@@ -2,11 +2,17 @@
#include <asm/mc146818rtc.h>
#ifndef COMPAT
-l4_pgentry_t *__read_mostly efi_l4_pgtable;
+mfn_t __read_mostly efi_l4_mfn = INVALID_MFN_INITIALIZER;
void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t l4e)
{
- if ( efi_l4_pgtable )
- l4e_write(efi_l4_pgtable + l4idx, l4e);
+ if ( !mfn_eq(efi_l4_mfn, INVALID_MFN) )
+ {
+ l4_pgentry_t *l4t;
+
+ l4t = map_xen_pagetable_new(efi_l4_mfn);
+ l4e_write(l4t + l4idx, l4e);
+ UNMAP_XEN_PAGETABLE_NEW(l4t);
+ }
}
#endif
@@ -1488,6 +1488,7 @@ void __init efi_init_memory(void)
unsigned int prot;
} *extra, *extra_head = NULL;
#endif
+ l4_pgentry_t *efi_l4_pgtable;
free_ebmalloc_unused_mem();
@@ -1603,8 +1604,9 @@ void __init efi_init_memory(void)
mdesc_ver, efi_memmap);
#else
/* Set up 1:1 page tables to do runtime calls in "physical" mode. */
- efi_l4_pgtable = alloc_xen_pagetable();
- BUG_ON(!efi_l4_pgtable);
+ efi_l4_mfn = alloc_xen_pagetable_new();
+ BUG_ON(mfn_eq(efi_l4_mfn, INVALID_MFN));
+ efi_l4_pgtable = map_xen_pagetable_new(efi_l4_mfn);
clear_page(efi_l4_pgtable);
copy_mapping(efi_l4_pgtable, 0, max_page, ram_range_valid);
@@ -1703,6 +1705,8 @@ void __init efi_init_memory(void)
i < l4_table_offset(DIRECTMAP_VIRT_END); ++i )
efi_l4_pgtable[i] = idle_pg_table[i];
#endif
+
+ UNMAP_XEN_PAGETABLE_NEW(efi_l4_pgtable);
}
#endif
@@ -6,6 +6,7 @@
#include <efi/eficapsule.h>
#include <efi/efiapi.h>
#include <xen/efi.h>
+#include <xen/mm.h>
#include <xen/spinlock.h>
#include <asm/page.h>
@@ -29,7 +30,7 @@ extern UINTN efi_memmap_size, efi_mdesc_size;
extern void *efi_memmap;
#ifdef CONFIG_X86
-extern l4_pgentry_t *efi_l4_pgtable;
+extern mfn_t efi_l4_mfn;
#endif
extern const struct efi_pci_rom *efi_pci_roms;
@@ -85,7 +85,7 @@ struct efi_rs_state efi_rs_enter(void)
static const u32 mxcsr = MXCSR_DEFAULT;
struct efi_rs_state state = { .cr3 = 0 };
- if ( !efi_l4_pgtable )
+ if ( mfn_eq(efi_l4_mfn, INVALID_MFN) )
return state;
state.cr3 = read_cr3();
@@ -111,7 +111,7 @@ struct efi_rs_state efi_rs_enter(void)
lgdt(&gdt_desc);
}
- switch_cr3_cr4(virt_to_maddr(efi_l4_pgtable), read_cr4());
+ switch_cr3_cr4(mfn_to_maddr(efi_l4_mfn), read_cr4());
return state;
}
@@ -140,9 +140,9 @@ void efi_rs_leave(struct efi_rs_state *state)
bool efi_rs_using_pgtables(void)
{
- return efi_l4_pgtable &&
+ return !mfn_eq(efi_l4_mfn, INVALID_MFN) &&
(smp_processor_id() == efi_rs_on_cpu) &&
- (read_cr3() == virt_to_maddr(efi_l4_pgtable));
+ (read_cr3() == mfn_to_maddr(efi_l4_mfn));
}
unsigned long efi_get_time(void)