xref: /kvm-unit-tests/s390x/snippets/c/stfle.c (revision 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright IBM Corp. 2023
4  *
5  * Snippet used by the STLFE interpretive execution facilities test.
6  */
7 #include <libcflat.h>
8 #include <snippet-exit.h>
9 
main(void)10 int main(void)
11 {
12 	const unsigned int max_fac_len = 8;
13 	uint64_t len_arg = max_fac_len - 1;
14 	uint64_t res[max_fac_len + 1];
15 	uint64_t fac[max_fac_len];
16 
17 	asm volatile (" lgr	0,%[len]\n"
18 		"	stfle	%[fac]\n"
19 		"	lgr	%[len],0\n"
20 		: [fac] "=Q"(fac),
21 		  [len] "+d"(len_arg)
22 		:
23 		: "%r0", "cc"
24 	);
25 	res[0] = len_arg;
26 	memcpy(&res[1], fac, sizeof(fac));
27 	force_exit_value((uint64_t)&res);
28 	return 0;
29 }
30