From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755216AbcI2LtP (ORCPT ); Thu, 29 Sep 2016 07:49:15 -0400 Received: from mail.skyhub.de ([78.46.96.112]:49518 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754589AbcI2LtG (ORCPT ); Thu, 29 Sep 2016 07:49:06 -0400 Date: Thu, 29 Sep 2016 13:48:53 +0200 From: Borislav Petkov To: Andy Lutomirski Cc: x86@kernel.org, david@saggiorato.net, Brian Gerst , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486 Message-ID: <20160929114853.GC10578@nazgul.tnic> References: <70dfb68f8f312764d5f6aca6e2aa6d7dc76df6e4.1475091074.git.luto@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <70dfb68f8f312764d5f6aca6e2aa6d7dc76df6e4.1475091074.git.luto@kernel.org> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 28, 2016 at 12:34:15PM -0700, Andy Lutomirski wrote: > The condition for reading CR4 was wrong: there are some CPUs with > CPUID but not CR4. Rather than trying to make the condition exact, > using __read_cr4_safe(). > > Reported-by: david@saggiorato.net > Fixes: 18bc7bd523e0 ("x86/boot: Synchronize trampoline_cr4_features and mmu_cr4_features directly") > Signed-off-by: Andy Lutomirski > --- > arch/x86/kernel/setup.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 0fa60f5f5a16..5930a4d191b4 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -1137,9 +1137,13 @@ void __init setup_arch(char **cmdline_p) > * auditing all the early-boot CR4 manipulation would be needed to > * rule it out. > */ > - if (boot_cpu_data.cpuid_level >= 0) > - /* A CPU has %cr4 if and only if it has CPUID. */ > - mmu_cr4_features = __read_cr4(); > + if (boot_cpu_data.cpuid_level >= 0) { > + /* > + * CPUs without CPUID don't have CR4. CPUs with CPUID > + * usually have CR4. > + */ > + mmu_cr4_features = __read_cr4_safe(); > + } Why are we even doing the CPUID check instead of unconditionally doing __read_cr4_safe()? The safe variant will give 0 on !CR4 machines. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --