From nobody Wed Apr 16 15:36:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155077561331273.64124455657088; Thu, 21 Feb 2019 11:00:13 -0800 (PST) Received: from localhost ([127.0.0.1]:36878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtZq-000275-8p for importer@patchew.org; Thu, 21 Feb 2019 14:00:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXj-0008NC-44 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXg-0007Mx-Eh for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:58 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:35614) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXV-0007Gl-LK for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:57:49 -0500 Received: by mail-wm1-x334.google.com with SMTP id y15so10336961wma.0 for ; Thu, 21 Feb 2019 10:57:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c18sm29065085wre.32.2019.02.21.10.57.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xUAIzDpNWv8YnIShod0ImX2EP9PZydu99S3FvI92H14=; b=OZl0YjBvOAQF3KG4MZfX66qbuojlhuOXl/CFTrwNXKI9o704ydaYBoAyr78J7cqQap yqvwflfns70eDuFKxdJGske/+buqezPdtFJt/q+yk1eJyi75ZA++lv5pVMOcz7mOi0vh kOxlDkSdmnpaHCk9n7+3n48hzmmsHuWehMD0lG9sdQvce+s2sjYbkMK34DUPdi/s7wiF aEAgF8mLCHImfLVEz63I6ZHWqMxi2Nx9Y42WBso2g2LOEwyomez1x/qtmTSjIHFnkG4I Y0plNVssbiXQ35qrupItiMmcaRljHohERN+KCH/B2qeZPmQ/odzCctdtyvVtAJQ0gNHm V+2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xUAIzDpNWv8YnIShod0ImX2EP9PZydu99S3FvI92H14=; b=cMP5OJ6ZYdL/iWZVjQiWk17RZerd8rBk3DEQYR7YS2NKwZpb8vFaWk60qvsxpPRTPj ge53CNv1x1ntfo7PMvNI4ouATb/0CN8bhTl3rVZqDsZ6PHDCs3yTmcRGsVFlBdgc4Dvc N+PjtNEflSzhqFYLGeUhDa1WGaYKsqqd1ijuJ3hEfjFVbGu47rrCitCL1B/S3dF7Mi1T 89niI0bEv2a6UDF8GrUdUvaOTftIVZHlC9cb87MJuoUpyvlbPZPvmthhPkmRvbNh85xH 1m3pErJYCw93HkGL1VEwnWYan4lOROIkGEOx+V8YL8+JnMg2OrAYSwXxiLMGLuenQeHp taiA== X-Gm-Message-State: AHQUAua3V+ihSK5ETp8WC5GdZIwY1wStN1vpnl99xe73Uv8kaCm9Iuy5 uwz81hfJHbFgtcBdBHXlWESqPgq7hMw= X-Google-Smtp-Source: AHgI3IYbPm/xTC1B6g3R2fUrTskn79PXLir2BX32ryoptHe1RBPkDvq5uZElHNswOSb6gAHl8PpBPA== X-Received: by 2002:a1c:3b06:: with SMTP id i6mr11298854wma.55.1550775464293; Thu, 21 Feb 2019 10:57:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:20 +0000 Message-Id: <20190221185739.25362-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221185739.25362-1-peter.maydell@linaro.org> References: <20190221185739.25362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 Subject: [Qemu-devel] [PULL 02/21] target/arm: v8M MPU should use background region as default, not always X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The "background region" for a v8M MPU is a default which will be used (if enabled, and if the access is privileged) if the access does not match any specific MPU region. We were incorrectly using it always (by putting the condition at the wrong nesting level). This meant that we would always return the default background permissions rather than the correct permissions for a specific region, and also that we would not return the right information in response to a TT instruction. Move the check for the background region to the same place in the logic as the equivalent v8M MPUCheck() pseudocode puts it. This in turn means we must adjust the condition we use to detect matches in multiple regions to avoid false-positives. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190214113408.10214-1-peter.maydell@linaro.org --- target/arm/helper.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index a018eb23fe2..fe054897c78 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11387,9 +11387,11 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, ui= nt32_t address, hit =3D true; } else if (m_is_ppb_region(env, address)) { hit =3D true; - } else if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { - hit =3D true; } else { + if (pmsav7_use_background_region(cpu, mmu_idx, is_user)) { + hit =3D true; + } + for (n =3D (int)cpu->pmsav7_dregion - 1; n >=3D 0; n--) { /* region search */ /* Note that the base address is bits [31:5] from the register @@ -11427,7 +11429,7 @@ static bool pmsav8_mpu_lookup(CPUARMState *env, uin= t32_t address, *is_subpage =3D true; } =20 - if (hit) { + if (matchregion !=3D -1) { /* Multiple regions match -- always a failure (unlike * PMSAv7 where highest-numbered-region wins) */ --=20 2.20.1