public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses
@ 2022-05-16 14:43 Janis Schoetterl-Glausch
  2022-05-17 12:02 ` Claudio Imbrenda
  0 siblings, 1 reply; 7+ messages in thread
From: Janis Schoetterl-Glausch @ 2022-05-16 14:43 UTC (permalink / raw)
  To: Thomas Huth, Janosch Frank, Claudio Imbrenda
  Cc: Janis Schoetterl-Glausch, David Hildenbrand, kvm, linux-s390

gcc 12 warns if a memory operand to inline asm points to memory in the
first 4k bytes. However, in our case, these operands are fine, either
because we actually want to use that memory, or expect and handle the
resulting exception.
Therefore, silence the warning.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
---

Alternatives:
 * Use memory clobber instead of memory output
   Use address in register input instead of memory input
       (may require WRITE_ONCE)
 * Disable the warning globally
 * Don't use gcc 12.0, with newer versions --param=min-pagesize=0 might
   avoid the problem

 lib/s390x/asm/cpacf.h | 7 +++++++
 s390x/skey.c          | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/s390x/asm/cpacf.h b/lib/s390x/asm/cpacf.h
index 685262b0..02e603c8 100644
--- a/lib/s390x/asm/cpacf.h
+++ b/lib/s390x/asm/cpacf.h
@@ -152,6 +152,12 @@ static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mas
 	register unsigned long r0 asm("0") = 0;	/* query function */
 	register unsigned long r1 asm("1") = (unsigned long) mask;
 
+/*
+ * gcc 12.0.1 warns if mask is < 4k.
+ * We use such addresses to test invalid or protected mask arguments.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
 	asm volatile(
 		"	spm 0\n" /* pckmo doesn't change the cc */
 		/* Parameter regs are ignored, but must be nonzero and unique */
@@ -160,6 +166,7 @@ static __always_inline void __cpacf_query(unsigned int opcode, cpacf_mask_t *mas
 		: "=m" (*mask)
 		: [fc] "d" (r0), [pba] "a" (r1), [opc] "i" (opcode)
 		: "cc");
+#pragma GCC diagnostic pop
 }
 
 static inline int __cpacf_check_opcode(unsigned int opcode)
diff --git a/s390x/skey.c b/s390x/skey.c
index 32bf1070..7aa91d19 100644
--- a/s390x/skey.c
+++ b/s390x/skey.c
@@ -242,12 +242,19 @@ static void test_store_cpu_address(void)
  */
 static void set_prefix_key_1(uint32_t *prefix_ptr)
 {
+/*
+ * gcc 12.0.1 warns if prefix_ptr is < 4k.
+ * We need such addresses to test fetch protection override.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
 	asm volatile (
 		"spka	0x10\n\t"
 		"spx	%0\n\t"
 		"spka	0\n"
 	     :: "Q" (*prefix_ptr)
 	);
+#pragma GCC diagnostic pop
 }
 
 /*

base-commit: c315f52b88b967cfb4cd58f3b4e1987378c47f3b
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-20 14:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-16 14:43 [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses Janis Schoetterl-Glausch
2022-05-17 12:02 ` Claudio Imbrenda
2022-05-17 16:09   ` Thomas Huth
2022-05-18  5:17     ` Claudio Imbrenda
2022-05-18 11:07     ` Janis Schoetterl-Glausch
2022-05-19  9:46       ` Thomas Huth
2022-05-20 14:08         ` Janis Schoetterl-Glausch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox