From patchwork Tue Oct 11 03:18:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 614153 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2370833pvb; Mon, 10 Oct 2022 20:29:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4DHBEIquXzzj2SO0SiX62Ru19Lgsej3R3OlalLKRcoKfEyuWypGiefmniv+iGzGQ1uEWM6 X-Received: by 2002:a05:620a:c85:b0:6ee:6fcf:cd45 with SMTP id q5-20020a05620a0c8500b006ee6fcfcd45mr2613562qki.595.1665458992485; Mon, 10 Oct 2022 20:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665458992; cv=none; d=google.com; s=arc-20160816; b=vh9Yzr75ET91758JeAkhej1HV6yqVyRxn6Gqnf/dxDYGTXnA5j68TsLFBvOcwZuN4n HfzRlsculJqESJwBNZR/4iAnBbM8HKyggMP2Aw31tlz1UUMVVDtapwMftiBTEF2fs9kn foWXmLtW0xM3NY4cGK/4KM2gEttDyakursLeGG7ytbUH64fKiFpJI7eflev2TeISpNx9 GHbLHsWLG0t4E+uFAq1qnSI8V2dkzDyoXkbsbLeviJp9J5T6PzGsMoKOV/LD/nT/vsDz wi93ZAJEetmWxt3bupRg007FkYDlXw2A9IKQEMSdIoRwHqAk4PbnAPO4tIC/Uq9vSMFt c7RQ== 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=xuiahaoEiVXlEWMWoZrC9RsYeFhfjxrmLG3QQS2jVro=; b=n4/DE20pqqhVO0WsMczslc4Lol38ArWRAMFBlvHY023WmCd/nTG7n/bFrZ+5hAqFu+ G8nk+jzfxJXw7m5VVurX+a/XtBTwTSqJ9XYHBqBcGv91ONsZZo5d2d/HhEQh6bER/qvO ResJP/xz/zIVY+vv7sRTqsykWlisCE552VBcFA69+myQg3cCTpnCCiavm5pXEHmbXR9g BfKLAuKDO64AKOUb4RRNlQuqJXryizLvDjFyTqziArNemIeBCkGRB39ONfoFaOytJo6V Scj4L+J+wjO/ekmcsB8gyppbO/RxMhW/S8iruYloQzplOuYoC3ewVeszQtXaAjirFgx5 xI/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GiM3QLQV; 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 h13-20020ac8514d000000b00342fa30095asi6101564qtn.55.2022.10.10.20.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 20:29:52 -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=GiM3QLQV; 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]:46724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi5xo-0002tM-0U for patch@linaro.org; Mon, 10 Oct 2022 23:29:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33670) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi5nr-0002NT-Rk for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:19:38 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:44581) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oi5nk-00031I-MT for qemu-devel@nongnu.org; Mon, 10 Oct 2022 23:19:35 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x6so11999983pll.11 for ; Mon, 10 Oct 2022 20:19:27 -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=xuiahaoEiVXlEWMWoZrC9RsYeFhfjxrmLG3QQS2jVro=; b=GiM3QLQVJoJRttJ8CKLTLc0SgJ7+E527/RkG+z2N+oeoz7/4LEpHKgCa3K4u+/aMGY esXyczKHzLHOsYxAgKk/pvGU8/O5noPw5KN9KlxlX0S/FMGNaCrLb8PxUo3KNCe862oe TNNnJSEQderXVV65LEFZptBXmhLk1cnbjKcv4ZoSmElD18ITH+mONAFj1nJA+WhRxEVJ sO4oMA0c+y78uaYOkggtR7Aw1w8HzV/IBe3SvD0NTtO3Tw5m+z1xp6OgJ9lbQxKBI1VP Ziav712riKXjoRZXX2iFkemKeTQb+jj6wbU6PSSltq3dZLmq9aW8EefOyZDStjBbnY9N bxvw== 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=xuiahaoEiVXlEWMWoZrC9RsYeFhfjxrmLG3QQS2jVro=; b=f3+geYeoGjlb25a2LK/Z9k9tBSSO4AUzKwU1I1qqsr93H6+kDgM7RyYtj4OdjS06on viQgBY/nCm9Mck2ODY87f0IxjLFIOOffoGecc9OBc7maTd/Urgdrli+chxhZ1VmEIAAG O39JH4stSqDv4DNScAdb0bC+QIzTjCtfM+2ETjoNBDH+8+aEv8k4MW/5dFqxjgB96y7A 88NZ3F95Hfc7t9EbAusgNMpfeMGDPKHq0setad2ESZEoIHhRUH7mPHXmVEA664BUhuS0 +D7jtMUsVwH5s2Y3CFP7QCC06Kd5tQkGME2Rp1q/9MXSc/qeFgOq3Th8Tko7+frb1O1F pqKQ== X-Gm-Message-State: ACrzQf1/6rpZtRLdqqTdyiL5vocUGYz8+AgGJsmAadHZhaDZ2/IKxtlU NcjN739gtdwL0r2B8UFvpfH9l3SdD7lJkA== X-Received: by 2002:a17:90a:e7cd:b0:20a:c658:c185 with SMTP id kb13-20020a17090ae7cd00b0020ac658c185mr24710531pjb.114.1665458366555; Mon, 10 Oct 2022 20:19:26 -0700 (PDT) Received: from stoup.. ([2602:47:d49d:ec01:5aa4:aba1:1c91:a9b7]) by smtp.gmail.com with ESMTPSA id o74-20020a62cd4d000000b0055f209690c0sm7663567pfg.50.2022.10.10.20.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 20:19:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v4 08/24] target/arm: Plumb debug into S1Translate Date: Mon, 10 Oct 2022 20:18:55 -0700 Message-Id: <20221011031911.2408754-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221011031911.2408754-1-richard.henderson@linaro.org> References: <20221011031911.2408754-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62c.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=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" Before using softmmu page tables for the ptw, plumb down a debug parameter so that we can query page table entries from gdbstub without modifying cpu state. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v4: Add debug to S1Translate, and plumb the S1Translate structure down from the very outside. It means that S1Translate is now perhaps mis-named, but it also eliminates the "secure_debug" function name. --- target/arm/ptw.c | 55 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index dee69ee743..8fa0088d98 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -17,6 +17,7 @@ typedef struct S1Translate { ARMMMUIdx in_mmu_idx; bool in_secure; + bool in_debug; bool out_secure; hwaddr out_phys; } S1Translate; @@ -230,6 +231,7 @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, S1Translate s2ptw = { .in_mmu_idx = s2_mmu_idx, .in_secure = is_secure, + .in_debug = ptw->in_debug, }; uint64_t hcr; int ret; @@ -2370,13 +2372,15 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, return 0; } -bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, - MMUAccessType access_type, ARMMMUIdx mmu_idx, - bool is_secure, GetPhysAddrResult *result, - ARMMMUFaultInfo *fi) +static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, + target_ulong address, + MMUAccessType access_type, + GetPhysAddrResult *result, + ARMMMUFaultInfo *fi) { + ARMMMUIdx mmu_idx = ptw->in_mmu_idx; ARMMMUIdx s1_mmu_idx = stage_1_mmu_idx(mmu_idx); - S1Translate ptw; + bool is_secure = ptw->in_secure; if (mmu_idx != s1_mmu_idx) { /* @@ -2392,8 +2396,9 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, bool is_el0; uint64_t hcr; - ret = get_phys_addr_with_secure(env, address, access_type, - s1_mmu_idx, is_secure, result, fi); + ptw->in_mmu_idx = s1_mmu_idx; + ret = get_phys_addr_with_struct(env, ptw, address, access_type, + result, fi); /* If S1 fails or S2 is disabled, return early. */ if (ret || regime_translation_disabled(env, ARMMMUIdx_Stage2, @@ -2413,9 +2418,9 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, s2walk_secure = false; } - ptw.in_mmu_idx = + ptw->in_mmu_idx = s2walk_secure ? ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2; - ptw.in_secure = s2walk_secure; + ptw->in_secure = s2walk_secure; is_el0 = mmu_idx == ARMMMUIdx_E10_0; /* @@ -2427,7 +2432,7 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, cacheattrs1 = result->cacheattrs; memset(result, 0, sizeof(*result)); - ret = get_phys_addr_lpae(env, &ptw, ipa, access_type, + ret = get_phys_addr_lpae(env, ptw, ipa, access_type, is_el0, result, fi); fi->s2addr = ipa; @@ -2534,19 +2539,29 @@ bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, is_secure, result, fi); } - ptw.in_mmu_idx = mmu_idx; - ptw.in_secure = is_secure; - if (regime_using_lpae_format(env, mmu_idx)) { - return get_phys_addr_lpae(env, &ptw, address, access_type, false, + return get_phys_addr_lpae(env, ptw, address, access_type, false, result, fi); } else if (regime_sctlr(env, mmu_idx) & SCTLR_XP) { - return get_phys_addr_v6(env, &ptw, address, access_type, result, fi); + return get_phys_addr_v6(env, ptw, address, access_type, result, fi); } else { - return get_phys_addr_v5(env, &ptw, address, access_type, result, fi); + return get_phys_addr_v5(env, ptw, address, access_type, result, fi); } } +bool get_phys_addr_with_secure(CPUARMState *env, target_ulong address, + MMUAccessType access_type, ARMMMUIdx mmu_idx, + bool is_secure, GetPhysAddrResult *result, + ARMMMUFaultInfo *fi) +{ + S1Translate ptw = { + .in_mmu_idx = mmu_idx, + .in_secure = is_secure, + }; + return get_phys_addr_with_struct(env, &ptw, address, access_type, + result, fi); +} + bool get_phys_addr(CPUARMState *env, target_ulong address, MMUAccessType access_type, ARMMMUIdx mmu_idx, GetPhysAddrResult *result, ARMMMUFaultInfo *fi) @@ -2595,12 +2610,16 @@ hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + S1Translate ptw = { + .in_mmu_idx = arm_mmu_idx(env), + .in_secure = arm_is_secure(env), + .in_debug = true, + }; GetPhysAddrResult res = {}; ARMMMUFaultInfo fi = {}; - ARMMMUIdx mmu_idx = arm_mmu_idx(env); bool ret; - ret = get_phys_addr(env, addr, MMU_DATA_LOAD, mmu_idx, &res, &fi); + ret = get_phys_addr_with_struct(env, &ptw, addr, MMU_DATA_LOAD, &res, &fi); *attrs = res.f.attrs; if (ret) {