From patchwork Thu Oct 20 22:35:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 616801 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp573149pvb; Thu, 20 Oct 2022 15:38:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7t7W0UtN96zecMb4iSR7oWDhRGPwycA3AvE4A7lF+u/1HrjESWt7iOXqWkc+maDU7lN+Qn X-Received: by 2002:a05:620a:2942:b0:6ee:e447:c3c6 with SMTP id n2-20020a05620a294200b006eee447c3c6mr11453438qkp.434.1666305523973; Thu, 20 Oct 2022 15:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666305523; cv=none; d=google.com; s=arc-20160816; b=uP7j8UFLO12hxkl+oON60iy/wFmYzic1iz+ma1CLGLSeBqXlbAQ7b2qz0IY4+CQ7ir MLOr1zR57ciRwSbIpaoawu7UnniSZcq7NyhctDN8Ft3LEJsuRJ2tBeQAGILOYCPa5iOR EJQMqTsh/qEhMTtPHX7Fwr/fmVk0Ef2Wv0wKcj38/98rsxVdaP9hn6yT7phoXwoOZWmF 1DUPY/AL8S3qLpZt7GAnVhP7uhlwadAMgQr1ak9s62lqDOMmgIahs8GSD2HpDFtlj/8A rAsO8PJKkHvkRGbPPcqWe3uYGCOsEsWZoPaRyKPxz58muup05iqrzjc+jjYKFaczIZBn abdA== 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=4OEjLGxioHnK53AFYFEVfccxIYEwGKi33iPaWC9c5ZM=; b=YhU1fzf2w4d7MNYQ8susuOrqgY8ujcf9ifQW+u62VrynmMzJeMZ9TnndWTOHxbV4xw rTbcWeWXU/2yNOm0GNE6SyPQxvZg6qS9IirKA8znEj9ZdxiPhyFWEH5tFUF9Uq2mqTlY 6ttVXKyIG2hrgH4GovJpfMbU6eijkwOy7t8Zq8Vf2coO2+1iAasaiwyorc549wBaJHjd k2flvuZTw3D22llp5iPsK8Iaf2LnHc+h5ck1pCOpOMdQ74oIUWIgPOTVflDR1X5hb516 jVFu1XPgtYwp248im05boPiqM4R5IUjDRmpAQYWWY289GgsJxsOlO/+75/KNLsKZqUn8 iqwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f+7zdT4C; 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 cn4-20020a05622a248400b00399f295a5e8si11867495qtb.38.2022.10.20.15.38.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Oct 2022 15:38:43 -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=f+7zdT4C; 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=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oleBX-0002Fx-Hb for patch@linaro.org; Thu, 20 Oct 2022 18:38:43 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ole9k-0006X5-Ke for patch@linaro.org; Thu, 20 Oct 2022 18:36:52 -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 1ole9d-0006Mx-1O for qemu-devel@nongnu.org; Thu, 20 Oct 2022 18:36:45 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ole9b-0000z8-CZ for qemu-devel@nongnu.org; Thu, 20 Oct 2022 18:36:44 -0400 Received: by mail-pl1-x630.google.com with SMTP id d24so635715pls.4 for ; Thu, 20 Oct 2022 15:36:42 -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=f+7zdT4CBN2FP77eUVaivjZiIMDB+oaQ8IhO8QEWynrV/DqVQemXhcSV3ofRONJAHw 3fUGFlY1pODuT/Q4h7os9NYxhOhjw5SgyCLif1iXD9lCNCunh2SCeEL6BXO2fp6LkhHB mV9e3txH34ecC4p6NkEj+MU5izvtMePeAgBL18eq63lfUPE3fZrn+ZfrylQIpM1NJOmv wKDL7su7vR7aKO2Tr2BFukm7SmZcVG+4UEaxTAYZUv3lgtleg/LhiYoijYxMle77hTwt D92lh5V1SAvwZkVbSyr83IBPPzeT50D2Kz0rZqEfaL1aMPhuyEeY52I0H3rc5LATZVCK 5B0w== 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=hbqpmHGBATjC2xGRa38VbZ8CcLKtXIH/96DIvZfEzU0mP0GeZR8QHvMQuSv7ixCH2W QNTJhkuU5MGoI8p7burJFQRbmhOHny1y4lrj0te7Y/20CBcLj/tHyhgUltWuwjbkwzl3 X2RKOYqVxB0pnBG8FtCA1s47uK8YYXvoKkheoooCNbjnR7c3+Z3uSa7m5MMxhqGnWB6p CJc43oGVfdANhcWAzOvK6DScNn/aKYfUwRWPUHgvnqPPO+aOOQEel69Zx0aanfsMQjw3 x8oNcD3FO4+4qEE5WgAByvWfYvT+aTTO3LnSg2KFpKnBs3T/mvIG0P3LT0+mIFvqmskL 1rqg== X-Gm-Message-State: ACrzQf3A5bzmsXAgAeZd3/uchxFOWmgLjMvw1XcDgNcTFw7agbYCVqtc ld9MKwZHrDWrrFK1pkAK36UBfOaUAyYOH9Oq X-Received: by 2002:a17:903:4ca:b0:179:d21f:f04b with SMTP id jm10-20020a17090304ca00b00179d21ff04bmr16218531plb.7.1666305402564; Thu, 20 Oct 2022 15:36:42 -0700 (PDT) Received: from localhost.localdomain ([149.135.10.35]) by smtp.gmail.com with ESMTPSA id r10-20020aa7988a000000b0054cd16c9f6bsm13753841pfl.200.2022.10.20.15.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 15:36:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v5 05/14] target/arm: Move S1_ptw_translate outside arm_ld[lq]_ptw Date: Fri, 21 Oct 2022 08:35:39 +1000 Message-Id: <20221020223548.2310496-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020223548.2310496-1-richard.henderson@linaro.org> References: <20221020223548.2310496-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x630.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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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; }