Skip to content

Commit

Permalink
Retire XEN_COMPAT_030001 as detailed on port-xen@:
Browse files Browse the repository at this point in the history
http://mail-index.netbsd.org/port-xen/2012/06/25/msg007431.html

The xen_p2m API comes next.

ok bouyer@.
Tested on i386 PAE and amd64 (Xen 3.3 on private test bed, and
Xen 3.4 for Amazon EC2).

FWIW, Amazon always reported:

hypervisor0 at mainbus0: Xen version 3.4.3-kaos_t1micro

multiple times for Europe and US West-1, so I guess they are now at
3.4 (32 and 64 bits).
  • Loading branch information
jymigeon committed Jun 27, 2012
1 parent 97b3c7a commit db50bb9
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 88 deletions.
6 changes: 3 additions & 3 deletions sys/arch/amd64/amd64/machdep.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $ */
/* $NetBSD: machdep.c,v 1.187 2012/06/27 00:37:07 jym Exp $ */

/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
Expand Down Expand Up @@ -111,7 +111,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.186 2012/06/16 20:47:04 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.187 2012/06/27 00:37:07 jym Exp $");

/* #define XENDEBUG_LOW */

Expand Down Expand Up @@ -1723,7 +1723,7 @@ init_x86_64(paddr_t first_avail)
/* Determine physical address space */
avail_start = first_avail;
avail_end = ctob(xen_start_info.nr_pages);
pmap_pa_start = XPMAP_OFFSET;
pmap_pa_start = 0;
pmap_pa_end = pmap_pa_start + ctob(xen_start_info.nr_pages);
__PRINTK(("pmap_pa_start 0x%lx avail_start 0x%lx avail_end 0x%lx\n",
pmap_pa_start, avail_start, avail_end));
Expand Down
3 changes: 1 addition & 2 deletions sys/arch/i386/conf/XEN3_DOMU
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: XEN3_DOMU,v 1.43 2012/03/10 21:51:53 joerg Exp $
# $NetBSD: XEN3_DOMU,v 1.44 2012/06/27 00:37:08 jym Exp $

include "arch/xen/conf/std.xen"

Expand Down Expand Up @@ -166,7 +166,6 @@ options NFS_BOOT_DHCP,NFS_BOOT_BOOTPARAM
#options NFS_BOOTSTATIC_SERVER="\"server:/path/to/root\""

#options __XEN_INTERFACE_VERSION__=0x00030205 # Xen 3.1 interface
options XEN_COMPAT_030001 #compatible with Xen3 before 3.0.2
options MAXPHYS=32768 #xbd doesn't handle 64k transfers

config netbsd root on ? type ?
Expand Down
15 changes: 4 additions & 11 deletions sys/arch/i386/i386/locore.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: locore.S,v 1.100 2012/06/16 17:30:19 chs Exp $ */
/* $NetBSD: locore.S,v 1.101 2012/06/27 00:37:08 jym Exp $ */

/*
* Copyright-o-rama!
Expand Down Expand Up @@ -129,7 +129,7 @@
*/

#include <machine/asm.h>
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.100 2012/06/16 17:30:19 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.101 2012/06/27 00:37:08 jym Exp $");

#include "opt_compat_oldboot.h"
#include "opt_ddb.h"
Expand Down Expand Up @@ -169,18 +169,11 @@ __KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.100 2012/06/16 17:30:19 chs Exp $");
*/
.section __xen_guest
.ascii "GUEST_OS=netbsd,GUEST_VER=3.0,XEN_VER=xen-3.0"
#if defined(DOM0OPS) || !defined(XEN_COMPAT_030001)
.ascii ",VIRT_BASE=0xc0000000" /* KERNBASE */
.ascii ",ELF_PADDR_OFFSET=0xc0000000" /* KERNBASE */
#else
.ascii ",VIRT_BASE=0xc0100000" /* KERNTEXTOFF */
.ascii ",ELF_PADDR_OFFSET=0xc0100000" /* KERNTEXTOFF */
#endif
.ascii ",VIRT_ENTRY=0xc0100000" /* KERNTEXTOFF */
#if !defined(XEN_COMPAT_030001)
.ascii ",HYPERCALL_PAGE=0x00000101"
/* (???+HYPERCALL_PAGE_OFFSET)/PAGE_SIZE) */
#endif
#ifdef PAE
.ascii ",PAE=yes[extended-cr3]"
#endif
Expand Down Expand Up @@ -824,13 +817,13 @@ start:
addl $PDE_SIZE,%esp # pop paddr_t
call _C_LABEL(main)

