Commit 7f50d4df authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus' of https://github.com/openrisc/linux

Pull OpenRISC updates from Stafford Horne:

 - A few sparse warning fixups and other cleanups I noticed when working
   on a recent TLB bug found on a new OpenRISC core bring up.

 - A few fixup's from me and Jason A Donenfeld to help shutdown OpenRISC
   platforms when running CI tests

* tag 'for-linus' of https://github.com/openrisc/linux:
  openrisc: Allow power off handler overriding
  openrisc: Remove unused IMMU tlb workardound
  openrisc/fault: Fix symbol scope warnings
  openrisc/delay: Add include to fix symbol not declared warning
  openrisc/time: Fix symbol scope warnings
  openrisc/traps: Declare unhandled_exception for asmlinkage
  openrisc/traps: Remove die_if_kernel function
  openrisc/traps: Declare file scope symbols as static
  openrisc: Update litex defconfig to support glibc userland
  openrisc: Pretty print show_registers memory dumps
  openrisc: Add syscall details to emergency syscall debugging
  openrisc: Add support for liteuart emergency printing
  openrisc: Cleanup emergency print handling
  openrisc: Add gcc machine instruction flag configuration
  openrisc: define nop command for simulator reboot
  openrisc: remove bogus nops and shutdowns
  openrisc: fix typos in comments
