Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1605300 > unrolled thread
| Started by | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| First post | 2017-03-21 05:30 +0100 |
| Last post | 2017-03-21 17:30 +0100 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v2 1/3] KVM: nVMX: Fix nested VPID vmx exec control Wanpeng Li <kernellwp@gmail.com> - 2017-03-21 05:30 +0100
[PATCH v2 3/3] KVM: x86: correct async page present tracepoint Wanpeng Li <kernellwp@gmail.com> - 2017-03-21 05:30 +0100
Re: [PATCH v2 3/3] KVM: x86: correct async page present tracepoint David Hildenbrand <david@redhat.com> - 2017-03-21 10:00 +0100
Re: [PATCH v2 1/3] KVM: nVMX: Fix nested VPID vmx exec control Paolo Bonzini <pbonzini@redhat.com> - 2017-03-21 17:30 +0100
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2017-03-21 05:30 +0100 |
| Subject | [PATCH v2 1/3] KVM: nVMX: Fix nested VPID vmx exec control |
| Message-ID | <tnjAJ-6z6-5@gated-at.bofh.it> |
From: Wanpeng Li <wanpeng.li@hotmail.com>
This can be reproduced by running kvm-unit-tests/vmx.flat on L0 w/ vpid disabled.
Test suite: VPID
Unhandled exception 6 #UD at ip 00000000004051a6
error_code=0000 rflags=00010047 cs=00000008
rax=0000000000000000 rcx=0000000000000001 rdx=0000000000000047 rbx=0000000000402f79
rbp=0000000000456240 rsi=0000000000000001 rdi=0000000000000000
r8=000000000000000a r9=00000000000003f8 r10=0000000080010011 r11=0000000000000000
r12=0000000000000003 r13=0000000000000708 r14=0000000000000000 r15=0000000000000000
cr0=0000000080010031 cr2=0000000000000000 cr3=0000000007fff000 cr4=0000000000002020
cr8=0000000000000000
STACK: @4051a6 40523e 400f7f 402059 40028f
We should hide and forbid VPID in L1 if it is disabled on L0. However, nested VPID
enable bit is set unconditionally during setup nested vmx exec controls though VPID
is not exposed through nested VMX capablity. This patch fixes it by don't set nested
VPID enable bit if it is disabled on L0.
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Fixes: 5c614b3583e (KVM: nVMX: nested VPID emulation)
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/vmx.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 98e82ee..8795a70 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2753,7 +2753,6 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
SECONDARY_EXEC_RDTSCP |
SECONDARY_EXEC_DESC |
SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
- SECONDARY_EXEC_ENABLE_VPID |
SECONDARY_EXEC_APIC_REGISTER_VIRT |
SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
SECONDARY_EXEC_WBINVD_EXITING |
@@ -2781,10 +2780,12 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
* though it is treated as global context. The alternative is
* not failing the single-context invvpid, and it is worse.
*/
- if (enable_vpid)
+ if (enable_vpid) {
+ vmx->nested.nested_vmx_secondary_ctls_high |=
+ SECONDARY_EXEC_ENABLE_VPID;
vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT |
VMX_VPID_EXTENT_SUPPORTED_MASK;
- else
+ } else
vmx->nested.nested_vmx_vpid_caps = 0;
if (enable_unrestricted_guest)
--
2.7.4
[toc] | [next] | [standalone]
| From | Wanpeng Li <kernellwp@gmail.com> |
|---|---|
| Date | 2017-03-21 05:30 +0100 |
| Subject | [PATCH v2 3/3] KVM: x86: correct async page present tracepoint |
| Message-ID | <tnjAJ-6z6-9@gated-at.bofh.it> |
| In reply to | #1605300 |
From: Wanpeng Li <wanpeng.li@hotmail.com>
After async pf setup successfully, there is a broadcast wakeup w/ special
token 0xffffffff which tells vCPU that it should wake up all processes
waiting for APFs though there is no real process waiting at the moment.
The async page present tracepoint print prematurely and fails to catch the
special token setup. This patch fixes it by moving the async page present
tracepoint after the special token setup.
Before patch:
qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0x0 gva 0x0
After patch:
qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0xffffffff gva 0x0
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/x86.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1faf620..e27eb7f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -8566,11 +8566,11 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
{
struct x86_exception fault;
- trace_kvm_async_pf_ready(work->arch.token, work->gva);
if (work->wakeup_all)
work->arch.token = ~0; /* broadcast wakeup */
else
kvm_del_async_pf_gfn(vcpu, work->arch.gfn);
+ trace_kvm_async_pf_ready(work->arch.token, work->gva);
if ((vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED) &&
!apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) {
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | David Hildenbrand <david@redhat.com> |
|---|---|
| Date | 2017-03-21 10:00 +0100 |
| Subject | Re: [PATCH v2 3/3] KVM: x86: correct async page present tracepoint |
| Message-ID | <tnnO2-Sm-19@gated-at.bofh.it> |
| In reply to | #1605301 |
On 21.03.2017 05:18, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> After async pf setup successfully, there is a broadcast wakeup w/ special
> token 0xffffffff which tells vCPU that it should wake up all processes
> waiting for APFs though there is no real process waiting at the moment.
>
> The async page present tracepoint print prematurely and fails to catch the
> special token setup. This patch fixes it by moving the async page present
> tracepoint after the special token setup.
>
> Before patch:
>
> qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0x0 gva 0x0
>
> After patch:
>
> qemu-system-x86-8499 [006] ...1 5973.473292: kvm_async_pf_ready: token 0xffffffff gva 0x0
>
Wonder if there is a reason why this is traced before any work is done.
Maybe we should keep that order (by breaking up the if-else).
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/x86.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 1faf620..e27eb7f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -8566,11 +8566,11 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
> {
> struct x86_exception fault;
>
> - trace_kvm_async_pf_ready(work->arch.token, work->gva);
> if (work->wakeup_all)
> work->arch.token = ~0; /* broadcast wakeup */
> else
> kvm_del_async_pf_gfn(vcpu, work->arch.gfn);
> + trace_kvm_async_pf_ready(work->arch.token, work->gva);
>
> if ((vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED) &&
> !apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) {
>
--
Thanks,
David
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2017-03-21 17:30 +0100 |
| Message-ID | <tnuPw-5O6-27@gated-at.bofh.it> |
| In reply to | #1605300 |
On 21/03/2017 05:18, Wanpeng Li wrote:
> From: Wanpeng Li <wanpeng.li@hotmail.com>
>
> This can be reproduced by running kvm-unit-tests/vmx.flat on L0 w/ vpid disabled.
>
> Test suite: VPID
> Unhandled exception 6 #UD at ip 00000000004051a6
> error_code=0000 rflags=00010047 cs=00000008
> rax=0000000000000000 rcx=0000000000000001 rdx=0000000000000047 rbx=0000000000402f79
> rbp=0000000000456240 rsi=0000000000000001 rdi=0000000000000000
> r8=000000000000000a r9=00000000000003f8 r10=0000000080010011 r11=0000000000000000
> r12=0000000000000003 r13=0000000000000708 r14=0000000000000000 r15=0000000000000000
> cr0=0000000080010031 cr2=0000000000000000 cr3=0000000007fff000 cr4=0000000000002020
> cr8=0000000000000000
> STACK: @4051a6 40523e 400f7f 402059 40028f
>
> We should hide and forbid VPID in L1 if it is disabled on L0. However, nested VPID
> enable bit is set unconditionally during setup nested vmx exec controls though VPID
> is not exposed through nested VMX capablity. This patch fixes it by don't set nested
> VPID enable bit if it is disabled on L0.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Fixes: 5c614b3583e (KVM: nVMX: nested VPID emulation)
> Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
> ---
> arch/x86/kvm/vmx.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 98e82ee..8795a70 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2753,7 +2753,6 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
> SECONDARY_EXEC_RDTSCP |
> SECONDARY_EXEC_DESC |
> SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
> - SECONDARY_EXEC_ENABLE_VPID |
> SECONDARY_EXEC_APIC_REGISTER_VIRT |
> SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
> SECONDARY_EXEC_WBINVD_EXITING |
> @@ -2781,10 +2780,12 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
> * though it is treated as global context. The alternative is
> * not failing the single-context invvpid, and it is worse.
> */
> - if (enable_vpid)
> + if (enable_vpid) {
> + vmx->nested.nested_vmx_secondary_ctls_high |=
> + SECONDARY_EXEC_ENABLE_VPID;
> vmx->nested.nested_vmx_vpid_caps = VMX_VPID_INVVPID_BIT |
> VMX_VPID_EXTENT_SUPPORTED_MASK;
> - else
> + } else
> vmx->nested.nested_vmx_vpid_caps = 0;
>
> if (enable_unrestricted_guest)
>
Applied patch 1 and 3 to kvm/master (well, locally for now).
Paolo
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web