Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1823400ybt; Thu, 2 Jul 2020 15:03:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymrgdHyv5BZBpR93SetTgf91DJfo5ksHyAf+uxwXROelWn/1r6qgWF4JHWF2IlDzY00YUW X-Received: by 2002:a17:906:5283:: with SMTP id c3mr27701731ejm.22.1593727429753; Thu, 02 Jul 2020 15:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593727429; cv=none; d=google.com; s=arc-20160816; b=yogPxDewX6WFEwEVJk2B2bJPo8RmTOHzdEuM1YeSIPIQpyKa1o1WBkD+1gXho1DKW5 w7K3hGJb6bkfgZgkUPt4BMl33F6lTHF/CFXvabCP590B+BJRmR1qq8/xEg72T2CahtwL TBEl93spNF/tN6qrMShBMFJfX8O6WRt1DZiLRLAgnBeWthIsOYOv8yP4gBEaPeKaqzNs CcceGy+IPCqxNMY+2sufZtASRgdOPgXPxej1T5hVYuAId8JMkkpI7MwdMri2QxbDILDt WDeNMeWLR/BSy5DkwhsJKACMYhUS32SbKRvBZHjbUC1LngLpKRzVwzUSisB/Az1Ukf3u rhAw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=M9o/yoakftKlRxGmFhWGkioeRiqSbXBUgs5p6s59O+0=; b=Rz3CtM8G8vXUHLlYe+7Z+PQhZC/bgvqCsTZObT4vq9wTR7WJ3eiOtuZFqIETmP5fyS PjiJUKaenC9Xowy35vmw7MsF8Ns4eJTYhQEZ83FXF2A2ozDkKNnUHFTG0JQE/rIoYpSL 2qWN1gnW3FKoO8xDusF0tfd6Up9P8L0MzWN9CVF5Zc/e5RWvNteQoRyhk2NtJryKmq7K aUpEukUjypY1qtJvU6DBBj4cy6IuEEeeqaZw6cdreY/n/3BC7hP5fb9pDK0WrxOFZuwm 1aQpuU4pZYkyeThqxNu5Axw/K6xrJ8QBJdvwjfkKzuzxFmIvdx5ub9cGKuMnQ9bY0Cm6 DGZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=aDpOVh4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df7si2676070edb.462.2020.07.02.15.03.27; Thu, 02 Jul 2020 15:03:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=aDpOVh4x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbgGBWBc (ORCPT + 99 others); Thu, 2 Jul 2020 18:01:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgGBWBb (ORCPT ); Thu, 2 Jul 2020 18:01:31 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9596DC08C5C1; Thu, 2 Jul 2020 15:01:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=M9o/yoakftKlRxGmFhWGkioeRiqSbXBUgs5p6s59O+0=; b=aDpOVh4x4GOtkt487bsCMFmLSw BslNH2ww+Y8SlYgWBognViQiZOYQ6VTKshjcPKegMCvXiA3j0oYopZF6UvSS8zaZM5hDObhUAzQVG LqPztF+/XEFRB85h2czRWj+OsWShXyoZ8ImCpfANrh/FLOJVgTiYyDWemFFKK/61XGNIjAioTzbCE VIcKncMxdL4casr61+Vnh251PCDTUvOJq2ulf8nVAEJeGhdgk9KbPNoXixYAxB0Zz568ML0mGHRla 7ggYV3A1rYw2PSvtNxz6BBXgo3AIBAI7U48I6go6z2zO8zrJufEL+Cs7ENsxyLGOpEynIAAsM53Sm hP64XkLA==; Received: from [2601:1c0:6280:3f0::19c2] by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jr7Gd-0008S8-LM; Thu, 02 Jul 2020 22:01:15 +0000 Subject: Re: [PATCH v2] x86/speculation/l1tf: Add KConfig for setting the L1D cache flush mode To: Abhishek Bhardwaj , LKML Cc: Anthony Steinhauser , Borislav Petkov , "H. Peter Anvin" , Ingo Molnar , Jim Mattson , Joerg Roedel , Josh Poimboeuf , Mark Gross , Paolo Bonzini , Pawan Gupta , Peter Zijlstra , Sean Christopherson , Thomas Gleixner , Tony Luck , Vitaly Kuznetsov , Waiman Long , Wanpeng Li , kvm@vger.kernel.org, x86@kernel.org References: <20200702213807.2511503-1-abhishekbh@google.com> From: Randy Dunlap Message-ID: <9c648d11-6b52-c755-d0a6-58f035ccd99d@infradead.org> Date: Thu, 2 Jul 2020 15:01:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200702213807.2511503-1-abhishekbh@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi-- On 7/2/20 2:38 PM, Abhishek Bhardwaj wrote: > This change adds a new kernel configuration that sets the l1d cache > flush setting at compile time rather than at run time. > > Signed-off-by: Abhishek Bhardwaj > > --- > > Changes in v2: > - Fix typo in the help of the new KConfig. > > arch/x86/kernel/cpu/bugs.c | 8 ++++++++ > arch/x86/kvm/Kconfig | 17 +++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c > index 0b71970d2d3d2..1dcc875cf5547 100644 > --- a/arch/x86/kernel/cpu/bugs.c > +++ b/arch/x86/kernel/cpu/bugs.c > @@ -1406,7 +1406,15 @@ enum l1tf_mitigations l1tf_mitigation __ro_after_init = L1TF_MITIGATION_FLUSH; > #if IS_ENABLED(CONFIG_KVM_INTEL) > EXPORT_SYMBOL_GPL(l1tf_mitigation); > #endif > +#if (CONFIG_KVM_VMENTRY_L1D_FLUSH == 1) > +enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_NEVER; > +#elif (CONFIG_KVM_VMENTRY_L1D_FLUSH == 2) > +enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_COND; > +#elif (CONFIG_KVM_VMENTRY_L1D_FLUSH == 3) > +enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_ALWAYS; > +#else > enum vmx_l1d_flush_state l1tf_vmx_mitigation = VMENTER_L1D_FLUSH_AUTO; > +#endif > EXPORT_SYMBOL_GPL(l1tf_vmx_mitigation); > > /* > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > index b277a2db62676..d375dcedd447d 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -107,4 +107,21 @@ config KVM_MMU_AUDIT > This option adds a R/W kVM module parameter 'mmu_audit', which allows > auditing of KVM MMU events at runtime. > > +config KVM_VMENTRY_L1D_FLUSH > + int "L1D cache flush settings (1-3)" > + range 1 3 > + default "2" > + depends on KVM && X86 && X86_64 Why does this apply only to KVM? and the "X86 && X86_64" is more than is needed. Just "X86_64" alone should be enough. > + help > + This setting determines the L1D cache flush behavior before a VMENTER. > + This is similar to setting the option / parameter to > + kvm-intel.vmentry_l1d_flush. > + 1 - Never flush. > + 2 - Conditionally flush. > + 3 - Always flush. > + > +# OK, it's a little counter-intuitive to do this, but it puts it neatly under > +# the virtualization menu. > +source "drivers/vhost/Kconfig" I don't quite understand why this 'source' line is here. Can you explain more about that, please? It puts "VHOST drivers" in the menu 2 times, in 2 totally unrelated places. Seems like it could be confusing. > + > endif # VIRTUALIZATION -- ~Randy