Skip to content

Commit 744465d

Browse files
committed
Merge tag 'xtensa-20220325' of https://github.com/jcmvbkbc/linux-xtensa
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
2 parents 1f1c153 + 1c4664f commit 744465d

32 files changed

+676
-114
lines changed

arch/xtensa/Kconfig

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ config XTENSA
2121
select DMA_REMAP if MMU
2222
select GENERIC_ATOMIC64
2323
select GENERIC_IRQ_SHOW
24+
select GENERIC_LIB_CMPDI2
25+
select GENERIC_LIB_MULDI3
26+
select GENERIC_LIB_UCMPDI2
2427
select GENERIC_PCI_IOMAP
2528
select GENERIC_SCHED_CLOCK
2629
select HAVE_ARCH_AUDITSYSCALL
@@ -32,6 +35,7 @@ config XTENSA
3235
select HAVE_DMA_CONTIGUOUS
3336
select HAVE_EXIT_THREAD
3437
select HAVE_FUNCTION_TRACER
38+
select HAVE_GCC_PLUGINS if GCC_VERSION >= 120000
3539
select HAVE_HW_BREAKPOINT if PERF_EVENTS
3640
select HAVE_IRQ_TIME_ACCOUNTING
3741
select HAVE_PCI
@@ -89,6 +93,9 @@ config CPU_BIG_ENDIAN
8993
config CPU_LITTLE_ENDIAN
9094
def_bool !CPU_BIG_ENDIAN
9195

96+
config CC_HAVE_CALL0_ABI
97+
def_bool $(success,test "$(shell,echo __XTENSA_CALL0_ABI__ | $(CC) -mabi=call0 -E -P - 2>/dev/null)" = 1)
98+
9299
menu "Processor type and features"
93100

94101
choice
@@ -221,6 +228,15 @@ config HOTPLUG_CPU
221228

222229
Say N if you want to disable CPU hotplug.
223230

231+
config SECONDARY_RESET_VECTOR
232+
bool "Secondary cores use alternative reset vector"
233+
default y
234+
depends on HAVE_SMP
235+
help
236+
Secondary cores may be configured to use alternative reset vector,
237+
or all cores may use primary reset vector.
238+
Say Y here to supply handler for the alternative reset location.
239+
224240
config FAST_SYSCALL_XTENSA
225241
bool "Enable fast atomic syscalls"
226242
default n
@@ -247,6 +263,38 @@ config FAST_SYSCALL_SPILL_REGISTERS
247263

248264
If unsure, say N.
249265

266+
choice
267+
prompt "Kernel ABI"
268+
default KERNEL_ABI_DEFAULT
269+
help
270+
Select ABI for the kernel code. This ABI is independent of the
271+
supported userspace ABI and any combination of the
272+
kernel/userspace ABI is possible and should work.
273+
274+
In case both kernel and userspace support only call0 ABI
275+
all register windows support code will be omitted from the
276+
build.
277+
278+
If unsure, choose the default ABI.
279+
280+
config KERNEL_ABI_DEFAULT
281+
bool "Default ABI"
282+
help
283+
Select this option to compile kernel code with the default ABI
284+
selected for the toolchain.
285+
Normally cores with windowed registers option use windowed ABI and
286+
cores without it use call0 ABI.
287+
288+
config KERNEL_ABI_CALL0
289+
bool "Call0 ABI" if CC_HAVE_CALL0_ABI
290+
help
291+
Select this option to compile kernel code with call0 ABI even with
292+
toolchain that defaults to windowed ABI.
293+
When this option is not selected the default toolchain ABI will
294+
be used for the kernel code.
295+
296+
endchoice
297+
250298
config USER_ABI_CALL0
251299
bool
252300

arch/xtensa/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ KBUILD_CFLAGS += -ffreestanding -D__linux__
3535
KBUILD_CFLAGS += -pipe -mlongcalls -mtext-section-literals
3636
KBUILD_CFLAGS += $(call cc-option,-mforce-no-pic,)
3737
KBUILD_CFLAGS += $(call cc-option,-mno-serialize-volatile,)
38+
ifneq ($(CONFIG_KERNEL_ABI_CALL0),)
39+
KBUILD_CFLAGS += -mabi=call0
40+
KBUILD_AFLAGS += -mabi=call0
41+
endif
3842

3943
KBUILD_AFLAGS += -mlongcalls -mtext-section-literals
4044

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

5256
KBUILD_DEFCONFIG := iss_defconfig
5357

54-
# Find libgcc.a
55-
56-
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
57-
5858
head-y := arch/xtensa/kernel/head.o
5959

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

6262
boot := arch/xtensa/boot
6363

arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
reg = <0x00000000 0x08000000>;
99
bank-width = <2>;
1010
device-width = <2>;
11-
partition@0x0 {
11+
partition@0 {
1212
label = "data";
1313
reg = <0x00000000 0x06000000>;
1414
};
15-
partition@0x6000000 {
15+
partition@6000000 {
1616
label = "boot loader area";
1717
reg = <0x06000000 0x00800000>;
1818
};
19-
partition@0x6800000 {
19+
partition@6800000 {
2020
label = "kernel image";
2121
reg = <0x06800000 0x017e0000>;
2222
};
23-
partition@0x7fe0000 {
23+
partition@7fe0000 {
2424
label = "boot environment";
2525
reg = <0x07fe0000 0x00020000>;
2626
};

arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
reg = <0x08000000 0x01000000>;
99
bank-width = <2>;
1010
device-width = <2>;
11-
partition@0x0 {
11+
partition@0 {
1212
label = "boot loader area";
1313
reg = <0x00000000 0x00400000>;
1414
};
15-
partition@0x400000 {
15+
partition@400000 {
1616
label = "kernel image";
1717
reg = <0x00400000 0x00600000>;
1818
};
19-
partition@0xa00000 {
19+
partition@a00000 {
2020
label = "data";
2121
reg = <0x00a00000 0x005e0000>;
2222
};
23-
partition@0xfe0000 {
23+
partition@fe0000 {
2424
label = "boot environment";
2525
reg = <0x00fe0000 0x00020000>;
2626
};

arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
reg = <0x08000000 0x00400000>;
99
bank-width = <2>;
1010
device-width = <2>;
11-
partition@0x0 {
11+
partition@0 {
1212
label = "boot loader area";
1313
reg = <0x00000000 0x003f0000>;
1414
};
15-
partition@0x3f0000 {
15+
partition@3f0000 {
1616
label = "boot environment";
1717
reg = <0x003f0000 0x00010000>;
1818
};

arch/xtensa/include/asm/asmmacro.h

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,39 @@
191191
#endif
192192
.endm
193193

194-
#define XTENSA_STACK_ALIGNMENT 16
194+
.macro do_nsau cnt, val, tmp, a
195+
#if XCHAL_HAVE_NSA
196+
nsau \cnt, \val
197+
#else
198+
mov \a, \val
199+
movi \cnt, 0
200+
extui \tmp, \a, 16, 16
201+
bnez \tmp, 0f
202+
movi \cnt, 16
203+
slli \a, \a, 16
204+
0:
205+
extui \tmp, \a, 24, 8
206+
bnez \tmp, 1f
207+
addi \cnt, \cnt, 8
208+
slli \a, \a, 8
209+
1:
210+
movi \tmp, __nsau_data
211+
extui \a, \a, 24, 8
212+
add \tmp, \tmp, \a
213+
l8ui \tmp, \tmp, 0
214+
add \cnt, \cnt, \tmp
215+
#endif /* !XCHAL_HAVE_NSA */
216+
.endm
217+
218+
.macro do_abs dst, src, tmp
219+
#if XCHAL_HAVE_ABS
220+
abs \dst, \src
221+
#else
222+
neg \tmp, \src
223+
movgez \tmp, \src, \src
224+
mov \dst, \tmp
225+
#endif
226+
.endm
195227

196228
#if defined(__XTENSA_WINDOWED_ABI__)
197229

arch/xtensa/include/asm/core.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@
3737
#endif
3838
#endif
3939

40+
/* Xtensa ABI requires stack alignment to be at least 16 */
41+
#if XCHAL_DATA_WIDTH > 16
42+
#define XTENSA_STACK_ALIGNMENT XCHAL_DATA_WIDTH
43+
#else
44+
#define XTENSA_STACK_ALIGNMENT 16
45+
#endif
46+
4047
#endif

arch/xtensa/include/asm/pci-bridge.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,4 @@ static inline void pcibios_init_resource(struct resource *res,
7373
res->child = NULL;
7474
}
7575

76-
77-
/* These are used for config access before all the PCI probing has been done. */
78-
int early_read_config_byte(struct pci_controller*, int, int, int, u8*);
79-
int early_read_config_word(struct pci_controller*, int, int, int, u16*);
80-
int early_read_config_dword(struct pci_controller*, int, int, int, u32*);
81-
int early_write_config_byte(struct pci_controller*, int, int, int, u8);
82-
int early_write_config_word(struct pci_controller*, int, int, int, u16);
83-
int early_write_config_dword(struct pci_controller*, int, int, int, u32);
84-
8576
#endif /* _XTENSA_PCI_BRIDGE_H */

arch/xtensa/include/asm/pgtable.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
412412

413413
typedef pte_t *pte_addr_t;
414414

415+
void update_mmu_tlb(struct vm_area_struct *vma,
416+
unsigned long address, pte_t *ptep);
417+
#define __HAVE_ARCH_UPDATE_MMU_TLB
418+
415419
#endif /* !defined (__ASSEMBLY__) */
416420

417421
#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG

arch/xtensa/include/asm/processor.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
#include <asm/types.h>
1919
#include <asm/regs.h>
2020

21-
/* Xtensa ABI requires stack alignment to be at least 16 */
22-
23-
#define STACK_ALIGN (XCHAL_DATA_WIDTH > 16 ? XCHAL_DATA_WIDTH : 16)
24-
25-
#define ARCH_SLAB_MINALIGN STACK_ALIGN
21+
#define ARCH_SLAB_MINALIGN XTENSA_STACK_ALIGNMENT
2622

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

240236
#define xtensa_set_sr(x, sr) \
241237
({ \
242-
unsigned int v = (unsigned int)(x); \
243-
__asm__ __volatile__ ("wsr %0, "__stringify(sr) :: "a"(v)); \
238+
__asm__ __volatile__ ("wsr %0, "__stringify(sr) :: \
239+
"a"((unsigned int)(x))); \
244240
})
245241

246242
#define xtensa_get_sr(sr) \

0 commit comments

Comments
 (0)