Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1830929ybt; Thu, 2 Jul 2020 15:16:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoj15BO9pqNHkpSnt5KaMvtc4AXZlNKz33dmXUBJuE2e1L/x6zn5cq1v8bh11pLkCYcnVy X-Received: by 2002:a17:906:1f52:: with SMTP id d18mr17510158ejk.84.1593728184445; Thu, 02 Jul 2020 15:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593728184; cv=none; d=google.com; s=arc-20160816; b=kKXeLO0X4XQ33It3bRn8cPjqINEshiSdtE2hJQDINiRWEoTTiT8/4fmpvCtBaNcTVt H+qttBPNXlYbq2SyT3G21jmeAyLUmmgQB/sj5krjTJXQBLalyPmzusyG7p6EH05ZO7Zv ucUhtk+EGhHMAJtAW4ez9IyNDQlMVcqH6P2R+wY+7MsqGlP2dOqVXGOqpY79zE06LKiz yuIDadvbrn7Vno1Tqs85X6IOZOj82u+aN3t7C24jpbgQ8HWGDYIYlvG8Ds2kjKBTJtwH cCHJc8vk6LoNIqt1zqAPpPdK81vozGXwqNGFLehD7YlKbjv6Ktd+t0Pg+ihRrFXbxtpe F9KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lcJAZjj8xewF97TwahN5y7Et+lrdL5BLJ9rAmJHlt1A=; b=JlPEG1I+uO7pUSX/s3khFe6garoczolEm9Kvu5/C1tXdTMsFpOQ5YW+2X65gn4TJZx 27i2xCKss3lGN/2WD1PMiATZFLB+jTqNbGl4hJnQ00lWV2fcUrjHZSECb2E3s7Nhw7GM HiOHjC+zsR6kHx0UJq28CsfAbhr6StRvVkkzzTvgZbyXkkzkcpbgayA+/J5wlNOIvQA9 C4AFc0y6a/SSkDVBG1Zp9ajECjOnp51GedZub1UJgAHfRm6JVAaplC9kQHlOmUa2HMXo UVAlXUukxCrKtTUiTk+bArCVFboeKiKZ4MwU80cfH3bN1Kh5CGhTsUWPaN/llkgTxszB 87/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WBlUeMpg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx16si6778061ejb.9.2020.07.02.15.16.01; Thu, 02 Jul 2020 15:16:24 -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=pass header.i=@google.com header.s=20161025 header.b=WBlUeMpg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbgGBWPR (ORCPT + 99 others); Thu, 2 Jul 2020 18:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbgGBWPQ (ORCPT ); Thu, 2 Jul 2020 18:15:16 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 808D6C08C5C1 for ; Thu, 2 Jul 2020 15:15:16 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id k6so25594263ili.6 for ; Thu, 02 Jul 2020 15:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lcJAZjj8xewF97TwahN5y7Et+lrdL5BLJ9rAmJHlt1A=; b=WBlUeMpgJQDKEDr6LjGfbHL+WCZTjSL7sdTk3Er+AOhPtLqBsqC8FMT3017u+4ojX4 NMLBegMXmRc6lbCAfWFJf75lGJnl9q5EP6QDTszdA9UcYkQyysEpsbtLr1iC7Xx0qsah rUeoDIYTMOeWWLfa8FBqN4StcBcX89Qv6PPJsVkB8QNMlV9WmT67j3517lvJpCcntFhm uBVmKsHhCyiEKXjai1Dpu9CwVlCVCAL97IiCiChQhWYRp5RR6MxKfyhMjGOZ0dWBheRJ JyWtYovv+ZQAcoFrBYibIKxIt7hvLCSLv4zV4GRNLwPkJnf1lbnOvi2uwNwytCpODpCB n4vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lcJAZjj8xewF97TwahN5y7Et+lrdL5BLJ9rAmJHlt1A=; b=rOHXFFCAHFfcxrz9wBW8rWW3FSMfIffm2FoPgIxvroqCNyke5nS/6R9soRp/KK+EO4 4ZKvSXebh4Uew+lAA2kVI+YobhHWaKwFOUmPf0HfMye4Hv1e/60fZoWdpOjDiGanhKhN dIj9uZLy2HpGKSi0a9dTVReMFwqkf8bjvyp6zhcqLhZNSnycJye0cXdEJf0oo3wvKGdJ j7+GN0x7oeYQxbv1U4X5bEwrISrerz1AuWw66+r1ILiZr/B6skMob5hIJ+8zhpQkUqU1 urX0Ik/zu5FCefqW4LOX6APl5CsFdM/R8SmHUFhRA/vV6ee8sIMEpRPLniht1josFFF7 zTkg== X-Gm-Message-State: AOAM532HUUKDIjeejgUcOvnR6ECFCORSyw9C1DrolYJ6Wd00TGjO29Wz an6prIpCaZev17ixF3GUO//zYe/ONzcigOGGUbnbIA== X-Received: by 2002:a92:cd01:: with SMTP id z1mr14965787iln.103.1593728115606; Thu, 02 Jul 2020 15:15:15 -0700 (PDT) MIME-Version: 1.0 References: <20200702213807.2511503-1-abhishekbh@google.com> <9c648d11-6b52-c755-d0a6-58f035ccd99d@infradead.org> In-Reply-To: <9c648d11-6b52-c755-d0a6-58f035ccd99d@infradead.org> From: Abhishek Bhardwaj Date: Thu, 2 Jul 2020 15:14:38 -0700 Message-ID: Subject: Re: [PATCH v2] x86/speculation/l1tf: Add KConfig for setting the L1D cache flush mode To: Randy Dunlap Cc: LKML , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 2, 2020 at 3:01 PM Randy Dunlap wrote: > > 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? Sorry, I don't know what this means. The runtime options this aims to emulate applied to kvm driver. Hence, this kernel config applies to KVM ? > > and the "X86 && X86_64" is more than is needed. Just "X86_64" alone > should be enough. Fixed in v3. > > > > + 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" This was a bad copy paste. Removed in v3. > > > 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 > -- Abhishek