]> Git Repo - linux.git/commitdiff
Merge tag 'loongarch-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuaca...
authorLinus Torvalds <[email protected]>
Fri, 27 Sep 2024 17:14:35 +0000 (10:14 -0700)
committerLinus Torvalds <[email protected]>
Fri, 27 Sep 2024 17:14:35 +0000 (10:14 -0700)
Pull LoongArch updates from Huacai Chen:

 - Fix objtool about do_syscall() and Clang

 - Enable generic CPU vulnerabilites support

 - Enable ACPI BGRT handling

 - Rework CPU feature probe from CPUCFG/IOCSR

 - Add ARCH_HAS_SET_MEMORY support

 - Add ARCH_HAS_SET_DIRECT_MAP support

 - Improve hardware page table walker

 - Simplify _percpu_read() and _percpu_write()

 - Add advanced extended IRQ model documentions

 - Some bug fixes and other small changes

* tag 'loongarch-6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
  Docs/LoongArch: Add advanced extended IRQ model description
  LoongArch: Remove posix_types.h include from sigcontext.h
  LoongArch: Fix memleak in pci_acpi_scan_root()
  LoongArch: Simplify _percpu_read() and _percpu_write()
  LoongArch: Improve hardware page table walker
  LoongArch: Add ARCH_HAS_SET_DIRECT_MAP support
  LoongArch: Add ARCH_HAS_SET_MEMORY support
  LoongArch: Rework CPU feature probe from CPUCFG/IOCSR
  LoongArch: Enable ACPI BGRT handling
  LoongArch: Enable generic CPU vulnerabilites support
  LoongArch: Remove STACK_FRAME_NON_STANDARD(do_syscall)
  LoongArch: Set AS_HAS_THIN_ADD_SUB as y if AS_IS_LLVM
  LoongArch: Enable objtool for Clang
  objtool: Handle frame pointer related instructions

1  2 
arch/loongarch/Kconfig
arch/loongarch/include/asm/loongarch.h
tools/objtool/check.c

diff --combined arch/loongarch/Kconfig
index 0eb0436ad4ce9b16cb5b92ed66019f5f7017a3ce,4b02b0492c3b28f4b0761226f3da465b0c0998f6..bb35c34f86d23a1cc6f049ad727bea236f700389
@@@ -25,6 -25,8 +25,8 @@@ config LOONGARC
        select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
        select ARCH_HAS_PTE_DEVMAP
        select ARCH_HAS_PTE_SPECIAL
+       select ARCH_HAS_SET_MEMORY
+       select ARCH_HAS_SET_DIRECT_MAP
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_INLINE_READ_LOCK if !PREEMPTION
        select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
@@@ -82,6 -84,7 +84,7 @@@
        select GENERIC_CMOS_UPDATE
        select GENERIC_CPU_AUTOPROBE
        select GENERIC_CPU_DEVICES
+       select GENERIC_CPU_VULNERABILITIES
        select GENERIC_ENTRY
        select GENERIC_GETTIMEOFDAY
        select GENERIC_IOREMAP if !ARCH_IOREMAP
        select HAVE_LIVEPATCH
        select HAVE_MOD_ARCH_SPECIFIC
        select HAVE_NMI
-       select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB && !CC_IS_CLANG
+       select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB
        select HAVE_PCI
        select HAVE_PERF_EVENTS
        select HAVE_PERF_REGS
        select TRACE_IRQFLAGS_SUPPORT
        select USE_PERCPU_NUMA_NODE_ID
        select USER_STACKTRACE_SUPPORT
 +      select VDSO_GETRANDOM
        select ZONE_DMA32
  
  config 32BIT
@@@ -267,7 -269,7 +270,7 @@@ config AS_HAS_FCSR_CLAS
        def_bool $(as-instr,movfcsr2gr \$t0$(comma)\$fcsr0)
  
  config AS_HAS_THIN_ADD_SUB
-       def_bool $(cc-option,-Wa$(comma)-mthin-add-sub)
+       def_bool $(cc-option,-Wa$(comma)-mthin-add-sub) || AS_IS_LLVM
  
  config AS_HAS_LSX_EXTENSION
        def_bool $(as-instr,vld \$vr0$(comma)\$a0$(comma)0)
index 04bf1a7f903a216ac980169eafe71b5fea005384,4084cb64ba06e697e368be4e1bbdc388e0222c22..26542413a5b0ea4c33843faecdc25b0da4745c02
@@@ -62,6 -62,7 +62,7 @@@
  #define LOONGARCH_CPUCFG1             0x1
  #define  CPUCFG1_ISGR32                       BIT(0)
  #define  CPUCFG1_ISGR64                       BIT(1)
