Some changes that were missing from the previous commit

This commit is contained in:
Philip Homburg 2008-10-02 13:48:05 +00:00
parent 5b5b54c76c
commit 005bc7a649
7 changed files with 99 additions and 23 deletions

View file

@ -33,6 +33,8 @@
#include "ddb.h"
#include "db_access.h"
#include "extra.h"
/*
* Access unaligned data items on aligned (longword)
* boundaries.
@ -55,7 +57,7 @@ db_read_bytes(addr, size, data)
src = (char *)addr;
while (--size >= 0)
*data++ = *src++;
*data++ = text_read_ub(src++);
}

View file

@ -30,7 +30,9 @@
* Instruction disassembler.
*/
#if 0
#include <linux/kernel.h>
#endif
#include "ddb.h"
#include "db_access.h"
@ -861,11 +863,12 @@ static const int db_lengths[] = {
result = db_get_value((loc), (size), (is_signed)); \
(loc) += (size);
//static db_addr_t
/*static db_addr_t
// db_disasm_esc __P((db_addr_t loc, int inst, int short_addr,
// int size, const char *seg));
//static void db_print_address __P((const char *seg, int size,
// struct i_addr *addrp));
*/
static db_addr_t
db_read_address __P((db_addr_t loc, int short_addr,
int regmodrm, struct i_addr *addrp));
@ -1099,13 +1102,19 @@ my_disasm(db_addr_t loc,
seg = "%gs";
break;
case 0xf0:
#if 0
// db_printf("lock ");
#endif
break;
case 0xf2:
#if 0
// db_printf("repne ");
#endif
break;
case 0xf3:
#if 0
// db_printf("repe "); /* XXX repe VS rep */
#endif
break;
default:
prefix = FALSE;
@ -1141,7 +1150,9 @@ my_disasm(db_addr_t loc,
get_value_inc(regmodrm, loc, 1, FALSE);
loc = db_read_address(loc, short_addr, regmodrm, &address);
modAddr=prev_loc;
#if 0
// printf("modrm at %x, offset %d\n", loc, loc-prev_loc);
#endif
}
i_name = ip->i_name;
@ -1187,51 +1198,75 @@ my_disasm(db_addr_t loc,
switch (i_mode & 0xFF) {
case E:
#if 0
// db_print_address(seg, size, &address);
#endif
break;
case Eind:
#if 0
// db_print_address(seg, size, &address);
#endif
break;
case El:
#if 0
// db_print_address(seg, LONG, &address);
#endif
break;
case Ew:
#if 0
// db_print_address(seg, WORD, &address);
#endif
break;
case Eb:
#if 0
// db_print_address(seg, BYTE, &address);
#endif
break;
case R:
#if 0
// db_printf("%s", db_reg[size][f_reg(regmodrm)]);
#endif
break;
case Rw:
#if 0
// db_printf("%s", db_reg[WORD][f_reg(regmodrm)]);
#endif
break;
case Ri:
#if 0
// db_printf("%s", db_reg[size][f_rm(inst)]);
#endif
break;
case Ril:
#if 0
// db_printf("%s", db_reg[LONG][f_rm(inst)]);
#endif
break;
case S:
#if 0
// db_printf("%s", db_seg_reg[f_reg(regmodrm)]);
#endif
break;
case Si:
#if 0
// db_printf("%s", db_seg_reg[f_reg(inst)]);
#endif
break;
case A:
#if 0
// db_printf("%s", db_reg[size][0]); /* acc */
#endif
break;
case BX:
@ -1295,7 +1330,9 @@ my_disasm(db_addr_t loc,
get_value_inc(displ, loc, len, FALSE);
if (seg) ;
else
#if 0
// db_printsym((db_addr_t)displ, DB_STGY_ANY);
#endif
break;
case Db:
@ -1303,7 +1340,9 @@ my_disasm(db_addr_t loc,
displ += loc;
if (size == WORD)
displ &= 0xFFFF;
#if 0
// db_printsym((db_addr_t)displ, DB_STGY_XTRN);
#endif
break;
case Dl:
@ -1312,7 +1351,9 @@ my_disasm(db_addr_t loc,
displ += loc;
if (size == WORD)
displ &= 0xFFFF;
#if 0
// db_printsym((db_addr_t)displ, DB_STGY_XTRN);
#endif
break;
case o1:
@ -1328,6 +1369,8 @@ my_disasm(db_addr_t loc,
break;
}
}
#if 0
// db_printf("\n");
#endif
return (loc);
}

View file

@ -29,8 +29,10 @@
#ifndef _MACHINE_DB_MACHDEP_H_
#define _MACHINE_DB_MACHDEP_H_
#if 0
//#include <machine/frame.h>
//#include <machine/psl.h>
#endif
#ifndef TRUE
#define TRUE 1

View file

@ -30,15 +30,21 @@
* Author: David B. Golub, Carnegie Mellon University
* Date: 7/90
*/
#if 0
//#include <sys/param.h>
//#include <sys/systm.h>
#endif
#if 0
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/kallsyms.h>
#endif
#include "ddb.h"
#include "db_sym.h"
#include "swifi.h"
#include "extra.h"
/*
* Multiple symbol tables
*/
@ -382,13 +388,17 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
cur_value = value;
while(cur_value < sec_end) {
if(verbose) {
#if 0
// db_printsym(cur_value, DB_STGY_PROC);
// printk(":\t");
#endif
}
prev_value=cur_value;
modAddr=0;
if(verbose) {
#if 0
//cur_value=db_disasm(prev_value, FALSE);
#endif
} else {
cur_value=my_disasm(prev_value, FALSE);
}
@ -397,7 +407,7 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
if(cur_value-prev_value == 1) {
unsigned char *c;
c=(char *) prev_value;
if(*c==0xc9) {
if(text_read_ub(c)==0xc9) {
if(verbose) printk("bailing out as we hit a leave\n");
found=0;
break;
@ -452,22 +462,24 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
/* look for repX prefix */
if(*c==0xf3 || *c==0xf2) {
if(text_read_ub(c)==0xf3 || text_read_ub(c)==0xf2) {
if(verbose)
printk("found repX prefix\n");
/* take out repX prefix only */
found=1;
cur_value=prev_value+1;
break;
} else if( ((*c)&0xf0)==0x70 || (*c>=0xe0 && *c<=0xe2) ) {
} else if( (text_read_ub(c)&0xf0)==0x70 ||
(text_read_ub(c)>=0xe0 && text_read_ub(c)<=0xe2) ) {
/* look for jXX 8 (7X), loop,jcx (e0-3), jXX 16/32 (0f 8X) */
found=1;
if(verbose)
printk("found jXX rel8, loop or jcx\n");
break;
} else if(*c==0x66 || *c==0x67) { /* override prefix */
} else if(text_read_ub(c)==0x66 ||
text_read_ub(c)==0x67) { /* override prefix */
c++;
} else if(*(c++)==0xf && ((*c)&0xf0)==0x80 ) {
} else if(text_read_ub(c++)==0xf && (text_read_ub(c)&0xf0)==0x80 ) {
found=1; /* 0x0f 0x8X */
if(verbose) printk("found branch!\n");
break;
@ -481,7 +493,8 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
if(cur_value>off && modAddr) {
unsigned char *c;
c=(char *) modAddr;
if( (*c)>0x3f && (*c)<0xc0 && (((*c)&7)!=5) ) {
if( text_read_ub(c)>0x3f && text_read_ub(c)<0xc0 &&
(text_read_ub(c)&7)!=5 ) {
found=1;
break;
}
@ -493,9 +506,9 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
*/
unsigned char *c;
c=(char *) prev_value;
if( *c==0x8a || *c==0x8b) {
if( text_read_ub(c)==0x8a || text_read_ub(c)==0x8b) {
c++;
if( ((*(c++))&0xc7)==0x45 && ((*c)&0x80)==0 ) {
if( ((text_read_ub(c++))&0xc7)==0x45 && (text_read_ub(c)&0x80)==0 ) {
/* 75% chance that we'll choose the next arg */
if(random()&0x3) {
found=1;
@ -512,26 +525,28 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
*/
unsigned char *c;
c=(char *) prev_value;
if (((*c & 0xf8) == 0x50) ||
(*c == 0xff)) {
if (*c == 0xff) {
if (((text_read_ub(c) & 0xf8) == 0x50) ||
(text_read_ub(c) == 0xff)) {
if (text_read_ub(c) == 0xff) {
c++;
#if 0
//
// Look for push x(ebp)
if ((*c & 0x78) != 0x70) {
#endif
if ((text_read_ub(c) & 0x78) != 0x70) {
continue;
}
//
/*
// Skip the offset
//
*/
c++;
}
c++;
if (*c == 0x9d) {
//
if (text_read_ub(c) == 0x9d) {
/*
// Increment cur_value to include the
// popf instruction
//
*/
cur_value++;
found = 1;
break;
@ -545,12 +560,14 @@ find_faulty_instr(db_expr_t off, int type, int *instr_len)
if(found) {
*instr_len=cur_value-prev_value;
off=prev_value;
if(1 || verbose) {
if(verbose) {
printk("%s", name);
if (d) printk("+0x%x", d);
printk(" @ %x, ", value);
printk("instr @ %x, len=%d, ", off, *instr_len);
#if 0
// db_disasm(prev_value, FALSE);
#endif
}
return off;
} else {

View file

@ -88,7 +88,9 @@ void db_check_interrupt __P((void));
void db_clear_watchpoints __P((void));
db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt));
/* instruction disassembler */
#if 0
//void db_error __P((char *s));
#endif
#define db_error printk
int db_expression __P((db_expr_t *valuep));
int db_get_variable __P((db_expr_t *valuep));

View file

@ -40,7 +40,14 @@ typedef struct swifi_result {
unsigned long new;
} swifi_result_t, *pswifi_result_t;
long
sys_inject_fault(char * module,
unsigned long argFaultType,
unsigned long argRandomSeed,
unsigned long argNumFaults,
pswifi_result_t result_record,
unsigned long argInjectFault);
#endif // _SWIFI_USER_H
#endif /* _SWIFI_USER_H */

View file

@ -1,6 +1,8 @@
#ifndef _LINUX_SWIFI_H
#define _LINUX_SWIFI_H
#include <stdlib.h>
#include "swifi-user.h"
long
@ -53,9 +55,10 @@ void *
swifi_kmalloc(size_t size, int flags);
#if 0
void *
swifi___vmalloc(unsigned long size, int gfp_mask, pgprot_t prot);
#endif
#endif // _LINUX_SWIFI_H
#endif /* _LINUX_SWIFI_H */