hv: ptcm: enable ptcm by default

Enable PTCM by default if the platform support it. We could check it by whether
the PTCM ACPI Table is exist. Besides to parse the PTCM ACPI Table and call
PTCM command interface to init pSRAM on all CPU cores, we need to ignore
WBINVD to flush the cache of th pSRAM.

Tracked-On: #5330

Signed-off-by: Qian Wang <qian1.wang@intel.com>
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Li Fei1 2020-09-14 23:02:43 +08:00 committed by wenlingz
parent 7125c522ef
commit f94ad6aef7
3 changed files with 73 additions and 34 deletions

View File

@ -276,6 +276,15 @@ config CDP_ENABLED
prioritization of code and data fetches to the L2 or L3 cache in a
software configurable manner, depending on hardware support.
config PTCM_ENABLED
bool "Enable PTCM (Platform Tuning Configuration Manager)"
depends on !CDP_ENABLED
default y
help
PCTM supports RTVM to make use of pSRAM to improve the performance
of RT APPs. pSRAM is a block of cache, which is separated and protected by
CAT and other methods. PTCM and CDP cannot be co-existing.
config GPU_SBDF
hex "Segment, Bus, Device, and function of the GPU"
depends on ACPI_PARSE_ENABLED

View File

@ -15,6 +15,7 @@
#include <vtd.h>
#include <logmsg.h>
#include <trace.h>
#include <ptct.h>
#define DBG_LEVEL_EPT 6U
@ -170,14 +171,39 @@ void ept_del_mr(struct acrn_vm *vm, uint64_t *pml4_page, uint64_t gpa, uint64_t
*/
void ept_flush_leaf_page(uint64_t *pge, uint64_t size)
{
uint64_t hpa = INVALID_HPA;
uint64_t hpa = INVALID_HPA, hpa_end;
void *hva = NULL;
uint64_t flush_size = size;
if ((*pge & EPT_MT_MASK) != EPT_UNCACHED) {
hpa = (*pge & (~(size - 1UL)));
hpa_end = hpa + size;
if (hpa < psram_area_bottom) {
if (hpa_end > psram_area_top) {
flush_size = psram_area_bottom - hpa;
hva = hpa2hva(hpa);
stac();
flush_address_space(hva, size);
flush_address_space(hva, flush_size);
clac();
flush_size = hpa_end - psram_area_top;
hpa = psram_area_top;
} else if (hpa_end > psram_area_bottom) {
flush_size = psram_area_bottom - hpa;
}
} else if (hpa < psram_area_top) {
if (hpa_end <= psram_area_top) {
flush_size = 0UL;
} else {
hpa = psram_area_top;
flush_size = hpa_end - psram_area_top;
}
}
hva = hpa2hva(hpa);
stac();
flush_address_space(hva, flush_size);
clac();
}
}

View File

@ -8,8 +8,8 @@
#include <misc_cfg.h>
#include <ptcm.h>
uint64_t psram_area_bottom = PSRAM_BASE_HPA;
uint64_t psram_area_top = PSRAM_BASE_HPA;
uint64_t psram_area_bottom;
uint64_t psram_area_top;
#ifdef CONFIG_PTCM_ENABLED
@ -32,6 +32,8 @@ static void parse_ptct(void)
entry = &acpi_ptct->ptct_first_entry; //&acpi_ptct->ptct_entries[0];
pr_fatal("find PTCT base entry, in HPA %llx", entry);
psram_area_bottom = PSRAM_BASE_HPA;
while (((uint64_t)entry - (uint64_t)acpi_ptct) < acpi_ptct->header.length) {
switch (entry->type) {
case PTCT_ENTRY_TYPE_PTCM_BINARY:
@ -109,6 +111,7 @@ void init_psram(bool is_bsp)
uint32_t magic,version;
int ret;
if (get_acpi_tbl(ACPI_SIG_PTCT) != NULL) {
if (is_bsp) {
parse_ptct();
pr_fatal("PTCT is parsed by BSP");
@ -146,6 +149,7 @@ void init_psram(bool is_bsp)
}
}
}
}
#else
void init_psram(__unused bool is_bsp)
{