devvmx, vmx: lilu dallas multivm
This commit is contained in:
parent
853049c3b9
commit
e5d3aaf1aa
8 changed files with 614 additions and 338 deletions
|
@ -161,6 +161,7 @@ struct PMMU
|
||||||
int nldt; /* number of ldt descriptors allocated */
|
int nldt; /* number of ldt descriptors allocated */
|
||||||
|
|
||||||
u32int dr[8]; /* debug registers */
|
u32int dr[8]; /* debug registers */
|
||||||
|
void *vmx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -260,6 +261,8 @@ struct Mach
|
||||||
int pdbfree;
|
int pdbfree;
|
||||||
|
|
||||||
u32int dr7; /* shadow copy of dr7 */
|
u32int dr7; /* shadow copy of dr7 */
|
||||||
|
|
||||||
|
void* vmx;
|
||||||
|
|
||||||
int stack[1];
|
int stack[1];
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -197,6 +197,7 @@ void upareserve(ulong, int);
|
||||||
void vectortable(void);
|
void vectortable(void);
|
||||||
void* vmap(ulong, int);
|
void* vmap(ulong, int);
|
||||||
int vmapsync(ulong);
|
int vmapsync(ulong);
|
||||||
|
void vmxprocrestore(Proc *);
|
||||||
void vunmap(void*, int);
|
void vunmap(void*, int);
|
||||||
void wbinvd(void);
|
void wbinvd(void);
|
||||||
void writeconf(void);
|
void writeconf(void);
|
||||||
|
|
|
@ -667,6 +667,9 @@ procrestore(Proc *p)
|
||||||
m->dr7 = p->dr[7];
|
m->dr7 = p->dr[7];
|
||||||
putdr(p->dr);
|
putdr(p->dr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(p->vmx != nil)
|
||||||
|
vmxprocrestore(p);
|
||||||
|
|
||||||
if(p->kp)
|
if(p->kp)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -146,6 +146,7 @@ struct PMMU
|
||||||
ulong mmucount;
|
ulong mmucount;
|
||||||
|
|
||||||
u64int dr[8];
|
u64int dr[8];
|
||||||
|
void *vmx;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -225,6 +226,8 @@ struct Mach
|
||||||
uvlong tscticks;
|
uvlong tscticks;
|
||||||
|
|
||||||
u64int dr7; /* shadow copy of dr7 */
|
u64int dr7; /* shadow copy of dr7 */
|
||||||
|
|
||||||
|
void* vmx;
|
||||||
|
|
||||||
uintptr stack[1];
|
uintptr stack[1];
|
||||||
};
|
};
|
||||||
|
|
|
@ -189,6 +189,7 @@ uintptr upaalloc(int, int);
|
||||||
void upafree(uintptr, int);
|
void upafree(uintptr, int);
|
||||||
void upareserve(uintptr, int);
|
void upareserve(uintptr, int);
|
||||||
void vectortable(void);
|
void vectortable(void);
|
||||||
|
void vmxprocrestore(Proc *);
|
||||||
void* vmap(uintptr, int);
|
void* vmap(uintptr, int);
|
||||||
void vunmap(void*, int);
|
void vunmap(void*, int);
|
||||||
void wbinvd(void);
|
void wbinvd(void);
|
||||||
|
|
|
@ -624,6 +624,9 @@ procrestore(Proc *p)
|
||||||
m->dr7 = p->dr[7];
|
m->dr7 = p->dr[7];
|
||||||
putdr(p->dr);
|
putdr(p->dr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(p->vmx != nil)
|
||||||
|
vmxprocrestore(p);
|
||||||
|
|
||||||
if(p->kp)
|
if(p->kp)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
|
char *segname;
|
||||||
|
int segrclose;
|
||||||
Region *mmap;
|
Region *mmap;
|
||||||
int ctlfd, regsfd, mapfd, waitfd;
|
int ctlfd, regsfd, mapfd, waitfd;
|
||||||
Channel *waitch, *sleepch, *notifch;
|
Channel *waitch, *sleepch, *notifch;
|
||||||
|
@ -76,34 +78,31 @@ modregion(Region *r)
|
||||||
static void
|
static void
|
||||||
vmxsetup(void)
|
vmxsetup(void)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
Region *r;
|
static char name[128];
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
fd = open("#X/status", OREAD);
|
ctlfd = open("#X/clone", ORDWR|ORCLOSE);
|
||||||
if(fd < 0) sysfatal("open: %r");
|
|
||||||
rc = read(fd, buf, sizeof(buf)-1);
|
|
||||||
if(rc < 0) sysfatal("read: %r");
|
|
||||||
close(fd);
|
|
||||||
buf[rc] = 0;
|
|
||||||
|
|
||||||
ctlfd = open("#X/ctl", ORDWR);
|
|
||||||
if(ctlfd < 0) sysfatal("open: %r");
|
if(ctlfd < 0) sysfatal("open: %r");
|
||||||
if(strcmp(buf, "inactive\n") != 0)
|
rc = read(ctlfd, name, sizeof(name) - 1);
|
||||||
if(ctl("quit") < 0)
|
if(rc < 0) sysfatal("read: %r");
|
||||||
sysfatal("ctl: %r");
|
name[rc] = 0;
|
||||||
if(ctl("init") < 0)
|
srand(atoi(name));
|
||||||
sysfatal("ctl: %r");
|
if(segname == nil){
|
||||||
regsfd = open("#X/regs", ORDWR);
|
segname = smprint("vm.%s", name);
|
||||||
|
segrclose = ORCLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprint(buf, sizeof(buf), "#X/%s/regs", name);
|
||||||
|
regsfd = open(buf, ORDWR);
|
||||||
if(regsfd < 0) sysfatal("open: %r");
|
if(regsfd < 0) sysfatal("open: %r");
|
||||||
|
|
||||||
mapfd = open("#X/map", OWRITE|OTRUNC);
|
snprint(buf, sizeof(buf), "#X/%s/map", name);
|
||||||
|
mapfd = open(buf, OWRITE|OTRUNC);
|
||||||
if(mapfd < 0) sysfatal("open: %r");
|
if(mapfd < 0) sysfatal("open: %r");
|
||||||
for(r = mmap; r != nil; r = r->next)
|
|
||||||
modregion(r);
|
|
||||||
|
|
||||||
waitfd = open("#X/wait", OREAD);
|
snprint(buf, sizeof(buf), "#X/%s/wait", name);
|
||||||
|
waitfd = open(buf, OREAD);
|
||||||
if(waitfd < 0) sysfatal("open: %r");
|
if(waitfd < 0) sysfatal("open: %r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,9 +346,8 @@ mksegment(char *sn)
|
||||||
gmem = segattach(0, sn, nil, sz);
|
gmem = segattach(0, sn, nil, sz);
|
||||||
if(gmem == (void*)-1){
|
if(gmem == (void*)-1){
|
||||||
snprint(buf, sizeof(buf), "#g/%s", sn);
|
snprint(buf, sizeof(buf), "#g/%s", sn);
|
||||||
fd = create(buf, OREAD, DMDIR | 0777);
|
fd = create(buf, OREAD|segrclose, DMDIR | 0777);
|
||||||
if(fd < 0) sysfatal("create: %r");
|
if(fd < 0) sysfatal("create: %r");
|
||||||
close(fd);
|
|
||||||
snprint(buf, sizeof(buf), "#g/%s/ctl", sn);
|
snprint(buf, sizeof(buf), "#g/%s/ctl", sn);
|
||||||
fd = open(buf, OWRITE|OTRUNC);
|
fd = open(buf, OWRITE|OTRUNC);
|
||||||
if(fd < 0) sysfatal("open: %r");
|
if(fd < 0) sysfatal("open: %r");
|
||||||
|
@ -376,6 +374,10 @@ mksegment(char *sn)
|
||||||
regptr(0xa0000)->ve = p;
|
regptr(0xa0000)->ve = p;
|
||||||
tmp = p;
|
tmp = p;
|
||||||
tmpoff = p - gmem;
|
tmpoff = p - gmem;
|
||||||
|
|
||||||
|
for(r = mmap; r != nil; r = r->next)
|
||||||
|
modregion(r);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -603,6 +605,10 @@ threadmain(int argc, char **argv)
|
||||||
bootmod = realloc(bootmod, (bootmodn + 1) * sizeof(char *));
|
bootmod = realloc(bootmod, (bootmodn + 1) * sizeof(char *));
|
||||||
bootmod[bootmodn++] = strdup(EARGF(usage()));
|
bootmod[bootmodn++] = strdup(EARGF(usage()));
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
segname = strdup(EARGF(usage()));
|
||||||
|
segrclose = 0;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
uartinit(0, EARGF(usage()));
|
uartinit(0, EARGF(usage()));
|
||||||
break;
|
break;
|
||||||
|
@ -663,8 +669,8 @@ threadmain(int argc, char **argv)
|
||||||
if(fbaddr != (u32int) fbaddr || (u32int)(fbaddr+fbsz) < fbaddr) sysfatal("framebuffer must be within first 4 GB");
|
if(fbaddr != (u32int) fbaddr || (u32int)(fbaddr+fbsz) < fbaddr) sysfatal("framebuffer must be within first 4 GB");
|
||||||
mkregion(fbaddr, fbaddr+fbsz, REGALLOC|REGRWX);
|
mkregion(fbaddr, fbaddr+fbsz, REGALLOC|REGRWX);
|
||||||
}
|
}
|
||||||
mksegment("vm");
|
|
||||||
vmxsetup();
|
vmxsetup();
|
||||||
|
mksegment(segname);
|
||||||
loadkernel(argv[0]);
|
loadkernel(argv[0]);
|
||||||
pciinit();
|
pciinit();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue