Skip to content

Commit d46392b

Browse files
committed
Merge tag 'riscv-for-linus-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for cbo.zero in userspace - Support for CBOs on ACPI-based systems - A handful of improvements for the T-Head cache flushing ops - Support for software shadow call stacks - Various cleanups and fixes * tag 'riscv-for-linus-6.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (31 commits) RISC-V: hwprobe: Fix vDSO SIGSEGV riscv: configs: defconfig: Enable configs required for RZ/Five SoC riscv: errata: prefix T-Head mnemonics with th. riscv: put interrupt entries into .irqentry.text riscv: mm: Update the comment of CONFIG_PAGE_OFFSET riscv: Using TOOLCHAIN_HAS_ZIHINTPAUSE marco replace zihintpause riscv/mm: Fix the comment for swap pte format RISC-V: clarify the QEMU workaround in ISA parser riscv: correct pt_level name via pgtable_l5/4_enabled RISC-V: Provide pgtable_l5_enabled on rv32 clocksource: timer-riscv: Increase rating of clock_event_device for Sstc clocksource: timer-riscv: Don't enable/disable timer interrupt lkdtm: Fix CFI_BACKWARD on RISC-V riscv: Use separate IRQ shadow call stacks riscv: Implement Shadow Call Stack riscv: Move global pointer loading to a macro riscv: Deduplicate IRQ stack switching riscv: VMAP_STACK overflow detection thread-safe RISC-V: cacheflush: Initialize CBO variables on ACPI systems RISC-V: ACPI: RHCT: Add function to get CBO block sizes ...
2 parents 3052301 + e1c05b3 commit d46392b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+918
-298
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ The following keys are defined:
7777
* :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined
7878
in version 1.0 of the Bit-Manipulation ISA extensions.
7979

80+
* :c:macro:`RISCV_HWPROBE_EXT_ZICBOZ`: The Zicboz extension is supported, as
81+
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
82+
8083
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
8184
information about the selected set of processors.
8285

@@ -96,3 +99,6 @@ The following keys are defined:
9699

97100
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
98101
not supported at all and will generate a misaligned address fault.
102+
103+
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which
104+
represents the size of the Zicboz block in bytes.

arch/riscv/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ config RISCV
3939
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
4040
select ARCH_HAS_UBSAN_SANITIZE_ALL
4141
select ARCH_HAS_VDSO_DATA
42+
select ARCH_KEEP_MEMBLOCK if ACPI
4243
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
4344
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
4445
select ARCH_STACKWALK
@@ -48,6 +49,7 @@ config RISCV
4849
select ARCH_SUPPORTS_HUGETLBFS if MMU
4950
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
5051
select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
52+
select ARCH_SUPPORTS_SHADOW_CALL_STACK if HAVE_SHADOW_CALL_STACK
5153
select ARCH_USE_MEMTEST
5254
select ARCH_USE_QUEUED_RWLOCKS
5355
select ARCH_USES_CFI_TRAPS if CFI_CLANG
@@ -174,6 +176,11 @@ config GCC_SUPPORTS_DYNAMIC_FTRACE
174176
def_bool CC_IS_GCC
175177
depends on $(cc-option,-fpatchable-function-entry=8)
176178

179+
config HAVE_SHADOW_CALL_STACK
180+
def_bool $(cc-option,-fsanitize=shadow-call-stack)
181+
# https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769
182+
depends on $(ld-option,--no-relax-gp)
183+
177184
config ARCH_MMAP_RND_BITS_MIN
178185
default 18 if 64BIT
179186
default 8

arch/riscv/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ endif
5454
endif
5555
endif
5656

57+
ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
58+
KBUILD_LDFLAGS += --no-relax-gp
59+
endif
60+
5761
# ISA string setting
5862
riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
5963
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima

