From patchwork Fri May 14 15:12:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 438913 Delivered-To: patch@linaro.org Received: by 2002:a02:b78d:0:0:0:0:0 with SMTP id f13csp434571jam; Fri, 14 May 2021 08:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAOwv1zvPNQHJ4TtrW6hHQtjwmD+ZRGd0LPcjing15J0KeHNOKb8d9i0xAqlFgp8MLLIxw X-Received: by 2002:a05:6e02:e92:: with SMTP id t18mr31908834ilj.283.1621005495861; Fri, 14 May 2021 08:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621005495; cv=none; d=google.com; s=arc-20160816; b=hL9SkZYv5TVlkPv0Z0DReScEZh1QAUa4+tpuyTxPFWnnynUBCRRGBYnXoVwLJjoJG4 Ji6ODME7zLookm4Btm83FT66NNZnkgVIlmjAt6r7zJWLr2cX8Z5yQ00ygJiUm4FAr4di 3bn4vbagy3X6YPdT6xj/4iCw8epag/Xv8pYf9LwSi7571Tfo5GmP5eFtDYAjK1LIrBk0 Xohh4yP70rvprOOAarsUs1IaUueMJ4DQI2nBjym1rpyoDPThBj4dYos51QZvuVwGA9qq lbwIajQKw+XinP8E1r6OS0C6V21JSk9VcBiRVudhZ0MWQVB6Yar5QwqXVJ9ZgaKMmHLo vzHw== 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=CJs83vrRkquhvYUlXXsfGJep/VUt9Y0YD41hrYq3TI8=; b=hDRGp+4h7HWxSHLdAHqqyt9Zw+f3aTFeVEgP2CDO5wxooBob/E9EDUAh0DG3X4fuh8 Uv+V8Vg75Lu5Lt0nOoT7V9KfbuX9kh3t5znkZkDLSBoTbrTKUWGNC8uJ3mdf74BljQaV jF23qUiKogr83QfvJUnMwdR3GibDwV+Ao3JS5fzKP1RKnJTpRpZWieQAFsPq58I5OY1a BNnMvPI179cZzNj+ngDoSxAP1MvS/Lp7YreV8OUduoXrm/Yz9/Geb4tMozBRwv7fPXou C8M8Sf5sD4p5/gCMr3nkibuldojQeneUNMjQCidih/i1y8LtqRG+ocgKhpSHD2pHqf8c xhMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MvoUuQRe; 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 x9si6402225ilu.78.2021.05.14.08.18.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 May 2021 08:18:15 -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=MvoUuQRe; 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]:52378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhZZv-0003Ce-8P for patch@linaro.org; Fri, 14 May 2021 11:18:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhZVf-00059M-AE for qemu-devel@nongnu.org; Fri, 14 May 2021 11:13:51 -0400 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:43896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhZVd-0006up-Q6 for qemu-devel@nongnu.org; Fri, 14 May 2021 11:13:51 -0400 Received: by mail-qt1-x830.google.com with SMTP id c10so12603258qtx.10 for ; Fri, 14 May 2021 08:13:49 -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=CJs83vrRkquhvYUlXXsfGJep/VUt9Y0YD41hrYq3TI8=; b=MvoUuQReRyPSIbc2dRBNtz8MHO+ecle/XMX8cLoU9adzaJ9LuTgBovFKR5smaG8D5b UGqDqLjjEvUyPqsvgoO/exA6+WN9ucgJJ2o3R6mkVqkXVh4o4l1vtphQstJUHqaa/z/Q TUXm9Jg13W3BlNxUgJnVNRUYBZ1yFhuINLKZ0ufw7VED4YSNi9YnMBv3Rm5xqlum9YjN ADlajAeWentUdeU/VEi6KxqYDZJWyc8yAsNpFTK6dIcIMAct6Nrb+urOKOTTGzFrB8Ao pFg8/hYQ3KcabjO3OmEWLugNFEYIrI/K6bM6HTOtGIVB4R8mX4k0TMYrkHFkj86JPo7L Ny2w== 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=CJs83vrRkquhvYUlXXsfGJep/VUt9Y0YD41hrYq3TI8=; b=VqEGOaa0GlCQACSi9dig3l/3dc5wtMHfp3ybJz9UONub1U1vaVmATI+hvAp/7LMhTI LOaHJ71L5l2QSon3K7Dv2fobAUbiswHRLW6GCC+itF2Mh/4++v6j/5YmawTl9DUX9AiL bMmiuZPqfNGguHzJbFiraE4nGsy0oWUM7MMSIZkC9FMxdOa1XyjEqrzD6FkANukk/0EE RKSbZfklJPqz4rDW63B9Iv+o4LOL+nwQk7xry4kaAXgW/oaxAb6zQdwaUtWywJaygEIw P1nWCPOKKSylFivsoNeaMNQvjPwk324lf094HuEHptsKpwM5Mb0z7CzMKNsY2/zkDLAC 75bw== X-Gm-Message-State: AOAM533l0U4E1BEzK3c7y6jgaGLA9p+2W7ipLnlMznAoIMEBEdFHdpee lZibJ+7CsAWTSTnu2zqkn2hxV9f9dJgttfE9oys= X-Received: by 2002:ac8:6908:: with SMTP id e8mr25694616qtr.174.1621005228941; Fri, 14 May 2021 08:13:48 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 08:13:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/50] target/i386: Split out check_iopl Date: Fri, 14 May 2021 10:12:57 -0500 Message-Id: <20210514151342.384376-6-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::830; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x830.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" Signed-off-by: Richard Henderson --- target/i386/tcg/translate.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) -- 2.25.1 Reviewed-by: Paolo Bonzini diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 74f6024f82..873ed00975 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -1302,6 +1302,16 @@ static bool check_vm86_iopl(DisasContext *s) return false; } +/* Check for iopl allowing access; if not, raise #GP and return false. */ +static bool check_iopl(DisasContext *s) +{ + if (s->vm86 ? s->iopl == 3 : s->cpl <= s->iopl) { + return true; + } + gen_exception_gpf(s); + return false; +} + /* if d == OR_TMP0, it means memory operand (address in A0) */ static void gen_op(DisasContext *s1, int op, MemOp ot, int d) { @@ -7095,28 +7105,16 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu) break; #endif case 0xfa: /* cli */ - if (!s->vm86) { - if (s->cpl <= s->iopl) { - gen_helper_cli(cpu_env); - } else { - gen_exception_gpf(s); - } - } else { - if (s->iopl == 3) { - gen_helper_cli(cpu_env); - } else { - gen_exception_gpf(s); - } + if (check_iopl(s)) { + gen_helper_cli(cpu_env); } break; case 0xfb: /* sti */ - if (s->vm86 ? s->iopl == 3 : s->cpl <= s->iopl) { + if (check_iopl(s)) { gen_helper_sti(cpu_env); /* interruptions are enabled only the first insn after sti */ gen_jmp_im(s, s->pc - s->cs_base); gen_eob_inhibit_irq(s, true); - } else { - gen_exception_gpf(s); } break; case 0x62: /* bound */