1
0
mirror of https://github.com/projectacrn/acrn-hypervisor.git synced 2025-05-04 22:47:00 +00:00

hv: Save/restore MSR_IA32_CSTAR during context switch

Both Windows guest and Linux guest use the MSR MSR_IA32_CSTAR, while
Linux uses it rarely. Now vcpu context switch doesn't save/restore it.
Windows detects the change of the MSR and rises a exception.

Do the save/resotre MSR_IA32_CSTAR during context switch.

Tracked-On: 
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
Shuo A Liu 2021-04-01 10:50:53 +08:00 committed by wenlingz
parent 9e4fd1f119
commit 684766f008
2 changed files with 3 additions and 0 deletions
hypervisor
arch/x86/guest
include/arch/x86

View File

@ -837,6 +837,7 @@ static void context_switch_out(struct thread_object *prev)
/* We don't flush TLB as we assume each vcpu has different vpid */
ectx->ia32_star = msr_read(MSR_IA32_STAR);
ectx->ia32_cstar = msr_read(MSR_IA32_CSTAR);
ectx->ia32_lstar = msr_read(MSR_IA32_LSTAR);
ectx->ia32_fmask = msr_read(MSR_IA32_FMASK);
ectx->ia32_kernel_gs_base = msr_read(MSR_IA32_KERNEL_GS_BASE);
@ -852,6 +853,7 @@ static void context_switch_in(struct thread_object *next)
load_vmcs(vcpu);
msr_write(MSR_IA32_STAR, ectx->ia32_star);
msr_write(MSR_IA32_CSTAR, ectx->ia32_cstar);
msr_write(MSR_IA32_LSTAR, ectx->ia32_lstar);
msr_write(MSR_IA32_FMASK, ectx->ia32_fmask);
msr_write(MSR_IA32_KERNEL_GS_BASE, ectx->ia32_kernel_gs_base);

View File

@ -392,6 +392,7 @@ struct ext_context {
struct segment_sel gs;
uint64_t ia32_star;
uint64_t ia32_cstar;
uint64_t ia32_lstar;
uint64_t ia32_fmask;
uint64_t ia32_kernel_gs_base;