Merge tag 'loongarch-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 19 Dec 2022 14:23:27 +0000 (08:23 -0600)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 19 Dec 2022 14:23:27 +0000 (08:23 -0600)
Pull LoongArch updates from Huacai Chen:

 - Switch to relative exception tables

 - Add unaligned access support

 - Add alternative runtime patching mechanism

 - Add FDT booting support from efi system table

 - Add suspend/hibernation (ACPI S3/S4) support

 - Add basic STACKPROTECTOR support

 - Add ftrace (function tracer) support

 - Update the default config file

* tag 'loongarch-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: (24 commits)
  LoongArch: Update Loongson-3 default config file
  LoongArch: modules/ftrace: Initialize PLT at load time
  LoongArch/ftrace: Add HAVE_FUNCTION_GRAPH_RET_ADDR_PTR support
  LoongArch/ftrace: Add HAVE_DYNAMIC_FTRACE_WITH_ARGS support
  LoongArch/ftrace: Add HAVE_DYNAMIC_FTRACE_WITH_REGS support
  LoongArch/ftrace: Add dynamic function graph tracer support
  LoongArch/ftrace: Add dynamic function tracer support
  LoongArch/ftrace: Add recordmcount support
  LoongArch/ftrace: Add basic support
  LoongArch: module: Use got/plt section indices for relocations
  LoongArch: Add basic STACKPROTECTOR support
  LoongArch: Add hibernation (ACPI S4) support
  LoongArch: Add suspend (ACPI S3) support
  LoongArch: Add processing ISA Node in DeviceTree
  LoongArch: Add FDT booting support from efi system table
  LoongArch: Use alternative to optimize libraries
  LoongArch: Add alternative runtime patching mechanism
  LoongArch: Add unaligned access support
  LoongArch: BPF: Add BPF exception tables
  LoongArch: Remove the .fixup section usage
  ...

1  2 
Documentation/admin-guide/sysctl/kernel.rst
arch/loongarch/Kconfig
arch/loongarch/include/asm/efi.h
arch/loongarch/kernel/efi.c
arch/loongarch/kernel/numa.c
arch/loongarch/kernel/process.c

index 659d7bc47d7b2acdb6c47fa8cd234a3836a2446b,f2b802cd6208bf1c6367a7288b7df52eb39b17dd..46e3d62c0eea84d1c6c382800d092e561672823b
@@@ -139,8 -139,6 +139,8 @@@ Highest valid capability of the runnin
  ``CAP_LAST_CAP`` from the kernel.
  
  
 +.. _core_pattern:
 +
  core_pattern
  ============
  
        %f              executable filename
        %E              executable path
        %c              maximum size of core file by resource limit RLIMIT_CORE
 +      %C              CPU the task ran on
        %<OTHER>        both are dropped
        ========        ==========================================
  
@@@ -436,8 -433,8 +436,8 @@@ ignore-unaligned-usertra
  
  On architectures where unaligned accesses cause traps, and where this
  feature is supported (``CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN``;
- currently, ``arc`` and ``ia64``), controls whether all unaligned traps
- are logged.
+ currently, ``arc``, ``ia64`` and ``loongarch``), controls whether all
unaligned traps are logged.
  
  = =============================================================
  0 Log all unaligned accesses.
@@@ -670,15 -667,6 +670,15 @@@ This is the default behavior
  an oops event is detected.
  
  
 +oops_limit
 +==========
 +
 +Number of kernel oopses after which the kernel should panic when
 +``panic_on_oops`` is not set. Setting this to 0 disables checking
 +the count. Setting this to  1 has the same effect as setting
 +``panic_on_oops=1``. The default value is 10000.
 +
 +
  osrelease, ostype & version
  ===========================
  
