diff mbox series

[v2,2/2] x86/kvm/hyper-v: disallow setting illegal vectors for direct mode stimers

Message ID 20181212165017.13278-3-vkuznets@redhat.com (mailing list archive)
State New, archived
Headers show
Series x86/kvm/hyper-v: Direct Mode stimers fixes | expand

Commit Message

Vitaly Kuznetsov Dec. 12, 2018, 4:50 p.m. UTC
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(+)

Comments

Roman Kagan Dec. 13, 2018, 12:18 p.m. UTC | #1
On Wed, Dec 12, 2018 at 05:50:17PM +0100, Vitaly Kuznetsov wrote:
> 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(+)

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
diff mbox series

Patch

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)