+ #define  CPUCFG1_ISA                  GENMASK(1, 0)
  #define  CPUCFG1_PAGING                       BIT(2)
  #define  CPUCFG1_IOCSR                        BIT(3)
  #define  CPUCFG1_PABITS                       GENMASK(11, 4)
  #define  CPUCFG6_PMP                  BIT(0)
  #define  CPUCFG6_PAMVER                       GENMASK(3, 1)
  #define  CPUCFG6_PMNUM                        GENMASK(7, 4)
 +#define  CPUCFG6_PMNUM_SHIFT          4
  #define  CPUCFG6_PMBITS                       GENMASK(13, 8)
  #define  CPUCFG6_UPM                  BIT(14)
  
  
  /*
   * CPUCFG index area: 0x40000000 -- 0x400000ff
 - * SW emulation for KVM hypervirsor
 + * SW emulation for KVM hypervirsor, see arch/loongarch/include/uapi/asm/kvm_para.h
   */
 -#define CPUCFG_KVM_BASE                       0x40000000
 -#define CPUCFG_KVM_SIZE                       0x100
 -
 -#define CPUCFG_KVM_SIG                        (CPUCFG_KVM_BASE + 0)
 -#define  KVM_SIGNATURE                        "KVM\0"
 -#define CPUCFG_KVM_FEATURE            (CPUCFG_KVM_BASE + 4)
 -#define  KVM_FEATURE_IPI              BIT(1)
 -#define  KVM_FEATURE_STEAL_TIME               BIT(2)
  
  #ifndef __ASSEMBLY__
  
diff --combined tools/objtool/check.c
index d086f207a3d31ef7511218286b75358a58519467,af9cfed7f4ecb5f35d354cec4ecb3ddeca1c2ecd..6604f5d038aadfff6e4465bda50662c32c9ff067
@@@ -177,52 -177,6 +177,52 @@@ static bool is_sibling_call(struct inst
        return (is_static_jump(insn) && insn_call_dest(insn));
  }
  
 +/*
 + * Checks if a string ends with another.
 + */
 +static bool str_ends_with(const char *s, const char *sub)
 +{
 +      const int slen = strlen(s);
 +      const int sublen = strlen(sub);
 +
 +      if (sublen > slen)
 +              return 0;
 +
 +      return !memcmp(s + slen - sublen, sub, sublen);
 +}
 +
 +/*
 + * Checks if a function is a Rust "noreturn" one.
 + */
 +static bool is_rust_noreturn(const struct symbol *func)
 +{
 +      /*
 +       * If it does not start with "_R", then it is not a Rust symbol.
 +       */
 +      if (strncmp(func->name, "_R", 2))
 +              return false;
 +
 +      /*
 +       * These are just heuristics -- we do not control the precise symbol
 +       * name, due to the crate disambiguators (which depend on the compiler)
 +       * as well as changes to the source code itself between versions (since
 +       * these come from the Rust standard library).
 +       */
 +      return str_ends_with(func->name, "_4core5sliceSp15copy_from_slice17len_mismatch_fail")          ||
 +             str_ends_with(func->name, "_4core6option13unwrap_failed")                                ||
 +             str_ends_with(func->name, "_4core6result13unwrap_failed")                                ||
 +             str_ends_with(func->name, "_4core9panicking5panic")                                      ||
 +             str_ends_with(func->name, "_4core9panicking9panic_fmt")                                  ||
 +             str_ends_with(func->name, "_4core9panicking14panic_explicit")                            ||
 +             str_ends_with(func->name, "_4core9panicking14panic_nounwind")                            ||
 +             str_ends_with(func->name, "_4core9panicking18panic_bounds_check")                        ||
 +             str_ends_with(func->name, "_4core9panicking19assert_failed_inner")                       ||
 +             str_ends_with(func->name, "_4core9panicking36panic_misaligned_pointer_dereference")      ||
 +             strstr(func->name, "_4core9panicking11panic_const24panic_const_")                        ||
 +             (strstr(func->name, "_4core5slice5index24slice_") &&
 +              str_ends_with(func->name, "_fail"));
 +}
 +
  /*
   * This checks to see if the given function is a "noreturn" function.
   *
@@@ -248,14 -202,10 +248,14 @@@ static bool __dead_end_function(struct 
        if (!func)
                return false;
  
 -      if (func->bind == STB_GLOBAL || func->bind == STB_WEAK)
 +      if (func->bind == STB_GLOBAL || func->bind == STB_WEAK) {
 +              if (is_rust_noreturn(func))
 +                      return true;
 +
                for (i = 0; i < ARRAY_SIZE(global_noreturns); i++)
                        if (!strcmp(func->name, global_noreturns[i]))
                                return true;
 +      }
  
        if (func->bind == STB_WEAK)
                return false;
@@@ -3043,10 -2993,27 +3043,27 @@@ static int update_cfi_state(struct inst
                                break;
                        }
  
-                       if (op->dest.reg == CFI_SP && op->src.reg == CFI_BP) {
+                       if (op->dest.reg == CFI_BP && op->src.reg == CFI_SP &&
+                           insn->sym->frame_pointer) {
+                               /* addi.d fp,sp,imm on LoongArch */
+                               if (cfa->base == CFI_SP && cfa->offset == op->src.offset) {
+                                       cfa->base = CFI_BP;
+                                       cfa->offset = 0;
+                               }
+                               break;
+                       }
  
-                               /* lea disp(%rbp), %rsp */
-                               cfi->stack_size = -(op->src.offset + regs[CFI_BP].offset);
+                       if (op->dest.reg == CFI_SP && op->src.reg == CFI_BP) {
+                               /* addi.d sp,fp,imm on LoongArch */
+                               if (cfa->base == CFI_BP && cfa->offset == 0) {
+                                       if (insn->sym->frame_pointer) {
+                                               cfa->base = CFI_SP;
+                                               cfa->offset = -op->src.offset;
+                                       }
+                               } else {
+                                       /* lea disp(%rbp), %rsp */
+                                       cfi->stack_size = -(op->src.offset + regs[CFI_BP].offset);
+                               }
                                break;
                        }
  
This page took 0.096514 seconds and 4 git commands to generate.