Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2061627imu; Wed, 12 Dec 2018 08:53:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/VvLEPghghKmFoajFUhzERhKgEH9PtOA28T0KxBhfsLkdIQdDeRbayev94dfeI9I1aHjqzs X-Received: by 2002:a17:902:209:: with SMTP id 9mr20873826plc.288.1544633619592; Wed, 12 Dec 2018 08:53:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544633619; cv=none; d=google.com; s=arc-20160816; b=JKgdrAxNHLJUwuSUHLLTU5AoEY+GSLaVkDiIiLlc9soY9JAYyUu+gmXpc0nEpqZQgV DX9dul7pl+B8dkSgpG94Ex8+COqS0VQJaRBvkpycVB9dvBVgBh7Ip3k70BMV4RqzQ3gc dHzjxg1Lli2M7N6Sd+1LruKL9Uv9P/PdVkRcCCxuSRmj+wRQlFFgWjNUpKXCF5AWhwY1 OrTUgPdAZiYTBHiHIYmqe5RKEbMG9PLYpp7ipI30orviW4xkpwHtu4V961qNrORf9lwl /fS+YQCjnhv6cDKcfKoUGmBhkZnYhCUfMHJbKOze2ogCXy8bvTrTmpUd4m6Or1US/jxk p2+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HQFPFjdTik7XUampY3AjRIRRh56fyncnfFnZrmE3Ioo=; b=WpXfMZ0vKqvU1Fqp0HmcDpr4Opa7xAl/h2PucDP2GY+m0iG4feUWk5K7bIdC+F9Lt8 11vGrQ6YzsdYAIqQH0m6f6W4wXHwUCr8Lv9GLWOX3LCQCE6aMMIDpn74dQBQyjkDz703 XcJ7x9BfXvfQ9i9lGgQ/DX9LkZZM7yB+2vkYQq2/xdZ4SjYEWPsLHSI1Lt8Fn8QSX3pd jacIP9Zqc/5ZEyDnWEsO0s/LTySuuV8GMOvDmiwEbsbkgIilcTeBAjjPNt9rku80z/b4 e9ILzINJiyaiyl5UwphBdzoiyRpex6opsOc/MxVr10tGGbrSqRG0k0+6NF6p4btaFz3Z GMFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c136si16193001pfc.141.2018.12.12.08.53.24; Wed, 12 Dec 2018 08:53:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728272AbeLLQuZ (ORCPT + 99 others); Wed, 12 Dec 2018 11:50:25 -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