]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
KVM: VMX: Change ple_window type to unsigned int
authorPeter Xu <peterx@redhat.com>
Fri, 6 Sep 2019 02:17:21 +0000 (10:17 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 10 Sep 2019 17:13:20 +0000 (19:13 +0200)
The VMX ple_window is 32 bits wide, so logically it can overflow with
an int.  The module parameter is declared as unsigned int which is
good, however the dynamic variable is not.  Switching all the
ple_window references to use unsigned int.

The tracepoint changes will also affect SVM, but SVM is using an even
smaller width (16 bits) so it's always fine.

Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/trace.h
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h

index 4d694c6ce5597312d26cacdfa373e5a4ad97eb70..a9e4e7f53b3f50c237367df0caccecea7f203f25 100644 (file)
@@ -891,14 +891,15 @@ TRACE_EVENT(kvm_pml_full,
 );
 
 TRACE_EVENT(kvm_ple_window,
-       TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old),
+       TP_PROTO(bool grow, unsigned int vcpu_id, unsigned int new,
+                unsigned int old),
        TP_ARGS(grow, vcpu_id, new, old),
 
        TP_STRUCT__entry(
                __field(                bool,      grow         )
                __field(        unsigned int,   vcpu_id         )
-               __field(                 int,       new         )
-               __field(                 int,       old         )
+               __field(        unsigned int,       new         )
+               __field(        unsigned int,       old         )
        ),
 
        TP_fast_assign(
@@ -908,7 +909,7 @@ TRACE_EVENT(kvm_ple_window,
                __entry->old            = old;
        ),
 
-       TP_printk("vcpu %u: ple_window %d (%s %d)",
+       TP_printk("vcpu %u: ple_window %u (%s %u)",
                  __entry->vcpu_id,
                  __entry->new,
                  __entry->grow ? "grow" : "shrink",
index 63f3d88b36cc14f69cd01ae06d12f502e4ea1a02..715ed5bca4d98f92183d269a05bc87efc79cada0 100644 (file)
@@ -5237,7 +5237,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
 static void grow_ple_window(struct kvm_vcpu *vcpu)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
-       int old = vmx->ple_window;
+       unsigned int old = vmx->ple_window;
 
        vmx->ple_window = __grow_ple_window(old, ple_window,
                                            ple_window_grow,
@@ -5252,7 +5252,7 @@ static void grow_ple_window(struct kvm_vcpu *vcpu)
 static void shrink_ple_window(struct kvm_vcpu *vcpu)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
-       int old = vmx->ple_window;
+       unsigned int old = vmx->ple_window;
 
        vmx->ple_window = __shrink_ple_window(old, ple_window,
                                              ple_window_shrink,
index 82d0bc3a4d52246f731be6c0e23163ebd05f9f34..64d5a4890aa9e3e5f88343a6f0aec2c63e21d36e 100644 (file)
@@ -253,7 +253,7 @@ struct vcpu_vmx {
        struct nested_vmx nested;
 
        /* Dynamic PLE window. */
-       int ple_window;
+       unsigned int ple_window;
        bool ple_window_dirty;
 
        bool req_immediate_exit;