aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2009-08-22 08:17:17 +0200
committerAndi Kleen <ak@linux.intel.com>2009-08-22 08:17:17 +0200
commit133643a89a54e811d60c80ad48514852cf74aea0 (patch)
tree449c7e29994cf3a7f50d52903e44439dfa5811b4
parentf899f8bcfcaafb902a71cb03ddf1c39c6760a5a9 (diff)
parent346a51a88e4efd1d531a132bb72c6c8e9ce0d657 (diff)
downloadmce-test-133643a89a54e811d60c80ad48514852cf74aea0.tar.gz
Merge branch 'master' of git://git.kernel.org/pub/scm/utils/cpu/mce/mce-test
-rw-r--r--Makefile3
-rwxr-xr-xcases/soft-inj/recoverable_ucr/cases.sh2
-rw-r--r--config/kdump.conf6
-rw-r--r--config/simple.conf4
-rw-r--r--doc/howto.txt11
-rwxr-xr-xdrivers/kdump/driver.sh17
-rwxr-xr-xdrivers/simple/driver.sh3
-rw-r--r--lib/mce.sh14
-rw-r--r--tools/Makefile8
-rw-r--r--tools/readcore/.gitignore2
-rw-r--r--tools/readcore/Makefile28
-rw-r--r--tools/readcore/mem_image.c232
-rw-r--r--tools/readcore/mem_image.h15
-rw-r--r--tools/readcore/readcore.c80
-rw-r--r--tools/readcore/util.c34
-rw-r--r--tools/readcore/util.h17
16 files changed, 30 insertions, 446 deletions
diff --git a/Makefile b/Makefile
index 66e9795..5972106 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,3 @@ test:
test-simple:
$(MAKE) reset
./drivers/simple/driver.sh simple.conf
-
-
-
diff --git a/cases/soft-inj/recoverable_ucr/cases.sh b/cases/soft-inj/recoverable_ucr/cases.sh
index 5a2c17c..61f1036 100755
--- a/cases/soft-inj/recoverable_ucr/cases.sh
+++ b/cases/soft-inj/recoverable_ucr/cases.sh
@@ -37,7 +37,7 @@ verify()
{
local removes="TSC TIME PROCESSOR"
case "$bcase" in
- srao_mem_scrub|srao_ewb|srao_unknown|srao_over|srao_no_en|srao_corrected|srao_ucna)
+ srao_*)
soft_inject_verify_mcelog
verify_klog $klog
soft_inject_verify_return_val
diff --git a/config/kdump.conf b/config/kdump.conf
new file mode 100644
index 0000000..e87ddc5
--- /dev/null
+++ b/config/kdump.conf
@@ -0,0 +1,6 @@
+
+CASES="soft-inj/panic/cases.sh soft-inj/panic_npcc/cases.sh"
+COREDIR="/var/crash"
+GCOV=1
+KSRC_DIR=/lib/modules/$(uname -r)/build
+VMLINUX=$KSRC_DIR/vmlinux
diff --git a/config/simple.conf b/config/simple.conf
new file mode 100644
index 0000000..be6d2f1
--- /dev/null
+++ b/config/simple.conf
@@ -0,0 +1,4 @@
+
+CASES="soft-inj/non-panic/cases.sh soft-inj/panic/cases.sh soft-inj/panic_npcc/cases.sh"
+GCOV=1
+KSRC_DIR=/lib/modules/$(uname -r)/build
diff --git a/doc/howto.txt b/doc/howto.txt
index 4939303..d8b1235 100644
--- a/doc/howto.txt
+++ b/doc/howto.txt
@@ -204,16 +204,7 @@ git://git.kernel.org/pub/scm/utils/cpu/mce/mcelog.git.
Note you need the git version of mcelog available in $PATH.
-3.3 readcore
-
-readcore read crash dump core file and output memory contents at
-specified virtual address with specified length or zero
-terminated. readcore is used to read some kernel information from
-/proc/kcore and kdump core file. The source code of readcore is put
-in tools/readcore. For more information about readcore please refer to
-README of readcore, which is in tools/readcore/README.
-
-3.4 gcovdump
+3.3 gcovdump
gcov is a test coverage tool, the original implementation is used for
user space program only. LTP (Linux Test Project) provides the kernel
diff --git a/drivers/kdump/driver.sh b/drivers/kdump/driver.sh
index fdf3761..f5982ec 100755
--- a/drivers/kdump/driver.sh
+++ b/drivers/kdump/driver.sh
@@ -29,7 +29,7 @@ setup_crontab ()
set +e
crontab -r
set -e
-
+
# crontab in some distros will not read from STDIN.
cat <<EOF > $WDIR/kdump.cron
@@ -42,7 +42,7 @@ EOF
crontab $WDIR/kdump.cron
echo "Enable cron daemon by default."
-
+
if [ -f /etc/init.d/crond ]; then
cron=crond
else
@@ -53,7 +53,7 @@ EOF
# Red Hat and SUSE.
if [ -x "/sbin/chkconfig" ]; then
/sbin/chkconfig "${cron}" on
-
+
# Debian and Ubuntu.
elif [ -x "/sbin/update-rc.d" ]; then
/sbin/update-rc.d "${cron}" defaults
@@ -64,16 +64,16 @@ setup_kdump ()
{
echo "Start kdump daemon."
/etc/init.d/kdump restart
-
+
echo "Enable kdump daemon by default."
# Red Hat and SUSE.
if [ -x "/sbin/chkconfig" ]; then
/sbin/chkconfig kdump on
-
+
# Debian and Ubuntu.
elif [ -x "/sbin/update-rc.d" ]; then
/sbin/update-rc.d kdump defaults
- fi
+ fi
}
get_klog()
@@ -101,7 +101,8 @@ dump_gcov()
return
fi
if ! chk_gcov; then
- echo "gcov is not supported by kernel, or there is no gcov utility installed, disable gcov support."
+ echo "gcov is not supported by kernel, or there is no " \
+ "gcov utility installed, disable gcov support."
unset GCOV
return
fi
@@ -205,7 +206,7 @@ if [ -z "${COREDIR}" ]; then
die "Fail: some mandatory variables are missing from configuration file."
fi
-# Reboot the machine first to take advantage of boot parameter
+# Reboot the machine first to take advantage of boot parameter
# changes.
if [ ! -f $WDIR/stamps/setupped ]; then
echo "Setup test environment."
diff --git a/drivers/simple/driver.sh b/drivers/simple/driver.sh
index 1936631..8ba21ed 100755
--- a/drivers/simple/driver.sh
+++ b/drivers/simple/driver.sh
@@ -58,7 +58,8 @@ test_all()
export GCOV=copy
export KSRC_DIR
else
- echo "gcov is not supported by kernel, or there is no gcov utility installed, disable gcov support."
+ echo "gcov is not supported by kernel, or there is no " \
+ "gcov utility installed, disable gcov support."
unset GCOV
fi
fi
diff --git a/lib/mce.sh b/lib/mce.sh
index 9c40de7..a9e70c4 100644
--- a/lib/mce.sh
+++ b/lib/mce.sh
@@ -252,12 +252,12 @@ get_panic_from_mcelog()
local addr
if mcelog_filter $mcelog "#BANK 219#" | head -1 > $tmpf; then
local F="$(sed '1,$s/#/\n/g' $tmpf | awk '/MISC / { print $2 }')"
- case "$F" in
- 0x1) echo "Fatal machine check" ;;
- 0x2) echo "Machine check from unknown source" ;;
- 0x3) echo "Uncorrected data corruption machine check" ;;
- 0x4) echo "Fatal machine check" ;;
- *) echo unknown panic $F ;;
+ case "$F" in
+ 0x1) echo "Fatal machine check" ;;
+ 0x2) echo "Machine check from unknown source" ;;
+ 0x3) echo "Uncorrected data corruption machine check" ;;
+ 0x4) echo "Fatal machine check" ;;
+ *) echo unknown panic $F ;;
esac
fi
}
@@ -301,7 +301,7 @@ get_tolerant()
set_fake_panic()
{
[ $# -eq 1 ] || die "missing parameter for set_fake_panic"
- echo -n $1 > /sys/devices/system/machinecheck/machinecheck0/fake_panic
+ echo -n $1 > /sys/kernel/debug/mce/fake_panic
}
set_panic_on_oops()
diff --git a/tools/Makefile b/tools/Makefile
index b59f62a..00e16fb 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,12 +1,4 @@
all:
- $(MAKE) -C readcore
- cp readcore/readcore ../bin
-
clean:
- $(MAKE) -C readcore clean
- rm -f ../bin/readcore
-
distclean:
- $(MAKE) -C readcore distclean
- rm -f ../bin/readcore
diff --git a/tools/readcore/.gitignore b/tools/readcore/.gitignore
deleted file mode 100644
index 4515bab..0000000
--- a/tools/readcore/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-readcore
-.depend
diff --git a/tools/readcore/Makefile b/tools/readcore/Makefile
deleted file mode 100644
index ec0890d..0000000
--- a/tools/readcore/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-EXEC_NAME = readcore
-OBJS = readcore.o mem_image.o util.o
-SRC = readcore.c mem_image.c util.c
-
-CC = gcc
-CFLAGS = -Wall -O2
-LDFLAGS =
-LIBS =
-
-$(EXEC_NAME) : $(OBJS)
- $(CC) -o $@ $(LDFLAGS) $^ $(LIBS)
-
-clean :
- rm -rf $(EXEC_NAME) $(OBJS)
-
-distclean: clean
- rm -f ${DISTCLEAN} *~
- rm -f .depend
-
-depend: .depend
-
-.depend: ${SRC}
- ${CC} -MM -DDEPS_RUN -I. ${SRC} ${GENSRC} > .depend.X && \
- mv .depend.X .depend
-
-Makefile: .depend
-
-include .depend
diff --git a/tools/readcore/mem_image.c b/tools/readcore/mem_image.c
deleted file mode 100644
index b77e005..0000000
--- a/tools/readcore/mem_image.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * vmcore memory image accessing functions
- *
- * Copyright (C) NEC Corporation., 2006, 2007
- *
- * Copyright (C) Intel Corp., 2008
- * Author: Huang Ying <ying.huang@intel.com>
- *
- * Revised from vmcore accessing function from makedumpfile.
- * - Huang Ying 2008/08/28
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <elf.h>
-
-#include "mem_image.h"
-#include "util.h"
-
-struct pt_load {
- loff_t offset;
- unsigned long long pstart;
- unsigned long long pend;
- unsigned long long vstart;
- unsigned long long vend;
-};
-
-struct mem_image
-{
- struct pt_load *ptloads;
- int nptload;
- int elf_fd;
-};
-
-static void get_elf64_phdr(int fd, int num, Elf64_Phdr *phdr)
-{
- off_t off, offret;
- int ret;
-
- off = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) * num;
- offret = lseek(fd, off, SEEK_SET);
- ERROR_EXIT_ON(offret == (off_t)-1, "Fail to seek");
- ret = read(fd, phdr, sizeof(Elf64_Phdr));
- ERROR_EXIT_ON(ret != sizeof(Elf64_Phdr), "Cannot read Elf64_Phdr");
-}
-
-static void get_elf32_phdr(int fd, int num, Elf32_Phdr *phdr)
-{
- off_t off, offret;
- int ret;
-
- off = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) * num;
- offret = lseek(fd, off, SEEK_SET);
- ERROR_EXIT_ON(offret == (off_t)-1, "Fail to seek");
- ret = read(fd, phdr, sizeof(Elf32_Phdr));
- ERROR_EXIT_ON(ret != sizeof(Elf32_Phdr), "Cannot read Elf32_Phdr");
-}
-
-struct mem_image *mi_open(const char *image_file_name)
-{
- struct mem_image *mi;
- struct pt_load *ptload;
- int i, ret;
- Elf64_Ehdr ehdr64;
- Elf64_Phdr load64;
- Elf32_Ehdr ehdr32;
- Elf32_Phdr load32;
- off_t offret;
- const off_t failed = (off_t)-1;
-
- mi = calloc(1, sizeof(struct mem_image));
- ERROR_EXIT_ON(!mi, "Cannot allocate mem_image");
-
- mi->elf_fd = open(image_file_name, O_RDWR);
- ERROR_EXIT_ON(mi->elf_fd == -1, "Cannot open image file: %s",
- image_file_name);
-
- ret = read(mi->elf_fd, &ehdr64, sizeof(Elf64_Ehdr));
- ERROR_EXIT_ON(ret!= sizeof(Elf64_Ehdr), "Can't read");
-
- offret = lseek(mi->elf_fd, 0, SEEK_SET);
- ERROR_EXIT_ON(offret == failed, "Fail to seek");
- ret = read(mi->elf_fd, &ehdr32, sizeof(Elf32_Ehdr));
- ERROR_EXIT_ON(ret!= sizeof(Elf32_Ehdr), "Can't read");
-
- mi->nptload = 0;
- if ((ehdr64.e_ident[EI_CLASS] == ELFCLASS64)
- && (ehdr32.e_ident[EI_CLASS] != ELFCLASS32)) {
- for (i = 0; i < ehdr64.e_phnum; i++) {
- get_elf64_phdr(mi->elf_fd, i, &load64);
- if (load64.p_type == PT_LOAD)
- mi->nptload++;
- }
-
- mi->ptloads = calloc(mi->nptload, sizeof(struct pt_load));
- ERROR_EXIT_ON(!mi->ptloads, "Cannot allocate for mem_image");
-
- ptload = mi->ptloads;
- for (i = 0; i < ehdr64.e_phnum; i++) {
- get_elf64_phdr(mi->elf_fd, i, &load64);
- if (load64.p_type == PT_LOAD) {
- ptload->pstart = load64.p_paddr;
- ptload->pend = load64.p_paddr+load64.p_filesz;
- ptload->vstart = load64.p_vaddr;
- ptload->vend = load64.p_vaddr+load64.p_filesz;
- ptload->offset = load64.p_offset;
- ptload++;
- }
- }
- } else if ((ehdr64.e_ident[EI_CLASS] != ELFCLASS64)
- && (ehdr32.e_ident[EI_CLASS] == ELFCLASS32)) {
- for (i = 0; i < ehdr32.e_phnum; i++) {
- get_elf32_phdr(mi->elf_fd, i, &load32);
- if (load32.p_type == PT_LOAD)
- mi->nptload++;
- }
-
- mi->ptloads = calloc(mi->nptload, sizeof(struct pt_load));
- ERROR_EXIT_ON(!mi->ptloads, "Cannot allocate for mem_image");
-
- ptload = mi->ptloads;
- for (i = 0; i < ehdr32.e_phnum; i++) {
- get_elf32_phdr(mi->elf_fd, i, &load32);
- if (load32.p_type == PT_LOAD) {
- ptload->pstart = load32.p_paddr;
- ptload->pend = load32.p_paddr+load32.p_filesz;
- ptload->vstart = load32.p_vaddr;
- ptload->vend = load32.p_vaddr+load32.p_filesz;
- ptload->offset = load32.p_offset;
- ptload++;
- }
- }
- } else
- ERROR_EXIT("Can't get valid ehdr.\n");
-
- return mi;
-}
-
-off_t mi_paddr_to_offset(struct mem_image *mi, unsigned long paddr,
- unsigned long size)
-{
- int i;
- struct pt_load *p;
-
- for (i = 0; i < mi->nptload; i++) {
- p = mi->ptloads + i;
- if (p->pstart <= paddr &&
- p->pend >= paddr + size)
- return p->offset + (paddr - p->pstart);
- }
- error_exit("Can not find paddr 0x%lx.\n", paddr);
- return 0;
-}
-
-off_t mi_vaddr_to_offset(struct mem_image *mi, unsigned long vaddr,
- unsigned long size)
-{
- int i;
- struct pt_load *p;
-
- for (i = 0; i < mi->nptload; i++) {
- p = mi->ptloads + i;
- if (vaddr >= p->vstart &&
- vaddr + size <= p->vend)
- return p->offset + (vaddr - p->vstart);
- }
- error_exit("Can not find vaddr 0x%lx.\n", vaddr);
- return 0;
-}
-
-void __mi_vread_mem(struct mem_image *mi, unsigned long vaddr,
- void *buf, unsigned long size)
-{
- off_t off, offret;
- int ret;
-
- off = mi_vaddr_to_offset(mi, vaddr, size);
- offret = lseek(mi->elf_fd, off, SEEK_SET);
- ERROR_EXIT_ON(offret == (off_t)-1, "Fail to seek");
- ret = read(mi->elf_fd, buf, size);
- ERROR_EXIT_ON(ret != size, "Cannot read mem");
-}
-
-void mi_close(struct mem_image *mi)
-{
- close(mi->elf_fd);
- free(mi->ptloads);
- free(mi);
-}
-
-void *mi_vread_mem(struct mem_image *mi, const void *vaddr, size_t len)
-{
- void *buf = malloc(len);
-
- ERROR_EXIT_ON(!buf, "Can not allocate memory in vread_mem");
- __mi_vread_mem(mi, (unsigned long)vaddr, buf, len);
- return buf;
-}
-
-uint32_t mi_vread_u32(struct mem_image *mi, const void *vaddr)
-{
- uint32_t u32;
- __mi_vread_mem(mi, (unsigned long)vaddr, &u32, sizeof(u32));
- return u32;
-}
-
-uint64_t mi_vread_u64(struct mem_image *mi, const void *vaddr)
-{
- uint64_t u64;
- __mi_vread_mem(mi, (unsigned long)vaddr, &u64, sizeof(u64));
- return u64;
-}
-
-char *mi_vread_string(struct mem_image *mi, const void *vaddr)
-{
- char ch;
- size_t len = 0;
-
- do {
- __mi_vread_mem(mi, (unsigned long)vaddr + len, &ch, 1);
- len++;
- } while (ch);
-
- return mi_vread_mem(mi, vaddr, len);
-}
diff --git a/tools/readcore/mem_image.h b/tools/readcore/mem_image.h
deleted file mode 100644
index a5cf35b..0000000
--- a/tools/readcore/mem_image.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef MEM_IMAGE_H
-#define MEM_IMAGE_H
-
-#include <stdint.h>
-
-struct mem_image;
-
-struct mem_image *mi_open(const char *image_file_name);
-void mi_close(struct mem_image *mi);
-void *mi_vread_mem(struct mem_image *mi, const void *vaddr, size_t len);
-uint32_t mi_vread_u32(struct mem_image *mi, const void *vaddr);
-uint64_t mi_vread_u64(struct mem_image *mi, const void *vaddr);
-char *mi_vread_string(struct mem_image *mi, const void *vaddr);
-
-#endif
diff --git a/tools/readcore/readcore.c b/tools/readcore/readcore.c
deleted file mode 100644
index 5f4ee9e..0000000
--- a/tools/readcore/readcore.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) Intel Corp., 2008
- * Author: Huang Ying <ying.huang@intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <getopt.h>
-
-#include "mem_image.h"
-#include "util.h"
-
-struct mem_image *mimg;
-
-void usage(void)
-{
- printf("Usage: readcore -a <addr> -l <len> <crash core>\n"
- " readcore -a <addr> -s <crash core>\n"
- " readcore -h\n"
- "read some data from crash core.\n"
- "\n"
- "-a virtual address to read\n"
- "-l length to read\n"
- "-s read a string\n"
- "-h Print this help.\n"
- "<crash core> Crash core.\n");
- printf("\n");
-}
-
-int main(int argc, char *argv[])
-{
- int opt, fileind, str = 0;
- unsigned long vaddr = 0, len = 0;
- char *endptr, *data;
-
- while ((opt = getopt(argc, argv, "a:hl:s")) != -1) {
- switch (opt) {
- case 'a':
- vaddr = strtoul(optarg, &endptr, 0);
- ERROR_EXIT_ON(*endptr, "Invalid address");
- break;
- case 'l':
- len = strtoul(optarg, &endptr, 0);
- ERROR_EXIT_ON(*endptr, "Invalid length");
- break;
- case 's':
- str = 1;
- break;
- case 'h':
- usage();
- return 0;
- default:
- ERROR_EXIT("Unknown option %c", opt);
- break;
- }
- }
- fileind = optind;
-
- ERROR_EXIT_ON(fileind >= argc, "No crash core file specified!");
- ERROR_EXIT_ON(!vaddr, "No virtual address specified!");
- ERROR_EXIT_ON(!len && !str, "Please specify data length or string!");
-
- mimg = mi_open(argv[fileind]);
- if (len) {
- data = mi_vread_mem(mimg, (void *)vaddr, len);
- fwrite(data, len, 1, stdout);
- } else {
- data = mi_vread_string(mimg, (void *)vaddr);
- puts(data);
- }
- free(data);
- mi_close(mimg);
-
- return 0;
-}
diff --git a/tools/readcore/util.c b/tools/readcore/util.c
deleted file mode 100644
index 888a2a3..0000000
--- a/tools/readcore/util.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Some utility functions
- *
- * Copyright (C) Intel Corp., 2008
- * Author: Huang Ying <ying.huang@intel.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <stdarg.h>
-#include <errno.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "util.h"
-
-void error_exit(char *fmt, ...)
-{
- va_list ap;
-
- fprintf(stderr, "Error: ");
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- if (errno)
- fprintf(stderr, ", %s\n", strerror(errno));
- else
- fprintf(stderr, "\n");
- exit(-1);
-}
-
diff --git a/tools/readcore/util.h b/tools/readcore/util.h
deleted file mode 100644
index a8907fb..0000000
--- a/tools/readcore/util.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef UTIL_H
-#define UTIL_H
-
-void error_exit(char *fmt, ...);
-
-#define ERROR_EXIT(fmt, ...) \
- do { \
- error_exit(fmt, ## __VA_ARGS__); \
- } while (0)
-
-#define ERROR_EXIT_ON(check, fmt, ...) \
- do { \
- if (check) \
- error_exit(fmt, ## __VA_ARGS__); \
- } while (0)
-
-#endif