Re: [PATCH 0/7] More lguest massage.
I don't have _any_ idea about what happened to those patches. They were sent through the normal git-send-email script, but for some reason, all got the same subject. They might be okay for the review, but anyone willing to try it more seriously, please grab it at http://glommer.net/patches-lguest.tar.gz On Jan 17, 2008 10:35 PM, Glauber de Oliveira Costa <[EMAIL PROTECTED]> wrote: > urrently, lguest module can't be compiled without the PARAVIRT flag being > on.This is a fake dependency, since the module itself shouldn't need any > paravirtoverride. Reason for that is the reference to pv_info structure > ininitial loading tests. > > his patch removes it in favour of a more generic error message. > > Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> > --- > drivers/lguest/core.c |2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c > indexbb42fd0..97b76d6 100644 > ---a/drivers/lguest/core.c > +++b/drivers/lguest/core.c > @@-255,7 +255,7 @@ static int __init init(void) > > /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. > */ > if (paravirt_enabled()) { > - printk("lguestis afraid of %s\n", pv_info.name); > + printk("lguestcan't run under another hypervisor"); > return -EPERM; > } > > -- > 1.5.0.6 > > -- Glauber de Oliveira Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act." -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
Wecan save some lines of code by getting rid of *lg= cpu... lines of code spread everywhere by now. he new macro lg_data(cpu) is used anywhere we'd otherwise use the cpu->lg->lguest_dataconstruction, to prevent lines getting to big. Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/core.c | 24 +++ drivers/lguest/hypercalls.c | 49 +++ drivers/lguest/interrupts_and_traps.c | 54 drivers/lguest/lg.h | 30 + drivers/lguest/page_tables.c | 114 drivers/lguest/segments.c |8 +-- drivers/lguest/x86/core.c | 30 - 7 files changed, 149 insertions(+), 160 deletions(-) diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c index4c26ba7..bb42fd0 100644 ---a/drivers/lguest/core.c +++b/drivers/lguest/core.c @@-151,23 +151,23 @@ int lguest_address_ok(const struct lguest *lg, /* This routine copies memory from the Guest. Here we can see how useful the * kill_lguest() routine we met in the Launcher can be: we return a random * value (all zeroes) instead of needing to return an error. */ -void__lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes) +void__lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes) { - if(!lguest_address_ok(lg, addr, bytes) - || copy_from_user(b, lg->mem_base + addr, bytes) != 0) { + if(!lguest_address_ok(cpu->lg, addr, bytes) + || copy_from_user(b, cpu->lg->mem_base + addr, bytes) != 0) { /* copy_from_user should do this, but as we rely on it... */ memset(b, 0, bytes); - kill_guest(lg,"bad read address %#lx len %u", addr, bytes); + kill_guest(cpu,"bad read address %#lx len %u", addr, bytes); } } /* This is the write (copy into guest) version. */ -void__lgwrite(struct lguest *lg, unsigned long addr, const void *b, +void__lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, unsigned bytes) { - if(!lguest_address_ok(lg, addr, bytes) - || copy_to_user(lg->mem_base + addr, b, bytes) != 0) - kill_guest(lg,"bad write address %#lx len %u", addr, bytes); + if(!lguest_address_ok(cpu->lg, addr, bytes) + || copy_to_user(cpu->lg->mem_base + addr, b, bytes) != 0) + kill_guest(cpu,"bad write address %#lx len %u", addr, bytes); } /*:*/ @@-176,10 +176,8 @@ void __lgwrite(struct lguest *lg, unsigned long addr, const void *b, * going around and around until something interesting happens. */ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) { - structlguest *lg = cpu->lg; - /* We stop running once the Guest is dead. */ - while(!lg->dead) { + while(!cpu->lg->dead) { /* First we run any hypercalls the Guest wants done. */ if (cpu->hcall) do_hypercalls(cpu); @@-212,7 +210,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) /* Just make absolutely sure the Guest is still alive. One of * those hypercalls could have been fatal, for example. */ - if(lg->dead) + if(cpu->lg->dead) break; /* If the Guest asked to be stopped, we sleep. The Guest's @@-237,7 +235,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) lguest_arch_handle_trap(cpu); } - if(lg->dead == ERR_PTR(-ERESTART)) + if(cpu->lg->dead == ERR_PTR(-ERESTART)) return -ERESTART; /* The Guest is dead => "No such file or directory" */ return -ENOENT; diff--git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index0471018..32666d0 100644 ---a/drivers/lguest/hypercalls.c +++b/drivers/lguest/hypercalls.c @@-31,8 +31,6 @@ * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) { - structlguest *lg = cpu->lg; - switch (args->arg0) { case LHCALL_FLUSH_ASYNC: /* This call does nothing, except by breaking out of the Guest @@-41,7 +39,7 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) case LHCALL_LGUEST_INIT: /* You can't get here unless you're already initialized. Don't * do that. */ - kill_guest(lg,"already have lguest_data"); + kill_guest(cpu,"already have lguest_data"); break; case LHCALL_SHUTDOWN: { /* Shutdown is such a trivial hypercall that we do it in four @@-49,11 +47,11 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) char msg[128]; /* If the lgread fails, it will call kill_guest() itself; the * kill_guest() with the message will be
[PATCH 0/7] More lguest massage.
urrently, lguest module can't be compiled without the PARAVIRT flag being on.This is a fake dependency, since the module itself shouldn't need any paravirtoverride. Reason for that is the reference to pv_info structure ininitial loading tests. his patch removes it in favour of a more generic error message. Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/core.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c indexbb42fd0..97b76d6 100644 ---a/drivers/lguest/core.c +++b/drivers/lguest/core.c @@-255,7 +255,7 @@ static int __init init(void) /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */ if (paravirt_enabled()) { - printk("lguestis afraid of %s\n", pv_info.name); + printk("lguestcan't run under another hypervisor"); return -EPERM; } -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
eventsrepresented in the 'changed' bitmap are per-cpu, not per-guest. moveit to the lg_cpu structure Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/interrupts_and_traps.c |2 +- drivers/lguest/lg.h |6 +++--- drivers/lguest/segments.c |4 ++-- drivers/lguest/x86/core.c | 11 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff--git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index6bbfce4..9ac7455 100644 ---a/drivers/lguest/interrupts_and_traps.c +++b/drivers/lguest/interrupts_and_traps.c @@-395,7 +395,7 @@ void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int num, u32 lo, u32 hi) /* Mark the IDT as changed: next time the Guest runs we'll know we have * to copy this again. */ - cpu->lg->changed|= CHANGED_IDT; + cpu->changed|= CHANGED_IDT; /* Check that the Guest doesn't try to step outside the bounds. */ if (num >= ARRAY_SIZE(cpu->arch.idt)) diff--git a/drivers/lguest/lg.h b/drivers/lguest/lg.h indexeb473a5..5458af8 100644 ---a/drivers/lguest/lg.h +++b/drivers/lguest/lg.h @@-51,6 +51,9 @@ struct lg_cpu { u32 esp1; u8 ss1; + /*Bitmap of what has changed: see CHANGED_* above. */ + intchanged; + unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ /* At end of a page shared mapped over lguest_pages in guest. */ @@-92,9 +95,6 @@ struct lguest void __user *mem_base; unsigned long kernel_address; - /*Bitmap of what has changed: see CHANGED_* above. */ - intchanged; - struct pgdir pgdirs[4]; unsigned long noirq_start, noirq_end; diff--git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index0213845..635f54c 100644 ---a/drivers/lguest/segments.c +++b/drivers/lguest/segments.c @@-159,7 +159,7 @@ void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num) fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu->arch.gdt)); /* Mark that the GDT changed so the core knows it has to copy it again, * even if the Guest is run on the same CPU. */ - lg->changed|= CHANGED_GDT; + cpu->changed|= CHANGED_GDT; } /* This is the fast-track version for just changing the three TLS entries. @@-174,7 +174,7 @@ void guest_load_tls(struct lg_cpu *cpu, unsigned long gtls) __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); fixup_gdt_table(cpu, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); /* Note that just the TLS entries have changed. */ - lg->changed|= CHANGED_GDT_TLS; + cpu->changed|= CHANGED_GDT_TLS; } /*:*/ diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index3e457f2..dea52d5 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-75,7 +75,6 @@ static DEFINE_PER_CPU(struct lg_cpu *, last_cpu); */ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) { - structlguest *lg = cpu->lg; /* Copying all this data can be quite expensive. We usually run the * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the @@-83,7 +82,7 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) if (__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) { __get_cpu_var(last_cpu) = cpu; cpu->last_pages = pages; - lg->changed= CHANGED_ALL; + cpu->changed= CHANGED_ALL; } /* These copies are pretty cheap, so we do them unconditionally: */ @@-99,18 +98,18 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) pages->state.guest_tss.ss1 = cpu->ss1; /* Copy direct-to-Guest trap entries. */ - if(lg->changed & CHANGED_IDT) + if(cpu->changed & CHANGED_IDT) copy_traps(cpu, pages->state.guest_idt, default_idt_entries); /* Copy all GDT entries which the Guest can change. */ - if(lg->changed & CHANGED_GDT) + if(cpu->changed & CHANGED_GDT) copy_gdt(cpu, pages->state.guest_gdt); /* If only the TLS entries have changed, copy them. */ - elseif (lg->changed & CHANGED_GDT_TLS) + elseif (cpu->changed & CHANGED_GDT_TLS) copy_gdt_tls(cpu, pages->state.guest_gdt); /* Mark the Guest as unchanged for next time. */ - lg->changed= 0; + cpu->changed= 0; } /* Finally: the code to actually call into the Switcher to run the Guest. */ -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
spte_addrdoes not depend on any guest information, so we wipeout the lg parameter completely. Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/page_tables.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff--git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c indexfb66561..c4b8eaf 100644 ---a/drivers/lguest/page_tables.c +++b/drivers/lguest/page_tables.c @@-84,7 +84,7 @@ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) /* This routine then takes the page directory entry returned above, which * contains the address of the page table entry (PTE) page. It then returns a * pointer to the PTE entry for the given address. */ -staticpte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) +staticpte_t *spte_addr(pgd_t spgd, unsigned long vaddr) { pte_t *page = __va(pgd_pfn(spgd) << PAGE_SHIFT); /* You should never call this if the PGD entry wasn't valid */ @@-261,7 +261,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode) gpte = pte_mkdirty(gpte); /* Get the pointer to the shadow PTE entry we're going to set. */ - spte= spte_addr(lg, *spgd, vaddr); + spte= spte_addr(*spgd, vaddr); /* If there was a valid shadow PTE entry here before, we release it. * This can happen with a write to a previously read-only entry. */ release_pte(*spte); @@-310,7 +310,7 @@ static int page_writable(struct lg_cpu *cpu, unsigned long vaddr) /* Check the flags on the pte entry itself: it must be present and * writable. */ - flags= pte_flags(*(spte_addr(cpu->lg, *spgd, vaddr))); + flags= pte_flags(*(spte_addr(*spgd, vaddr))); return (flags & (_PAGE_PRESENT|_PAGE_RW)) == (_PAGE_PRESENT|_PAGE_RW); } @@-509,7 +509,7 @@ static void do_set_pte(struct lguest *lg, int idx, /* If the top level isn't present, there's no entry to update. */ if (pgd_flags(*spgd) & _PAGE_PRESENT) { /* Otherwise, we start by releasing the existing entry. */ - pte_t*spte = spte_addr(lg, *spgd, vaddr); + pte_t*spte = spte_addr(*spgd, vaddr); release_pte(*spte); /* If they're setting this entry as dirty or accessed, we might -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
inour new model, pages are assigned to a virtual cpu, not to a guest. Wemove it to the lg_cpu structure. Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/lg.h |3 ++- drivers/lguest/lguest_user.c |8 drivers/lguest/x86/core.c|4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff--git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index11a3ae2..eb473a5 100644 ---a/drivers/lguest/lg.h +++b/drivers/lguest/lg.h @@-57,6 +57,8 @@ struct lg_cpu { unsigned long regs_page; struct lguest_regs *regs; + structlguest_pages *last_pages; + int cpu_pgd; /* which pgd this cpu is currently using */ /* If a hypercall was asked for, this points to the arguments. */ @@-92,7 +94,6 @@ struct lguest /* Bitmap of what has changed: see CHANGED_* above. */ int changed; - structlguest_pages *last_pages; struct pgdir pgdirs[4]; diff--git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c indexf4f6df8..a87fca6 100644 ---a/drivers/lguest/lguest_user.c +++b/drivers/lguest/lguest_user.c @@-131,6 +131,10 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) * reference, it is destroyed before close() is called. */ cpu->mm = get_task_mm(cpu->tsk); + /*We remember which CPU's pages this Guest used last, for optimization + * when the same Guest runs on the same CPU twice. */ + cpu->last_pages= NULL; + return 0; } @@-192,10 +196,6 @@ static int initialize(struct file *file, const unsigned long __user *input) if (err) goto free_regs; - /*We remember which CPU's pages this Guest used last, for optimization - * when the same Guest runs on the same CPU twice. */ - lg->last_pages= NULL; - /* We keep our "struct lguest" in the file's private_data. */ file->private_data = lg; diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index25f48fd..3e457f2 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-80,9 +80,9 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the * Guest has changed. */ - if(__get_cpu_var(last_cpu) != cpu || lg->last_pages != pages) { + if(__get_cpu_var(last_cpu) != cpu || cpu->last_pages != pages) { __get_cpu_var(last_cpu) = cpu; - lg->last_pages= pages; + cpu->last_pages= pages; lg->changed = CHANGED_ALL; } -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
gpte_addr()does not depend on any guest information. So we wipe out thelg parameter from it completely. Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/page_tables.c |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff--git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c indexc4b8eaf..c9acafc 100644 ---a/drivers/lguest/page_tables.c +++b/drivers/lguest/page_tables.c @@-100,8 +100,7 @@ static unsigned long gpgd_addr(struct lg_cpu *cpu, unsigned long vaddr) return cpu->lg->pgdirs[cpu->cpu_pgd].gpgdir + index * sizeof(pgd_t); } -staticunsigned long gpte_addr(struct lguest *lg, - pgd_t gpgd, unsigned long vaddr) +staticunsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr) { unsigned long gpage = pgd_pfn(gpgd) << PAGE_SHIFT; BUG_ON(!(pgd_flags(gpgd) & _PAGE_PRESENT)); @@-235,7 +234,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode) /* OK, now we look at the lower level in the Guest page table: keep its * address, because we might update it later. */ - gpte_ptr= gpte_addr(lg, gpgd, vaddr); + gpte_ptr= gpte_addr(gpgd, vaddr); gpte = lgread(lg, gpte_ptr, pte_t); /* If this page isn't in the Guest page tables, we can't page it in. */ @@-378,7 +377,7 @@ unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr) if (!(pgd_flags(gpgd) & _PAGE_PRESENT)) kill_guest(cpu->lg, "Bad address %#lx", vaddr); - gpte= lgread(cpu->lg, gpte_addr(cpu->lg, gpgd, vaddr), pte_t); + gpte= lgread(cpu->lg, gpte_addr(gpgd, vaddr), pte_t); if (!(pte_flags(gpte) & _PAGE_PRESENT)) kill_guest(cpu->lg, "Bad address %#lx", vaddr); -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
This series takes one more step towards cpu-ification of lguest. As for rusty's last suggestion, I get rid of the whole bunch of "struct lguest *lg = cpu->lg" statements around by using lg_cpu as our base structure wherever it matters. (this saves us 11 lines) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
inour model, a guest does not run in a cpu anymore: a virtual cpu does.So we change last_guest to last_cpu Signed-off-by:Glauber de Oliveira Costa <[EMAIL PROTECTED]> --- drivers/lguest/x86/core.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index2859447..25f48fd 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-60,7 +60,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu) (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); } -staticDEFINE_PER_CPU(struct lguest *, last_guest); +staticDEFINE_PER_CPU(struct lg_cpu *, last_cpu); /*S:010 * We approach the Switcher. @@-80,8 +80,8 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the * Guest has changed. */ - if(__get_cpu_var(last_guest) != lg || lg->last_pages != pages) { - __get_cpu_var(last_guest)= lg; + if(__get_cpu_var(last_cpu) != cpu || lg->last_pages != pages) { + __get_cpu_var(last_cpu)= cpu; lg->last_pages = pages; lg->changed = CHANGED_ALL; } -- 1.5.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
This series takes one more step towards cpu-ification of lguest. As for rusty's last suggestion, I get rid of the whole bunch of struct lguest *lg = cpu-lg statements around by using lg_cpu as our base structure wherever it matters. (this saves us 11 lines) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
inour model, a guest does not run in a cpu anymore: a virtual cpu does.So we change last_guest to last_cpu Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/x86/core.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index2859447..25f48fd 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-60,7 +60,7 @@ static struct lguest_pages *lguest_pages(unsigned int cpu) (SWITCHER_ADDR + SHARED_SWITCHER_PAGES*PAGE_SIZE))[cpu]); } -staticDEFINE_PER_CPU(struct lguest *, last_guest); +staticDEFINE_PER_CPU(struct lg_cpu *, last_cpu); /*S:010 * We approach the Switcher. @@-80,8 +80,8 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the * Guest has changed. */ - if(__get_cpu_var(last_guest) != lg || lg-last_pages != pages) { - __get_cpu_var(last_guest)= lg; + if(__get_cpu_var(last_cpu) != cpu || lg-last_pages != pages) { + __get_cpu_var(last_cpu)= cpu; lg-last_pages = pages; lg-changed = CHANGED_ALL; } -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
spte_addrdoes not depend on any guest information, so we wipeout the lg parameter completely. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/page_tables.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff--git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c indexfb66561..c4b8eaf 100644 ---a/drivers/lguest/page_tables.c +++b/drivers/lguest/page_tables.c @@-84,7 +84,7 @@ static pgd_t *spgd_addr(struct lguest *lg, u32 i, unsigned long vaddr) /* This routine then takes the page directory entry returned above, which * contains the address of the page table entry (PTE) page. It then returns a * pointer to the PTE entry for the given address. */ -staticpte_t *spte_addr(struct lguest *lg, pgd_t spgd, unsigned long vaddr) +staticpte_t *spte_addr(pgd_t spgd, unsigned long vaddr) { pte_t *page = __va(pgd_pfn(spgd) PAGE_SHIFT); /* You should never call this if the PGD entry wasn't valid */ @@-261,7 +261,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode) gpte = pte_mkdirty(gpte); /* Get the pointer to the shadow PTE entry we're going to set. */ - spte= spte_addr(lg, *spgd, vaddr); + spte= spte_addr(*spgd, vaddr); /* If there was a valid shadow PTE entry here before, we release it. * This can happen with a write to a previously read-only entry. */ release_pte(*spte); @@-310,7 +310,7 @@ static int page_writable(struct lg_cpu *cpu, unsigned long vaddr) /* Check the flags on the pte entry itself: it must be present and * writable. */ - flags= pte_flags(*(spte_addr(cpu-lg, *spgd, vaddr))); + flags= pte_flags(*(spte_addr(*spgd, vaddr))); return (flags (_PAGE_PRESENT|_PAGE_RW)) == (_PAGE_PRESENT|_PAGE_RW); } @@-509,7 +509,7 @@ static void do_set_pte(struct lguest *lg, int idx, /* If the top level isn't present, there's no entry to update. */ if (pgd_flags(*spgd) _PAGE_PRESENT) { /* Otherwise, we start by releasing the existing entry. */ - pte_t*spte = spte_addr(lg, *spgd, vaddr); + pte_t*spte = spte_addr(*spgd, vaddr); release_pte(*spte); /* If they're setting this entry as dirty or accessed, we might -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
inour new model, pages are assigned to a virtual cpu, not to a guest. Wemove it to the lg_cpu structure. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/lg.h |3 ++- drivers/lguest/lguest_user.c |8 drivers/lguest/x86/core.c|4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff--git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index11a3ae2..eb473a5 100644 ---a/drivers/lguest/lg.h +++b/drivers/lguest/lg.h @@-57,6 +57,8 @@ struct lg_cpu { unsigned long regs_page; struct lguest_regs *regs; + structlguest_pages *last_pages; + int cpu_pgd; /* which pgd this cpu is currently using */ /* If a hypercall was asked for, this points to the arguments. */ @@-92,7 +94,6 @@ struct lguest /* Bitmap of what has changed: see CHANGED_* above. */ int changed; - structlguest_pages *last_pages; struct pgdir pgdirs[4]; diff--git a/drivers/lguest/lguest_user.c b/drivers/lguest/lguest_user.c indexf4f6df8..a87fca6 100644 ---a/drivers/lguest/lguest_user.c +++b/drivers/lguest/lguest_user.c @@-131,6 +131,10 @@ static int lg_cpu_start(struct lg_cpu *cpu, unsigned id, unsigned long start_ip) * reference, it is destroyed before close() is called. */ cpu-mm = get_task_mm(cpu-tsk); + /*We remember which CPU's pages this Guest used last, for optimization + * when the same Guest runs on the same CPU twice. */ + cpu-last_pages= NULL; + return 0; } @@-192,10 +196,6 @@ static int initialize(struct file *file, const unsigned long __user *input) if (err) goto free_regs; - /*We remember which CPU's pages this Guest used last, for optimization - * when the same Guest runs on the same CPU twice. */ - lg-last_pages= NULL; - /* We keep our struct lguest in the file's private_data. */ file-private_data = lg; diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index25f48fd..3e457f2 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-80,9 +80,9 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the * Guest has changed. */ - if(__get_cpu_var(last_cpu) != cpu || lg-last_pages != pages) { + if(__get_cpu_var(last_cpu) != cpu || cpu-last_pages != pages) { __get_cpu_var(last_cpu) = cpu; - lg-last_pages= pages; + cpu-last_pages= pages; lg-changed = CHANGED_ALL; } -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
gpte_addr()does not depend on any guest information. So we wipe out thelg parameter from it completely. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/page_tables.c |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff--git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c indexc4b8eaf..c9acafc 100644 ---a/drivers/lguest/page_tables.c +++b/drivers/lguest/page_tables.c @@-100,8 +100,7 @@ static unsigned long gpgd_addr(struct lg_cpu *cpu, unsigned long vaddr) return cpu-lg-pgdirs[cpu-cpu_pgd].gpgdir + index * sizeof(pgd_t); } -staticunsigned long gpte_addr(struct lguest *lg, - pgd_t gpgd, unsigned long vaddr) +staticunsigned long gpte_addr(pgd_t gpgd, unsigned long vaddr) { unsigned long gpage = pgd_pfn(gpgd) PAGE_SHIFT; BUG_ON(!(pgd_flags(gpgd) _PAGE_PRESENT)); @@-235,7 +234,7 @@ int demand_page(struct lg_cpu *cpu, unsigned long vaddr, int errcode) /* OK, now we look at the lower level in the Guest page table: keep its * address, because we might update it later. */ - gpte_ptr= gpte_addr(lg, gpgd, vaddr); + gpte_ptr= gpte_addr(gpgd, vaddr); gpte = lgread(lg, gpte_ptr, pte_t); /* If this page isn't in the Guest page tables, we can't page it in. */ @@-378,7 +377,7 @@ unsigned long guest_pa(struct lg_cpu *cpu, unsigned long vaddr) if (!(pgd_flags(gpgd) _PAGE_PRESENT)) kill_guest(cpu-lg, Bad address %#lx, vaddr); - gpte= lgread(cpu-lg, gpte_addr(cpu-lg, gpgd, vaddr), pte_t); + gpte= lgread(cpu-lg, gpte_addr(gpgd, vaddr), pte_t); if (!(pte_flags(gpte) _PAGE_PRESENT)) kill_guest(cpu-lg, Bad address %#lx, vaddr); -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
eventsrepresented in the 'changed' bitmap are per-cpu, not per-guest. moveit to the lg_cpu structure Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/interrupts_and_traps.c |2 +- drivers/lguest/lg.h |6 +++--- drivers/lguest/segments.c |4 ++-- drivers/lguest/x86/core.c | 11 +-- 4 files changed, 11 insertions(+), 12 deletions(-) diff--git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c index6bbfce4..9ac7455 100644 ---a/drivers/lguest/interrupts_and_traps.c +++b/drivers/lguest/interrupts_and_traps.c @@-395,7 +395,7 @@ void load_guest_idt_entry(struct lg_cpu *cpu, unsigned int num, u32 lo, u32 hi) /* Mark the IDT as changed: next time the Guest runs we'll know we have * to copy this again. */ - cpu-lg-changed|= CHANGED_IDT; + cpu-changed|= CHANGED_IDT; /* Check that the Guest doesn't try to step outside the bounds. */ if (num = ARRAY_SIZE(cpu-arch.idt)) diff--git a/drivers/lguest/lg.h b/drivers/lguest/lg.h indexeb473a5..5458af8 100644 ---a/drivers/lguest/lg.h +++b/drivers/lguest/lg.h @@-51,6 +51,9 @@ struct lg_cpu { u32 esp1; u8 ss1; + /*Bitmap of what has changed: see CHANGED_* above. */ + intchanged; + unsigned long pending_notify; /* pfn from LHCALL_NOTIFY */ /* At end of a page shared mapped over lguest_pages in guest. */ @@-92,9 +95,6 @@ struct lguest void __user *mem_base; unsigned long kernel_address; - /*Bitmap of what has changed: see CHANGED_* above. */ - intchanged; - struct pgdir pgdirs[4]; unsigned long noirq_start, noirq_end; diff--git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index0213845..635f54c 100644 ---a/drivers/lguest/segments.c +++b/drivers/lguest/segments.c @@-159,7 +159,7 @@ void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num) fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu-arch.gdt)); /* Mark that the GDT changed so the core knows it has to copy it again, * even if the Guest is run on the same CPU. */ - lg-changed|= CHANGED_GDT; + cpu-changed|= CHANGED_GDT; } /* This is the fast-track version for just changing the three TLS entries. @@-174,7 +174,7 @@ void guest_load_tls(struct lg_cpu *cpu, unsigned long gtls) __lgread(lg, tls, gtls, sizeof(*tls)*GDT_ENTRY_TLS_ENTRIES); fixup_gdt_table(cpu, GDT_ENTRY_TLS_MIN, GDT_ENTRY_TLS_MAX+1); /* Note that just the TLS entries have changed. */ - lg-changed|= CHANGED_GDT_TLS; + cpu-changed|= CHANGED_GDT_TLS; } /*:*/ diff--git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index3e457f2..dea52d5 100644 ---a/drivers/lguest/x86/core.c +++b/drivers/lguest/x86/core.c @@-75,7 +75,6 @@ static DEFINE_PER_CPU(struct lg_cpu *, last_cpu); */ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) { - structlguest *lg = cpu-lg; /* Copying all this data can be quite expensive. We usually run the * same Guest we ran last time (and that Guest hasn't run anywhere else * meanwhile). If that's not the case, we pretend everything in the @@-83,7 +82,7 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) if (__get_cpu_var(last_cpu) != cpu || cpu-last_pages != pages) { __get_cpu_var(last_cpu) = cpu; cpu-last_pages = pages; - lg-changed= CHANGED_ALL; + cpu-changed= CHANGED_ALL; } /* These copies are pretty cheap, so we do them unconditionally: */ @@-99,18 +98,18 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages) pages-state.guest_tss.ss1 = cpu-ss1; /* Copy direct-to-Guest trap entries. */ - if(lg-changed CHANGED_IDT) + if(cpu-changed CHANGED_IDT) copy_traps(cpu, pages-state.guest_idt, default_idt_entries); /* Copy all GDT entries which the Guest can change. */ - if(lg-changed CHANGED_GDT) + if(cpu-changed CHANGED_GDT) copy_gdt(cpu, pages-state.guest_gdt); /* If only the TLS entries have changed, copy them. */ - elseif (lg-changed CHANGED_GDT_TLS) + elseif (cpu-changed CHANGED_GDT_TLS) copy_gdt_tls(cpu, pages-state.guest_gdt); /* Mark the Guest as unchanged for next time. */ - lg-changed= 0; + cpu-changed= 0; } /* Finally: the code to actually call into the Switcher to run the Guest. */ -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/7] More lguest massage.
Wecan save some lines of code by getting rid of *lg= cpu... lines of code spread everywhere by now. he new macro lg_data(cpu) is used anywhere we'd otherwise use the cpu-lg-lguest_dataconstruction, to prevent lines getting to big. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/core.c | 24 +++ drivers/lguest/hypercalls.c | 49 +++ drivers/lguest/interrupts_and_traps.c | 54 drivers/lguest/lg.h | 30 + drivers/lguest/page_tables.c | 114 drivers/lguest/segments.c |8 +-- drivers/lguest/x86/core.c | 30 - 7 files changed, 149 insertions(+), 160 deletions(-) diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c index4c26ba7..bb42fd0 100644 ---a/drivers/lguest/core.c +++b/drivers/lguest/core.c @@-151,23 +151,23 @@ int lguest_address_ok(const struct lguest *lg, /* This routine copies memory from the Guest. Here we can see how useful the * kill_lguest() routine we met in the Launcher can be: we return a random * value (all zeroes) instead of needing to return an error. */ -void__lgread(struct lguest *lg, void *b, unsigned long addr, unsigned bytes) +void__lgread(struct lg_cpu *cpu, void *b, unsigned long addr, unsigned bytes) { - if(!lguest_address_ok(lg, addr, bytes) - || copy_from_user(b, lg-mem_base + addr, bytes) != 0) { + if(!lguest_address_ok(cpu-lg, addr, bytes) + || copy_from_user(b, cpu-lg-mem_base + addr, bytes) != 0) { /* copy_from_user should do this, but as we rely on it... */ memset(b, 0, bytes); - kill_guest(lg,bad read address %#lx len %u, addr, bytes); + kill_guest(cpu,bad read address %#lx len %u, addr, bytes); } } /* This is the write (copy into guest) version. */ -void__lgwrite(struct lguest *lg, unsigned long addr, const void *b, +void__lgwrite(struct lg_cpu *cpu, unsigned long addr, const void *b, unsigned bytes) { - if(!lguest_address_ok(lg, addr, bytes) - || copy_to_user(lg-mem_base + addr, b, bytes) != 0) - kill_guest(lg,bad write address %#lx len %u, addr, bytes); + if(!lguest_address_ok(cpu-lg, addr, bytes) + || copy_to_user(cpu-lg-mem_base + addr, b, bytes) != 0) + kill_guest(cpu,bad write address %#lx len %u, addr, bytes); } /*:*/ @@-176,10 +176,8 @@ void __lgwrite(struct lguest *lg, unsigned long addr, const void *b, * going around and around until something interesting happens. */ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) { - structlguest *lg = cpu-lg; - /* We stop running once the Guest is dead. */ - while(!lg-dead) { + while(!cpu-lg-dead) { /* First we run any hypercalls the Guest wants done. */ if (cpu-hcall) do_hypercalls(cpu); @@-212,7 +210,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) /* Just make absolutely sure the Guest is still alive. One of * those hypercalls could have been fatal, for example. */ - if(lg-dead) + if(cpu-lg-dead) break; /* If the Guest asked to be stopped, we sleep. The Guest's @@-237,7 +235,7 @@ int run_guest(struct lg_cpu *cpu, unsigned long __user *user) lguest_arch_handle_trap(cpu); } - if(lg-dead == ERR_PTR(-ERESTART)) + if(cpu-lg-dead == ERR_PTR(-ERESTART)) return -ERESTART; /* The Guest is dead = No such file or directory */ return -ENOENT; diff--git a/drivers/lguest/hypercalls.c b/drivers/lguest/hypercalls.c index0471018..32666d0 100644 ---a/drivers/lguest/hypercalls.c +++b/drivers/lguest/hypercalls.c @@-31,8 +31,6 @@ * Or gets killed. Or, in the case of LHCALL_CRASH, both. */ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) { - structlguest *lg = cpu-lg; - switch (args-arg0) { case LHCALL_FLUSH_ASYNC: /* This call does nothing, except by breaking out of the Guest @@-41,7 +39,7 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) case LHCALL_LGUEST_INIT: /* You can't get here unless you're already initialized. Don't * do that. */ - kill_guest(lg,already have lguest_data); + kill_guest(cpu,already have lguest_data); break; case LHCALL_SHUTDOWN: { /* Shutdown is such a trivial hypercall that we do it in four @@-49,11 +47,11 @@ static void do_hcall(struct lg_cpu *cpu, struct hcall_args *args) char msg[128]; /* If the lgread fails, it will call kill_guest() itself; the * kill_guest() with the message will be ignored. */ - __lgread(lg,msg,
[PATCH 0/7] More lguest massage.
urrently, lguest module can't be compiled without the PARAVIRT flag being on.This is a fake dependency, since the module itself shouldn't need any paravirtoverride. Reason for that is the reference to pv_info structure ininitial loading tests. his patch removes it in favour of a more generic error message. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/core.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c indexbb42fd0..97b76d6 100644 ---a/drivers/lguest/core.c +++b/drivers/lguest/core.c @@-255,7 +255,7 @@ static int __init init(void) /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */ if (paravirt_enabled()) { - printk(lguestis afraid of %s\n, pv_info.name); + printk(lguestcan't run under another hypervisor); return -EPERM; } -- 1.5.0.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 0/7] More lguest massage.
I don't have _any_ idea about what happened to those patches. They were sent through the normal git-send-email script, but for some reason, all got the same subject. They might be okay for the review, but anyone willing to try it more seriously, please grab it at http://glommer.net/patches-lguest.tar.gz On Jan 17, 2008 10:35 PM, Glauber de Oliveira Costa [EMAIL PROTECTED] wrote: urrently, lguest module can't be compiled without the PARAVIRT flag being on.This is a fake dependency, since the module itself shouldn't need any paravirtoverride. Reason for that is the reference to pv_info structure ininitial loading tests. his patch removes it in favour of a more generic error message. Signed-off-by:Glauber de Oliveira Costa [EMAIL PROTECTED] --- drivers/lguest/core.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff--git a/drivers/lguest/core.c b/drivers/lguest/core.c indexbb42fd0..97b76d6 100644 ---a/drivers/lguest/core.c +++b/drivers/lguest/core.c @@-255,7 +255,7 @@ static int __init init(void) /* Lguest can't run under Xen, VMI or itself. It does Tricky Stuff. */ if (paravirt_enabled()) { - printk(lguestis afraid of %s\n, pv_info.name); + printk(lguestcan't run under another hypervisor); return -EPERM; } -- 1.5.0.6 -- Glauber de Oliveira Costa. Free as in Freedom http://glommer.net The less confident you are, the more serious you have to act. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/