diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2013-04-22 06:40:37 +0200 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2013-04-22 08:01:35 +0200 |
commit | c215a8b9eb17739c01d59faa7db9d1ef162a82a8 (patch) | |
tree | 915c1175bb30c25462f39c9450899368d383c411 /drivers/lguest | |
parent | lguest: check vaddr not pgd for Switcher protection. (diff) | |
download | linux-c215a8b9eb17739c01d59faa7db9d1ef162a82a8.tar.xz linux-c215a8b9eb17739c01d59faa7db9d1ef162a82a8.zip |
lguest: remove RESERVE_MEM constant.
We can use switcher_addr directly.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/lguest')
-rw-r--r-- | drivers/lguest/page_tables.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c index a2454a24a10c..27cbb186a911 100644 --- a/drivers/lguest/page_tables.c +++ b/drivers/lguest/page_tables.c @@ -63,10 +63,8 @@ */ #ifdef CONFIG_X86_PAE #define SWITCHER_PMD_INDEX (PTRS_PER_PMD - 1) -#define RESERVE_MEM 2U #define CHECK_GPGD_MASK _PAGE_PRESENT #else -#define RESERVE_MEM 4U #define CHECK_GPGD_MASK _PAGE_TABLE #endif @@ -977,15 +975,21 @@ int init_guest_pagetable(struct lguest *lg) /*H:508 When the Guest calls LHCALL_LGUEST_INIT we do more setup. */ void page_table_guest_data_init(struct lg_cpu *cpu) { + /* + * We tell the Guest that it can't use the virtual addresses + * used by the Switcher. This trick is equivalent to 4GB - + * switcher_addr. + */ + u32 top = ~switcher_addr + 1; + /* We get the kernel address: above this is all kernel memory. */ if (get_user(cpu->lg->kernel_address, - &cpu->lg->lguest_data->kernel_address) + &cpu->lg->lguest_data->kernel_address) /* - * We tell the Guest that it can't use the top 2 or 4 MB - * of virtual addresses used by the Switcher. + * We tell the Guest that it can't use the top virtual + * addresses (used by the Switcher). */ - || put_user(RESERVE_MEM * 1024 * 1024, - &cpu->lg->lguest_data->reserve_mem)) { + || put_user(top, &cpu->lg->lguest_data->reserve_mem)) { kill_guest(cpu, "bad guest page %p", cpu->lg->lguest_data); return; } |