|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 13/19] xen/arm: Resume memory management on Xen resume
Hi, On 07/10/2022 11:32, Mykyta Poturai wrote: From: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx> The MMU needs to be enabled in the resume flow before the context can be restored (we need to be able to access the context data by virtual address in order to restore it). The configuration of system registers prior to branching to the routine that sets up the page tables is copied from xen/arch/arm/arm64/head.S. After the MMU is enabled, the content of TTBR0_EL2 is changed to point to init_ttbr (page tables used at runtime). This is not Arm Arm compliant. Please look at the series [1] to see how you can safely switch the MMU on and use the page tables. At boot the init_ttbr variable is updated when a secondary CPU is hotplugged. In the scenario where there is only one physical CPU in the system, the init_ttbr would not be initialized for the use in resume flow. To get the variable initialized in all scenarios in this patch we add that the boot CPU updates init_ttbr after it sets the page tables for runtime. After the memory management is resumed, the SCTLR_WXN in SCTLR_EL2 has to be set in order to configure that a mapping cannot be both writable and executable (this was configured prior to suspend). This is done using an existing function (mmu_init_secondary_cpu). Update: moved hyp_resume to head.S to place it near the rest of the start code Signed-off-by: Mirela Simonovic <mirela.simonovic@xxxxxxxxxx> Signed-off-by: Saeed Nowshadi <saeed.nowshadi@xxxxxxxxxx> Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx> --- xen/arch/arm/arm64/entry.S | 2 ++ xen/arch/arm/arm64/head.S | 30 ++++++++++++++++++++++++++++++ xen/arch/arm/mm.c | 1 + xen/arch/arm/suspend.c | 6 ++++++ xen/include/asm-arm/processor.h | 22 ++++++++++++++++++++++ 5 files changed, 61 insertions(+) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index fc3811ad0a..f49f1daf46 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -1,4 +1,6 @@ #include <asm/current.h> +#include <asm/macros.h> +#include <asm/page.h> #include <asm/regs.h> #include <asm/alternative.h> #include <asm/smccc.h> diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 8857955699..82d83214dc 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -958,6 +958,36 @@ ENTRY(efi_xen_start) ENDPROC(efi_xen_start)ENTRY(hyp_resume)+ msr DAIFSet, 0xf /* Disable all interrupts */ + + tlbi alle2 + dsb sy /* Ensure completion of TLB flush */ + isb Please explain what this TLB is for. + + ldr x0, =start + adr x19, start /* x19 := paddr (start) */ + sub x20, x19, x0 /* x20 := phys-offset */ + + mov x22, #0 /* x22 := is_secondary_cpu */ x22 is not hold the is_secondary_cpu anymore.
This function is used to prepare the page tables for the secondary CPUs. This may allocate memory. So this is incorrect to call for CPU0. In this case, I think it would be better if the code to suspend sets init_ttbr and clear the boot pages tables. This could be done by split init_secondary_pagetables() in two: 1) Allocate memory for the page tables 2) Clear the boot page tables and the init_ttbr #ifdef CONFIG_ARM_32 Let's avoid to describe what a function does in the caller. This can be easily rot. + mmu_init_secondary_cpu(); I dislike the idea of using this function here. It is meant to be used by secondary CPUs, not CPU0. If you want to use it here, then it should be renamed to reflect how the function is used.
I don't see any use of SCTLR_* and HSCTLR_* here. What why do you need to define them? /* Bits specific to SCTLR_EL1 for Arm32 */ Cheers, [2] https://lore.kernel.org/all/20221022150422.17707-1-julien@xxxxxxx/ -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |