aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBixuan Cui <cuibixuan@linux.alibaba.com>2022-09-15 20:07:29 +0800
committerBixuan Cui <cuibixuan@linux.alibaba.com>2022-09-15 20:07:29 +0800
commitfe4a436c9d33e388137ef8654f48dffa1ab0a765 (patch)
tree8aa8ca945b21ff53c405fd1aae538e3c59375bc2
parent31afc0db520db03fedaf6f207858ec26097adae8 (diff)
downloadras-tools-fe4a436c9d33e388137ef8654f48dffa1ab0a765.tar.gz
add thread cases
Single read by two threads to target address at the same time. Signed-off-by: Bixuan Cui <cuibixuan@linux.alibaba.com>
-rw-r--r--Makefile2
-rw-r--r--einj_mem_uc.c34
2 files changed, 35 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index ee97592..5aa6919 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ hornet: hornet.c
cc -o hornet $(CFLAGS) hornet.c
einj_mem_uc: einj_mem_uc.o proc_cpuinfo.o proc_interrupt.o proc_pagemap.o do_memcpy.o
- cc -o einj_mem_uc einj_mem_uc.o proc_cpuinfo.o proc_interrupt.o proc_pagemap.o do_memcpy.o
+ cc -o einj_mem_uc einj_mem_uc.o proc_cpuinfo.o proc_interrupt.o proc_pagemap.o do_memcpy.o -pthread
lmce: proc_pagemap.o lmce.o
cc -o lmce proc_pagemap.o lmce.o -pthread
diff --git a/einj_mem_uc.c b/einj_mem_uc.c
index 89af626..09171f2 100644
--- a/einj_mem_uc.c
+++ b/einj_mem_uc.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <sys/syscall.h>
#include <linux/futex.h>
+#include <pthread.h>
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0x40000
@@ -596,6 +597,35 @@ int trigger_write_qword(char *addr)
}
#endif
+int thread(char *addr)
+{
+ printf(">> trigger_thread\n");
+
+ return addr[0];
+}
+
+int trigger_thread(char *addr)
+{
+ unsigned long ret;
+ pthread_t id1, id2;
+
+ ret = pthread_create(&id1, NULL, (void*)thread, addr);
+ if (ret != 0) {
+ printf("create pthread error\n");
+ exit(1);
+ }
+
+ ret = pthread_create(&id2, NULL, (void*)thread, addr);
+ if (ret != 0) {
+ printf("create pthread error\n");
+ exit(1);
+ }
+
+ pthread_join(id1, NULL);
+ pthread_join(id2, NULL);
+
+ return 0;
+}
/*
* parameters to the memcpy and copyin tests.
*/
@@ -850,6 +880,10 @@ struct test {
data_alloc, inject_uc, 0, trigger_patrol, F_EITHER|F_LONGWAIT,
},
{
+ "thread", "Single read by two threads to target address at the same time, generates SRAR machine check",
+ data_alloc, inject_uc, 1, trigger_thread, F_MCE|F_CMCI|F_SIGBUS,
+ },
+ {
"llc", "Cache write-back, generates SRAO machine check",
data_alloc, inject_llc, 1, trigger_llc, F_MCE,
},