aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2019-09-05 22:17:21 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2019-09-10 13:13:20 -0400
commitc5c5d6fae001c653a4e831325e062816a60c5e38 (patch)
treec74165a1d0516ab3f4ac57fbb820b174a874b8eb
parent13a7e370cb89e2ec0859c99960b24b12a3c2c029 (diff)
KVM: VMX: Change ple_window type to unsigned int
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>
-rw-r--r--arch/x86/kvm/trace.h9
-rw-r--r--arch/x86/kvm/vmx/vmx.c4
-rw-r--r--arch/x86/kvm/vmx/vmx.h2
3 files changed, 8 insertions, 7 deletions
diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
index 4d694c6ce559..a9e4e7f53b3f 100644
--- a/arch/x86/kvm/trace.h
+++ b/arch/x86/kvm/trace.h
@@ -891,14 +891,15 @@ TRACE_EVENT(kvm_pml_full,
891); 891);
892 892
893TRACE_EVENT(kvm_ple_window, 893TRACE_EVENT(kvm_ple_window,
894 TP_PROTO(bool grow, unsigned int vcpu_id, int new, int old), 894 TP_PROTO(bool grow, unsigned int vcpu_id, unsigned int new,
895 unsigned int old),
895 TP_ARGS(grow, vcpu_id, new, old), 896 TP_ARGS(grow, vcpu_id, new, old),
896 897
897 TP_STRUCT__entry( 898 TP_STRUCT__entry(
898 __field( bool, grow ) 899 __field( bool, grow )
899 __field( unsigned int, vcpu_id ) 900 __field( unsigned int, vcpu_id )
900 __field( int, new ) 901 __field( unsigned int, new )
901 __field( int, old ) 902 __field( unsigned int, old )
902 ), 903 ),
903 904
904 TP_fast_assign( 905 TP_fast_assign(
@@ -908,7 +909,7 @@ TRACE_EVENT(kvm_ple_window,
908 __entry->old = old; 909 __entry->old = old;
909 ), 910 ),
910 911
911 TP_printk("vcpu %u: ple_window %d (%s %d)", 912 TP_printk("vcpu %u: ple_window %u (%s %u)",
912 __entry->vcpu_id, 913 __entry->vcpu_id,
913 __entry->new, 914 __entry->new,
914 __entry->grow ? "grow" : "shrink", 915 __entry->grow ? "grow" : "shrink",
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 63f3d88b36cc..715ed5bca4d9 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -5237,7 +5237,7 @@ emulation_error:
5237static void grow_ple_window(struct kvm_vcpu *vcpu) 5237static void grow_ple_window(struct kvm_vcpu *vcpu)
5238{ 5238{
5239 struct vcpu_vmx *vmx = to_vmx(vcpu); 5239 struct vcpu_vmx *vmx = to_vmx(vcpu);
5240 int old = vmx->ple_window; 5240 unsigned int old = vmx->ple_window;
5241 5241
5242 vmx->ple_window = __grow_ple_window(old, ple_window, 5242 vmx->ple_window = __grow_ple_window(old, ple_window,
5243 ple_window_grow, 5243 ple_window_grow,
@@ -5252,7 +5252,7 @@ static void grow_ple_window(struct kvm_vcpu *vcpu)
5252static void shrink_ple_window(struct kvm_vcpu *vcpu) 5252static void shrink_ple_window(struct kvm_vcpu *vcpu)
5253{ 5253{
5254 struct vcpu_vmx *vmx = to_vmx(vcpu); 5254 struct vcpu_vmx *vmx = to_vmx(vcpu);
5255 int old = vmx->ple_window; 5255 unsigned int old = vmx->ple_window;
5256 5256
5257 vmx->ple_window = __shrink_ple_window(old, ple_window, 5257 vmx->ple_window = __shrink_ple_window(old, ple_window,
5258 ple_window_shrink, 5258 ple_window_shrink,
diff --git a/arch/x86/kvm/vmx/vmx.h b/arch/x86/kvm/vmx/vmx.h
index 82d0bc3a4d52..64d5a4890aa9 100644
--- a/arch/x86/kvm/vmx/vmx.h
+++ b/arch/x86/kvm/vmx/vmx.h
@@ -253,7 +253,7 @@ struct vcpu_vmx {
253 struct nested_vmx nested; 253 struct nested_vmx nested;
254 254
255 /* Dynamic PLE window. */ 255 /* Dynamic PLE window. */
256 int ple_window; 256 unsigned int ple_window;
257 bool ple_window_dirty; 257 bool ple_window_dirty;
258 258
259 bool req_immediate_exit; 259 bool req_immediate_exit;