]> xenbits.xensource.com Git - xen.git/commit
x86emul: avoid UB shifts in FLDENV/FRSTOR handling
authorJan Beulich <jbeulich@suse.com>
Wed, 30 Apr 2025 06:46:21 +0000 (08:46 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 30 Apr 2025 06:46:21 +0000 (08:46 +0200)
commitd00fc019b6eba68bd7f2186a6427e5a005ce989f
tree545b01a8f88d8ca790625e2b59ddc81cede7ff53
parentff3e5dfa7c2d09825dfd8545d49920830fa71243
x86emul: avoid UB shifts in FLDENV/FRSTOR handling

16-bit quantities, no matter whether expressed as uint16_t or as
bitfield, will be promoted to plain int before doing any arithmetic on
them. Shifting such values by 16 will therefore shift into the sign bit,
which is UB if that bit becomes set. To account for all reads and all
writes accessing opposite members of the same union, introduce yet more
local variables to reduce the shift counts to 12.

Fixes: be55ed744ed8 ("x86emul: support FLDENV and FRSTOR")
Reported-by: Fabian Specht <f.specht@tum.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
xen/arch/x86/x86_emulate/blk.c