#if defined(XEN) && !defined(XEN_COMPAT_030001)
#if defined(XEN)
/* space for the hypercall call page */
#define HYPERCALL_PAGE_OFFSET 0x1000
.org HYPERCALL_PAGE_OFFSET
ENTRY(hypercall_page)
.skip 0x1000
#endif /* defined(XEN) && !defined(XEN_COMPAT_030001) */
#endif /* defined(XEN) */

/*
* void lgdt_finish(void);
Expand Down
6 changes: 3 additions & 3 deletions sys/arch/i386/i386/machdep.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.728 2012/06/02 21:36:41 dsl Exp $ */
/* $NetBSD: machdep.c,v 1.729 2012/06/27 00:37:08 jym Exp $ */

/*-
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
Expand Down Expand Up @@ -67,7 +67,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.728 2012/06/02 21:36:41 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.729 2012/06/27 00:37:08 jym Exp $");

#include "opt_beep.h"
#include "opt_compat_ibcs2.h"
Expand Down Expand Up @@ -1364,7 +1364,7 @@ init386(paddr_t first_avail)
/* Make sure the end of the space used by the kernel is rounded. */
first_avail = round_page(first_avail);
avail_start = first_avail;
avail_end = ctob((paddr_t)xen_start_info.nr_pages) + XPMAP_OFFSET;
avail_end = ctob((paddr_t)xen_start_info.nr_pages);
pmap_pa_start = (KERNTEXTOFF - KERNBASE);
pmap_pa_end = pmap_pa_start + ctob((paddr_t)xen_start_info.nr_pages);
mem_clusters[0].start = avail_start;
Expand Down
4 changes: 2 additions & 2 deletions sys/arch/xen/conf/files.xen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: files.xen,v 1.126 2012/05/07 17:45:29 jym Exp $
# $NetBSD: files.xen,v 1.127 2012/06/27 00:37:09 jym Exp $
# NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp
# NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp

Expand Down Expand Up @@ -391,7 +391,7 @@ endif
include "dev/pcmcia/files.pcmcia"

# Domain-0 operations
defflag opt_xen.h DOM0OPS XEN_COMPAT_030001
defflag opt_xen.h DOM0OPS
file arch/xen/xen/privcmd.c dom0ops
file arch/xen/x86/xen_shm_machdep.c dom0ops
file arch/x86/pci/pci_machdep.c hypervisor & pci & dom0ops
Expand Down
12 changes: 1 addition & 11 deletions sys/arch/xen/include/i386/hypercalls.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: hypercalls.h,v 1.14 2011/12/07 16:01:39 cegger Exp $ */
/* $NetBSD: hypercalls.h,v 1.15 2012/06/27 00:37:09 jym Exp $ */

/*
* Copyright (c) 2006 Manuel Bouyer.
Expand Down Expand Up @@ -59,7 +59,6 @@

#include <machine/pte.h> /* pt_entry_t */

#if !defined(XEN_COMPAT_030001)
/* hypercall via the hypercall call page */
#define __str(x) #x
#define _str(x) __str(x)
Expand All @@ -69,15 +68,6 @@
: output_const \
: input_const \
: "memory" )
#else
/* traditionnal hypercall via int 0x82 */
#define _hypercall(name, input_const, output_const) \
__asm volatile ( \
TRAP_INSTR \
: output_const \
: "0" (name), input_const \
: "memory" )
#endif

