aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBixuan Cui <cuibixuan@linux.alibaba.com>2023-01-05 11:31:36 +0800
committerTony Luck <tony.luck@intel.com>2023-01-05 14:12:18 -0800
commitf276ebba2d1ff616e5a2c7673343f588843bcb64 (patch)
treee40f65573f3505f7dd0a79c324ad6b422c79d781
parent93f96e3f8fa2ec67e9cc19d0e728603440e535b4 (diff)
downloadras-tools-f276ebba2d1ff616e5a2c7673343f588843bcb64.tar.gz
einj_mem_uc: add new test case for share memory
Share memory is read by two tasks to target address. [Tony: Fix some indenting. Rename page_cache_alloc() to map_file_alloc() now it is used for another test] Signed-off-by: Bixuan Cui <cuibixuan@linux.alibaba.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--einj_mem_uc.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c
index bfb644b..2e0d75a 100644
--- a/einj_mem_uc.c
+++ b/einj_mem_uc.c
@@ -474,7 +474,7 @@ static void *data_alloc_private(void)
static FILE *pcfile;
-static void *page_cache_alloc(void)
+static void *map_file_alloc(void)
{
char c, *p;
int i;
@@ -642,6 +642,34 @@ int trigger_thread(char *addr)
return 0;
}
+
+int trigger_share(char *addr)
+{
+ int pid, status;
+
+ switch (pid = fork()) {
+ case -1:
+ fprintf(stderr, "%s: fork failed\n", progname);
+ return -1;
+ case 0:
+ /* mmap share memory */
+ char *p = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fileno(pcfile), 0);
+ if (p == NULL) {
+ fprintf(stderr, "%s: cannot mmap sharefile\n", progname);
+ exit(1);
+ }
+
+ PRINT_TRIGGERING;
+ return *(p + pagesize / 4);
+ }
+
+ while (wait(&status) != pid)
+ ;
+
+ PRINT_TRIGGERING;
+ return addr[0];
+}
+
/*
* parameters to the memcpy and copyin tests.
*/
@@ -942,6 +970,10 @@ struct test {
data_alloc, inject_uc, 1, trigger_thread, F_MCE|F_CMCI|F_SIGBUS,
},
{
+ "share", "Share memory is read by two tasks to target address, generates SRAR machine check",
+ map_file_alloc, inject_uc, 1, trigger_share, F_MCE|F_CMCI|F_SIGBUS,
+ },
+ {
"llc", "Cache write-back, generates SRAO machine check",
data_alloc, inject_llc, 1, trigger_llc, F_MCE,
},
@@ -951,7 +983,7 @@ struct test {
},
{
"copyout", "Kernel copies data to user. Probably fatal",
- page_cache_alloc, inject_uc, 1, trigger_copyout, F_MCE|F_CMCI|F_SIGBUS|F_FATAL,
+ map_file_alloc, inject_uc, 1, trigger_copyout, F_MCE|F_CMCI|F_SIGBUS|F_FATAL,
},
{
"copy-on-write", "Kernel copies user page. Probably fatal",