From patchwork Wed May 15 09:40:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796924 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp2890900wra; Wed, 15 May 2024 02:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVq0DKA2xFokm3wERCMN/VhtsKxNHE2c8dmIFA5PXqzfN+icYYNdwJLZJEksvWbAtF3b9ocwKMli3g6bnOhzw29 X-Google-Smtp-Source: AGHT+IE94Teazfi1OfftJVZ+kCoc7Dm5OnAFXzrW2sbXPvJYqJ2yGcmo271moTCE+aEgB5HnCkqm X-Received: by 2002:a05:6122:2017:b0:4de:8eb7:a8b8 with SMTP id 71dfb90a1353d-4df88283b98mr13414613e0c.3.1715766250505; Wed, 15 May 2024 02:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715766250; cv=none; d=google.com; s=arc-20160816; b=hCOygvtRPrEqveAROAjuXN9cYvsv06OEv8NEbgm4YITR7MhkCsj3d0NQn+V0f61K7Q CLA7m/V2bGbUZIRtkfVkcvlXtXpopOmi0iriQx8yhD8W1XJBaBQzPb/jMF0wcHn3QYQr IplaGYur6q7ZbwjY68bSxiXWHXiWhexOQAgFTY7ab/F1Wl/c17PI2sQbBOpzsY3IociG xBAdLhpip3KgXw//gqQ0qzFaZV9yoUXfJaFC+QLJGBpEaYttuRI/Hq0t+xo/4aUscAET nvDFDljfSNPFasI5Yzl1lE2ycmzXw04cOmKBNJLhyP+JcaOR7ijbbrafeTDFfTwAiQBZ 91mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=p3G2DK0EX9Noz2yBNpV4zSuKlrdMpRgaC2kALcGrAt4=; fh=wDljmxUHXfz9MGj2//jPHYRc53BMWF157v8rVKELrf4=; b=B3WVNM1jhUgEOPOPPeqBBfpWQQrEyzptFjQ/BUc6zy9OuX1vdKPloRx24VCZxseQgK VX/RJyZ3vm1VLtL7LtPgoQEy3fUQKYJegfZj+ln99VIqhZKAVFObaopYydfcnF4UYC07 46mHc4IrUUfk4e268qxooDhXWZ504qaFPdaFauHNHABEhQEH7NF2K/SVi5QiQivruV77 eKWFQLQCNpXd16wPBXmAPsUcvPZg/n5eiiu8oMcrjm9yBG/D7ckZA3OP+RNYFeMtqaXb 5OXDztfR7IOu8PR+ofbMuilbaFQdGvVfxpGCkDC1t3iuQVwiQMUsLTiXv2LEsX1O3m3u Gs6g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="s0CatD/m"; 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 af79cd13be357-792bf38de2esi1300207485a.782.2024.05.15.02.44.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 May 2024 02:44:10 -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="s0CatD/m"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s7B8i-0000xb-Po; Wed, 15 May 2024 05:41:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s7B8O-0006xL-Fp for qemu-devel@nongnu.org; Wed, 15 May 2024 05:41:16 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s7B8L-0001io-Om for qemu-devel@nongnu.org; Wed, 15 May 2024 05:41:16 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-41fd5dc0439so44821495e9.0 for ; Wed, 15 May 2024 02:41:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715766071; x=1716370871; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=p3G2DK0EX9Noz2yBNpV4zSuKlrdMpRgaC2kALcGrAt4=; b=s0CatD/m+z6uHwAnQxRbf+OwuALGScW/HRa0PJskf8twufLmjaLiGeJHwNiKJUZw0n KE/uKXvMfwOIvb1Ir+GM3qO9KxHkUnEMNy8wA+B+eNMeiVqGcuaY10HIXEybL+MRze8l vJwy0uYO3tBBW7G7/9cl3IuB7zFXvjCy0sVSZNNZgu33mQZudhUzJqb6fw66+0FGG2Gm wcOXRV4e7Apy5YaFc/pwgDRXPsRQcxgyKlKSoWw3IYXnXjGyJ62AvicwrPEDOavtIbw7 bBoRYBpCLxKX+A4YUKEfi0qZxDgRWB1QLIk8uHKhSTv6zK66AlsyO0d7FzF/2J3aZPug BnDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715766071; x=1716370871; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p3G2DK0EX9Noz2yBNpV4zSuKlrdMpRgaC2kALcGrAt4=; b=gDFjbjB7FEnmYHiES09DnvPYqoTPTITbTWimx6EFpdgw/f9DesKtMUoRgABrea0VFQ klNf4oS8OSjSnqf2zumTJNI7TrgDpiPslyVe7QWDqTf+fY6GIaW4dFOkIVesIMSpVrfU UP94jIoSN+ju77UbwR5yWdHdvm9LqPXsb8cUo55arE3x+t5G8jCZxnpkoG6Lo7FbjeO5 eUarVhhohH70UU7diQwOFFYMIeA5/gR1dSt44r9qCLnRDrRptvYAbIq68rdrEHq6ZJCz 08KntDq4mZx29T8X28ig7STd0ujw5aarQiTC7xKLzuwLqLn+0sWTMSwhqrE4Zl28PkA7 COUw== X-Gm-Message-State: AOJu0Yz5fOkBosdQvyU3EET08IoWaNXPJOtZUCL/VqkFTWgAB9dZTb0p 6VIvygXPBtvajEWkTflV5qUndftglDqOc+l0lIFyI7LOInTjpx8e1RFTX5Myb9LMzU71aXgGEV2 ImLM= X-Received: by 2002:a05:6000:150:b0:34a:a754:eb48 with SMTP id ffacd0b85a97d-3504a969261mr10962225f8f.48.1715766071268; Wed, 15 May 2024 02:41:11 -0700 (PDT) Received: from stoup.. ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbbbefdsm15897058f8f.94.2024.05.15.02.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 02:41:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller Subject: [PULL 37/43] target/hppa: Implement PSW_B Date: Wed, 15 May 2024 11:40:37 +0200 Message-Id: <20240515094043.82850-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240515094043.82850-1-richard.henderson@linaro.org> References: <20240515094043.82850-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-x32a.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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org PSW_B causes B,GATE to trap as an illegal instruction, removing our previous sequential execution test that was merely an approximation. Reviewed-by: Helge Deller Signed-off-by: Richard Henderson --- target/hppa/translate.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/target/hppa/translate.c b/target/hppa/translate.c index f7d54f4009..f40ac92e98 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2062,11 +2062,8 @@ static void do_page_zero(DisasContext *ctx) g_assert_not_reached(); } - /* Check that we didn't arrive here via some means that allowed - non-sequential instruction execution. Normally the PSW[B] bit - detects this by disallowing the B,GATE instruction to execute - under such conditions. */ - if (iaqe_variable(&ctx->iaq_b) || ctx->iaq_b.disp != 4) { + /* If PSW[B] is set, the B,GATE insn would trap. */ + if (ctx->psw_xb & PSW_B) { goto do_sigill; } @@ -3965,23 +3962,13 @@ static bool trans_b_gate(DisasContext *ctx, arg_b_gate *a) { int64_t disp = a->disp; - nullify_over(ctx); - - /* Make sure the caller hasn't done something weird with the queue. - * ??? This is not quite the same as the PSW[B] bit, which would be - * expensive to track. Real hardware will trap for - * b gateway - * b gateway+4 (in delay slot of first branch) - * However, checking for a non-sequential instruction queue *will* - * diagnose the security hole - * b gateway - * b evil - * in which instructions at evil would run with increased privs. - */ - if (iaqe_variable(&ctx->iaq_b) || ctx->iaq_b.disp != ctx->iaq_f.disp + 4) { + /* Trap if PSW[B] is set. */ + if (ctx->psw_xb & PSW_B) { return gen_illegal(ctx); } + nullify_over(ctx); + #ifndef CONFIG_USER_ONLY if (ctx->tb_flags & PSW_C) { int type = hppa_artype_for_page(cpu_env(ctx->cs), ctx->base.pc_next);