All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: xen-devel@lists.xenproject.org
Cc: sstabellini@kernel.org, jgross@suse.com,
	oleksandr_tyshchenko@epam.com, linux-kernel@vger.kernel.org,
	Julien Grall <jgrall@amazon.com>
Subject: [PATCH] x86/xen: Remove undefined behavior in setup_features()
Date: Fri, 17 Jun 2022 11:30:37 +0100	[thread overview]
Message-ID: <20220617103037.57828-1-julien@xen.org> (raw)

From: Julien Grall <jgrall@amazon.com>

1 << 31 is undefined. So switch to 1U << 31.

Fixes: 5ead97c84fa7 ("xen: Core Xen implementation")
Signed-off-by: Julien Grall <jgrall@amazon.com>

---

This was actually caught because I wasn't able to boot Linux 5.18
and onwards when built with GCC 7.3 and UBSAN enabled. There was
no message but instead an early crash because the instruction "cli
was used too early.

This issue has always been there but it only shows after Linux
switched from C89 to C11.
---
 drivers/xen/features.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/features.c b/drivers/xen/features.c
index 7b591443833c..87f1828d40d5 100644
--- a/drivers/xen/features.c
+++ b/drivers/xen/features.c
@@ -42,7 +42,7 @@ void xen_setup_features(void)
 		if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
 			break;
 		for (j = 0; j < 32; j++)
-			xen_features[i * 32 + j] = !!(fi.submap & 1<<j);
+			xen_features[i * 32 + j] = !!(fi.submap & 1U << j);
 	}
 
 	if (xen_pv_domain()) {
-- 
2.32.0


             reply	other threads:[~2022-06-17 11:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-17 10:30 Julien Grall [this message]
2022-06-17 10:32 ` [PATCH] x86/xen: Remove undefined behavior in setup_features() Juergen Gross
2022-06-23 13:00 ` Juergen Gross

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=20220617103037.57828-1-julien@xen.org \
    --to=julien@xen.org \
    --cc=jgrall@amazon.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.