[PATCH v3 2/2] selftests/powerpc: Add a test of the switch_endian() syscall
This adds a test of the switch_endian() syscall we added in the previous commit. We test it by calling the endian switch syscall, and then executing some code in the other endian to check everything went as expected. That code checks registers we expect to be maintained are, and then writes to stdout. If the endian switch failed to happen that code sequence will be illegal and cause the test to abort. We then switch back to the original endian, do the same checks and finally write a success message and exit(0). Signed-off-by: Michael Ellerman --- v3: Have the test switch back to the original endian. tools/testing/selftests/powerpc/Makefile | 2 +- .../selftests/powerpc/switch_endian/Makefile | 23 + .../selftests/powerpc/switch_endian/check.S| 101 + .../selftests/powerpc/switch_endian/common.h | 6 ++ .../powerpc/switch_endian/switch_endian_test.S | 92 +++ 5 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/powerpc/switch_endian/Makefile create mode 100644 tools/testing/selftests/powerpc/switch_endian/check.S create mode 100644 tools/testing/selftests/powerpc/switch_endian/common.h create mode 100644 tools/testing/selftests/powerpc/switch_endian/switch_endian_test.S diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile index 1d5e7ad2c460..85c24a2210b5 100644 --- a/tools/testing/selftests/powerpc/Makefile +++ b/tools/testing/selftests/powerpc/Makefile @@ -13,7 +13,7 @@ CFLAGS := -Wall -O2 -flto -Wall -Werror -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CUR export CC CFLAGS -TARGETS = pmu copyloops mm tm primitives stringloops +TARGETS = pmu copyloops mm tm primitives stringloops switch_endian endif diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile new file mode 100644 index ..c7fefbf880b5 --- /dev/null +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile @@ -0,0 +1,23 @@ +PROGS := switch_endian_test + +ASFLAGS += -O2 -Wall -g -nostdlib -m64 + +all: $(PROGS) + +switch_endian_test: check-reversed.S + +check-reversed.o: check.o + objcopy -j .text --reverse-bytes=4 -O binary $< $@ + +check-reversed.S: check-reversed.o + hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@ + +run_tests: all + @-for PROG in $(PROGS); do \ + ./$$PROG; \ + done; + +clean: + rm -f $(PROGS) *.o check-reversed.S + +.PHONY: all run_tests clean diff --git a/tools/testing/selftests/powerpc/switch_endian/check.S b/tools/testing/selftests/powerpc/switch_endian/check.S new file mode 100644 index ..671d20ab9cf9 --- /dev/null +++ b/tools/testing/selftests/powerpc/switch_endian/check.S @@ -0,0 +1,101 @@ +#include "common.h" + +/* + * Checks that registers contain what we expect, ie. they were not clobbered by + * the syscall. If that all works we then print a message. + * + * r14: address of message to print (size is hardcoded at 25 bytes) + * r15: pattern to check registers against. + * + * At the end r3 == 0 if everything's OK. + */ + nop # guaranteed to be illegal in reverse-endian + cmpdr15,r3 + bne 1f + addir3,r15,4 + cmpdr3,r4 + bne 1f + lis r3,0x00FF + ori r3,r3,0xF000 + mfcrr4 + and r4,r4,r3 + cmpwr3,r4 + addir3,r15,34 + bne 1f + addir3,r15,32 + mflrr4 + cmpdr3,r4 + bne 1f + addir3,r15,5 + cmpdr3,r5 + bne 1f + addir3,r15,6 + cmpdr3,r6 + bne 1f + addir3,r15,7 + cmpdr3,r7 + bne 1f + addir3,r15,8 + cmpdr3,r8 + bne 1f + addir3,r15,13 + cmpdr3,r13 + bne 1f + addir3,r15,16 + cmpdr3,r16 + bne 1f + addir3,r15,17 + cmpdr3,r17 + bne 1f + addir3,r15,18 + cmpdr3,r18 + bne 1f + addir3,r15,19 + cmpdr3,r19 + bne 1f + addir3,r15,20 + cmpdr3,r20 + bne 1f + addir3,r15,21 + cmpdr3,r21 + bne 1f + addir3,r15,22 + cmpdr3,r22 + bne 1f + addir3,r15,23 + cmpdr3,r23 + bne 1f + addir3,r15,24 + cmpdr3,r24 + bne 1f + addir3,r15,25 + cmpdr3,r25 + bne 1f + addir3,r15,26 + cmpdr3,r26 + bne 1f + addir3,r15,27 + cmpdr3,r27 + bne 1f + addir3,r15,28 + cmpdr3,r28 + bne 1f + addir3,r15,29 + cmpdr3,r29 + bne 1f + addir3,r15,30 + cmpdr3,r30 + bne 1f + addir3,r15,31 + cmpdr3,r31 +
[PATCH v3 1/2] powerpc: Add a proper syscall for switching endianness
We currently have a "special" syscall for switching endianness. This is syscall number 0x1ebe, which is handled explicitly in the 64-bit syscall exception entry. That has a few problems, firstly the syscall number is outside of the usual range, which confuses various tools. For example strace doesn't recognise the syscall at all. Secondly it's handled explicitly as a special case in the syscall exception entry, which is complicated enough without it. As a first step toward removing the special syscall, we need to add a regular syscall that implements the same functionality. The logic is simple, it simply toggles the MSR_LE bit in the userspace MSR. This is the same as the special syscall, with the caveat that the special syscall clobbers fewer registers. This version clobbers r9-r12, XER, CTR, and CR0-1,5-7. Signed-off-by: Michael Ellerman --- v3: Don't provide the syscall on 32-bit. arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + arch/powerpc/kernel/entry_64.S | 5 + arch/powerpc/kernel/syscalls.c | 17 + arch/powerpc/kernel/systbl.S| 2 ++ arch/powerpc/kernel/systbl_chk.c| 2 ++ arch/powerpc/platforms/cell/spu_callbacks.c | 1 + 8 files changed, 30 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h index 91062eef582f..f1863a138b4a 100644 --- a/arch/powerpc/include/asm/systbl.h +++ b/arch/powerpc/include/asm/systbl.h @@ -367,3 +367,4 @@ SYSCALL_SPU(getrandom) SYSCALL_SPU(memfd_create) SYSCALL_SPU(bpf) COMPAT_SYS(execveat) +PPC64ONLY(switch_endian) diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h index 36b79c31eedd..f4f8b667d75b 100644 --- a/arch/powerpc/include/asm/unistd.h +++ b/arch/powerpc/include/asm/unistd.h @@ -12,7 +12,7 @@ #include -#define __NR_syscalls 363 +#define __NR_syscalls 364 #define __NR__exit __NR_exit #define NR_syscalls__NR_syscalls diff --git a/arch/powerpc/include/uapi/asm/unistd.h b/arch/powerpc/include/uapi/asm/unistd.h index ef5b5b1f3123..e4aa173dae62 100644 --- a/arch/powerpc/include/uapi/asm/unistd.h +++ b/arch/powerpc/include/uapi/asm/unistd.h @@ -385,5 +385,6 @@ #define __NR_memfd_create 360 #define __NR_bpf 361 #define __NR_execveat 362 +#define __NR_switch_endian 363 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */ diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S index d180caf2d6de..afbc20019c2e 100644 --- a/arch/powerpc/kernel/entry_64.S +++ b/arch/powerpc/kernel/entry_64.S @@ -356,6 +356,11 @@ _GLOBAL(ppc64_swapcontext) bl sys_swapcontext b .Lsyscall_exit +_GLOBAL(ppc_switch_endian) + bl save_nvgprs + bl sys_switch_endian + b .Lsyscall_exit + _GLOBAL(ret_from_fork) bl schedule_tail REST_NVGPRS(r1) diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c index b2702e87db0d..5fa92706444b 100644 --- a/arch/powerpc/kernel/syscalls.c +++ b/arch/powerpc/kernel/syscalls.c @@ -121,3 +121,20 @@ long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low, return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, (u64)len_high << 32 | len_low, advice); } + +long sys_switch_endian(void) +{ + struct thread_info *ti; + + current->thread.regs->msr ^= MSR_LE; + + /* +* Set TIF_RESTOREALL so that r3 isn't clobbered on return to +* userspace. That also has the effect of restoring the non-volatile +* GPRs, so we saved them on the way in here. +*/ + ti = current_thread_info(); + ti->flags |= _TIF_RESTOREALL; + + return 0; +} diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S index 7ab5d434e2ee..4d6b1d3a747f 100644 --- a/arch/powerpc/kernel/systbl.S +++ b/arch/powerpc/kernel/systbl.S @@ -22,6 +22,7 @@ #define PPC_SYS(func) .llong DOTSYM(ppc_##func),DOTSYM(ppc_##func) #define OLDSYS(func) .llong DOTSYM(sys_ni_syscall),DOTSYM(sys_ni_syscall) #define SYS32ONLY(func).llong DOTSYM(sys_ni_syscall),DOTSYM(compat_sys_##func) +#define PPC64ONLY(func).llong DOTSYM(ppc_##func),DOTSYM(sys_ni_syscall) #define SYSX(f, f3264, f32).llong DOTSYM(f),DOTSYM(f3264) #else #define SYSCALL(func) .long sys_##func @@ -29,6 +30,7 @@ #define PPC_SYS(func) .long ppc_##func #define OLDSYS(func) .long sys_##func #define SYS32ONLY(func).long sys_##func +#define PPC64ONLY(func).long sys_ni_syscall #define SYSX(f, f3264, f32).long f32 #endif #define SYSCALL_SPU(func) SYSCALL(func) diff --git a/arch/powerpc/kernel/systbl_chk.c b/arch/powerpc/ker
Re: linux panic on 4.0.0-rc4
On Mon, Mar 16, 2015 at 1:11 AM, Pranith Kumar wrote: > Hello, > > I have a power mac mini 32-bit system. > ... > You can see the panic message here: http://imgur.com/s1lH15g. (there > is no log and I have no serial console). There was some debug code in there when it hit. The actual hang seems to be in printk_late_init(). It does not return from this. May be this is a hint? Please let me know if you need more information to debug this. Thanks! > > Let me know if you need any more information. Config follows: > > # > # Automatically generated file; DO NOT EDIT. > # Linux/powerpc 4.0.0-rc4 Kernel Configuration > # > # CONFIG_PPC64 is not set > > # > # Processor support > # > CONFIG_PPC_BOOK3S_32=y > # CONFIG_PPC_85xx is not set > # CONFIG_PPC_8xx is not set > # CONFIG_40x is not set > # CONFIG_44x is not set > # CONFIG_E200 is not set > CONFIG_PPC_BOOK3S=y > CONFIG_6xx=y > CONFIG_PPC_FPU=y > CONFIG_ALTIVEC=y > CONFIG_PPC_STD_MMU=y > CONFIG_PPC_STD_MMU_32=y > # CONFIG_PPC_MM_SLICES is not set > CONFIG_PPC_HAVE_PMU_SUPPORT=y > CONFIG_PPC_PERF_CTRS=y > # CONFIG_SMP is not set > # CONFIG_PPC_DOORBELL is not set > CONFIG_CPU_BIG_ENDIAN=y > # CONFIG_CPU_LITTLE_ENDIAN is not set > CONFIG_PPC32=y > CONFIG_32BIT=y > CONFIG_WORD_SIZE=32 > # CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set > # CONFIG_ARCH_DMA_ADDR_T_64BIT is not set > CONFIG_MMU=y > # CONFIG_HAVE_SETUP_PER_CPU_AREA is not set > # CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK is not set > CONFIG_NR_IRQS=512 > CONFIG_STACKTRACE_SUPPORT=y > CONFIG_HAVE_LATENCYTOP_SUPPORT=y > CONFIG_TRACE_IRQFLAGS_SUPPORT=y > CONFIG_LOCKDEP_SUPPORT=y > CONFIG_RWSEM_XCHGADD_ALGORITHM=y > CONFIG_ARCH_HAS_ILOG2_U32=y > CONFIG_GENERIC_HWEIGHT=y > CONFIG_PPC=y > # CONFIG_GENERIC_CSUM is not set > CONFIG_EARLY_PRINTK=y > CONFIG_PANIC_TIMEOUT=0 > CONFIG_GENERIC_NVRAM=y > CONFIG_SCHED_OMIT_FRAME_POINTER=y > CONFIG_ARCH_MAY_HAVE_PC_FDC=y > CONFIG_PPC_OF=y > CONFIG_PPC_UDBG_16550=y > # CONFIG_GENERIC_TBSYNC is not set > CONFIG_AUDIT_ARCH=y > CONFIG_GENERIC_BUG=y > # CONFIG_EPAPR_BOOT is not set > # CONFIG_DEFAULT_UIMAGE is not set > CONFIG_ARCH_HIBERNATION_POSSIBLE=y > CONFIG_ARCH_SUSPEND_POSSIBLE=y > # CONFIG_PPC_DCR_NATIVE is not set > # CONFIG_PPC_DCR_MMIO is not set > CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y > CONFIG_ARCH_SUPPORTS_UPROBES=y > CONFIG_PPC_EMULATE_SSTEP=y > CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" > CONFIG_IRQ_WORK=y > > # > # General setup > # > CONFIG_BROKEN_ON_SMP=y > CONFIG_INIT_ENV_ARG_LIMIT=32 > CONFIG_CROSS_COMPILE="" > # CONFIG_COMPILE_TEST is not set > CONFIG_LOCALVERSION="" > # CONFIG_LOCALVERSION_AUTO is not set > CONFIG_DEFAULT_HOSTNAME="(none)" > CONFIG_SWAP=y > CONFIG_SYSVIPC=y > CONFIG_SYSVIPC_SYSCTL=y > CONFIG_POSIX_MQUEUE=y > CONFIG_POSIX_MQUEUE_SYSCTL=y > CONFIG_CROSS_MEMORY_ATTACH=y > CONFIG_FHANDLE=y > CONFIG_USELIB=y > CONFIG_AUDIT=y > CONFIG_HAVE_ARCH_AUDITSYSCALL=y > CONFIG_AUDITSYSCALL=y > CONFIG_AUDIT_WATCH=y > CONFIG_AUDIT_TREE=y > > # > # IRQ subsystem > # > CONFIG_GENERIC_IRQ_SHOW=y > CONFIG_GENERIC_IRQ_SHOW_LEVEL=y > CONFIG_IRQ_DOMAIN=y > CONFIG_GENERIC_MSI_IRQ=y > CONFIG_IRQ_FORCED_THREADING=y > CONFIG_SPARSE_IRQ=y > CONFIG_GENERIC_TIME_VSYSCALL_OLD=y > CONFIG_GENERIC_CLOCKEVENTS=y > CONFIG_GENERIC_CLOCKEVENTS_BUILD=y > CONFIG_GENERIC_CMOS_UPDATE=y > > # > # Timers subsystem > # > CONFIG_TICK_ONESHOT=y > CONFIG_NO_HZ_COMMON=y > # CONFIG_HZ_PERIODIC is not set > CONFIG_NO_HZ_IDLE=y > # CONFIG_NO_HZ is not set > CONFIG_HIGH_RES_TIMERS=y > > # > # CPU/Task time and stats accounting > # > CONFIG_TICK_CPU_ACCOUNTING=y > CONFIG_BSD_PROCESS_ACCT=y > CONFIG_BSD_PROCESS_ACCT_V3=y > CONFIG_TASKSTATS=y > CONFIG_TASK_DELAY_ACCT=y > CONFIG_TASK_XACCT=y > CONFIG_TASK_IO_ACCOUNTING=y > > # > # RCU Subsystem > # > CONFIG_TINY_RCU=y > CONFIG_SRCU=y > CONFIG_TASKS_RCU=y > # CONFIG_RCU_STALL_COMMON is not set > # CONFIG_TREE_RCU_TRACE is not set > CONFIG_RCU_KTHREAD_PRIO=0 > CONFIG_BUILD_BIN2C=y > CONFIG_IKCONFIG=m > # CONFIG_IKCONFIG_PROC is not set > CONFIG_LOG_BUF_SHIFT=17 > CONFIG_CGROUPS=y > # CONFIG_CGROUP_DEBUG is not set > CONFIG_CGROUP_FREEZER=y > CONFIG_CGROUP_DEVICE=y > CONFIG_CPUSETS=y > CONFIG_PROC_PID_CPUSET=y > CONFIG_CGROUP_CPUACCT=y > CONFIG_PAGE_COUNTER=y > CONFIG_MEMCG=y > CONFIG_MEMCG_SWAP=y > # CONFIG_MEMCG_SWAP_ENABLED is not set > CONFIG_CGROUP_PERF=y > CONFIG_CGROUP_SCHED=y > CONFIG_FAIR_GROUP_SCHED=y > # CONFIG_CFS_BANDWIDTH is not set > # CONFIG_RT_GROUP_SCHED is not set > CONFIG_BLK_CGROUP=y > # CONFIG_DEBUG_BLK_CGROUP is not set > CONFIG_CHECKPOINT_RESTORE=y > CONFIG_NAMESPACES=y > CONFIG_UTS_NS=y > CONFIG_IPC_NS=y > CONFIG_USER_NS=y > CONFIG_PID_NS=y > CONFIG_NET_NS=y > CONFIG_SCHED_AUTOGROUP=y > # CONFIG_SYSFS_DEPRECATED is not set > CONFIG_RELAY=y > CONFIG_BLK_DEV_INITRD=y > CONFIG_INITRAMFS_SOURCE="" > CONFIG_RD_GZIP=y > CONFIG_RD_BZIP2=y > CONFIG_RD_LZMA=y > CONFIG_RD_XZ=y > CONFIG_RD_LZO=y > CONFIG_RD_LZ4=y > # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set > CONFIG_SYSCTL=y > CONFIG_ANON_INODES=y > CONFIG_SYSCTL_EXCEPTIO
linux panic on 4.0.0-rc4
Hello, I have a power mac mini 32-bit system. I am getting a kernel panic with the latest rc kernel. The last kernel which worked on this which I remember booting was 3.19-rc5. You can see the panic message here: http://imgur.com/s1lH15g. (there is no log and I have no serial console). Let me know if you need any more information. Config follows: # # Automatically generated file; DO NOT EDIT. # Linux/powerpc 4.0.0-rc4 Kernel Configuration # # CONFIG_PPC64 is not set # # Processor support # CONFIG_PPC_BOOK3S_32=y # CONFIG_PPC_85xx is not set # CONFIG_PPC_8xx is not set # CONFIG_40x is not set # CONFIG_44x is not set # CONFIG_E200 is not set CONFIG_PPC_BOOK3S=y CONFIG_6xx=y CONFIG_PPC_FPU=y CONFIG_ALTIVEC=y CONFIG_PPC_STD_MMU=y CONFIG_PPC_STD_MMU_32=y # CONFIG_PPC_MM_SLICES is not set CONFIG_PPC_HAVE_PMU_SUPPORT=y CONFIG_PPC_PERF_CTRS=y # CONFIG_SMP is not set # CONFIG_PPC_DOORBELL is not set CONFIG_CPU_BIG_ENDIAN=y # CONFIG_CPU_LITTLE_ENDIAN is not set CONFIG_PPC32=y CONFIG_32BIT=y CONFIG_WORD_SIZE=32 # CONFIG_ARCH_PHYS_ADDR_T_64BIT is not set # CONFIG_ARCH_DMA_ADDR_T_64BIT is not set CONFIG_MMU=y # CONFIG_HAVE_SETUP_PER_CPU_AREA is not set # CONFIG_NEED_PER_CPU_EMBED_FIRST_CHUNK is not set CONFIG_NR_IRQS=512 CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y CONFIG_TRACE_IRQFLAGS_SUPPORT=y CONFIG_LOCKDEP_SUPPORT=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_ARCH_HAS_ILOG2_U32=y CONFIG_GENERIC_HWEIGHT=y CONFIG_PPC=y # CONFIG_GENERIC_CSUM is not set CONFIG_EARLY_PRINTK=y CONFIG_PANIC_TIMEOUT=0 CONFIG_GENERIC_NVRAM=y CONFIG_SCHED_OMIT_FRAME_POINTER=y CONFIG_ARCH_MAY_HAVE_PC_FDC=y CONFIG_PPC_OF=y CONFIG_PPC_UDBG_16550=y # CONFIG_GENERIC_TBSYNC is not set CONFIG_AUDIT_ARCH=y CONFIG_GENERIC_BUG=y # CONFIG_EPAPR_BOOT is not set # CONFIG_DEFAULT_UIMAGE is not set CONFIG_ARCH_HIBERNATION_POSSIBLE=y CONFIG_ARCH_SUSPEND_POSSIBLE=y # CONFIG_PPC_DCR_NATIVE is not set # CONFIG_PPC_DCR_MMIO is not set CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y CONFIG_ARCH_SUPPORTS_UPROBES=y CONFIG_PPC_EMULATE_SSTEP=y CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" CONFIG_IRQ_WORK=y # # General setup # CONFIG_BROKEN_ON_SMP=y CONFIG_INIT_ENV_ARG_LIMIT=32 CONFIG_CROSS_COMPILE="" # CONFIG_COMPILE_TEST is not set CONFIG_LOCALVERSION="" # CONFIG_LOCALVERSION_AUTO is not set CONFIG_DEFAULT_HOSTNAME="(none)" CONFIG_SWAP=y CONFIG_SYSVIPC=y CONFIG_SYSVIPC_SYSCTL=y CONFIG_POSIX_MQUEUE=y CONFIG_POSIX_MQUEUE_SYSCTL=y CONFIG_CROSS_MEMORY_ATTACH=y CONFIG_FHANDLE=y CONFIG_USELIB=y CONFIG_AUDIT=y CONFIG_HAVE_ARCH_AUDITSYSCALL=y CONFIG_AUDITSYSCALL=y CONFIG_AUDIT_WATCH=y CONFIG_AUDIT_TREE=y # # IRQ subsystem # CONFIG_GENERIC_IRQ_SHOW=y CONFIG_GENERIC_IRQ_SHOW_LEVEL=y CONFIG_IRQ_DOMAIN=y CONFIG_GENERIC_MSI_IRQ=y CONFIG_IRQ_FORCED_THREADING=y CONFIG_SPARSE_IRQ=y CONFIG_GENERIC_TIME_VSYSCALL_OLD=y CONFIG_GENERIC_CLOCKEVENTS=y CONFIG_GENERIC_CLOCKEVENTS_BUILD=y CONFIG_GENERIC_CMOS_UPDATE=y # # Timers subsystem # CONFIG_TICK_ONESHOT=y CONFIG_NO_HZ_COMMON=y # CONFIG_HZ_PERIODIC is not set CONFIG_NO_HZ_IDLE=y # CONFIG_NO_HZ is not set CONFIG_HIGH_RES_TIMERS=y # # CPU/Task time and stats accounting # CONFIG_TICK_CPU_ACCOUNTING=y CONFIG_BSD_PROCESS_ACCT=y CONFIG_BSD_PROCESS_ACCT_V3=y CONFIG_TASKSTATS=y CONFIG_TASK_DELAY_ACCT=y CONFIG_TASK_XACCT=y CONFIG_TASK_IO_ACCOUNTING=y # # RCU Subsystem # CONFIG_TINY_RCU=y CONFIG_SRCU=y CONFIG_TASKS_RCU=y # CONFIG_RCU_STALL_COMMON is not set # CONFIG_TREE_RCU_TRACE is not set CONFIG_RCU_KTHREAD_PRIO=0 CONFIG_BUILD_BIN2C=y CONFIG_IKCONFIG=m # CONFIG_IKCONFIG_PROC is not set CONFIG_LOG_BUF_SHIFT=17 CONFIG_CGROUPS=y # CONFIG_CGROUP_DEBUG is not set CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_DEVICE=y CONFIG_CPUSETS=y CONFIG_PROC_PID_CPUSET=y CONFIG_CGROUP_CPUACCT=y CONFIG_PAGE_COUNTER=y CONFIG_MEMCG=y CONFIG_MEMCG_SWAP=y # CONFIG_MEMCG_SWAP_ENABLED is not set CONFIG_CGROUP_PERF=y CONFIG_CGROUP_SCHED=y CONFIG_FAIR_GROUP_SCHED=y # CONFIG_CFS_BANDWIDTH is not set # CONFIG_RT_GROUP_SCHED is not set CONFIG_BLK_CGROUP=y # CONFIG_DEBUG_BLK_CGROUP is not set CONFIG_CHECKPOINT_RESTORE=y CONFIG_NAMESPACES=y CONFIG_UTS_NS=y CONFIG_IPC_NS=y CONFIG_USER_NS=y CONFIG_PID_NS=y CONFIG_NET_NS=y CONFIG_SCHED_AUTOGROUP=y # CONFIG_SYSFS_DEPRECATED is not set CONFIG_RELAY=y CONFIG_BLK_DEV_INITRD=y CONFIG_INITRAMFS_SOURCE="" CONFIG_RD_GZIP=y CONFIG_RD_BZIP2=y CONFIG_RD_LZMA=y CONFIG_RD_XZ=y CONFIG_RD_LZO=y CONFIG_RD_LZ4=y # CONFIG_CC_OPTIMIZE_FOR_SIZE is not set CONFIG_SYSCTL=y CONFIG_ANON_INODES=y CONFIG_SYSCTL_EXCEPTION_TRACE=y CONFIG_HAVE_PCSPKR_PLATFORM=y CONFIG_BPF=y CONFIG_EXPERT=y CONFIG_SGETMASK_SYSCALL=y CONFIG_SYSFS_SYSCALL=y # CONFIG_SYSCTL_SYSCALL is not set CONFIG_KALLSYMS=y CONFIG_KALLSYMS_ALL=y CONFIG_PRINTK=y CONFIG_BUG=y CONFIG_ELF_CORE=y CONFIG_PCSPKR_PLATFORM=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y CONFIG_EPOLL=y CONFIG_SIGNALFD=y CONFIG_TIMERFD=y CONFIG_EVENTFD=y CONFIG_BPF_SYSCALL=y CONFIG_SHMEM=y CONFIG_AIO=y CONFIG_ADVISE_SYSCALLS=y CONFIG_PCI_QUIRKS=y # CONFIG_EMBEDDED is not set CONFIG_HAVE_PERF_EVENTS=y # # Ke
Re: [RFC v0 PATCH] kvm: powerpc: Allow reuse of vCPU object
Any feedback on the below patch ? On Mon, Mar 9, 2015 at 11:00 AM, wrote: > From: Bharata B Rao > > Since KVM isn't equipped to handle closure of vcpu fd from userspace(QEMU) > correctly, certain work arounds have to be employed to allow reuse of > vcpu array slot in KVM during cpu hot plug/unplug from guest. One such > proposed workaround is to park the vcpu fd in userspace during cpu unplug > and reuse it later during next hotplug. > > More details can be found here: > KVM: https://www.mail-archive.com/kvm@vger.kernel.org/msg102839.html > QEMU: http://lists.gnu.org/archive/html/qemu-devel/2014-12/msg00859.html > > In order to support this workaround with PowerPC KVM, don't create or > initialize ICP if the vCPU is found to be already associated with an ICP. > > Signed-off-by: Bharata B Rao > --- > Note: It is not sure at the moment if "park vcpu and reuse" approach will > be acceptable to KVM/QEMU community, but nevertheless I wanted to check > if this little patch is harmful or not. > > arch/powerpc/kvm/book3s_xics.c | 9 +++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kvm/book3s_xics.c b/arch/powerpc/kvm/book3s_xics.c > index a4a8d9f..ead3a35 100644 > --- a/arch/powerpc/kvm/book3s_xics.c > +++ b/arch/powerpc/kvm/book3s_xics.c > @@ -1313,8 +1313,13 @@ int kvmppc_xics_connect_vcpu(struct kvm_device *dev, > struct kvm_vcpu *vcpu, > return -EPERM; > if (xics->kvm != vcpu->kvm) > return -EPERM; > - if (vcpu->arch.irq_type) > - return -EBUSY; > + > + /* > +* If irq_type is already set, don't reinialize but > +* return success allowing this vcpu to be reused. > +*/ > + if (vcpu->arch.irq_type != KVMPPC_IRQ_DEFAULT) > + return 0; > > r = kvmppc_xics_create_icp(vcpu, xcpu); > if (!r) > -- > 2.1.0 > -- http://raobharata.wordpress.com/ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] powerpc: Add a proper syscall for switching endianness
On Mon, 2015-03-16 at 11:07 +1100, Benjamin Herrenschmidt wrote: > On Mon, 2015-03-16 at 09:59 +1100, Tony Breeds wrote: > > On Fri, Mar 13, 2015 at 05:38:46PM +1100, Michael Ellerman wrote: > > > > > According to Paul there are no working implementations of LE on 32-bit > > > cpus, so > > > the syscall doesn't really make sense there. > > > > Ummm that doesn't sound right. I don't think there is an LE linux userspace > > but I'm pretty sure we had 32-bit working on 44x. Check where Ian did the > > initial LE patchset. > > Yes but that's done by using a per-page endian flag, not a global MSR > bit, so we never supported a syscall to switch there and never will. Yeah sorry, I should have said "implementations of MSR_LE on 32-bit cpus". We can always add a 32-bit version in future if we need to, but we can't remove it once it's there, so for now we won't do it on 32-bit. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] drivers/vfio: Support EEH error injection
On Fri, Mar 13, 2015 at 02:28:09PM -0600, Alex Williamson wrote: > On Thu, 2015-03-12 at 15:21 +1100, David Gibson wrote: > > On Thu, Mar 12, 2015 at 02:16:42PM +1100, Gavin Shan wrote: > > > On Thu, Mar 12, 2015 at 11:57:21AM +1100, David Gibson wrote: > > > >On Wed, Mar 11, 2015 at 05:34:11PM +1100, Gavin Shan wrote: > > > >> The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR) > > > >> to inject the specified EEH error, which is represented by > > > >> (struct vfio_eeh_pe_err), to the indicated PE for testing purpose. > > > >> > > > >> Signed-off-by: Gavin Shan > > > >> --- > > > >> Documentation/vfio.txt| 47 > > > >> ++- > > > >> drivers/vfio/vfio_spapr_eeh.c | 14 + > > > >> include/uapi/linux/vfio.h | 34 ++- > > > >> 3 files changed, 80 insertions(+), 15 deletions(-) > > > >> > > > >> diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt > > > >> index 96978ec..2e7f736 100644 > > > >> --- a/Documentation/vfio.txt > > > >> +++ b/Documentation/vfio.txt > > > >> @@ -328,7 +328,13 @@ So 4 additional ioctls have been added: > > > >> > > > >> The code flow from the example above should be slightly changed: > > > >> > > > >> - struct vfio_eeh_pe_op pe_op = { .argsz = sizeof(pe_op), .flags > > > >> = 0 }; > > > >> + struct vfio_eeh_pe_op *pe_op; > > > >> + struct vfio_eeh_pe_err *pe_err; > > > >> + > > > >> + pe_op = malloc(sizeof(*pe_op) + sizeof(*pe_err)); > > > >> + pe_err = (void *)pe_op + sizeof(*pe_op); > > > >> + pe_op->argsz = sizeof(*pe_op) + sizeof(*pe_err); > > > > > > > >Surely that argsz can't be correct for most of the operations. The > > > >extended structure should only be there for the error inject ioctl, > > > >yes? > > > > > > > > > > argsz isn't appropriate for most cases because kernel has the check > > > "expected_argsz < passed_argsz", not "expected_argsz == > > > passed_argsz". > > > > It works for now, but if any of those calls was extended with more > > data, it would break horribly. By setting the argsz greater than > > necessary, you're effectively passing uninitialized data to the > > ioctl(). At the moment, the ioctl() ignores it, but the whole point > > of the argsz value is that in the future, it might not. > > argsz tells us how much data the user is passing, we're always going to > need to figure out what the extra data is, so I don't really see the > point of this objection. In fact, it might make use of this interface > quite a bit easier if vfio_eeh_pe_op ended with a union including > vfio_eeh_pe_err. op == VFIO_EEH_PE_INJECT_ERR defines that the user has > passed vfio_eeh_pe_err in the union, other ops may add new unions later. *thinks* Yeah, I missed the fact that all these ioctls are using a common arguments structure. In which case, yes, absolutely the error field should be added to that structure rather than bolted on afterwards. A union is the obvious way to do that, but I think we should make sure to include a padding field in that union as well, so we've got some room to move if we both need to add other union options and add common things after the union in future. > -- David Gibson| I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson pgpSLpz3eXJWa.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC] powerpc: use ticket spin lock for !CONFIG_PPC_SPLPAR
On 13/03/15 18:14, Benjamin Herrenschmidt wrote: > On Fri, 2015-03-13 at 18:09 +1100, Michael Ellerman wrote: >> On Thu, 2015-03-12 at 22:13 +1100, Benjamin Herrenschmidt wrote: >>> On Thu, 2015-03-12 at 18:55 +0800, Kevin Hao wrote: I know Torsten Duwe has tried to add the ticket spinlock for powerpc one year ago [1]. But it make no progress due to the conflict between PPC_SPLPAR and lockref. We still don't find a better way to handle this. But instead of waiting forever for a perfect solution, can't we just use the ticket spinlock for the !CONFIG_PPC_SPLPAR? This is a very rough patch based on arm64 codes. I want to make sure that this is acceptable before going step further. This just passed build and boot test on a fsl t4240rdb board. I have done a simple performance benchmark by running the following command ten times before and after applying this patch: ./perf bench sched messaging BeforeAfter Averaged total time [sec]: 0.403 0.367 So we can see a ~9% performance enhancing. This patch depends on this one [2]. >>> >>> I would do the ifdef'ing differently, something like >>> >>> CONFIG_PPC_HAS_LOCK_OWNER >>> >>> CONFIG_PPC_TICKET_LOCKS depends on !PPC_HAS_LOCK_OWNER >>> >>> and use these two in the code... with SPLPAR select'ing HAS_LOCK_OWNER >> >> >> Sam was doing some work looking at CONFER, and I think so far he hasn't found >> that it is much of a benefit. Hopefully he can chime in with his >> observations. >> >> So the question is, should we just drop the directed CONFER and switch >> wholesale to ticket locks? Confer certainly helps in some situations, although I think it will be strongly workload and configuration dependent and I haven't tried to do much realistic testing. Also, being able to use confer depends on both knowing the lock owner and also that the lock owner's VCPU is not currently running (which is done via the yield count, which is also part of the lock token at the moment). With just the yield count we could still use an undirected confer (which might be almost as good as a directed one), but without it we would have to drop it entirely. >> We can still do CONFER on SPLPAR, we just tell the hypervisor we don't know >> who >> to confer to. >> >> There is still the drawback that we loose the lock owner for debugging, but >> that might be worth it. And I think you can get it back with appropriate >> debug >> options? > > Another possibility would be to change the order of the count and the > lock in lockref and defined it to be packed. That might allow us to have > our lock contain the ticket first and the count next and "fit" ... > >> cheers >> > > > ___ > Linuxppc-dev mailing list > Linuxppc-dev@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/linuxppc-dev > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] powerpc: Add a proper syscall for switching endianness
On Mon, 2015-03-16 at 09:59 +1100, Tony Breeds wrote: > On Fri, Mar 13, 2015 at 05:38:46PM +1100, Michael Ellerman wrote: > > > According to Paul there are no working implementations of LE on 32-bit > > cpus, so > > the syscall doesn't really make sense there. > > Ummm that doesn't sound right. I don't think there is an LE linux userspace > but I'm pretty sure we had 32-bit working on 44x. Check where Ian did the > initial LE patchset. Yes but that's done by using a per-page endian flag, not a global MSR bit, so we never supported a syscall to switch there and never will. Cheers, Ben. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCHv3] powerpc: convert relocs_check to a shell script using grep
On Sun, Mar 15, 2015 at 10:08:47PM +1100, Stephen Rothwell wrote: > This runs a bit faster and removes another use of perl from > the kernel build. > > Signed-off-by: Stephen Rothwell I only wrote it in perl because ... lazy. Kill it with fire. Acked-By: Tony Breeds Yours Tony. pgpPjZcz7Lh5E.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] powerpc: Add a proper syscall for switching endianness
On Fri, Mar 13, 2015 at 05:38:46PM +1100, Michael Ellerman wrote: > According to Paul there are no working implementations of LE on 32-bit cpus, > so > the syscall doesn't really make sense there. Ummm that doesn't sound right. I don't think there is an LE linux userspace but I'm pretty sure we had 32-bit working on 44x. Check where Ian did the initial LE patchset. Yours Tony. pgpSc3geHj_hd.pgp Description: PGP signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] drivers/vfio: Support EEH error injection
On Fri, Mar 13, 2015 at 02:35:18PM -0600, Alex Williamson wrote: >On Wed, 2015-03-11 at 17:34 +1100, Gavin Shan wrote: >> The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR) >> to inject the specified EEH error, which is represented by >> (struct vfio_eeh_pe_err), to the indicated PE for testing purpose. >> >> Signed-off-by: Gavin Shan >> --- >> Documentation/vfio.txt| 47 >> ++- >> drivers/vfio/vfio_spapr_eeh.c | 14 + >> include/uapi/linux/vfio.h | 34 ++- >> 3 files changed, 80 insertions(+), 15 deletions(-) >> >> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h >[snip] >> @@ -490,6 +499,29 @@ struct vfio_eeh_pe_op { >> #define VFIO_EEH_PE_RESET_HOT 6 /* Assert hot reset >> */ >> #define VFIO_EEH_PE_RESET_FUNDAMENTAL 7 /* Assert fundamental >> reset */ >> #define VFIO_EEH_PE_CONFIGURE 8 /* PE configuration >> */ >> +#define VFIO_EEH_PE_INJECT_ERR 9 /* Inject EEH error >> */ >> +#define VFIO_EEH_ERR_TYPE_32 0 /* 32-bits EEH error >> type*/ >> +#define VFIO_EEH_ERR_TYPE_64 1 /* 64-bits EEH error >> type*/ >> +#define VFIO_EEH_ERR_FUNC_LD_MEM_ADDR 0 /* Memory load >> */ >> +#define VFIO_EEH_ERR_FUNC_LD_MEM_DATA 1 >> +#define VFIO_EEH_ERR_FUNC_LD_IO_ADDR 2 /* IO load >> */ >> +#define VFIO_EEH_ERR_FUNC_LD_IO_DATA 3 >> +#define VFIO_EEH_ERR_FUNC_LD_CFG_ADDR 4 /* Config load >> */ >> +#define VFIO_EEH_ERR_FUNC_LD_CFG_DATA 5 >> +#define VFIO_EEH_ERR_FUNC_ST_MEM_ADDR 6 /* Memory store >> */ >> +#define VFIO_EEH_ERR_FUNC_ST_MEM_DATA 7 >> +#define VFIO_EEH_ERR_FUNC_ST_IO_ADDR 8 /* IO store >> */ >> +#define VFIO_EEH_ERR_FUNC_ST_IO_DATA 9 >> +#define VFIO_EEH_ERR_FUNC_ST_CFG_ADDR 10 /* Config store >> */ >> +#define VFIO_EEH_ERR_FUNC_ST_CFG_DATA 11 >> +#define VFIO_EEH_ERR_FUNC_DMA_RD_ADDR 12 /* DMA read >> */ >> +#define VFIO_EEH_ERR_FUNC_DMA_RD_DATA 13 >> +#define VFIO_EEH_ERR_FUNC_DMA_RD_MASTER14 >> +#define VFIO_EEH_ERR_FUNC_DMA_RD_TARGET15 >> +#define VFIO_EEH_ERR_FUNC_DMA_WR_ADDR 16 /* DMA write >> */ >> +#define VFIO_EEH_ERR_FUNC_DMA_WR_DATA 17 >> +#define VFIO_EEH_ERR_FUNC_DMA_WR_MASTER18 >> +#define VFIO_EEH_ERR_FUNC_DMA_WR_TARGET19 > >This data duplication from patch 1/2 is kind of concerning. In one case >we're adding to arch/powerpc/include/asm/eeh.h, which is a kernel >internal interface and entirely changeable, in the other we're matching >those current definitions in uapi, which needs to be stable. Are these >indexes part of a spec that we can rely on them being stable or do we >need some sort of translation layer to go from the vfio uapi defined >value to the kernel internal version? Thanks, > All those constants are defined by PAPR specification, and those constants defined here or by PATCH[1/2] aren't expected to be changed. Thanks, Gavin >Alex > > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] drivers/vfio: Support EEH error injection
On Fri, Mar 13, 2015 at 02:28:09PM -0600, Alex Williamson wrote: >On Thu, 2015-03-12 at 15:21 +1100, David Gibson wrote: >> On Thu, Mar 12, 2015 at 02:16:42PM +1100, Gavin Shan wrote: >> > On Thu, Mar 12, 2015 at 11:57:21AM +1100, David Gibson wrote: >> > >On Wed, Mar 11, 2015 at 05:34:11PM +1100, Gavin Shan wrote: >> > >> The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR) >> > >> to inject the specified EEH error, which is represented by >> > >> (struct vfio_eeh_pe_err), to the indicated PE for testing purpose. >> > >> >> > >> Signed-off-by: Gavin Shan >> > >> --- >> > >> Documentation/vfio.txt| 47 >> > >> ++- >> > >> drivers/vfio/vfio_spapr_eeh.c | 14 + >> > >> include/uapi/linux/vfio.h | 34 ++- >> > >> 3 files changed, 80 insertions(+), 15 deletions(-) >> > >> >> > >> diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt >> > >> index 96978ec..2e7f736 100644 >> > >> --- a/Documentation/vfio.txt >> > >> +++ b/Documentation/vfio.txt >> > >> @@ -328,7 +328,13 @@ So 4 additional ioctls have been added: >> > >> >> > >> The code flow from the example above should be slightly changed: >> > >> >> > >> - struct vfio_eeh_pe_op pe_op = { .argsz = sizeof(pe_op), .flags >> > >> = 0 }; >> > >> + struct vfio_eeh_pe_op *pe_op; >> > >> + struct vfio_eeh_pe_err *pe_err; >> > >> + >> > >> + pe_op = malloc(sizeof(*pe_op) + sizeof(*pe_err)); >> > >> + pe_err = (void *)pe_op + sizeof(*pe_op); >> > >> + pe_op->argsz = sizeof(*pe_op) + sizeof(*pe_err); >> > > >> > >Surely that argsz can't be correct for most of the operations. The >> > >extended structure should only be there for the error inject ioctl, >> > >yes? >> > > >> > >> > argsz isn't appropriate for most cases because kernel has the check >> > "expected_argsz < passed_argsz", not "expected_argsz == >> > passed_argsz". >> >> It works for now, but if any of those calls was extended with more >> data, it would break horribly. By setting the argsz greater than >> necessary, you're effectively passing uninitialized data to the >> ioctl(). At the moment, the ioctl() ignores it, but the whole point >> of the argsz value is that in the future, it might not. > >argsz tells us how much data the user is passing, we're always going to >need to figure out what the extra data is, so I don't really see the >point of this objection. In fact, it might make use of this interface >quite a bit easier if vfio_eeh_pe_op ended with a union including >vfio_eeh_pe_err. op == VFIO_EEH_PE_INJECT_ERR defines that the user has >passed vfio_eeh_pe_err in the union, other ops may add new unions later. >Thanks, > Ok. I'll have following data struct in next revision: struct vfio_eeh_pe_err { __u32 type; __u32 func; __u64 addr; __u64 mask; }; struct vfio_eeh_pe_op { __u32 argsz; __u32 flags; __u32 op; union { struct vfio_eeh_pe_err err; }; }; Thanks, Gavin >Alex > >> > However, I'll fix it as follows to avoid confusion after collecting >> > more comments: >> > >> >struct vfio_eeh_pe_op *pe_op; >> >struct vfio_eeh_pe_err *pe_err; >> > >> >/* For all cases except error injection */ >> >pe_op = malloc(sizeof(*pe_op)); >> >pe_op->argsz = sizeof(*pe_op); >> > >> >/* For error injection case here */ >> >pe_op = realloc(sizeof(*pe_op) + sizeof(*pe_err)); >> >pe_op->argsz = sizeof(*pe_op) + sizeof(*pe_err); >> >pe_err = (void *)pe_op + sizeof(*pe_op); >> > >> > Thanks, >> > Gavin >> > >> > >> > >> > > > ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/2] powerpc/eeh: Introduce eeh_pe_inject_err()
On Fri, Mar 13, 2015 at 02:28:33PM -0600, Alex Williamson wrote: >On Wed, 2015-03-11 at 17:34 +1100, Gavin Shan wrote: >> The patch defines PCI error types and functions in eeh.h and >> exports function eeh_pe_inject_err(), which will be called by >> VFIO driver to inject the specified PCI error to the indicated >> PE for testing purpose. >> >> Signed-off-by: Gavin Shan >> --- >> arch/powerpc/include/asm/eeh.h | 24 >> arch/powerpc/kernel/eeh.c | 63 >> ++ >> 2 files changed, 87 insertions(+) >> >> diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h >> index 9de87ce..eb20c62 100644 >> --- a/arch/powerpc/include/asm/eeh.h >> +++ b/arch/powerpc/include/asm/eeh.h >> @@ -196,6 +196,28 @@ enum { >> #define EEH_RESET_COMPLETE 4 /* PHB complete reset */ >> #define EEH_LOG_TEMP1 /* EEH temporary error log >> */ >> #define EEH_LOG_PERM2 /* EEH permanent error log >> */ >> +#define EEH_ERR_TYPE_32 0 /* 32-bits PCI error*/ >> +#define EEH_ERR_TYPE_64 1 /* 64-bits PCI error*/ >> +#define EEH_ERR_FUNC_LD_MEM_ADDR0 /* Memory load */ >> +#define EEH_ERR_FUNC_LD_MEM_DATA1 >> +#define EEH_ERR_FUNC_LD_IO_ADDR 2 /* IO load */ >> +#define EEH_ERR_FUNC_LD_IO_DATA 3 >> +#define EEH_ERR_FUNC_LD_CFG_ADDR4 /* Config load */ >> +#define EEH_ERR_FUNC_LD_CFG_DATA5 >> +#define EEH_ERR_FUNC_ST_MEM_ADDR6 /* Memory store */ >> +#define EEH_ERR_FUNC_ST_MEM_DATA7 >> +#define EEH_ERR_FUNC_ST_IO_ADDR 8 /* IO store */ >> +#define EEH_ERR_FUNC_ST_IO_DATA 9 >> +#define EEH_ERR_FUNC_ST_CFG_ADDR10 /* Config store */ >> +#define EEH_ERR_FUNC_ST_CFG_DATA11 >> +#define EEH_ERR_FUNC_DMA_RD_ADDR12 /* DMA read */ >> +#define EEH_ERR_FUNC_DMA_RD_DATA13 >> +#define EEH_ERR_FUNC_DMA_RD_MASTER 14 >> +#define EEH_ERR_FUNC_DMA_RD_TARGET 15 >> +#define EEH_ERR_FUNC_DMA_WR_ADDR16 /* DMA write*/ >> +#define EEH_ERR_FUNC_DMA_WR_DATA17 >> +#define EEH_ERR_FUNC_DMA_WR_MASTER 18 >> +#define EEH_ERR_FUNC_DMA_WR_TARGET 19 >> >> struct eeh_ops { >> char *name; >> @@ -296,6 +318,8 @@ int eeh_pe_set_option(struct eeh_pe *pe, int option); >> int eeh_pe_get_state(struct eeh_pe *pe); >> int eeh_pe_reset(struct eeh_pe *pe, int option); >> int eeh_pe_configure(struct eeh_pe *pe); >> +int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, >> + unsigned long addr, unsigned long mask); >> >> /** >> * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure. >> diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c >> index 60a0f15ce..dbab1a4 100644 >> --- a/arch/powerpc/kernel/eeh.c >> +++ b/arch/powerpc/kernel/eeh.c >> @@ -1657,6 +1657,69 @@ int eeh_pe_configure(struct eeh_pe *pe) >> } >> EXPORT_SYMBOL_GPL(eeh_pe_configure); >> >> +/** >> + * eeh_pe_inject_err - Injecting the specified PCI error to the indicated PE >> + * @pe: the indicated PE >> + * @type: error type >> + * @function: error function >> + * @addr: address >> + * @mask: address mask >> + * >> + * The routine is called to inject the specified PCI error, which >> + * is determined by @type and @function, to the indicated PE for >> + * testing purpose. >> + */ >> +int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func, >> + unsigned long addr, unsigned long mask) >> +{ >> +/* Invalid PE ? */ >> +if (!pe) >> +return -ENODEV; >> + >> +/* Unsupported operation ? */ >> +if (!eeh_ops || !eeh_ops->err_inject) >> +return -ENOENT; >> + >> +/* Check on PCI error type */ >> +switch (type) { >> +case EEH_ERR_TYPE_32: >> +case EEH_ERR_TYPE_64: >> +break; >> +default: >> +return -EINVAL; >> +} >> + >> +/* Check on PCI error function */ >> +switch (func) { >> +case EEH_ERR_FUNC_LD_MEM_ADDR: >> +case EEH_ERR_FUNC_LD_MEM_DATA: >> +case EEH_ERR_FUNC_LD_IO_ADDR: >> +case EEH_ERR_FUNC_LD_IO_DATA: >> +case EEH_ERR_FUNC_LD_CFG_ADDR: >> +case EEH_ERR_FUNC_LD_CFG_DATA: >> +case EEH_ERR_FUNC_ST_MEM_ADDR: >> +case EEH_ERR_FUNC_ST_MEM_DATA: >> +case EEH_ERR_FUNC_ST_IO_ADDR: >> +case EEH_ERR_FUNC_ST_IO_DATA: >> +case EEH_ERR_FUNC_ST_CFG_ADDR: >> +case EEH_ERR_FUNC_ST_CFG_DATA: >> +case EEH_ERR_FUNC_DMA_RD_ADDR: >> +case EEH_ERR_FUNC_DMA_RD_DATA: >> +case EEH_ERR_FUNC_DMA_RD_MASTER: >> +case EEH_ERR_FUNC_DMA_RD_TARGET: >> +case EEH_ERR_FUNC_DMA_WR_ADDR: >> +case EEH_ERR_FUNC_DMA_WR_DATA: >> +case EEH_ERR_FUNC_DMA_WR_MASTER: >> +case EEH_ERR_FUNC_DMA_WR_TARGET: >> +break; >> +default: >> +return -EINVAL; >> +} > >Potentially a good use case for an enum for both type and func. Then >you could clo
[PATCHv3] powerpc: convert relocs_check to a shell script using grep
This runs a bit faster and removes another use of perl from the kernel build. Signed-off-by: Stephen Rothwell --- v3: use $# instead of ${#*} (thanks David Laight) also added check on vmlinux and objdump v2: address ShellCheck comments from Michael arch/powerpc/Makefile| 4 +-- arch/powerpc/relocs_check.pl | 66 -- arch/powerpc/relocs_check.sh | 68 3 files changed, 70 insertions(+), 68 deletions(-) delete mode 100755 arch/powerpc/relocs_check.pl create mode 100755 arch/powerpc/relocs_check.sh diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 132d9c681d6a..1e868023b2c3 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -248,10 +248,10 @@ boot := arch/$(ARCH)/boot ifeq ($(CONFIG_RELOCATABLE),y) quiet_cmd_relocs_check = CALL$< - cmd_relocs_check = perl $< "$(OBJDUMP)" "$(obj)/vmlinux" + cmd_relocs_check = $(CONFIG_SHELL) $< "$(OBJDUMP)" "$(obj)/vmlinux" PHONY += relocs_check -relocs_check: arch/powerpc/relocs_check.pl vmlinux +relocs_check: arch/powerpc/relocs_check.sh vmlinux $(call cmd,relocs_check) zImage: relocs_check diff --git a/arch/powerpc/relocs_check.pl b/arch/powerpc/relocs_check.pl deleted file mode 100755 index 3f46e8b9c56d.. --- a/arch/powerpc/relocs_check.pl +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/perl - -# Copyright © 2009 IBM Corporation - -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version -# 2 of the License, or (at your option) any later version. - -# This script checks the relocations of a vmlinux for "suspicious" -# relocations. - -use strict; -use warnings; - -if ($#ARGV != 1) { - die "$0 [path to objdump] [path to vmlinux]\n"; -} - -# Have Kbuild supply the path to objdump so we handle cross compilation. -my $objdump = shift; -my $vmlinux = shift; -my $bad_relocs_count = 0; -my $bad_relocs = ""; -my $old_binutils = 0; - -open(FD, "$objdump -R $vmlinux|") or die; -while () { - study $_; - - # Only look at relocation lines. - next if (!/\s+R_/); - - # These relocations are okay - # On PPC64: - # R_PPC64_RELATIVE, R_PPC64_NONE, R_PPC64_ADDR64 - # On PPC: - # R_PPC_RELATIVE, R_PPC_ADDR16_HI, - # R_PPC_ADDR16_HA,R_PPC_ADDR16_LO, - # R_PPC_NONE - - next if (/\bR_PPC64_RELATIVE\b/ or /\bR_PPC64_NONE\b/ or -/\bR_PPC64_ADDR64\s+mach_/); - next if (/\bR_PPC_ADDR16_LO\b/ or /\bR_PPC_ADDR16_HI\b/ or -/\bR_PPC_ADDR16_HA\b/ or /\bR_PPC_RELATIVE\b/ or -/\bR_PPC_NONE\b/); - - # If we see this type of relocation it's an idication that - # we /may/ be using an old version of binutils. - if (/R_PPC64_UADDR64/) { - $old_binutils++; - } - - $bad_relocs_count++; - $bad_relocs .= $_; -} - -if ($bad_relocs_count) { - print "WARNING: $bad_relocs_count bad relocations\n"; - print $bad_relocs; -} - -if ($old_binutils) { - print "WARNING: You need at least binutils >= 2.19 to build a ". - "CONFIG_RELOCATABLE kernel\n"; -} diff --git a/arch/powerpc/relocs_check.sh b/arch/powerpc/relocs_check.sh new file mode 100755 index ..bdc5cc639569 --- /dev/null +++ b/arch/powerpc/relocs_check.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# Copyright © 2015 IBM Corporation + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version +# 2 of the License, or (at your option) any later version. + +# This script checks the relocations of a vmlinux for "suspicious" +# relocations. + +# based on relocs_check.pl +# Copyright © 2009 IBM Corporation + +if [ $# -lt 2 ]; then + echo "$0 [path to objdump] [path to vmlinux]" 1>&2 + exit 1 +fi + +# Have Kbuild supply the path to objdump so we handle cross compilation. +objdump="$1" +vmlinux="$2" + +if [ ! -x "$objdump" ]; then + echo "$0: objdump ($objdump) is not executable" 1>&2 + exit 1 +fi +if [ ! -r "$vmlinux" ]; then + echo "$0: vmlinux ($vmlinux) is not readable" 1>&2 + exit 1 +fi + +bad_relocs=$( +"$objdump" -R "$vmlinux" | + # Only look at relocation lines. + grep -E '\ + # On PPC: + # R_PPC_RELATIVE, R_PPC_ADDR16_HI, + # R_PPC_ADDR16_HA,R_PPC_ADDR16_LO, + # R_PPC_NONE + grep -F -w -v 'R_PPC64_RELATIVE +R_PPC64_NONE +R_PPC_ADDR16_LO +R_PPC_ADDR16_HI +R_PPC_ADDR16_HA +R_PPC_RELATIVE +R_PPC_NONE' | + grep -E -v '\= 2.19 to build a CONFIG_RELOCATABLE kernel" +fi -- 2.1.4 -- Cheers, Stephen Rothwells...@canb.auug.org.au pgp6gK_2RDNZI.pgp Description: OpenPGP digital signature _