Mailing List Archive

Hand merged
ChangeSet 1.1267, 2005/04/04 17:13:17+01:00, mafetter@fleming.research

Hand merged

Signed-off-by: michael.fetterman@cl.cam.ac.uk



tools/libxc/xc.h | 5
tools/misc/Makefile | 5
xen/arch/x86/domain.c | 97 +---
xen/arch/x86/domain_build.c | 58 ++
xen/arch/x86/mm.c | 1006 +++++++++++++-------------------------------
xen/arch/x86/shadow.c | 18
xen/arch/x86/traps.c | 11
xen/arch/x86/vmx.c | 31 -
xen/arch/x86/vmx_io.c | 2
xen/common/grant_table.c | 25 -
xen/common/page_alloc.c | 17
xen/common/schedule.c | 3
xen/drivers/char/console.c | 19
xen/include/asm-x86/mm.h | 84 +++
xen/include/asm-x86/page.h | 15
xen/include/xen/sched.h | 1
16 files changed, 553 insertions(+), 844 deletions(-)


diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h
--- a/tools/libxc/xc.h 2005-04-05 12:21:46 -04:00
+++ b/tools/libxc/xc.h 2005-04-05 12:21:46 -04:00
@@ -381,6 +381,11 @@
u32 op,
xc_perfc_desc_t *desc);

+/* read/write msr */
+long long xc_msr_read(int xc_handle, int cpu_mask, int msr);
+int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
+ unsigned int high);
+
/**
* Memory maps a range within one domain to a local address range. Mappings
* should be unmapped with munmap and should follow the same rules as mmap
diff -Nru a/tools/misc/Makefile b/tools/misc/Makefile
--- a/tools/misc/Makefile 2005-04-05 12:21:46 -04:00
+++ b/tools/misc/Makefile 2005-04-05 12:21:46 -04:00
@@ -13,7 +13,7 @@

HDRS = $(wildcard *.h)

-TARGETS = xenperf
+TARGETS = xenperf xc_shadow

INSTALL_BIN = $(TARGETS) xencons
INSTALL_SBIN = netfix xm xend xensv xenperf
@@ -21,6 +21,7 @@
all: build
build: $(TARGETS)
$(MAKE) -C miniterm
+ $(MAKE) -C cpuperf
$(MAKE) -C mbootpack

install: build
@@ -28,6 +29,7 @@
[ -d $(DESTDIR)/usr/sbin ] || $(INSTALL_DIR) $(DESTDIR)/usr/sbin
$(INSTALL_PROG) $(INSTALL_BIN) $(DESTDIR)/usr/bin
$(INSTALL_PROG) $(INSTALL_SBIN) $(DESTDIR)/usr/sbin
+ $(MAKE) -C cpuperf install
# No sense in installing miniterm on the Xen box.
# $(MAKE) -C miniterm install
# Likewise mbootpack
@@ -36,6 +38,7 @@
clean:
$(RM) *.o $(TARGETS) *~
$(MAKE) -C miniterm clean
+ $(MAKE) -C cpuperf clean
$(MAKE) -C mbootpack clean

%.o: %.c $(HDRS) Makefile
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c 2005-04-05 12:21:46 -04:00
+++ b/xen/arch/x86/domain.c 2005-04-05 12:21:46 -04:00
@@ -259,12 +259,14 @@
machine_to_phys_mapping[virt_to_phys(d->arch.mm_perdomain_pt) >>
PAGE_SHIFT] = INVALID_M2P_ENTRY;
ed->arch.perdomain_ptes = d->arch.mm_perdomain_pt;
-#if 0 /* don't need this yet, but maybe soon! */
- ed->arch.guest_vtable = linear_l2_table;
- ed->arch.shadow_vtable = shadow_linear_l2_table;
-#endif
+
+ ed->arch.guest_vtable = __linear_l2_table;
+ ed->arch.shadow_vtable = __shadow_linear_l2_table;

#ifdef __x86_64__
+ ed->arch.guest_vl3table = __linear_l3_table;
+ ed->arch.guest_vl4table = __linear_l4_table;
+
d->arch.mm_perdomain_l2 = (l2_pgentry_t *)alloc_xenheap_page();
memset(d->arch.mm_perdomain_l2, 0, PAGE_SIZE);
d->arch.mm_perdomain_l2[l2_table_offset(PERDOMAIN_VIRT_START)] =
@@ -276,6 +278,7 @@
#endif

shadow_lock_init(d);
+ INIT_LIST_HEAD(&d->arch.free_shadow_frames);
}
}

@@ -307,70 +310,6 @@
reset_stack_and_jump(vmx_asm_do_launch);
}

