Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp95818ybc; Mon, 18 Nov 2019 21:05:19 -0800 (PST) X-Google-Smtp-Source: APXvYqy7GPQGBPuK3nJj2nRNa4hejViNOgTOohz1wtKXT4q13PDnLy/zEvxLhWmGEvc8Qv9WYc6n X-Received: by 2002:a17:906:1cd8:: with SMTP id i24mr31985570ejh.149.1574139919198; Mon, 18 Nov 2019 21:05:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574139919; cv=none; d=google.com; s=arc-20160816; b=cqCM+sLQjc+9ztm6gUMITq1FbFSs9yV7D/xPWFEoeaoDH9z/7/yEoxGRu0Hvlgh94K qBqbRgYkLQEhlqTYfxNl0CRZ+aXD4swHsINNAsyHKXlp6ZKkWNhNeNy5qPglCvi17lOI qLb9rwZRJJxNTlQzSqz7wxHFlW3GvHXYwGp4aaCkJuePHiUyWvLY6+7DcTS5R23FhJd9 obAN1AulRfjWaFCegiHZuus/ha8QUA0kJy+37hcxBfIAKXXzu4m43ex36+uK4mHPJjDx VysXqL7qtsHdRoHopT1vdpf7Hm9lGskxpmH7WTKqCPU5QkFIzJJ1Mmps5LZIyks6HWrC AiWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Qo5TVJWiAhOEva8P2mJ1z2iezO0JgR9weJ2LnTcztUM=; b=xoKYEPC9uuaMJEoufNEsHvbmRG+NrHR2BDqQ9Geb0EvwWhOce8I7L8CMCejU7E6LW5 CEGiAz/Vw09MEzntvY3YAIis0ZOzPe7TlE91f1lOEqHcxK/j726ivqksSeATOw4ulSY9 FcggweWSxMhkIZFKFjHIxo/gp9KZaxyVzcXBoN5Arcc4zSFbxXdnjbE97EPLOz+ETcMP uuWEP/fXY0R93xFuF2OVgTWpfMLyZPnfRscPDKERKIBlAXKWY//6RGZYKzjpJs7lAYVe hWRhxR2DH4HNg1FHVB0DLwM1HNZtHMAkzyAr6SgT/e/NzF239H/dXD+gXnvFN0lA0loJ A8jQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o2si16111020edj.290.2019.11.18.21.04.55; Mon, 18 Nov 2019 21:05:19 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726667AbfKSFDW (ORCPT + 99 others); Tue, 19 Nov 2019 00:03:22 -0500 Received: from mga14.intel.com ([192.55.52.115]:8390 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726170AbfKSFDW (ORCPT ); Tue, 19 Nov 2019 00:03:22 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 21:03:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,322,1569308400"; d="scan'208";a="407626283" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.41]) by fmsmga006.fm.intel.com with ESMTP; 18 Nov 2019 21:03:17 -0800 Date: Mon, 18 Nov 2019 21:03:17 -0800 From: Sean Christopherson To: Kai Huang Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Tony Luck , Tony W Wang-oc , Shuah Khan , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-edac@vger.kernel.org, linux-kselftest@vger.kernel.org, Borislav Petkov , Jarkko Sakkinen Subject: Re: [PATCH v3 04/19] x86/intel: Initialize IA32_FEATURE_CONTROL MSR at boot Message-ID: <20191119050317.GF23085@linux.intel.com> References: <20191119031240.7779-1-sean.j.christopherson@intel.com> <20191119031240.7779-5-sean.j.christopherson@intel.com> <17a1831a3a72fb87ce2a35689e07ff517c4bdf99.camel@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17a1831a3a72fb87ce2a35689e07ff517c4bdf99.camel@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 19, 2019 at 05:41:49PM +1300, Kai Huang wrote: > On Mon, 2019-11-18 at 19:12 -0800, Sean Christopherson wrote: > > + /* > > + * Enable VMX if and only if the kernel may do VMXON at some point, > > + * i.e. KVM is enabled, to avoid unnecessarily adding an attack vector > > + * for the kernel, e.g. using VMX to hide malicious code. > > + */ > > + if (cpu_has(c, X86_FEATURE_VMX) && IS_ENABLED(CONFIG_KVM)) { Hmm, this should more specifically be CONFIG_KVM_INTEL. > > + msr |= FEAT_CTL_VMX_ENABLED_OUTSIDE_SMX; > > + if (tboot_enabled()) > > + msr |= FEAT_CTL_VMX_ENABLED_INSIDE_SMX; > > + } > > Why not also take this chance to enable SGX? Or it will come with SGX patch > series? The latter. Similar to the KVM check, this shouldn't opt in to SGX unless the kernel is capable of using SGX. > > + wrmsrl(MSR_IA32_FEATURE_CONTROL, msr); > > +} > > diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c > > index 4a900804a023..b7c6ed0b40b6 100644 > > --- a/arch/x86/kernel/cpu/intel.c > > +++ b/arch/x86/kernel/cpu/intel.c > > @@ -755,6 +755,8 @@ static void init_intel(struct cpuinfo_x86 *c) > > /* Work around errata */ > > srat_detect_node(c); > > > > + init_feature_control_msr(c); > > Will this compile if you disable CONFIG_X86_FEATURE_CONTROL_MSR? > > Provide an empty one in cpu.h if the config is not enabled? CONFIG_X86_FEATURE_CONTROL_MSR can't be disabled manually, it's selected by CPU_SUP_INTEL (and by Zhaoxin/Centaur for their relevant patches).