On 9/27/26 05:36, Mark Cave-Ayland wrote:
When the effective address calculation was simplified in commit 55a15eb3504
("target/i386/tcg: simplify effective address calculation") the refactoring
accidentally introduced the ADDSEG() macro into the CS base address inclusion
test.
Fix the logic in gen_lea_v_seg_dest() to use CODE64() instead of ADDSEG() for
the CS base address inclusion test, and at the same time split it into a switch
statement to make the logic easier to follow.
Fixes: 55a15eb3504 ("target/i386/tcg: simplify effective address calculation")
Signed-off-by: Mark Cave-Ayland <[email protected]>
---
target/i386/tcg/translate.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 192cf43215e..2d3fffeab7b 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -605,7 +605,25 @@ static void gen_lea_v_seg_dest(DisasContext *s, MemOp
aflag, TCGv dest, TCGv a0,
ovr_seg = def_seg;
}
- has_base = ovr_seg >= R_FS || (ovr_seg >= 0 && ADDSEG(s));
+ switch (ovr_seg) {
+ case R_DS:
+ case R_ES:
+ case R_SS:
+ has_base = ADDSEG(s);
+ break;
+ case R_CS:
+ has_base = !CODE64(s);
I suppose one slight improvement could be
has_base = s->cs_base != 0;
since we know the value. It's more rearrangement than it's worth to add
a non-zero constant instead of the seg_base temp.
Anyway,
Reviewed-by: Richard Henderson <[email protected]>
r~
+ break;
+ case R_FS:
+ case R_GS:
+ has_base = true;
+ break;
+ default:
+ assert(ovr_seg < 0);
+ has_base = false;
+ break;
+ }
+
easize = CODE64(s) ? MO_64 : MO_32;
if (has_base) {