From f782a8cc394523b0ca488d27cf9744713dba4570 Mon Sep 17 00:00:00 2001 From: Tao Yuhong Date: Thu, 20 May 2021 08:00:22 -0400 Subject: [PATCH] HV: cache: Fix page fault by flushing cache for VM trusty RAM in HV The accrss right of HV RAM can be changed to PAGE_USER (eg. trusty RAM of post-launched VM). So before using clflush(or clflushopt) to flush HV RAM cache, must allow explicit supervisor-mode data accesses to user-mode pages. Otherwise, it may trigger page fault. Tracked-On: #6020 Signed-off-by: Tao Yuhong --- hypervisor/arch/x86/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hypervisor/arch/x86/cpu.c b/hypervisor/arch/x86/cpu.c index 772567196..14a0c4dfb 100644 --- a/hypervisor/arch/x86/cpu.c +++ b/hypervisor/arch/x86/cpu.c @@ -450,7 +450,9 @@ void cpu_dead(void) /* clean up native stuff */ vmx_off(); + stac(); flush_cache_range((void *)get_hv_image_base(), CONFIG_HV_RAM_SIZE); + clac(); /* Set state to show CPU is dead */ pcpu_set_current_state(pcpu_id, PCPU_STATE_DEAD);