Skip to content

Commit adc4cef

Browse files
kedareswararaomichalsimek
authored andcommitted
microblaze: Add support for error injection
To inject the error using the tmr inject IP reset vectors need to be placed in lmb(bram) due to the limitation in HW when this code runs out of DDR. Below code adds the error inject code to the .init.ivt section to copy it in machine_early_init to lmb/Bram location. C_BASE_VECTORS which allow moving reset vectors out of 0 location is not currently supported by Microblaze architecture, that's why all the time reset vectors with injection code is all the time copied to address 0. As of now getting this functionality working CPU switches to real mode and simply jumps to bram, which causes triggering of fault which continues to call_xmb_manager_break break handler which will at the end calls the error count callback function and performs recovery. Signed-off-by: Appana Durga Kedareswara rao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michal Simek <[email protected]>
1 parent 88707eb commit adc4cef

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

arch/microblaze/include/asm/xilinx_mb_manager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef _XILINX_MB_MANAGER_H
66
#define _XILINX_MB_MANAGER_H
77

8+
# ifndef __ASSEMBLY__
9+
810
#include <linux/of_address.h>
911

1012
/*
@@ -17,5 +19,11 @@
1719
void xmb_manager_register(uintptr_t phys_baseaddr, u32 cr_val,
1820
void (*callback)(void *data),
1921
void *priv, void (*reset_callback)(void *data));
22+
asmlinkage void xmb_inject_err(void);
23+
24+
# endif /* __ASSEMBLY__ */
25+
26+
/* Error injection offset */
27+
#define XMB_INJECT_ERR_OFFSET 0x200
2028

2129
#endif /* _XILINX_MB_MANAGER_H */

arch/microblaze/kernel/entry.S

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <asm/page.h>
2929
#include <asm/unistd.h>
30+
#include <asm/xilinx_mb_manager.h>
3031

3132
#include <linux/errno.h>
3233
#include <asm/signal.h>
@@ -1151,6 +1152,41 @@ ENTRY(_switch_to)
11511152
nop
11521153

11531154
#ifdef CONFIG_MB_MANAGER
1155+
.global xmb_inject_err
1156+
.section .text
1157+
.align 2
1158+
.ent xmb_inject_err
1159+
.type xmb_inject_err, @function
1160+
xmb_inject_err:
1161+
addik r1, r1, -PT_SIZE
1162+
SAVE_REGS
1163+
1164+
/* Switch to real mode */
1165+
VM_OFF;
1166+
set_bip;
1167+
mbar 1
1168+
mbar 2
1169+
bralid r15, XMB_INJECT_ERR_OFFSET
1170+
nop;
1171+
1172+
/* enable virtual mode */
1173+
set_vms;
1174+
/* barrier for instructions and data accesses */
1175+
mbar 1
1176+
mbar 2
1177+
/*
1178+
* Enable Interrupts, Virtual Protected Mode, equalize
1179+
* initial state for all possible entries.
1180+
*/
1181+
rtbd r0, 1f
1182+
nop;
1183+
1:
1184+
RESTORE_REGS
1185+
addik r1, r1, PT_SIZE
1186+
rtsd r15, 8;
1187+
nop;
1188+
.end xmb_inject_err
1189+
11541190
.section .data
11551191
.global xmb_manager_dev
11561192
.global xmb_manager_baseaddr
@@ -1225,6 +1261,22 @@ ENTRY(_reset)
12251261
.org 0x20
12261262
brai TOPHYS(_hw_exception_handler); /* HW exception handler */
12271263

1264+
#ifdef CONFIG_MB_MANAGER
1265+
/*
1266+
* For TMR Inject API which injects the error should
1267+
* be executed from LMB.
1268+
* TMR Inject is programmed with address of 0x200 so that
1269+
* when program counter matches with this address error will
1270+
* be injected. 0x200 is expected to be next available bram
1271+
* offset, hence used for this api.
1272+
*/
1273+
.org XMB_INJECT_ERR_OFFSET
1274+
xmb_inject_error:
1275+
nop
1276+
rtsd r15, 8
1277+
nop
1278+
#endif
1279+
12281280
.section .rodata,"a"
12291281
#include "syscall_table.S"
12301282

0 commit comments

Comments
 (0)