Skip to content
  1. Dec 24, 2016
    • Josh Poimboeuf's avatar
      Revert "x86/unwind: Detect bad stack return address" · c280f773
      Josh Poimboeuf authored
      Revert the following commit:
      
        b6959a36
      
       ("x86/unwind: Detect bad stack return address")
      
      ... because Andrey Konovalov reported an unwinder warning:
      
        WARNING: unrecognized kernel stack return address ffffffffa0000001 at ffff88006377fa18 in a.out:4467
      
      The unwind was initiated from an interrupt which occurred while running in the
      generated code for a kprobe.  The unwinder printed the warning because it
      expected regs->ip to point to a valid text address, but instead it pointed to
      the generated code.
      
      Eventually we may want come up with a way to identify generated kprobe
      code so the unwinder can know that it's a valid return address.  Until
      then, just remove the warning.
      
      Reported-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/02f296848fbf49fb72dfeea706413ecbd9d4caf6.1482418739.git.jpoimboe@redhat.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      c280f773
  2. Dec 23, 2016
    • Peter Zijlstra's avatar
      x86/paravirt: Mark unused patch_default label · cef4402d
      Peter Zijlstra authored
      A bugfix commit:
      
        45dbea5f
      
       ("x86/paravirt: Fix native_patch()")
      
      ... introduced a harmless warning:
      
        arch/x86/kernel/paravirt_patch_32.c: In function 'native_patch':
        arch/x86/kernel/paravirt_patch_32.c:71:1: error: label 'patch_default' defined but not used [-Werror=unused-label]
      
      Fix it by annotating the label as __maybe_unused.
      
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reported-by: default avatarPiotr Gregor <piotrgregor@rsyncme.org>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 45dbea5f
      
       ("x86/paravirt: Fix native_patch()")
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cef4402d
  3. Dec 21, 2016
  4. Dec 20, 2016
    • Nicolas Iooss's avatar
      x86/platform/intel/quark: Add printf attribute to imr_self_test_result() · 9120cf4f
      Nicolas Iooss authored
      
      
      __printf() attributes help detecting issues in printf() format strings at
      compile time.
      
      Even though imr_selftest.c is only compiled with
      CONFIG_DEBUG_IMR_SELFTEST=y, GCC complains about a missing format
      attribute when compiling allmodconfig with -Wmissing-format-attribute.
      
      Silence this warning by adding the attribute.
      
      Signed-off-by: default avatarNicolas Iooss <nicolas.iooss_linux@m4x.org>
      Acked-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20161219132144.4108-1-nicolas.iooss_linux@m4x.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      9120cf4f
    • Linus Walleij's avatar
      x86/platform/intel-mid: Switch MPU3050 driver to IIO · 634b847b
      Linus Walleij authored
      The Intel Mid goes in and creates a I2C device for the
      MPU3050 if the input driver for MPU-3050 is activated.
      
      As of commit:
      
        3904b28e
      
       ("iio: gyro: Add driver for the MPU-3050 gyroscope")
      
      .. there is a proper and fully featured IIO driver for this
      device, so deprecate the use of the incomplete input driver
      by augmenting the device population code to react to the
      presence of the IIO driver's Kconfig symbol instead.
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Cc: Jonathan Cameron <jic23@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1481722794-4348-1-git-send-email-linus.walleij@linaro.org
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      634b847b
    • Borislav Petkov's avatar
      x86/alternatives: Do not use sync_core() to serialize I$ · 34bfab0e
      Borislav Petkov authored
      
      
      We use sync_core() in the alternatives code to stop speculative
      execution of prefetched instructions because we are potentially changing
      them and don't want to execute stale bytes.
      
      What it does on most machines is call CPUID which is a serializing
      instruction. And that's expensive.
      
      However, the instruction cache is serialized when we're on the local CPU
      and are changing the data through the same virtual address. So then, we
      don't need the serializing CPUID but a simple control flow change. Last
      being accomplished with a CALL/RET which the noinline causes.
      
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Reviewed-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Matthew Whitehead <tedheadster@gmail.com>
      Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20161203150258.vwr5zzco7ctgc4pe@pd.tnic
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      34bfab0e
    • Borislav Petkov's avatar
      x86/topology: Document cpu_llc_id · a268b5f1
      Borislav Petkov authored
      
      
      It means different things on Intel and AMD so write it down so that
      there's no confusion.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Yazen Ghannam <yazen.ghannam@amd.com>
      Link: http://lkml.kernel.org/r/20161117094557.jm6hwzdd52h7iwnj@pd.tnic
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      a268b5f1
    • Vitaly Kuznetsov's avatar
      x86/hyperv: Handle unknown NMIs on one CPU when unknown_nmi_panic · 59107e2f
      Vitaly Kuznetsov authored
      
      
      There is a feature in Hyper-V ('Debug-VM --InjectNonMaskableInterrupt')
      which injects NMI to the guest. We may want to crash the guest and do kdump
      on this NMI by enabling unknown_nmi_panic. To make kdump succeed we need to
      allow the kdump kernel to re-establish VMBus connection so it will see
      VMBus devices (storage, network,..).
      
      To properly unload VMBus making it possible to start over during kdump we
      need to do the following:
      
       - Send an 'unload' message to the hypervisor. This can be done on any CPU
         so we do this the crashing CPU.
      
       - Receive the 'unload finished' reply message. WS2012R2 delivers this
         message to the CPU which was used to establish VMBus connection during
         module load and this CPU may differ from the CPU sending 'unload'.
      
      Receiving a VMBus message means the following:
      
       - There is a per-CPU slot in memory for one message. This slot can in
         theory be accessed by any CPU.
      
       - We get an interrupt on the CPU when a message was placed into the slot.
      
       - When we read the message we need to clear the slot and signal the fact
         to the hypervisor. In case there are more messages to this CPU pending
         the hypervisor will deliver the next message. The signaling is done by
         writing to an MSR so this can only be done on the appropriate CPU.
      
      To avoid doing cross-CPU work on crash we have vmbus_wait_for_unload()
      function which checks message slots for all CPUs in a loop waiting for the
      'unload finished' messages. However, there is an issue which arises when
      these conditions are met:
      
       - We're crashing on a CPU which is different from the one which was used
         to initially contact the hypervisor.
      
       - The CPU which was used for the initial contact is blocked with interrupts
         disabled and there is a message pending in the message slot.
      
      In this case we won't be able to read the 'unload finished' message on the
      crashing CPU. This is reproducible when we receive unknown NMIs on all CPUs
      simultaneously: the first CPU entering panic() will proceed to crash and
      all other CPUs will stop themselves with interrupts disabled.
      
      The suggested solution is to handle unknown NMIs for Hyper-V guests on the
      first CPU which gets them only. This will allow us to rely on VMBus
      interrupt handler being able to receive the 'unload finish' message in
      case it is delivered to a different CPU.
      
      The issue is not reproducible on WS2016 as Debug-VM delivers NMI to the
      boot CPU only, WS2012R2 and earlier Hyper-V versions are affected.
      
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Cc: devel@linuxdriverproject.org
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Link: http://lkml.kernel.org/r/20161202100720.28121-1-vkuznets@redhat.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      59107e2f
  5. Dec 19, 2016
    • Andy Lutomirski's avatar
      x86/asm: Rewrite sync_core() to use IRET-to-self · c198b121
      Andy Lutomirski authored
      
      
      Aside from being excessively slow, CPUID is problematic: Linux runs
      on a handful of CPUs that don't have CPUID.  Use IRET-to-self
      instead.  IRET-to-self works everywhere, so it makes testing easy.
      
      For reference, On my laptop, IRET-to-self is ~110ns,
      CPUID(eax=1, ecx=0) is ~83ns on native and very very slow under KVM,
      and MOV-to-CR2 is ~42ns.
      
      While we're at it: sync_core() serves a very specific purpose.
      Document it.
      
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Matthew Whitehead <tedheadster@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: xen-devel <Xen-devel@lists.xen.org>
      Link: http://lkml.kernel.org/r/5c79f0225f68bc8c40335612bf624511abb78941.1481307769.git.luto@kernel.org
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      c198b121
    • Andy Lutomirski's avatar
      x86/microcode/intel: Replace sync_core() with native_cpuid() · 484d0e5c
      Andy Lutomirski authored
      
      
      The Intel microcode driver is using sync_core() to mean "do CPUID
      with EAX=1".  I want to rework sync_core(), but first the Intel
      microcode driver needs to stop depending on its current behavior.
      
      Reported-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Acked-by: default avatarBorislav Petkov <bp@alien8.de>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Matthew Whitehead <tedheadster@gmail.com>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: xen-devel <Xen-devel@lists.xen.org>
      Link: http://lkml.kernel.org/r/535a025bb91fed1a019c5412b036337ad239e5bb.1481307769.git.luto@kernel.org
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      484d0e5c
    • Andy Lutomirski's avatar
      Revert "x86/boot: Fail the boot if !M486 and CPUID is missing" · 426d1aff
      Andy Lutomirski authored
      This reverts commit ed68d7e9
      
      .
      
      The patch wasn't quite correct -- there are non-Intel (and hence
      non-486) CPUs that we support that don't have CPUID.  Since we no
      longer require CPUID for sync_core(), just revert the patch.
      
      I think the relevant CPUs are Geode and Elan, but I'm not sure.
      
      In principle, we should try to do better at identifying CPUID-less
      CPUs in early boot, but that's more complicated.
      
      Reported-by: default avatarOne Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Matthew Whitehead <tedheadster@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: xen-devel <Xen-devel@lists.xen.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Link: http://lkml.kernel.org/r/82acde18a108b8e353180dd6febcc2876df33f24.1481307769.git.luto@kernel.org
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      426d1aff
    • Andy Lutomirski's avatar
      x86/asm/32: Make sync_core() handle missing CPUID on all 32-bit kernels · 1c52d859
      Andy Lutomirski authored
      
      
      We support various non-Intel CPUs that don't have the CPUID
      instruction, so the M486 test was wrong.  For now, fix it with a big
      hammer: handle missing CPUID on all 32-bit CPUs.
      
      Reported-by: default avatarOne Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Matthew Whitehead <tedheadster@gmail.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Andrew Cooper <andrew.cooper3@citrix.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: xen-devel <Xen-devel@lists.xen.org>
      Link: http://lkml.kernel.org/r/685bd083a7c036f7769510b6846315b17d6ba71f.1481307769.git.luto@kernel.org
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      1c52d859
    • Andy Lutomirski's avatar
      x86/cpu: Probe CPUID leaf 6 even when cpuid_level == 6 · 3df8d920
      Andy Lutomirski authored
      A typo (or mis-merge?) resulted in leaf 6 only being probed if
      cpuid_level >= 7.
      
      Fixes: 2ccd71f1
      
       ("x86/cpufeature: Move some of the scattered feature bits to x86_capability")
      Signed-off-by: default avatarAndy Lutomirski <luto@kernel.org>
      Acked-by: default avatarBorislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Link: http://lkml.kernel.org/r/6ea30c0e9daec21e488b54761881a6dfcf3e04d0.1481825597.git.luto@kernel.org
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      3df8d920
    • Markus Trippelsdorf's avatar
      x86/tools: Fix gcc-7 warning in relocs.c · 7ebb9167
      Markus Trippelsdorf authored
      
      
      gcc-7 warns:
      
      In file included from arch/x86/tools/relocs_64.c:17:0:
      arch/x86/tools/relocs.c: In function ‘process_64’:
      arch/x86/tools/relocs.c:953:2: warning: argument 1 null where non-null expected [-Wnonnull]
        qsort(r->offset, r->count, sizeof(r->offset[0]), cmp_relocs);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      In file included from arch/x86/tools/relocs.h:6:0,
                       from arch/x86/tools/relocs_64.c:1:
      /usr/include/stdlib.h:741:13: note: in a call to function ‘qsort’ declared here         
       extern void qsort 
      
      This happens because relocs16 is not used for ELF_BITS == 64, 
      so there is no point in trying to sort it.
      
      Make the sort_relocs(&relocs16) call 32bit only.
      
      Signed-off-by: default avatarMarkus Trippelsdorf <markus@trippelsdorf.de>
      Link: http://lkml.kernel.org/r/20161215124513.GA289@x4
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      7ebb9167
    • Josh Poimboeuf's avatar
      x86/unwind: Dump stack data on warnings · 8b5e99f0
      Josh Poimboeuf authored
      
      
      The unwinder warnings are good at finding unexpected unwinder issues,
      but they often don't give enough data to be able to fully diagnose them.
      Print a one-time stack dump when a warning is detected.
      
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Link: http://lkml.kernel.org/r/15607370e3ddb1732b6a73d5c65937864df16ac8.1481904011.git.jpoimboe@redhat.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      8b5e99f0
    • Josh Poimboeuf's avatar
      x86/unwind: Adjust last frame check for aligned function stacks · 8023e0e2
      Josh Poimboeuf authored
      Somehow, CONFIG_PARAVIRT=n convinces gcc to change the
      x86_64_start_kernel() prologue from:
      
        0000000000000129 <x86_64_start_kernel>:
         129:	55                   	push   %rbp
         12a:	48 89 e5             	mov    %rsp,%rbp
      
      to:
      
        0000000000000124 <x86_64_start_kernel>:
         124:	4c 8d 54 24 08       	lea    0x8(%rsp),%r10
         129:	48 83 e4 f0          	and    $0xfffffffffffffff0,%rsp
         12d:	41 ff 72 f8          	pushq  -0x8(%r10)
         131:	55                   	push   %rbp
         132:	48 89 e5             	mov    %rsp,%rbp
      
      This is an unusual pattern which aligns rsp (though in this case it's
      already aligned) and saves the start_cpu() return address again on the
      stack before storing the frame pointer.
      
      The unwinder assumes the last stack frame header is at a certain offset,
      but the above code breaks that assumption, resulting in the following
      warning:
      
        WARNING: kernel stack frame pointer at ffffffff82e03f40 in swapper:0 has bad value           (null)
      
      Fix it by checking for the last task stack frame at the aligned offset
      in addition to the normal unaligned offset.
      
      Fixes: acb4608a
      
       ("x86/unwind: Create stack frames for saved syscall registers")
      Reported-by: default avatarBorislav Petkov <bp@alien8.de>
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Link: http://lkml.kernel.org/r/9d7b4eb8cf55a7d6002cb738f25c23e7429c99a0.1481904011.git.jpoimboe@redhat.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      8023e0e2
    • Dmitry Torokhov's avatar
      x86/init: Fix a couple of comment typos · 22d3c0d6
      Dmitry Torokhov authored
      
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Acked-by: default avatarMarcos Paulo de Souza <marcos.souza.org@gmail.com>
      Cc: linux-input@vger.kernel.org
      Link: http://lkml.kernel.org/r/1481317061-31486-5-git-send-email-dmitry.torokhov@gmail.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      22d3c0d6
    • Dmitry Torokhov's avatar
      x86/init: Remove i8042_detect() from platform ops · 32786fdc
      Dmitry Torokhov authored
      
      
      Now that i8042 uses flag in legacy platform data, i8042_detect() is
      no longer used and can be removed.
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarMarcos Paulo de Souza <marcos.souza.org@gmail.com>
      Cc: linux-input@vger.kernel.org
      Link: http://lkml.kernel.org/r/1481317061-31486-4-git-send-email-dmitry.torokhov@gmail.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      32786fdc
    • Dmitry Torokhov's avatar
      Input: i8042 - Trust firmware a bit more when probing on X86 · d79e141c
      Dmitry Torokhov authored
      
      
      The error message "Can't read CTR while initializing i8042" appears on
      Cherry Trail-based devices at each boot time:
      
        i8042: PNP: No PS/2 controller found. Probing ports directly.
        i8042: Can't read CTR while initializing i8042
        i8042: probe of i8042 failed with error -5
      
      This happens because we historically do not trust firmware on X86 and,
      while noting that PNP does not show keyboard or mouse devices, we still
      charge ahead and try to probe the controller. Let's relax this a bit and if
      results of PNP probe agree with the results of platform
      initialization/quirks conclude that there is, in fact, no i8042.
      
      While at it, let's avoid using x86_platform.i8042_detect() and instead
      abort execution early if platform indicates that it can not possibly have
      i8042 (x86_platform.legacy.i8042 equals X86_LEGACY_I8042_PLATFORM_ABSENT).
      
      Reported-and-tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Acked-by: default avatarMarcos Paulo de Souza <marcos.souza.org@gmail.com>
      Cc: linux-input@vger.kernel.org
      Link: http://lkml.kernel.org/r/1481317061-31486-3-git-send-email-dmitry.torokhov@gmail.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      d79e141c
    • Dmitry Torokhov's avatar
      x86/init: Add i8042 state to the platform data · 93ffa9a4
      Dmitry Torokhov authored
      
      
      Add i8042 state to the platform data to help i8042 driver make decision
      whether to probe for i8042 or not. We recognize 3 states: platform/subarch
      ca not possible have i8042 (as is the case with Inrel MID platform),
      firmware (such as ACPI) reports that i8042 is absent from the device,
      or i8042 may be present and the driver should probe for it.
      
      The intent is to allow i8042 driver abort initialization on x86 if PNP data
      (absence of both keyboard and mouse PNP devices) agrees with firmware data.
      
      It will also allow us to remove i8042_detect later.
      
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
      Acked-by: default avatarMarcos Paulo de Souza <marcos.souza.org@gmail.com>
      Cc: linux-input@vger.kernel.org
      Link: http://lkml.kernel.org/r/1481317061-31486-2-git-send-email-dmitry.torokhov@gmail.com
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      93ffa9a4
    • Boris Ostrovsky's avatar
      x86/microcode/AMD: Use native_cpuid() in load_ucode_amd_bsp() · 2b4c9156
      Boris Ostrovsky authored
      
      
      When CONFIG_PARAVIRT is selected, cpuid() becomes a call. Since
      for 32-bit kernels load_ucode_amd_bsp() is executed before paging
      is enabled the call cannot be completed (as kernel virtual addresses
      are not reachable yet).
      
      Use native_cpuid() instead which is an asm wrapper for the CPUID
      instruction.
      
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Jürgen Gross <jgross@suse.com>
      Link: http://lkml.kernel.org/r/1481906392-3847-1-git-send-email-boris.ostrovsky@oracle.com
      Link: http://lkml.kernel.org/r/20161218164414.9649-5-bp@alien8.de
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      2b4c9156
    • Borislav Petkov's avatar
      x86/microcode/AMD: Do not load when running on a hypervisor · a15a7535
      Borislav Petkov authored
      
      
      Doing so is completely void of sense for multiple reasons so prevent
      it. Set dis_ucode_ldr to true and thus disable the microcode loader by
      default to address xen pv guests which execute the AP path but not the
      BSP path.
      
      By having it turned off by default, the APs won't run into the loader
      either.
      
      Also, check CPUID(1).ECX[31] which hypervisors set. Well almost, not the
      xen pv one. That one gets the aforementioned "fix".
      
      Also, improve the detection method by caching the final decision whether
      to continue loading in dis_ucode_ldr and do it once on the BSP. The APs
      then simply test that value.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Tested-by: default avatarJuergen Gross <jgross@suse.com>
      Tested-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Acked-by: default avatarJuergen Gross <jgross@suse.com>
      Link: http://lkml.kernel.org/r/20161218164414.9649-4-bp@alien8.de
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      a15a7535
    • Borislav Petkov's avatar
      x86/microcode/AMD: Sanitize apply_microcode_early_amd() · 200d3553
      Borislav Petkov authored
      
      
      Make it simply return bool to denote whether it found a container or not
      and return the pointer to the container and its size in the handed-in
      container pointer instead, as returning a struct was just silly.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Jürgen Gross <jgross@suse.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Link: http://lkml.kernel.org/r/20161218164414.9649-3-bp@alien8.de
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      200d3553
    • Borislav Petkov's avatar
      x86/microcode/AMD: Make find_proper_container() sane again · 8feaa64a
      Borislav Petkov authored
      
      
      Fixup signature and retvals, return the container struct through the
      passed in pointer, not as a function return value.
      
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: Jürgen Gross <jgross@suse.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Link: http://lkml.kernel.org/r/20161218164414.9649-2-bp@alien8.de
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      8feaa64a
    • Linus Torvalds's avatar
      Merge tag 'rtc-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux · b0b3a37b
      Linus Torvalds authored
      Pull RTC updates from Alexandre Belloni:
        "Subsystem:
         - non-modular drivers are now explicitly non-modular
      
        New driver:
          - Epson Toyocom rtc-7301sf/dg
      
        Drivers:
         - cmos: reject unsupported alarm values wrt the RTC capabilities
         - ds1307: ACPI support
         - jz4740: DT support, jz4780 handling, can now be used as a system
           power controller
         - mcp795: many fixes, in particular proper month handling
         - twl: driver is now DT only"
      
      * tag 'rtc-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (31 commits)
        rtc: mcp795: Fix whitespace and indentation.
        rtc: mcp795: Prefer using the BIT() macro.
        rtc: mcp795: fix month write resetting date to 1.
        rtc: mcp795: fix time range difference between linux and RTC chip.
        rtc: mcp795: fix bitmask value for leap year (LP).
        rtc: mcp795: use bcd2bin/bin2bcd.
        rtc: add support for EPSON TOYOCOM RTC-7301SF/DG
        rtc: ds1307: Add ACPI support
        rtc: imxdi: (trivial) fix a typo
        rtc: ds1374: Merge conditional + WARN_ON()
        rtc: twl: make driver DT only
        rtc: twl: kill static variables
        rtc: fix typos in Kconfig
        rtc: jz4740: make the driver builtin only
        rtc: jz4740: remove unused EXPORT_SYMBOL
        Documentation: bindings: fix twl-rtc documentation
        rtc: Enable compile testing for Maxim and Samsung drivers
        MIPS: jz4740: Remove obsolete code
        MIPS: qi_lb60: Probe RTC driver from DT and use it as power controller
        MIPS: jz4740: DTS: Probe the jz4740-rtc driver from devicetree
        ...
      b0b3a37b
    • Emil Bartczak's avatar
      rtc: mcp795: Fix whitespace and indentation. · d3e59259
      Emil Bartczak authored
      
      
      Fix whitespace and indentation errors and the following
      checkpatch warnings:
      - line 15: Block comments use a trailing */ on a separate line
      - line 256: Line over 80 characters
      No code change.
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      d3e59259
    • Emil Bartczak's avatar
      rtc: mcp795: Prefer using the BIT() macro. · a2b42997
      Emil Bartczak authored
      
      
      This patch doesn't change the code but replaces all bitmask values
      with the BIT(x) macro.
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      a2b42997
    • Emil Bartczak's avatar
      rtc: mcp795: fix month write resetting date to 1. · 43d0b10f
      Emil Bartczak authored
      
      
      According to Microchip errata some combinations of date and month
      values may result in the date being reset to 1, even if the date
      is also written with the month (for example 31-07 or 31-08).
      As a workaround avoid writing date and month values within the same
      Write command. Instead, terminate the Write command after loading
      the date and begin a new command to write the month. In addition,
      disable the oscillator before loading the new values. This is done
      by ensuring both the ST and EXTOSC bits are cleared and waiting for
      the OSCON bit to clear.
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      43d0b10f
    • Emil Bartczak's avatar
      rtc: mcp795: fix time range difference between linux and RTC chip. · 26eeefd5
      Emil Bartczak authored
      
      
      In linux rtc_time struct, tm_mon range is 0~11, while in RTC HW REG,
      month range is 1~12. This patch adjusts difference of them.
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      26eeefd5
    • Emil Bartczak's avatar
      rtc: mcp795: fix bitmask value for leap year (LP). · e72765c6
      Emil Bartczak authored
      
      
      According the datasheet the leap year is a fifth bit in month register.
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      e72765c6
    • Emil Bartczak's avatar
      rtc: mcp795: use bcd2bin/bin2bcd. · bcf18d88
      Emil Bartczak authored
      
      
      Change rtc-mcp795.c to use the bcd2bin/bin2bcd functions.
      This change fixes the wrong conversion of month value
      from binary to BCD (missing right shift operation for 10 month).
      
      Signed-off-by: default avatarEmil Bartczak <emilbart@gmail.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      bcf18d88
    • Akinobu Mita's avatar
      rtc: add support for EPSON TOYOCOM RTC-7301SF/DG · 0b6a8f5c
      Akinobu Mita authored
      
      
      This adds support for EPSON TOYOCOM RTC-7301SF/DG which has parallel
      interface compatible with SRAM.
      
      This driver supports basic clock, calendar and alarm functionality.
      
      Tested with Microblaze linux running on Artix7 FPGA board with my own
      custom IP for RTC-7301.
      
      Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      0b6a8f5c
    • Tin Huynh's avatar
      rtc: ds1307: Add ACPI support · 9c19b893
      Tin Huynh authored
      
      
      This patch enables ACPI support for rtc-ds1307 driver.
      
      Signed-off-by: default avatarTin Huynh <tnhuynh@apm.com>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
      9c19b893
    • Linus Torvalds's avatar
      Merge tag 'libnvdimm-for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm · 3be134e5
      Linus Torvalds authored
      Pull libnvdimm updates from Dan Williams:
       "The libnvdimm pull request is relatively small this time around due to
        some development topics being deferred to 4.11.
      
        As for this pull request the bulk of it has been in -next for several
        releases leading to one late fix being added (commit 868f036f
        ("libnvdimm: fix mishandled nvdimm_clear_poison() return value")). It
        has received a build success notification from the 0day-kbuild robot
        and passes the latest libnvdimm unit tests.
      
        Summary:
      
         - Dynamic label support: To date namespace label support has been
           limited to disambiguating cases where PMEM (direct load/store) and
           BLK (mmio aperture) accessed-capacity alias on the same DIMM. Since
           4.9 added support for multiple namespaces per PMEM-region there is
           value to support namespace labels even in the non-aliasing case.
           The presence of a valid namespace index block force-enables label
           support when the kernel would otherwise rely on region boundaries,
           and permits the region to be sub-divided.
      
         - Handle media errors in namespace metadata: Complement the error
           handling for media errors in namespace data areas with support for
           clearing errors on writes, and downgrading potential machine-check
           exceptions to simple i/o errors on read.
      
         - Device-DAX region attributes: Add 'align', 'id', and 'size' as
           attributes for device-dax regions. In particular this enables
           userspace tooling to generically size memory mapping and i/o
           operations. Prevent userspace from growing assumptions /
           dependencies about the parent device topology for a dax region. A
           libnvdimm namespace may not always be the parent device of a dax
           region.
      
         - Various cleanups and small fixes"
      
      * tag 'libnvdimm-for-4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
        dax: add region 'id', 'size', and 'align' attributes
        libnvdimm: fix mishandled nvdimm_clear_poison() return value
        libnvdimm: replace mutex_is_locked() warnings with lockdep_assert_held
        libnvdimm, pfn: fix align attribute
        libnvdimm, e820: use module_platform_driver
        libnvdimm, namespace: use octal for permissions
        libnvdimm, namespace: avoid multiple sector calculations
        libnvdimm: remove else after return in nsio_rw_bytes()
        libnvdimm, namespace: fix the type of name variable
        libnvdimm: use consistent naming for request_mem_region()
        nvdimm: use the right length of "pmem"
        libnvdimm: check and clear poison before writing to pmem
        tools/testing/nvdimm: dynamic label support
        libnvdimm: allow a platform to force enable label support
        libnvdimm: use generic iostat interfaces
      3be134e5
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v4.10-2' of... · 8421c604
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v4.10-2' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86
      
      Pull more x86 platform driver updates from Darren Hart:
       "Move and add registration for the mlx-platform driver. Introduce
        button and lid drivers for the surface3 (different from the
        surface3-pro). Add BXT PMIC TMU support. Add Y700 to existing
        ideapad-laptop quirk.
      
        Summary:
      
        ideapad-laptop:
         - Add Y700 15-ACZ to no_hw_rfkill DMI list
      
        surface3_button:
         - Introduce button support for the Surface 3
      
        surface3-wmi:
         - Add custom surface3 platform device for controlling LID
         - Balance locking on error path
      
        mlx-platform:
         - Add mlxcpld-hotplug driver registration
         - Fix semicolon.cocci warnings
         - Move module from arch/x86
      
        platform/x86:
         - Add Whiskey Cove PMIC TMU support"
      
      * tag 'platform-drivers-x86-v4.10-2' of git://git.infradead.org/users/dvhart/linux-platform-drivers-x86:
        platform/x86: surface3-wmi: Balance locking on error path
        platform/x86: Add Whiskey Cove PMIC TMU support
        platform/x86: ideapad-laptop: Add Y700 15-ACZ to no_hw_rfkill DMI list
        platform/x86: Introduce button support for the Surface 3
        platform/x86: Add custom surface3 platform device for controlling LID
        platform/x86: mlx-platform: Add mlxcpld-hotplug driver registration
        platform/x86: mlx-platform: Fix semicolon.cocci warnings
        platform/x86: mlx-platform: Move module from arch/x86
      8421c604
    • Andy Shevchenko's avatar
      platform/x86: surface3-wmi: Balance locking on error path · 83da6b59
      Andy Shevchenko authored
      
      
      There is a possibility that lock will be left acquired.
      Consolidate error path under out_free_unlock label.
      
      Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
      Reviewed-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      83da6b59
    • Nilesh Bacchewar's avatar
      platform/x86: Add Whiskey Cove PMIC TMU support · 957ae509
      Nilesh Bacchewar authored
      
      
      This adds TMU (Time Management Unit) support for Intel BXT platform.
      It enables the alarm wake-up functionality in the TMU unit of Whiskey Cove
      PMIC.
      
      Signed-off-by: default avatarNilesh Bacchewar <nilesh.bacchewar@intel.com>
      Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      [andy: resolve merge conflict in Kconfig]
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      957ae509
    • Linus Torvalds's avatar
      Merge branch 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · f7dd3b17
      Linus Torvalds authored
      Pull timer updates from Thomas Gleixner:
       "This is the last functional update from the tip tree for 4.10. It got
        delayed due to a newly reported and anlyzed variant of BIOS bug and
        the resulting wreckage:
      
         - Seperation of TSC being marked realiable and the fact that the
           platform provides the TSC frequency via CPUID/MSRs and making use
           for it for GOLDMONT.
      
         - TSC adjust MSR validation and sanitizing:
      
           The TSC adjust MSR contains the offset to the hardware counter. The
           sum of the adjust MSR and the counter is the TSC value which is
           read via RDTSC.
      
           On at least two machines from different vendors the BIOS sets the
           TSC adjust MSR to negative values. This happens on cold and warm
           boot. While on cold boot the offset is a few milliseconds, on warm
           boot it basically compensates the power on time of the system. The
           BIOSes are not even using the adjust MSR to set all CPUs in the
           package to the same offset. The offsets are different which renders
           the TSC unusable,
      
           What's worse is that the TSC deadline timer has a HW feature^Wbug.
           It malfunctions when the TSC adjust value is negative or greater
           equal 0x80000000 resulting in silent boot failures, hard lockups or
           non firing timers. This looks like some hardware internal 32/64bit
           issue with a sign extension problem. Intel has been silent so far
           on the issue.
      
           The update contains sanity checks and keeps the adjust register
           within working limits and in sync on the package.
      
           As it looks like this disease is spreading via BIOS crapware, we
           need to address this urgently as the boot failures are hard to
           debug for users"
      
      * 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/tsc: Limit the adjust value further
        x86/tsc: Annotate printouts as firmware bug
        x86/tsc: Force TSC_ADJUST register to value >= zero
        x86/tsc: Validate TSC_ADJUST after resume
        x86/tsc: Validate cpumask pointer before accessing it
        x86/tsc: Fix broken CONFIG_X86_TSC=n build
        x86/tsc: Try to adjust TSC if sync test fails
        x86/tsc: Prepare warp test for TSC adjustment
        x86/tsc: Move sync cleanup to a safe place
        x86/tsc: Sync test only for the first cpu in a package
        x86/tsc: Verify TSC_ADJUST from idle
        x86/tsc: Store and check TSC ADJUST MSR
        x86/tsc: Detect random warps
        x86/tsc: Use X86_FEATURE_TSC_ADJUST in detect_art()
        x86/tsc: Finalize the split of the TSC_RELIABLE flag
        x86/tsc: Set TSC_KNOWN_FREQ and TSC_RELIABLE flags on Intel Atom SoCs
        x86/tsc: Mark Intel ATOM_GOLDMONT TSC reliable
        x86/tsc: Mark TSC frequency determined by CPUID as known
        x86/tsc: Add X86_FEATURE_TSC_KNOWN_FREQ flag
      f7dd3b17
    • Linus Torvalds's avatar
      Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 1bbb05f5
      Linus Torvalds authored
      Pull x86 fixes and cleanups from Thomas Gleixner:
       "This set of updates contains:
      
         - Robustification for the logical package managment. Cures the AMD
           and virtualization issues.
      
         - Put the correct start_cpu() return address on the stack of the idle
           task.
      
         - Fixups for the fallout of the nodeid <-> cpuid persistent mapping
           modifciations
      
         - Move the x86/MPX specific mm_struct member to the arch specific
           mm_context where it belongs
      
         - Cleanups for C89 struct initializers and useless function
           arguments"
      
      * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/floppy: Use designated initializers
        x86/mpx: Move bd_addr to mm_context_t
        x86/mm: Drop unused argument 'removed' from sync_global_pgds()
        ACPI/NUMA: Do not map pxm to node when NUMA is turned off
        x86/acpi: Use proper macro for invalid node
        x86/smpboot: Prevent false positive out of bounds cpumask access warning
        x86/boot/64: Push correct start_cpu() return address
        x86/boot/64: Use 'push' instead of 'call' in start_cpu()
        x86/smpboot: Make logical package management more robust
      1bbb05f5
    • Linus Torvalds's avatar
      Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 451bb1a6
      Linus Torvalds authored
      Pull timer fix from Thomas Gleixner:
       "Prevent NULL pointer dereferencing in the tick broadcast code. Old
        bug, which got unearthed by the hotplug ordering problem"
      
      * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        tick/broadcast: Prevent NULL pointer dereference
      451bb1a6