devvmx, vmx: lilu dallas multivm

This commit is contained in:
aiju 2017-08-28 17:27:41 +00:00
parent 853049c3b9
commit e5d3aaf1aa
8 changed files with 614 additions and 338 deletions

View file

@ -161,6 +161,7 @@ struct PMMU
int nldt; /* number of ldt descriptors allocated */
u32int dr[8]; /* debug registers */
void *vmx;
};
/*
@ -260,6 +261,8 @@ struct Mach
int pdbfree;
u32int dr7; /* shadow copy of dr7 */
void* vmx;
int stack[1];
};

File diff suppressed because it is too large Load diff

View file

@ -197,6 +197,7 @@ void upareserve(ulong, int);
void vectortable(void);
void* vmap(ulong, int);
int vmapsync(ulong);
void vmxprocrestore(Proc *);
void vunmap(void*, int);
void wbinvd(void);
void writeconf(void);

View file

@ -667,6 +667,9 @@ procrestore(Proc *p)
m->dr7 = p->dr[7];
putdr(p->dr);
}
if(p->vmx != nil)
vmxprocrestore(p);
if(p->kp)
return;

View file

@ -146,6 +146,7 @@ struct PMMU
ulong mmucount;
u64int dr[8];
void *vmx;
};
/*
@ -225,6 +226,8 @@ struct Mach
uvlong tscticks;
u64int dr7; /* shadow copy of dr7 */
void* vmx;
uintptr stack[1];
};

View file

@ -189,6 +189,7 @@ uintptr upaalloc(int, int);
void upafree(uintptr, int);
void upareserve(uintptr, int);
void vectortable(void);
void vmxprocrestore(Proc *);
void* vmap(uintptr, int);
void vunmap(void*, int);
void wbinvd(void);

View file

@ -624,6 +624,9 @@ procrestore(Proc *p)
m->dr7 = p->dr[7];
putdr(p->dr);
}
if(p->vmx != nil)
vmxprocrestore(p);
if(p->kp)
return;

View file

@ -5,6 +5,8 @@
#include "dat.h"
#include "fns.h"
char *segname;
int segrclose;
Region *mmap;
int ctlfd, regsfd, mapfd, waitfd;
Channel *waitch, *sleepch, *notifch;
@ -76,34 +78,31 @@ modregion(Region *r)
static void
vmxsetup(void)
{
int fd;
static char buf[128];
Region *r;
static char name[128];
int rc;
fd = open("#X/status", OREAD);
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);
ctlfd = open("#X/clone", ORDWR|ORCLOSE);
if(ctlfd < 0) sysfatal("open: %r");
if(strcmp(buf, "inactive\n") != 0)
if(ctl("quit") < 0)
sysfatal("ctl: %r");
if(ctl("init") < 0)
sysfatal("ctl: %r");
regsfd = open("#X/regs", ORDWR);
rc = read(ctlfd, name, sizeof(name) - 1);
if(rc < 0) sysfatal("read: %r");
name[rc] = 0;
srand(atoi(name));
if(segname == nil){
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");
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");
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");
}
@ -347,9 +346,8 @@ mksegment(char *sn)
gmem = segattach(0, sn, nil, sz);
if(gmem == (void*)-1){
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");
close(fd);
snprint(buf, sizeof(buf), "#g/%s/ctl", sn);
fd = open(buf, OWRITE|OTRUNC);
if(fd < 0) sysfatal("open: %r");
@ -376,6 +374,10 @@ mksegment(char *sn)
regptr(0xa0000)->ve = p;
tmp = p;
tmpoff = p - gmem;
for(r = mmap; r != nil; r = r->next)
modregion(r);
}
void
@ -603,6 +605,10 @@ threadmain(int argc, char **argv)
bootmod = realloc(bootmod, (bootmodn + 1) * sizeof(char *));
bootmod[bootmodn++] = strdup(EARGF(usage()));
break;
case 's':
segname = strdup(EARGF(usage()));
segrclose = 0;
break;
case 'c':
uartinit(0, EARGF(usage()));
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");
mkregion(fbaddr, fbaddr+fbsz, REGALLOC|REGRWX);
}
mksegment("vm");
vmxsetup();
mksegment(segname);
loadkernel(argv[0]);
pciinit();