arch/riscv/configs/defconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ CONFIG_SMP=y
3737
CONFIG_HOTPLUG_CPU=y
3838
CONFIG_PM=y
3939
CONFIG_CPU_IDLE=y
40+
CONFIG_CPU_FREQ=y
41+
CONFIG_CPU_FREQ_STAT=y
42+
CONFIG_CPU_FREQ_GOV_POWERSAVE=m
43+
CONFIG_CPU_FREQ_GOV_USERSPACE=y
44+
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
45+
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=m
46+
CONFIG_CPUFREQ_DT=y
4047
CONFIG_VIRTUALIZATION=y
4148
CONFIG_KVM=m
4249
CONFIG_ACPI=y
@@ -95,13 +102,19 @@ CONFIG_NETLINK_DIAG=y
95102
CONFIG_CGROUP_NET_PRIO=y
96103
CONFIG_NET_9P=y
97104
CONFIG_NET_9P_VIRTIO=y
105+
CONFIG_CAN=m
98106
CONFIG_PCI=y
99107
CONFIG_PCIEPORTBUS=y
100108
CONFIG_PCI_HOST_GENERIC=y
101109
CONFIG_PCIE_XILINX=y
102110
CONFIG_PCIE_FU740=y
103111
CONFIG_DEVTMPFS=y
104112
CONFIG_DEVTMPFS_MOUNT=y
113+
CONFIG_MTD=y
114+
CONFIG_MTD_BLOCK=y
115+
CONFIG_MTD_CFI=y
116+
CONFIG_MTD_CFI_ADV_OPTIONS=y
117+
CONFIG_MTD_SPI_NOR=y
105118
CONFIG_BLK_DEV_LOOP=y
106119
CONFIG_VIRTIO_BLK=y
107120
CONFIG_BLK_DEV_NVME=m
@@ -124,8 +137,11 @@ CONFIG_VIRTIO_NET=y
124137
CONFIG_MACB=y
125138
CONFIG_E1000E=y
126139
CONFIG_R8169=y
140+
CONFIG_RAVB=y
127141
CONFIG_STMMAC_ETH=m
142+
CONFIG_MICREL_PHY=y
128143
CONFIG_MICROSEMI_PHY=y
144+
CONFIG_CAN_RCAR_CANFD=m
129145
CONFIG_INPUT_MOUSEDEV=y
130146
CONFIG_KEYBOARD_SUN4I_LRADC=m
131147
CONFIG_SERIAL_8250=y
@@ -136,56 +152,92 @@ CONFIG_SERIAL_SH_SCI=y
136152
CONFIG_VIRTIO_CONSOLE=y
137153
CONFIG_HW_RANDOM=y
138154
CONFIG_HW_RANDOM_VIRTIO=y
155+
CONFIG_I2C_CHARDEV=m
139156
CONFIG_I2C_MV64XXX=m
157+
CONFIG_I2C_RIIC=y
140158
CONFIG_SPI=y
159+
CONFIG_SPI_RSPI=m
141160
CONFIG_SPI_SIFIVE=y
142161
CONFIG_SPI_SUN6I=y
143162
# CONFIG_PTP_1588_CLOCK is not set
144163
CONFIG_GPIO_SIFIVE=y
164+
CONFIG_CPU_THERMAL=y
165+
CONFIG_DEVFREQ_THERMAL=y
166+
CONFIG_RZG2L_THERMAL=y
145167
CONFIG_WATCHDOG=y
146168
CONFIG_SUNXI_WATCHDOG=y
169+
CONFIG_RENESAS_RZG2LWDT=y
147170
CONFIG_REGULATOR=y
148171
CONFIG_REGULATOR_FIXED_VOLTAGE=y
172+
CONFIG_REGULATOR_GPIO=y
149173
CONFIG_DRM=m
150174
CONFIG_DRM_RADEON=m
151175
CONFIG_DRM_NOUVEAU=m
152176
CONFIG_DRM_SUN4I=m
153177
CONFIG_DRM_VIRTIO_GPU=m
154178
CONFIG_FB=y
155179
CONFIG_FRAMEBUFFER_CONSOLE=y
180+
CONFIG_SOUND=y
181+
CONFIG_SND=y
182+
CONFIG_SND_SOC=y
183+
CONFIG_SND_SOC_RZ=m
184+
CONFIG_SND_SOC_WM8978=m
185+
CONFIG_SND_SIMPLE_CARD=m
156186
CONFIG_USB=y
187+
CONFIG_USB_OTG=y
157188
CONFIG_USB_XHCI_HCD=y
158189
CONFIG_USB_XHCI_PLATFORM=y
159190
CONFIG_USB_EHCI_HCD=y
160191
CONFIG_USB_EHCI_HCD_PLATFORM=y
161192
CONFIG_USB_OHCI_HCD=y
162193
CONFIG_USB_OHCI_HCD_PLATFORM=y
194+
CONFIG_USB_RENESAS_USBHS=m
163195
CONFIG_USB_STORAGE=y
164196
CONFIG_USB_UAS=y
165197
CONFIG_USB_MUSB_HDRC=m
166198
CONFIG_USB_MUSB_SUNXI=m
167199
CONFIG_NOP_USB_XCEIV=m
200+
CONFIG_USB_GADGET=y
201+
CONFIG_USB_RENESAS_USBHS_UDC=m
202+
CONFIG_USB_CONFIGFS=m
203+
CONFIG_USB_CONFIGFS_SERIAL=y
204+
CONFIG_USB_CONFIGFS_ACM=y
205+
CONFIG_USB_CONFIGFS_OBEX=y
206+
CONFIG_USB_CONFIGFS_NCM=y
207+
CONFIG_USB_CONFIGFS_ECM=y
208+
CONFIG_USB_CONFIGFS_ECM_SUBSET=y
209+
CONFIG_USB_CONFIGFS_RNDIS=y
210+
CONFIG_USB_CONFIGFS_EEM=y
211+
CONFIG_USB_CONFIGFS_MASS_STORAGE=y
212+
CONFIG_USB_CONFIGFS_F_FS=y
168213
CONFIG_MMC=y
169214
CONFIG_MMC_SDHCI=y
170215
CONFIG_MMC_SDHCI_PLTFM=y
171216
CONFIG_MMC_SDHCI_CADENCE=y
172217
CONFIG_MMC_SPI=y
218+
CONFIG_MMC_SDHI=y
173219
CONFIG_MMC_SUNXI=y
174220
CONFIG_RTC_CLASS=y
175221
CONFIG_RTC_DRV_SUN6I=y
176222
CONFIG_DMADEVICES=y
177223
CONFIG_DMA_SUN6I=m
224+
CONFIG_RZ_DMAC=y
178225
CONFIG_VIRTIO_PCI=y
179226
CONFIG_VIRTIO_BALLOON=y
180227
CONFIG_VIRTIO_INPUT=y
181228
CONFIG_VIRTIO_MMIO=y
229+
CONFIG_RENESAS_OSTM=y
182230
CONFIG_SUN8I_DE2_CCU=m
183231
CONFIG_SUN50I_IOMMU=y
184232
CONFIG_RPMSG_CHAR=y
185233
CONFIG_RPMSG_CTRL=y
186234
CONFIG_RPMSG_VIRTIO=y
187235
CONFIG_ARCH_R9A07G043=y
236+
CONFIG_IIO=y
237+
CONFIG_RZG2L_ADC=m
238+
CONFIG_RESET_RZG2L_USBPHY_CTRL=y
188239
CONFIG_PHY_SUN4I_USB=m
240+
CONFIG_PHY_RCAR_GEN3_USB2=y
189241
CONFIG_LIBNVDIMM=y
190242
CONFIG_NVMEM_SUNXI_SID=y
191243
CONFIG_EXT4_FS=y