-unsigned long alloc_monitor_pagetable(struct exec_domain *ed)
-{
- unsigned long mmfn;
- l2_pgentry_t *mpl2e;
- struct pfn_info *mmfn_info;
- struct domain *d = ed->domain;
-
- ASSERT(pagetable_val(ed->arch.monitor_table) == 0);
-
- mmfn_info = alloc_domheap_page(NULL);
- ASSERT(mmfn_info != NULL);
-
- mmfn = (unsigned long) (mmfn_info - frame_table);
- mpl2e = (l2_pgentry_t *) map_domain_mem(mmfn << PAGE_SHIFT);
- memset(mpl2e, 0, PAGE_SIZE);
-
- memcpy(&mpl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
- &idle_pg_table[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
- HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t));
-
- mpl2e[l2_table_offset(PERDOMAIN_VIRT_START)] =
- mk_l2_pgentry((__pa(d->arch.mm_perdomain_pt) & PAGE_MASK)
- | __PAGE_HYPERVISOR);
-
- ed->arch.monitor_vtable = mpl2e;
-
- /* Map the p2m map into the Read-Only MPT space for this domain. */
- mpl2e[l2_table_offset(RO_MPT_VIRT_START)] =
- mk_l2_pgentry(pagetable_val(ed->arch.phys_table) | __PAGE_HYPERVISOR);
-
- return mmfn;
-}
-
-/*
- * Free the pages for monitor_table and hl2_table
- */
-static void free_monitor_pagetable(struct exec_domain *ed)
-{
- l2_pgentry_t *mpl2e;
- unsigned long mfn;
-
- ASSERT( pagetable_val(ed->arch.monitor_table) );
-
- mpl2e = ed->arch.monitor_vtable;
-
- /*
- * First get the mfn for hl2_table by looking at monitor_table
- */
- mfn = l2_pgentry_val(mpl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT])
- >> PAGE_SHIFT;
-
- free_domheap_page(&frame_table[mfn]);
- unmap_domain_mem(mpl2e);
-
- /*
- * Then free monitor_table.
- */
- mfn = (pagetable_val(ed->arch.monitor_table)) >> PAGE_SHIFT;
- free_domheap_page(&frame_table[mfn]);
-
- ed->arch.monitor_table = mk_pagetable(0);
- ed->arch.monitor_vtable = 0;
-}
-
static int vmx_final_setup_guest(struct exec_domain *ed,
full_execution_context_t *full_context)
{
@@ -421,8 +360,6 @@
shadow_mode_enable(ed->domain, SHM_enable|SHM_translate|SHM_external);
}

- update_pagetables(ed);
-
return 0;

out:
@@ -509,7 +446,7 @@
d->vm_assist = c->vm_assist;

phys_basetab = c->pt_base;
- ed->arch.guest_table = ed->arch.phys_table = mk_pagetable(phys_basetab);
+ ed->arch.guest_table = mk_pagetable(phys_basetab);

if ( !get_page_and_type(&frame_table[phys_basetab>>PAGE_SHIFT], d,
PGT_base_page_table) )
@@ -528,8 +465,22 @@
}

#ifdef CONFIG_VMX
- if (c->flags & ECF_VMX_GUEST)
- return vmx_final_setup_guest(ed, c);
+ if ( c->flags & ECF_VMX_GUEST )
+ {
+ int error;
+
+ // VMX uses the initially provided page tables as the P2M map.
+ //
+ // XXX: This creates a security issue -- Xen can't necessarily
+ // trust the VMX domain builder. Xen should validate this
+ // page table, and/or build the table itself, or ???
+ //
+ if ( !pagetable_val(d->arch.phys_table) )
+ d->arch.phys_table = ed->arch.guest_table;
+
+ if ( (error = vmx_final_setup_guest(ed, c)) )
+ return error;
+ }
#endif

update_pagetables(ed);
diff -Nru a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c 2005-04-05 12:21:46 -04:00
+++ b/xen/arch/x86/domain_build.c 2005-04-05 12:21:46 -04:00
@@ -25,6 +25,12 @@
static unsigned int opt_dom0_mem = 0;
integer_param("dom0_mem", opt_dom0_mem);

+static unsigned int opt_dom0_shadow = 0;
+boolean_param("dom0_shadow", opt_dom0_shadow);
+
+static unsigned int opt_dom0_translate = 0;
+boolean_param("dom0_translate", opt_dom0_translate);
+
#if defined(__i386__)
/* No ring-3 access in initial leaf page tables. */
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
@@ -103,6 +109,7 @@
unsigned long mpt_alloc;

extern void physdev_init_dom0(struct domain *);
+ extern void translate_l2pgtable(struct domain *d, l1_pgentry_t *p2m, unsigned long l2mfn);

