vmx(1): support debug instructions
This commit is contained in:
parent
2bb65c40ab
commit
52a3502927
4 changed files with 58 additions and 6 deletions
|
@ -15,6 +15,17 @@ enum {
|
|||
#define RBX "bx"
|
||||
#define RCX "cx"
|
||||
#define RDX "dx"
|
||||
#define RBP "bp"
|
||||
#define RSI "si"
|
||||
#define RDI "di"
|
||||
#define R8 "r8"
|
||||
#define R9 "r9"
|
||||
#define R10 "r10"
|
||||
#define R11 "r11"
|
||||
#define R12 "r12"
|
||||
#define R13 "r13"
|
||||
#define R14 "r14"
|
||||
#define R15 "r15"
|
||||
|
||||
enum {
|
||||
MMIORD = 0,
|
||||
|
@ -72,8 +83,12 @@ struct PCICap {
|
|||
};
|
||||
|
||||
enum {
|
||||
/* irqline argument */
|
||||
IRQLTOGGLE = -1,
|
||||
IRQLLOHI = -2,
|
||||
|
||||
/* postexc */
|
||||
NOERRC = -1,
|
||||
};
|
||||
|
||||
typedef struct VgaMode VgaMode;
|
||||
|
|
|
@ -75,7 +75,7 @@ iohandler(ExitInfo *ei)
|
|||
isin = (ei->qual & 8) != 0;
|
||||
if((ei->qual & 1<<4) != 0){
|
||||
vmerror("i/o string instruction not implemented");
|
||||
postexc("#ud", 0);
|
||||
postexc("#ud", NOERRC);
|
||||
return;
|
||||
}
|
||||
if(isin){
|
||||
|
@ -320,6 +320,37 @@ rdwrmsr(ExitInfo *ei)
|
|||
skipinstr(ei);
|
||||
}
|
||||
|
||||
static void
|
||||
movdr(ExitInfo *ei)
|
||||
{
|
||||
static char *reg[16] = {
|
||||
RAX, RCX, RDX, RBX,
|
||||
RSP, RBP, RSI, RDI,
|
||||
R8, R9, R10, R11,
|
||||
R12, R13, R14, R15
|
||||
};
|
||||
static char *dr[8] = { "dr0", "dr1", "dr2", "dr3", nil, nil, "dr6", "dr7" };
|
||||
int q;
|
||||
|
||||
q = ei->qual;
|
||||
if((q & 6) == 4){
|
||||
postexc("#gp", 0);
|
||||
return;
|
||||
}
|
||||
if((q & 16) != 0)
|
||||
rset(reg[q >> 8 & 15], rget(dr[q & 7]));
|
||||
else
|
||||
rset(dr[q & 7], rget(reg[q >> 8 & 15]));
|
||||
skipinstr(ei);
|
||||
}
|
||||
|
||||
static void
|
||||
dbgexc(ExitInfo *ei)
|
||||
{
|
||||
rset("dr6", rget("dr6") | ei->qual);
|
||||
postexc("#db", NOERRC);
|
||||
}
|
||||
|
||||
static void
|
||||
hlt(ExitInfo *ei)
|
||||
{
|
||||
|
@ -347,6 +378,8 @@ static ExitType etypes[] = {
|
|||
{"*ack", irqackhand},
|
||||
{".rdmsr", rdwrmsr},
|
||||
{".wrmsr", rdwrmsr},
|
||||
{".movdr", movdr},
|
||||
{"#db", dbgexc},
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -391,7 +424,7 @@ processexit(char *msg)
|
|||
}
|
||||
if(*f[0] == '.'){
|
||||
vmerror("vmx: unknown instruction %s", f[0]+1);
|
||||
postexc("#ud", 0);
|
||||
postexc("#ud", NOERRC);
|
||||
return;
|
||||
}
|
||||
if(*f[0] == '*'){
|
||||
|
|
|
@ -13,7 +13,7 @@ int ctl(char *, ...);
|
|||
void registermmio(uvlong, uvlong, uvlong (*)(int, uvlong, uvlong));
|
||||
void irqline(int, int);
|
||||
void irqack(int);
|
||||
void postexc(char *, u32int);
|
||||
void postexc(char *, vlong);
|
||||
void vgaresize(void);
|
||||
void uartinit(int, char *);
|
||||
void sendnotif(void (*)(void *), void *);
|
||||
|
|
|
@ -318,10 +318,14 @@ mksegment(char *sn)
|
|||
}
|
||||
|
||||
void
|
||||
postexc(char *name, u32int)
|
||||
postexc(char *name, vlong code)
|
||||
{
|
||||
if(ctl("exc %s", name) < 0)
|
||||
sysfatal("ctl(postexc): %r");
|
||||
if(code >= 0){
|
||||
if(ctl("exc %s,%#ux", name, (u32int)code) < 0)
|
||||
sysfatal("ctl(postexc): %r");
|
||||
}else
|
||||
if(ctl("exc %s", name) < 0)
|
||||
sysfatal("ctl(postexc): %r");
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue