Commit graph

201441 commits

Author SHA1 Message Date
Michal Simek 2d5973cb5a microblaze: Add KGDB support
Kgdb uses brki r16, 0x18 instruction to call
low level _debug_exception function which save
current state to pt_regs and call microblaze_kgdb_break
function. _debug_exception should be called only from
the kernel space. User space calling is not supported
because user application debugging uses different handling.

pt_regs_to_gdb_regs loads additional special registers
which can't be changed

 * Enable KGDB in Kconfig
 * Remove ancient not-tested KGDB support
 * Remove ancient _debug_exception code from entry.S

Only MMU KGDB support is supported.

Signed-off-by: Michal Simek <monstr@monstr.eu>
CC: Jason Wessel <jason.wessel@windriver.com>
CC: John Williams <john.williams@petalogix.com>
CC: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
CC: linux-kernel@vger.kernel.org
Acked-by: Jason Wessel <jason.wessel@windriver.com>
2010-08-04 10:45:17 +02:00
Michal Simek 751f1605e0 microblaze: Support brki rX, 0x18 for user application debugging
This is the first patch which add support for
user application debugging through brki rX, 0x18 vector.

This patch has side effect which also remove security issue
to use brki rX, 0x18 to freeze kernel.

Support for old gdb support via priviledged exception
(brk r0, r0) is still there. It will be remove in future.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:16 +02:00
Michal Simek 958063e67b microblaze: Remove nop after MSRCLR/SET, MTS, MFS instructions
We need to save instruction and the latest Microblaze shouldn't
have any problem with it.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:16 +02:00
Michal Simek 0e41c90908 microblaze: Simplify syscall rutine
Syscall can be called only from userspace that's why
we don't need to check which space kernel come from.

Kernel syscall calling is not check and shouldn't come
throught this part of code.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:15 +02:00
Michal Simek 0a6b08fda6 microblaze: Move PT_MODE saving to delay slot
We can save one more instruction if PT_MODE is saved in delay slot

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:14 +02:00
Michal Simek 80c5ff6b9b microblaze: Fix _interrupt function
Save instructions by using delay slot and
clear UMS only if kernel comes from user space.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:13 +02:00
Michal Simek 25f6e59657 microblaze: Fix _user_exception function
Saving some instructions. Clear VMS bit if kernel comes
from kernel space.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:45:12 +02:00
Michal Simek 287503fabd microblaze: Put together addik instructions
Saving instructions by adding 2/3 addik instructions to one.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:44:56 +02:00
Michal Simek 9814cc11e5 microblaze: Use delay slot in syscall macros
Saving instruction with delay slot usage.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:32:22 +02:00
Michal Simek da23355280 microblaze: Save kernel mode in delay slot
This change save one instruction if kernel comes from kernel
space.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:32:21 +02:00
Michal Simek e7741075b3 microblaze: Do not mix register saving and mode setting
Separate reg saving and mode setting.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:32:20 +02:00
Michal Simek e5d2af2b96 microblaze: Move SAVE_STATE upward
SAVE_STATE macro could be used by other rutines too.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:31:09 +02:00
Michal Simek 66f7de8634 microblaze: entry.S: Macro optimization
We are not working with values from MSR that's why
we can discard it and use r11 for different purpose without
saving/restoring.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:30:07 +02:00
Michal Simek c318d483b3 microblaze: Optimize hw exception rutine
Remove set_vms because UMS is cleared and VMS is already setup.
Optimize function calling which save one additional instruction.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:30:06 +02:00
Michal Simek b318067e2c microblaze: Implement clear_ums macro and fix SAVE_STATE macro
VMS is always setup because VM mode was before
exception/syscall/interrupt. Kernel continues in kernel mode
that's why we have to clear UMS bit if kernel comes from
user space.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:29:44 +02:00
Michal Simek 77f6d22605 microblaze: Remove additional setup for kernel_mode
PT_MODE stores information if kernel comes from user
or kernel space. If come from user space, PT_MODE
contains 0. If come from kernel store, PT_MODE contains
non zero value. We don't need to save value 1. I am using
r1 register which contains non zero value.
This change save one additional instruction.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:53 +02:00
Michal Simek 06a54604a3 microblaze: Optimize SAVE_STATE macro
SAVE_STATE macro could be used for user_exception
or interrupt functions.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:52 +02:00
Michal Simek 40eb0dc456 microblaze: Remove additional loading
We don't need to save r0 to PT_R0. It could be additional
operation.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:51 +02:00
Michal Simek 653e447e11 microblaze: Completely remove working with R11 register
We don't need to save R11 register. There is easy way
to use only R1 which is saved and restore later.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:50 +02:00
Michal Simek 0388107dd5 microblaze: Do not setup BIP in _debug_exception
BIP is already setup.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:50 +02:00
Michal Simek 06b2864038 microblaze: Simplify _debug_exception function
Keep together all arguments for send_sig function.
Move returning address to delay slot which is executed.
Remove additional send_sig loading. I am using IMM part of
rtbd instruction with r0.

old solution:
addik r11, r0, send_sig
rtbd r11, 0
nop

new solution:
rtbd r0, send_sig
nop

There is one instruction saving.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:48 +02:00
Michal Simek 8b110d157c microblaze: Optimize SAVE_STATE macro
It is necessary to setup BIP and EE and clear EIP
only for unaligned exception handler. The rest of
hw exception handlers don't require it.
HW exception occured and we are not in virtual mode.
That's why we can do operations protected by EIP.
Interrupt, next hw exception or syscall can't occur.

EIP is cleared by rted.

This change speedup page_fault hw exception handler
which is critical path.

There is also necessary to save R11 content before
flag setup for unaligned exception.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:48 +02:00
Michal Simek b9ea77e2d3 microblaze: trivial: Use la insted of addik
la is translated to addik by toolchain.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:47 +02:00
Michal Simek be304350dd microblaze: remove enable_irq from SAVE_STATE macro
SAVE_STATE macro is used in hw exceptions high level handling
functions. Hw exception doesn't disable IRQ that's why we don't
need to reenable it.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:46 +02:00
Michal Simek 63708f635c microblaze: Move stack backup to SAVE_STATE macro
Remove code duplicity and move it to SAVE_STATE macro.
There is no impact on performance.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:45 +02:00
Michal Simek 96014cc39b microblaze: Move BIP setup to the end of ret_from_trap/ret_from_exc
We don't need to protect by BIP whole ret_from_trap/ret_from_exc code.
Only restoring from user/hw exception should be covered.
If BIP is setup, IRQ can't occur.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:45 +02:00
Michal Simek 5c0d72b1b3 microblaze: Remove PER_CPU(KM) variable
There is a way howto remove Kernel Mode variable. It is easier
to parse UMS bit in MSR to find out if I come from kernel or user
space. Loading MSR content should be in one cycle and loading
PER_CPU variable depends on memory state.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:44 +02:00
Michal Simek 3fbd93e58e microblaze: Optimize clear_vms_ums macro
We can save two instruction when MSR_VMS and MSR_UMS
are setup in one instruction.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:43 +02:00
Michal Simek 36f6095419 microblaze: Save and restore r3/r4 in SAVE/RESTORE_REGS macros
Save and restore R3/R4 registers in macros. This change
help to cleanup entry.S.

In ret_from_trap function we are saving returning value from
syscall to pt_regs on stack that's why we don't need to save and
restore these values before kernel functions (schedule, do_signal).

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:42 +02:00
Michal Simek a4a94dbf20 microblaze: Fix VM_ON and VM_OFF macros
Jump behind macro. We don't want to execute nop instruction again.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:42 +02:00
Michal Simek ca28b51016 microblaze: Do not use _start in vmlinux
_start symbol stores physical address where kernel is.
Gdb uses this symbol for their purpose that's why
we have to rename it.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:41 +02:00
Michal Simek 61b403af8b microblaze: Cleanup boot/Makefile
Remove spaces and use tabs instead.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:40 +02:00
Michal Simek aee04d76d2 microblaze: Fix number of pvr regs
Microblaze has only 11 pvr regs according manual.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:39 +02:00
Michal Simek c8f77436d1 microblaze: Decrease time shifting values
Lower shifting values ensure that shifted 32bit counter
value doesn't exceed 64bit cycle variable too fast.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:39 +02:00
Michal Simek 615748aefa microblaze: Enable early printk only for uartlite
Microblaze has support for early printk. The second serial
driver (uart16550/8250) has no microblaze support for early
printk.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:38 +02:00
FUJITA Tomonori 75842abfd8 microblaze: remove unused HAVE_ARCH_PCI_SET_DMA_MASK
HAVE_ARCH_PCI_SET_DMA_MASK was removed in 2.6.34 (no architecture has
the own implementation of pci_set_dma_mask).

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:37 +02:00
Michal Simek d0f140e03e microblaze: Do not trace cpu_relax function
IRQsoff tracer requires to protect cpu_idle function
to get correct timing report.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:36 +02:00
Michal Simek 6f34b08f58 microblaze: Improve ftrace time measuring
I had to comment sched_clock generic function because of broken toolchain.
It is fine grain timing.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:35 +02:00
Steven J. Magnani ce3266c047 microblaze: Add stack unwinder
Implement intelligent backtracing by searching for stack frame creation,
and emitting only return addresses. Use print_hex_dump() to display the
entire binary kernel stack.

Limitation: MMU kernels are not currently able to trace beyond a system trap
(interrupt, syscall, etc.). It is the intent of this patch to provide
infrastructure that can be extended to add this capability later.

Changes from V1:
* Removed checks in find_frame_creation() that prevented location of the frame
  creation instruction in heavily optimized code
