Commit f1f9984f authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'riscv-for-linus-6.10-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux

Pull more RISC-V updates from Palmer Dabbelt:

 - The compression format used for boot images is now configurable at
   build time, and these formats are shown in `make help`

 - access_ok() has been optimized

 - A pair of performance bugs have been fixed in the uaccess handlers

 - Various fixes and cleanups, including one for the IMSIC build failure
   and one for the early-boot ftrace illegal NOPs bug

* tag 'riscv-for-linus-6.10-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: Fix early ftrace nop patching
  irqchip: riscv-imsic: Fixup riscv_ipi_set_virq_range() conflict
  riscv: selftests: Add signal handling vector tests
  riscv: mm: accelerate pagefault when badaccess
  riscv: uaccess: Relax the threshold for fast path
  riscv: uaccess: Allow the last potential unrolled copy
  riscv: typo in comment for get_f64_reg
  Use bool value in set_cpu_online()
  riscv: selftests: Add hwprobe binaries to .gitignore
  riscv: stacktrace: fixed walk_stackframe()
  ftrace: riscv: move from REGS to ARGS
  riscv: do not select MODULE_SECTIONS by default
  riscv: show help string for riscv-specific targets
  riscv: make image compression configurable
  riscv: cpufeature: Fix extension subset checking
  riscv: cpufeature: Fix thead vector hwcap removal
  riscv: rewrite __kernel_map_pages() to fix sleeping in invalid context
  riscv: force PAGE_SIZE linear mapping if debug_pagealloc is enabled
  riscv: Define TASK_SIZE_MAX for __access_ok()
  riscv: Remove PGDIR_SIZE_L3 and TASK_SIZE_MIN
parents 9351f138 6ca445d8
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ config RISCV
	select HAVE_DMA_CONTIGUOUS if MMU
	select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
	select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
	select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
	select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE
	select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
	select HAVE_FUNCTION_GRAPH_TRACER
	select HAVE_FUNCTION_GRAPH_RETVAL if HAVE_FUNCTION_GRAPH_TRACER
@@ -141,6 +141,13 @@ config RISCV
	select HAVE_GCC_PLUGINS
	select HAVE_GENERIC_VDSO if MMU && 64BIT
	select HAVE_IRQ_TIME_ACCOUNTING
	select HAVE_KERNEL_BZIP2 if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_GZIP if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_LZ4 if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_LZMA if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_LZO if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_UNCOMPRESSED if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KERNEL_ZSTD if !XIP_KERNEL && !EFI_ZBOOT
	select HAVE_KPROBES if !XIP_KERNEL
	select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
	select HAVE_KRETPROBES if !XIP_KERNEL
@@ -170,7 +177,6 @@ config RISCV
	select LOCK_MM_AND_FIND_VMA
	select MMU_GATHER_RCU_TABLE_FREE if SMP && MMU
	select MODULES_USE_ELF_RELA if MODULES
	select MODULE_SECTIONS if MODULES
	select OF
	select OF_EARLY_FLATTREE
	select OF_IRQ
@@ -861,6 +867,7 @@ config PARAVIRT_TIME_ACCOUNTING
config RELOCATABLE
	bool "Build a relocatable kernel"
	depends on MMU && 64BIT && !XIP_KERNEL
	select MODULE_SECTIONS if MODULES
	help
          This builds a kernel as a Position Independent Executable (PIE),
          which retains all relocation metadata required to relocate the
+37 −7
Original line number Diff line number Diff line
@@ -154,6 +154,21 @@ endif
endif
endif

boot					:= arch/riscv/boot
boot-image-y				:= Image
boot-image-$(CONFIG_KERNEL_BZIP2)	:= Image.bz2
boot-image-$(CONFIG_KERNEL_GZIP)	:= Image.gz
boot-image-$(CONFIG_KERNEL_LZ4)		:= Image.lz4
boot-image-$(CONFIG_KERNEL_LZMA)	:= Image.lzma
boot-image-$(CONFIG_KERNEL_LZO)		:= Image.lzo
boot-image-$(CONFIG_KERNEL_ZSTD)	:= Image.zst
ifdef CONFIG_RISCV_M_MODE
boot-image-$(CONFIG_ARCH_CANAAN)	:= loader.bin
endif
boot-image-$(CONFIG_EFI_ZBOOT)		:= vmlinuz.efi
boot-image-$(CONFIG_XIP_KERNEL)		:= xipImage
KBUILD_IMAGE				:= $(boot)/$(boot-image-y)

libs-y += arch/riscv/lib/
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a

@@ -171,21 +186,19 @@ endif
vdso-install-y			+= arch/riscv/kernel/vdso/vdso.so.dbg
vdso-install-$(CONFIG_COMPAT)	+= arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg

BOOT_TARGETS := Image Image.gz loader loader.bin xipImage vmlinuz.efi
BOOT_TARGETS := Image Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader loader.bin xipImage vmlinuz.efi

all:	$(notdir $(KBUILD_IMAGE))

loader.bin: loader
Image.gz loader vmlinuz.efi: Image
Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst loader xipImage vmlinuz.efi: Image

$(BOOT_TARGETS): vmlinux
	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
	@$(kecho) '  Kernel: $(boot)/$@ is ready'

Image.%: Image
	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@

