diff options
author | Bixuan Cui <cuibixuan@linux.alibaba.com> | 2023-01-28 14:34:00 +0800 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2023-01-30 11:07:11 -0800 |
commit | 60c3182214feb4b192234eb980f30e109bbde5cd (patch) | |
tree | 680aeadc2b554076db543176a1e67993439c84c9 | |
parent | 3f414a16c32958ae961ebc7fc3b48b9f28112ec2 (diff) | |
download | ras-tools-60c3182214feb4b192234eb980f30e109bbde5cd.tar.gz |
einj_mem_uc: Add new test case for overflow
Trigger two UCE by reading from two target addresses at the same time.
The OVER(Error overflow) bit will be set and probably fatal.
Signed-off-by: Bixuan Cui <cuibixuan@linux.alibaba.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r-- | einj_mem_uc.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c index 67e1783..3bb2d39 100644 --- a/einj_mem_uc.c +++ b/einj_mem_uc.c @@ -49,6 +49,7 @@ static int *apicmap; static int child_process; #define CACHE_LINE_SIZE 64 +#define DOUBLE_INJECT_OFFSET (pagesize / 4) #define EINJ_ETYPE "/sys/kernel/debug/apei/einj/error_type" #define EINJ_ETYPE_AVAILABLE "/sys/kernel/debug/apei/einj/available_error_type" @@ -139,6 +140,27 @@ static void inject_uc(unsigned long long addr, void *vaddr, int notrigger) wfile(EINJ_DOIT, 1); } +static void inject_double_uc(unsigned long long addr, void *vaddr, int notrigger) +{ + PRINT_INJECTING; + + if (Sflag) { + vaddr = (void *)((long)vaddr & ~(pagesize - 1)); + madvise(vaddr, pagesize, MADV_HWPOISON); + return; + } + + wfile(EINJ_ETYPE, 0x10); + wfile(EINJ_ADDR, addr); + wfile(EINJ_MASK, ~0x0ul); + wfile(EINJ_FLAGS, 2); + wfile(EINJ_NOTRIGGER, notrigger); + wfile(EINJ_DOIT, 1); + + wfile(EINJ_ADDR, vtop((unsigned long long)(vaddr + DOUBLE_INJECT_OFFSET), getpid())); + wfile(EINJ_DOIT, 1); +} + static void inject_core_ce(unsigned long long addr, void *vaddr, int notrigger) { unsigned int cpu; @@ -671,6 +693,14 @@ int trigger_share(char *addr) return addr[0]; } +int trigger_overflow(char *addr) +{ + char *target = addr + trigger_offset; + + PRINT_TRIGGERING; + return target[0] + (target + DOUBLE_INJECT_OFFSET)[0]; +} + /* * parameters to the memcpy and copyin tests. */ @@ -975,6 +1005,10 @@ struct test { map_file_alloc, inject_uc, 1, trigger_share, F_MCE|F_CMCI|F_SIGBUS, }, { + "overflow", "Read to two target addresses at the same time, Probably fatal", + data_alloc, inject_double_uc, 1, trigger_overflow, F_MCE|F_CMCI|F_SIGBUS|F_FATAL, + }, + { "llc", "Cache write-back, generates SRAO machine check", data_alloc, inject_llc, 1, trigger_llc, F_MCE, }, |