All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	linux-kernel@vger.kernel.org,
	"Roman Kagan" <rkagan@virtuozzo.com>
Subject: [PATCH v2 2/2] x86/kvm/hyper-v: disallow setting illegal vectors for direct mode stimers
Date: Wed, 12 Dec 2018 17:50:17 +0100	[thread overview]
Message-ID: <20181212165017.13278-3-vkuznets@redhat.com> (raw)
In-Reply-To: <20181212165017.13278-1-vkuznets@redhat.com>

APIC vectors used for direct mode stimers should be valid for lAPIC and
just like genuine Hyper-V we should #GP when an illegal one is specified.

Add the appropriate check to stimer_set_config()

Suggested-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 arch/x86/kvm/hyperv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
index 0a16a77e6ac3..8723a802e9b7 100644
--- a/arch/x86/kvm/hyperv.c
+++ b/arch/x86/kvm/hyperv.c
@@ -549,6 +549,11 @@ static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,
 	trace_kvm_hv_stimer_set_config(stimer_to_vcpu(stimer)->vcpu_id,
 				       stimer->index, config, host);
 
+	/* Valid vectors for Direct Mode are 16..255. */
+	if (new_config.enable && new_config.direct_mode &&
+	    new_config.apic_vector < HV_SYNIC_FIRST_VALID_VECTOR)
+		return 1;
+
 	stimer_cleanup(stimer);
 	if (old_config.enable &&
 	    !new_config.direct_mode && new_config.sintx == 0)
-- 
2.19.2


  parent reply	other threads:[~2018-12-12 16:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 16:50 [PATCH v2 0/2] x86/kvm/hyper-v: Direct Mode stimers fixes Vitaly Kuznetsov
2018-12-12 16:50 ` [PATCH v2 1/2] x86/hyper-v: Stop caring about EOI for direct stimers Vitaly Kuznetsov
2018-12-13 12:17   ` Roman Kagan
2018-12-12 16:50 ` Vitaly Kuznetsov [this message]
2018-12-13 12:18   ` [PATCH v2 2/2] x86/kvm/hyper-v: disallow setting illegal vectors for direct mode stimers Roman Kagan
2018-12-14 10:53 ` [PATCH v2 0/2] x86/kvm/hyper-v: Direct Mode stimers fixes Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181212165017.13278-3-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkagan@virtuozzo.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.