代码拉取完成,页面将自动刷新
同步操作将从 anolis/ras-tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2015 Intel Corporation
* Author: Tony Luck
*/
#include "einj.h"
struct error_type error_types[] = {
{ 0x00000001, "Processor Correctable",},
{ 0x00000002, "Processor Uncorrectable non-fatal",},
{ 0x00000004, "Processor Uncorrectable fatal",},
{ 0x00000008, "Memory Correctable",},
{ 0x00000010, "Memory Uncorrectable non-fatal",},
{ 0x00000020, "Memory Uncorrectable fatal",},
{ 0x00000040, "PCI Express Correctable",},
{ 0x00000080, "PCI Express Uncorrectable non-fatal",},
{ 0x00000100, "PCI Express Uncorrectable fatal",},
{ 0x00000200, "Platform Correctabl",},
{ 0x00000400, "Platform Uncorrectable non-fatal",},
{ 0x00000800, "Platform Uncorrectable fatal",},
{ -1, NULL }
};
int check_errortype_available(char *file, unsigned long long val)
{
FILE *fp;
int ret = -1;
unsigned long long available_error_type;
if (strcmp(file, EINJ_ETYPE) != 0)
return 0;
fp = fopen(EINJ_ETYPE_AVAILABLE, "r");
if (!fp) {
fprintf(stderr, "%s: cannot open '%s'\n", progname, file);
exit(1);
}
while (fscanf(fp, "%llx%*[^\n]", &available_error_type) == 1) {
if (val == available_error_type) {
ret = 0;
break;
}
}
fclose(fp);
return ret;
}
void wfile(char *file, unsigned long long val)
{
FILE *fp;
if (check_errortype_available(file, val) != 0) {
fprintf(stderr, "%s: no support for error type: 0x%llx\n", progname, val);
exit(1);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
if (!strcmp(file, EINJ_FLAGS))
return;
#endif
fp = fopen(file, "w");
if (fp == NULL) {
fprintf(stderr, "%s: cannot open '%s'\n", progname, file);
exit(1);
}
fprintf(fp, "0x%llx\n", val);
if (fclose(fp) == EOF) {
fprintf(stderr, "%s: write error on '%s'\n", progname, file);
exit(1);
}
}
int is_einj_support(void)
{
if (access("/sys/firmware/acpi/tables/EINJ", R_OK) == -1) {
fprintf(stderr, "%s: Error injection not supported, check your BIOS settings\n", progname);
return 0;
}
if (access(EINJ_NOTRIGGER, R_OK|W_OK) == -1) {
fprintf(stderr, "%s: Is the einj.ko module loaded?\n", progname);
return 0;
}
return 1;
}
int is_privileged(void)
{
if (getuid() != 0) {
fprintf(stderr, "%s: must be root to run error injection tests\n", progname);
return 0;
}
return 1;
}
void inject_mem_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);
}
char *lookup_type_name(unsigned long long type)
{
struct error_type *t;
for (t = error_types; t->type_name; t++)
if (t->type == type)
return t->type_name;
fprintf(stderr, "%s: unknown type '%x'\n", progname, type);
exit(1);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。