From patchwork Mon Oct 24 05:18:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617850 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2521936pvb; Sun, 23 Oct 2022 23:32:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/pMIvO9L+G36N+e8UdNBjV4PsD54XCxHWClI+JQvFvQZ+1CXnOq3vx74siryaSFFlMdwE X-Received: by 2002:a05:6214:300e:b0:4bb:704a:ec5d with SMTP id ke14-20020a056214300e00b004bb704aec5dmr3126471qvb.42.1666593149557; Sun, 23 Oct 2022 23:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666593149; cv=none; d=google.com; s=arc-20160816; b=mFw3B/+wuLjOUfCVUrbZpS8sji/WjTEDlPa72s6F0fy6wvk3QwZ/NzXBrcmofBnmh/ GEhAk4JhEJpGbVkKszNNzRBOKsIMWGY494EGWFdkvm3RD63V0ShYRuYXWzqt/FEP2MXf mi0jahGZBDj9AiwK5LtJu4WadwdMkSW5dcHjPl8bTWznvST0lv31BzJRruI/alHDL11G ItEmOF9lgziPZfvQev4ZAIRkxUONKlv99ogGjGYRY2kV1pAEdtnog3g2TO+115DBiVSn X8gKPkbjDb5AKhu16eh340GwJBrpjJkQqhg+WNwvm3Hfy9WLlb+BS9HFOqCzXd+GIJlY 7k8g== 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:cc:to :from:dkim-signature; bh=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=cpiX6kzx4jFi17vlEBQq3hvA5Iad+hA9MDkISV1+E1VKimsHRYn2J5ywpc4aOX5xge 6oQedsGR68m/U90ETlHeTD7V25rSsMdhx8ne7HLHLhbhZhQbfTayFxYXU4mvHdx+/u9s N5v1Q40L2DBgWGYz5NFfMMDdacBXMH+mJqRQEuORlyM+dGFb1W56t4JiF4u2cYDZWQ07 8DdYAIiG0axPMVvJAHgvH3NswyB6eaP/bZUia5S53waDBXbz+HWZ3Mtzk/+D5h1h86Q/ yljGuQZ2QpxwWAPJQy427d6FwEADBPZG4iE6axyeLpr/XGYNTQU4nNl/wIN8iokDGXhJ Ywjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IfYYdXX5; 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 k2-20020a37ba02000000b006ee0b43d2dfsi14884093qkf.238.2022.10.23.23.32.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 23 Oct 2022 23:32:29 -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=IfYYdXX5; 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 1ompsn-0007Pc-9F; Mon, 24 Oct 2022 01:20:17 -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 1ompro-0006aj-R3 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:20 -0400 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1omprl-0002La-8V for qemu-devel@nongnu.org; Mon, 24 Oct 2022 01:19:14 -0400 Received: by mail-pj1-x1035.google.com with SMTP id m2so3321783pjr.3 for ; Sun, 23 Oct 2022 22:19:12 -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:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=IfYYdXX5BP6H2RKB06MWo2FGklxdm07IL/N5UXRPwLBGTAEP0hqm7919yy3GVGqKjd uaD75kv6DQqxgbZf5VyT0kdfFeTX2Cw4eOAkIIg9ITJdmArWCGyKJcTqEsH6R69cslJy oruTjvQQqUYgs0jrjaXKqb5smIVyxVJwENHfbH8Q7sUgbu2CgUGIXLJbA4gErK1KHQH8 tcxw6VuFgGhQuYc69C//SKX4J9c/07HSugvm/2EVoVAZmRfEQTOAjKPBYWlWnyNrEKw3 AYPSnVcrBCBI1F03zgDwWtz7ZqBnlmB0lzLFLnRN4GPSuYZ86Q5tcAqu9b6HFA06VtdS yIeg== 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=Q9u/CTbpsuyt+vL/yIxrL5pNR478Gk+hKHZIa5AENgq+5hU80mnwf7hSfVzlMs51K3 dSNmPqnC2cbCUUVsCEmrGpOEq4xED6GZ10V0OiBbcYelPZrGYuoDwdZ2awOU6PsVJTmB h4Ku79CS8PsTX/4sN2yuGfYhqSSwWqQUViLPw1KEmIxn1L98Oezw0BZTVV1vw+mGEqb7 rTVAfmSSmapAuliIF88+ocsBWJeXcP9NUhtZUe5JRVlfY13OMzxYL0xtiJoSohMfJnD7 NcXp6cW1qoWS0vUE8l3m+JEORZmRKfcDZNqQvqPsDVabCzK7gDv+VHZEX1PGTtNuW7p4 kojg== X-Gm-Message-State: ACrzQf2YmDessKD80gzXToAZLF6BxAhK/h8u92m6heqaTXllFB1Nq+Zc cpGBj2Gj3NKb+PELry/rWOMl5da62cwddWOB X-Received: by 2002:a17:903:283:b0:186:8a20:c1b6 with SMTP id j3-20020a170903028300b001868a20c1b6mr10784768plr.119.1666588751667; Sun, 23 Oct 2022 22:19:11 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id q12-20020a170902f34c00b00172951ddb12sm1895231ple.42.2022.10.23.22.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Oct 2022 22:19:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 05/14] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Date: Mon, 24 Oct 2022 15:18:42 +1000 Message-Id: <20221024051851.3074715-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024051851.3074715-1-richard.henderson@linaro.org> References: <20221024051851.3074715-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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 Separate S1 translation from the actual lookup. Will enable lpae hardware updates. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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 161b7922e3..36524b35ef 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -319,18 +319,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) { @@ -358,18 +352,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) { @@ -526,7 +514,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; } @@ -564,7 +555,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; } @@ -649,7 +643,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; } @@ -702,7 +699,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; } @@ -1291,7 +1291,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; }