Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: kvm@vger.kernel.org
Cc: linux-s390@vger.kernel.org, imbrenda@linux.ibm.com,
	borntraeger@linux.ibm.com, nrb@linux.ibm.com
Subject: [kvm-unit-tests PATCH 1/2] lib: s390x: snippet: Add snippet declaration macro
Date: Tue,  1 Sep 2026 14:20:25 +0000	[thread overview]
Message-ID: <20260901142538.42553-2-frankja@linux.ibm.com> (raw)
In-Reply-To: <20260901142538.42553-1-frankja@linux.ibm.com>

Improving readability.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 lib/s390x/snippet.h |  9 +++++++++
 s390x/mvpg-sie.c    |  3 +--
 s390x/pv-diags.c    | 15 +++------------
 s390x/pv-edat1.c    |  5 +----
 s390x/pv-icptcode.c | 30 ++++++------------------------
 s390x/pv-ipl.c      |  5 +----
 s390x/sie-dat.c     |  3 +--
 s390x/spec_ex-sie.c |  3 +--
 s390x/stfle-sie.c   |  3 +--
 9 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h
index 83d74387..6f82a873 100644
--- a/lib/s390x/snippet.h
+++ b/lib/s390x/snippet.h
@@ -30,6 +30,15 @@
 #define SNIPPET_HDR_LEN(type, file) \
 	((uintptr_t)SNIPPET_HDR_END(type, file) - (uintptr_t)SNIPPET_HDR_START(type, file))
 
+#define SNIPPET_DECLARE(type, file)				\
+	extern const char SNIPPET_NAME_START(type, file)[];	\
+	extern const char SNIPPET_NAME_END(type, file)[]
+
+#define SNIPPET_DECLARE_PV(type, file)				\
+	SNIPPET_DECLARE(type, file);				\
+	extern const char SNIPPET_HDR_START(type, file)[];	\
+	extern const char SNIPPET_HDR_END(type, file)[]
+
 /*
  * Some of the UV memory needs to be allocated with >31 bit
  * addresses which means we need a lot more memory than other
diff --git a/s390x/mvpg-sie.c b/s390x/mvpg-sie.c
index 21082c53..ec0737be 100644
--- a/s390x/mvpg-sie.c
+++ b/s390x/mvpg-sie.c
@@ -84,8 +84,7 @@ static void test_mvpg(void)
 
 static void setup_guest(void)
 {
-	extern const char SNIPPET_NAME_START(c, mvpg_snippet)[];
-	extern const char SNIPPET_NAME_END(c, mvpg_snippet)[];
+	SNIPPET_DECLARE(c, mvpg_snippet);
 	pgd_t *root;
 
 	setup_vm();
diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c
index b6f08dd2..e7cc0e85 100644
--- a/s390x/pv-diags.c
+++ b/s390x/pv-diags.c
@@ -18,10 +18,7 @@ static struct vm vm;
 
 static void test_diag_500(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_diag_500)[];
-	extern const char SNIPPET_NAME_END(asm, pv_diag_500)[];
-	extern const char SNIPPET_HDR_START(asm, pv_diag_500)[];
-	extern const char SNIPPET_HDR_END(asm, pv_diag_500)[];
+	SNIPPET_DECLARE_PV(asm, pv_diag_500);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_500);
 	int size_gbin = SNIPPET_LEN(asm, pv_diag_500);
 
@@ -69,10 +66,7 @@ static void test_diag_500(void)
 
 static void test_diag_288(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_diag_288)[];
-	extern const char SNIPPET_NAME_END(asm, pv_diag_288)[];
-	extern const char SNIPPET_HDR_START(asm, pv_diag_288)[];
-	extern const char SNIPPET_HDR_END(asm, pv_diag_288)[];
+	SNIPPET_DECLARE_PV(asm, pv_diag_288);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_288);
 	int size_gbin = SNIPPET_LEN(asm, pv_diag_288);
 
@@ -110,10 +104,7 @@ static void test_diag_288(void)
 
 static void test_diag_yield(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_diag_yield)[];
-	extern const char SNIPPET_NAME_END(asm, pv_diag_yield)[];
-	extern const char SNIPPET_HDR_START(asm, pv_diag_yield)[];
-	extern const char SNIPPET_HDR_END(asm, pv_diag_yield)[];
+	SNIPPET_DECLARE_PV(asm, pv_diag_yield);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_yield);
 	int size_gbin = SNIPPET_LEN(asm, pv_diag_yield);
 
diff --git a/s390x/pv-edat1.c b/s390x/pv-edat1.c
index ff762c75..05afbb41 100644
--- a/s390x/pv-edat1.c
+++ b/s390x/pv-edat1.c
@@ -36,10 +36,7 @@
 static struct vm vm;
 static pgd_t *root;
 
-extern const char SNIPPET_NAME_START(c, pv_memhog)[];
-extern const char SNIPPET_NAME_END(c, pv_memhog)[];
-extern const char SNIPPET_HDR_START(c, pv_memhog)[];
-extern const char SNIPPET_HDR_END(c, pv_memhog)[];
+SNIPPET_DECLARE_PV(c, pv_memhog);
 
 static void init_snippet(struct vm *vm) {
 	const unsigned long size_hdr = SNIPPET_HDR_LEN(c, pv_memhog);
diff --git a/s390x/pv-icptcode.c b/s390x/pv-icptcode.c
index bdef3a05..35bfde56 100644
--- a/s390x/pv-icptcode.c
+++ b/s390x/pv-icptcode.c
@@ -33,10 +33,7 @@ static struct vm vm, vm2;
  */
 static void test_validity_timing(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_icpt_vir_timing)[];
