From patchwork Fri May 14 15:13:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 438919 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp436552jam; Fri, 14 May 2021 08:20:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0tdVzpagqEqWKuJeHxu9zkjHQgfEHs0QHWx4TWcxA/ePjjgaVTxzfzr7K5/vKdjZ4hJu6 X-Received: by 2002:a05:6602:55:: with SMTP id z21mr24140528ioz.54.1621005650529; Fri, 14 May 2021 08:20:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621005650; cv=none; d=google.com; s=arc-20160816; b=LfAp3+EMwgJCfvOyHyp23yXkn5Q6MY2o/+MLaEEB1zR5+HmSG021kAFEBb7DcSgR/i KdIxgrSpov8WEY1lh5fPfDB//bJZTC9jDlM6aASPmcsnHlohnbVVZMpLbX0BG5shTwpa PF6vbJVTD0zx1ya8IVq/XDyj5adg8rf/TVKjNNzloVF2BtYqS73qbGUav7kcPpVgCeV1 YMNEVM+LL6U+afzcAWhRJl8ipZhOQH1zpWJ3o7COT1R33qXar/To0RHrTVUrHiYFBg7E tAlc3Ypz1Y8TcDo+jQtUC/A5fhGhbfQQBpNzrZmHgzoI7a99LaAH+9sTJuoHjCUinOsh nVxg== 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=Am14AxV+KQh4bHEznp653AdoYsyeLiCdw25zID82iYg=; b=gASi59iTbTTJt62gTw8SMjbyYuZJK1l3leHvPYXX0kS3moXibQzSrs3t6R/fc/ZwI3 HoxF4F9PXWlAAxLXpRI4xd2AwcC07YYxqXE0qqpih60kbkl42+Oi+rH1zjGVjVp0PFi/ pn5phdrkti4VDyP6+ioxfwrAXCbfDPvxf4LemWPilMnLbnSgkdSQWwdrRYBozNYQjyOt JIRtXPRa0MIR9h6thrH5D0qPxbiSkpb8XVe6lTDfmc05nqH77ybK+CkM15BKZyS7yzjK B1n1QVhHEXAkIjxUnDyezfnuzY8hzYL4nOqEb5Xjno790nrPFbxdpLuS7llGB671gl2h cM2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="M/WtbCGs"; 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=fail (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 9si6957815ilg.48.2021.05.14.08.20.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 08:20: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=fail header.i=@linaro.org header.s=google header.b="M/WtbCGs"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhZcP-0000VN-Ur for patch@linaro.org; Fri, 14 May 2021 11:20:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhZVk-0005SL-6v for qemu-devel@nongnu.org; Fri, 14 May 2021 11:13:56 -0400 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]:41571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhZVi-0006xg-EN for qemu-devel@nongnu.org; Fri, 14 May 2021 11:13:55 -0400 Received: by mail-qt1-x82d.google.com with SMTP id t20so18136070qtx.8 for ; Fri, 14 May 2021 08:13:54 -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=Am14AxV+KQh4bHEznp653AdoYsyeLiCdw25zID82iYg=; b=M/WtbCGsjZ7eKzLS0Or7lxiSHG4Bso5o+eyvWP1gGoFFa8Iql9ir8nQVHg0fZ88ycr lYAVmq9cibnO3VuG+fciD11qWLXrgwNC61V1E62R8MaEhJhuA3goe5+GdY3IvKCd8gmf L8k/AgpGVmqRDV2TTWgLyljU58w+gwb3eIMM3sYnoNrWe3Wrce9o9efBHWwQMxBz+GCW kXTV9xawyTX9ELTfX+zFwZ+yrX5PtzxX3br8DcdvKTAS/hjK+JkHB46weO1n41ygRbRt Z6IesF7bBXjFjinaSsL5ZpUEPboafWaWZFCiceNLuw4Pel/+wjMawSUyi0340eA4a+HG jSbQ== 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=Am14AxV+KQh4bHEznp653AdoYsyeLiCdw25zID82iYg=; b=b5hcSM19cGF6tvmsiYDeasvHNVuRoRGvJAWEtL/tfeZhQa0U2ijUsGLcAY53WqdjQ/ BksZiNVRqi3KvC3vw2Z9pEUhUR5sVJD8Em4toK0yeQgF9kP38NG/QC9cVPfZXzRdL7fE BnF4GWU8hm4qX7gS08AHn8CZ6t5u0aXDz6TO/wnFsk2k5HuadTwvzwg4ahJBjXyhJ7U2 NL6D1qNt0wnsgeV+c6PajWgJ2MsK03jnudoTitDSesArf7/CbYaUbmLLyECfB5a9xYEJ 7gxD6vYGpHZaugnBpssj3R37Epv3H92bqRnARqtTPnE4wS+dbxHrdy+WAD4rFf5xuyk0 tBxA== X-Gm-Message-State: AOAM531MkSiW7a065Qxly68JnP3YV3okYse1rEfxueFhl9yZ5CD3wySO D4zRP0XgeuUPNFTeX3cJOIq3fqy+/6/p/KTH468= X-Received: by 2002:ac8:5d10:: with SMTP id f16mr42752117qtx.123.1621005233581; Fri, 14 May 2021 08:13:53 -0700 (PDT) Received: from localhost.localdomain (163.189-204-200.bestelclientes.com.mx. [189.204.200.163]) by smtp.gmail.com with ESMTPSA id u6sm4778966qkj.117.2021.05.14.08.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 08:13:53 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 10/50] target/i386: Assert CODE32 for x86_64 user-only Date: Fri, 14 May 2021 10:13:02 -0500 Message-Id: <20210514151342.384376-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210514151342.384376-1-richard.henderson@linaro.org> References: <20210514151342.384376-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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: pbonzini@redhat.com, f4bug@amsat.org, ehabkost@redhat.com, cfontana@suse.de Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" For user-only, CODE32 == !VM86, because we are never in real-mode. Since we cannot enter vm86 mode for x86_64 user-only, CODE32 is always set. Since we're adding an accessor macro, pull the value directly out of flags otherwise. Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) -- 2.25.1 Reviewed-by: Paolo Bonzini diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 27806f35f9..b570921410 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -100,7 +100,6 @@ typedef struct DisasContext { uint8_t iopl; /* i/o priv level */ #endif - int code32; /* 32 bit code segment */ #ifdef TARGET_X86_64 int lma; /* long mode active */ int code64; /* 64 bit code segment */ @@ -160,8 +159,10 @@ typedef struct DisasContext { #endif #if defined(CONFIG_USER_ONLY) && defined(TARGET_X86_64) #define VM86(S) false +#define CODE32(S) true #else #define VM86(S) (((S)->flags & HF_VM_MASK) != 0) +#define CODE32(S) (((S)->flags & HF_CS32_MASK) != 0) #endif static void gen_eob(DisasContext *s); @@ -2370,7 +2371,7 @@ static void gen_movl_seg_T0(DisasContext *s, X86Seg seg_reg) because ss32 may change. For R_SS, translation must always stop as a special handling must be done to disable hardware interrupts for the next instruction */ - if (seg_reg == R_SS || (s->code32 && seg_reg < R_FS)) { + if (seg_reg == R_SS || (CODE32(s) && seg_reg < R_FS)) { s->base.is_jmp = DISAS_TOO_MANY; } } else { @@ -4619,7 +4620,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) case 0xc4: /* 3-byte VEX */ /* VEX prefixes cannot be used except in 32-bit mode. Otherwise the instruction is LES or LDS. */ - if (s->code32 && !VM86(s)) { + if (CODE32(s) && !VM86(s)) { static const int pp_prefix[4] = { 0, PREFIX_DATA, PREFIX_REPZ, PREFIX_REPNZ }; @@ -4686,13 +4687,13 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) aflag = (prefixes & PREFIX_ADR ? MO_32 : MO_64); } else { /* In 16/32-bit mode, 0x66 selects the opposite data size. */ - if (s->code32 ^ ((prefixes & PREFIX_DATA) != 0)) { + if (CODE32(s) ^ ((prefixes & PREFIX_DATA) != 0)) { dflag = MO_32; } else { dflag = MO_16; } /* In 16/32-bit mode, 0x67 selects the opposite addressing. */ - if (s->code32 ^ ((prefixes & PREFIX_ADR) != 0)) { + if (CODE32(s) ^ ((prefixes & PREFIX_ADR) != 0)) { aflag = MO_32; } else { aflag = MO_16; @@ -8494,8 +8495,8 @@ static void i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu) g_assert(CPL(dc) == cpl); g_assert(IOPL(dc) == iopl); g_assert(VM86(dc) == ((flags & HF_VM_MASK) != 0)); + g_assert(CODE32(dc) == ((flags & HF_CS32_MASK) != 0)); - dc->code32 = (flags >> HF_CS32_SHIFT) & 1; dc->ss32 = (flags >> HF_SS32_SHIFT) & 1; dc->addseg = (flags >> HF_ADDSEG_SHIFT) & 1; dc->f_st = 0;