From 32cb5954f2ccb617085858d92925b38feb372bef Mon Sep 17 00:00:00 2001 From: "Zhou, Wu" Date: Thu, 31 Mar 2022 18:26:44 +0800 Subject: [PATCH] hv: refine the hard-coded GPA SSRAM area size Using the SSRAM area size extracted by config_tools, the patch changes the hard-coded GPA SSRAM area size to its actual size, so that pre-launched VMs can support large(>8MB) SSRAM area. When booting service VM, the SSRAM area has to be removed from Service VM's mem space, because they are passed-through to the pre-rt VM. The code was bugged since it was using the SSRAM area's GPA in the pre-rt VM. Changed it to GPA in Service VM. Tracked-On: #7212 Acked-by: Eddie Dong Signed-off-by: Zhou, Wu --- hypervisor/arch/x86/guest/vm.c | 6 +++--- hypervisor/include/arch/x86/asm/rtct.h | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/hypervisor/arch/x86/guest/vm.c b/hypervisor/arch/x86/guest/vm.c index b6ed6a670..2bb4b6de5 100644 --- a/hypervisor/arch/x86/guest/vm.c +++ b/hypervisor/arch/x86/guest/vm.c @@ -523,13 +523,13 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm) pci_mmcfg = get_mmcfg_region(); ept_del_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp, pci_mmcfg->address, get_pci_mmcfg_size(pci_mmcfg)); -#if defined(PRE_RTVM_SW_SRAM_ENABLED) /* remove Software SRAM region from Service VM EPT, to prevent Service VM from using clflush to * flush the Software SRAM cache. * This is applicable to prelaunch RTVM case only, for post-launch RTVM, Service VM is trusted. + * When system don't have Software SRAM or not enabled, get_software_sram_size() will return 0. + * In this case no mem region will be removed. */ - ept_del_mr(vm, pml4_page, PRE_RTVM_SW_SRAM_BASE_GPA, PRE_RTVM_SW_SRAM_END_GPA - PRE_RTVM_SW_SRAM_BASE_GPA); -#endif + ept_del_mr(vm, pml4_page, service_vm_hpa2gpa(get_software_sram_base()), get_software_sram_size()); /* unmap Intel IOMMU register pages for below reason: * Service VM can detect IOMMU capability in its ACPI table hence it may access diff --git a/hypervisor/include/arch/x86/asm/rtct.h b/hypervisor/include/arch/x86/asm/rtct.h index c3adbfca8..de57d1710 100644 --- a/hypervisor/include/arch/x86/asm/rtct.h +++ b/hypervisor/include/arch/x86/asm/rtct.h @@ -33,19 +33,13 @@ #define RTCT_V2_MEMORY_HIERARCHY_LATENCY 8U #define RTCT_V2_ERROR_LOG_ADDRESS 9U -#if !defined(PRE_RTVM_SW_SRAM_ENABLED) /* - * PRE_RTVM_SW_SRAM_BASE_GPA is for Prelaunch VM only and - * is configured by config tool on platform that Software SRAM is detected. + * PRE_RTVM_SW_SRAM_MAX_SIZE is for Prelaunch VM only and + * is generated by config tool on platform that Software SRAM is configured. * - * For cases that Software SRAM is not detected, we still hardcode a dummy - * placeholder entry in vE820 table of Prelaunch VM to unify the logic - * to initialize the vE820. + * For cases that Software SRAM is not configured, PRE_RTVM_SW_SRAM_MAX_SIZE is defined as 0 */ #define PRE_RTVM_SW_SRAM_BASE_GPA (GPU_OPREGION_GPA - PRE_RTVM_SW_SRAM_MAX_SIZE) -#endif - -#define PRE_RTVM_SW_SRAM_MAX_SIZE 0x00800000U struct rtct_entry { uint16_t size;