-	extern const char SNIPPET_NAME_END(asm, pv_icpt_vir_timing)[];
-	extern const char SNIPPET_HDR_START(asm, pv_icpt_vir_timing)[];
-	extern const char SNIPPET_HDR_END(asm, pv_icpt_vir_timing)[];
+	SNIPPET_DECLARE_PV(asm, pv_icpt_vir_timing);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_vir_timing);
 	int size_gbin = SNIPPET_LEN(asm, pv_icpt_vir_timing);
 	uint64_t time_exit, time_entry, tmp;
@@ -82,10 +79,7 @@ static void run_loop(void)
 
 static void test_validity_already_running(void)
 {
-	extern const char SNIPPET_NAME_START(asm, loop)[];
-	extern const char SNIPPET_NAME_END(asm, loop)[];
-	extern const char SNIPPET_HDR_START(asm, loop)[];
-	extern const char SNIPPET_HDR_END(asm, loop)[];
+	SNIPPET_DECLARE_PV(asm, loop);
 	int size_hdr = SNIPPET_HDR_LEN(asm, loop);
 	int size_gbin = SNIPPET_LEN(asm, loop);
 	struct psw psw = {
@@ -131,10 +125,7 @@ out:
 /* Tests if a vcpu handle from another configuration results in a validity intercept. */
 static void test_validity_handle_not_in_config(void)
 {
-	extern const char SNIPPET_NAME_START(asm, icpt_loop)[];
-	extern const char SNIPPET_NAME_END(asm, icpt_loop)[];
-	extern const char SNIPPET_HDR_START(asm, icpt_loop)[];
-	extern const char SNIPPET_HDR_END(asm, icpt_loop)[];
+	SNIPPET_DECLARE_PV(asm, icpt_loop);
 	int size_hdr = SNIPPET_HDR_LEN(asm, icpt_loop);
 	int size_gbin = SNIPPET_LEN(asm, icpt_loop);
 
@@ -173,10 +164,7 @@ static void test_validity_handle_not_in_config(void)
 /* Tests if a wrong vm or vcpu handle results in a validity intercept. */
 static void test_validity_seid(void)
 {
-	extern const char SNIPPET_NAME_START(asm, icpt_loop)[];
-	extern const char SNIPPET_NAME_END(asm, icpt_loop)[];
-	extern const char SNIPPET_HDR_START(asm, icpt_loop)[];
-	extern const char SNIPPET_HDR_END(asm, icpt_loop)[];
+	SNIPPET_DECLARE_PV(asm, icpt_loop);
 	int size_hdr = SNIPPET_HDR_LEN(asm, icpt_loop);
 	int size_gbin = SNIPPET_LEN(asm, icpt_loop);
 	int fails = 0;
@@ -224,10 +212,7 @@ static void test_validity_seid(void)
  */
 static void test_validity_asce(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_icpt_112)[];
-	extern const char SNIPPET_NAME_END(asm, pv_icpt_112)[];
-	extern const char SNIPPET_HDR_START(asm, pv_icpt_112)[];
-	extern const char SNIPPET_HDR_END(asm, pv_icpt_112)[];
+	SNIPPET_DECLARE_PV(asm, pv_icpt_112);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_112);
 	int size_gbin = SNIPPET_LEN(asm, pv_icpt_112);
 	uint64_t asce_old, asce_new;
@@ -311,10 +296,7 @@ static void run_icpt_122_tests_prefix(unsigned long prefix)
 
 static void test_icpt_112(void)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_icpt_112)[];
-	extern const char SNIPPET_NAME_END(asm, pv_icpt_112)[];
-	extern const char SNIPPET_HDR_START(asm, pv_icpt_112)[];
-	extern const char SNIPPET_HDR_END(asm, pv_icpt_112)[];
+	SNIPPET_DECLARE_PV(asm, pv_icpt_112);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_icpt_112);
 	int size_gbin = SNIPPET_LEN(asm, pv_icpt_112);
 
diff --git a/s390x/pv-ipl.c b/s390x/pv-ipl.c
index 1219573f..af2cfbcf 100644
--- a/s390x/pv-ipl.c
+++ b/s390x/pv-ipl.c
@@ -19,10 +19,7 @@ static struct vm vm;
 
 static void test_diag_308(int subcode)
 {
-	extern const char SNIPPET_NAME_START(asm, pv_diag_308)[];
-	extern const char SNIPPET_NAME_END(asm, pv_diag_308)[];
-	extern const char SNIPPET_HDR_START(asm, pv_diag_308)[];
-	extern const char SNIPPET_HDR_END(asm, pv_diag_308)[];
+	SNIPPET_DECLARE_PV(asm, pv_diag_308);
 	int size_hdr = SNIPPET_HDR_LEN(asm, pv_diag_308);
 	int size_gbin = SNIPPET_LEN(asm, pv_diag_308);
 	uint16_t rc, rrc;
diff --git a/s390x/sie-dat.c b/s390x/sie-dat.c
index a5ff0872..46d20dab 100644
--- a/s390x/sie-dat.c
+++ b/s390x/sie-dat.c
@@ -63,8 +63,7 @@ static void test_sie_dat(void)
 
 static void setup_guest(void)
 {
-	extern const char SNIPPET_NAME_START(c, sie_dat)[];
-	extern const char SNIPPET_NAME_END(c, sie_dat)[];
+	SNIPPET_DECLARE(c, sie_dat);
 	uint64_t guest_max_addr;
 	pgd_t *root;
 
diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c
index dd4ab77e..e79208df 100644
--- a/s390x/spec_ex-sie.c
+++ b/s390x/spec_ex-sie.c
@@ -21,8 +21,7 @@ static bool strict;
 
 static void setup_guest(void)
 {
-	extern const char SNIPPET_NAME_START(c, spec_ex)[];
-	extern const char SNIPPET_NAME_END(c, spec_ex)[];
+	SNIPPET_DECLARE(c, spec_ex);
 
 	setup_vm();
 
diff --git a/s390x/stfle-sie.c b/s390x/stfle-sie.c
index 3697e1ae..e3642078 100644
--- a/s390x/stfle-sie.c
+++ b/s390x/stfle-sie.c
@@ -20,8 +20,7 @@ static prng_state prng_s;
 
 static void setup_guest(void)
 {
-	extern const char SNIPPET_NAME_START(c, stfle)[];
-	extern const char SNIPPET_NAME_END(c, stfle)[];
+	SNIPPET_DECLARE(c, stfle);
 
 	setup_vm();
 	fac = alloc_pages_flags(0, AREA_DMA31);
-- 
2.53.0


  reply	other threads:[~2026-09-01 14:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 14:20 [kvm-unit-tests PATCH 0/2] lib: s390x: Add more snippet macros Janosch Frank
2026-09-01 14:20 ` Janosch Frank [this message]
2026-09-01 14:20 ` [kvm-unit-tests PATCH 2/2] lib: s390x: snippet: Add setup macro Janosch Frank

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260901142538.42553-2-frankja@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox