Skip to content

Commit 85fb6da

Browse files
committed
Merge tag 'riscv-for-linus-7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: - Fix a CONFIG_SPARSEMEM crash on RV32 by avoiding early phys_to_page() - Prevent runtime const infrastructure from being used by modules, similar to what was done for x86 - Avoid problems when shutting down ACPI systems with IOMMUs by adding a device dependency between IOMMU and devices that use it - Fix a bug where the CPU pointer masking state isn't properly reset when tagged addresses aren't enabled for a task - Fix some incorrect register assignments, and add some missing ones, in kgdb support code - Fix compilation of non-kernel code that uses the ptrace uapi header by replacing BIT() with _BITUL() - Fix compilation of the validate_v_ptrace kselftest by working around kselftest macro expansion issues * tag 'riscv-for-linus-7.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: ACPI: RIMT: Add dependency between iommu and devices selftests: riscv: Add braces around EXPECT_EQ() riscv: use _BITUL macro rather than BIT() in ptrace uapi and kselftests riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set riscv: make runtime const not usable by modules riscv: patch: Avoid early phys_to_page() riscv: kgdb: fix several debug register assignment bugs
2 parents 10b76a4 + 9156585 commit 85fb6da

7 files changed

Lines changed: 47 additions & 28 deletions

File tree

arch/riscv/include/asm/runtime-const.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
#ifndef _ASM_RISCV_RUNTIME_CONST_H
33
#define _ASM_RISCV_RUNTIME_CONST_H
44

5+
#ifdef MODULE
6+
#error "Cannot use runtime-const infrastructure from modules"
7+
#endif
8+
59
#include <asm/asm.h>
610
#include <asm/alternative.h>
711
#include <asm/cacheflush.h>

arch/riscv/include/uapi/asm/ptrace.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef __ASSEMBLER__
1010

1111
#include <linux/types.h>
12+
#include <linux/const.h>
1213

1314
#define PTRACE_GETFDPIC 33
1415

@@ -138,12 +139,12 @@ struct __sc_riscv_cfi_state {
138139
#define PTRACE_CFI_SS_LOCK_BIT 4
139140
#define PTRACE_CFI_SS_PTR_BIT 5
140141

141-
#define PTRACE_CFI_LP_EN_STATE BIT(PTRACE_CFI_LP_EN_BIT)
142-
#define PTRACE_CFI_LP_LOCK_STATE BIT(PTRACE_CFI_LP_LOCK_BIT)
143-
#define PTRACE_CFI_ELP_STATE BIT(PTRACE_CFI_ELP_BIT)
144-
#define PTRACE_CFI_SS_EN_STATE BIT(PTRACE_CFI_SS_EN_BIT)
145-
#define PTRACE_CFI_SS_LOCK_STATE BIT(PTRACE_CFI_SS_LOCK_BIT)
146-
#define PTRACE_CFI_SS_PTR_STATE BIT(PTRACE_CFI_SS_PTR_BIT)
142+
#define PTRACE_CFI_LP_EN_STATE _BITUL(PTRACE_CFI_LP_EN_BIT)
143+
#define PTRACE_CFI_LP_LOCK_STATE _BITUL(PTRACE_CFI_LP_LOCK_BIT)
144+
#define PTRACE_CFI_ELP_STATE _BITUL(PTRACE_CFI_ELP_BIT)
145+
#define PTRACE_CFI_SS_EN_STATE _BITUL(PTRACE_CFI_SS_EN_BIT)
146+
#define PTRACE_CFI_SS_LOCK_STATE _BITUL(PTRACE_CFI_SS_LOCK_BIT)
147+
#define PTRACE_CFI_SS_PTR_STATE _BITUL(PTRACE_CFI_SS_PTR_BIT)
147148

148149
#define PRACE_CFI_STATE_INVALID_MASK ~(PTRACE_CFI_LP_EN_STATE | \
149150
PTRACE_CFI_LP_LOCK_STATE | \

arch/riscv/kernel/kgdb.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = {
175175
{DBG_REG_T1, GDB_SIZEOF_REG, offsetof(struct pt_regs, t1)},
176176
{DBG_REG_T2, GDB_SIZEOF_REG, offsetof(struct pt_regs, t2)},
177177
{DBG_REG_FP, GDB_SIZEOF_REG, offsetof(struct pt_regs, s0)},
178-
{DBG_REG_S1, GDB_SIZEOF_REG, offsetof(struct pt_regs, a1)},
178+
{DBG_REG_S1, GDB_SIZEOF_REG, offsetof(struct pt_regs, s1)},
179179
{DBG_REG_A0, GDB_SIZEOF_REG, offsetof(struct pt_regs, a0)},
180180
{DBG_REG_A1, GDB_SIZEOF_REG, offsetof(struct pt_regs, a1)},
181181
{DBG_REG_A2, GDB_SIZEOF_REG, offsetof(struct pt_regs, a2)},
@@ -244,8 +244,9 @@ sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task)
244244
gdb_regs[DBG_REG_S6_OFF] = task->thread.s[6];
245245
gdb_regs[DBG_REG_S7_OFF] = task->thread.s[7];
246246
gdb_regs[DBG_REG_S8_OFF] = task->thread.s[8];
247-
gdb_regs[DBG_REG_S9_OFF] = task->thread.s[10];
248-
gdb_regs[DBG_REG_S10_OFF] = task->thread.s[11];
247+
gdb_regs[DBG_REG_S9_OFF] = task->thread.s[9];
248+
gdb_regs[DBG_REG_S10_OFF] = task->thread.s[10];
249+
gdb_regs[DBG_REG_S11_OFF] = task->thread.s[11];
249250
gdb_regs[DBG_REG_EPC_OFF] = task->thread.ra;
250251
}
251252