@@@ -1326,29 -1314,6 +1326,29 @@@ watchdog work to be queued by the watch
  watchdog — if enabled — can detect a hard lockup condition.
  
  
 +split_lock_mitigate (x86 only)
 +==============================
 +
 +On x86, each "split lock" imposes a system-wide performance penalty. On larger
 +systems, large numbers of split locks from unprivileged users can result in
 +denials of service to well-behaved and potentially more important users.
 +
 +The kernel mitigates these bad users by detecting split locks and imposing
 +penalties: forcing them to wait and only allowing one core to execute split
 +locks at a time.
 +
 +These mitigations can make those bad applications unbearably slow. Setting
 +split_lock_mitigate=0 may restore some application performance, but will also
 +increase system exposure to denial of service attacks from split lock users.
 +
 += ===================================================================
 +0 Disable the mitigation mode - just warns the split lock on kernel log
 +  and exposes the system to denials of service from the split lockers.
 +1 Enable the mitigation mode (this is the default) - penalizes the split
 +  lockers with intentional performance degradation.
 += ===================================================================
 +
 +
  stack_erasing
  =============
  
@@@ -1492,8 -1457,8 +1492,8 @@@ unaligned-tra
  
  On architectures where unaligned accesses cause traps, and where this
  feature is supported (``CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW``; currently,
- ``arc`` and ``parisc``), controls whether unaligned traps are caught
- and emulated (instead of failing).
+ ``arc``, ``parisc`` and ``loongarch``), controls whether unaligned traps
+ are caught and emulated (instead of failing).
  
  = ========================================================
  0 Do not emulate unaligned accesses.
@@@ -1535,16 -1500,6 +1535,16 @@@ entry will default to 2 instead of 0
  2 Unprivileged calls to ``bpf()`` are disabled
  = =============================================================
  
 +
 +warn_limit
 +==========
 +
 +Number of kernel warnings after which the kernel should panic when
 +``panic_on_warn`` is not set. Setting this to 0 disables checking
 +the warning count. Setting this to 1 has the same effect as setting
 +``panic_on_warn=1``. The default value is 0.
 +
 +
  watchdog
  ========
  
diff --combined arch/loongarch/Kconfig
index a508813d5ea299382fc723698d8c661439d1f515,a36bb0fe197759e261517b848370dea5a1766d46..9cc8b84f7eb03d856900f2fb42f412d25ec5b0d5
@@@ -10,7 -10,6 +10,7 @@@ config LOONGARC
        select ARCH_ENABLE_MEMORY_HOTPLUG
        select ARCH_ENABLE_MEMORY_HOTREMOVE
        select ARCH_HAS_ACPI_TABLE_UPGRADE      if ACPI
 +      select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_INLINE_READ_LOCK if !PREEMPTION
        select ARCH_USE_QUEUED_RWLOCKS
        select ARCH_USE_QUEUED_SPINLOCKS
        select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
 +      select ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
        select ARCH_WANT_LD_ORPHAN_WARN
        select ARCH_WANTS_NO_INSTR
        select BUILDTIME_TABLE_SORT
        select COMMON_CLK
+       select CPU_PM
        select EFI
        select GENERIC_CLOCKEVENTS
        select GENERIC_CMOS_UPDATE
        select HAVE_ARCH_TRANSPARENT_HUGEPAGE
        select HAVE_ASM_MODVERSIONS
        select HAVE_CONTEXT_TRACKING_USER
+       select HAVE_C_RECORDMCOUNT
        select HAVE_DEBUG_STACKOVERFLOW
        select HAVE_DMA_CONTIGUOUS
+       select HAVE_DYNAMIC_FTRACE
+       select HAVE_DYNAMIC_FTRACE_WITH_ARGS
+       select HAVE_DYNAMIC_FTRACE_WITH_REGS
        select HAVE_EBPF_JIT
        select HAVE_EXIT_THREAD
        select HAVE_FAST_GUP
+       select HAVE_FTRACE_MCOUNT_RECORD
+       select HAVE_FUNCTION_GRAPH_TRACER
+       select HAVE_FUNCTION_TRACER
        select HAVE_GENERIC_VDSO
        select HAVE_IOREMAP_PROT
        select HAVE_IRQ_EXIT_ON_IRQ_STACK
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RSEQ
        select HAVE_SETUP_PER_CPU_AREA if NUMA
+       select HAVE_STACKPROTECTOR
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_TIF_NOHZ
        select HAVE_VIRT_CPU_ACCOUNTING_GEN if !SMP
        select MODULES_USE_ELF_RELA if MODULES
        select NEED_PER_CPU_EMBED_FIRST_CHUNK
        select NEED_PER_CPU_PAGE_FIRST_CHUNK
