# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1246884125 -3600
# Node ID d3e660723f8a0ff96fc99dd4ff4a3595de9d1d13
# Parent 09c96ee6c787518093ba515479df8a8c20e42520
Avoid compat_arg_xlat to be a large per-CPU object
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
xen-unstable changeset: 19896:bcee82a0e9d6
xen-unstable date: Mon Jul 06 11:51:19 2009 +0100
x86: PERCPU_SHIFT can be reduced to 12 now compat_arg_xlat_area is not
directly a per-cpu object.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset: 19897:3313efd1c367
xen-unstable date: Mon Jul 06 11:55:01 2009 +0100
---
xen/arch/x86/smpboot.c | 5 +++++
xen/arch/x86/x86_64/compat/mm.c | 8 ++++----
xen/arch/x86/x86_64/mm.c | 26 +++++++++++++++++++++++++-
xen/common/compat/domain.c | 2 +-
xen/common/compat/grant_table.c | 2 +-
xen/common/compat/memory.c | 2 +-
xen/include/asm-x86/percpu.h | 2 +-
xen/include/asm-x86/x86_64/uaccess.h | 3 ++-
8 files changed, 40 insertions(+), 10 deletions(-)
diff -r 09c96ee6c787 -r d3e660723f8a xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/arch/x86/smpboot.c Mon Jul 06 13:42:05 2009 +0100
@@ -868,6 +868,11 @@ static int __devinit do_boot_cpu(int api
smpboot_setup_warm_reset_vector(start_eip);
+#ifdef __x86_64__
+ if (!per_cpu(compat_arg_xlat, cpu))
+ setup_compat_arg_xlat(cpu, apicid_to_node[apicid]);
+#endif
+
if (!idt_tables[cpu]) {
idt_tables[cpu] = xmalloc_array(idt_entry_t, IDT_ENTRIES);
memcpy(idt_tables[cpu], idt_table,
diff -r 09c96ee6c787 -r d3e660723f8a xen/arch/x86/x86_64/compat/mm.c
--- a/xen/arch/x86/x86_64/compat/mm.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/arch/x86/x86_64/compat/mm.c Mon Jul 06 13:42:05 2009 +0100
@@ -58,7 +58,7 @@ int compat_arch_memory_op(int op, XEN_GU
case XENMEM_add_to_physmap:
{
struct compat_add_to_physmap cmp;
- struct xen_add_to_physmap *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+ struct xen_add_to_physmap *nat = COMPAT_ARG_XLAT_VIRT_BASE;
if ( copy_from_guest(&cmp, arg, 1) )
return -EFAULT;
@@ -72,7 +72,7 @@ int compat_arch_memory_op(int op, XEN_GU
case XENMEM_set_memory_map:
{
struct compat_foreign_memory_map cmp;
- struct xen_foreign_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+ struct xen_foreign_memory_map *nat = COMPAT_ARG_XLAT_VIRT_BASE;
if ( copy_from_guest(&cmp, arg, 1) )
return -EFAULT;
@@ -91,7 +91,7 @@ int compat_arch_memory_op(int op, XEN_GU
case XENMEM_machine_memory_map:
{
struct compat_memory_map cmp;
- struct xen_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+ struct xen_memory_map *nat = COMPAT_ARG_XLAT_VIRT_BASE;
if ( copy_from_guest(&cmp, arg, 1) )
return -EFAULT;
@@ -189,7 +189,7 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm
if ( unlikely(!guest_handle_okay(cmp_uops, count)) )
return -EFAULT;
- set_xen_guest_handle(nat_ops, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+ set_xen_guest_handle(nat_ops, COMPAT_ARG_XLAT_VIRT_BASE);
for ( ; count; count -= i )
{
diff -r 09c96ee6c787 -r d3e660723f8a xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/arch/x86/x86_64/mm.c Mon Jul 06 13:42:05 2009 +0100
@@ -22,6 +22,7 @@
#include <xen/init.h>
#include <xen/mm.h>
#include <xen/sched.h>
+#include <xen/numa.h>
#include <xen/guest_access.h>
#include <asm/current.h>
#include <asm/asm_defns.h>
@@ -36,7 +37,7 @@ unsigned int m2p_compat_vstart = __HYPER
unsigned int m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
#endif
-DEFINE_PER_CPU(char, compat_arg_xlat[COMPAT_ARG_XLAT_SIZE]);
+DEFINE_PER_CPU(void *, compat_arg_xlat);
/* Top-level master (and idle-domain) page directory. */
l4_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
@@ -219,6 +220,25 @@ void __init zap_low_mappings(void)
0x10, __PAGE_HYPERVISOR);
}
+int __cpuinit setup_compat_arg_xlat(unsigned int cpu, int node)
+{
+ unsigned int order = get_order_from_bytes(COMPAT_ARG_XLAT_SIZE);
+ unsigned long sz = PAGE_SIZE << order;
+ unsigned int memflags = node != NUMA_NO_NODE ? MEMF_node(node) : 0;
+ struct page_info *pg;
+
+ pg = alloc_domheap_pages(NULL, order, memflags);
+ if ( !pg )
+ return -ENOMEM;
+
+ for ( ; (sz -= PAGE_SIZE) >= COMPAT_ARG_XLAT_SIZE; ++pg )
+ free_domheap_page(pg);
+
+ per_cpu(compat_arg_xlat, cpu) = page_to_virt(pg);
+
+ return 0;
+}
+
void __init subarch_init_memory(void)
{
unsigned long i, v, m2p_start_mfn;
@@ -276,6 +296,10 @@ void __init subarch_init_memory(void)
share_xen_page_with_privileged_guests(page, XENSHARE_readonly);
}
}
+
+ if ( setup_compat_arg_xlat(smp_processor_id(),
+ apicid_to_node[boot_cpu_physical_apicid]) )
+ panic("Could not setup argument translation area");
}
long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
diff -r 09c96ee6c787 -r d3e660723f8a xen/common/compat/domain.c
--- a/xen/common/compat/domain.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/common/compat/domain.c Mon Jul 06 13:42:05 2009 +0100
@@ -87,7 +87,7 @@ int compat_vcpu_op(int cmd, int vcpuid,
if ( copy_from_guest(&cmp, arg, 1) )
return -EFAULT;
- nat = (void *)COMPAT_ARG_XLAT_VIRT_BASE;
+ nat = COMPAT_ARG_XLAT_VIRT_BASE;
XLAT_vcpu_set_singleshot_timer(nat, &cmp);
rc = do_vcpu_op(cmd, vcpuid, guest_handle_from_ptr(nat, void));
break;
diff -r 09c96ee6c787 -r d3e660723f8a xen/common/compat/grant_table.c
--- a/xen/common/compat/grant_table.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/common/compat/grant_table.c Mon Jul 06 13:42:05 2009 +0100
@@ -97,7 +97,7 @@ int compat_grant_table_op(unsigned int c
struct compat_gnttab_copy copy;
} cmp;
- set_xen_guest_handle(nat.uop, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+ set_xen_guest_handle(nat.uop, COMPAT_ARG_XLAT_VIRT_BASE);
switch ( cmd )
{
case GNTTABOP_setup_table:
diff -r 09c96ee6c787 -r d3e660723f8a xen/common/compat/memory.c
--- a/xen/common/compat/memory.c Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/common/compat/memory.c Mon Jul 06 13:42:05 2009 +0100
@@ -27,7 +27,7 @@ int compat_memory_op(unsigned int cmd, X
struct compat_translate_gpfn_list xlat;
} cmp;
- set_xen_guest_handle(nat.hnd, (void *)COMPAT_ARG_XLAT_VIRT_BASE);
+ set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE);
split = 0;
switch ( op )
{
diff -r 09c96ee6c787 -r d3e660723f8a xen/include/asm-x86/percpu.h
--- a/xen/include/asm-x86/percpu.h Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/include/asm-x86/percpu.h Mon Jul 06 13:42:05 2009 +0100
@@ -1,7 +1,7 @@
#ifndef __X86_PERCPU_H__
#define __X86_PERCPU_H__
-#define PERCPU_SHIFT 13
+#define PERCPU_SHIFT 12
#define PERCPU_SIZE (1UL << PERCPU_SHIFT)
/* Separate out the type, so (int[3], foo) works. */
diff -r 09c96ee6c787 -r d3e660723f8a xen/include/asm-x86/x86_64/uaccess.h
--- a/xen/include/asm-x86/x86_64/uaccess.h Mon Jul 06 13:37:38 2009 +0100
+++ b/xen/include/asm-x86/x86_64/uaccess.h Mon Jul 06 13:42:05 2009 +0100
@@ -3,7 +3,8 @@
#define COMPAT_ARG_XLAT_VIRT_BASE this_cpu(compat_arg_xlat)
#define COMPAT_ARG_XLAT_SIZE PAGE_SIZE
-DECLARE_PER_CPU(char, compat_arg_xlat[COMPAT_ARG_XLAT_SIZE]);
+DECLARE_PER_CPU(void *, compat_arg_xlat);
+int setup_compat_arg_xlat(unsigned int cpu, int node);
#define is_compat_arg_xlat_range(addr, size) ({ \
unsigned long __off; \
__off = (unsigned long)(addr) - (unsigned long)COMPAT_ARG_XLAT_VIRT_BASE; \
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|