[PATCH v2] KVM: vmx: add mismatched size assertions in vmcs_check32()

2021-04-08 Thread lihaiwei . kernel
From: Haiwei Li Add compile-time assertions in vmcs_check32() to disallow accesses to 64-bit and 64-bit high fields via vmcs_{read,write}32(). Upper level KVM code should never do partial accesses to VMCS fields. KVM handles the split accesses automatically in vmcs_{read,write}64() when

[PATCH] KVM: vmx: add mismatched size in vmcs_check32

2021-04-08 Thread lihaiwei . kernel
From: Haiwei Li vmcs_check32 misses the check for 64-bit and 64-bit high. Signed-off-by: Haiwei Li --- arch/x86/kvm/vmx/vmx_ops.h | 4 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx_ops.h b/arch/x86/kvm/vmx/vmx_ops.h index 692b0c3..164b64f 100644 ---

[PATCH] KVM: VMX: Check the corresponding bits according to the intel sdm

2021-03-22 Thread lihaiwei . kernel
From: Haiwei Li According to IA-32 SDM Vol.3D "A.1 BASIC VMX INFORMATION", two inspections are missing. * Bit 31 is always 0. Earlier versions of this manual specified that the VMCS revision identifier was a 32-bit field in bits 31:0 of this MSR. For all processors produced prior to this change,

[PATCH] KVM: clean up the unused argument

2021-03-12 Thread lihaiwei . kernel
From: Haiwei Li kvm_msr_ignored_check function never uses vcpu argument. Clean up the function and invokers. Signed-off-by: Haiwei Li --- arch/x86/kvm/x86.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index

[PATCH] kvm: lapic: add module parameters for LAPIC_TIMER_ADVANCE_ADJUST_MAX/MIN

2021-03-03 Thread lihaiwei . kernel
From: Haiwei Li In my test environment, advance_expire_delta is frequently greater than the fixed LAPIC_TIMER_ADVANCE_ADJUST_MAX. And this will hinder the adjustment. Adding module parameters for LAPIC_TIMER_ADVANCE_ADJUST_MAX/MIN, so they can be dynamically adjusted. Signed-off-by: Haiwei Li

[PATCH v5] KVM: Check the allocation of pv cpu mask

2020-11-03 Thread lihaiwei . kernel
From: Haiwei Li Both 'kvm_send_ipi_mask_allbutself' and 'kvm_flush_tlb_others' are using per-cpu __pv_cpu_mask. Init pv ipi ops only if the allocation succeeds and check the cpumask in 'kvm_flush_tlb_others'. Thanks to Vitaly Kuznetsov's tireless advice. Suggested-by: Vitaly Kuznetsov

[PATCH v4] KVM: Check the allocation of pv cpu mask

2020-10-17 Thread lihaiwei . kernel
From: Haiwei Li check the allocation of per-cpu __pv_cpu_mask. Init 'send_IPI_mask_allbutself' only when successful and check the allocation of __pv_cpu_mask in 'kvm_flush_tlb_others'. Suggested-by: Vitaly Kuznetsov Signed-off-by: Haiwei Li --- v1 -> v2: * add CONFIG_SMP for

[PATCH v2] KVM: x86: Add tracepoint for dr_write/dr_read

2020-10-08 Thread lihaiwei . kernel
From: Haiwei Li When vmexit occurs caused by accessing dr, there is no tracepoint to track this action. Add tracepoint for this on x86 kvm. Signed-off-by: Haiwei Li --- v1 -> v2: * Improve the changelog arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/trace.h | 27 +++

[PATCH] KVM: x86: Add tracepoint for dr_write/dr_read

2020-09-29 Thread lihaiwei . kernel
From: Haiwei Li Add tracepoint trace_kvm_dr_write/trace_kvm_dr_read for x86 kvm. Signed-off-by: Haiwei Li --- arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/trace.h | 27 +++ arch/x86/kvm/vmx/vmx.c | 10 -- arch/x86/kvm/x86.c | 1 + 4 files changed, 38

[PATCH v3] KVM: Check the allocation of pv cpu mask

2020-09-25 Thread lihaiwei . kernel
From: Haiwei Li check the allocation of per-cpu __pv_cpu_mask. Suggested-by: Vitaly Kuznetsov Signed-off-by: Haiwei Li --- v1 -> v2: * add CONFIG_SMP for kvm_send_ipi_mask_allbutself to prevent build error v2 -> v3: * always check the allocation of __pv_cpu_mask in kvm_flush_tlb_others

[PATCH] KVM: SVM: use __GFP_ZERO instead of clear_page()

2020-09-16 Thread lihaiwei . kernel
From: Haiwei Li Use __GFP_ZERO while alloc_page(). Signed-off-by: Haiwei Li --- arch/x86/kvm/svm/avic.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index ac830cd50830..f73f84d56452 100644 ---

[PATCH] KVM: SVM: Get rid of the variable 'exit_fastpath'

2020-09-15 Thread lihaiwei . kernel
From: Haiwei Li 'exit_fastpath' isn't used anywhere else, so remove it. Suggested-by: Krish Sadhukhan Signed-off-by: Haiwei Li --- arch/x86/kvm/svm/svm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index

[PATCH 2/2] KVM: Check if __pv_cpu_mask was allocated instead of assigning ops too late

2020-09-14 Thread lihaiwei . kernel
From: Haiwei Li Without this patch, kvm_flush_tlb_others is not called. We can always check if __pv_cpu_mask was allocated and revert back to the architectural path if not. Suggested-by: Vitaly Kuznetsov Signed-off-by: Haiwei Li --- arch/x86/kernel/kvm.c | 8 ++-- 1 file changed, 6

[PATCH 0/2] Fix the allocation of pv cpu mask

2020-09-14 Thread lihaiwei . kernel
From: Haiwei Li Hi, There is a old version patch of 'KVM: Check the allocation of pv cpu mask' in upstream. The v2 and what is discussed is in url: https://lore.kernel.org/kvm/87o8mlooki@vitty.brq.redhat.com/ In this patch, i fix the build error and make changes as suggested. Haiwei Li

[PATCH 1/2] KVM: Fix the build error

2020-09-14 Thread lihaiwei . kernel
From: Haiwei Li When CONFIG_SMP is not set, an build error occurs with message "error: use of undeclared identifier 'kvm_send_ipi_mask_allbutself'" Fixes: 0f990222108d ("KVM: Check the allocation of pv cpu mask", 2020-09-01) Reported-by: kernel test robot Signed-off-by: Haiwei Li ---