install: KBUILD_IMAGE := $(boot)/Image
zinstall: KBUILD_IMAGE := $(boot)/Image.gz
# the install target always installs KBUILD_IMAGE (which may be compressed)
# but keep the zinstall target for compatibility with older releases
install zinstall:
	$(call cmd,install)

@@ -206,3 +219,20 @@ rv32_defconfig:
PHONY += rv32_nommu_virt_defconfig
rv32_nommu_virt_defconfig:
	$(Q)$(MAKE) -f $(srctree)/Makefile nommu_virt_defconfig 32-bit.config

define archhelp
  echo  '  Image		- Uncompressed kernel image (arch/riscv/boot/Image)'
  echo  '  Image.gz	- Compressed kernel image (arch/riscv/boot/Image.gz)'
  echo  '  Image.bz2	- Compressed kernel image (arch/riscv/boot/Image.bz2)'
  echo  '  Image.lz4	- Compressed kernel image (arch/riscv/boot/Image.lz4)'
  echo  '  Image.lzma	- Compressed kernel image (arch/riscv/boot/Image.lzma)'
  echo  '  Image.lzo	- Compressed kernel image (arch/riscv/boot/Image.lzo)'
  echo  '  Image.zst	- Compressed kernel image (arch/riscv/boot/Image.zst)'
  echo  '  vmlinuz.efi	- Compressed EFI kernel image (arch/riscv/boot/vmlinuz.efi)'
  echo  '		  Default when CONFIG_EFI_ZBOOT=y'
  echo  '  xipImage	- Execute-in-place kernel image (arch/riscv/boot/xipImage)'
  echo  '		  Default when CONFIG_XIP_KERNEL=y'
  echo  '  install	- Install kernel using (your) ~/bin/$(INSTALLKERNEL) or'
  echo  '		  (distribution) /sbin/$(INSTALLKERNEL) or install to '
  echo  '		  $$(INSTALL_PATH)'
endef
+6 −3
Original line number Diff line number Diff line
@@ -17,15 +17,18 @@
#   $3 - kernel map file
#   $4 - default install path (blank if root directory)

if [ "$(basename $2)" = "Image.gz" ]; then
case "${2##*/}" in
# Compressed install
Image.*|vmlinuz.efi)
  echo "Installing compressed kernel"
  base=vmlinuz
else
  ;;
# Normal install
*)
  echo "Installing normal kernel"
  base=vmlinux
fi
  ;;
esac

if [ -f $4/$base-$1 ]; then
  mv $4/$base-$1 $4/$base-$1.old
+6 −0
Original line number Diff line number Diff line
@@ -13,6 +13,12 @@ static inline void local_flush_icache_all(void)
	asm volatile ("fence.i" ::: "memory");
}

static inline void local_flush_icache_range(unsigned long start,
					    unsigned long end)
{
	local_flush_icache_all();
}

#define PG_dcache_clean PG_arch_1

static inline void flush_dcache_folio(struct folio *folio)
+69 −7
Original line number Diff line number Diff line
@@ -124,20 +124,82 @@ struct dyn_ftrace;
int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
#define ftrace_init_nop ftrace_init_nop

#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_ARGS
#define arch_ftrace_get_regs(regs) NULL
struct ftrace_ops;
struct ftrace_regs;
struct ftrace_regs {
	unsigned long epc;
	unsigned long ra;
	unsigned long sp;
	unsigned long s0;
	unsigned long t1;
	union {
		unsigned long args[8];
		struct {
			unsigned long a0;
			unsigned long a1;
			unsigned long a2;
			unsigned long a3;
			unsigned long a4;
			unsigned long a5;
			unsigned long a6;
			unsigned long a7;
		};
	};
};

static __always_inline unsigned long ftrace_regs_get_instruction_pointer(const struct ftrace_regs
									 *fregs)
{
	return fregs->epc;
}

static __always_inline void ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
								unsigned long pc)
{
	fregs->epc = pc;
}

static __always_inline unsigned long ftrace_regs_get_stack_pointer(const struct ftrace_regs *fregs)
{
	return fregs->sp;
}

static __always_inline unsigned long ftrace_regs_get_argument(struct ftrace_regs *fregs,
							      unsigned int n)
{
	if (n < 8)
		return fregs->args[n];
	return 0;
}

static __always_inline unsigned long ftrace_regs_get_return_value(const struct ftrace_regs *fregs)
{
	return fregs->a0;
}

static __always_inline void ftrace_regs_set_return_value(struct ftrace_regs *fregs,
							 unsigned long ret)
{
	fregs->a0 = ret;
}

static __always_inline void ftrace_override_function_with_return(struct ftrace_regs *fregs)
{
	fregs->epc = fregs->ra;
}

int ftrace_regs_query_register_offset(const char *name);

void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
		       struct ftrace_ops *op, struct ftrace_regs *fregs);
#define ftrace_graph_func ftrace_graph_func

static inline void __arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr)
{
		regs->t1 = addr;
	fregs->t1 = addr;
}
#define arch_ftrace_set_direct_caller(fregs, addr) \
	__arch_ftrace_set_direct_caller(&(fregs)->regs, addr)
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
#endif /* CONFIG_DYNAMIC_FTRACE_WITH_ARGS */

#endif /* __ASSEMBLY__ */

Loading