Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1864877ybt; Thu, 2 Jul 2020 16:18:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNlKTWPFsqtxqmvJRZLWKcF04DXvSNEUNsHM9/z4+tzFopw0XCzaz4XbD7rbiKSkqmCdod X-Received: by 2002:a05:6402:1a4b:: with SMTP id bf11mr23239332edb.191.1593731918855; Thu, 02 Jul 2020 16:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593731918; cv=none; d=google.com; s=arc-20160816; b=Z30Y0tLJjKKxm8AsERncmSJGY1ey9J30F9O4TDBsNNxi6VC8d8wS/3MCjLQjgImWzZ CCjwQnNediL4/aftgV2x3MANER8ghlJIBBMei6H4wlmHhwaC/ZQdysG/PP8baZARq9Kl TnuwtVZnYmrK+eoVwsckTCspKkGSIXfHUKNF1ITgdA0zAyFVh4JEcpPsMPyCcYy9k+I/ yHPphnSBpqtbvmo/qcebhGcVx3eRBIu2A5IPDLxeq9+eAa4j3kmDe1vAwLMJxaRQQsSV hFf146L9XKXO/KzccCQBv5xy8Qg/obGgDiv/Ixsayf7r2iWh4g1ipdUG7fUZWuvNN+Wr 4Ggg== 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=B/JphhCu3M1hSIG0Qr2x65szj7uszGgbufi/R0O3CrU=; b=gstMqU4khHtBFHxnyejLliwLKQkPkb3ApsjD8+Bx5z5IUAEkWhVjga7012IzQQ/ij/ LYCZCrDtrFJiPoFtJV4rWjUdRxbTlhmDMNtE1fm00iWrl5ZVjua9qpbgCRSfoU7T9tYw dALzWS1NyxtoxngVdvsdAgrMn5G64CtAXcx97Y2yckpgq32PMqO0/FIlmfumuzXasXd3 XJWGek6Wws6XMK5Sh5b4XeDH3B9U6SNAnIdGjidgnsXuCYPOywB9pEHt+0azEo3a/uuD 6jtrnH4uBLAJu0FKmtoQIahljv7XI1j5SAcDqRj4Cw0lDekCUj42YMNCcaFhEVtpGO0d 2RgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=XrCbPgWB; 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 k8si6788909ejc.257.2020.07.02.16.18.14; Thu, 02 Jul 2020 16:18:38 -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=XrCbPgWB; 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 S1726194AbgGBXQp (ORCPT + 99 others); Thu, 2 Jul 2020 19:16:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726017AbgGBXQp (ORCPT ); Thu, 2 Jul 2020 19:16:45 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A75BC08C5C1; Thu, 2 Jul 2020 16:16:44 -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=B/JphhCu3M1hSIG0Qr2x65szj7uszGgbufi/R0O3CrU=; b=XrCbPgWByhnDZis4NQa7dSvZdl lbDiqQzKHZEzRZ1EbvVukQ6KwTc1zxwQuWbMf2UQOgs62dM4gUsHtqbzlwaM6Qm5YuuknDU8kYf27 xoPkCGduZueR5k7lba2dPlyiIfJ3c7EybO1enmRfPmtodsQzeOj536JGpPRulet3xecEb/IaIAj3H x8exA5FiimEzjC8ABrQ8D5VXi7ByjNQ1obo/Z/drj7kGPNPSZwUdZBLM9XRczxutW5wi5aZQvNCHL YSZwpNy0RlIWs50f98fWXi3Fk58pecd/qOAkXRn3w1rVsq6cMzJj0UoR8mEUkWzo9re2R2hf/D2sJ hhFz8wPw==; Received: from [2601:1c0:6280:3f0::19c2] by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jr8RT-0005Hh-1p; Thu, 02 Jul 2020 23:16:31 +0000 Subject: Re: [PATCH v3] 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 , Mike Rapoport , 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: <20200702221237.2517080-1-abhishekbh@google.com> From: Randy Dunlap Message-ID: Date: Thu, 2 Jul 2020 16:16:22 -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: <20200702221237.2517080-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 On 7/2/20 3:12 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 v3: > - Change depends on to only x86_64. > - Remove copy paste errors at the end of the KConfig. > > Changes in v2: > - Fix typo in the help of the new KConfig. > > arch/x86/kernel/cpu/bugs.c | 8 ++++++++ > arch/x86/kvm/Kconfig | 13 +++++++++++++ > 2 files changed, 21 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..1f85374a0b812 100644 > --- a/arch/x86/kvm/Kconfig > +++ b/arch/x86/kvm/Kconfig > @@ -107,4 +107,17 @@ 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_64 > + 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. No hurry on this (wait for other comments), but help text should be indented by one tab + 2 spaces, per Documentation/process/coding-style.rst: Lines under a ``config`` definition are indented with one tab, while help text is indented an additional two spaces. > + > endif # VIRTUALIZATION > -- ~Randy