mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-04-28 19:54:01 +00:00
hv: skip pSRAM for guest WBINVD emulation
Use ept_flush_leaf_page to emulate guest WBINVD when PTCM is enabled and skip the pSRAM in ept_flush_leaf_page. TODO: do we need to emulate WBINVD in HV side. Tracked-On: #5330 Signed-off-by: Qian Wang <qian1.wang@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
f3067f5385
commit
ca2aee225c
@ -445,6 +445,7 @@ void cpu_dead(void)
|
||||
if (bitmap_test(pcpu_id, &pcpu_active_bitmap)) {
|
||||
/* clean up native stuff */
|
||||
vmx_off();
|
||||
/* TODO: a cpu dead can't effect the RTVM which use pSRAM */
|
||||
cache_flush_invalidate_all();
|
||||
|
||||
/* Set state to show CPU is dead */
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <vtd.h>
|
||||
#include <logmsg.h>
|
||||
#include <trace.h>
|
||||
#include <ptct.h>
|
||||
|
||||
#define DBG_LEVEL_EPT 6U
|
||||
|
||||
@ -170,14 +171,52 @@ 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 flush_base_hpa = INVALID_HPA, flush_end_hpa;
|
||||
void *hva = NULL;
|
||||
uint64_t flush_size = size;
|
||||
|
||||
if ((*pge & EPT_MT_MASK) != EPT_UNCACHED) {
|
||||
hpa = (*pge & (~(size - 1UL)));
|
||||
hva = hpa2hva(hpa);
|
||||
flush_base_hpa = (*pge & (~(size - 1UL)));
|
||||
flush_end_hpa = flush_base_hpa + size;
|
||||
|
||||
/* When pSRAM is not intialized, both psram_area_bottom and psram_area_top is 0,
|
||||
* so the below if/else will have no use
|
||||
*/
|
||||
if (flush_base_hpa < psram_area_bottom) {
|
||||
/* Only flush [flush_base_hpa, psram_area_bottom) and [psram_area_top, flush_base_hpa),
|
||||
* ignore [psram_area_bottom, psram_area_top)
|
||||
*/
|
||||
if (flush_end_hpa > psram_area_top) {
|
||||
/* Only flush [flush_base_hpa, psram_area_bottom) and [psram_area_top, flush_base_hpa),
|
||||
* ignore [psram_area_bottom, psram_area_top)
|
||||
*/
|
||||
flush_size = psram_area_bottom - flush_base_hpa;
|
||||
hva = hpa2hva(flush_base_hpa);
|
||||
stac();
|
||||
flush_address_space(hva, flush_size);
|
||||
clac();
|
||||
|
||||
flush_size = flush_end_hpa - psram_area_top;
|
||||
flush_base_hpa = psram_area_top;
|
||||
} else if (flush_end_hpa > psram_area_bottom) {
|
||||
/* Only flush [flush_base_hpa, psram_area_bottom) and
|
||||
* ignore [psram_area_bottom, flush_end_hpa)
|
||||
*/
|
||||
flush_size = psram_area_bottom - flush_base_hpa;
|
||||
}
|
||||
} else if (flush_base_hpa < psram_area_top) {
|
||||
if (flush_end_hpa <= psram_area_top) {
|
||||
flush_size = 0UL;
|
||||
} else {
|
||||
/* Only flush [psram_area_top, flush_end_hpa) and ignore [flush_base_hpa, psram_area_top) */
|
||||
flush_base_hpa = psram_area_top;
|
||||
flush_size = flush_end_hpa - psram_area_top;
|
||||
}
|
||||
}
|
||||
|
||||
hva = hpa2hva(flush_base_hpa);
|
||||
stac();
|
||||
flush_address_space(hva, size);
|
||||
flush_address_space(hva, flush_size);
|
||||
clac();
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <vtd.h>
|
||||
#include <vcpuid.h>
|
||||
#include <trace.h>
|
||||
#include <ptcm.h>
|
||||
|
||||
/*
|
||||
* According to "SDM APPENDIX C VMX BASIC EXIT REASONS",
|
||||
@ -382,7 +383,8 @@ static int32_t wbinvd_vmexit_handler(struct acrn_vcpu *vcpu)
|
||||
uint16_t i;
|
||||
struct acrn_vcpu *other;
|
||||
|
||||
if (has_rt_vm() == false) {
|
||||
/* GUEST_FLAG_RT has not set in post-launched RTVM before it has been created */
|
||||
if ((is_psram_initialized) || (has_rt_vm() == false)) {
|
||||
cache_flush_invalidate_all();
|
||||
} else {
|
||||
if (is_rt_vm(vcpu->vm)) {
|
||||
|
Loading…
Reference in New Issue
Block a user