Skip to content

Commit

Permalink
KVM: x86/PVM: Check the validity of the root page for direct switchin…
Browse files Browse the repository at this point in the history
…g when PCID is not supported

Similar to the check performed in
pvm_set_host_cr3_for_guest_with_host_pcid(), the HPA of the SPT page
table for direct switching should also be verified in
pvm_set_host_cr3_for_guest_without_host_pcid().

Signed-off-by: Yong He <[email protected]>
Signed-off-by: Hou Wenlong <[email protected]>
Link: #4
  • Loading branch information
bysui committed Apr 10, 2024
1 parent 2932b89 commit f239d10
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/x86/kvm/pvm/pvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,11 @@ static void pvm_set_host_cr3_for_guest_without_host_pcid(struct vcpu_pvm *pvm)
{
u64 root_hpa = pvm->vcpu.arch.mmu->root.hpa;
u64 switch_root = 0;
u64 prev_root_hpa = pvm->vcpu.arch.mmu->prev_roots[0].hpa;

if (pvm->vcpu.arch.mmu->prev_roots[0].pgd == pvm->msr_switch_cr3) {
switch_root = pvm->vcpu.arch.mmu->prev_roots[0].hpa;
if (VALID_PAGE(prev_root_hpa) &&
pvm->vcpu.arch.mmu->prev_roots[0].pgd == pvm->msr_switch_cr3) {
switch_root = prev_root_hpa;
pvm->switch_flags &= ~SWITCH_FLAGS_NO_DS_CR3;
} else {
pvm->switch_flags |= SWITCH_FLAGS_NO_DS_CR3;
Expand Down

0 comments on commit f239d10

Please sign in to comment.