[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/50] target/i386: Assert CODE64 for x86_64 user-only
From: |
Richard Henderson |
Subject: |
[PULL 12/50] target/i386: Assert CODE64 for x86_64 user-only |
Date: |
Wed, 19 May 2021 13:30:12 -0500 |
For x86_64 user-only, there is no way to leave 64-bit mode.
Without x86_64, there is no way to enter 64-bit mode. There is
an existing macro to aid with that; simply place it in the right
place in the ifdef chain.
Since we're adding an accessor macro, pull the value directly out
of flags when we're not assuming a constant.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210514151342.384376-13-richard.henderson@linaro.org>
---
target/i386/tcg/translate.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 7b5031f647..e3907f9066 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -41,11 +41,9 @@
#define PREFIX_VEX 0x20
#ifdef TARGET_X86_64
-#define CODE64(s) ((s)->code64)
#define REX_X(s) ((s)->rex_x)
#define REX_B(s) ((s)->rex_b)
#else
-#define CODE64(s) 0
#define REX_X(s) 0
#define REX_B(s) 0
#endif
@@ -102,7 +100,6 @@ typedef struct DisasContext {
#ifdef TARGET_X86_64
int lma; /* long mode active */
- int code64; /* 64 bit code segment */
int rex_x, rex_b;
#endif
int vex_l; /* vex vector length */
@@ -165,6 +162,13 @@ typedef struct DisasContext {
#define CODE32(S) (((S)->flags & HF_CS32_MASK) != 0)
#define SS32(S) (((S)->flags & HF_SS32_MASK) != 0)
#endif
+#if !defined(TARGET_X86_64)
+#define CODE64(S) false
+#elif defined(CONFIG_USER_ONLY)
+#define CODE64(S) true
+#else
+#define CODE64(S) (((S)->flags & HF_CS64_MASK) != 0)
+#endif
static void gen_eob(DisasContext *s);
static void gen_jr(DisasContext *s, TCGv dest);
@@ -8497,6 +8501,7 @@ static void i386_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cpu)
g_assert(IOPL(dc) == iopl);
g_assert(VM86(dc) == ((flags & HF_VM_MASK) != 0));
g_assert(CODE32(dc) == ((flags & HF_CS32_MASK) != 0));
+ g_assert(CODE64(dc) == ((flags & HF_CS64_MASK) != 0));
g_assert(SS32(dc) == ((flags & HF_SS32_MASK) != 0));
dc->addseg = (flags >> HF_ADDSEG_SHIFT) & 1;
@@ -8518,7 +8523,6 @@ static void i386_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cpu)
dc->cpuid_xsave_features = env->features[FEAT_XSAVE];
#ifdef TARGET_X86_64
dc->lma = (flags >> HF_LMA_SHIFT) & 1;
- dc->code64 = (flags >> HF_CS64_SHIFT) & 1;
#endif
dc->jmp_opt = !(dc->tf || dc->base.singlestep_enabled ||
(flags & HF_INHIBIT_IRQ_MASK));
--
2.25.1
- [PULL 02/50] target/i386: Split out check_cpl0, (continued)
- [PULL 02/50] target/i386: Split out check_cpl0, Richard Henderson, 2021/05/19
- [PULL 03/50] target/i386: Unify code paths for IRET, Richard Henderson, 2021/05/19
- [PULL 01/50] target/i386: Split out gen_exception_gpf, Richard Henderson, 2021/05/19
- [PULL 05/50] target/i386: Split out check_iopl, Richard Henderson, 2021/05/19
- [PULL 08/50] target/i386: Assert IOPL is 0 for user-only, Richard Henderson, 2021/05/19
- [PULL 07/50] target/i386: Assert CPL is 3 for user-only, Richard Henderson, 2021/05/19
- [PULL 06/50] target/i386: Assert PE is set for user-only, Richard Henderson, 2021/05/19
- [PULL 10/50] target/i386: Assert CODE32 for x86_64 user-only, Richard Henderson, 2021/05/19
- [PULL 11/50] target/i386: Assert SS32 for x86_64 user-only, Richard Henderson, 2021/05/19
- [PULL 13/50] target/i386: Assert LMA for x86_64 user-only, Richard Henderson, 2021/05/19
- [PULL 12/50] target/i386: Assert CODE64 for x86_64 user-only,
Richard Henderson <=
- [PULL 16/50] target/i386: Tidy REX_B, REX_X definition, Richard Henderson, 2021/05/19
- [PULL 09/50] target/i386: Assert !VM86 for x86_64 user-only, Richard Henderson, 2021/05/19
- [PULL 14/50] target/i386: Assert !ADDSEG for x86_64 user-only, Richard Henderson, 2021/05/19
- [PULL 18/50] target/i386: Move rex_w into DisasContext, Richard Henderson, 2021/05/19
- [PULL 17/50] target/i386: Move rex_r into DisasContext, Richard Henderson, 2021/05/19
- [PULL 15/50] target/i386: Introduce REX_PREFIX, Richard Henderson, 2021/05/19
- [PULL 22/50] target/i386: Reduce DisasContext.prefix to uint8_t, Richard Henderson, 2021/05/19
- [PULL 23/50] target/i386: Reduce DisasContext.vex_[lv] to uint8_t, Richard Henderson, 2021/05/19
- [PULL 21/50] target/i386: Reduce DisasContext.override to int8_t, Richard Henderson, 2021/05/19
- [PULL 29/50] target/i386: Add stub generator for helper_set_dr, Richard Henderson, 2021/05/19