xref: /kvm-unit-tests/s390x/snippets/c/mvpg-snippet.c (revision 3df301615cead4142fe28629d86142de32fc6768)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Snippet used by the mvpg-sie.c test to check SIE PEI intercepts.
4  *
5  * Copyright (c) 2021 IBM Corp
6  *
7  * Authors:
8  *  Janosch Frank <frankja@linux.ibm.com>
9  */
10 
force_exit(void)11 static inline void force_exit(void)
12 {
13 	asm volatile("	diag	0,0,0x44\n");
14 }
15 
mvpg(unsigned long r0,void * dest,void * src)16 static inline int mvpg(unsigned long r0, void *dest, void *src)
17 {
18 	register unsigned long reg0 asm ("0") = r0;
19 	int cc;
20 
21 	asm volatile("	mvpg    %1,%2\n"
22 		     "	ipm     %0\n"
23 		     "	srl     %0,28"
24 		     : "=d" (cc) : "a" (dest), "a" (src), "d" (reg0)
25 		     : "memory", "cc");
26 	return cc;
27 }
28 
test_mvpg_real(void)29 static void test_mvpg_real(void)
30 {
31 	mvpg(0, (void *)0x5000, (void *)0x6000);
32 	force_exit();
33 }
34 
main(void)35 __attribute__((section(".text"))) int main(void)
36 {
37 	test_mvpg_real();
38 	test_mvpg_real();
39 	test_mvpg_real();
40 	return 0;
41 }
42