xref: /kvm-unit-tests/s390x/snippets/lib/snippet-exit.h (revision 1f08a91a41402b0e032ecce8ed1b5952cbfca0ea)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Functionality for exiting the snippet.
4  *
5  * Copyright IBM Corp. 2023
6  */
7 
8 #ifndef _S390X_SNIPPET_LIB_EXIT_H_
9 #define _S390X_SNIPPET_LIB_EXIT_H_
10 
11 #include <asm/arch_def.h>
12 #include <asm/barrier.h>
13 
force_exit(void)14 static inline void force_exit(void)
15 {
16 	mb(); /* host may read any memory written by the guest before */
17 	diag44();
18 	mb(); /* allow host to modify guest memory */
19 }
20 
force_exit_value(uint64_t val)21 static inline void force_exit_value(uint64_t val)
22 {
23 	mb(); /* host may read any memory written by the guest before */
24 	diag500(val);
25 	mb(); /* allow host to modify guest memory */
26 }
27 
28 #endif /* _S390X_SNIPPET_LIB_EXIT_H_ */
29