|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 27/44] x86/smp: Allocate a percpu linear range for the compat translation area.
The existing translation area claims to be 2 frames and a guard page, but is
actually 4 frames with no guard page at all.
Allocate 2 frames in the percpu area, which actually has unmapped frames on
either side.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/smpboot.c | 27 +++++++++++++++++++++++++++
xen/include/asm-x86/config.h | 2 ++
2 files changed, 29 insertions(+)
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 6a5f18a..a5d3f7a 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -646,6 +646,8 @@ void cpu_exit_clear(unsigned int cpu)
enum percpu_alter_action {
PERCPU_MAP, /* Map existing frame: page and flags are input parameters. */
PERCPU_ALLOC_L1T, /* Allocate an L1 table. optionally returned via *page.
*/
+ PERCPU_ALLOC_FRAME, /* Allocate a frame. flags is an input, and *page is
+ * optionally an output. */
};
static int _alter_percpu_mappings(
unsigned int cpu, unsigned long linear,
@@ -707,6 +709,15 @@ static int _alter_percpu_mappings(
l1t[l1_table_offset(linear)] = l1e_from_page(*page, flags);
break;
+ case PERCPU_ALLOC_FRAME:
+ pg = alloc_domheap_page(NULL, memflags);
+ if ( !pg )
+ goto out;
+
+ clear_domain_page(page_to_mfn(pg));
+ l1t[l1_table_offset(linear)] = l1e_from_page(pg, flags);
+
+ /* Fallthrough */
case PERCPU_ALLOC_L1T:
if ( page )
*page = pg;
@@ -742,6 +753,12 @@ static int percpu_alloc_l1t(unsigned int cpu, unsigned
long linear,
return _alter_percpu_mappings(cpu, linear, PERCPU_ALLOC_L1T, page, 0);
}
+static int percpu_alloc_frame(unsigned int cpu, unsigned long linear,
+ struct page_info **page, unsigned int flags)
+{
+ return _alter_percpu_mappings(cpu, linear, PERCPU_ALLOC_FRAME, page,
flags);
+}
+
/* Allocate data common between the BSP and APs. */
static int cpu_smpboot_alloc_common(unsigned int cpu)
{
@@ -795,6 +812,16 @@ static int cpu_smpboot_alloc_common(unsigned int cpu)
if ( rc )
goto out;
+ /* Allocate two pages for the XLAT area. */
+ rc = percpu_alloc_frame(cpu, PERCPU_XLAT_START, NULL,
+ PAGE_HYPERVISOR_RW | MAP_PERCPU_AUTOFREE);
+ if ( rc )
+ goto out;
+ rc = percpu_alloc_frame(cpu, PERCPU_XLAT_START + PAGE_SIZE, NULL,
+ PAGE_HYPERVISOR_RW | MAP_PERCPU_AUTOFREE);
+ if ( rc )
+ goto out;
+
rc = 0; /* Success */
out:
diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h
index f78cbde..3d64047 100644
--- a/xen/include/asm-x86/config.h
+++ b/xen/include/asm-x86/config.h
@@ -300,6 +300,8 @@ extern unsigned long xen_phys_start;
#define PERCPU_MAPCACHE_START (PERCPU_LINEAR_START + MB(4))
#define PERCPU_MAPCACHE_END (PERCPU_MAPCACHE_START + MB(2))
+#define PERCPU_XLAT_START (PERCPU_LINEAR_START + MB(6) + KB(8))
+
/* GDT/LDT shadow mapping area. The first per-domain-mapping sub-area. */
#define GDT_LDT_VCPU_SHIFT 5
#define GDT_LDT_VCPU_VA_SHIFT (GDT_LDT_VCPU_SHIFT + PAGE_SHIFT)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |