diff options
| -rw-r--r-- | Documentation/lguest/.gitignore | 1 | ||||
| -rw-r--r-- | Documentation/lguest/lguest.txt | 11 | ||||
| -rw-r--r-- | arch/x86/include/asm/lguest_hcall.h | 2 | ||||
| -rw-r--r-- | arch/x86/lguest/boot.c | 16 | ||||
| -rw-r--r-- | drivers/lguest/lg.h | 3 | ||||
| -rw-r--r-- | drivers/lguest/segments.c | 13 | ||||
| -rw-r--r-- | drivers/lguest/x86/core.c | 9 | ||||
| -rw-r--r-- | drivers/virtio/virtio_balloon.c | 3 |
8 files changed, 35 insertions, 23 deletions
diff --git a/Documentation/lguest/.gitignore b/Documentation/lguest/.gitignore new file mode 100644 index 000000000000..115587fd5f65 --- /dev/null +++ b/Documentation/lguest/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| lguest | |||
diff --git a/Documentation/lguest/lguest.txt b/Documentation/lguest/lguest.txt index 29510dc51510..28c747362f95 100644 --- a/Documentation/lguest/lguest.txt +++ b/Documentation/lguest/lguest.txt | |||
| @@ -3,11 +3,11 @@ | |||
| 3 | /, /` - or, A Young Coder's Illustrated Hypervisor | 3 | /, /` - or, A Young Coder's Illustrated Hypervisor |
| 4 | \\"--\\ http://lguest.ozlabs.org | 4 | \\"--\\ http://lguest.ozlabs.org |
| 5 | 5 | ||
| 6 | Lguest is designed to be a minimal hypervisor for the Linux kernel, for | 6 | Lguest is designed to be a minimal 32-bit x86 hypervisor for the Linux kernel, |
| 7 | Linux developers and users to experiment with virtualization with the | 7 | for Linux developers and users to experiment with virtualization with the |
| 8 | minimum of complexity. Nonetheless, it should have sufficient | 8 | minimum of complexity. Nonetheless, it should have sufficient features to |
| 9 | features to make it useful for specific tasks, and, of course, you are | 9 | make it useful for specific tasks, and, of course, you are encouraged to fork |
| 10 | encouraged to fork and enhance it (see drivers/lguest/README). | 10 | and enhance it (see drivers/lguest/README). |
| 11 | 11 | ||
| 12 | Features: | 12 | Features: |
| 13 | 13 | ||
| @@ -37,6 +37,7 @@ Running Lguest: | |||
| 37 | "Paravirtualized guest support" = Y | 37 | "Paravirtualized guest support" = Y |
| 38 | "Lguest guest support" = Y | 38 | "Lguest guest support" = Y |
| 39 | "High Memory Support" = off/4GB | 39 | "High Memory Support" = off/4GB |
| 40 | "PAE (Physical Address Extension) Support" = N | ||
| 40 | "Alignment value to which kernel should be aligned" = 0x100000 | 41 | "Alignment value to which kernel should be aligned" = 0x100000 |
| 41 | (CONFIG_PARAVIRT=y, CONFIG_LGUEST_GUEST=y, CONFIG_HIGHMEM64G=n and | 42 | (CONFIG_PARAVIRT=y, CONFIG_LGUEST_GUEST=y, CONFIG_HIGHMEM64G=n and |
| 42 | CONFIG_PHYSICAL_ALIGN=0x100000) | 43 | CONFIG_PHYSICAL_ALIGN=0x100000) |
diff --git a/arch/x86/include/asm/lguest_hcall.h b/arch/x86/include/asm/lguest_hcall.h index 0f4ee7148afe..faae1996487b 100644 --- a/arch/x86/include/asm/lguest_hcall.h +++ b/arch/x86/include/asm/lguest_hcall.h | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #define LHCALL_FLUSH_ASYNC 0 | 5 | #define LHCALL_FLUSH_ASYNC 0 |
| 6 | #define LHCALL_LGUEST_INIT 1 | 6 | #define LHCALL_LGUEST_INIT 1 |
| 7 | #define LHCALL_SHUTDOWN 2 | 7 | #define LHCALL_SHUTDOWN 2 |
| 8 | #define LHCALL_LOAD_GDT 3 | ||
| 9 | #define LHCALL_NEW_PGTABLE 4 | 8 | #define LHCALL_NEW_PGTABLE 4 |
| 10 | #define LHCALL_FLUSH_TLB 5 | 9 | #define LHCALL_FLUSH_TLB 5 |
| 11 | #define LHCALL_LOAD_IDT_ENTRY 6 | 10 | #define LHCALL_LOAD_IDT_ENTRY 6 |
| @@ -17,6 +16,7 @@ | |||
| 17 | #define LHCALL_SET_PMD 15 | 16 | #define LHCALL_SET_PMD 15 |
| 18 | #define LHCALL_LOAD_TLS 16 | 17 | #define LHCALL_LOAD_TLS 16 |
| 19 | #define LHCALL_NOTIFY 17 | 18 | #define LHCALL_NOTIFY 17 |
| 19 | #define LHCALL_LOAD_GDT_ENTRY 18 | ||
| 20 | 20 | ||
| 21 | #define LGUEST_TRAP_ENTRY 0x1F | 21 | #define LGUEST_TRAP_ENTRY 0x1F |
| 22 | 22 | ||
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c index e94a11e42f98..a2085368a3dc 100644 --- a/arch/x86/lguest/boot.c +++ b/arch/x86/lguest/boot.c | |||
| @@ -273,15 +273,15 @@ static void lguest_load_idt(const struct desc_ptr *desc) | |||
| 273 | * controls the entire thing and the Guest asks it to make changes using the | 273 | * controls the entire thing and the Guest asks it to make changes using the |
| 274 | * LOAD_GDT hypercall. | 274 | * LOAD_GDT hypercall. |
| 275 | * | 275 | * |
| 276 | * This is the opposite of the IDT code where we have a LOAD_IDT_ENTRY | 276 | * This is the exactly like the IDT code. |
| 277 | * hypercall and use that repeatedly to load a new IDT. I don't think it | ||
| 278 | * really matters, but wouldn't it be nice if they were the same? Wouldn't | ||
| 279 | * it be even better if you were the one to send the patch to fix it? | ||
| 280 | */ | 277 | */ |
| 281 | static void lguest_load_gdt(const struct desc_ptr *desc) | 278 | static void lguest_load_gdt(const struct desc_ptr *desc) |
| 282 | { | 279 | { |
| 283 | BUG_ON((desc->size + 1) / 8 != GDT_ENTRIES); | 280 | unsigned int i; |
| 284 | kvm_hypercall2(LHCALL_LOAD_GDT, __pa(desc->address), GDT_ENTRIES); | 281 | struct desc_struct *gdt = (void *)desc->address; |
| 282 | |||
| 283 | for (i = 0; i < (desc->size+1)/8; i++) | ||
| 284 | kvm_hypercall3(LHCALL_LOAD_GDT_ENTRY, i, gdt[i].a, gdt[i].b); | ||
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | /* For a single GDT entry which changes, we do the lazy thing: alter our GDT, | 287 | /* For a single GDT entry which changes, we do the lazy thing: alter our GDT, |
| @@ -291,7 +291,9 @@ static void lguest_write_gdt_entry(struct desc_struct *dt, int entrynum, | |||
| 291 | const void *desc, int type) | 291 | const void *desc, int type) |
| 292 | { | 292 | { |
| 293 | native_write_gdt_entry(dt, entrynum, desc, type); | 293 | native_write_gdt_entry(dt, entrynum, desc, type); |
| 294 | kvm_hypercall2(LHCALL_LOAD_GDT, __pa(dt), GDT_ENTRIES); | 294 | /* Tell Host about this new entry. */ |
| 295 | kvm_hypercall3(LHCALL_LOAD_GDT_ENTRY, entrynum, | ||
| 296 | dt[entrynum].a, dt[entrynum].b); | ||
| 295 | } | 297 | } |
| 296 | 298 | ||
| 297 | /* OK, I lied. There are three "thread local storage" GDT entries which change | 299 | /* OK, I lied. There are three "thread local storage" GDT entries which change |
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h index ac8a4a3741b8..af92a176697f 100644 --- a/drivers/lguest/lg.h +++ b/drivers/lguest/lg.h | |||
| @@ -158,7 +158,8 @@ void free_interrupts(void); | |||
| 158 | /* segments.c: */ | 158 | /* segments.c: */ |
| 159 | void setup_default_gdt_entries(struct lguest_ro_state *state); | 159 | void setup_default_gdt_entries(struct lguest_ro_state *state); |
| 160 | void setup_guest_gdt(struct lg_cpu *cpu); | 160 | void setup_guest_gdt(struct lg_cpu *cpu); |
| 161 | void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num); | 161 | void load_guest_gdt_entry(struct lg_cpu *cpu, unsigned int i, |
| 162 | u32 low, u32 hi); | ||
| 162 | void guest_load_tls(struct lg_cpu *cpu, unsigned long tls_array); | 163 | void guest_load_tls(struct lg_cpu *cpu, unsigned long tls_array); |
| 163 | void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt); | 164 | void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt); |
| 164 | void copy_gdt_tls(const struct lg_cpu *cpu, struct desc_struct *gdt); | 165 | void copy_gdt_tls(const struct lg_cpu *cpu, struct desc_struct *gdt); |
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c index 4f15439b7f12..7ede64ffeef9 100644 --- a/drivers/lguest/segments.c +++ b/drivers/lguest/segments.c | |||
| @@ -144,18 +144,19 @@ void copy_gdt(const struct lg_cpu *cpu, struct desc_struct *gdt) | |||
| 144 | gdt[i] = cpu->arch.gdt[i]; | 144 | gdt[i] = cpu->arch.gdt[i]; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | /*H:620 This is where the Guest asks us to load a new GDT (LHCALL_LOAD_GDT). | 147 | /*H:620 This is where the Guest asks us to load a new GDT entry |
| 148 | * We copy it from the Guest and tweak the entries. */ | 148 | * (LHCALL_LOAD_GDT_ENTRY). We tweak the entry and copy it in. */ |
| 149 | void load_guest_gdt(struct lg_cpu *cpu, unsigned long table, u32 num) | 149 | void load_guest_gdt_entry(struct lg_cpu *cpu, u32 num, u32 lo, u32 hi) |
| 150 | { | 150 | { |
| 151 | /* We assume the Guest has the same number of GDT entries as the | 151 | /* We assume the Guest has the same number of GDT entries as the |
| 152 | * Host, otherwise we'd have to dynamically allocate the Guest GDT. */ | 152 | * Host, otherwise we'd have to dynamically allocate the Guest GDT. */ |
| 153 | if (num > ARRAY_SIZE(cpu->arch.gdt)) | 153 | if (num > ARRAY_SIZE(cpu->arch.gdt)) |
| 154 | kill_guest(cpu, "too many gdt entries %i", num); | 154 | kill_guest(cpu, "too many gdt entries %i", num); |
| 155 | 155 | ||
| 156 | /* We read the whole thing in, then fix it up. */ | 156 | /* Set it up, then fix it. */ |
| 157 | __lgread(cpu, cpu->arch.gdt, table, num * sizeof(cpu->arch.gdt[0])); | 157 | cpu->arch.gdt[num].a = lo; |
| 158 | fixup_gdt_table(cpu, 0, ARRAY_SIZE(cpu->arch.gdt)); | 158 | cpu->arch.gdt[num].b = hi; |
| 159 | fixup_gdt_table(cpu, num, num+1); | ||
| 159 | /* Mark that the GDT changed so the core knows it has to copy it again, | 160 | /* Mark that the GDT changed so the core knows it has to copy it again, |
| 160 | * even if the Guest is run on the same CPU. */ | 161 | * even if the Guest is run on the same CPU. */ |
| 161 | cpu->changed |= CHANGED_GDT; | 162 | cpu->changed |= CHANGED_GDT; |
diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c index a6b717644be0..1a83910f674f 100644 --- a/drivers/lguest/x86/core.c +++ b/drivers/lguest/x86/core.c | |||
| @@ -324,6 +324,11 @@ static void rewrite_hypercall(struct lg_cpu *cpu) | |||
| 324 | u8 insn[3] = {0xcd, 0x1f, 0x90}; | 324 | u8 insn[3] = {0xcd, 0x1f, 0x90}; |
| 325 | 325 | ||
| 326 | __lgwrite(cpu, guest_pa(cpu, cpu->regs->eip), insn, sizeof(insn)); | 326 | __lgwrite(cpu, guest_pa(cpu, cpu->regs->eip), insn, sizeof(insn)); |
| 327 | /* The above write might have caused a copy of that page to be made | ||
| 328 | * (if it was read-only). We need to make sure the Guest has | ||
| 329 | * up-to-date pagetables. As this doesn't happen often, we can just | ||
| 330 | * drop them all. */ | ||
| 331 | guest_pagetable_clear_all(cpu); | ||
| 327 | } | 332 | } |
| 328 | 333 | ||
| 329 | static bool is_hypercall(struct lg_cpu *cpu) | 334 | static bool is_hypercall(struct lg_cpu *cpu) |
| @@ -563,8 +568,8 @@ void __exit lguest_arch_host_fini(void) | |||
| 563 | int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args) | 568 | int lguest_arch_do_hcall(struct lg_cpu *cpu, struct hcall_args *args) |
| 564 | { | 569 | { |
| 565 | switch (args->arg0) { | 570 | switch (args->arg0) { |
| 566 | case LHCALL_LOAD_GDT: | 571 | case LHCALL_LOAD_GDT_ENTRY: |
| 567 | load_guest_gdt(cpu, args->arg1, args->arg2); | 572 | load_guest_gdt_entry(cpu, args->arg1, args->arg2, args->arg3); |
| 568 | break; | 573 | break; |
| 569 | case LHCALL_LOAD_IDT_ENTRY: | 574 | case LHCALL_LOAD_IDT_ENTRY: |
| 570 | load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3); | 575 | load_guest_idt_entry(cpu, args->arg1, args->arg2, args->arg3); |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 59268266b79a..9c76a061a04d 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
| @@ -190,7 +190,8 @@ static int balloon(void *_vballoon) | |||
| 190 | try_to_freeze(); | 190 | try_to_freeze(); |
| 191 | wait_event_interruptible(vb->config_change, | 191 | wait_event_interruptible(vb->config_change, |
| 192 | (diff = towards_target(vb)) != 0 | 192 | (diff = towards_target(vb)) != 0 |
| 193 | || kthread_should_stop()); | 193 | || kthread_should_stop() |
| 194 | || freezing(current)); | ||
| 194 | if (diff > 0) | 195 | if (diff > 0) |
| 195 | fill_balloon(vb, diff); | 196 | fill_balloon(vb, diff); |
| 196 | else if (diff < 0) | 197 | else if (diff < 0) |