arch/riscv/include/asm/acpi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,
6666
unsigned int cpu, const char **isa);
6767

6868
static inline int acpi_numa_get_nid(unsigned int cpu) { return NUMA_NO_NODE; }
69+
void acpi_get_cbo_block_size(struct acpi_table_header *table, u32 *cbom_size,
70+
u32 *cboz_size, u32 *cbop_size);
6971
#else
7072
static inline void acpi_init_rintc_map(void) { }
7173
static inline struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu)
@@ -79,6 +81,10 @@ static inline int acpi_get_riscv_isa(struct acpi_table_header *table,
7981
return -EINVAL;
8082
}
8183

84+
static inline void acpi_get_cbo_block_size(struct acpi_table_header *table,
85+
u32 *cbom_size, u32 *cboz_size,
86+
u32 *cbop_size) { }
87+
8288
#endif /* CONFIG_ACPI */
8389

8490
#endif /*_ASM_ACPI_H*/

arch/riscv/include/asm/asm-prototypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ DECLARE_DO_ERROR_INFO(do_trap_ecall_s);
2525
DECLARE_DO_ERROR_INFO(do_trap_ecall_m);
2626
DECLARE_DO_ERROR_INFO(do_trap_break);
2727

28-
asmlinkage unsigned long get_overflow_stack(void);
2928
asmlinkage void handle_bad_stack(struct pt_regs *regs);
3029
asmlinkage void do_page_fault(struct pt_regs *regs);
3130
asmlinkage void do_irq(struct pt_regs *regs);

arch/riscv/include/asm/asm.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,47 @@
8282
.endr
8383
.endm
8484