#define _harg(...) __VA_ARGS__

Expand Down
23 changes: 4 additions & 19 deletions sys/arch/xen/include/xenpmap.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: xenpmap.h,v 1.35 2012/06/24 18:31:52 jym Exp $ */
/* $NetBSD: xenpmap.h,v 1.36 2012/06/27 00:37:09 jym Exp $ */

/*
*
Expand Down Expand Up @@ -76,29 +76,14 @@ void xen_kpm_sync(struct pmap *, int);

extern unsigned long *xpmap_phys_to_machine_mapping;

/*
* On Xen-2, the start of the day virtual memory starts at KERNTEXTOFF
* (0xc0100000). On Xen-3 for domain0 it starts at KERNBASE (0xc0000000).
* So the offset between physical and virtual address is different on
* Xen-2 and Xen-3 for domain0.
* starting with xen-3.0.2, we can add notes so that virtual memory starts
* at KERNBASE for domU as well.
*/
#if defined(DOM0OPS) || !defined(XEN_COMPAT_030001)
#define XPMAP_OFFSET 0
#else
#define XPMAP_OFFSET (KERNTEXTOFF - KERNBASE)
#endif

#define mfn_to_pfn(mfn) (machine_to_phys_mapping[(mfn)])
#define pfn_to_mfn(pfn) (xpmap_phys_to_machine_mapping[(pfn)])

static __inline paddr_t
xpmap_mtop_masked(paddr_t mpa)
{
return (
((paddr_t)machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT)
+ XPMAP_OFFSET);
(paddr_t)machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT);
}

static __inline paddr_t
Expand All @@ -110,8 +95,8 @@ xpmap_mtop(paddr_t mpa)
static __inline paddr_t
xpmap_ptom_masked(paddr_t ppa)
{
return (((paddr_t)xpmap_phys_to_machine_mapping[(ppa -
XPMAP_OFFSET) >> PAGE_SHIFT]) << PAGE_SHIFT);
return (((paddr_t)xpmap_phys_to_machine_mapping[(ppa) >> PAGE_SHIFT])
<< PAGE_SHIFT);
}

static __inline paddr_t
Expand Down
6 changes: 3 additions & 3 deletions sys/arch/xen/x86/x86_xpmap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: x86_xpmap.c,v 1.44 2012/06/06 22:22:41 rmind Exp $ */
/* $NetBSD: x86_xpmap.c,v 1.45 2012/06/27 00:37:10 jym Exp $ */

/*
* Copyright (c) 2006 Mathieu Ropert <[email protected]>
Expand Down Expand Up @@ -69,7 +69,7 @@


#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.44 2012/06/06 22:22:41 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: x86_xpmap.c,v 1.45 2012/06/27 00:37:10 jym Exp $");

#include "opt_xen.h"
#include "opt_ddb.h"
Expand Down Expand Up @@ -235,7 +235,7 @@ xpq_queue_machphys_update(paddr_t ma, paddr_t pa)
"\n", (int64_t)ma, (int64_t)pa));

xpq_queue[xpq_idx].ptr = ma | MMU_MACHPHYS_UPDATE;
xpq_queue[xpq_idx].val = (pa - XPMAP_OFFSET) >> PAGE_SHIFT;
xpq_queue[xpq_idx].val = pa >> PAGE_SHIFT;
xpq_increment_idx();
#ifdef XENDEBUG_SYNC
xpq_flush_queue();
Expand Down
15 changes: 6 additions & 9 deletions sys/arch/xen/x86/xen_bus_dma.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: xen_bus_dma.c,v 1.23 2011/07/01 18:37:08 dyoung Exp $ */
/* $NetBSD: xen_bus_dma.c,v 1.24 2012/06/27 00:37:10 jym Exp $ */
/* NetBSD bus_dma.c,v 1.21 2005/04/16 07:53:35 yamt Exp */

