From patchwork Mon May 13 07:47:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 796518 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp1884059wra; Mon, 13 May 2024 00:51:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9ctKlW0i97WN/QhAoQd3yX18DtFrXlWoJd9A4XVksOoPu1htGtgebc2/2PgCCRI7xI/FLSlZKK7cFBPJjbCoP X-Google-Smtp-Source: AGHT+IGNNBwJH3lmk43KwYZ7m22yE/fLi9GHZslr4jSkUoMF7lCBGaHrwKvN9OqsLEJSHGgBhV3B X-Received: by 2002:a05:6808:4d9:b0:3c9:8aeb:a83e with SMTP id 5614622812f47-3c9970d19abmr9411792b6e.52.1715586719599; Mon, 13 May 2024 00:51:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715586719; cv=none; d=google.com; s=arc-20160816; b=Wyww3vmgJBeRXYl/ZXRHTYISBnshu2UyDkVQ4cKjgxSlNlBQf9leNPr1iQyOYmK9oK Z+B8j8tW/5dQvgd6tkfaZjqtxhYnFdzqjmGQXcwxUm5iK8qOrGd7uG4i8gomuvkPNwvl DFgHiXNx+BH+wIfvoUreON5q1EYjO2rR6FiJEUQQJPgRuDzEcHU4DU/Uood4pl8X+tkD D4foEevFp/O7+aKVaTlLA+M+DmpqlWTnxrPExRPzFCspqU9m5oWQWqH9SpKuCOR8BVja 9YRY6DjGxZBKQ55GMngfrLi71iM5OVA99NqTlOXGuFBQYzmbaMSpRueEXYKz6qNTuHIl bqnQ== 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=e5GRNpEQvFWJc+tF6eTBVa97b3dnETbzXExkDc8WgAI=; fh=f2WZoDMBYjCKWIIOoPI+rQtxlv4fmOm4u+dLdQLqpOk=; b=TpLme7M05TMszHHhBTxGy2re1zqWh11cisXXi6v0TOLvvRKbj9s0KlDWWcH7Qk8OHV QnIzkedVmcJc5vp/8/2/EbKqM4HgRwdG1185gexdr8/+NxzICRQbRnqNzj7JHw8iTF+z 4nNbEgqnW0v3QL4WUX6+ZpcWScxCC0QFDnMWoN/6mCalRtznoN9S20RNJXcWpPGudzda Vlqe+zcBA4V98cKJSzQa4/50bjHhduH7O5sE/SiiRHQAYpTw8KxTVrdIsqRqNzu/aLxq 1w7D/FfVcHXKhm2kpSqdCkhr7r3+Ojl3srRyerJWg+HYbnyg/EyqTywS3axE1g6nkEGb A1KA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bRnU31lb; 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-792bf277875si881869185a.119.2024.05.13.00.51.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 May 2024 00:51:59 -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=bRnU31lb; 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 1s6QQi-0004A1-UR; Mon, 13 May 2024 03:49:09 -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 1s6QPW-0002yf-LC for qemu-devel@nongnu.org; Mon, 13 May 2024 03:47:50 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6QPT-0001QU-0j for qemu-devel@nongnu.org; Mon, 13 May 2024 03:47:50 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-41ff5e3dc3bso17922065e9.1 for ; Mon, 13 May 2024 00:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715586465; x=1716191265; 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=e5GRNpEQvFWJc+tF6eTBVa97b3dnETbzXExkDc8WgAI=; b=bRnU31lbRThKVjamRSWRV4tRWEMwInbq6T/yw1cHp1hx6xtKNSxWh2ckjB5/HeuRkB +nafIWRJUukeU1lLyZPt89SWrBdZvyzr0o6/VJZ0Y0Ht42W9FNLgLiCNIcKzyOQOt9J+ uqtCbBjutY/6krV3aUwJVsUlUUxQafg6BexUdAZcuYO7AosYaLlcCs/oZbTF7GCjCm4T TL+QUD4iA20Cgpfvqik7ZW20SA8D9Le9+nVVVrNrGZzuJzdFy6EVb22RA3UbaxrIYJRg On6HiBFTdiyt7AnUPn7/UMlII/iNWLkPJZvVQU/PV/xaB+oPNNzm8kALcsfN0TdtYuSn w3XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715586465; x=1716191265; 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=e5GRNpEQvFWJc+tF6eTBVa97b3dnETbzXExkDc8WgAI=; b=DaQGk1oz1f9fNJOf9oOxVAPkPfQttzahWZm/avMfdFnvdTTWJpFBsEPMC/uUSRnqmh Sri8qIEv3D9RcMlCVbjphaAwn5bWwgmzMKkJrN3a03Iw2BNow8bXBJR89SA+1jJSid2P BdHUzlbyUX8EIz4pxVWdHud3f0PGcci7G8DMWGiByDxne5eRfj3PrPuUVgA4CTBur1/t oR0NUYa4u/gUNzolYoqS+3mc85MRL+9o2crvylwy/G3qnQv5sH3klvWx5rmgcXE72oJq XdnpjnGIlAbpZOntj3Cpd3tRUWja15rP4dHvRKoV4zo9xX57/QN55g/2ypNZnKWEg7SJ NhZw== X-Gm-Message-State: AOJu0YxYc0hTmcbnsHtf1sP110u29EgZCy5+jJ8WCDEWN4/AP44fzAHE SBfYkbbMwRjkzZWSYW5zlEEVXeOkT1Cpd4GRAeXaS9cw1NGctbl1BxTuEZ79LLTcaF/DTlV27/y CsFQ= X-Received: by 2002:a05:600c:1c9a:b0:41b:8660:c530 with SMTP id 5b1f17b1804b1-41fea932021mr76999535e9.5.1715586465612; Mon, 13 May 2024 00:47:45 -0700 (PDT) Received: from stoup.. (12.red-213-97-13.staticip.rima-tde.net. [213.97.13.12]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fccee9318sm148204765e9.30.2024.05.13.00.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 00:47:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: deller@gmx.de Subject: [PATCH v2 37/45] target/hppa: Implement PSW_B Date: Mon, 13 May 2024 09:47:09 +0200 Message-Id: <20240513074717.130949-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240513074717.130949-1-richard.henderson@linaro.org> References: <20240513074717.130949-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=richard.henderson@linaro.org; helo=mail-wm1-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.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 the sequential execution test that was merely an approximation. Signed-off-by: Richard Henderson Reviewed-by: Helge Deller --- 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 1a6a140d6f..2d8410b8ea 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2061,11 +2061,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; } @@ -3964,23 +3961,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);