|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN v6 11/12] xen/arm: p2m: Use the pa_range_info table to support ARM_32 and ARM_64
Hi Ayan, On 11/05/2023 12:45, Ayan Kumar Halder wrote: On 03/05/2023 13:20, Julien Grall wrote:Hi,Hi Julien, I have some clarification.On 28/04/2023 18:55, Ayan Kumar Halder wrote:Restructure the code so that one can use pa_range_info[] table for both ARM_32 as well as ARM_64. Also, removed the hardcoding for P2M_ROOT_ORDER and P2M_ROOT_LEVEL as p2m_root_order can be obtained from the pa_range_info[].root_order and p2m_root_level can be obtained from pa_range_info[].sl0. Refer ARM DDI 0406C.d ID040418, B3-1345, "Use of concatenated first-level translation tables...However, a 40-bit input address range with a translation granularity of 4KBrequires a total of 28 bits of address resolution. Therefore, a stage 2translation that supports a 40-bit input address range requires two concatenatedfirst-level translation tables,..." Thus, root-order is 1 for 40-bit IPA on ARM_32. Refer ARM DDI 0406C.d ID040418, B3-1348, "Determining the required first lookup level for stage 2 translations For a stage 2 translation, the output address range from the stage 1 translations determines the required input address range for the stage 2 translation. The permitted values of VTCR.SL0 are: 0b00 Stage 2 translation lookup must start at the second level. 0b01 Stage 2 translation lookup must start at the first level.VTCR.T0SZ must indicate the required input address range. The size of the inputaddress region is 2^(32-T0SZ) bytes."Thus VTCR.SL0 = 1 (maximum value) and VTCR.T0SZ = -8 when the size of inputaddress region is 2^40 bytes.Thus, pa_range_info[].t0sz = 1 (VTCR.S) | 8 (VTCR.T0SZ) ie 11000b which is 24.Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx> --- Changes from - v3 - 1. New patch introduced in v4.2. Restructure the code such that pa_range_info[] is used both by ARM_32 aswell as ARM_64.v4 - 1. Removed the hardcoded definitions of P2M_ROOT_ORDER and P2M_ROOT_LEVEL.The reason being root_order will not be always 1 (See the next patch).2. Updated the commit message to explain t0sz, sl0 and root_order values for32-bit IPA on Arm32. 3. Some sanity fixes. v5 - pa_range_info is indexed by system_cpuinfo.mm64.pa_range. iewhen PARange is 0, the PA size is 32, 1 -> 36 and so on. So pa_range_info[] hasbeen updated accordingly.For ARM_32 pa_range_info[0] = 0 and pa_range_info[1] = 0 as we do not support32-bit, 36-bit physical address range yet. xen/arch/arm/include/asm/p2m.h | 8 +------- xen/arch/arm/p2m.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 21 deletions(-)diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.hindex f67e9ddc72..4ddd4643d7 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -14,16 +14,10 @@ /* Holds the bit size of IPAs in p2m tables. */ extern unsigned int p2m_ipa_bits; -#ifdef CONFIG_ARM_64 extern unsigned int p2m_root_order; extern unsigned int p2m_root_level; -#define P2M_ROOT_ORDER p2m_root_order +#define P2M_ROOT_ORDER p2m_root_orderThis looks like a spurious change.#define P2M_ROOT_LEVEL p2m_root_level -#else -/* First level P2M is always 2 consecutive pages */ -#define P2M_ROOT_ORDER 1 -#define P2M_ROOT_LEVEL 1 -#endif struct domain; diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 418997843d..1fe3cccf46 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -19,9 +19,9 @@ #define INVALID_VMID 0 /* VMID 0 is reserved */ -#ifdef CONFIG_ARM_64 unsigned int __read_mostly p2m_root_order; unsigned int __read_mostly p2m_root_level; +#ifdef CONFIG_ARM_64 static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT; /* VMID is by default 8 bit width on AArch64 */ #define MAX_VMID max_vmid @@ -2247,16 +2247,6 @@ void __init setup_virt_paging(void) /* Setup Stage 2 address translation */register_t val = VTCR_RES1|VTCR_SH0_IS|VTCR_ORGN0_WBWA|VTCR_IRGN0_WBWA; You are correct that the line is not correct for Arm32. But my point was more for that fact you don't update p2m_ipa_bits based on the PA range selected. ReferARM DDI 0406C.d ID040418, B3-1348, "Determining the required first lookup level for stage 2 translations""...The size of this input address region is 2(32-TxSZ) bytes, ..." So for #ifdef CONFIG_ARM_32 p2m_ipa_bits = 32 - pa_range_info[pa_range].t0sz; #endif This will be a problem for 40-bit PA as T0SZ = 24. So p2m_ipa_bits = 32 - 24 = 8 (which is incorrect). To get around this issue, there are two possible solutions :-1. For ARM_32, do not modify p2m_ipa_bits. Thus p2m_ipa_bits will be using its initialized value (ie PADDR_BITS). AFAICT, this approach would be incorrect because we wouldn't take into account any restriction from the SMMU susbystem (it may support less than what the processor support). I don't think the two options are equivalent. So my first priority is correctness, then if we have still multiple possibility, we can discuss which one look the nicest to read.2. T0SZ should be signed int for ARM_32 (so that it can hold -8) and unsigned int for ARM_64. To avoid the #ifdef in the struct, we could possibly use a series of cast. It might be slightly better because a reader will be less confused on the type change. Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |