1. 01 2月, 2019 5 次提交
    • C
      x86/boot: Search for RSDP in memory · 93a209aa
      Chao Fan 提交于
      Scan memory (EBDA) for the RSDP and verify RSDP by signature and
      checksum.
      
       [ bp:
         - Trim commit message.
         - Simplify bios_get_rsdp_addr() and cleanup mad casting.
       ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-5-fanc.fnst@cn.fujitsu.com
      93a209aa
    • C
      x86/boot: Search for RSDP in the EFI tables · 33f0df8d
      Chao Fan 提交于
      The immovable memory ranges information in the SRAT table is necessary
      to fix the issue of KASLR not paying attention to movable memory regions
      when selecting the offset. Therefore, SRAT needs to be parsed.
      
      Depending on the boot: KEXEC/EFI/BIOS, the methods to compute RSDP are
      different. When booting from EFI, the EFI table points to the RSDP. So
      iterate over the EFI system tables in order to find the RSDP.
      
       [ bp:
         - Heavily massage commit message
         - Trim comments
         - Move the CONFIG_ACPI ifdeffery into the Makefile.
       ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-4-fanc.fnst@cn.fujitsu.com
      33f0df8d
    • C
      x86/boot: Add "acpi_rsdp=" early parsing · 3c98e71b
      Chao Fan 提交于
      KASLR may randomly choose offsets which are located in movable memory
      regions resulting in the movable memory becoming immovable.
      
      The ACPI SRAT (System/Static Resource Affinity Table) describes memory
      ranges including ranges of memory provided by hot-added memory devices.
      In order to access SRAT, one needs the Root System Description Pointer
      (RSDP) with which to find the Root/Extended System Description Table
      (R/XSDT) which then contains the system description tables of which SRAT
      is one of.
      
      In case the RSDP address has been passed on the command line (kexec-ing
      a second kernel) parse it from there.
      
       [ bp: Rewrite the commit message and cleanup the code. ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Tom Lendacky <thomas.lendacky@amd.com>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-3-fanc.fnst@cn.fujitsu.com
      3c98e71b
    • C
      x86/boot: Copy kstrtoull() to boot/string.c · de50ce20
      Chao Fan 提交于
      Copy kstrtoull() and the other necessary functions from lib/kstrtox.c
      to boot/string.c so that code in boot/ can use kstrtoull() and the old
      simple_strtoull() can gradually be phased out.
      
      Using div_u64() from math64.h directly will cause the dividend to be
      handled as a 64-bit value and cause the infamous __divdi3 linker error
      due to gcc trying to use its library function for the 64-bit division.
      
      Therefore, separate the dividend into an upper and lower part.
      
       [ bp: Rewrite commit message. ]
      Signed-off-by: NChao Fan <fanc.fnst@cn.fujitsu.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: caoj.fnst@cn.fujitsu.com
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: indou.takao@jp.fujitsu.com
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: kasong@redhat.com
      Cc: Kees Cook <keescook@chromium.org>
      Cc: msys.mizuma@gmail.com
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86-ml <x86@kernel.org>
      Link: https://lkml.kernel.org/r/20190123110850.12433-2-fanc.fnst@cn.fujitsu.com
      de50ce20
    • B
      x86/boot: Build the command line parsing code unconditionally · ac09c5f4
      Borislav Petkov 提交于
      Just drop the three-item ifdeffery and build it in unconditionally.
      Early cmdline parsing is needed more often than not.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: bhe@redhat.com
      Cc: hpa@zytor.com
      Cc: indou.takao@jp.fujitsu.com
      Cc: kasong@redhat.com
      Cc: keescook@chromium.org
      Cc: mingo@redhat.com
      Cc: msys.mizuma@gmail.com
      Cc: tglx@linutronix.de
      Cc: x86@kernel.org
      Link: https://lkml.kernel.org/r/20190130112238.GB18383@zn.tnic
      ac09c5f4
  2. 26 1月, 2019 16 次提交
  3. 24 1月, 2019 1 次提交
  4. 23 1月, 2019 1 次提交
  5. 20 1月, 2019 2 次提交
  6. 18 1月, 2019 15 次提交
    • E
      ARCv2: lib: memeset: fix doing prefetchw outside of buffer · e6a72b7d
      Eugeniy Paltsev 提交于
      ARCv2 optimized memset uses PREFETCHW instruction for prefetching the
      next cache line but doesn't ensure that the line is not past the end of
      the buffer. PRETECHW changes the line ownership and marks it dirty,
      which can cause issues in SMP config when next line was already owned by
      other core. Fix the issue by avoiding the PREFETCHW
      
      Some more details:
      
      The current code has 3 logical loops (ignroing the unaligned part)
        (a) Big loop for doing aligned 64 bytes per iteration with PREALLOC
        (b) Loop for 32 x 2 bytes with PREFETCHW
        (c) any left over bytes
      
      loop (a) was already eliding the last 64 bytes, so PREALLOC was
      safe. The fix was removing PREFETCW from (b).
      
      Another potential issue (applicable to configs with 32 or 128 byte L1
      cache line) is that PREALLOC assumes 64 byte cache line and may not do
      the right thing specially for 32b. While it would be easy to adapt,
      there are no known configs with those lie sizes, so for now, just
      compile out PREALLOC in such cases.
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Cc: stable@vger.kernel.org #4.4+
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      [vgupta: rewrote changelog, used asm .macro vs. "C" macro]
      e6a72b7d
    • V
      ARC: mm: do_page_fault fixes #1: relinquish mmap_sem if signal arrives while handle_mm_fault · 4d447455
      Vineet Gupta 提交于
      do_page_fault() forgot to relinquish mmap_sem if a signal came while
      handling handle_mm_fault() - due to say a ctl+c or oom etc.
      This would later cause a deadlock by acquiring it twice.
      
      This came to light when running libc testsuite tst-tls3-malloc test but
      is likely also the cause for prior seen LTP failures. Using lockdep
      clearly showed what the issue was.
      
      | # while true; do ./tst-tls3-malloc ; done
      | Didn't expect signal from child: got `Segmentation fault'
      | ^C
      | ============================================
      | WARNING: possible recursive locking detected
      | 4.17.0+ #25 Not tainted
      | --------------------------------------------
      | tst-tls3-malloc/510 is trying to acquire lock:
      | 606c7728 (&mm->mmap_sem){++++}, at: __might_fault+0x28/0x5c
      |
      |but task is already holding lock:
      |606c7728 (&mm->mmap_sem){++++}, at: do_page_fault+0x9c/0x2a0
      |
      | other info that might help us debug this:
      |  Possible unsafe locking scenario:
      |
      |       CPU0
      |       ----
      |  lock(&mm->mmap_sem);
      |  lock(&mm->mmap_sem);
      |
      | *** DEADLOCK ***
      |
      
      ------------------------------------------------------------
      What the change does is not obvious (note to myself)
      
      prior code was
      
      | do_page_fault
      |
      |   down_read()		<-- lock taken
      |   handle_mm_fault	<-- signal pending as this runs
      |   if fatal_signal_pending
      |       if VM_FAULT_ERROR
      |           up_read
      |       if user_mode
      |          return	<-- lock still held, this was the BUG
      
      New code
      
      | do_page_fault
      |
      |   down_read()		<-- lock taken
      |   handle_mm_fault	<-- signal pending as this runs
      |   if fatal_signal_pending
      |       if VM_FAULT_RETRY
      |          return       <-- not same case as above, but still OK since
      |                           core mm already relinq lock for FAULT_RETRY
      |    ...
      |
      |   < Now falls through for bug case above >
      |
      |   up_read()		<-- lock relinquished
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      4d447455
    • J
      x86/entry/64/compat: Fix stack switching for XEN PV · fc24d75a
      Jan Beulich 提交于
      While in the native case entry into the kernel happens on the trampoline
      stack, PV Xen kernels get entered with the current thread stack right
      away. Hence source and destination stacks are identical in that case,
      and special care is needed.
      
      Other than in sync_regs() the copying done on the INT80 path isn't
      NMI / #MC safe, as either of these events occurring in the middle of the
      stack copying would clobber data on the (source) stack.
      
      There is similar code in interrupt_entry() and nmi(), but there is no fixup
      required because those code paths are unreachable in XEN PV guests.
      
      [ tglx: Sanitized subject, changelog, Fixes tag and stable mail address. Sigh ]
      
      Fixes: 7f2590a1 ("x86/entry/64: Use a per-CPU trampoline stack for IDT entries")
      Signed-off-by: NJan Beulich <jbeulich@suse.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NJuergen Gross <jgross@suse.com>
      Acked-by: NAndy Lutomirski <luto@kernel.org>
      Cc: Peter Anvin <hpa@zytor.com>
      Cc: xen-devel@lists.xenproject.org>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/5C3E1128020000780020DFAD@prv1-mh.provo.novell.com
      fc24d75a
    • V
      ARC: show_regs: lockdep: re-enable preemption · f731a8e8
      Vineet Gupta 提交于
      signal handling core calls show_regs() with preemption disabled which
      on ARC takes mmap_sem for mm/vma access, causing lockdep splat.
      
      | [ARCLinux]# ./segv-null-ptr
      | potentially unexpected fatal signal 11.
      | BUG: sleeping function called from invalid context at kernel/fork.c:1011
      | in_atomic(): 1, irqs_disabled(): 0, pid: 70, name: segv-null-ptr
      | no locks held by segv-null-ptr/70.
      | CPU: 0 PID: 70 Comm: segv-null-ptr Not tainted 4.18.0+ #69
      |
      | Stack Trace:
      |  arc_unwind_core+0xcc/0x100
      |  ___might_sleep+0x17a/0x190
      |  mmput+0x16/0xb8
      |  show_regs+0x52/0x310
      |  get_signal+0x5ee/0x610
      |  do_signal+0x2c/0x218
      |  resume_user_mode_begin+0x90/0xd8
      
      Workaround by re-enabling preemption temporarily.
      
      Note that the preemption disabling in core code around show_regs()
      was introduced by commit 3a9f84d3 ("signals, debug: fix BUG: using
      smp_processor_id() in preemptible code in print_fatal_signal()")
      
      to silence a differnt lockdep seen on x86 bakc in 2009.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      f731a8e8
    • V
      ARC: show_regs: lockdep: avoid page allocator... · ab6c0367
      Vineet Gupta 提交于
      and use smaller/on-stack buffer instead
      
      The motivation for this change was lockdep splat like below.
      
      | potentially unexpected fatal signal 11.
      | BUG: sleeping function called from invalid context at ../mm/page_alloc.c:4317
      | in_atomic(): 1, irqs_disabled(): 0, pid: 57, name: segv
      | no locks held by segv/57.
      | Preemption disabled at:
      | [<8182f17e>] get_signal+0x4a6/0x7c4
      | CPU: 0 PID: 57 Comm: segv Not tainted 4.17.0+ #23
      |
      | Stack Trace:
      |  arc_unwind_core.constprop.1+0xd0/0xf4
      |  __might_sleep+0x1f6/0x234
      |  __get_free_pages+0x174/0xca0
      |  show_regs+0x22/0x330
      |  get_signal+0x4ac/0x7c4     # print_fatal_signals() -> preempt_disable()
      |  do_signal+0x30/0x224
      |  resume_user_mode_begin+0x90/0xd8
      
      So signal handling core calls show_regs() with preemption disabled but
      an ensuing GFP_KERNEL page allocator call is flagged by lockdep.
      
      We could have switched to GFP_NOWAIT, but turns out that is not enough
      anways and eliding page allocator call leads to less code and
      instruction traces to sift thru when debugging pesky crashes.
      
      FWIW, this patch doesn't cure the lockdep splat (which next patch does).
      Reviewed-by: NWilliam Kucharski <william.kucharski@oracle.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      ab6c0367
    • E
      ARC: perf: avoid kernel killing where it is possible · 29133260
      Eugeniy Paltsev 提交于
      No, not gonna die tonight.
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      29133260
    • E
      ARC: perf: move HW events mapping to separate function · baf9cc85
      Eugeniy Paltsev 提交于
      Move HW events mapping to separate function to make code more readable.
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      baf9cc85
    • E
      ARC: perf: introduce Kernel PMU events support · 0e956150
      Eugeniy Paltsev 提交于
      Export all available ARC architected hardware events as
      kernel PMU events to make non-generic events accessible.
      
      ARC PMU HW allow us to read the list of all available
      events names. So we generate kernel PMU event list
      dynamically in arc_pmu_device_probe() using
      human-readable events names we got from HW instead of
      using pre-defined events list.
      
      -------------------------->8--------------------------
      $ perf list
        [snip]
        arc_pmu/bdata64/                  [Kernel PMU event]
        arc_pmu/bdcstall/                 [Kernel PMU event]
        arc_pmu/bdslot/                   [Kernel PMU event]
        arc_pmu/bfbmp/                    [Kernel PMU event]
        arc_pmu/bfirqex/                  [Kernel PMU event]
        arc_pmu/bflgstal/                 [Kernel PMU event]
        arc_pmu/bflush/                   [Kernel PMU event]
      -------------------------->8--------------------------
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      0e956150
    • E
      ARC: perf: trivial code cleanup · 14f81a91
      Eugeniy Paltsev 提交于
      * Use BIT(), lower_32_bits(), upper_32_bits() macroses,
        fix code style violations.
      * Use u32, u64, s64 instead of uint32_t, uint64_t, int64_t
      * Fix description comment as this code doesn't belong only to
        ARC700 anymore.
      * Use SPDX License Identifier.
      * Remove useless ifdefs. ifdef around 'arc_pmu_match' structure
        declaration is useless as we refer to 'arc_pmu_match' in
        several places which aren't guarded with ifdef. Nevertheless
        'ARC' option selects 'OF' unconditionally so we can simply
        get rid of this ifdef.
      Acked-by: NVineet Gupta <vgupta@synopsys.com>
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      14f81a91
    • E
      ARC: perf: map generic branches to correct hardware condition · 3affbf0e
      Eugeniy Paltsev 提交于
      So far we've mapped branches to "ijmp" which also counts conditional
      branches NOT taken. This makes us different from other architectures
      such as ARM which seem to be counting only taken branches.
      
      So use "ijmptak" hardware condition which only counts (all jump
      instructions that are taken)
      
      'ijmptak' event is available on both ARCompact and ARCv2 ISA based
      cores.
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      [vgupta: reworked changelog]
      3affbf0e
    • E
      ARC: adjust memblock_reserve of kernel memory · a3010a04
      Eugeniy Paltsev 提交于
      In setup_arch_memory we reserve the memory area wherein the kernel
      is located. Current implementation may reserve more memory than
      it actually required in case of CONFIG_LINUX_LINK_BASE is not
      equal to CONFIG_LINUX_RAM_BASE. This happens because we calculate
      start of the reserved region relatively to the CONFIG_LINUX_RAM_BASE
      and end of the region relatively to the CONFIG_LINUX_RAM_BASE.
      
      For example in case of HSDK board we wasted 256MiB of physical memory:
      ------------------->8------------------------------
      Memory: 770416K/1048576K available (5496K kernel code,
          240K rwdata, 1064K rodata, 2200K init, 275K bss,
          278160K reserved, 0K cma-reserved)
      ------------------->8------------------------------
      
      Fix that.
      
      Fixes: 9ed68785 ("ARC: mm: Decouple RAM base address from kernel link addr")
      Cc: stable@vger.kernel.org	#4.14+
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      a3010a04
    • M
      arc: remove redundant kernel-space generic-y · 76e60867
      Masahiro Yamada 提交于
      This commit removes redundant generic-y defines in
      arch/arc/include/asm/Kbuild.
      
      It is redundant to define generic-y when arch-specific implementation
      exists in arch/$(ARCH)/include/asm/*.h
      
      Remove the following generic-y:
      
          dma-mapping.h
          fb.h
          kmap_types.h
          pci.h
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      76e60867
    • E
      ARC: fix __ffs return value to avoid build warnings · 4e868f84
      Eugeniy Paltsev 提交于
      |  CC      mm/nobootmem.o
      |In file included from ./include/asm-generic/bug.h:18:0,
      |                 from ./arch/arc/include/asm/bug.h:32,
      |                 from ./include/linux/bug.h:5,
      |                 from ./include/linux/mmdebug.h:5,
      |                 from ./include/linux/gfp.h:5,
      |                 from ./include/linux/slab.h:15,
      |                 from mm/nobootmem.c:14:
      |mm/nobootmem.c: In function '__free_pages_memory':
      |./include/linux/kernel.h:845:29: warning: comparison of distinct pointer types lacks a cast
      |   (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
      |                             ^
      |./include/linux/kernel.h:859:4: note: in expansion of macro '__typecheck'
      |   (__typecheck(x, y) && __no_side_effects(x, y))
      |    ^~~~~~~~~~~
      |./include/linux/kernel.h:869:24: note: in expansion of macro '__safe_cmp'
      |  __builtin_choose_expr(__safe_cmp(x, y), \
      |                        ^~~~~~~~~~
      |./include/linux/kernel.h:878:19: note: in expansion of macro '__careful_cmp'
      | #define min(x, y) __careful_cmp(x, y, <)
      |                   ^~~~~~~~~~~~~
      |mm/nobootmem.c:104:11: note: in expansion of macro 'min'
      |   order = min(MAX_ORDER - 1UL, __ffs(start));
      
      Change __ffs return value from 'int' to 'unsigned long' as it
      is done in other implementations (like asm-generic, x86, etc...)
      to avoid build-time warnings in places where type is strictly
      checked.
      
      As __ffs may return values in [0-31] interval changing return
      type to unsigned is valid.
      Signed-off-by: NEugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      4e868f84
    • V
      ARC: boot log: print Action point details · 7dd380c3
      Vineet Gupta 提交于
      This now prints the number of action points {2,4,8} and {min,full}
      targets supported.
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      7dd380c3
    • V
      ARCv2: boot log: BPU return stack depth · 97e98132
      Vineet Gupta 提交于
      Signed-off-by: NVineet Gupta <vgupta@synopsys.com>
      97e98132