From patchwork Tue Oct 25 16:39:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 618134 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3521337pvb; Tue, 25 Oct 2022 09:51:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kkqSTHkv7k304LK0X6cJEYer10v7pb4pAay/vBCgJnCAe3ugytdxY/P5A/ha8L4/Z3cvD X-Received: by 2002:a05:620a:40d5:b0:6ee:e3f8:20d2 with SMTP id g21-20020a05620a40d500b006eee3f820d2mr27636115qko.14.1666716690175; Tue, 25 Oct 2022 09:51:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666716690; cv=none; d=google.com; s=arc-20160816; b=fY6h5p37epsxtum9Baf4E27Ew2ohgWi9PuuqDJHEmjOaolnn0NWIKayGvse8IlBeNm QO2Jm1gXZrVliKbB4nn1KmRiqmXzGE6rXIeC6lPm/7YnL/l1/zqJ++7JcR+aNbeUNeL+ mlEprzYCci39rhFbsNETz0RhmFJZpNig/d/mo+EKE1eIKKk4N8BUWAvIKZVkK97NgCZu KGTp1j/s7GLWsjJzOx4Z5J01w2hD2xffxR9PdOgR04TNMbF+ouMfOpd/NuIuch2/T3Dq aP/ebsn4ju1SZvabU28l7PligGQI/7jid+wI37q7ZAlCXSDWyxHacLmVjaFZ7fMOzMBJ FcBg== 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:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=M9eE5nsjZqyegEP4MH1Sbkb8QwBPdQnOQ7AKAsrnlSkH0tZ1ymG9FopgJrpvPSP29u nEidqw6nX9MxNm9VzP6mNa6OsIs3Ifrakz0Grme7csHEeFTxRCp21/hZkXIYuLiuwdKx DrqOuWy9Slm4twY5ABKsmRHbvXyafIgDMnYS6/0vE3j1lXZLlf+i/t7oZPsCP1Q2L9Od 1vKn42X4BvTNgjUc8nnVstJsoAkU+zvCS0k8/na+P3xyFqe6QPQpsWUEmfcFyHoNJN8n PQ74E52MSGO3gWTLqvOQB2Cujvy7TcCmulmKntr/oGojwBi/6gxrTcmnOj48E3N+0g9w jzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RGjHJo4k; 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 i14-20020a05620a404e00b006cecb19c97esi2332043qko.29.2022.10.25.09.51.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Oct 2022 09:51:30 -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=RGjHJo4k; 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 1onMyc-000665-4C; Tue, 25 Oct 2022 12:40:30 -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 1onMyR-0005lA-L4 for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:19 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1onMyI-0001bS-Lh for qemu-devel@nongnu.org; Tue, 25 Oct 2022 12:40:19 -0400 Received: by mail-wr1-x42d.google.com with SMTP id a14so19284926wru.5 for ; Tue, 25 Oct 2022 09:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=RGjHJo4kPSLLAzBsez5vE7dhMLWDy7VIytb459BJOLf3eOjIxdZDO5N7C7hCZkBDHl Dsxy+pitYf+oALYoEqrWwVpDhzYKoQcHy9VYIoHBTD68dtSGaC0h8DZYaIusISSyMdsD Tr330WqnUAfdqqXR+9bFVQBq19wVkUByvhMjB7VsMFT7ZJHM22zBUc0LHzJcqMVp0GAq ziIQS4hTPCGytWi0V/XzSb9j+02blef6cpj1uT1mDLJ3GHhmI8ahxqX81ZmsrbgWIHkr ZAonVLkUZv9W1WgT5PFQAocpMsp9osDUAeY82lKODCDDfjaya2McS8/VURVEvw9NMsVU aXkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h6xCcu8StBL3pe5a7E0ohO4YG9jcw79bAXoYz4WfMPo=; b=XukQllgcTThbpPinvzn2YyESxOSnn+VdnRSB6hFY56dvl0d0Dku6R/YAcfrqHEbKbK ffNnQ54FV9jVhgpFswHBg/yUnD2zHi1Ght5BtJis1WtG9DpKGHGUyFwJwuDEmk1bAuXb VORIQ5g2S0zGo0BxY/jyn4L6EduXrwswFbBgM2Eqm71F82eVtqHEg2Y/XvXK4uuaAAlQ dGZC7XJWtD45sWVbzQG03UtZoEy02JRod3mAZIoMq+3VMW4Ss1p+Umr9de2O/9uNGHJl 9csUfWqCAFhbPYmvCCrWRmxFe3rU6upEE52kP3oQFA7woDSJjvj1enjz4/HBOI8DhtMx FlTw== X-Gm-Message-State: ACrzQf0NW7jFFztjFgVUnAt63JYPtrqe40tpMAQ1NbApJsG1c70NFvZv hHbyuKSr61i+S07UTIk9Reja84qTK16nag== X-Received: by 2002:a5d:6185:0:b0:236:776f:2bed with SMTP id j5-20020a5d6185000000b00236776f2bedmr6279415wru.535.1666716008263; Tue, 25 Oct 2022 09:40:08 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id z12-20020a05600c220c00b003cd9c26a0basm2971084wml.40.2022.10.25.09.40.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:40:06 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/30] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Date: Tue, 25 Oct 2022 17:39:33 +0100 Message-Id: <20221025163952.4131046-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221025163952.4131046-1-peter.maydell@linaro.org> References: <20221025163952.4131046-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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, 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 From: Richard Henderson Separate S1 translation from the actual lookup. Will enable lpae hardware updates. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Message-id: 20221024051851.3074715-6-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- target/arm/ptw.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 3c153f68318..44341a9dbcb 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -300,18 +300,12 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, } /* All loads done in the course of a page table walk go through here. */ -static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr, +static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); uint32_t data; - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -339,18 +333,12 @@ static uint32_t arm_ldl_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr, return data; } -static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, hwaddr addr, +static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw, ARMMMUFaultInfo *fi) { CPUState *cs = env_cpu(env); uint64_t data; - if (!S1_ptw_translate(env, ptw, addr, fi)) { - /* Failure. */ - assert(fi->s1ptw); - return 0; - } - if (likely(ptw->out_host)) { /* Page tables are in RAM, and we have the host address. */ if (ptw->out_be) { @@ -507,7 +495,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw, fi->type = ARMFault_Translation; goto do_fault; } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -545,7 +536,10 @@ static bool get_phys_addr_v5(CPUARMState *env, S1Translate *ptw, /* Fine pagetable. */ table = (desc & 0xfffff000) | ((address >> 8) & 0xffc); } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -630,7 +624,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw, fi->type = ARMFault_Translation; goto do_fault; } - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -683,7 +680,10 @@ static bool get_phys_addr_v6(CPUARMState *env, S1Translate *ptw, ns = extract32(desc, 3, 1); /* Lookup l2 entry. */ table = (desc & 0xfffffc00) | ((address >> 10) & 0x3fc); - desc = arm_ldl_ptw(env, ptw, table, fi); + if (!S1_ptw_translate(env, ptw, table, fi)) { + goto do_fault; + } + desc = arm_ldl_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; } @@ -1272,7 +1272,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, ptw->in_ptw_idx &= ~1; ptw->in_secure = false; } - descriptor = arm_ldq_ptw(env, ptw, descaddr, fi); + if (!S1_ptw_translate(env, ptw, descaddr, fi)) { + goto do_fault; + } + descriptor = arm_ldq_ptw(env, ptw, fi); if (fi->type != ARMFault_None) { goto do_fault; }