summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRegia König2021-06-16 13:25:56 +0200
committerRegia König2021-06-16 13:25:56 +0200
commit93aefb2dab67f4c3246f0e9be6fbae161fd14301 (patch)
tree6b9353c4178d9fc554b9ced80eaad5d948c3b86d
parentGet approximation of stack location (diff)
downloadmemtest86-93aefb2dab67f4c3246f0e9be6fbae161fd14301.tar.gz
memtest86-93aefb2dab67f4c3246f0e9be6fbae161fd14301.tar.xz
memtest86-93aefb2dab67f4c3246f0e9be6fbae161fd14301.zip
Save last state
-rw-r--r--efi_memtest/MemtestEfi.c10
-rw-r--r--efi_memtest/memtest86+/efi/test.c70
2 files changed, 66 insertions, 14 deletions
diff --git a/efi_memtest/MemtestEfi.c b/efi_memtest/MemtestEfi.c
index b2c13c1..0d2d472 100644
--- a/efi_memtest/MemtestEfi.c
+++ b/efi_memtest/MemtestEfi.c
@@ -12,6 +12,9 @@
extern EFI_SYSTEM_TABLE *gST;
+// TODO remove
+int global = 1;
+
void stack_check() {
int i;
int *p = &i;
@@ -99,6 +102,13 @@ UefiMain (
}
stack_check();
+
+ if (logflag) {
+ char log[49] = "Address of global variable = ";
+ int length = 29;
+ int_to_charr((unsigned long) &global, log, &length);
+ print_log(log, length);
+ }
test_start();
diff --git a/efi_memtest/memtest86+/efi/test.c b/efi_memtest/memtest86+/efi/test.c
index 900e082..badba42 100644
--- a/efi_memtest/memtest86+/efi/test.c
+++ b/efi_memtest/memtest86+/efi/test.c
@@ -23,7 +23,7 @@ extern short log_tst2;
// TODO REMOVE
int addr_written = 0;
-ulong bad_addr = 103456768;
+ulong bad_addr = 103493632;
extern struct cpu_ident cpu_id;
extern volatile int mstr_cpu;
@@ -280,6 +280,15 @@ void addr_tst1(int me)
unsliced_foreach_segment(nullptr, me, addr_tst1_seg);
}
+// TODO remove
+void stack_addr() {
+ int i;
+ char log[32] = "stack ptr = ";
+ int length = 12;
+ int_to_charr((unsigned long) &i, log, &length);
+ print_log(log, length);
+}
+
int print_init_counter = 0;
STATIC void addr_tst2_init_segment(ulong* p,
ulong len_dw, const void* unused) {
@@ -313,20 +322,45 @@ STATIC void addr_tst2_init_segment(ulong* p,
print_log(log, length);
}
+ stack_addr();
+
//Original C code replaced with hand tuned assembly code
+
+ int round = 1;
+
for (; p <= pe; p++) {
*p = (ulong)p;
if ((ulong)p == bad_addr) {
addr_written = 1;
+ ulong *px = (ulong *)bad_addr;
+ char log[35] = "content of p = ";
+ int length = 15;
+ int_to_charr(*px, log, &length);
+ print_log(log, length);
}
- if (addr_written) {
+ if (addr_written && (*(ulong *) bad_addr != bad_addr)) {
ulong *px = (ulong *)bad_addr;
char log[35] = "content of p = ";
int length = 15;
int_to_charr(*px, log, &length);
print_log(log, length);
- }
+
+ char lg[16] = "Round ";
+ length = 6;
+ int_to_charr(round, lg, &length);
+ print_log(lg, length);
+
+ if (logflag) {
+ char log[45] = "Current return address = ";
+ int length = 25;
+ int_to_charr((unsigned long) ((unsigned long *) __builtin_return_address(0)), log, &length);
+ print_log(log, length);
+ }
+
+ while(1);
+ }
+ round++;
}
/*asm __volatile__ (
@@ -341,13 +375,13 @@ STATIC void addr_tst2_init_segment(ulong* p,
: : "D" (p), "d" (pe)
);*/
- if (addr_written) {
+/* if (addr_written) {
ulong *px = (ulong *)bad_addr;
char log[35] = "content of p = ";
int length = 15;
int_to_charr(*px, log, &length);
print_log(log, length);
- }
+ } */
}
int print_check_counter = 0;
@@ -385,13 +419,13 @@ STATIC void addr_tst2_check_segment(ulong* p,
//Original C code replaced with hand tuned assembly code
- if (logflag && log_tst2 && addr_written) {
+/* if (logflag && log_tst2 && addr_written) {
ulong *px = (ulong*)bad_addr;
char log[35] = "content of p = ";
int length = 15;
int_to_charr(*px, log, &length);
print_log(log, length);
- }
+ } */
for (; p <= pe; p++) {
@@ -400,7 +434,7 @@ STATIC void addr_tst2_check_segment(ulong* p,
if((bad = *p) != (ulong)p) {
- ad_err2((ulong *)p, bad);
+ ad_err2((ulong *)p, bad);
}
}
@@ -479,29 +513,37 @@ void addr_tst2(int me)
print_log("addr_tst2(): starting addr_tst2_init_segment", 44);
}
+
+ if (logflag) {
+ char log[49] = "Address of global variable = ";
+ int length = 29;
+ int_to_charr((unsigned long) &addr_written, log, &length);
+ print_log(log, length);
+ }
+
/* Write each address with its own address */
unsliced_foreach_segment(nullptr, me, addr_tst2_init_segment);
{ BAILR }
- ulong *p = (ulong * )bad_addr;
+ /* ulong *p = (ulong * )bad_addr;
if (logflag && log_tst2 && addr_written) {
char log[35] = "content of p = ";
int length = 15;
int_to_charr(*p, log, &length);
print_log(log, length);
- }
+ } */
- if (logflag && log_tst2) {
+ /* if (logflag && log_tst2) {
print_log("addr_tst2(): starting addr_tst2_check_segment", 45);
- }
+ }*/
- if (logflag && log_tst2 && addr_written) {
+ /* if (logflag && log_tst2 && addr_written) {
char log[35] = "content of p = ";
int length = 15;
int_to_charr(*p, log, &length);
print_log(log, length);
- }
+ }*/
/* Each address should have its own address */
unsliced_foreach_segment(nullptr, me, addr_tst2_check_segment);