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

View File

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

View File

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

View File

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

View File

@ -88,7 +88,9 @@ void db_check_interrupt __P((void));
void db_clear_watchpoints __P((void)); void db_clear_watchpoints __P((void));
db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt)); db_addr_t db_disasm __P((db_addr_t loc, boolean_t altfmt));
/* instruction disassembler */ /* instruction disassembler */
#if 0
//void db_error __P((char *s)); //void db_error __P((char *s));
#endif
#define db_error printk #define db_error printk
int db_expression __P((db_expr_t *valuep)); int db_expression __P((db_expr_t *valuep));
int db_get_variable __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; unsigned long new;
} swifi_result_t, *pswifi_result_t; } 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 #ifndef _LINUX_SWIFI_H
#define _LINUX_SWIFI_H #define _LINUX_SWIFI_H
#include <stdlib.h>
#include "swifi-user.h" #include "swifi-user.h"
long long
@ -53,9 +55,10 @@ void *
swifi_kmalloc(size_t size, int flags); swifi_kmalloc(size_t size, int flags);
#if 0
void * void *
swifi___vmalloc(unsigned long size, int gfp_mask, pgprot_t prot); swifi___vmalloc(unsigned long size, int gfp_mask, pgprot_t prot);
#endif
#endif /* _LINUX_SWIFI_H */
#endif // _LINUX_SWIFI_H