]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
x86emul: adjust 2nd param of idiv_dbl()
authorJan Beulich <jbeulich@suse.com>
Thu, 8 Aug 2024 11:27:25 +0000 (13:27 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 8 Aug 2024 11:27:25 +0000 (13:27 +0200)
-LONG_MIN cannot be represented in a long and hence is UB, for being one
larger than LONG_MAX.

The caller passing an unsigned long and the 1st param also being (array
of) unsigned long, change the 2nd param accordingly while adding the
sole necessary cast. This was the original form of the function anyway.

Fixes: 5644ce014223 ("x86emul: relax asm() constraints")
Oss-fuzz: 70923
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/x86/x86_emulate/x86_emulate.c

index f0829a19d4c1adc5e6afa486cad64cff1aaa3c9f..a0deafbd3b99093372f74c09cfb50141416368fa 100644 (file)
@@ -607,9 +607,9 @@ static bool div_dbl(unsigned long u[2], unsigned long v)
  * NB. We don't use idiv directly as it's moderately hard to work out
  *     ahead of time whether it will #DE, which we cannot allow to happen.
  */
-static bool idiv_dbl(unsigned long u[2], long v)
+static bool idiv_dbl(unsigned long u[2], unsigned long v)
 {
-    bool negu = (long)u[1] < 0, negv = v < 0;
+    bool negu = (long)u[1] < 0, negv = (long)v < 0;
 
     /* u = abs(u) */
     if ( negu )