85+
#ifdef CONFIG_SMP
86+
#ifdef CONFIG_32BIT
87+
#define PER_CPU_OFFSET_SHIFT 2
88+
#else
89+
#define PER_CPU_OFFSET_SHIFT 3
90+
#endif
91+
92+
.macro asm_per_cpu dst sym tmp
93+
REG_L \tmp, TASK_TI_CPU_NUM(tp)
94+
slli \tmp, \tmp, PER_CPU_OFFSET_SHIFT
95+
la \dst, __per_cpu_offset
96+
add \dst, \dst, \tmp
97+
REG_L \tmp, 0(\dst)
98+
la \dst, \sym
99+
add \dst, \dst, \tmp
100+
.endm
101+
#else /* CONFIG_SMP */
102+
.macro asm_per_cpu dst sym tmp
103+
la \dst, \sym
104+
.endm
105+
#endif /* CONFIG_SMP */
106+
107+
.macro load_per_cpu dst ptr tmp
108+
asm_per_cpu \dst \ptr \tmp
109+
REG_L \dst, 0(\dst)
110+
.endm
111+
112+
#ifdef CONFIG_SHADOW_CALL_STACK
113+
/* gp is used as the shadow call stack pointer instead */
114+
.macro load_global_pointer
115+
.endm
116+
#else
117+
/* load __global_pointer to gp */
118+
.macro load_global_pointer
119+
.option push
120+
.option norelax
121+
la gp, __global_pointer$
122+
.option pop
123+
.endm
124+
#endif /* CONFIG_SHADOW_CALL_STACK */
125+
85126
/* save all GPs except x1 ~ x5 */
86127
.macro save_from_x6_to_x31
87128
REG_S x6, PT_T1(sp)

arch/riscv/include/asm/cpufeature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@ DECLARE_PER_CPU(long, misaligned_access_speed);
3131
extern struct riscv_isainfo hart_isa[NR_CPUS];
3232

3333
void check_unaligned_access(int cpu);
34+
void riscv_user_isa_enable(void);
3435

3536
#endif

arch/riscv/include/asm/errata_list.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,25 @@ asm volatile(ALTERNATIVE( \
9595
#endif
9696

9797
/*
98-
* dcache.ipa rs1 (invalidate, physical address)
98+
* th.dcache.ipa rs1 (invalidate, physical address)
9999
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
100100
* 0000001 01010 rs1 000 00000 0001011
101-
* dache.iva rs1 (invalida, virtual address)
101+
* th.dache.iva rs1 (invalida, virtual address)
102102
* 0000001 00110 rs1 000 00000 0001011
103103
*
104-
* dcache.cpa rs1 (clean, physical address)
104+
* th.dcache.cpa rs1 (clean, physical address)
105105
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
106106
* 0000001 01001 rs1 000 00000 0001011
107-
* dcache.cva rs1 (clean, virtual address)
107+
* th.dcache.cva rs1 (clean, virtual address)
108108
* 0000001 00101 rs1 000 00000 0001011
109109
*
110-
* dcache.cipa rs1 (clean then invalidate, physical address)
110+
* th.dcache.cipa rs1 (clean then invalidate, physical address)
111111
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
112112
* 0000001 01011 rs1 000 00000 0001011
113-
* dcache.civa rs1 (... virtual address)
113+
* th.dcache.civa rs1 (... virtual address)
114114
* 0000001 00111 rs1 000 00000 0001011
115115
*
116-
* sync.s (make sure all cache operations finished)
116+
* th.sync.s (make sure all cache operations finished)
117117
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
118118
* 0000000 11001 00000 000 00000 0001011
119119
*/

arch/riscv/include/asm/hwcap.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#ifndef __ASSEMBLY__
7373

7474
#include <linux/jump_label.h>
75+
#include <asm/cpufeature.h>
7576

7677
unsigned long riscv_get_elf_hwcap(void);
7778

@@ -139,6 +140,21 @@ riscv_has_extension_unlikely(const unsigned long ext)
139140
return true;
140141
}
141142

143+
static __always_inline bool riscv_cpu_has_extension_likely(int cpu, const unsigned long ext)
144+
{
145+
if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_likely(ext))
146+
return true;
147+
148+
return __riscv_isa_extension_available(hart_isa[cpu].isa, ext);
149+
}
150+
151+
static __always_inline bool riscv_cpu_has_extension_unlikely(int cpu, const unsigned long ext)
152+
{
153+
if (IS_ENABLED(CONFIG_RISCV_ALTERNATIVE) && riscv_has_extension_unlikely(ext))
154+
return true;
155+
156+
return __riscv_isa_extension_available(hart_isa[cpu].isa, ext);
157+
}
142158
#endif
143159

144160
#endif /* _ASM_RISCV_HWCAP_H */

0 commit comments

Comments
 (0)