KVM: x86: Take an unsigned 32-bit int for has_emulated_msr()'s index
Take a u32 for the index in has_emulated_msr() to match hardware, which treats MSR indices as unsigned 32-bit values. Functionally, taking a signed int doesn't cause problems with the current code base, but could theoretically cause problems with 32-bit KVM, e.g. if the index were checked via a less-than statement, which would evaluate incorrectly for MSR indices with bit 31 set. Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Message-Id: <20200218234012.7110-3-sean.j.christopherson@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:

committed by
Paolo Bonzini

parent
7cb85fc465
commit
cb97c2d680
@@ -1064,7 +1064,7 @@ struct kvm_x86_ops {
|
|||||||
void (*hardware_disable)(void);
|
void (*hardware_disable)(void);
|
||||||
void (*hardware_unsetup)(void);
|
void (*hardware_unsetup)(void);
|
||||||
bool (*cpu_has_accelerated_tpr)(void);
|
bool (*cpu_has_accelerated_tpr)(void);
|
||||||
bool (*has_emulated_msr)(int index);
|
bool (*has_emulated_msr)(u32 index);
|
||||||
void (*cpuid_update)(struct kvm_vcpu *vcpu);
|
void (*cpuid_update)(struct kvm_vcpu *vcpu);
|
||||||
|
|
||||||
unsigned int vm_size;
|
unsigned int vm_size;
|
||||||
|
@@ -3525,7 +3525,7 @@ static bool svm_cpu_has_accelerated_tpr(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool svm_has_emulated_msr(int index)
|
static bool svm_has_emulated_msr(u32 index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case MSR_IA32_MCG_EXT_CTL:
|
case MSR_IA32_MCG_EXT_CTL:
|
||||||
|
@@ -6434,7 +6434,7 @@ static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
|
|||||||
handle_exception_nmi_irqoff(vmx);
|
handle_exception_nmi_irqoff(vmx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vmx_has_emulated_msr(int index)
|
static bool vmx_has_emulated_msr(u32 index)
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case MSR_IA32_SMBASE:
|
case MSR_IA32_SMBASE:
|
||||||
|
Reference in New Issue
Block a user