Skip to content

Instantly share code, notes, and snippets.

@nathanchance
Created February 10, 2020 06:59
Show Gist options
  • Save nathanchance/58381497a3d351551d829e11bc1d58f3 to your computer and use it in GitHub Desktop.
Save nathanchance/58381497a3d351551d829e11bc1d58f3 to your computer and use it in GitHub Desktop.
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index b9009a2fbaf5..e6d261f00bcc 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -42,7 +42,9 @@ riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
KBUILD_AFLAGS += -march=$(riscv-march-y)
+ifndef CONFIG_CC_IS_CLANG
KBUILD_CFLAGS += -mno-save-restore
+endif
KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
ifeq ($(CONFIG_CMODEL_MEDLOW),y)
diff --git a/arch/riscv/configs/defconfig b/arch/riscv/configs/defconfig
index e2ff95cb3390..19ca91c329cf 100644
--- a/arch/riscv/configs/defconfig
+++ b/arch/riscv/configs/defconfig
@@ -16,8 +16,6 @@ CONFIG_EXPERT=y
CONFIG_BPF_SYSCALL=y
CONFIG_SOC_SIFIVE=y
CONFIG_SMP=y
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
diff --git a/arch/riscv/include/asm/current.h b/arch/riscv/include/asm/current.h
index dd973efe5d7c..c0e7b3d76bb1 100644
--- a/arch/riscv/include/asm/current.h
+++ b/arch/riscv/include/asm/current.h
@@ -24,9 +24,9 @@ struct task_struct;
* <asm/asm-offsets.h> includes this, and I can't get the definition of "struct
* task_struct" here due to some header ordering problems.
*/
+register struct task_struct *tp __asm__("tp");
static __always_inline struct task_struct *get_current(void)
{
- register struct task_struct *tp __asm__("tp");
return tp;
}
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index 817cf7b0974c..b5ed942c333c 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -99,6 +99,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
return 0;
}
+const register unsigned long gp __asm__ ("gp");
int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
unsigned long arg, struct task_struct *p, unsigned long tls)
{
@@ -107,7 +108,6 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
/* p->thread holds context to be restored by __switch_to() */
if (unlikely(p->flags & PF_KTHREAD)) {
/* Kernel thread */
- const register unsigned long gp __asm__ ("gp");
memset(childregs, 0, sizeof(struct pt_regs));
childregs->gp = gp;
/* Supervisor/Machine, irqs on: */
diff --git a/arch/riscv/kernel/stacktrace.c b/arch/riscv/kernel/stacktrace.c
index 0940681d2f68..45034c4be928 100644
--- a/arch/riscv/kernel/stacktrace.c
+++ b/arch/riscv/kernel/stacktrace.c
@@ -19,6 +19,7 @@ struct stackframe {
unsigned long ra;
};
+const register unsigned long current_sp __asm__ ("sp");
void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
bool (*fn)(unsigned long, void *), void *arg)
{
@@ -29,7 +30,6 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
sp = user_stack_pointer(regs);
pc = instruction_pointer(regs);
} else if (task == NULL || task == current) {
- const register unsigned long current_sp __asm__ ("sp");
fp = (unsigned long)__builtin_frame_address(0);
sp = current_sp;
pc = (unsigned long)walk_stackframe;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment