diff options
author | Tony Luck <tony.luck@intel.com> | 2017-07-26 11:02:34 -0700 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2017-07-26 11:02:34 -0700 |
commit | 7e0703b76e9c8c5b8d161850290b4ebab89cda3a (patch) | |
tree | 4b5711c65582a3f69ca6d7cdefa5c8bb3652714a | |
parent | 35ddfe7955e05cc305e6a90ec3ff2fcb5a7061db (diff) | |
download | ras-tools-7e0703b76e9c8c5b8d161850290b4ebab89cda3a.tar.gz |
einj_mem_uc: Add test case to mlock(2) the target page.
-rw-r--r-- | einj_mem_uc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c index 671345f..547a701 100644 --- a/einj_mem_uc.c +++ b/einj_mem_uc.c @@ -158,6 +158,25 @@ static void *data_alloc(void) return p + pagesize / 4; } +static void *mlock_data_alloc(void) +{ + char *p = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0); + int i; + + if (p == NULL) { + fprintf(stderr, "%s: cannot allocate memory\n", progname); + exit(1); + } + srandom(getpid() * time(NULL)); + for (i = 0; i < pagesize; i++) + p[i] = random(); + if (mlock(p, pagesize) == -1) { + fprintf(stderr, "%s: cannot mlock(2) memory\n", progname); + exit(1); + } + return p + pagesize / 4; +} + static void *instr_alloc(void) { char *p = (char *)dosums; @@ -334,6 +353,10 @@ struct test { "copyin", "Kernel copies data from user. Probably fatal", data_alloc, inject_uc, 1, trigger_copyin, F_MCE|F_CMCI|F_SIGBUS|F_FATAL, }, + { + "mlock", "mlock target page then inject/read to generates SRAR machine check", + mlock_data_alloc, inject_uc, 1, trigger_single, F_MCE|F_CMCI|F_SIGBUS, + }, { NULL } }; |