[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 19/21] target/i386: Remove dead assignment to ss in do_interrupt64
From: |
Peter Maydell |
Subject: |
[PULL 19/21] target/i386: Remove dead assignment to ss in do_interrupt64() |
Date: |
Tue, 30 Jul 2024 10:40:18 +0100 |
Coverity points out that in do_interrupt64() in the "to inner
privilege" codepath we set "ss = 0", but because we also set
"new_stack = 1" there, later in the function we will always override
that value of ss with "ss = 0 | dpl".
Remove the unnecessary initialization of ss, which allows us to
reduce the scope of the variable to only where it is used. Borrow a
comment from helper_lcall_protected() that explains what "0 | dpl"
means here.
Resolves: Coverity CID 1527395
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20240723162525.1585743-1-peter.maydell@linaro.org
---
target/i386/tcg/seg_helper.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c
index aac092a356b..bab552cd535 100644
--- a/target/i386/tcg/seg_helper.c
+++ b/target/i386/tcg/seg_helper.c
@@ -926,7 +926,7 @@ static void do_interrupt64(CPUX86State *env, int intno, int
is_int,
target_ulong ptr;
int type, dpl, selector, cpl, ist;
int has_error_code, new_stack;
- uint32_t e1, e2, e3, ss, eflags;
+ uint32_t e1, e2, e3, eflags;
target_ulong old_eip, offset;
bool set_rf;
StackAccess sa;
@@ -1007,7 +1007,6 @@ static void do_interrupt64(CPUX86State *env, int intno,
int is_int,
/* to inner privilege */
new_stack = 1;
sa.sp = get_rsp_from_tss(env, ist != 0 ? ist + 3 : dpl);
- ss = 0;
} else {
/* to same privilege */
if (env->eflags & VM_MASK) {
@@ -1040,7 +1039,7 @@ static void do_interrupt64(CPUX86State *env, int intno,
int is_int,
env->eflags &= ~(TF_MASK | VM_MASK | RF_MASK | NT_MASK);
if (new_stack) {
- ss = 0 | dpl;
+ uint32_t ss = 0 | dpl; /* SS = NULL selector with RPL = new CPL */
cpu_x86_load_seg_cache(env, R_SS, ss, 0, 0, dpl << DESC_DPL_SHIFT);
}
env->regs[R_ESP] = sa.sp;
--
2.34.1
- [PULL 03/21] target/arm/kvm: Set PMU for host only when available, (continued)
- [PULL 03/21] target/arm/kvm: Set PMU for host only when available, Peter Maydell, 2024/07/30
- [PULL 04/21] target/arm/kvm: Do not silently remove PMU, Peter Maydell, 2024/07/30
- [PULL 08/21] hw/misc/bcm2835_property: Fix handling of FRAMEBUFFER_SET_PALETTE, Peter Maydell, 2024/07/30
- [PULL 06/21] hvf: arm: Properly disable PMU, Peter Maydell, 2024/07/30
- [PULL 14/21] target/arm: Avoid shifts by -1 in tszimm_shr() and tszimm_shl(), Peter Maydell, 2024/07/30
- [PULL 02/21] hw/arm/smmuv3: Assert input to oas2bits() is valid, Peter Maydell, 2024/07/30
- [PULL 05/21] hvf: arm: Raise an exception for sysreg by default, Peter Maydell, 2024/07/30
- [PULL 07/21] hvf: arm: Do not advance PC when raising an exception, Peter Maydell, 2024/07/30
- [PULL 15/21] target/arm: Ignore SMCR_EL2.LEN and SVCR_EL2.LEN if EL2 is not enabled, Peter Maydell, 2024/07/30
- [PULL 18/21] target/m68k: avoid shift into sign bit in dump_address_map(), Peter Maydell, 2024/07/30
- [PULL 19/21] target/i386: Remove dead assignment to ss in do_interrupt64(),
Peter Maydell <=
- [PULL 20/21] target/sh4: Avoid shift into sign bit in update_itlb_use(), Peter Maydell, 2024/07/30
- [PULL 21/21] system/physmem: Where we assume we have a RAM MR, assert it, Peter Maydell, 2024/07/30
- [PULL 09/21] hw/misc/bcm2835_property: Avoid overflow in OTP access properties, Peter Maydell, 2024/07/30
- [PULL 11/21] hw/misc/bcm2835_property: Reduce scope of variables in mbox push function, Peter Maydell, 2024/07/30
- [PULL 10/21] hw/misc/bcm2835_property: Restrict scope of start_num, number, otp_row, Peter Maydell, 2024/07/30
- [PULL 12/21] target/arm: Don't assert for 128-bit tile accesses when SVL is 128, Peter Maydell, 2024/07/30
- [PULL 13/21] target/arm: Fix UMOPA/UMOPS of 16-bit values, Peter Maydell, 2024/07/30
- [PULL 16/21] target/tricore: Use unsigned types for bitops in helper_eq_b(), Peter Maydell, 2024/07/30
- [PULL 17/21] target/xtensa: Make use of 'segment' in pptlb helper less confusing, Peter Maydell, 2024/07/30
- Re: [PULL 00/21] target-arm queue, Richard Henderson, 2024/07/30