/*-
Expand Down Expand Up @@ -32,7 +32,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.23 2011/07/01 18:37:08 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: xen_bus_dma.c,v 1.24 2012/06/27 00:37:10 jym Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -91,7 +91,7 @@ _xen_alloc_contig(bus_size_t size, bus_size_t alignment,
pa = VM_PAGE_TO_PHYS(pg);
mfn = xpmap_ptom(pa) >> PAGE_SHIFT;
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = INVALID_P2M_ENTRY;
pa >> PAGE_SHIFT] = INVALID_P2M_ENTRY;
xenguest_handle(res.extent_start) = &mfn;
res.nr_extents = 1;
res.extent_order = 0;
Expand All @@ -104,8 +104,7 @@ _xen_alloc_contig(bus_size_t size, bus_size_t alignment,
"failed: err %d (pa %#" PRIxPADDR " mfn %#lx)\n",
error, pa, mfn);
#endif
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn;
xpmap_phys_to_machine_mapping[pa >> PAGE_SHIFT] = mfn;

error = ENOMEM;
goto failed;
Expand Down Expand Up @@ -133,8 +132,7 @@ _xen_alloc_contig(bus_size_t size, bus_size_t alignment,
for (pg = mlistp->tqh_first, i = 0; pg != NULL; pg = pgnext, i++) {
pgnext = pg->pageq.queue.tqe_next;
pa = VM_PAGE_TO_PHYS(pg);
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn+i;
xpmap_phys_to_machine_mapping[pa >> PAGE_SHIFT] = mfn+i;
xpq_queue_machphys_update(((paddr_t)(mfn+i)) << PAGE_SHIFT, pa);
/* while here, give extra pages back to UVM */
if (i >= npagesreq) {
Expand Down Expand Up @@ -178,8 +176,7 @@ _xen_alloc_contig(bus_size_t size, bus_size_t alignment,
break;
}
pa = VM_PAGE_TO_PHYS(pg);
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn;
xpmap_phys_to_machine_mapping[pa >> PAGE_SHIFT] = mfn;
xpq_queue_machphys_update(((paddr_t)mfn) << PAGE_SHIFT, pa);
TAILQ_REMOVE(mlistp, pg, pageq.queue);
uvm_pagefree(pg);
Expand Down
9 changes: 4 additions & 5 deletions sys/arch/xen/xen/balloon.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: balloon.c,v 1.13 2012/01/05 18:11:50 jym Exp $ */
/* $NetBSD: balloon.c,v 1.14 2012/06/27 00:37:10 jym Exp $ */

/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -71,7 +71,7 @@
#define BALLOONDEBUG 0

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.13 2012/01/05 18:11:50 jym Exp $");
__KERNEL_RCSID(0, "$NetBSD: balloon.c,v 1.14 2012/06/27 00:37:10 jym Exp $");

#include <sys/inttypes.h>
#include <sys/device.h>
Expand Down Expand Up @@ -400,8 +400,7 @@ balloon_inflate(struct balloon_xenbus_softc *sc, size_t tpages)

/* Invalidate pg */
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT
] = INVALID_P2M_ENTRY;
pa >> PAGE_SHIFT] = INVALID_P2M_ENTRY;

splx(s);

Expand Down Expand Up @@ -518,7 +517,7 @@ balloon_deflate(struct balloon_xenbus_softc *sc, size_t tpages)
s = splvm();

xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = mfn_list[rpages];
pa >> PAGE_SHIFT] = mfn_list[rpages];

xpq_queue_machphys_update(
((paddr_t) (mfn_list[rpages])) << PAGE_SHIFT, pa);
Expand Down
15 changes: 7 additions & 8 deletions sys/arch/xen/xen/if_xennet_xenbus.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: if_xennet_xenbus.c,v 1.59 2012/02/22 18:54:51 bouyer Exp $ */
/* $NetBSD: if_xennet_xenbus.c,v 1.60 2012/06/27 00:37:10 jym Exp $ */

