From patchwork Thu Jul 14 13:22:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 590380 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp1574631max; Thu, 14 Jul 2022 06:25:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uYF0b/Jmi2v3WDtQNFAUAyWykNGJkTjhysO4aXaua6AlBFuer4ubhi6q0o9F5zroWwIkEM X-Received: by 2002:a05:622a:50c:b0:31e:c29d:16fd with SMTP id l12-20020a05622a050c00b0031ec29d16fdmr7890051qtx.427.1657805136602; Thu, 14 Jul 2022 06:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657805136; cv=none; d=google.com; s=arc-20160816; b=WrgQzdj1zvu6GMeHI+I/EfKgZkRRon4fpyKbkjn/AvOSFdMpKUsNy/o9XYp8gL3aK9 Yddidatl9CoQUkw0L5f6EPs6Z4h8svNfRyZbzmMqjJLi4LA/5VJwhk1kasR6nt5uL6T7 mxftSrI7iUjm8zXmu5/uhSqw+K43vrI9cX26t+QvtvqfVn2EziSI7aMX/K+hiWkvzSQ3 5FnoI8cZ3i+ozfpt/nsTcVJvh51BzMZ6DW4fOU76ZjKSXCgziJieaLZmdWBhqooJrb/e Ob0JCQAvmaR9/4vhLEiUKsUvIq3+wUW9BhZQUWkrlQXWdpN/I6oTxtZt4KwNM6Un7g2C CmVg== 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=7fzrSUgKfikFHeNFkh9/TCh+g92276JL8XDKKltgm70=; b=MpXdbGwDor4KmdvN+rVvAYW+cFig+JTMz3ykQ0mZs6YJrTrRFK8vKlg8YHKT2Dlwgf +O+BXxN/FHASU+S8oNsP75JrR3uFzuVBkUN7phnsktvOe/jWRQP8nA7taySOJzKeN3zB rLzXhToPaGYtbmhaEr799wAyAI56VOMOOTbWbRsTSHlh/J5snBPqOgBrvUlJFyg+PfrB 8skJ+l3s2UXVEvX3Qyr9oeiS8uKdOPOhsLQSS8FFZQfVmjUa3io5kZMPbIENNbf6dQXD 4JMiar4wuTntESKIAcgbFPOUMZbhyj8tDPM97lrpncTxqmqR7g09YvhkK6qG6VkAsNdv gg3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fkbNBOPc; 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 c11-20020a05622a058b00b0031eb8a3d373si1232026qtb.182.2022.07.14.06.25.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Jul 2022 06:25:36 -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=fkbNBOPc; 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]:33744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oByqW-0002F2-4y for patch@linaro.org; Thu, 14 Jul 2022 09:25:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45786) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oByoA-0002BZ-OE for qemu-devel@nongnu.org; Thu, 14 Jul 2022 09:23:10 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:34639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oByo9-0004oK-5b for qemu-devel@nongnu.org; Thu, 14 Jul 2022 09:23:10 -0400 Received: by mail-wr1-x435.google.com with SMTP id r14so2575997wrg.1 for ; Thu, 14 Jul 2022 06:23:08 -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=7fzrSUgKfikFHeNFkh9/TCh+g92276JL8XDKKltgm70=; b=fkbNBOPc7mP/VK9xdZU8F3BO+d1w6JTnZoYVjmgahER7FgebSBBX/wMsiJ0VyK5g/u aJ4F8HdZ7jFPW73PMRb0TvzCC+pWSDlFf1C10itfaFs3xtvLP86W6Wtzhr9NbBo4cvLt vpGAf/NFYyopFed7HEdFG/kxQq++MbtHN3GjvCNYEmzfy7An7ApyRySuy5sFZxtaZER5 Cn9eDOjPU/ilgI6gfvFWC6BVnxOa3k8dru77KNHjui8KW/O7ZUL5EBbLEbUcQaJHk8wp 5GwDz6+AbDxdV9j5xlDc3HE47aS2m1XHns/Crwvr3EEDFBrJ918X84Cxci63fjed9L7A g9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7fzrSUgKfikFHeNFkh9/TCh+g92276JL8XDKKltgm70=; b=1gzWz876dlxGM7tVq4GzJ+QEn2jvsOGgmKFDSy16+X3u53PH5UKNk85WggW3T5NYXv DpCt4X+7BmjQrsAwK2cIKUK2iWTolyyLZdambbu7Z0+tyCKaj0STyV4cT21aOkwMs2Ml ZIeCJVWUnaZ133AOAt+Sx4R86owtQKOjDD05E1czETdFausuXupb4ktjGeX/yTD+aGJn aj8/2yHVXV34SreametQeuh8KwJpmFIkLIo/N7J/U3wLRUnspIARu7dxiWG/ebntvHLw 334molgwl7m3hF5N2MskXrEa5bGF16dDpA5DiZwdxjhiO4afyrtFbSKFNhOVEE6yytoa kfMA== X-Gm-Message-State: AJIora8svNBTLjdgExys8xx+Zx+MZdfBtpULKdBbScCfuooKdmnRw8tj v62Y7pfrGc2q9xVgfvsH/75oAkRcC1mFDg== X-Received: by 2002:a05:6000:885:b0:21b:a423:172c with SMTP id ca5-20020a056000088500b0021ba423172cmr8323973wrb.98.1657804987582; Thu, 14 Jul 2022 06:23:07 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id k11-20020a7bc40b000000b0039c5cecf206sm1925079wmi.4.2022.07.14.06.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 06:23:07 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Idan Horowitz Subject: [PATCH 2/7] target/arm: Calculate mask/base_mask in get_level1_table_address() Date: Thu, 14 Jul 2022 14:22:58 +0100 Message-Id: <20220714132303.1287193-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220714132303.1287193-1-peter.maydell@linaro.org> References: <20220714132303.1287193-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x435.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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" In get_level1_table_address(), instead of using precalculated values of mask and base_mask from the TCR struct, calculate them directly (in the same way we currently do in vmsa_ttbcr_raw_write() to populate the TCR struct fields). Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/ptw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 0d7e8ffa41b..16226d14233 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -315,20 +315,24 @@ static bool get_level1_table_address(CPUARMState *env, ARMMMUIdx mmu_idx, uint32_t *table, uint32_t address) { /* Note that we can only get here for an AArch32 PL0/PL1 lookup */ - TCR *tcr = regime_tcr(env, mmu_idx); + uint64_t tcr = regime_tcr_value(env, mmu_idx); + int maskshift = extract32(tcr, 0, 3); + uint32_t mask = ~(((uint32_t)0xffffffffu) >> maskshift); + uint32_t base_mask; - if (address & tcr->mask) { - if (tcr->raw_tcr & TTBCR_PD1) { + if (address & mask) { + if (tcr & TTBCR_PD1) { /* Translation table walk disabled for TTBR1 */ return false; } *table = regime_ttbr(env, mmu_idx, 1) & 0xffffc000; } else { - if (tcr->raw_tcr & TTBCR_PD0) { + if (tcr & TTBCR_PD0) { /* Translation table walk disabled for TTBR0 */ return false; } - *table = regime_ttbr(env, mmu_idx, 0) & tcr->base_mask; + base_mask = ~((uint32_t)0x3fffu >> maskshift); + *table = regime_ttbr(env, mmu_idx, 0) & base_mask; } *table |= (address >> 18) & 0x3ffc; return true;