[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 30/50] target/i386: Assert !SVME for user-only
From: |
Richard Henderson |
Subject: |
[PATCH 30/50] target/i386: Assert !SVME for user-only |
Date: |
Sun, 28 Feb 2021 15:23:01 -0800 |
Most of the VMM instructions are already disabled for
user-only, by being usable only from ring 0.
The spec is intentionally loose for VMMCALL, allowing
the VMM to define syscalls for user-only. However,
linux does not do so; VMMCALL is illegal.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/i386/tcg/translate.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 42b96a2669..3779da9042 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -138,10 +138,12 @@ typedef struct DisasContext {
#define PE(S) true
#define CPL(S) 3
#define IOPL(S) 0
+#define SVME(S) false
#else
#define PE(S) (((S)->flags & HF_PE_MASK) != 0)
#define CPL(S) ((S)->cpl)
#define IOPL(S) ((S)->iopl)
+#define SVME(S) (((S)->flags & HF_SVME_MASK) != 0)
#endif
#if defined(CONFIG_USER_ONLY) && defined(TARGET_X86_64)
#define VM86(S) false
@@ -7489,7 +7491,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xd8: /* VMRUN */
- if (!(s->flags & HF_SVME_MASK) || !PE(s)) {
+ if (!SVME(s) || !PE(s)) {
goto illegal_op;
}
if (!check_cpl0(s)) {
@@ -7504,7 +7506,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xd9: /* VMMCALL */
- if (!(s->flags & HF_SVME_MASK)) {
+ if (!SVME(s)) {
goto illegal_op;
}
gen_update_cc_op(s);
@@ -7513,7 +7515,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xda: /* VMLOAD */
- if (!(s->flags & HF_SVME_MASK) || !PE(s)) {
+ if (!SVME(s) || !PE(s)) {
goto illegal_op;
}
if (!check_cpl0(s)) {
@@ -7525,7 +7527,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xdb: /* VMSAVE */
- if (!(s->flags & HF_SVME_MASK) || !PE(s)) {
+ if (!SVME(s) || !PE(s)) {
goto illegal_op;
}
if (!check_cpl0(s)) {
@@ -7537,8 +7539,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xdc: /* STGI */
- if ((!(s->flags & HF_SVME_MASK)
- && !(s->cpuid_ext3_features & CPUID_EXT3_SKINIT))
+ if ((!SVME(s) && !(s->cpuid_ext3_features & CPUID_EXT3_SKINIT))
|| !PE(s)) {
goto illegal_op;
}
@@ -7552,7 +7553,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xdd: /* CLGI */
- if (!(s->flags & HF_SVME_MASK) || !PE(s)) {
+ if (!SVME(s) || !PE(s)) {
goto illegal_op;
}
if (!check_cpl0(s)) {
@@ -7564,8 +7565,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xde: /* SKINIT */
- if ((!(s->flags & HF_SVME_MASK)
- && !(s->cpuid_ext3_features & CPUID_EXT3_SKINIT))
+ if ((!SVME(s) && !(s->cpuid_ext3_features & CPUID_EXT3_SKINIT))
|| !PE(s)) {
goto illegal_op;
}
@@ -7575,7 +7575,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState
*cpu)
break;
case 0xdf: /* INVLPGA */
- if (!(s->flags & HF_SVME_MASK) || !PE(s)) {
+ if (!SVME(s) || !PE(s)) {
goto illegal_op;
}
if (!check_cpl0(s)) {
@@ -8510,6 +8510,7 @@ static void i386_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cpu)
g_assert(SS32(dc) == ((flags & HF_SS32_MASK) != 0));
g_assert(LMA(dc) == ((flags & HF_LMA_MASK) != 0));
g_assert(ADDSEG(dc) == ((flags & HF_ADDSEG_MASK) != 0));
+ g_assert(SVME(dc) == ((flags & HF_SVME_MASK) != 0));
dc->cc_op = CC_OP_DYNAMIC;
dc->cc_op_dirty = false;
--
2.25.1
- [PATCH 26/50] target/i386: Reduce DisasContext jmp_opt, repz_opt to bool, (continued)
- [PATCH 26/50] target/i386: Reduce DisasContext jmp_opt, repz_opt to bool, Richard Henderson, 2021/02/28
- [PATCH 24/50] target/i386: Reduce DisasContext popl_esp_hack and rip_offset to uint8_t, Richard Henderson, 2021/02/28
- [PATCH 23/50] target/i386: Reduce DisasContext.vex_[lv] to uint8_t, Richard Henderson, 2021/02/28
- [PATCH 22/50] target/i386: Reduce DisasContext.prefix to uint8_t, Richard Henderson, 2021/02/28
- [PATCH 27/50] target/i386: Fix the comment for repz_opt, Richard Henderson, 2021/02/28
- [PATCH 28/50] target/i386: Reorder DisasContext members, Richard Henderson, 2021/02/28
- [PATCH 29/50] target/i386: Add stub generator for helper_set_dr, Richard Henderson, 2021/02/28
- [PATCH 36/50] target/i386: Tidy svm_check_intercept from tcg, Richard Henderson, 2021/02/28
- [PATCH 25/50] target/i386: Leave TF in DisasContext.flags, Richard Henderson, 2021/02/28
- [PATCH 32/50] target/i386: Implement skinit in translate.c, Richard Henderson, 2021/02/28
- [PATCH 30/50] target/i386: Assert !SVME for user-only,
Richard Henderson <=
- [PATCH 31/50] target/i386: Assert !GUEST for user-only, Richard Henderson, 2021/02/28
- [PATCH 33/50] target/i386: Eliminate SVM helpers for user-only, Richard Henderson, 2021/02/28
- [PATCH 35/50] target/i386: Simplify gen_debug usage, Richard Henderson, 2021/02/28
- [PATCH 34/50] target/i386: Mark some helpers as noreturn, Richard Henderson, 2021/02/28
- [PATCH 38/50] target/i386: Remove user stub for cpu_vmexit, Richard Henderson, 2021/02/28
- [PATCH 37/50] target/i386: Remove pc_start argument to gen_svm_check_intercept, Richard Henderson, 2021/02/28
- [PATCH 39/50] target/i386: Cleanup read_crN, write_crN, lmsw, Richard Henderson, 2021/02/28
- [PATCH 40/50] target/i386: Pass env to do_pause and do_hlt, Richard Henderson, 2021/02/28
- [PATCH 41/50] target/i386: Move invlpg, hlt, monitor, mwait to sysemu, Richard Henderson, 2021/02/28
- [PATCH 43/50] target/i386: Inline user cpu_svm_check_intercept_param, Richard Henderson, 2021/02/28