Skip to content

Commit 6c51df5

Browse files
zeff-irHarsh Prateek Bora
authored andcommitted
target/ppc: use MAKE_64BIT_MASK for mcrfs exception clear mask
In gen_mcrfs() the FPSCR nibble mask is computed as: `~((0xF << shift) & FP_EX_CLEAR_BITS)` Here, 0xF is of type int, so the left shift is performed in 32-bit signed arithmetic. For bfa=0 we get shift=28, and (0xF << 28) = 0xF0000000, which is not representable as a 32-bit signed int. Static analyzers flag this as a potential integer overflow. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Denis Sergeev <zeff@altlinux.org> Reviewed-by: Chinmay Rath <rathc@linux.ibm.com> Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Link: https://lore.kernel.org/r/20250915080118.29898-1-zeff@altlinux.org Message-ID: <20250915080118.29898-1-zeff@altlinux.org>
1 parent 264a604 commit 6c51df5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

target/ppc/translate/fp-impl.c.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static void gen_mcrfs(DisasContext *ctx)
396396
tcg_gen_extu_tl_i64(tnew_fpscr, cpu_fpscr);
397397
/* Only the exception bits (including FX) should be cleared if read */
398398
tcg_gen_andi_i64(tnew_fpscr, tnew_fpscr,
399-
~((0xF << shift) & FP_EX_CLEAR_BITS));
399+
~(MAKE_64BIT_MASK(shift, 4) & FP_EX_CLEAR_BITS));
400400
/* FEX and VX need to be updated, so don't set fpscr directly */
401401
tmask = tcg_constant_i32(1 << nibble);
402402
gen_helper_store_fpscr(tcg_env, tnew_fpscr, tmask);

0 commit comments

Comments
 (0)