arch/riscv/kernel/patch.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,20 @@ static inline bool is_kernel_exittext(uintptr_t addr)
4242
static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
4343
{
4444
uintptr_t uintaddr = (uintptr_t) addr;
45-
struct page *page;
45+
phys_addr_t phys;
4646

47-
if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr))
48-
page = phys_to_page(__pa_symbol(addr));
49-
else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX))
50-
page = vmalloc_to_page(addr);
51-
else
52-
return addr;
47+
if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) {
48+
phys = __pa_symbol(addr);
49+
} else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) {
50+
struct page *page = vmalloc_to_page(addr);
5351

54-
BUG_ON(!page);
52+
BUG_ON(!page);
53+
phys = page_to_phys(page) + offset_in_page(addr);
54+
} else {
55+
return addr;
56+
}
5557

56-
return (void *)set_fixmap_offset(fixmap, page_to_phys(page) +
57-
offset_in_page(addr));
58+
return (void *)set_fixmap_offset(fixmap, phys);
5859
}
5960

6061
static void patch_unmap(int fixmap)

arch/riscv/kernel/process.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
347347
if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen))
348348
return -EINVAL;
349349

350-
if (!(arg & PR_TAGGED_ADDR_ENABLE))
350+
if (!(arg & PR_TAGGED_ADDR_ENABLE)) {
351351
pmlen = PMLEN_0;
352+
pmm = ENVCFG_PMM_PMLEN_0;
353+
}
352354

353355
if (mmap_write_lock_killable(mm))
354356
return -EINTR;

drivers/acpi/riscv/rimt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ static int rimt_iommu_xlate(struct device *dev, struct acpi_rimt_node *node, u32
263263
if (!rimt_fwnode)
264264
return -EPROBE_DEFER;
265265

266+
/*
267+
* EPROBE_DEFER ensures IOMMU is probed before the devices that
268+
* depend on them. During shutdown, however, the IOMMU may be removed
269+
* first, leading to issues. To avoid this, a device link is added
270+
* which enforces the correct removal order.
271+
*/
272+
device_link_add(dev, rimt_fwnode->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
266273
return acpi_iommu_fwspec_init(dev, deviceid, rimt_fwnode);
267274
}
268275

tools/testing/selftests/riscv/vector/validate_v_ptrace.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,11 @@ TEST(ptrace_v_syscall_clobbering)
290290

291291
/* verify initial vsetvli settings */
292292

293-
if (is_xtheadvector_supported())
293+
if (is_xtheadvector_supported()) {
294294
EXPECT_EQ(5UL, regset_data->vtype);
295-
else
295+
} else {
296296
EXPECT_EQ(9UL, regset_data->vtype);
297+
}
297298

298299
EXPECT_EQ(regset_data->vlenb, regset_data->vl);
299300
EXPECT_EQ(vlenb, regset_data->vlenb);
@@ -346,8 +347,8 @@ FIXTURE_TEARDOWN(v_csr_invalid)
346347
{
347348
}
348349

349-
#define VECTOR_1_0 BIT(0)
350-
#define XTHEAD_VECTOR_0_7 BIT(1)
350+
#define VECTOR_1_0 _BITUL(0)
351+
#define XTHEAD_VECTOR_0_7 _BITUL(1)
351352

352353
#define vector_test(x) ((x) & VECTOR_1_0)
353354
#define xthead_test(x) ((x) & XTHEAD_VECTOR_0_7)
@@ -619,10 +620,11 @@ TEST_F(v_csr_invalid, ptrace_v_invalid_values)
619620

620621
/* verify initial vsetvli settings */
621622

622-
if (is_xtheadvector_supported())
623+
if (is_xtheadvector_supported()) {
623624
EXPECT_EQ(5UL, regset_data->vtype);
624-
else
625+
} else {
625626
EXPECT_EQ(9UL, regset_data->vtype);
627+
}
626628

627629
EXPECT_EQ(regset_data->vlenb, regset_data->vl);
628630
EXPECT_EQ(vlenb, regset_data->vlenb);
@@ -827,10 +829,11 @@ TEST_F(v_csr_valid, ptrace_v_valid_values)
827829

828830
/* verify initial vsetvli settings */
829831

830-
if (is_xtheadvector_supported())
832+
if (is_xtheadvector_supported()) {
831833
EXPECT_EQ(5UL, regset_data->vtype);
832-
else
834+
} else {
833835
EXPECT_EQ(9UL, regset_data->vtype);
836+
}
834837

835838
EXPECT_EQ(regset_data->vlenb, regset_data->vl);
836839
EXPECT_EQ(vlenb, regset_data->vlenb);

0 commit comments

Comments
 (0)