parents ba62a537 83da38d8
...@@ -113,6 +113,59 @@ config OPENRISC_HAVE_INST_DIV ...@@ -113,6 +113,59 @@ config OPENRISC_HAVE_INST_DIV
default y default y
help help
Select this if your implementation has a hardware divide instruction Select this if your implementation has a hardware divide instruction
config OPENRISC_HAVE_INST_CMOV
bool "Have instruction l.cmov for conditional move"
default n
help
This config enables gcc to generate l.cmov instructions when compiling
the kernel which in general will improve performance and reduce the
binary size.
Select this if your implementation has support for the Class II
l.cmov conistional move instruction.
Say N if you are unsure.
config OPENRISC_HAVE_INST_ROR
bool "Have instruction l.ror for rotate right"
default n
help
This config enables gcc to generate l.ror instructions when compiling
the kernel which in general will improve performance and reduce the
binary size.
Select this if your implementation has support for the Class II
l.ror rotate right instruction.
Say N if you are unsure.
config OPENRISC_HAVE_INST_RORI
bool "Have instruction l.rori for rotate right with immediate"
default n
help
This config enables gcc to generate l.rori instructions when compiling
the kernel which in general will improve performance and reduce the
binary size.
Select this if your implementation has support for the Class II
l.rori rotate right with immediate instruction.
Say N if you are unsure.
config OPENRISC_HAVE_INST_SEXT
bool "Have instructions l.ext* for sign extension"
default n
help
This config enables gcc to generate l.ext* instructions when compiling
the kernel which in general will improve performance and reduce the
binary size.
Select this if your implementation has support for the Class II
l.exths, l.extbs, l.exthz and l.extbz size extend instructions.
Say N if you are unsure.
endmenu endmenu
config NR_CPUS config NR_CPUS
......
...@@ -21,6 +21,7 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S ...@@ -21,6 +21,7 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name) LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
KBUILD_CFLAGS += -pipe -ffixed-r10 -D__linux__ KBUILD_CFLAGS += -pipe -ffixed-r10 -D__linux__
KBUILD_CFLAGS += -msfimm -mshftimm
all: vmlinux.bin all: vmlinux.bin
...@@ -38,6 +39,22 @@ else ...@@ -38,6 +39,22 @@ else
KBUILD_CFLAGS += $(call cc-option,-msoft-div) KBUILD_CFLAGS += $(call cc-option,-msoft-div)
endif endif
ifeq ($(CONFIG_OPENRISC_HAVE_INST_CMOV),y)
KBUILD_CFLAGS += $(call cc-option,-mcmov)
endif
ifeq ($(CONFIG_OPENRISC_HAVE_INST_ROR),y)
KBUILD_CFLAGS += $(call cc-option,-mror)
endif
ifeq ($(CONFIG_OPENRISC_HAVE_INST_RORI),y)
KBUILD_CFLAGS += $(call cc-option,-mrori)
endif
ifeq ($(CONFIG_OPENRISC_HAVE_INST_SEXT),y)
KBUILD_CFLAGS += $(call cc-option,-msext)
endif
head-y := arch/openrisc/kernel/head.o head-y := arch/openrisc/kernel/head.o
libs-y += $(LIBGCC) libs-y += $(LIBGCC)
......
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_CGROUPS=y
CONFIG_NAMESPACES=y
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y CONFIG_BLK_DEV_INITRD=y
CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SGETMASK_SYSCALL=y
CONFIG_EMBEDDED=y CONFIG_EMBEDDED=y
CONFIG_OPENRISC_BUILTIN_DTB="or1klitex" CONFIG_OPENRISC_BUILTIN_DTB="or1klitex"
CONFIG_HZ_100=y CONFIG_HZ_100=y
CONFIG_OPENRISC_HAVE_SHADOW_GPRS=y
CONFIG_NET=y CONFIG_NET=y
CONFIG_PACKET=y CONFIG_PACKET=y
CONFIG_PACKET_DIAG=y
CONFIG_UNIX=y CONFIG_UNIX=y
CONFIG_UNIX_DIAG=y
CONFIG_INET=y CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_INET_UDP_DIAG=y
CONFIG_INET_RAW_DIAG=y
# CONFIG_WIRELESS is not set
# CONFIG_ETHTOOL_NETLINK is not set
CONFIG_DEVTMPFS=y CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y CONFIG_DEVTMPFS_MOUNT=y
CONFIG_OF_OVERLAY=y CONFIG_OF_OVERLAY=y
CONFIG_NETDEVICES=y CONFIG_NETDEVICES=y
CONFIG_LITEX_LITEETH=y CONFIG_LITEX_LITEETH=y
# CONFIG_WLAN is not set
CONFIG_SERIAL_LITEUART=y CONFIG_SERIAL_LITEUART=y
CONFIG_SERIAL_LITEUART_CONSOLE=y CONFIG_SERIAL_LITEUART_CONSOLE=y
CONFIG_TTY_PRINTK=y CONFIG_TTY_PRINTK=y
# CONFIG_GPIO_CDEV is not set
CONFIG_MMC=y
CONFIG_MMC_LITEX=y
# CONFIG_VHOST_MENU is not set
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_LITEX_SOC_CONTROLLER=y CONFIG_LITEX_SOC_CONTROLLER=y
CONFIG_EXT2_FS=y
CONFIG_EXT3_FS=y
CONFIG_MSDOS_FS=y
CONFIG_VFAT_FS=y
CONFIG_EXFAT_FS=y
CONFIG_TMPFS=y CONFIG_TMPFS=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ISO8859_1=y
CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity,bpf"
CONFIG_PRINTK_TIME=y CONFIG_PRINTK_TIME=y
CONFIG_PANIC_ON_OOPS=y CONFIG_PANIC_ON_OOPS=y
CONFIG_SOFTLOCKUP_DETECTOR=y CONFIG_SOFTLOCKUP_DETECTOR=y
......
...@@ -601,7 +601,7 @@ UNHANDLED_EXCEPTION(_vector_0xb00,0xb00) ...@@ -601,7 +601,7 @@ UNHANDLED_EXCEPTION(_vector_0xb00,0xb00)
*/ */
_string_syscall_return: _string_syscall_return:
.string "syscall return %ld \n\r\0" .string "syscall r9:0x%08x -> syscall(%ld) return %ld\0"
.align 4 .align 4
ENTRY(_sys_call_handler) ENTRY(_sys_call_handler)
...@@ -679,15 +679,25 @@ _syscall_return: ...@@ -679,15 +679,25 @@ _syscall_return:
_syscall_debug: _syscall_debug:
l.movhi r3,hi(_string_syscall_return) l.movhi r3,hi(_string_syscall_return)
l.ori r3,r3,lo(_string_syscall_return) l.ori r3,r3,lo(_string_syscall_return)
l.ori r27,r0,1 l.ori r27,r0,2
l.sw -4(r1),r27 l.sw -4(r1),r27
l.sw -8(r1),r11 l.sw -8(r1),r11
l.addi r1,r1,-8 l.lwz r29,PT_ORIG_GPR11(r1)
l.sw -12(r1),r29
l.lwz r29,PT_GPR9(r1)
l.sw -16(r1),r29
l.movhi r27,hi(_printk) l.movhi r27,hi(_printk)
l.ori r27,r27,lo(_printk) l.ori r27,r27,lo(_printk)
l.jalr r27 l.jalr r27
l.nop l.addi r1,r1,-16
l.addi r1,r1,8 l.addi r1,r1,16
#endif
#if 0
_syscall_show_regs:
l.movhi r27,hi(show_registers)
l.ori r27,r27,lo(show_registers)
l.jalr r27
l.or r3,r1,r1
#endif #endif
_syscall_check_trace_leave: _syscall_check_trace_leave:
......
This diff is collapsed.
...@@ -52,6 +52,8 @@ void machine_restart(char *cmd) ...@@ -52,6 +52,8 @@ void machine_restart(char *cmd)
{ {
do_kernel_restart(cmd); do_kernel_restart(cmd);
__asm__("l.nop 13");
/* Give a grace period for failure to restart of 1s */ /* Give a grace period for failure to restart of 1s */
mdelay(1000); mdelay(1000);
...@@ -60,6 +62,16 @@ void machine_restart(char *cmd) ...@@ -60,6 +62,16 @@ void machine_restart(char *cmd)
while (1); while (1);
} }
/*
* This is used if pm_power_off has not been set by a power management
* driver, in this case we can assume we are on a simulator. On
* OpenRISC simulators l.nop 1 will trigger the simulator exit.
*/
static void default_power_off(void)
{
__asm__("l.nop 1");
}
/* /*
* Similar to machine_power_off, but don't shut off power. Add code * Similar to machine_power_off, but don't shut off power. Add code
* here to freeze the system for e.g. post-mortem debug purpose when * here to freeze the system for e.g. post-mortem debug purpose when
...@@ -75,7 +87,10 @@ void machine_halt(void) ...@@ -75,7 +87,10 @@ void machine_halt(void)
void machine_power_off(void) void machine_power_off(void)
{ {
printk(KERN_INFO "*** MACHINE POWER OFF ***\n"); printk(KERN_INFO "*** MACHINE POWER OFF ***\n");
__asm__("l.nop 1"); if (pm_power_off != NULL)
pm_power_off();
else
default_power_off();
} }
/* /*
...@@ -89,7 +104,7 @@ void arch_cpu_idle(void) ...@@ -89,7 +104,7 @@ void arch_cpu_idle(void)
mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME); mtspr(SPR_PMR, mfspr(SPR_PMR) | SPR_PMR_DME);
} }
void (*pm_power_off) (void) = machine_power_off; void (*pm_power_off)(void) = NULL;
EXPORT_SYMBOL(pm_power_off); EXPORT_SYMBOL(pm_power_off);
/* /*
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/of_clk.h> #include <linux/of_clk.h>
#include <asm/cpuinfo.h> #include <asm/cpuinfo.h>
#include <asm/time.h>
/* Test the timer ticks to count, used in sync routine */ /* Test the timer ticks to count, used in sync routine */
inline void openrisc_timer_set(unsigned long count) inline void openrisc_timer_set(unsigned long count)
...@@ -61,7 +62,7 @@ static int openrisc_timer_set_next_event(unsigned long delta, ...@@ -61,7 +62,7 @@ static int openrisc_timer_set_next_event(unsigned long delta,
* timers) we cannot enable the PERIODIC feature. The tick timer can run using * timers) we cannot enable the PERIODIC feature. The tick timer can run using
* one-shot events, so no problem. * one-shot events, so no problem.
*/ */
DEFINE_PER_CPU(struct clock_event_device, clockevent_openrisc_timer); static DEFINE_PER_CPU(struct clock_event_device, clockevent_openrisc_timer);
void openrisc_clockevent_init(void) void openrisc_clockevent_init(void)
{ {
......
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
#include <asm/unwinder.h> #include <asm/unwinder.h>
#include <asm/sections.h> #include <asm/sections.h>
int kstack_depth_to_print = 0x180; static int kstack_depth_to_print = 0x180;
int lwa_flag; int lwa_flag;
unsigned long __user *lwa_addr; static unsigned long __user *lwa_addr;
void print_trace(void *data, unsigned long addr, int reliable) static void print_trace(void *data, unsigned long addr, int reliable)
{ {
const char *loglvl = data; const char *loglvl = data;
...@@ -46,6 +46,14 @@ void print_trace(void *data, unsigned long addr, int reliable) ...@@ -46,6 +46,14 @@ void print_trace(void *data, unsigned long addr, int reliable)
(void *) addr); (void *) addr);
} }
static void print_data(unsigned long base_addr, unsigned long word, int i)
{
if (i == 0)
printk("(%08lx:)\t%08lx", base_addr + (i * 4), word);
else
printk(" %08lx:\t%08lx", base_addr + (i * 4), word);
}
/* displays a short stack trace */ /* displays a short stack trace */
void show_stack(struct task_struct *task, unsigned long *esp, const char *loglvl) void show_stack(struct task_struct *task, unsigned long *esp, const char *loglvl)
{ {
...@@ -99,22 +107,36 @@ void show_registers(struct pt_regs *regs) ...@@ -99,22 +107,36 @@ void show_registers(struct pt_regs *regs)
printk("\nStack: "); printk("\nStack: ");
show_stack(NULL, (unsigned long *)esp, KERN_EMERG); show_stack(NULL, (unsigned long *)esp, KERN_EMERG);
if (esp < PAGE_OFFSET)
goto bad_stack;
printk("\n");
for (i = -8; i < 24; i += 1) {
unsigned long word;
if (__get_user(word, &((unsigned long *)esp)[i])) {
bad_stack:
printk(" Bad Stack value.");
break;
}
print_data(esp, word, i);
}
printk("\nCode: "); printk("\nCode: ");
if (regs->pc < PAGE_OFFSET) if (regs->pc < PAGE_OFFSET)
goto bad; goto bad;
for (i = -24; i < 24; i++) { for (i = -6; i < 6; i += 1) {
unsigned char c; unsigned long word;
if (__get_user(c, &((unsigned char *)regs->pc)[i])) {
if (__get_user(word, &((unsigned long *)regs->pc)[i])) {
bad: bad:
printk(" Bad PC value."); printk(" Bad PC value.");
break; break;
} }
if (i == 0) print_data(regs->pc, word, i);
printk("(%02x) ", c);
else
printk("%02x ", c);
} }
} }
printk("\n"); printk("\n");
...@@ -185,13 +207,11 @@ void nommu_dump_state(struct pt_regs *regs, ...@@ -185,13 +207,11 @@ void nommu_dump_state(struct pt_regs *regs,
printk("\nCode: "); printk("\nCode: ");
for (i = -24; i < 24; i++) { for (i = -24; i < 24; i++) {
unsigned char c; unsigned long word;
c = ((unsigned char *)(__pa(regs->pc)))[i];
word = ((unsigned long *)(__pa(regs->pc)))[i];
if (i == 0) print_data(regs->pc, word, i);
printk("(%02x) ", c);
else
printk("%02x ", c);
} }
printk("\n"); printk("\n");
} }
...@@ -215,16 +235,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, long err) ...@@ -215,16 +235,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, long err)
make_task_dead(SIGSEGV); make_task_dead(SIGSEGV);
} }
/* This is normally the 'Oops' routine */ asmlinkage void unhandled_exception(struct pt_regs *regs, int ea, int vector)
void die_if_kernel(const char *str, struct pt_regs *regs, long err)
{
if (user_mode(regs))
return;
die(str, regs, err);
}
void unhandled_exception(struct pt_regs *regs, int ea, int vector)
{ {
printk("Unable to handle exception at EA =0x%x, vector 0x%x", printk("Unable to handle exception at EA =0x%x, vector 0x%x",
ea, vector); ea, vector);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/timex.h>
#include <asm/param.h> #include <asm/param.h>
#include <asm/delay.h> #include <asm/delay.h>
#include <asm/timex.h> #include <asm/timex.h>
......
...@@ -18,15 +18,13 @@ ...@@ -18,15 +18,13 @@
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/mmu_context.h>
#include <asm/siginfo.h> #include <asm/siginfo.h>
#include <asm/signal.h> #include <asm/signal.h>
#define NUM_TLB_ENTRIES 64 #define NUM_TLB_ENTRIES 64
#define TLB_OFFSET(add) (((add) >> PAGE_SHIFT) & (NUM_TLB_ENTRIES-1)) #define TLB_OFFSET(add) (((add) >> PAGE_SHIFT) & (NUM_TLB_ENTRIES-1))
unsigned long pte_misses; /* updated by do_page_fault() */
unsigned long pte_errors; /* updated by do_page_fault() */
/* __PHX__ :: - check the vmalloc_fault in do_page_fault() /* __PHX__ :: - check the vmalloc_fault in do_page_fault()
* - also look into include/asm/mmu_context.h * - also look into include/asm/mmu_context.h
*/ */
...@@ -223,8 +221,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -223,8 +221,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
{ {
const struct exception_table_entry *entry; const struct exception_table_entry *entry;
__asm__ __volatile__("l.nop 42");
if ((entry = search_exception_tables(regs->pc)) != NULL) { if ((entry = search_exception_tables(regs->pc)) != NULL) {
/* Adjust the instruction pointer in the stackframe */ /* Adjust the instruction pointer in the stackframe */
regs->pc = entry->fixup; regs->pc = entry->fixup;
...@@ -252,9 +248,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -252,9 +248,6 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,
*/ */
out_of_memory: out_of_memory:
__asm__ __volatile__("l.nop 42");
__asm__ __volatile__("l.nop 1");
mmap_read_unlock(mm); mmap_read_unlock(mm);
if (!user_mode(regs)) if (!user_mode(regs))
goto no_context; goto no_context;
......
...@@ -128,7 +128,7 @@ void local_flush_tlb_mm(struct mm_struct *mm) ...@@ -128,7 +128,7 @@ void local_flush_tlb_mm(struct mm_struct *mm)
/* Was seeing bugs with the mm struct passed to us. Scrapped most of /* Was seeing bugs with the mm struct passed to us. Scrapped most of
this function. */ this function. */
/* Several architctures do this */ /* Several architectures do this */
local_flush_tlb_all(); local_flush_tlb_all();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment