Skip to content

Commit

Permalink
KVM: x86: nSVM: always intercept x2apic msrs
Browse files Browse the repository at this point in the history
As a preparation for x2avic, this patch ensures that x2apic msrs
are always intercepted for the nested guest.

Reviewed-by: Suravee Suthikulpanit <[email protected]>
Tested-by: Suravee Suthikulpanit <[email protected]>
Signed-off-by: Maxim Levitsky <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Maxim Levitsky authored and bonzini committed Jun 24, 2022
1 parent 05c4fe8 commit 7a8f7c1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions arch/x86/kvm/svm/nested.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
break;

p = msrpm_offsets[i];

/* x2apic msrs are intercepted always for the nested guest */
if (is_x2apic_msrpm_offset(p))
continue;

offset = svm->nested.ctl.msrpm_base_pa + (p * 4);

if (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4))
Expand Down
9 changes: 9 additions & 0 deletions arch/x86/kvm/svm/svm.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,15 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm)
return svm->nested.ctl.nested_ctl & SVM_NESTED_CTL_NP_ENABLE;
}

static inline bool is_x2apic_msrpm_offset(u32 offset)
{
/* 4 msrs per u8, and 4 u8 in u32 */
u32 msr = offset * 16;

return (msr >= APIC_BASE_MSR) &&
(msr < (APIC_BASE_MSR + 0x100));
}

/* svm.c */
#define MSR_INVALID 0xffffffffU

Expand Down

0 comments on commit 7a8f7c1

Please sign in to comment.