2021-09-14 09:49:14

by Chenyi Qiang

[permalink] [raw]
Subject: [PATCH v2] KVM: nVMX: Fix nested bus lock VM exit

Nested bus lock VM exits are not supported yet. If L2 triggers bus lock
VM exit, it will be directed to L1 VMM, which would cause unexpected
behavior. Therefore, handle L2's bus lock VM exits in L0 directly.

Fixes: fe6b6bc802b4 ("KVM: VMX: Enable bus lock VM exit")
Signed-off-by: Chenyi Qiang <[email protected]>

---
Change log
v1->v2
- Because nested bus lock VM exit is not supported and how nested
support would operate is uncertain. Add a brief comment to state that this
feature is never exposed to L1 at present. (Sean)
- v1: https://lore.kernel.org/lkml/[email protected]/
---
arch/x86/kvm/vmx/nested.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index bc6327950657..5646cc1e8d4c 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5873,6 +5873,12 @@ static bool nested_vmx_l0_wants_exit(struct kvm_vcpu *vcpu,
case EXIT_REASON_VMFUNC:
/* VM functions are emulated through L2->L0 vmexits. */
return true;
+ case EXIT_REASON_BUS_LOCK:
+ /*
+ * At present, bus lock VM exit is never exposed to L1.
+ * Handle L2's bus locks in L0 directly.
+ */
+ return true;
default:
break;
}
--
2.17.1


2021-09-21 01:32:02

by Sean Christopherson

[permalink] [raw]
Subject: Re: [PATCH v2] KVM: nVMX: Fix nested bus lock VM exit

On Tue, Sep 14, 2021, Chenyi Qiang wrote:
> Nested bus lock VM exits are not supported yet. If L2 triggers bus lock
> VM exit, it will be directed to L1 VMM, which would cause unexpected
> behavior. Therefore, handle L2's bus lock VM exits in L0 directly.
>
> Fixes: fe6b6bc802b4 ("KVM: VMX: Enable bus lock VM exit")

Cc: [email protected]

> Signed-off-by: Chenyi Qiang <[email protected]>
>
> ---

Reviewed-by: Sean Christopherson <[email protected]>

2021-09-22 02:12:46

by Xiaoyao Li

[permalink] [raw]
Subject: Re: [PATCH v2] KVM: nVMX: Fix nested bus lock VM exit

On 9/14/2021 5:50 PM, Chenyi Qiang wrote:
> Nested bus lock VM exits are not supported yet. If L2 triggers bus lock
> VM exit, it will be directed to L1 VMM, which would cause unexpected
> behavior. Therefore, handle L2's bus lock VM exits in L0 directly.
>
> Fixes: fe6b6bc802b4 ("KVM: VMX: Enable bus lock VM exit")
> Signed-off-by: Chenyi Qiang <[email protected]>

Reviewed-by: Xiaoyao Li <[email protected]>

> ---
> Change log
> v1->v2
> - Because nested bus lock VM exit is not supported and how nested
> support would operate is uncertain. Add a brief comment to state that this
> feature is never exposed to L1 at present. (Sean)
> - v1: https://lore.kernel.org/lkml/[email protected]/
> ---
> arch/x86/kvm/vmx/nested.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index bc6327950657..5646cc1e8d4c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -5873,6 +5873,12 @@ static bool nested_vmx_l0_wants_exit(struct kvm_vcpu *vcpu,
> case EXIT_REASON_VMFUNC:
> /* VM functions are emulated through L2->L0 vmexits. */
> return true;
> + case EXIT_REASON_BUS_LOCK:
> + /*
> + * At present, bus lock VM exit is never exposed to L1.
> + * Handle L2's bus locks in L0 directly.
> + */
> + return true;
> default:
> break;
> }
>

2021-09-22 09:59:18

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH v2] KVM: nVMX: Fix nested bus lock VM exit

On 20/09/21 16:52, Sean Christopherson wrote:
> On Tue, Sep 14, 2021, Chenyi Qiang wrote:
>> Nested bus lock VM exits are not supported yet. If L2 triggers bus lock
>> VM exit, it will be directed to L1 VMM, which would cause unexpected
>> behavior. Therefore, handle L2's bus lock VM exits in L0 directly.
>>
>> Fixes: fe6b6bc802b4 ("KVM: VMX: Enable bus lock VM exit")
>
> Cc: [email protected]
>
>> Signed-off-by: Chenyi Qiang <[email protected]>
>>
>> ---
>
> Reviewed-by: Sean Christopherson <[email protected]>
>

Queued, thanks.

Paolo