From patchwork Wed Nov 2 05:47:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 620836 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp4072066pvb; Tue, 1 Nov 2022 22:48:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7uwaLvBw05e114B3z4Rx5ZucQFOEogEVkZ8M+QmmSvu0J+ET8e5mLHPXl9CWEes8tWbWwc X-Received: by 2002:a05:620a:28c1:b0:6ee:d4f1:21df with SMTP id l1-20020a05620a28c100b006eed4f121dfmr15714696qkp.724.1667368117548; Tue, 01 Nov 2022 22:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667368117; cv=none; d=google.com; s=arc-20160816; b=EsyfXjeTpMKwAV3sahvnX2KplFvxg6PKidXLMHwscBbGDBEfBWOSYhle0Rct68GW+l /jMlU7p/CzKBbDA2AgrhCSwP6vMmlBTlAyNPucfz+TkMQQyfn909VCnBGTeZiiMwxvAn f3Jz17MOJS+qKP6BAkZ9sZp3GIL+QamDMVVLafw5TARAlasnJGhq5j2uTe6EozJfCHhj K/tOObqTJtH55tN9VqoeZegks469ITyarbkpMJySC53YRHlNWCAeJrlpRhW94+jEQhTg 1/xXXIa7L9WYsJamgYhWUMlAakrb80/X36N5aX51UOsn2iIJgKDMVN4C1gjUjJ5QnyOh lynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=ULAXwT5VzMBCI1KaQ06N0fdiq7JAkC5SfEaYbtxC2vU=; b=v9L9EpOjxQz3qN84z/iAECLgoE+DcXmff5mmcMRo9ADbY2dD4xcQxO0KJX/hfOCl2p /Eg60nKK3gl4OUdS5TrAEW8yEDZ7bktZqudi19MzPxPAnwHozuV9CCsretbYoMOB/v2p fO0rMgtOKtAY92Zj4CFVxmrJWF8g8GbF7oMRHaa0FtPTLJ2fYJu/C+tnPL6X1Ks+ylTd gPYPAMIFd5vUeypdtk0ado+VdPMoDOq2sdWwlBgLVFAVP8iI0GxKgJ69NHsiVikwjAj9 SSTeI+sjVFmQ+qC6jFPEyu0QtyJHBEnBRtjp9UETlXItL8t871PukhlZ7VT1xLrQn5tb 2A0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ftojNHF4; 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 gh12-20020a05621429cc00b004b47ac09de5si7006330qvb.467.2022.11.01.22.48.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 01 Nov 2022 22:48:37 -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=ftojNHF4; 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 1oq6at-0004vX-9h; Wed, 02 Nov 2022 01:47:19 -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 1oq6aq-0004uh-Qm for qemu-devel@nongnu.org; Wed, 02 Nov 2022 01:47:16 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oq6ap-0005cn-4N for qemu-devel@nongnu.org; Wed, 02 Nov 2022 01:47:16 -0400 Received: by mail-pl1-x635.google.com with SMTP id g24so15588458plq.3 for ; Tue, 01 Nov 2022 22:47:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ULAXwT5VzMBCI1KaQ06N0fdiq7JAkC5SfEaYbtxC2vU=; b=ftojNHF4D2Wc5nS1vAhXS5sk7n3+11OEqnSv7aentEeNDQOCpx9YRlniXw80ynRNE1 A8YAdozQitcVCfyoKUNgd2r+napGsCv0sK311aS4Sg5pniSyghu5pWDlJzcdotLxzBJ6 +A+nqSZIlFBlETt5EDF4jD4heudDri4fhb8LTyLcgVTB+j9ndeF/nFafejfFMMgAAuJQ /qFUTZ+SVJD8WCfn2dveOKRKrC4ZLLl7U5qYK/H32av3TJ7yLKmIyPTqjPBSBsNarJKf ewG+r5ZsEEnkAHWxLS/jKdOINfz7AwKL8L89G2PIoY6cEmumTnffNxYykdZcOSleQvcO snIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ULAXwT5VzMBCI1KaQ06N0fdiq7JAkC5SfEaYbtxC2vU=; b=bHrAFce5VgxH90dr+kb7s/iZJsbchMo7WUTmSqP3l0LeuWI3HAdX7quQgW0ooUI20/ GT5OBTtxH1Yoa17//IcOUMmqQ394tb5czA4J29CQHaz+JzeIoRmxSPkNv6CXexyP2NhE mg3q8M7XNKRljxhYO0bANomhz2fcuc4n2j0rlt19bHQntPcv7ZAUts7QMMx1v8RT1trK Ijt9QPcFAimPg2cj0C9UDr3Jx8gejpgrYsq2XKL5IKmwktNn7i72W7T4eJgvSEvSik9V 8M7/Hce6VDGzDxBmtFKeCUzMQJ3TzYpqzLjyYDlyKZyU0kWcq3dDXaiIBoMTlV/N+yrY Dugg== X-Gm-Message-State: ACrzQf247vrA2+7dz5fv2R1ANC44V/VJNvLDz03OoWwF/W62Yt/CREXO HXFmGOHB5ZBTL4oc1K+7wqz8bHXzHBZu9WtE X-Received: by 2002:a17:902:ccc2:b0:178:29e1:899e with SMTP id z2-20020a170902ccc200b0017829e1899emr22802065ple.114.1667368033464; Tue, 01 Nov 2022 22:47:13 -0700 (PDT) Received: from stoup.. (mur1374950.lnk.telstra.net. [139.130.176.43]) by smtp.gmail.com with ESMTPSA id x5-20020a17090a788500b0020ad53b5883sm551575pjk.14.2022.11.01.22.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 22:47:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: philmd@linaro.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH] target/arm: Two fixes for secure ptw Date: Wed, 2 Nov 2022 16:47:06 +1100 Message-Id: <20221102054706.1015830-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.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: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Reversed the sense of non-secure in get_phys_addr_lpae, and failed to initialize attrs.secure for ARMMMUIdx_Phys_S. Fixes: 48da29e4 ("target/arm: Add ptw_idx to S1Translate") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1293 Signed-off-by: Richard Henderson Tested-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 58a7bbda50..df3573f150 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1357,7 +1357,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, descaddr |= (address >> (stride * (4 - level))) & indexmask; descaddr &= ~7ULL; nstable = extract32(tableattrs, 4, 1); - if (!nstable) { + if (nstable) { /* * Stage2_S -> Stage2 or Phys_S -> Phys_NS * Assert that the non-secure idx are even, and relative order. @@ -2671,6 +2671,13 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, bool is_secure = ptw->in_secure; ARMMMUIdx s1_mmu_idx; + /* + * The page table entries may downgrade secure to non-secure, but + * cannot upgrade an non-secure translation regime's attributes + * to secure. + */ + result->f.attrs.secure = is_secure; + switch (mmu_idx) { case ARMMMUIdx_Phys_S: case ARMMMUIdx_Phys_NS: @@ -2712,12 +2719,6 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, break; } - /* - * The page table entries may downgrade secure to non-secure, but - * cannot upgrade an non-secure translation regime's attributes - * to secure. - */ - result->f.attrs.secure = is_secure; result->f.attrs.user = regime_is_user(env, mmu_idx); /*