* [PATCH 01/11] x86: introduce virt_to_xen_l1e()
@ 2013-01-22 10:47 Jan Beulich
0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2013-01-22 10:47 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 1960 bytes --]
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5204,12 +5204,9 @@ int map_pages_to_xen(
/* Normal page mapping. */
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
{
- pl1e = alloc_xen_pagetable();
+ pl1e = virt_to_xen_l1e(virt);
if ( pl1e == NULL )
return -ENOMEM;
- clear_page(pl1e);
- l2e_write(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
- __PAGE_HYPERVISOR));
}
else if ( l2e_get_flags(*pl2e) & _PAGE_PSE )
{
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -121,6 +121,28 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
return l3e_to_l2e(*pl3e) + l2_table_offset(v);
}
+l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
+{
+ l2_pgentry_t *pl2e;
+
+ pl2e = virt_to_xen_l2e(v);
+ if ( !pl2e )
+ return NULL;
+
+ if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
+ {
+ l1_pgentry_t *pl1e = alloc_xen_pagetable();
+
+ if ( !pl1e )
+ return NULL;
+ clear_page(pl1e);
+ l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR));
+ }
+
+ BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE);
+ return l2e_to_l1e(*pl2e) + l1_table_offset(v);
+}
+
void *do_page_walk(struct vcpu *v, unsigned long addr)
{
unsigned long mfn = pagetable_get_pfn(v->arch.guest_table);
--- a/xen/include/asm-x86/page.h
+++ b/xen/include/asm-x86/page.h
@@ -328,6 +328,7 @@ void setup_idle_pagetable(void);
/* Allocator functions for Xen pagetables. */
void *alloc_xen_pagetable(void);
void free_xen_pagetable(void *v);
+l1_pgentry_t *virt_to_xen_l1e(unsigned long v);
l2_pgentry_t *virt_to_xen_l2e(unsigned long v);
l3_pgentry_t *virt_to_xen_l3e(unsigned long v);
[-- Attachment #2: x86-virt_to_xen_l1e.patch --]
[-- Type: text/plain, Size: 1990 bytes --]
x86: introduce virt_to_xen_l1e()
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5204,12 +5204,9 @@ int map_pages_to_xen(
/* Normal page mapping. */
if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
{
- pl1e = alloc_xen_pagetable();
+ pl1e = virt_to_xen_l1e(virt);
if ( pl1e == NULL )
return -ENOMEM;
- clear_page(pl1e);
- l2e_write(pl2e, l2e_from_pfn(virt_to_mfn(pl1e),
- __PAGE_HYPERVISOR));
}
else if ( l2e_get_flags(*pl2e) & _PAGE_PSE )
{
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -121,6 +121,28 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
return l3e_to_l2e(*pl3e) + l2_table_offset(v);
}
+l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
+{
+ l2_pgentry_t *pl2e;
+
+ pl2e = virt_to_xen_l2e(v);
+ if ( !pl2e )
+ return NULL;
+
+ if ( !(l2e_get_flags(*pl2e) & _PAGE_PRESENT) )
+ {
+ l1_pgentry_t *pl1e = alloc_xen_pagetable();
+
+ if ( !pl1e )
+ return NULL;
+ clear_page(pl1e);
+ l2e_write(pl2e, l2e_from_paddr(__pa(pl1e), __PAGE_HYPERVISOR));
+ }
+
+ BUG_ON(l2e_get_flags(*pl2e) & _PAGE_PSE);
+ return l2e_to_l1e(*pl2e) + l1_table_offset(v);
+}
+
void *do_page_walk(struct vcpu *v, unsigned long addr)
{
unsigned long mfn = pagetable_get_pfn(v->arch.guest_table);
--- a/xen/include/asm-x86/page.h
+++ b/xen/include/asm-x86/page.h
@@ -328,6 +328,7 @@ void setup_idle_pagetable(void);
/* Allocator functions for Xen pagetables. */
void *alloc_xen_pagetable(void);
void free_xen_pagetable(void *v);
+l1_pgentry_t *virt_to_xen_l1e(unsigned long v);
l2_pgentry_t *virt_to_xen_l2e(unsigned long v);
l3_pgentry_t *virt_to_xen_l3e(unsigned long v);
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-01-22 10:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-22 10:47 [PATCH 01/11] x86: introduce virt_to_xen_l1e() Jan Beulich
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.