select ARCH_HAS_SET_MEMORY if MMU
        select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
        select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
+       select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
        select ARCH_HAS_SYSCALL_WRAPPER
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
 -      select ARCH_HAS_UBSAN_SANITIZE_ALL
 +      select ARCH_HAS_UBSAN
        select ARCH_HAS_VDSO_DATA
        select ARCH_KEEP_MEMBLOCK if ACPI
        select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
 
  
  static __always_inline unsigned long variable__ffs(unsigned long word)
  {
-       int num;
- 
 -      asm_volatile_goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
 +      asm goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
                                      RISCV_ISA_EXT_ZBB, 1)
                          : : : : legacy);
  
  
  static __always_inline unsigned long variable__fls(unsigned long word)
  {
-       int num;
- 
 -      asm_volatile_goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
 +      asm goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
                                      RISCV_ISA_EXT_ZBB, 1)
                          : : : : legacy);
  
  
  static __always_inline int variable_ffs(int x)
  {
-       int r;
- 
-       if (!x)
-               return 0;
- 
 -      asm_volatile_goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
 +      asm goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
                                      RISCV_ISA_EXT_ZBB, 1)
                          : : : : legacy);
  
  
  static __always_inline int variable_fls(unsigned int x)
  {
-       int r;
- 
-       if (!x)
-               return 0;
- 
 -      asm_volatile_goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
 +      asm goto(ALTERNATIVE("j %l[legacy]", "nop", 0,
                                      RISCV_ISA_EXT_ZBB, 1)
                          : : : : legacy);
  
 
  #define RISCV_ISA_EXT_ZFA             71
  #define RISCV_ISA_EXT_ZTSO            72
  #define RISCV_ISA_EXT_ZACAS           73
+ #define RISCV_ISA_EXT_XANDESPMU               74
  
 +#define RISCV_ISA_EXT_XLINUXENVCFG    127
 +
  #define RISCV_ISA_EXT_MAX             128
  #define RISCV_ISA_EXT_INVALID         U32_MAX
  
 
  #include <asm/cacheflush.h>
  #include <asm/cpufeature.h>
  #include <asm/hwcap.h>
- #include <asm/hwprobe.h>
  #include <asm/patch.h>
  #include <asm/processor.h>
 +#include <asm/sbi.h>
  #include <asm/vector.h>
  
- #include "copy-unaligned.h"
- 
  #define NUM_ALPHA_EXTS ('z' - 'a' + 1)
  
- #define MISALIGNED_ACCESS_JIFFIES_LG2 1
- #define MISALIGNED_BUFFER_SIZE 0x4000
- #define MISALIGNED_BUFFER_ORDER get_order(MISALIGNED_BUFFER_SIZE)
- #define MISALIGNED_COPY_SIZE ((MISALIGNED_BUFFER_SIZE / 2) - 0x80)
- 
  unsigned long elf_hwcap __read_mostly;
  
  /* Host ISA bitmap */
 
          full perf feature support i.e. counter overflow, privilege mode
          filtering, counter configuration.
  
 +config STARFIVE_STARLINK_PMU
 +      depends on ARCH_STARFIVE || COMPILE_TEST
 +      depends on 64BIT
 +      bool "StarFive StarLink PMU"
 +      help
 +         Provide support for StarLink Performance Monitor Unit.
 +         StarLink Performance Monitor Unit integrates one or more cores with
 +         an L3 memory system. The L3 cache events are added into perf event
 +         subsystem, allowing monitoring of various L3 cache perf events.
 +
+ config ANDES_CUSTOM_PMU
+       bool "Andes custom PMU support"
+       depends on ARCH_RENESAS && RISCV_ALTERNATIVE && RISCV_PMU_SBI
+       default y
+       help
+         The Andes cores implement the PMU overflow extension very
+         similar to the standard Sscofpmf and Smcntrpmf extension.
+ 
+         This will patch the overflow and pending CSRs and handle the
+         non-standard behaviour via the regular SBI PMU driver and
+         interface.
+ 
+         If you don't know what to do here, say "Y".
+ 
  config ARM_PMU_ACPI
        depends on ARM_PMU && ACPI
        def_bool y