From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88BBEC65BAF for ; Wed, 12 Dec 2018 16:50:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 51F832080F for ; Wed, 12 Dec 2018 16:50:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51F832080F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728277AbeLLQu0 (ORCPT ); Wed, 12 Dec 2018 11:50:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728261AbeLLQuX (ORCPT ); Wed, 12 Dec 2018 11:50:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B73FA3004E78; Wed, 12 Dec 2018 16:50:23 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13A4C61B6E; Wed, 12 Dec 2018 16:50:21 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , linux-kernel@vger.kernel.org, Roman Kagan 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 Message-Id: <20181212165017.13278-3-vkuznets@redhat.com> In-Reply-To: <20181212165017.13278-1-vkuznets@redhat.com> References: <20181212165017.13278-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 12 Dec 2018 16:50:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Vitaly Kuznetsov --- 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