+       select OF
+       select OF_EARLY_FLATTREE
        select PCI
        select PCI_DOMAINS_GENERIC
        select PCI_ECAM if ACPI
        select RTC_LIB
        select SMP
        select SPARSE_IRQ
+       select SYSCTL_ARCH_UNALIGN_ALLOW
+       select SYSCTL_ARCH_UNALIGN_NO_WARN
        select SYSCTL_EXCEPTION_TRACE
        select SWIOTLB
        select TRACE_IRQFLAGS_SUPPORT
@@@ -489,7 -500,6 +502,7 @@@ config ARCH_FLATMEM_ENABL
  
  config ARCH_SPARSEMEM_ENABLE
        def_bool y
 +      select SPARSEMEM_VMEMMAP_ENABLE
        help
          Say Y to support efficient handling of sparse physical memory,
          for architectures which are either NUMA (Non-Uniform Memory Access)
@@@ -516,6 -526,13 +529,13 @@@ config ARCH_MMAP_RND_BITS_MA
  
  menu "Power management options"
  
+ config ARCH_SUSPEND_POSSIBLE
+       def_bool y
+ config ARCH_HIBERNATION_POSSIBLE
+       def_bool y
+ source "kernel/power/Kconfig"
  source "drivers/acpi/Kconfig"
  
  endmenu
index 97f16e60c6ff2f2e76aa29f36847a5ca4b6e35b9,81e5d33718684a42bfe51524eef89e33791c8d6c..091897d40b0375758b4822ae1a95719013314709
@@@ -9,6 -9,7 +9,7 @@@
  
  void __init efi_init(void);
  void __init efi_runtime_init(void);
+ void __init *efi_fdt_pointer(void);
  void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
  
  #define ARCH_EFI_IRQ_FLAGS_MASK  0x00000004  /* Bit 2: CSR.CRMD.IE */
  #define EFI_ALLOC_ALIGN               SZ_64K
  #define EFI_RT_VIRTUAL_OFFSET CSR_DMW0_BASE
  
 -static inline struct screen_info *alloc_screen_info(void)
 +static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
  {
 -      return &screen_info;
 +      return ULONG_MAX;
  }
  
 -static inline void free_screen_info(struct screen_info *si)
 +static inline unsigned long efi_get_kimg_min_align(void)
  {
 +      return SZ_2M;
  }
  
 -static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
 -{
 -      return ULONG_MAX;
 -}
 +#define EFI_KIMG_PREFERRED_ADDRESS    PHYSADDR(VMLINUX_LOAD_ADDRESS)
 +
 +unsigned long kernel_entry_address(void);
  
  #endif /* _ASM_LOONGARCH_EFI_H */
index d75ce73e8ff82b77a3491aeb15a772740084b085,ea485b0e1e7f5dda5666183205182ad96ed069bd..3d448fef3af454ce46dc5b52e2cbcfa56d0be11d
@@@ -28,16 -28,29 +28,29 @@@ static unsigned long efi_nr_tables
  static unsigned long efi_config_table;
  
  static unsigned long __initdata boot_memmap = EFI_INVALID_TABLE_ADDR;
+ static unsigned long __initdata fdt_pointer = EFI_INVALID_TABLE_ADDR;
  
  static efi_system_table_t *efi_systab;
  static efi_config_table_type_t arch_tables[] __initdata = {
        {LINUX_EFI_BOOT_MEMMAP_GUID,    &boot_memmap,   "MEMMAP" },
+       {DEVICE_TREE_GUID,              &fdt_pointer,   "FDTPTR" },
        {},
  };
  
