* [PATCH] x86/xen: Remove undefined behavior in setup_features()
@ 2022-06-17 10:30 Julien Grall
2022-06-17 10:32 ` Juergen Gross
2022-06-23 13:00 ` Juergen Gross
0 siblings, 2 replies; 3+ messages in thread
From: Julien Grall @ 2022-06-17 10:30 UTC (permalink / raw)
To: xen-devel
Cc: sstabellini, jgross, oleksandr_tyshchenko, linux-kernel, Julien Grall
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86/xen: Remove undefined behavior in setup_features()
2022-06-17 10:30 [PATCH] x86/xen: Remove undefined behavior in setup_features() Julien Grall
@ 2022-06-17 10:32 ` Juergen Gross
2022-06-23 13:00 ` Juergen Gross
1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2022-06-17 10:32 UTC (permalink / raw)
To: Julien Grall, xen-devel
Cc: sstabellini, oleksandr_tyshchenko, linux-kernel, Julien Grall
[-- Attachment #1.1.1: Type: text/plain, Size: 306 bytes --]
On 17.06.22 12:30, Julien Grall wrote:
> 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>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] x86/xen: Remove undefined behavior in setup_features()
2022-06-17 10:30 [PATCH] x86/xen: Remove undefined behavior in setup_features() Julien Grall
2022-06-17 10:32 ` Juergen Gross
@ 2022-06-23 13:00 ` Juergen Gross
1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2022-06-23 13:00 UTC (permalink / raw)
To: Julien Grall, xen-devel
Cc: sstabellini, oleksandr_tyshchenko, linux-kernel, Julien Grall
[-- Attachment #1.1.1: Type: text/plain, Size: 299 bytes --]
On 17.06.22 12:30, Julien Grall wrote:
> 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>
Pushed to xen/tip.git for-linus-5.19a
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3149 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-23 13:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 10:30 [PATCH] x86/xen: Remove undefined behavior in setup_features() Julien Grall
2022-06-17 10:32 ` Juergen Gross
2022-06-23 13:00 ` Juergen Gross
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®