From patchwork Wed May 19 18:30:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 442502 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1599758jac; Wed, 19 May 2021 11:59:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOm78p2XmsBRLWKvPkeRIa+8/O8gEL+Pkk8vJoN2dsy/3PEyuBYSNYdFOiOUP57Ygb2Pxq X-Received: by 2002:a25:f206:: with SMTP id i6mr1419014ybe.123.1621450784618; Wed, 19 May 2021 11:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621450784; cv=none; d=google.com; s=arc-20160816; b=cTMsjk07mMrEhnXRUG9apKYjJuLkbeiJVYIZXjG/4wY9a0J02+unvWSf2ejtIGB3uC 784YH/V26da386f6rTzLGAYOVkKpwlLw6k+IrQjWKuPl+ebW3G8wdIvnZrxNsEvoO4nJ jFrNKHAe1egJ3P61xQmS8mdHuro8VZoOlGEEikiUjyDJ+oqdevTJepFrfCGLG464atju NPrG27fcoAlcpwYyK40OL+Jq/Ku387TvlH5DLZmtA3zXQBpKYPAwHjwSsZ2NVw8N77hB n54lRrCvRIgv0iTk7gE6YnJJ1fXKGuT0IRFpvjyQce15N1WWsV0aReYcV6cw0fa9q+K1 dq+g== 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=vrBlr05OPyOsTxUcBIownyAACzTpgn59yE8tdL4D5Hs=; b=vO1qSRp/qfk5Kjzs3mn5dt+qqjt4C18rk8wX1MYZ1k9rStp/NVBtHnsZEPRiM6ngCY qOoH5RkcvQyGB99Vm2Foas185WYB/DRD1kfo8JqMCT4Htxnr4Iw5153mdz5i2J3yMkuB +aTsrtU96NwHyVs7b83Sy1QLXQdlHmH2yWxWQAr6px1/0aiwQZa7TPbKPHLvS8DaUZc4 daIBZWXaqqRtoVknv126l+bLH0s47DP0L8RyFMGU8OfzCqZfvxvMlYiNTqal18y19l5f Z9fuH3q6ak14XQ4qtBE883ZgriDHRsChJYJwtvmmsxufVTjJ8rJ0ubglCsaNoJK77/hU QnZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UfvTlxwp; 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 w126si229661ybg.271.2021.05.19.11.59.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 May 2021 11:59:44 -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=UfvTlxwp; 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]:43954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljRPy-0000f5-EJ for patch@linaro.org; Wed, 19 May 2021 14:59:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljR1p-0003AM-DL for qemu-devel@nongnu.org; Wed, 19 May 2021 14:34:45 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:45890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ljR1l-0007Uz-Fd for qemu-devel@nongnu.org; Wed, 19 May 2021 14:34:45 -0400 Received: by mail-ot1-x32f.google.com with SMTP id t10-20020a05683022eab0290304ed8bc759so12598047otc.12 for ; Wed, 19 May 2021 11:34:41 -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=vrBlr05OPyOsTxUcBIownyAACzTpgn59yE8tdL4D5Hs=; b=UfvTlxwp+Ccmg+lvKKBZhUfQhnFHQIZ5ZjNDNbuj2XvrmAJ91X4mD7nHLfK3FnfJlT Cwdez5OBeYqCfHPYByprKAV6pJHZrEt5g+JPQCiZdf3xkWuIu25auymkbEhnWLb6vyBr DzYWRR9CvGt/pFmTbz8LivGGlGYPR88MHoRxJfa/LYQO0pIuga4aJj9XkxZ7crJQ12fY +TbC0hDMqpTmAjghFMU4N29SsXLtL62j1wwu1pLiM4XaBjQ+UTGHCOc8DfYgYw5MWgwk odkAsbX7p1Zzch9xIUvQuZtoO+zFYsmWwd1rLQ43Mw4lp8ip2AvKBvM7+HjwcOTv9+Bt zsWQ== 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=vrBlr05OPyOsTxUcBIownyAACzTpgn59yE8tdL4D5Hs=; b=LbLyw+3i8OyVJ+v2dEEHwuvzS4JjxFORCSVx4vASLl+EjSTHHYkymvV7gG1ZsVBem+ jAbAe0S0tGuKqvuWJ4elrFvZcTIwmNE9NmcZm99YTigtVDC10AEyM2EZbdKL7aAuMWOY veInmDivC1PsZY1UZ54R+/7nsYCcjhhIn7deVcPSFdufeo1nR9JcRN1QgbcaESbo18pf 2pHgAwNHcZZU4O+y2q439VRemLzIwbay23mDJEf83RDg7/uaEfvwHRq4qrTNXrdmAXSB J3czPGiXIiVgfvoi0XZhM8I7c8Gw155SVNMbl22R2jPSXuWSyk3r6sMYfrrGB6a2Fmsc TRTA== X-Gm-Message-State: AOAM531yfkKlInbL6zACkeBxjVi5UMq3xSzRUoEZd3ZSkesaPNz39AX/ vGtl9c0UAgyTCe3q6EQ5HxokDhamDKtSxlk5 X-Received: by 2002:a9d:61cb:: with SMTP id h11mr638072otk.19.1621449280393; Wed, 19 May 2021 11:34:40 -0700 (PDT) Received: from localhost.localdomain ([45.235.253.15]) by smtp.gmail.com with ESMTPSA id i9sm38642oog.17.2021.05.19.11.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 11:34:40 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 48/50] target/i386: Create helper_check_io Date: Wed, 19 May 2021 13:30:48 -0500 Message-Id: <20210519183050.875453-49-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::32f; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32f.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, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Drop helper_check_io[bwl] and expose their common subroutine to tcg directly. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20210514151342.384376-49-richard.henderson@linaro.org> --- target/i386/helper.h | 4 +--- target/i386/tcg/seg_helper.c | 21 +++------------------ target/i386/tcg/translate.c | 14 +------------- 3 files changed, 5 insertions(+), 34 deletions(-) -- 2.25.1 diff --git a/target/i386/helper.h b/target/i386/helper.h index 1d85f033df..47d0d67699 100644 --- a/target/i386/helper.h +++ b/target/i386/helper.h @@ -86,9 +86,7 @@ DEF_HELPER_1(rdtsc, void, env) DEF_HELPER_1(rdtscp, void, env) DEF_HELPER_FLAGS_1(rdpmc, TCG_CALL_NO_WG, noreturn, env) -DEF_HELPER_2(check_iob, void, env, i32) -DEF_HELPER_2(check_iow, void, env, i32) -DEF_HELPER_2(check_iol, void, env, i32) +DEF_HELPER_FLAGS_3(check_io, TCG_CALL_NO_WG, void, env, i32, i32) DEF_HELPER_3(outb, void, env, i32, i32) DEF_HELPER_2(inb, tl, env, i32) DEF_HELPER_3(outw, void, env, i32, i32) diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index cf3f051524..69d6e8f602 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -2418,10 +2418,10 @@ void helper_verw(CPUX86State *env, target_ulong selector1) } /* check if Port I/O is allowed in TSS */ -static inline void check_io(CPUX86State *env, int addr, int size, - uintptr_t retaddr) +void helper_check_io(CPUX86State *env, uint32_t addr, uint32_t size) { - int io_offset, val, mask; + uintptr_t retaddr = GETPC(); + uint32_t io_offset, val, mask; /* TSS must be a valid 32 bit one */ if (!(env->tr.flags & DESC_P_MASK) || @@ -2444,18 +2444,3 @@ static inline void check_io(CPUX86State *env, int addr, int size, raise_exception_err_ra(env, EXCP0D_GPF, 0, retaddr); } } - -void helper_check_iob(CPUX86State *env, uint32_t t0) -{ - check_io(env, t0, 1, GETPC()); -} - -void helper_check_iow(CPUX86State *env, uint32_t t0) -{ - check_io(env, t0, 2, GETPC()); -} - -void helper_check_iol(CPUX86State *env, uint32_t t0) -{ - check_io(env, t0, 4, GETPC()); -} diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c index 94193a8e00..68ae9b0798 100644 --- a/target/i386/tcg/translate.c +++ b/target/i386/tcg/translate.c @@ -682,19 +682,7 @@ static bool gen_check_io(DisasContext *s, MemOp ot, TCGv_i32 port, uint32_t svm_flags) { if (PE(s) && (CPL(s) > IOPL(s) || VM86(s))) { - switch (ot) { - case MO_8: - gen_helper_check_iob(cpu_env, port); - break; - case MO_16: - gen_helper_check_iow(cpu_env, port); - break; - case MO_32: - gen_helper_check_iol(cpu_env, port); - break; - default: - tcg_abort(); - } + gen_helper_check_io(cpu_env, port, tcg_constant_i32(1 << ot)); } if (GUEST(s)) { target_ulong cur_eip = s->base.pc_next - s->cs_base;