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 <eddie.dong@intel.com>
Signed-off-by: Zhou, Wu <wu.zhou@intel.com>
This commit is contained in:
Zhou, Wu 2022-03-31 18:26:44 +08:00 committed by acrnsi-robot
parent 423312881d
commit 32cb5954f2
2 changed files with 6 additions and 12 deletions

View File

@ -523,13 +523,13 @@ static void prepare_service_vm_memmap(struct acrn_vm *vm)
pci_mmcfg = get_mmcfg_region(); 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)); 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 /* remove Software SRAM region from Service VM EPT, to prevent Service VM from using clflush to
* flush the Software SRAM cache. * flush the Software SRAM cache.
* This is applicable to prelaunch RTVM case only, for post-launch RTVM, Service VM is trusted. * 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); ept_del_mr(vm, pml4_page, service_vm_hpa2gpa(get_software_sram_base()), get_software_sram_size());
#endif
/* unmap Intel IOMMU register pages for below reason: /* unmap Intel IOMMU register pages for below reason:
* Service VM can detect IOMMU capability in its ACPI table hence it may access * Service VM can detect IOMMU capability in its ACPI table hence it may access

View File

@ -33,19 +33,13 @@
#define RTCT_V2_MEMORY_HIERARCHY_LATENCY 8U #define RTCT_V2_MEMORY_HIERARCHY_LATENCY 8U
#define RTCT_V2_ERROR_LOG_ADDRESS 9U #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 * PRE_RTVM_SW_SRAM_MAX_SIZE is for Prelaunch VM only and
* is configured by config tool on platform that Software SRAM is detected. * 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 * For cases that Software SRAM is not configured, PRE_RTVM_SW_SRAM_MAX_SIZE is defined as 0
* placeholder entry in vE820 table of Prelaunch VM to unify the logic
* to initialize the vE820.
*/ */
#define PRE_RTVM_SW_SRAM_BASE_GPA (GPU_OPREGION_GPA - PRE_RTVM_SW_SRAM_MAX_SIZE) #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 { struct rtct_entry {
uint16_t size; uint16_t size;