public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
To: Thomas Huth <thuth@redhat.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org
Subject: [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses
Date: Mon, 16 May 2022 16:43:32 +0200	[thread overview]
Message-ID: <20220516144332.3785876-1-scgl@linux.ibm.com> (raw)

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


             reply	other threads:[~2022-05-16 14:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16 14:43 Janis Schoetterl-Glausch [this message]
2022-05-17 12:02 ` [kvm-unit-tests PATCH] s390x: Ignore gcc 12 warnings for low addresses 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

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=20220516144332.3785876-1-scgl@linux.ibm.com \
    --to=scgl@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=thuth@redhat.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