Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1493680

Re: [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486

From Andy Lutomirski <luto@amacapital.net>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486
Date 2016-09-29 21:10 +0200
Message-ID <smOSt-88A-9@gated-at.bofh.it> (permalink)
References <smsRX-2td-3@gated-at.bofh.it> <smsRX-2td-7@gated-at.bofh.it> <smI0G-3zS-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Sep 29, 2016 at 4:48 AM, Borislav Petkov <bp@alien8.de> wrote:
> 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 <luto@kernel.org>
>> ---
>>  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.

Will do.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] CR4 fixes (some are urgent) Andy Lutomirski <luto@kernel.org> - 2016-09-28 21:40 +0200
  [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486 Andy Lutomirski <luto@kernel.org> - 2016-09-28 21:40 +0200
    Re: [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486 Borislav Petkov <bp@alien8.de> - 2016-09-29 13:50 +0200
      Re: [PATCH 2/3] x86/boot: Fix another __read_cr4() case on 486 Andy Lutomirski <luto@amacapital.net> - 2016-09-29 21:10 +0200
  [PATCH 3/3] x86/asm: Get rid of __read_cr4_safe() Andy Lutomirski <luto@kernel.org> - 2016-09-28 21:40 +0200
  [PATCH 1/3] x86/init: Fix cr4_init_shadow() on CR4-less machines Andy Lutomirski <luto@kernel.org> - 2016-09-28 21:40 +0200
    Re: [PATCH 1/3] x86/init: Fix cr4_init_shadow() on CR4-less machines Borislav Petkov <bp@alien8.de> - 2016-09-29 13:50 +0200
    [tip:x86/urgent] x86/init: Fix cr4_init_shadow() on CR4-less  machines tip-bot for Andy Lutomirski <tipbot@zytor.com> - 2016-09-29 20:30 +0200

csiph-web