+ void __init *efi_fdt_pointer(void)
+ {
+       if (!efi_systab)
+               return NULL;
+       if (fdt_pointer == EFI_INVALID_TABLE_ADDR)
+               return NULL;
+       return early_memremap_ro(fdt_pointer, SZ_64K);
+ }
  void __init efi_runtime_init(void)
  {
-       if (!efi_enabled(EFI_BOOT))
+       if (!efi_enabled(EFI_BOOT) || !efi_systab->runtime)
                return;
  
        if (efi_runtime_disabled()) {
        set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
  }
  
 +unsigned long __initdata screen_info_table = EFI_INVALID_TABLE_ADDR;
 +
 +static void __init init_screen_info(void)
 +{
 +      struct screen_info *si;
 +
 +      if (screen_info_table == EFI_INVALID_TABLE_ADDR)
 +              return;
 +
 +      si = early_memremap(screen_info_table, sizeof(*si));
 +      if (!si) {
 +              pr_err("Could not map screen_info config table\n");
 +              return;
 +      }
 +      screen_info = *si;
 +      memset(si, 0, sizeof(*si));
 +      early_memunmap(si, sizeof(*si));
 +
 +      memblock_reserve(screen_info.lfb_base, screen_info.lfb_size);
 +}
 +
  void __init efi_init(void)
  {
        int size;
  
        set_bit(EFI_CONFIG_TABLES, &efi.flags);
  
 -      if (screen_info.orig_video_isVGA == VIDEO_TYPE_EFI)
 -              memblock_reserve(screen_info.lfb_base, screen_info.lfb_size);
 +      init_screen_info();
  
        if (boot_memmap == EFI_INVALID_TABLE_ADDR)
                return;
index eb5d3a4c8a7ad7726ae8e2704d0b0f1f1f4b63ab,3019ca14c760b59fe55740352911f3975c5918bb..708665895b47d314df2f13c13db75c021f7b198a
@@@ -78,7 -78,7 +78,7 @@@ void __init pcpu_populate_pte(unsigned 
                new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
                pgd_populate(&init_mm, pgd, new);
  #ifndef __PAGETABLE_PUD_FOLDED
 -              pud_init((unsigned long)new, (unsigned long)invalid_pmd_table);
 +              pud_init(new);
  #endif
        }
  
@@@ -89,7 -89,7 +89,7 @@@
                new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
                pud_populate(&init_mm, pud, new);
  #ifndef __PAGETABLE_PMD_FOLDED
 -              pmd_init((unsigned long)new, (unsigned long)invalid_pte_table);
 +              pmd_init(new);
  #endif
        }
  
@@@ -388,6 -388,21 +388,21 @@@ static void __init numa_default_distanc
        }
  }
  
+ /*
+  * fake_numa_init() - For Non-ACPI systems
+  * Return: 0 on success, -errno on failure.
+  */
+ static int __init fake_numa_init(void)
+ {
+       phys_addr_t start = memblock_start_of_DRAM();
+       phys_addr_t end = memblock_end_of_DRAM() - 1;
+       node_set(0, numa_nodes_parsed);
+       pr_info("Faking a node at [mem %pap-%pap]\n", &start, &end);
+       return numa_add_memblk(0, start, end + 1);
+ }
  int __init init_numa_memory(void)
  {
        int i;
        memset(&numa_meminfo, 0, sizeof(numa_meminfo));
  
        /* Parse SRAT and SLIT if provided by firmware. */
-       ret = acpi_numa_init();
+       ret = acpi_disabled ? fake_numa_init() : acpi_numa_init();
        if (ret < 0)
                return ret;
  
index d61c9f465b9520842a3b004cdf07cafaf3a08f24,790cc14c5f06a1d0f67bec829181f295595fb0ed..c583b1ef1f44cefaada16d0d9c450b2019515ec9
  #include <asm/unwind.h>
  #include <asm/vdso.h>
  
+ #ifdef CONFIG_STACKPROTECTOR
+ #include <linux/stackprotector.h>
+ unsigned long __stack_chk_guard __read_mostly;
+ EXPORT_SYMBOL(__stack_chk_guard);
+ #endif
  /*
   * Idle related variables and functions
   */
@@@ -294,7 -300,7 +300,7 @@@ unsigned long stack_top(void
  unsigned long arch_align_stack(unsigned long sp)
  {
        if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
 -              sp -= prandom_u32_max(PAGE_SIZE);
 +              sp -= get_random_u32_below(PAGE_SIZE);
  
        return sp & STACK_ALIGN;
  }