target/i386/tcg: Reorg push/pop within seg_helper.c
commit059368bcf589f4c6cba860516f57cec0b51c1fa1
authorRichard Henderson <richard.henderson@linaro.org>
Mon, 17 Jun 2024 16:12:10 +0000 (17 09:12 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 16 Jul 2024 16:18:24 +0000 (16 18:18 +0200)
tree08e7354d53c49b47b72d1541ec52b801614be07b
parent312ef3243e3bae07e49314efb2854f6f17080ec5
target/i386/tcg: Reorg push/pop within seg_helper.c

Interrupts and call gates should use accesses with the DPL as
the privilege level.  While computing the applicable MMU index
is easy, the harder thing is how to plumb it in the code.

One possibility could be to add a single argument to the PUSH* macros
for the privilege level, but this is repetitive and risks confusion
between the involved privilege levels.

Another possibility is to pass both CPL and DPL, and adjusting both
PUSH* and POP* to use specific privilege levels (instead of using
cpu_{ld,st}*_data). This makes the code more symmetric.

However, a more complicated but much nicer approach is to use a structure
to contain the stack parameters, env, unwind return address, and rewrite
the macros into functions.  The struct provides an easy home for the MMU
index as well.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Link: https://lore.kernel.org/r/20240617161210.4639-4-richard.henderson@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/seg_helper.c