/*
* Copyright (c) 2006 Manuel Bouyer.
Expand Down Expand Up @@ -85,7 +85,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.59 2012/02/22 18:54:51 bouyer Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.60 2012/06/27 00:37:10 jym Exp $");

#include "opt_xen.h"
#include "opt_nfs_boot.h"
Expand Down Expand Up @@ -731,7 +731,7 @@ xennet_alloc_rx_buffer(struct xennet_xenbus_softc *sc)
* Remove this page from pseudo phys map before
* passing back to Xen.
*/
pfn = (req->rxreq_pa - XPMAP_OFFSET) >> PAGE_SHIFT;
pfn = req->rxreq_pa >> PAGE_SHIFT;
xennet_pages[i] = xpmap_phys_to_machine_mapping[pfn];
xpmap_phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
}
Expand Down Expand Up @@ -838,12 +838,12 @@ xennet_free_rx_buffer(struct xennet_xenbus_softc *sc)
va = rxreq->rxreq_va;
/* remap the page */
mmu[0].ptr = (ma << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
mmu[0].val = ((pa - XPMAP_OFFSET) >> PAGE_SHIFT);
mmu[0].val = pa >> PAGE_SHIFT;
MULTI_update_va_mapping(&mcl[0], va,
(ma << PAGE_SHIFT) | PG_V | PG_KW,
UVMF_TLB_FLUSH|UVMF_ALL);
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = ma;
pa >> PAGE_SHIFT] = ma;
mcl[1].op = __HYPERVISOR_mmu_update;
mcl[1].args[0] = (unsigned long)mmu;
mcl[1].args[1] = 1;
Expand Down Expand Up @@ -1036,11 +1036,10 @@ xennet_handler(void *arg)
if (sc->sc_rx_feature == FEATURE_RX_FLIP) {
/* remap the page */
mmu[0].ptr = (ma << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
mmu[0].val = ((pa - XPMAP_OFFSET) >> PAGE_SHIFT);
mmu[0].val = pa >> PAGE_SHIFT;
MULTI_update_va_mapping(&mcl[0], va,
(ma << PAGE_SHIFT) | PG_V | PG_KW, UVMF_TLB_FLUSH|UVMF_ALL);
xpmap_phys_to_machine_mapping[
(pa - XPMAP_OFFSET) >> PAGE_SHIFT] = ma;
xpmap_phys_to_machine_mapping[pa >> PAGE_SHIFT] = ma;
mcl[1].op = __HYPERVISOR_mmu_update;
mcl[1].args[0] = (unsigned long)mmu;
mcl[1].args[1] = 1;
Expand Down
8 changes: 2 additions & 6 deletions sys/arch/xen/xen/privcmd.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: privcmd.c,v 1.43 2011/06/15 19:51:50 rmind Exp $ */
/* $NetBSD: privcmd.c,v 1.44 2012/06/27 00:37:10 jym Exp $ */

/*-
* Copyright (c) 2004 Christian Limpach.
Expand Down Expand Up @@ -27,7 +27,7 @@


#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.43 2011/06/15 19:51:50 rmind Exp $");
__KERNEL_RCSID(0, "$NetBSD: privcmd.c,v 1.44 2012/06/27 00:37:10 jym Exp $");

#include <sys/param.h>
#include <sys/systm.h>
Expand Down Expand Up @@ -286,13 +286,9 @@ privcmd_ioctl(void *v)
"movl 16(%%eax),%%esi ;"
"movl 20(%%eax),%%edi ;"
"movl (%%eax),%%eax ;"
#if !defined(XEN_COMPAT_030001)
"shll $5,%%eax ;"
"addl $hypercall_page,%%eax ;"
"call *%%eax ;"
#else
TRAP_INSTR "; "
#endif
"popl %%edi; popl %%esi; popl %%edx;"
"popl %%ecx; popl %%ebx"
: "=a" (error) : "0" (ap->a_data) : "memory" );
Expand Down
Loading

0 comments on commit db50bb9

Please sign in to comment.