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 <yuhong.tao@intel.com>
This commit is contained in:
Tao Yuhong 2021-05-20 08:00:22 -04:00 committed by wenlingz
parent a1f12d2931
commit 2ab70f43e5
1 changed files with 2 additions and 0 deletions

View File

@ -450,7 +450,9 @@ void cpu_dead(void)
/* clean up native stuff */ /* clean up native stuff */
vmx_off(); vmx_off();
clac();
flush_cache_range((void *)get_hv_image_base(), CONFIG_HV_RAM_SIZE); flush_cache_range((void *)get_hv_image_base(), CONFIG_HV_RAM_SIZE);
stac();
/* Set state to show CPU is dead */ /* Set state to show CPU is dead */
pcpu_set_current_state(pcpu_id, PCPU_STATE_DEAD); pcpu_set_current_state(pcpu_id, PCPU_STATE_DEAD);