Return-Path: Received: from mx3-rdu2.redhat.com ([66.187.233.73] helo=mx1.redhat.com) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fOmJj-0002b0-2r for speck@linutronix.de; Fri, 01 Jun 2018 17:50:15 +0200 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 44156859A5 for ; Fri, 1 Jun 2018 15:50:08 +0000 (UTC) Received: from treble (ovpn-122-112.rdu2.redhat.com [10.10.122.112]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1E5AE2026609 for ; Fri, 1 Jun 2018 15:50:07 +0000 (UTC) Date: Fri, 1 Jun 2018 10:50:06 -0500 From: Josh Poimboeuf Subject: [MODERATED] Re: [PATCH v6 6/8] L1TFv6 3 Message-ID: <20180601155006.bjirurqbrvj5ygnu@treble> References: <20180524210235.19B9061156@crypto-ml.lab.linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180524210235.19B9061156@crypto-ml.lab.linutronix.de> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: On Thu, May 24, 2018 at 02:00:37PM -0700, speck for Andi Kleen wrote: > From: Andi Kleen > Subject: x86, l1tf: Report if too much memory for L1TF > workaround > > If the system has more than MAX_PA/2 physical memory the > invert page workarounds don't protect the system against > the L1TF attack anymore, because an inverted physical address > will point to valid memory. > > We cannot do much here, after all users want to use the > memory, but at least print a warning and report the system as > vulnerable in sysfs. > > Note this is all extremely unlikely to happen on a real machine > because they typically have far more MAX_PA than DIMM slots. > > Some VMs also report fairly small PAs to guest, e.g. only 36bits. > In this case the threshold will be lower, but applies only > to the maximum guest size. > > Currently forcing a feature beats clearing it. Since > this patch needs to clear a feature that has been forced > earlier also fix setup_clear... to prefer clearing > over setting. > > v2: > Do force clearing in setup_clear_... > Rename variables, fix comments, change formatting. > v3: Use boot_cpu_has_bug. Add l1tf_ Use l1tf_pfn_limit() > v4: Rephrase comment and warning message. > Signed-off-by: Andi Kleen > --- > arch/x86/kernel/cpu/cpuid-deps.c | 1 + > arch/x86/kernel/setup.c | 23 ++++++++++++++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c > index 2c0bd38a44ab..ffb178fe6356 100644 > --- a/arch/x86/kernel/cpu/cpuid-deps.c > +++ b/arch/x86/kernel/cpu/cpuid-deps.c > @@ -118,4 +118,5 @@ void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int feature) > void setup_clear_cpu_cap(unsigned int feature) > { > do_clear_cpu_cap(NULL, feature); > + clear_bit(feature, (unsigned long *)cpu_caps_set); > } > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 89fd35349412..3dc6158d40c5 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -785,7 +785,26 @@ static void __init trim_low_memory_range(void) > { > memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); > } > - > + > +static __init void l1tf_check_maxpa_memory(void) > +{ > + u64 half_pa; > + > + if (!boot_cpu_has_bug(X86_BUG_L1TF)) > + return; > + > + half_pa = (u64)l1tf_pfn_limit() << PAGE_SHIFT; This breaks bisection -- l1tf_pfn_limit() is introduced in the next patch. The patches can probably just be swapped. -- Josh