diff options
| author | Wanpeng Li <[email protected]> | 2021-04-09 12:18:31 +0800 |
|---|---|---|
| committer | Paolo Bonzini <[email protected]> | 2021-04-19 18:04:46 -0400 |
| commit | a1fa4cbd53d9bc7bb0eaa7bcf7c8a5904372a4ec (patch) | |
| tree | 79403ec43ea41295aa61a6e26d61b296d2ebe8f8 | |
| parent | 4a7132efff1c9f4f80b3cdba75b81c4344e088c2 (diff) | |
KVM: X86: Do not yield to self
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]>
Message-Id: <[email protected]>
Cc: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
| -rw-r--r-- | arch/x86/kvm/x86.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 05a4bce181d7..66d2ab074a5f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -8228,6 +8228,10 @@ static void kvm_sched_yield(struct kvm_vcpu *vcpu, unsigned long dest_id) if (!target || !READ_ONCE(target->ready)) goto no_yield; + /* Ignore requests to yield to self */ + if (vcpu == target) + goto no_yield; + if (kvm_vcpu_yield_to(target) <= 0) goto no_yield; |