xen: fix generated code for calling hypercall handlers
authorJuergen Gross <jgross@suse.com>
Fri, 4 Nov 2022 07:54:57 +0000 (08:54 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Nov 2022 07:54:57 +0000 (08:54 +0100)
The code generated for the call_handlers_*() macros needs to avoid
undefined behavior when multiple handlers share the same priority.
The issue is the hypercall number being unverified fed into the macros
and then used to set a mask via "mask = 1ULL << <hypercall-number>".

Avoid a shift amount of more than 63 by setting mask to zero in case
the hypercall number is too large.

Fixes: eca1f00d0227 ("xen: generate hypercall interface related code")
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Henry Wang <Henry.Wang@arm.com>
xen/scripts/gen_hypercall.awk

index 34840c514fd639976f27b2250c9e609a20cf7aef..9f7cfa298a6d00c914e62ab972b89e1e90683664 100644 (file)
@@ -263,7 +263,7 @@ END {
         printf("#define call_handlers_%s(num, ret, a1, a2, a3, a4, a5) \\\n", ca);
         printf("({ \\\n");
         if (need_mask)
-            printf("    uint64_t mask = 1ULL << num; \\\n");
+            printf("    uint64_t mask = (num) > 63 ? 0 : 1ULL << (num); \\\n");
         printf("    ");
         for (pl = 1; pl <= n_prios[ca]; pl++) {
             if (prios[ca, p_list[pl]] > 1) {