* Various formatting/commenting/file location tweaks per review comments
* Dropped Kconfig option to enable STACKTRACE as something logically separate

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
2010-08-04 10:22:35 +02:00
Steven J. Magnani ba9c4f88d7 microblaze: Allow PAGE_SIZE configuration
Allow developer to configure memory page size at compile time.
Larger pages can improve performance on some workloads.

Based on PowerPC code.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:34 +02:00
Michal Simek 0d9ec762af microblaze: Trace hardirqs
Add trace_hardirqs_off and trace_hardirqs_on to do_IRQ function.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:33 +02:00
Michal Simek 570e3e236e microblaze: Fix sys_clone syscall
sys_clone syscall ignored args which this patch mapped to args
which are passing from glibc.

Here is the origin problem description.

"I ran the static libgcc tests (very few of them are there, they are
mostly dynamically linked) and some of  them fail with an assertion in
fork() system call (tid != pid), I looked at the microblaze/entry.S
file and it looks suspicious (ignores arguments 3-5)"

Arg mapping should be:
glibc ARCH_FORK(...) -> do_fork(...)
r5 -> r5   (clone_flags)
r6  -> r6 (stack_start, use parent->stack if NULL)
pt_regs -> r7 (pt_regs)
r7 -> r8 (stack_size)
r8 -> r9 (parent_tidptr)
r9 -> r10 (child_tidptr)

Signed-off-by: John Williams <john.williams@petalogix.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:32 +02:00
Michal Simek 79aac88903 microblaze: Disable FRAME_POINTER selection
Microblaze doesn't support frame pointers. Ftrace code
uses CALLER_ADDR1 which is defined in linux/ftrace.h. For Microblaze
is 0.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:32 +02:00
Michal Simek 6847ba91a1 microblaze: Fix copy_to_user_page macro
copy_to_user_page macro is used in mm/memory.c:access_process_vm
function. This function is called from ptrace code (POKETEXT, POKEDATA)
which write data to memory. Microblaze handle physical address for
caches that's why there is virt_to_phys conversion.

There is potential one location which can caused the problem on WB system.

The important is take a look at write PTRACEs requests
(POKE/TEXT, DATA, USR).

Note:
Majority of Microblaze PTRACE code is moved to generic location
in newer kernel version that's why this solution should work on
the newest kernel version too.

linux/io.h is in cacheflush because of mm/nommu.c

Tested on a WB system - hello world debugging.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:31 +02:00
Michal Simek e05816679b microblaze: Sync noMMU and MMU setup_memory
Both versions can use the same node to register NODE_DATA(0)

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:30 +02:00
Michal Simek ef78705034 microblaze: Remove unused label
The label should be remove by
21e1c93631

Warning message:
arch/microblaze/mm/fault.c: In function 'do_page_fault':
arch/microblaze/mm/fault.c:229: warning: label 'survive' defined but not used

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:29 +02:00
Michal Simek 79e87830fa microblaze: Implement flush_dcache_page macro
flush_dcache_page macro is necessary to implement for
JFFS2 rootfs support on WB system.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-04 10:22:09 +02:00
Michal Simek af58ed854b microblaze: Fix comment for TLB
There is wrong comment for TLB. Early printk uartlite
console uses TLB 63.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-02 10:44:03 +02:00
Michal Simek 8d7ec6ee59 microblaze: Fix __copy_to/from_user_inatomic macros
__copy_to/from_user_inatomic should call __copy_to/from_user
because there is not necessary to check access because of kernel function.

might_sleep in copy_to/from_user macros is causing problems
in debug sessions too (CONFIG_DEBUG_SPINLOCK_SLEEP).

BUG: sleeping function called from invalid context at
.../arch/microblaze/include/asm/uaccess.h:388
in_atomic(): 1, irqs_disabled(): 0, pid: 1, name: swapper
1 lock held by swapper/1:
 #0:  (&p->cred_guard_mutex){......}, at: [<c00d4b90>] prepare_bprm_creds+0x2c/0x88
Kernel Stack:
...

Call Trace:
[<c0006bd4>] microblaze_unwind+0x7c/0x94
[<c0006684>] show_stack+0xf4/0x190
[<c0006730>] dump_stack+0x10/0x30
[<c00103a0>] __might_sleep+0x12c/0x160
[<c0090de4>] file_read_actor+0x1d8/0x2a8
[<c0091568>] generic_file_aio_read+0x6b4/0xa64
[<c00cd778>] do_sync_read+0xac/0x110
[<c00ce254>] vfs_read+0xc8/0x160
[<c00d585c>] kernel_read+0x38/0x64
[<c00d5984>] prepare_binprm+0xfc/0x130
[<c00d6430>] do_execve+0x228/0x370
[<c000614c>] microblaze_execve+0x58/0xa4

caused by file_read_actor (mm/filemap.c) which calls
__copy_to_user_inatomic.

Signed-off-by: Michal Simek <monstr@monstr.eu>
2010-08-02 10:44:03 +02:00
Linus Torvalds 9fe6206f40 Linux 2.6.35 2010-08-01 15:11:14 -07:00