From patchwork Wed Feb 22 02:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 655675 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp456919wrb; Tue, 21 Feb 2023 18:38:03 -0800 (PST) X-Google-Smtp-Source: AK7set/dUuhoX8fqVot1itvnp6fjApQsEQAYoPY8x4VhvXpX8vBv4yEHyzF63ATbGK5aW1Jh3ljk X-Received: by 2002:ac8:5cd4:0:b0:3bd:d8f:2d7a with SMTP id s20-20020ac85cd4000000b003bd0d8f2d7amr12665619qta.55.1677033483516; Tue, 21 Feb 2023 18:38:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677033483; cv=none; d=google.com; s=arc-20160816; b=OMqdA0hzTnomjFhcIXtUHUByzKUg+CUdyEmizo+l7TYZ/WJWIbgGg8PUuGBycAHIH+ /asvoejaBdzgTHqU5HtcmzQs/gvFUz1/ABj/yNffXFh7H7IaMwumcFstnWAQKqlVz7VN v9c8eVUaC6v/CVaNGEWBuncJMLH9e9PCqZlbxrx2d1C1PINF3El1QpSUiK4Obj8tesaY PAuRbMLjBmjO/Fl+2TX3bFmYX+D6bIy/E5rKroRD+QpPRctSsZrVd0hkfOBtppK4lUdw hrb1q0VM8mPAlO8HlGcderTHU7XyNuy4UaXEpoUHsNyDbynfF1MfLy9nnw3e4dq299fM eWgw== 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=ManreqguuHsU2H8Z3wJmlF43bUQxuUikBGpUaE6IsMg=; b=XIdLFX1dBNHiT4HxAmUGfacxWDn4qVuBFZ4f21qbPOk8UyxJmGwEGLIYqLEVQP5RKW y5MHfoscJuC7DBM8UxaF9PwvZdnF6zdZtRWzyRVAqUOixmYnjbbvEDYiHMDVebC/aHFa 33dTRW5zkAmbAjY1PcWJI4TmUGjwgZgMOU02VOtw5YC/xuz7b9yXY4cF769GKfW/Lqba uKG5wjW3LEmYez5kDZs/Aq6hv2PcafEb4+pLINs1WN1ZUEM+MYbI00T+nwCsooIblLtD +5hoCC3QrT0zZTXpjwd5IZeuC+QXycaRns1PlUf/HhEHYJmlx2EtQ8i+CAyYCqgWDzeU i+Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AocALbKh; 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 f62-20020a37d241000000b00738d7b3a1cfsi12494722qkj.111.2023.02.21.18.38.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 18:38:03 -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=AocALbKh; 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 1pUexR-0007cE-62; Tue, 21 Feb 2023 21:34:13 -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 1pUexC-0007Me-U8 for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:33:59 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUexB-0001bU-9I for qemu-devel@nongnu.org; Tue, 21 Feb 2023 21:33:58 -0500 Received: by mail-pj1-x102a.google.com with SMTP id pt11so7907002pjb.1 for ; Tue, 21 Feb 2023 18:33:56 -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=ManreqguuHsU2H8Z3wJmlF43bUQxuUikBGpUaE6IsMg=; b=AocALbKhIYvuNsOUP/0nu8WLrw99RivhRd9ADiuobvqEf0OQjBBfObn4Hb9advEU/x LNau8XUsMhF4LjZRz/ojZajfEJY+LjTY3YPZbu3jtZl4tY4CkzHQqZ5F41JPx0rnnaEi 1AchgoEsD+vF7gWzmlhnUJuSFinUFTTcdY0Ql6VqVl4PavafqwHZzlXFVHzl86cc7Ugj bzNF40XFXXVJgEG7eKsYfGEEIWGQo79fxJiQaEFDE3d2gAlx5eIYuVUche3s07sgHKEO DxP+uvdxAt+oLleOjyQ9bBIyHH0VAY1MiMKoI6hNBh98JwncSbD0/zMqhhhbNKNc2GwL KO5g== 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=ManreqguuHsU2H8Z3wJmlF43bUQxuUikBGpUaE6IsMg=; b=XRpskHfhoghz9QiK5ffDTFW3EzdyKGnn8qZ0+8LTWhkR7KlC4EO33HhtUiQQszuQ0A zsGoimsBUkhOcJ6p+tcBj25XXMhEFt0dk/GG5jZIJiwkXuFvorfyNn/VFiSegoaMZGhu 06gZ2EjjG9Tn45x9pbR4acWXCZa6+Tib+T6qVV8ekeB44DcrVpEyR/HFm3osNEqYjZdZ 2o+ZP1HLvoWn02hGqNoGSWaZtKTQHyXrpXuC+DIMv+fdYj1QWY9jDwLJo3VmBQOppUbY w5T91RTR/vuPmi9soDt+ehCJ6LmxxF3zr4HNk/rX4LaZpP3KmvfVLDOImO8fEulyhcFy s11g== X-Gm-Message-State: AO0yUKUF/CXJdHMcr7N/mIveofQNZ+DwT2yozPc/FZNdHMMfrxEgrtLW hd7yRGj3BauvrQfnJ94kmx0iY+tKwDBgFsWw0eU= X-Received: by 2002:a17:902:e80f:b0:19b:afb:b92e with SMTP id u15-20020a170902e80f00b0019b0afbb92emr11077986plg.40.1677033236537; Tue, 21 Feb 2023 18:33:56 -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.33.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 18:33:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v3 12/25] target/arm: Introduce ARMMMUIdx_Phys_{Realm,Root} Date: Tue, 21 Feb 2023 16:33:23 -1000 Message-Id: <20230222023336.915045-13-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::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.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 With FEAT_RME, there are four physical address spaces. For now, just define the symbols, and mention them in the same spots as the other Phys indexes in ptw.c. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/cpu-param.h | 2 +- target/arm/cpu.h | 23 +++++++++++++++++++++-- target/arm/ptw.c | 10 ++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu-param.h b/target/arm/cpu-param.h index 53cac9c89b..8dfd7a0bb6 100644 --- a/target/arm/cpu-param.h +++ b/target/arm/cpu-param.h @@ -47,6 +47,6 @@ bool guarded; #endif -#define NB_MMU_MODES 12 +#define NB_MMU_MODES 14 #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c5fc475cf8..05fd6e61aa 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2865,8 +2865,10 @@ typedef enum ARMMMUIdx { ARMMMUIdx_Stage2 = 9 | ARM_MMU_IDX_A, /* TLBs with 1-1 mapping to the physical address spaces. */ - ARMMMUIdx_Phys_S = 10 | ARM_MMU_IDX_A, - ARMMMUIdx_Phys_NS = 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_S = 10 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_NS = 11 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Root = 12 | ARM_MMU_IDX_A, + ARMMMUIdx_Phys_Realm = 13 | ARM_MMU_IDX_A, /* * These are not allocated TLBs and are used only for AT system @@ -2930,6 +2932,23 @@ typedef enum ARMASIdx { ARMASIdx_TagS = 3, } ARMASIdx; +static inline ARMMMUIdx arm_space_to_phys(ARMSecuritySpace space) +{ + /* Assert the relative order of the physical mmu indexes. */ + QEMU_BUILD_BUG_ON(ARMSS_Secure != 0); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_NS != ARMMMUIdx_Phys_S + ARMSS_NonSecure); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_Root != ARMMMUIdx_Phys_S + ARMSS_Root); + QEMU_BUILD_BUG_ON(ARMMMUIdx_Phys_Realm != ARMMMUIdx_Phys_S + ARMSS_Realm); + + return ARMMMUIdx_Phys_S + space; +} + +static inline ARMSecuritySpace arm_phys_to_space(ARMMMUIdx idx) +{ + assert(idx >= ARMMMUIdx_Phys_S && idx <= ARMMMUIdx_Phys_Realm); + return idx - ARMMMUIdx_Phys_S; +} + static inline bool arm_v7m_csselr_razwi(ARMCPU *cpu) { /* If all the CLIDR.Ctypem bits are 0 there are no caches, and diff --git a/target/arm/ptw.c b/target/arm/ptw.c index 5ed5bb5039..5a0c5edc88 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -182,8 +182,10 @@ static bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx, case ARMMMUIdx_E3: break; - case ARMMMUIdx_Phys_NS: case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: /* No translation for physical address spaces. */ return true; @@ -2632,8 +2634,10 @@ static bool get_phys_addr_disabled(CPUARMState *env, target_ulong address, switch (mmu_idx) { case ARMMMUIdx_Stage2: case ARMMMUIdx_Stage2_S: - case ARMMMUIdx_Phys_NS: case ARMMMUIdx_Phys_S: + case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: break; default: @@ -2830,6 +2834,8 @@ static bool get_phys_addr_with_struct(CPUARMState *env, S1Translate *ptw, switch (mmu_idx) { case ARMMMUIdx_Phys_S: case ARMMMUIdx_Phys_NS: + case ARMMMUIdx_Phys_Root: + case ARMMMUIdx_Phys_Realm: /* Checking Phys early avoids special casing later vs regime_el. */ return get_phys_addr_disabled(env, address, access_type, mmu_idx, is_secure, result, fi);