Received: by 10.223.176.46 with SMTP id f43csp747846wra; Wed, 24 Jan 2018 05:26:24 -0800 (PST) X-Google-Smtp-Source: AH8x224QjoLpdS3H9YEDBicqGyebddy6GhCb7idMlcqlthO1sQnFQsLLnKH05ibsNeqq45iwphgP X-Received: by 10.99.175.76 with SMTP id s12mr10855860pgo.240.1516800384761; Wed, 24 Jan 2018 05:26:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516800384; cv=none; d=google.com; s=arc-20160816; b=kqK+gnGR7VTKZOGb+33livr9sTKk2xeBi4OBf9l0AvK0w0dNmbGWStYC952hRG8Fsy xd10JRimYSxV/kTGbPeG3d8nFvl7nJn7l8LOmTV1WgKBxrEyp5KketIJxM8nT5GVIzF4 gbZiIp4/MUI8mYaXqqn25Ce4j7mvkqNlahsuuTXtTI9bRcWWtKYMv12mjFL1gzF2eVaN 0yix2VEqv6STTQNZlP1LNTpWOztsopM+t322rsaJuOjL6XRqTdwrwJHPlFMQV4l7PZkA ftsrl//UuB6e68UFYulrZ1LuO4BzVi9wPw2z41dCEiSp/4y3gquigjhhHmEJTNg1ZXCU Qa2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XzRA55/F7x6BooewBwdrMcqRBKZgWkMvG/iGrld5aXA=; b=R3NZlH99P/3iKUf6dOxaR+JfsR2HyZG0vBWeNWgJ+UcqDkeFsbKz/N9Hxh1Zo/p2HW oqpeZofCy6KXV7rkDMJeHSfQ2GT1KpCJrOSGnZ4LV9/8/R2qy4rNnqNOzn0xk1scCpBK jQ1if6nWMhyHDU+9CGDwZweMc/9rkDAz7qHEZp+Boa3ljqmeKoTNHMBOayofJripS+LM Kr4WHgko8L8e4FO6LNqQcIO7yeZO7YtftllgEgcBdVPSFvuhuEWC8950zh/FfRTVxAh7 X2X4NSBCoKRqocMOWgFPmKa0xMJOlrIO0gsIY/t0j7wjnm4t4lhHz5cbnjgISButZbBD y7Yw== 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 x16-v6si192949pll.736.2018.01.24.05.26.10; Wed, 24 Jan 2018 05:26:24 -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 S933879AbeAXNXz (ORCPT + 99 others); Wed, 24 Jan 2018 08:23:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38932 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933615AbeAXNXw (ORCPT ); Wed, 24 Jan 2018 08:23:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96149272B2; Wed, 24 Jan 2018 13:23:52 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBD7C7574E; Wed, 24 Jan 2018 13:23:42 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, x86@kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Andy Lutomirski , Mohammed Gamal , Cathy Avery , Roman Kagan , linux-kernel@vger.kernel.org, devel@linuxdriverproject.org Subject: [PATCH v4 1/7] x86/hyper-v: check for required priviliges in hyperv_init() Date: Wed, 24 Jan 2018 14:23:31 +0100 Message-Id: <20180124132337.30138-2-vkuznets@redhat.com> In-Reply-To: <20180124132337.30138-1-vkuznets@redhat.com> References: <20180124132337.30138-1-vkuznets@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 24 Jan 2018 13:23:52 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In hyperv_init() we presume we always have access to VP index and hypercall MSRs while according to the specification we should check if we're allowed to access the corresponding MSRs before accessing them. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Thomas Gleixner --- arch/x86/hyperv/hv_init.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c index 189a398290db..21f9d53d9f00 100644 --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -110,12 +110,19 @@ static int hv_cpu_init(unsigned int cpu) */ void hyperv_init(void) { - u64 guest_id; + u64 guest_id, required_msrs; union hv_x64_msr_hypercall_contents hypercall_msr; if (x86_hyper_type != X86_HYPER_MS_HYPERV) return; + /* Absolutely required MSRs */ + required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE | + HV_X64_MSR_VP_INDEX_AVAILABLE; + + if ((ms_hyperv.features & required_msrs) != required_msrs) + return; + /* Allocate percpu VP index */ hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index), GFP_KERNEL); -- 2.14.3