Commit 1c656b1e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'loongarch-fixes-6.17-1' of...

Merge tag 'loongarch-fixes-6.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson

Pull LoongArch fixes from Huacai Chen:
 "Fix a lot of build warnings for LTO-enabled objtool check, increase
  COMMAND_LINE_SIZE up to 4096, rename a missing GCC_PLUGIN_STACKLEAK to
  KSTACK_ERASE, and fix some bugs about arch timer, module loading, LBT
  and KVM"

* tag 'loongarch-fixes-6.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
  LoongArch: KVM: Add address alignment check in pch_pic register access
  LoongArch: KVM: Use kvm_get_vcpu_by_id() instead of kvm_get_vcpu()
  LoongArch: KVM: Fix stack protector issue in send_ipi_data()
  LoongArch: KVM: Make function kvm_own_lbt() robust
  LoongArch: Rename GCC_PLUGIN_STACKLEAK to KSTACK_ERASE
  LoongArch: Save LBT before FPU in setup_sigcontext()
  LoongArch: Optimize module load time by optimizing PLT/GOT counting
  LoongArch: Add cpuhotplug hooks to fix high cpu usage of vCPU threads
  LoongArch: Increase COMMAND_LINE_SIZE up to 4096
  LoongArch: Pass annotate-tablejump option if LTO is enabled
  objtool/LoongArch: Get table size correctly if LTO is enabled
parents 32b7144f 538c06e3
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -102,7 +102,13 @@ KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)

ifdef CONFIG_OBJTOOL
ifdef CONFIG_CC_HAS_ANNOTATE_TABLEJUMP
# The annotate-tablejump option can not be passed to LLVM backend when LTO is enabled.
# Ensure it is aware of linker with LTO, '--loongarch-annotate-tablejump' also needs to
# be passed via '-mllvm' to ld.lld.
KBUILD_CFLAGS			+= -mannotate-tablejump
ifdef CONFIG_LTO_CLANG
KBUILD_LDFLAGS			+= -mllvm --loongarch-annotate-tablejump
endif
else
KBUILD_CFLAGS			+= -fno-jump-tables # keep compatibility with older compilers
endif
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
	.endm

	.macro STACKLEAK_ERASE
#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
#ifdef CONFIG_KSTACK_ERASE
	bl	stackleak_erase_on_task_stack
#endif
	.endm
+8 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */

#ifndef _UAPI_ASM_LOONGARCH_SETUP_H
#define _UAPI_ASM_LOONGARCH_SETUP_H

#define COMMAND_LINE_SIZE	4096

#endif /* _UAPI_ASM_LOONGARCH_SETUP_H */
+18 −18
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <linux/module.h>
#include <linux/moduleloader.h>
#include <linux/ftrace.h>
#include <linux/sort.h>

Elf_Addr module_emit_got_entry(struct module *mod, Elf_Shdr *sechdrs, Elf_Addr val)
{
@@ -61,38 +62,37 @@ Elf_Addr module_emit_plt_entry(struct module *mod, Elf_Shdr *sechdrs, Elf_Addr v
	return (Elf_Addr)&plt[nr];
}

static int is_rela_equal(const Elf_Rela *x, const Elf_Rela *y)
{
	return x->r_info == y->r_info && x->r_addend == y->r_addend;
}
#define cmp_3way(a, b)  ((a) < (b) ? -1 : (a) > (b))

static bool duplicate_rela(const Elf_Rela *rela, int idx)
static int compare_rela(const void *x, const void *y)
{
	int i;
	int ret;
	const Elf_Rela *rela_x = x, *rela_y = y;

	for (i = 0; i < idx; i++) {
		if (is_rela_equal(&rela[i], &rela[idx]))
			return true;
	}
	ret = cmp_3way(rela_x->r_info, rela_y->r_info);
	if (ret == 0)
		ret = cmp_3way(rela_x->r_addend, rela_y->r_addend);

	return false;
	return ret;
}

static void count_max_entries(Elf_Rela *relas, int num,
			      unsigned int *plts, unsigned int *gots)
{
	unsigned int i, type;
	unsigned int i;

	sort(relas, num, sizeof(Elf_Rela), compare_rela, NULL);

	for (i = 0; i < num; i++) {
		type = ELF_R_TYPE(relas[i].r_info);
		switch (type) {
		if (i && !compare_rela(&relas[i-1], &relas[i]))
			continue;

		switch (ELF_R_TYPE(relas[i].r_info)) {
		case R_LARCH_SOP_PUSH_PLT_PCREL:
		case R_LARCH_B26:
			if (!duplicate_rela(relas, i))
			(*plts)++;
			break;
		case R_LARCH_GOT_PC_HI20:
			if (!duplicate_rela(relas, i))
			(*gots)++;
			break;
		default:
+5 −5
Original line number Diff line number Diff line
@@ -677,6 +677,11 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
	for (i = 1; i < 32; i++)
		err |= __put_user(regs->regs[i], &sc->sc_regs[i]);

#ifdef CONFIG_CPU_HAS_LBT
	if (extctx->lbt.addr)
		err |= protected_save_lbt_context(extctx);
#endif

	if (extctx->lasx.addr)
		err |= protected_save_lasx_context(extctx);
	else if (extctx->lsx.addr)
@@ -684,11 +689,6 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
	else if (extctx->fpu.addr)
		err |= protected_save_fpu_context(extctx);

#ifdef CONFIG_CPU_HAS_LBT
	if (extctx->lbt.addr)
		err |= protected_save_lbt_context(extctx);
#endif

	/* Set the "end" magic */
	info = (struct sctx_info *)extctx->end.addr;
	err |= __put_user(0, &info->magic);
Loading