KVM: X86: Do not yield to self
PATCH 1/1 KVM: X86: Do not yield to self
From: Wanpeng Li <[email protected]>
If the target is self we do not need to yield, we can avoid malicious guest to play this.
---
Rebased on https://lore.kernel.org/kvm/[email protected]/
arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/x86.c +4 -0
@@ -8230,6 +8230,10 @@ static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id)if (!target) goto no_yield; +/* yield to self */ +if (vcpu->vcpu_id == target->vcpu_id) + goto no_yield; +if (!READ_ONCE (target->ready)) goto no_yield;
Signature · 1 line
2.7.4
Sean Christopherson
maintainerQuoted 17 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
If the target is self we do not need to yield, we can avoid malicious guest to play this.
Signed-off-by Wanpeng Li <[email protected]>---
Rebased on https://lore.kernel.org/kvm/[email protected]/arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id) · line 8233
Quoted 4 lines
arch/x86/kvm/x86.c +1
-0@@ -8230,6 +8230,10 @@ static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id)if (!target) goto no_yield; +/* yield to self */
If you're going to bother with a comment, maybe elaborate a bit, e.g.
/* Ignore requests to yield to self. */
Quoted 9 lines
arch/x86/kvm/x86.c +3
-0+if (vcpu->vcpu_id == target->vcpu_id) + goto no_yield; +if (!READ_ONCE (target->ready)) goto no_yield;Signature · 1 line
2.7.4
Quoted 22 lines · Sean Christopherson
Quoted 20 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
If the target is self we do not need to yield, we can avoid malicious guest to play this.
Signed-off-by Wanpeng Li <[email protected]>---
Rebased on https://lore.kernel.org/kvm/[email protected]/arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/kvm/x86.c +0
-0@@ -8230,6 +8230,10 @@ static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id)if (!target) goto no_yield;
Quoted 5 lines
arch/x86/kvm/x86.c static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id) · line 8233
Quoted 1 line
arch/x86/kvm/x86.c +1
-0+/* yield to self */ If you're going to bother with a comment, maybe elaborate a bit, e.g.
/* Ignore requests to yield to self. */
Looks good, thanks.
Wanpeng