From patchwork Wed Feb 22 02:33:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655667 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp456321wrb; Tue, 21 Feb 2023 18:36:10 -0800 (PST) X-Google-Smtp-Source: AK7set/MGGQRSlyqyvjqy48pdYp3mhslv+aEBfAPxcfl1bYTJJgnbMr1tYlbpt6uyECcbP1ec7l+ X-Received: by 2002:a05:6214:c41:b0:53c:c2d1:e3da with SMTP id r1-20020a0562140c4100b0053cc2d1e3damr10752940qvj.2.1677033370783; Tue, 21 Feb 2023 18:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677033370; cv=none; d=google.com; s=arc-20160816; b=QSXMO90RxVfdEW8G1CZn3zJnj8Cm8bu+fe/5XcYeu7OelL5fWAkCzhExmQJ5+9TtLR fNVlIwjx+njtJQxzkhMLv56koSVybvGA8wTMU50yH4YC4lu9v7SDPNDcuYsz5ZiTAuNp LA6x8nPcqubBdQJtAbHFG+keAP2cMuRWEij2aE+610NxzdBVej98gfI7VysgWFeXyYxF jrnfyrnF+/SxywihgeZBzoxp9gKhu8K64DG8BTHWEndYDwwUPBgQT1BPWsOoFDXEikBi 4Oe04gMqWbT7EuNHbeeJsxHKUUvuSy9PJlobgjxq/Ww40CWuKi0ULSmq1iAqpMVVs6Qn +sfA== 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=AEaPa3mWe3IpmNaEY7zBYHLgHnvDHdVZm/A7K3Apt8Y=; b=DHtcU08FoC4cq5nr8U/q8VBxeu1MSkEFjffaDWz6udF0K0riqCTyQKv2rS1wj4pZNa lnkYRx38MK4BV03/vacKQxzT1fk4fZxhdQGolsap4iMNTSzcJy1VjL2MXpqKR4c2aLGH VZOmBDs5axsVVWbEvfmhkufOCuns5ca7qFuvUoS4W5yRNYGQ3s3Wasfdoafwf19nUeju +9Ra9G6FfaMN9pFh8fyeZZfUqBfJOmzu9lNsIpIQxqcd8DBHoT0Y93VhwH0fZFTCbruC StLVPmYOkHW0sdUbeEOQ6fBzudT43JzFKXvf59RfsGBSNL06UEtrdbB7W1Luhkf9jPSN m5BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=slrKf1w6; 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 m4-20020a0cf184000000b0056c227e9a1dsi13604196qvl.253.2023.02.21.18.36.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 18:36:10 -0800 (PST) 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=slrKf1w6; 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 1pUexS-0007en-DE; Tue, 21 Feb 2023 21:34:14 -0500 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 1pUexN-0007UM-25 for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:34:09 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUexL-0001cv-5H for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:34:08 -0500 Received: by mail-pj1-x102c.google.com with SMTP id co23-20020a17090afe9700b002341fadc370so7074443pjb.1 for ; Tue, 21 Feb 2023 18:34:06 -0800 (PST) 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=AEaPa3mWe3IpmNaEY7zBYHLgHnvDHdVZm/A7K3Apt8Y=; b=slrKf1w6o8G4NW/9zKU1h5yPBXZfsL4a0cJB1a6Ukz/H9WhpisMiKUYSScCVykneJa pRoF2/UjqnD/Y234vXIg0/TfY/3B+I703ZaKROmjWTtEcMBYSKKy/Vpsf0AxVrNormEU aoMQruspCfS9lmKN5tFry+n9QemaobUjq888g5uH1HJGBm9ndf9/cLj0UgIssG5qImYs xPLTfuO0v9kveGUfFoW94jiEeeBZIrZ8nsgXIUMyJaqrEgH85VYzzu9vlqqc8PPA3/Y0 KASd27EMjIEsnnabDaNan28JO1hKNMLbuEGUd6HRJ/xXPpMTbsG2dv+v7OrrpxS6OaNg /YpA== 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=AEaPa3mWe3IpmNaEY7zBYHLgHnvDHdVZm/A7K3Apt8Y=; b=SwIcUKIJf5ncCMTZ4pBU7XfcrSrUBViTpf4QgrtdYVmcrbDsuCcDZpp8qFUmsuuZlQ ANwJ+RIW9VNFAFmojMxNYCtJZqiaAwts4vUy5nmmuyOhPWdvOgG1Ma19IObb42+mXkkr NVAWIWOi/LptKizLQEc+IjMTzoObotnsDOl6b1cRqnHAhTh55ot+nw9ZwEkZ47+c2HRV 2GK37BjkQaZ+xefhe9euHcRTM7tdOjWpEjkOu3VjwRRKzNgOYafjhIkHrG4hRKoGNt5H Ladr96+cRv0Bj9MkvJZKfkbA7IiqxzKXgNWBfmNC9KAmWpp3sklaKriT2EfG+RN4cYRS j4Zw== X-Gm-Message-State: AO0yUKWvNaHGiysZMHeIXBPvWBPzX8iqcHUGp5Am+FMo6v3FVwFhc6f0 PEM8Rwhm5ggmnmwZkjee8bHmUJbOW3yZNamZnHo= X-Received: by 2002:a17:902:f98d:b0:19a:ac93:64a with SMTP id ky13-20020a170902f98d00b0019aac93064amr6549667plb.18.1677033246130; Tue, 21 Feb 2023 18:34:06 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id k3-20020a170902e90300b00198fde9178csm10520112pld.197.2023.02.21.18.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:34:05 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 19/25] target/arm: Move s1_is_el0 into S1Translate Date: Tue, 21 Feb 2023 16:33:30 -1000 Message-Id: <20230222023336.915045-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230222023336.915045-1-richard.henderson@linaro.org> References: <20230222023336.915045-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102c.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-bounces+patch=linaro.org@nongnu.org Instead of passing this to get_phys_addr_lpae, stash it in the S1Translate structure. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/ptw.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 8a31af60c9..6fa3d33a4e 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -22,6 +22,12 @@ typedef struct S1Translate { ARMSecuritySpace in_space; bool in_secure; bool in_debug; + /* + * If this is stage 2 of a stage 1+2 page table walk, then this must + * be true if stage 1 is an EL0 access; otherwise this is ignored. + * Stage 2 is indicated by in_mmu_idx set to ARMMMUIdx_Stage2{,_S}. + */ + bool in_s1_is_el0; bool out_secure; bool out_rw; bool out_be; @@ -32,8 +38,7 @@ typedef struct S1Translate { } S1Translate; static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, - uint64_t address, - MMUAccessType access_type, bool s1_is_el0, + uint64_t address, MMUAccessType access_type, GetPhysAddrResult *result, ARMMMUFaultInfo *fi); static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, @@ -1255,17 +1260,12 @@ static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, * @ptw: Current and next stage parameters for the walk. * @address: virtual address to get physical address for * @access_type: MMU_DATA_LOAD, MMU_DATA_STORE or MMU_INST_FETCH - * @s1_is_el0: if @ptw->in_mmu_idx is ARMMMUIdx_Stage2 - * (so this is a stage 2 page table walk), - * must be true if this is stage 2 of a stage 1+2 - * walk for an EL0 access. If @mmu_idx is anything else, - * @s1_is_el0 is ignored. * @result: set on translation success, * @fi: set to fault info if the translation fails */ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, uint64_t address, - MMUAccessType access_type, bool s1_is_el0, + MMUAccessType access_type, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) { ARMCPU *cpu = env_archcpu(env); @@ -1598,7 +1598,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1Translate *ptw, result->f.prot = get_S2prot_noexecute(ap); } else { xn = extract64(attrs, 53, 2); - result->f.prot = get_S2prot(env, ap, xn, s1_is_el0); + result->f.prot = get_S2prot(env, ap, xn, ptw->in_s1_is_el0); } } else { int nse, ns = extract32(attrs, 5, 1); @@ -2820,7 +2820,6 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, bool ret, ipa_secure, s2walk_secure; ARMCacheAttrs cacheattrs1; ARMSecuritySpace ipa_space, s2walk_space; - bool is_el0; uint64_t hcr; ret = get_phys_addr_with_struct(env, ptw, address, access_type, result, fi); @@ -2845,7 +2844,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, s2walk_space = ipa_space; } - is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; + ptw->in_s1_is_el0 = ptw->in_mmu_idx == ARMMMUIdx_Stage1_E0; ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; ptw->in_ptw_idx = arm_space_to_phys(s2walk_space); ptw->in_secure = s2walk_secure; @@ -2864,8 +2863,7 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, ret = get_phys_addr_pmsav8(env, ipa, access_type, ptw->in_mmu_idx, is_secure, result, fi); } else { - ret = get_phys_addr_lpae(env, ptw, ipa, access_type, - is_el0, result, fi); + ret = get_phys_addr_lpae(env, ptw, ipa, access_type, result, fi); } fi->s2addr = ipa; @@ -3041,8 +3039,7 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, } if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, ptw, address, access_type, false, - result, fi); + return get_phys_addr_lpae(env, ptw, address, access_type, result, fi); } else if (arm_feature(env, ARM_FEATURE_V7) || regime_sctlr(env, mmu_idx) & SCTLR_XP) { return get_phys_addr_v6(env, ptw, address, access_type, result, fi);