diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2009-04-20 01:14:00 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2009-04-19 09:44:01 -0400 |
commit | a489f0b555b753f9df8ddc24c7e74f657ef7ee7b (patch) | |
tree | 560bd8c56524b658eb0b46e03ef42e262eb5f9b7 /arch | |
parent | 88df781afb788fa588dbf2e77f205214022a8893 (diff) |
lguest: fix guest crash on non-linear addresses in gdt pvops
Fixes guest crash 'lguest: bad read address 0x4800000 len 256'
The new per-cpu allocator ends up handing a non-linear address to
write_gdt_entry. We do __pa() on it, and hand it to the host, which
kills us.
I've long wanted to make the hypercall "LOAD_GDT_ENTRY" to match the IDT
code, but had no pressing reason until now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: lguest@ozlabs.org
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/lguest_hcall.h | 2 | ||||
-rw-r--r-- | arch/x86/lguest/boot.c | 16 |
2 files changed, 10 insertions, 8 deletions
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 |