From patchwork Wed May 19 18:30:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 442485 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1591978jac; Wed, 19 May 2021 11:48:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNtkTr+65WEc3TDgp5Me0uCIp9ZywUgjitKt/Xv45dZf25pNDbuYvOI/oOgD2zmJUspy2o X-Received: by 2002:a1f:add0:: with SMTP id w199mr1199071vke.0.1621450130817; Wed, 19 May 2021 11:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621450130; cv=none; d=google.com; s=arc-20160816; b=oDvu3ys1wowo+bpiLQm5Zb1B3Yw4yEtm7pFpcFDThZE/I1EuIsqn8S2rhH/fuuqMrg /orj7F9d6uHXyAPEMWaw7rEBAjYEfWwQ2BmaM1qnKewIu21+StKACqwQ/9IFlHmde7uv mqOJVr1x0BD9nIznLwavihvuO6a7GG2d6f4OHSIDQwNb/P6Fr/aKDPifjwJtD2lgKa3S rz0pqJ/+0HKN+bNRGCEeepVtbzWA4aUiwN/oJWjWtd4kmsQyCC4abzVxxdEuf/PyE/o4 Tn6m1++cP3BWO+9Mu9vXB2JCq+2jT6YfNNZwVJHyQlxcTzSxs2Hs9WfNS8x1bpN3ZEGa oLDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=nqW7XsN57M2hYAJUK6/QOBNZBxSwu2T66IctV1Y0s/A=; b=spVMiAXFzNsvF8l8Csi8YiMRlGNtu6zNp+paJ9N3q1AF7q+hav+0wxm3zP+lgm3/GR amLrNUpUMsX7dUigK+bsBfvJ0sp2OvO3utGdaVTJz+KkOQkFzNvjNbIsEu6WA/wJkrxi e3KmUqg9aGfBXlga3toZPtcFl1Ji1o29hD0cDlnaqdaSMjJrFWShGziM/piLysjK3e2d zRh+U2+53HSOnt0yJbgnudbWL6mPE8qeDU31oBci9B87fGtV+HiYyaOxMxTe+qupKPzS cFkHvq25UhurR4ElW+CZMBtlwRFuzmc2eAFhdy+Z9sfOOxG0Mrd/6Qzi8pVwKLB86uQc w6cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SnqMeTAj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a186si344729vkc.54.2021.05.19.11.48.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 May 2021 11:48:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SnqMeTAj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljRFS-0005CC-31 for patch@linaro.org; Wed, 19 May 2021 14:48:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljQyl-0004Gy-BS for qemu-devel@nongnu.org; Wed, 19 May 2021 14:31:35 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]:33465) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljQyZ-0005m2-Cc for qemu-devel@nongnu.org; Wed, 19 May 2021 14:31:35 -0400 Received: by mail-oi1-x22b.google.com with SMTP id b25so14061359oic.0 for ; Wed, 19 May 2021 11:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nqW7XsN57M2hYAJUK6/QOBNZBxSwu2T66IctV1Y0s/A=; b=SnqMeTAjuWrxkMmy3a+oCbs8vSN0TfPhkZuiS4KDL7XXc5/nHizmyNHswCzDOi52xz 5May5pa1u/OsClq0PGP4PPZS4aK/QPrYv9i4UPVTjptuDQ5p8xidsIfEJjzIEajaT4l1 st3GHrfSO2Y5Q/lF+Us0fuhlQAbXEClvr0CK8AR7NSiqw1ppUTAYaljaXCqecRGWxpjE hzywhtrzPYy495RmVaQx33Ryewo7yYO1cY/KxhGpicZk06sT3XY3yHSX9TmtzpWtYdGo SBU0l3CCUZgAOKMu2+wKUPL98ai8CK776Q9YAgKbIiux04GPBV0/85LqYTuLKvJVXWpC BwwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nqW7XsN57M2hYAJUK6/QOBNZBxSwu2T66IctV1Y0s/A=; b=XRvRkHUmGY2KAUf5tpi4+/mSEoibrakuSiUCZANnJx43slLnCKIznyhnHtBUkp3RtF SWUlC+0BtHVazYTowpBvvEWP+wcLUQ2iBkYP6WXdUMkPoq2UrFJ6NFvfee1P1r/SIMWM GztmUEZJubnu1RfjjYqH3ndLCZY9y5Tdgkf/rnp7V2c4iqO2qV+hYIEMeyqh5D4ckPfW 7LEoRzwaJa5tu1BU0E2jPzv8OZFSAjmO8uT0DYrhMbWQ5INXK66aY/MMBTyeaFEWo6II RKTfhuf7fljA28SfGbt8CwUwXC2AyUnk9SYyCoi+wEoZbIr8CHrrooJJgZJRKfnlFfFy EX+A== X-Gm-Message-State: AOAM533dR7jpYYqJ05f4RvfTppgMC1ilVO5OXuOiZTVsXLrGrVzS4X4J z4H4ukgti31t2g6iS+ASfM/1WqGwXR6ri9+V X-Received: by 2002:a54:4396:: with SMTP id u22mr524959oiv.118.1621449081845; Wed, 19 May 2021 11:31:21 -0700 (PDT) Received: from localhost.localdomain ([45.235.253.15]) by smtp.gmail.com with ESMTPSA id l9sm28428oou.43.2021.05.19.11.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 11:31:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 30/50] target/i386: Assert !SVME for user-only Date: Wed, 19 May 2021 13:30:30 -0500 Message-Id: <20210519183050.875453-31-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210519183050.875453-1-richard.henderson@linaro.org> References: <20210519183050.875453-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Paolo Bonzini Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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, we're not emulating any VMM, so VMMCALL can just raise #UD unconditionally. Reviewed-by: Paolo Bonzini Signed-off-by: Richard Henderson Message-Id: <20210514151342.384376-31-richard.henderson@linaro.org> --- target/i386/tcg/translate.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) -- 2.25.1 diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 28eb0e8adf..235caa247b 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 @@ -7495,7 +7497,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)) { @@ -7510,7 +7512,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); @@ -7519,7 +7521,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)) { @@ -7531,7 +7533,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)) { @@ -7543,8 +7545,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; } @@ -7558,7 +7559,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)) { @@ -7570,8 +7571,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; } @@ -7581,7 +7581,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)) { @@ -8516,6 +8516,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;