/* Sanity! */
if ( d->id != 0 )
@@ -270,8 +277,13 @@
l1tab += l1_table_offset(vpt_start);
for ( count = 0; count < nr_pt_pages; count++ )
{
- *l1tab = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
page = &frame_table[l1_pgentry_to_pfn(*l1tab)];
+ if ( !opt_dom0_shadow )
+ *l1tab = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
+ else
+ if ( !get_page_type(page, PGT_writable_page) )
+ BUG();
+
if ( count == 0 )
{
page->u.inuse.type_info &= ~PGT_type_mask;
@@ -414,7 +426,7 @@
d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
d->shared_info->n_vcpu = smp_num_cpus;

- /* Set up shadow and monitor tables. */
+ /* Set up monitor table */
update_pagetables(ed);

/* Install the new page tables. */
@@ -434,12 +446,24 @@
init_domheap_pages(
_initrd_start, (_initrd_start+initrd_len+PAGE_SIZE-1) & PAGE_MASK);
}
-
+
+ d->next_io_page = max_page;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog
Hand merged [ In reply to ]
ChangeSet 1.1288, 2005/04/12 10:48:55+01:00, mafetter@fleming.research

Hand merged



linux-2.6.11-xen-sparse/arch/xen/Kconfig | 12
linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 | 9
linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 | 9
linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h | 512 ----------
xen/arch/x86/domain.c | 29
xen/arch/x86/shadow.c | 18
xen/common/dom_mem_ops.c | 14
xen/include/asm-x86/shadow.h | 46
8 files changed, 107 insertions(+), 542 deletions(-)


diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/Kconfig b/linux-2.6.11-xen-sparse/arch/xen/Kconfig
--- a/linux-2.6.11-xen-sparse/arch/xen/Kconfig 2005-04-13 19:03:13 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/Kconfig 2005-04-13 19:03:13 -04:00
@@ -143,17 +143,17 @@

choice
prompt "Processor Type"
- default X86
+ default XEN_X86

-config X86
+config XEN_X86
bool "X86"
help
Choose this option if your computer is a X86 architecture.

-config X86_64
+config XEN_X86_64
bool "X86_64"
help
- Choose this option if your computer is a X86 architecture.
+ Choose this option if your computer is a X86_64 architecture.

endchoice

@@ -165,11 +165,11 @@

source "init/Kconfig"

-if X86
+if XEN_X86
source "arch/xen/i386/Kconfig"
endif

-if X86_64
+if XEN_X86_64
source "arch/xen/x86_64/Kconfig"
endif

diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32
--- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 2005-04-13 19:03:13 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32 2005-04-13 19:03:13 -04:00
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.11-xen0
-# Sat Mar 19 19:42:39 2005
+# Wed Apr 6 09:19:05 2005
#
CONFIG_XEN=y
CONFIG_ARCH_XEN=y
@@ -14,15 +14,15 @@
CONFIG_XEN_PHYSDEV_ACCESS=y
CONFIG_XEN_BLKDEV_BACKEND=y
# CONFIG_XEN_BLKDEV_TAP_BE is not set
-# CONFIG_XEN_BLKDEV_GRANT is not set
+CONFIG_XEN_BLKDEV_GRANT=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
# CONFIG_XEN_BLKDEV_TAP is not set
CONFIG_XEN_SCRUB_PAGES=y
-CONFIG_X86=y
-# CONFIG_X86_64 is not set
+CONFIG_XEN_X86=y
+# CONFIG_XEN_X86_64 is not set
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y

#
@@ -76,6 +76,7 @@
# X86 Processor Configuration
#
CONFIG_XENARCH="i386"
+CONFIG_X86=y
CONFIG_MMU=y
CONFIG_UID16=y
CONFIG_GENERIC_ISA_DMA=y
diff -Nru a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32
--- a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 2005-04-13 19:03:13 -04:00
+++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_32 2005-04-13 19:03:13 -04:00
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.11-xenU
-# Tue Apr 5 16:44:33 2005
+# Wed Apr 6 09:20:09 2005
#
CONFIG_XEN=y
CONFIG_ARCH_XEN=y
@@ -12,15 +12,15 @@
#
# CONFIG_XEN_PRIVILEGED_GUEST is not set
# CONFIG_XEN_PHYSDEV_ACCESS is not set
-# CONFIG_XEN_BLKDEV_GRANT is not set
+CONFIG_XEN_BLKDEV_GRANT=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_NETDEV_FRONTEND=y
# CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
# CONFIG_XEN_BLKDEV_TAP is not set
CONFIG_XEN_SHADOW_MODE=y
CONFIG_XEN_SCRUB_PAGES=y
-CONFIG_X86=y
-# CONFIG_X86_64 is not set
+CONFIG_XEN_X86=y
+# CONFIG_XEN_X86_64 is not set
CONFIG_HAVE_ARCH_DEV_ALLOC_SKB=y

#
@@ -73,6 +73,7 @@
# X86 Processor Configuration
#
CONFIG_XENARCH="i386"
+CONFIG_X86=y
CONFIG_MMU=y
CONFIG_UID16=y
CONFIG_GENERIC_ISA_DMA=y
diff -Nru a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h
--- a/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h 2005-04-13 19:03:13 -04:00
+++ b/linux-2.6.11-xen-sparse/include/asm-xen/hypervisor.h 2005-04-13 19:03:13 -04:00
@@ -39,9 +39,11 @@
#include <asm-xen/xen-public/io/domain_controller.h>
#include <asm/ptrace.h>
#include <asm/page.h>
+#if defined(__i386__)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
#include <asm-generic/pgtable-nopmd.h>
#endif
+#endif

/* arch/xen/i386/kernel/setup.c */
union xen_start_info_union
@@ -72,14 +74,22 @@
*/

void xen_pt_switch(unsigned long ptr);
+void xen_new_user_pt(unsigned long ptr); /* x86_64 only */
+void xen_load_gs(unsigned int selector); /* x86_64 only */
void xen_tlb_flush(void);
void xen_invlpg(unsigned long ptr);

#ifndef CONFIG_XEN_SHADOW_MODE
void xen_l1_entry_update(pte_t *ptr, unsigned long val);
void xen_l2_entry_update(pmd_t *ptr, pmd_t val);
+void xen_l3_entry_update(pud_t *ptr, pud_t val); /* x86_64 only */
+void xen_l4_entry_update(pgd_t *ptr, pgd_t val); /* x86_64 only */
void xen_pgd_pin(unsigned long ptr);
void xen_pgd_unpin(unsigned long ptr);
+void xen_pud_pin(unsigned long ptr); /* x86_64 only */
+void xen_pud_unpin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_pin(unsigned long ptr); /* x86_64 only */
+void xen_pmd_unpin(unsigned long ptr); /* x86_64 only */
void xen_pte_pin(unsigned long ptr);
void xen_pte_unpin(unsigned long ptr);
#else
@@ -123,506 +133,6 @@
unsigned long allocate_empty_lowmem_region(unsigned long pages);
#endif

-/*
- * Assembler stubs for hyper-calls.
- */
-
-static inline int
-HYPERVISOR_set_trap_table(
- trap_info_t *table)
-{
- int ret;
- unsigned long ignore;
-
- __asm__ __volatile__ (
- TRAP_INSTR
- : "=a" (ret), "=b" (ignore)
- : "0" (__HYPERVISOR_set_trap_table), "1" (table)
- : "memory" );
-
- return ret;
-}
-
-static inline int
-HYPERVISOR_mmu_update(
- mmu_update_t *req, int count, int *success_count, domid_t domid)
-{
- int ret;
- unsigned long ign1, ign2, ign3, ign4;
-
- __asm__ __volatile__ (
- TRAP_INSTR
- : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
- : "0" (__HYPERVISOR_mmu_update), "1" (req), "2" (count),
- "3" (success_count), "4" (domid)
- : "memory" );
-
- return ret;
-}
-
-static inline int
-HYPERVISOR_mmuext_op(
- struct mmuext_op *op, int count, int *success_count, domid_t domid)
-{
- int ret;
- unsigned long ign1, ign2, ign3, ign4;
-
- __asm__ __volatile__ (
- TRAP_INSTR
- : "=a" (ret), "=b" (ign1), "=c" (ign2), "=d" (ign3), "=S" (ign4)
- : "0" (__HYPERVISOR_mmuext_op), "1" (op), "2" (count),
- "3" (success_count), "4" (domid)
- : "memory" );
-
- return ret;
-}
-
-static inline int
-HYPERVISOR_set_gdt(
- unsigned long *frame_list, int entries)
-{
- int ret;
- unsigned long ign1, ign2;
-
- __asm__ __volatile__ (
- TRAP_INSTR
- : "=a" (ret), "=b" (ign1), "=c" (ign2)
- : "0" (__HYPERVISOR_set_gdt), "1" (frame_list), "2" (entries)
- : "memory" );
-
-
- return ret;
-}
-
-static inline int
-HYPERVISOR_stack_switch(
- unsigned long ss, unsigned long esp)
-{
- int ret;
- unsigned long ign1, ign2;
-
- __asm__ __volatile__ (
- TRAP_INSTR
- : "=a" (ret), "=b" (ign1), "=c" (ign2)
- : "0" (__HYPERVISOR_stack_switch), "1" (ss), "2" (esp)
- : "memory" );
-
- return ret;
-}
-
-static inline int
-HYPERVISOR_set_callbacks(
- unsigned long event_selector, unsigned long event_address,
- unsigned long failsafe_selector, unsigned long failsafe_address)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog