Skip to content

Commit

Permalink
Merge tag 'xtensa-20220325' of https://github.com/jcmvbkbc/linux-xtensa
Browse files Browse the repository at this point in the history
Pull Xtensa updates from Max Filippov:

 - remove dependency on the compiler's libgcc

 - allow selection of internal kernel ABI via Kconfig

 - enable compiler plugins support for gcc-12 or newer

 - various minor cleanups and fixes

* tag 'xtensa-20220325' of https://github.com/jcmvbkbc/linux-xtensa:
  xtensa: define update_mmu_tlb function
  xtensa: fix xtensa_wsr always writing 0
  xtensa: enable plugin support
  xtensa: clean up kernel exit assembly code
  xtensa: rearrange NMI exit path
  xtensa: merge stack alignment definitions
  xtensa: fix DTC warning unit_address_format
  xtensa: fix stop_machine_cpuslocked call in patch_text
  xtensa: make secondary reset vector support conditional
  xtensa: add kernel ABI selection to Kconfig
  xtensa: don't link with libgcc
  xtensa: add helpers for division, remainder and shifts
  xtensa: add missing XCHAL_HAVE_WINDOWED check
  xtensa: use XCHAL_NUM_AREGS as pt_regs::areg size
  xtensa: rename PT_SIZE to PT_KERNEL_SIZE
  xtensa: Remove unused early_read_config_byte() et al declarations
  xtensa: use strscpy to copy strings
  net: xtensa: use strscpy to copy strings
  • Loading branch information
torvalds committed Mar 25, 2022
2 parents 1f1c153 + 1c4664f commit 744465d
Show file tree
Hide file tree
Showing 32 changed files with 676 additions and 114 deletions.
48 changes: 48 additions & 0 deletions arch/xtensa/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ config XTENSA
select DMA_REMAP if MMU
select GENERIC_ATOMIC64
select GENERIC_IRQ_SHOW
select GENERIC_LIB_CMPDI2
select GENERIC_LIB_MULDI3
select GENERIC_LIB_UCMPDI2
select GENERIC_PCI_IOMAP
select GENERIC_SCHED_CLOCK
select HAVE_ARCH_AUDITSYSCALL
Expand All @@ -32,6 +35,7 @@ config XTENSA
select HAVE_DMA_CONTIGUOUS
select HAVE_EXIT_THREAD
select HAVE_FUNCTION_TRACER
select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
select HAVE_HW_BREAKPOINT if PERF_EVENTS
select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_PCI
Expand Down Expand Up @@ -89,6 +93,9 @@ config CPU_BIG_ENDIAN
config CPU_LITTLE_ENDIAN
def_bool !CPU_BIG_ENDIAN

config CC_HAVE_CALL0_ABI
def_bool $(success,test "$(shell,echo __XTENSA_CALL0_ABI__ | $(CC) -mabi=call0 -E -P - 2>/dev/null)" = 1)

menu "Processor type and features"

choice
Expand Down Expand Up @@ -221,6 +228,15 @@ config HOTPLUG_CPU

Say N if you want to disable CPU hotplug.

config SECONDARY_RESET_VECTOR
bool "Secondary cores use alternative reset vector"
default y
depends on HAVE_SMP
help
Secondary cores may be configured to use alternative reset vector,
or all cores may use primary reset vector.
Say Y here to supply handler for the alternative reset location.

config FAST_SYSCALL_XTENSA
bool "Enable fast atomic syscalls"
default n
Expand All @@ -247,6 +263,38 @@ config FAST_SYSCALL_SPILL_REGISTERS

If unsure, say N.

choice
prompt "Kernel ABI"
default KERNEL_ABI_DEFAULT
help
Select ABI for the kernel code. This ABI is independent of the
supported userspace ABI and any combination of the
kernel/userspace ABI is possible and should work.

In case both kernel and userspace support only call0 ABI
all register windows support code will be omitted from the
build.

If unsure, choose the default ABI.

config KERNEL_ABI_DEFAULT
bool "Default ABI"
help
Select this option to compile kernel code with the default ABI
selected for the toolchain.
Normally cores with windowed registers option use windowed ABI and
cores without it use call0 ABI.

config KERNEL_ABI_CALL0
bool "Call0 ABI" if CC_HAVE_CALL0_ABI
help
Select this option to compile kernel code with call0 ABI even with
toolchain that defaults to windowed ABI.
When this option is not selected the default toolchain ABI will
be used for the kernel code.

endchoice

config USER_ABI_CALL0
bool

Expand Down
10 changes: 5 additions & 5 deletions arch/xtensa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ KBUILD_CFLAGS += -ffreestanding -D__linux__
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,)
KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,)
ifneq ($(CONFIG_KERNEL_ABI_CALL0),)
KBUILD_CFLAGS += -mabi=call0
KBUILD_AFLAGS += -mabi=call0
endif

KBUILD_AFLAGS += -mlongcalls -mtext-section-literals

Expand All @@ -51,13 +55,9 @@ KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(vardirs) $(plfdirs))

KBUILD_DEFCONFIG := iss_defconfig

# Find libgcc.a

LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)

head-y := arch/xtensa/kernel/head.o

libs-y += arch/xtensa/lib/ $(LIBGCC)
libs-y += arch/xtensa/lib/

boot := arch/xtensa/boot

Expand Down
8 changes: 4 additions & 4 deletions arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
reg = <0x00000000 0x08000000>;
bank-width = <2>;
device-width = <2>;
partition@0x0 {
partition@0 {
label = "data";
reg = <0x00000000 0x06000000>;
};
partition@0x6000000 {
partition@6000000 {
label = "boot loader area";
reg = <0x06000000 0x00800000>;
};
partition@0x6800000 {
partition@6800000 {
label = "kernel image";
reg = <0x06800000 0x017e0000>;
};
partition@0x7fe0000 {
partition@7fe0000 {
label = "boot environment";
reg = <0x07fe0000 0x00020000>;
};
Expand Down
8 changes: 4 additions & 4 deletions arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
reg = <0x08000000 0x01000000>;
bank-width = <2>;
device-width = <2>;
partition@0x0 {
partition@0 {
label = "boot loader area";
reg = <0x00000000 0x00400000>;
};
partition@0x400000 {
partition@400000 {
label = "kernel image";
reg = <0x00400000 0x00600000>;
};
partition@0xa00000 {
partition@a00000 {
label = "data";
reg = <0x00a00000 0x005e0000>;
};
partition@0xfe0000 {
partition@fe0000 {
label = "boot environment";
reg = <0x00fe0000 0x00020000>;
};
Expand Down
4 changes: 2 additions & 2 deletions arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
reg = <0x08000000 0x00400000>;
bank-width = <2>;
device-width = <2>;
partition@0x0 {
partition@0 {
label = "boot loader area";
reg = <0x00000000 0x003f0000>;
};
partition@0x3f0000 {
partition@3f0000 {
label = "boot environment";
reg = <0x003f0000 0x00010000>;
};
Expand Down
34 changes: 33 additions & 1 deletion arch/xtensa/include/asm/asmmacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,39 @@
#endif
.endm

#define XTENSA_STACK_ALIGNMENT 16
.macro do_nsau cnt, val, tmp, a
#if XCHAL_HAVE_NSA
nsau \cnt, \val
#else
mov \a, \val
movi \cnt, 0
extui \tmp, \a, 16, 16
bnez \tmp, 0f
movi \cnt, 16
slli \a, \a, 16
0:
extui \tmp, \a, 24, 8
bnez \tmp, 1f
addi \cnt, \cnt, 8
slli \a, \a, 8
1:
movi \tmp, __nsau_data
extui \a, \a, 24, 8
add \tmp, \tmp, \a
l8ui \tmp, \tmp, 0
add \cnt, \cnt, \tmp
#endif /* !XCHAL_HAVE_NSA */
.endm

.macro do_abs dst, src, tmp
#if XCHAL_HAVE_ABS
abs \dst, \src
#else
neg \tmp, \src
movgez \tmp, \src, \src
mov \dst, \tmp
#endif
.endm

#if defined(__XTENSA_WINDOWED_ABI__)

Expand Down
7 changes: 7 additions & 0 deletions arch/xtensa/include/asm/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@
#endif
#endif

/* Xtensa ABI requires stack alignment to be at least 16 */
#if XCHAL_DATA_WIDTH > 16
#define XTENSA_STACK_ALIGNMENT XCHAL_DATA_WIDTH
#else
#define XTENSA_STACK_ALIGNMENT 16
#endif

#endif
9 changes: 0 additions & 9 deletions arch/xtensa/include/asm/pci-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,4 @@ static inline void pcibios_init_resource(struct resource *res,
res->child = NULL;
}


/* These are used for config access before all the PCI probing has been done. */
int early_read_config_byte(struct pci_controller*, int, int, int, u8*);
int early_read_config_word(struct pci_controller*, int, int, int, u16*);
int early_read_config_dword(struct pci_controller*, int, int, int, u32*);
int early_write_config_byte(struct pci_controller*, int, int, int, u8);
int early_write_config_word(struct pci_controller*, int, int, int, u16);
int early_write_config_dword(struct pci_controller*, int, int, int, u32);

#endif /* _XTENSA_PCI_BRIDGE_H */
4 changes: 4 additions & 0 deletions arch/xtensa/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ extern void update_mmu_cache(struct vm_area_struct * vma,

typedef pte_t *pte_addr_t;

void update_mmu_tlb(struct vm_area_struct *vma,
unsigned long address, pte_t *ptep);
#define __HAVE_ARCH_UPDATE_MMU_TLB

#endif /* !defined (__ASSEMBLY__) */

#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
Expand Down
10 changes: 3 additions & 7 deletions arch/xtensa/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
#include <asm/types.h>
#include <asm/regs.h>

/* Xtensa ABI requires stack alignment to be at least 16 */

#define STACK_ALIGN (XCHAL_DATA_WIDTH > 16 ? XCHAL_DATA_WIDTH : 16)

#define ARCH_SLAB_MINALIGN STACK_ALIGN
#define ARCH_SLAB_MINALIGN XTENSA_STACK_ALIGNMENT

/*
* User space process size: 1 GB.
Expand Down Expand Up @@ -239,8 +235,8 @@ extern unsigned long __get_wchan(struct task_struct *p);

#define xtensa_set_sr(x, sr) \
({ \
unsigned int v = (unsigned int)(x); \
__asm__ __volatile__ ("wsr %0, "__stringify(sr) :: "a"(v)); \
__asm__ __volatile__ ("wsr %0, "__stringify(sr) :: \
"a"((unsigned int)(x))); \
})

#define xtensa_get_sr(sr) \
Expand Down
7 changes: 3 additions & 4 deletions arch/xtensa/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#ifndef __ASSEMBLY__

#include <asm/coprocessor.h>
#include <asm/core.h>

/*
* This struct defines the way the registers are stored on the
Expand Down Expand Up @@ -77,14 +78,12 @@ struct pt_regs {
/* current register frame.
* Note: The ESF for kernel exceptions ends after 16 registers!
*/
unsigned long areg[16];
unsigned long areg[XCHAL_NUM_AREGS];
};

#include <asm/core.h>

# define arch_has_single_step() (1)
# define task_pt_regs(tsk) ((struct pt_regs*) \
(task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)
(task_stack_page(tsk) + KERNEL_STACK_SIZE) - 1)
# define user_mode(regs) (((regs)->ps & 0x00000020)!=0)
# define instruction_pointer(regs) ((regs)->pc)
# define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
Expand Down
3 changes: 2 additions & 1 deletion arch/xtensa/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ obj-$(CONFIG_MMU) += pci-dma.o
obj-$(CONFIG_PCI) += pci.o
obj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o
obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
obj-$(CONFIG_SMP) += smp.o mxhead.o
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_SECONDARY_RESET_VECTOR) += mxhead.o
obj-$(CONFIG_XTENSA_VARIANT_HAVE_PERF_EVENTS) += perf_event.o
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
obj-$(CONFIG_S32C1I_SELFTEST) += s32c1i_selftest.o
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/kernel/asm-offsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int main(void)
DEFINE(PT_AREG15, offsetof (struct pt_regs, areg[15]));
DEFINE(PT_WINDOWBASE, offsetof (struct pt_regs, windowbase));
DEFINE(PT_WINDOWSTART, offsetof(struct pt_regs, windowstart));
DEFINE(PT_SIZE, sizeof(struct pt_regs));
DEFINE(PT_KERNEL_SIZE, offsetof(struct pt_regs, areg[16]));
DEFINE(PT_AREG_END, offsetof (struct pt_regs, areg[XCHAL_NUM_AREGS]));
DEFINE(PT_USER_SIZE, offsetof(struct pt_regs, areg[XCHAL_NUM_AREGS]));
DEFINE(PT_XTREGS_OPT, offsetof(struct pt_regs, xtregs_opt));
Expand Down
Loading

0 comments on commit 744465d

Please sign in to comment.