xref: /kvm-unit-tests/lib/s390x/snippet.h (revision dbd3800490429358367c717669aab76678429ef1)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Snippet definitions
4  *
5  * Copyright IBM Corp. 2021
6  * Author: Janosch Frank <frankja@linux.ibm.com>
7  */
8 
9 #ifndef _S390X_SNIPPET_H_
10 #define _S390X_SNIPPET_H_
11 
12 /* This macro cuts down the length of the pointers to snippets */
13 #define SNIPPET_NAME_START(type, file) \
14 	_binary_s390x_snippets_##type##_##file##_gbin_start
15 #define SNIPPET_NAME_END(type, file) \
16 	_binary_s390x_snippets_##type##_##file##_gbin_end
17 
18 /* Returns the length of the snippet */
19 #define SNIPPET_LEN(type, file) \
20 	((uintptr_t)SNIPPET_NAME_END(type, file) - (uintptr_t)SNIPPET_NAME_START(type, file))
21 
22 /*
23  * C snippet instructions start at 0x4000 due to the prefix and the
24  * stack being before that. ASM snippets don't strictly need a stack
25  * but keeping the starting address the same means less code.
26  */
27 #define SNIPPET_ENTRY_ADDR 0x4000
28 
29 /* Standard entry PSWs for snippets which can simply be copied into the guest PSW */
30 static const struct psw snippet_psw = {
31 	.mask = PSW_MASK_64,
32 	.addr = SNIPPET_ENTRY_ADDR,
33 };
34 #endif
35