[Xen-devel] [qemu-mainline test] 50623: trouble: blocked/broken

2015-04-19 Thread osstest service user
flight 50623 qemu-mainline real [real]
http://logs.test-lab.xenproject.org/osstest/logs/50623/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-armhf-xsm   3 host-install(3) broken REGR. vs. 50391
 build-armhf   3 host-install(3) broken REGR. vs. 50391
 build-i386-pvops  3 host-install(3) broken REGR. vs. 50391
 build-amd64-xsm   3 host-install(3) broken REGR. vs. 50391
 build-i386-xsm3 host-install(3) broken REGR. vs. 50391
 build-amd64-pvops 3 host-install(3) broken REGR. vs. 50391
 build-amd64   3 host-install(3) broken REGR. vs. 50391
 build-i3863 host-install(3) broken REGR. vs. 50391
 build-armhf-pvops 3 host-install(3) broken REGR. vs. 50391

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-pvh-amd   1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-xl-xsm1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-freebsd10-i386  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-xsm   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-pvh-intel  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-freebsd10-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-multivcpu  1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf-pin  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-credit2   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-winxpsp3  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-i386-qemut-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-qemut-winxpsp3  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-qemut-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-i386-qemut-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-amd64-amd64-pair 1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-armhf-armhf-xl   1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-credit2   1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-armhf-armhf-xl-sedf  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-sedf-pin  1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-armhf-armhf-xl-multivcpu  1 build-check(1)   blocked  n/a
 test-amd64-i386-rhel6hvm-intel  1 build-check(1)   blocked  n/a
 build-i386-libvirt1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-win7-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-win7-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-winxpsp3  1 build-check(1)   blocked  n/a
 build-amd64-libvirt   1 build-check(1)   blocked  n/a
 test-armhf-armhf-libvirt  1 build-check(1)   blocked  n/a
 test-amd64-i386-rhel6hvm-amd  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-cubietruck  1 build-check(1)   blocked  n/a
 test-armhf-armhf-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-arndale   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-pair  1 build-check(1)   blocked  

[Xen-devel] [PATCH V3 1/6] libxl: export some functions for pvusb use

2015-04-19 Thread Chunyan Liu
Signed-off-by: Chunyan Liu cy...@suse.com
Signed-off-by: Simon Cao caobosi...@gmail.com
---
 tools/libxl/libxl.c  | 6 +++---
 tools/libxl/libxl_internal.h | 5 +
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 511eef1..b05d18b 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1963,7 +1963,7 @@ out:
 
/**/
 
 /* generic callback for devices that only need to set ao_complete */
-static void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
+void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
 {
 STATE_AO_GC(aodev-ao);
 
@@ -1986,7 +1986,7 @@ out:
 }
 
 /* common function to get next device id */
-static int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device)
+int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device)
 {
 char *dompath, **l;
 unsigned int nb;
@@ -2005,7 +2005,7 @@ static int libxl__device_nextid(libxl__gc *gc, uint32_t 
domid, char *device)
 return nextid;
 }
 
-static int libxl__resolve_domid(libxl__gc *gc, const char *name,
+int libxl__resolve_domid(libxl__gc *gc, const char *name,
 uint32_t *domid)
 {
 if (!name)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 9c22309..42eb1b9 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1080,6 +1080,9 @@ _hidden int libxl__init_console_from_channel(libxl__gc 
*gc,
  libxl__device_console *console,
  int dev_num,
  libxl_device_channel *channel);
+_hidden int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device);
+_hidden int libxl__resolve_domid(libxl__gc *gc, const char *name,
+ uint32_t *domid);
 
 /*
  * For each aggregate type which can be used as an input we provide:
@@ -2208,6 +2211,8 @@ struct libxl__ao_device {
 
 /* Starts preparing to add/remove a bunch of devices. */
 _hidden void libxl__multidev_begin(libxl__ao *ao, libxl__multidev*);
+/* generic callback for devices that only need to set ao_complete */
+_hidden void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev);
 
 /* Prepares to add/remove one of many devices.
  * Calls libxl__prepare_ao_device on libxl__ao_device argument provided and
-- 
1.8.5.2


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH V3 5/6] domcreate: support pvusb in configuration file

2015-04-19 Thread Chunyan Liu
Add code to support pvusb in domain config file. One could specify
usbctrl and usb in domain's configuration file and create domain,
then usb controllers will be created and usb device would be attached
to guest automatically.

One could specify usb controllers and usb devices in config file
like this:
usbctrl=['version=2,ports=4', 'version=1, ports=4', ]
usb=['2.1,controller=0,port=1', ]

Signed-off-by: Chunyan Liu cy...@suse.com
Signed-off-by: Simon Cao caobosi...@gmail.com
---
Changes to v2:
  *add 'usbctrls' to domain_config
  *add 'usbctrl' to xl.cfg to allow user specify USB controllers in config file
  *add documentation

 docs/man/xl.cfg.pod.5  | 70 
 tools/libxl/libxl_create.c | 73 --
 tools/libxl/xl_cmdimpl.c   | 88 +-
 3 files changed, 227 insertions(+), 4 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5 b/docs/man/xl.cfg.pod.5
index f936dfc..c53e2d1 100644
--- a/docs/man/xl.cfg.pod.5
+++ b/docs/man/xl.cfg.pod.5
@@ -645,6 +645,76 @@ assigned slave device.
 
 =back
 
+=item Busbctrl=[ USBCTRL_SPEC_STRING, USBCTRL_SPEC_STRING, ... ]
+
+Specifies the USB controllers created for this guest. Each
+BUSB_SPEC_STRING has the form CKEY=VALUE,KEY=VALUE,... where:
+
+=over 4
+
+=item BKEY=VALUE
+
+Possible BKEYs are:
+
+=over 4
+
+=item Bversion=VERSION
+
+Specifies version of the USB controller, could be 1 (USB1.1) or 2 (USB2.0).
+Default is 2 (USB2.0).
+
+=item Bports=PORTS
+
+Specifies port number of the USB controller. Default is 8.
+
+Each USB controller will have an index starting from 0. On the same
+controller, each port will have an index starting from 1.
+
+E.g.
+usbctrl=[version=1,ports=4, version=2,port2=8,]
+The first controller has:
+controller index = 0, and port 1,2,3,4.
+The second controller has:
+controller index = 1, and port 1,2,3,4,5,6,7,8.
+
+=back
+
+=back
+
+=item Busb=[ USB_SPEC_STRING, USB_SPEC_STRING, ... ]
+
+Specifies the host USB devices to passthrough to this guest. Each
+BUSB_SPEC_STRING has the form Cbus.addr,KEY=VALUE,KEY=VALUE,... where:
+
+=over 4
+
+=item Bbus.addr
+
+Identifies the busnum.devnum of the USB device from the host perspective.
+This is the same scheme as used in the output of Clsusb for the device in
+question.
+
+=item BKEY=VALUE
+
+Possible BKEYs are:
+
+=over 4
+
+=item Bcontroller=CONTROLLER
+
+Specifies USB controller index, to which controller the USB device is attached.
+
+=item Bport=PORT
+
+Specifies USB port index, to which port the USB device is attached. 
Bport=PORT
+is valid only when Bcontroller=CONTROLLER is specified. Without
+Bcontroller=CONTROLLER, it will find the first available USB controller:port
+and use it. If there is no controller at all, it will create one.
+
+=back
+
+=back
+
 =item Bpci=[ PCI_SPEC_STRING, PCI_SPEC_STRING, ... ]
 
 Specifies the host PCI devices to passthrough to this guest. Each 
BPCI_SPEC_STRING
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e5a343f..d17cdf4 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -749,6 +749,10 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__multidev *aodevs,
 
 static void domcreate_attach_vtpms(libxl__egc *egc, libxl__multidev *multidev,
int ret);
+static void domcreate_attach_usbctrls(libxl__egc *egc, libxl__multidev 
*multidev,
+  int ret);
+static void domcreate_attach_usbs(libxl__egc *egc, libxl__multidev *multidev,
+   int ret);
 static void domcreate_attach_pci(libxl__egc *egc, libxl__multidev *aodevs,
  int ret);
 
@@ -1396,13 +1400,13 @@ static void domcreate_attach_vtpms(libxl__egc *egc,
if (d_config-num_vtpms  0) {
/* Attach vtpms */
libxl__multidev_begin(ao, dcs-multidev);
-   dcs-multidev.callback = domcreate_attach_pci;
+   dcs-multidev.callback = domcreate_attach_usbctrls;
libxl__add_vtpms(egc, ao, domid, d_config, dcs-multidev);
libxl__multidev_prepared(egc, dcs-multidev, 0);
return;
}
 
-   domcreate_attach_pci(egc, multidev, 0);
+   domcreate_attach_usbctrls(egc, multidev, 0);
return;
 
 error_out:
@@ -1410,6 +1414,69 @@ error_out:
domcreate_complete(egc, dcs, ret);
 }
 
+static void domcreate_attach_usbctrls(libxl__egc *egc, libxl__multidev 
*multidev,
+  int ret)
+{
+libxl__domain_create_state *dcs = CONTAINER_OF(multidev, *dcs, multidev);
+STATE_AO_GC(dcs-ao);
+int i;
+int domid = dcs-guest_domid;
+
+libxl_domain_config *const d_config = dcs-guest_config;
+
+if (ret) {
+LOG(ERROR, unable to add vtpm devices);
+goto error_out;
+}
+
+for (i = 0; i  d_config-num_usbctrls; i++) {
+ret = libxl__device_usbctrl_add(gc, domid, d_config-usbctrls[i]);
+if (ret  0) {
+LOG(ERROR, 

[Xen-devel] [PATCH V3 3/6] libxl: add pvusb API

2015-04-19 Thread Chunyan Liu
Add pvusb APIs, including:
 - attach/detach (create/destroy) virtual usb controller.
 - attach/detach usb device
 - list usb controller and usb devices
 - some other helper functions

Signed-off-by: Chunyan Liu cy...@suse.com
Signed-off-by: Simon Cao caobosi...@gmail.com
---
Changes to v2:
  * remove qemu emulated usb related definitions, keep the work pure pvusb.
In last patch, will do all refactor work to unify pvusb and qemu emulated
usb.
  * use bus.addr as user interface instead of busid to do usb-attach|detach
  * remove usb-assignable-list APIs and some other unnecessary APIs
  * reuse libxl_read_file_contents function instead of another new function
to handle getting sysfs file content
  * fix build on different platforms as pci does
  * fix many coding style problems
  * address other comments in last version
  * adjust codes to let it look better

 tools/libxl/Makefile |2 +-
 tools/libxl/libxl.c  |2 +
 tools/libxl/libxl.h  |   45 ++
 tools/libxl/libxl_internal.h |   11 +-
 tools/libxl/libxl_osdeps.h   |   13 +
 tools/libxl/libxl_pvusb.c| 1201 ++
 tools/libxl/libxl_types.idl  |   41 ++
 tools/libxl/libxl_types_internal.idl |1 +
 8 files changed, 1314 insertions(+), 2 deletions(-)
 create mode 100644 tools/libxl/libxl_pvusb.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 1b16598..d52281f 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -95,7 +95,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_internal.o libxl_utils.o libxl_uuid.o \
libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o 
\
libxl_save_callout.o _libxl_save_msgs_callout.o \
-   libxl_qmp.o libxl_event.o libxl_fork.o $(LIBXL_OBJS-y)
+   libxl_qmp.o libxl_event.o libxl_fork.o libxl_pvusb.o 
$(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index b05d18b..a7c81d9 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1611,6 +1611,8 @@ void libxl__destroy_domid(libxl__egc *egc, 
libxl__destroy_domid_state *dis)
 
 if (libxl__device_pci_destroy_all(gc, domid)  0)
 LIBXL__LOG(ctx, LIBXL__LOG_ERROR, pci shutdown failed for domid %d, 
domid);
+if (libxl__device_usb_destroy_all(gc, domid)  0)
+ LIBXL__LOG(ctx, LIBXL__LOG_ERROR, usb shutdown failed for domid %d, 
domid);
 rc = xc_domain_pause(ctx-xch, domid);
 if (rc  0) {
 LIBXL__LOG_ERRNOVAL(ctx, LIBXL__LOG_ERROR, rc, xc_domain_pause failed 
for %d, domid);
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 6bc75c5..cbe3519 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -114,6 +114,12 @@
 #define LIBXL_HAVE_DOMAIN_NODEAFFINITY 1
 
 /*
+ * LIBXL_HAVE_PVUSB indicates the functions for doing hot-plug of
+ * USB devices through pvusb.
+ */
+#define LIBXL_HAVE_PVUSB 1
+
+/*
  * LIBXL_HAVE_BUILDINFO_HVM_VENDOR_DEVICE indicates that the
  * libxl_vendor_device field is present in the hvm sections of
  * libxl_domain_build_info. This field tells libxl which
@@ -1224,6 +1230,45 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, 
libxl_device_disk *disk,
const libxl_asyncop_how *ao_how)
LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* USB Controllers*/
+int libxl_device_usbctrl_add(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_usbctrl *usbctrl,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usbctrl_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_usbctrl *usbctrl,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usbctrl_destroy(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_usbctrl *usbctrl,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
+libxl_device_usbctrl *libxl_device_usbctrl_list(libxl_ctx *ctx,
+uint32_t domid, int *num);
+
+
+int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid,
+libxl_device_usbctrl *usbctrl,
+libxl_usbctrlinfo *usbctrlinfo)
+LIBXL_EXTERNAL_CALLERS_ONLY;
+
+/* USB Devices */
+int libxl_device_usb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_usb *usb,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
+int libxl_device_usb_remove(libxl_ctx *ctx, uint32_t domid, libxl_device_usb 
*usb,
+

[Xen-devel] [PATCH V3 0/6] libxl pvusb toolstack work

2015-04-19 Thread Chunyan Liu
This patch series is to add pvusb toolstack work, supporting hot add|remove
USB device to|from guest and specify USB device in domain configuration file.

1/6~5/6 implement clean pvusb work. 6/6 is an independent patch to refactor
codes for merging QEMU emulated USB code later.

1/6 is to export some functions for later usage
2/6 fixes read_file_content limit when reading sysfs file, for later usage.
3/6 libxl pvusb API implementation
4/6 xl pvusb hotplug commands implementation
5/6 usb from config file implementation
6/6 changing codes to unify qemu and pvusb.

Changes to v2:
* change xl interfaces from specifing usb device by busid to specifing
  usb device by bus.addr, so that pvusb and qemu can use same interface
* remove usb-assignable-list interface
* call existing helper functions to read sysfs file content to get usb
  device info.
* reorganize patches, first implement clean pvusb work, then in last
  patch changing codes for pvusb and qemu merging.
* Many fixes to address coding style, build on different platform, etc.
  Codes adjustment to better view.

V2 is here:
http://lists.xen.org/archives/html/xen-devel/2015-01/threads.html#03636

Related Discussion Threads:
http://www.redhat.com/archives/libvir-list/2014-June/msg00038.html
http://lists.xen.org/archives/html/xen-devel/2014-06/msg00086.html

For a better understanding, a summary is posted in following.

1. Overview

There are two general methods for passing through individual host
devices to a guest. The first is via an emulated USB device
controller; the second is PVUSB.

Additionally, there are two ways to add USB devices to a guest: via
the config file at domain creation time, and via hot-plug while the VM
is running. 

* Emulated USB

In emulated USB, the device model (qemu) presents an emulated USB
controller to the guest. The device model process then grabs control
of the device from domain 0 and and passes the USB commands between
the guest OS and the host USB device.

This method is only available to HVM domains, and is not available for
domains running with device model stubdomains.

* PVUSB

PVUSB uses a paravirtialized front-end/back-end interface, similar to
the traditional Xen PV network and disk protocols. In order to use
PVUSB, you need usbfront in your guest OS, and usbback in dom0 (or
your USB driver domain).

Additionally, for easy use of PVUSB, you need support in the toolstack
to get the two sides to talk to each other.

2. Specifying a host USB device

QEMU hmp commands allows USB devices to be specified either by their
bus address (in the form bus.device) or their device tag (in the form
vendorid:deviceid).

Each way of specifying has its advantages:

Specifying by device tag will always get the same device,
regardless of where the device ends up in the USB bus topology.
However, if there are two identical devices, it will not allow you to
specify which one. 

Specifying by bus address will always allow you to choose a
specific device, even if you have duplicates. However, the bus address
may change depending on which port you plugged the device into, and
possibly also after a reboot. 

To avoid duplication of vendorid:deviceid, we'll use bus address to
specify host USB device in xl toolstack.

You can use lsusb to list the USB devices on the system:

Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0
Hub
Bus 003 Device 002: ID f617:0905  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0424:2640 Standard Microsystems Corp. USB 2.0
Hub
Bus 001 Device 005: ID 0424:4060 Standard Microsystems Corp. Ultra
Fast Media Reader
Bus 001 Device 006: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse

To pass through the Logitec mouse, for instance, you could specify
1.6 (remove leading zeroes).

Note: USB Hub could not be assigned to guest.

3. PVUSB toolstack

* Specify USB device in xl config file

You can just specify usb devices, like:
usb=['1.6']

Then it will create a USB controller automatically and attach the USB
device to the first available USB controller:port.

or, you can explicitly specify usb controllers and usb devices, like:
usbctrl=['verison=1, ports=4', 'version=2, ports=8', ]
usb=['1.6, controller=0, port=1']

Then it will create two USB controllers as you specified.
And if controller and port are specified in usb config, then it will
attach the USB device to that controller:port. About the controller
and port value:
Each USB controller has a index (or called devid) based on 0. The 1st
controller has index 0, the 2nd controller has index 1, ...
Under controller, each port has a port number based on 1. In above
configuration, the 1st controller will have port 1,2,3,4.

To be compatible with QEMU emulated USB, this interface could be
extended to:
usb=['1.6, type=pv|qemu',]
type=pv means attaching the USB device in pvusb way; type=qemu means
attaching USB device in QEMU emulated way.

* Hot-Plug USB device

To attach a USB device, you should first create 

[Xen-devel] [PATCH V3 2/6] libxl_read_file_contents: fix reading sysfs file

2015-04-19 Thread Chunyan Liu
Sysfs file has size=4096 but actual file content is less than that.
Current libxl_read_file_contents will treat it as error when file size
and actual file content differs, so reading sysfs file content with
this function always fails. Fix it so that we can reuse this function
to get sysfs file content in later pvusb work.

Signed-off-by: Chunyan Liu cy...@suse.com
---
 tools/libxl/libxl_utils.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c
index 9053b27..18ad2b8 100644
--- a/tools/libxl/libxl_utils.c
+++ b/tools/libxl/libxl_utils.c
@@ -363,12 +363,9 @@ int libxl_read_file_contents(libxl_ctx *ctx, const char 
*filename,
 if (!data) goto xe;
 
 rs = fread(data, 1, datalen, f);
-if (rs != datalen) {
+if (rs != datalen  !feof(f)) {
 if (ferror(f))
 LOGE(ERROR, failed to read %s, filename);
-else if (feof(f))
-LOG(ERROR, %s changed size while we were reading it,
-   filename);
 else
 abort();
 goto xe;
-- 
1.8.5.2


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [rumpuserxen test] 50441: regressions - trouble: blocked/broken/fail/pass

2015-04-19 Thread osstest service user
flight 50441 rumpuserxen real [real]
http://logs.test-lab.xenproject.org/osstest/logs/50441/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-i386-rumpuserxen3 host-install(3) broken REGR. vs. 33866
 build-amd64-rumpuserxen   5 rumpuserxen-build fail REGR. vs. 33866

Regressions which are regarded as allowable (not blocking):
 build-i386-xsm3 host-install(3)broken blocked in 33866

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-rumpuserxen-amd64  1 build-check(1)   blocked n/a
 test-amd64-i386-rumpuserxen-i386  1 build-check(1)   blocked  n/a

version targeted for testing:
 rumpuserxen  3b91e44996ea6ae1276bce1cc44f38701c53ee6f
baseline version:
 rumpuserxen  30d72f3fc5e35cd53afd82c8179cc0e0b11146ad


People who touched revisions under test:
  Antti Kantee po...@iki.fi
  Ian Jackson ian.jack...@eu.citrix.com
  Martin Lucina mar...@lucina.net
  Wei Liu l...@liuw.name


jobs:
 build-amd64-xsm  pass
 build-i386-xsm   broken  
 build-amd64  pass
 build-i386   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 build-amd64-rumpuserxen  fail
 build-i386-rumpuserxen   broken  
 test-amd64-amd64-rumpuserxen-amd64   blocked 
 test-amd64-i386-rumpuserxen-i386 blocked 



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/osstest/pub/logs
images: /home/osstest/pub/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-i386-xsm host-install(3)
broken-step build-i386-rumpuserxen host-install(3)

Not pushing.

(No revision log; it would be 535 lines long.)

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [seabios test] 50478: trouble: blocked/broken

2015-04-19 Thread osstest service user
flight 50478 seabios real [real]
http://logs.test-lab.xenproject.org/osstest/logs/50478/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-i3863 host-install(3) broken REGR. vs. 36656
 build-i386-pvops  3 host-install(3) broken REGR. vs. 36656
 build-amd64-pvops 3 host-install(3) broken REGR. vs. 36656
 build-amd64   3 host-install(3) broken REGR. vs. 36656

Tests which did not succeed, but are not blocking:
 test-amd64-i386-freebsd10-i386  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-xsm1 build-check(1)   blocked  n/a
 build-amd64-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-libvirt-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-freebsd10-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-winxpsp3  1 build-check(1)   blocked n/a
 build-i386-libvirt1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-ovmf-amd64  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-credit2   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-win7-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf-pin  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-ovmf-amd64  1 build-check(1)  blocked n/a
 test-amd64-amd64-xl-qemut-winxpsp3  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-winxpsp3-vcpus1  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-amd64-i386-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-winxpsp3  1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-winxpsp3  1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-winxpsp3   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-amd64-xl-win7-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf  1 build-check(1)   blocked  n/a
 test-amd64-i386-pair  1 build-check(1)   blocked  n/a
 test-amd64-amd64-pair 1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-win7-amd64  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-qemut-win7-amd64  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-qemuu-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-pvh-intel  1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-amd64-xl-multivcpu  1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemut-winxpsp3  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-pvh-amd   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-qemut-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemut-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-i386-qemut-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-amd64-i386-rhel6hvm-amd  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-i386-rhel6hvm-intel  1 build-check(1)   blocked  n/a
 build-amd64-xsm   3 host-install(3)  broken never pass
 build-i386-xsm3 host-install(3)  broken never pass

version targeted for testing:
 seabios  0b2165d191f51ed2a522142c3ed3db55bc852627
baseline version:
 seabios  b4581224824871ad2909f84fc4a9e067cda663f2


People who touched revisions under test:
  Bruce 

[Xen-devel] [linux-3.10 test] 50433: tolerable trouble: broken/fail/pass - PUSHED

2015-04-19 Thread osstest service user
flight 50433 linux-3.10 real [real]
http://logs.test-lab.xenproject.org/osstest/logs/50433/

Failures :-/ but no regressions.

Tests which are failing intermittently (not blocking):
 test-amd64-i386-xl-xsm3 host-install(3)   broken pass in 50411
 test-amd64-i386-xl-qemut-winxpsp3  3 host-install(3)  broken pass in 50411
 test-amd64-amd64-xl-qemuu-win7-amd64  3 host-install(3)   broken pass in 50411
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm 3 host-install(3) broken pass in 
50411
 test-amd64-amd64-xl-xsm   3 host-install(3)   broken pass in 50411
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm 3 host-install(3) broken pass in 
50411
 test-amd64-amd64-xl-pvh-amd   3 host-install(3)   broken pass in 50411
 test-amd64-amd64-xl-sedf 11 guest-startfail in 50411 pass in 50433
 test-amd64-i386-xl-qemut-win7-amd64  6 xen-bootfail in 50411 pass in 50433
 test-amd64-i386-freebsd10-amd64 16 guest-localmigrate/x10 fail in 50411 pass 
in 50433

Regressions which are regarded as allowable (not blocking):
 test-amd64-i386-pair21 guest-migrate/src_host/dst_host fail like 50271

Tests which did not succeed, but are not blocking:
 test-amd64-i386-xl-xsm   11 guest-start   fail in 50411 never pass
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-stopfail in 50411 never pass
 test-amd64-i386-xl-qemut-winxpsp3 16 guest-stop   fail in 50411 never pass
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm 9 debian-hvm-install fail in 
50411 never pass
 test-amd64-amd64-xl-xsm  11 guest-start   fail in 50411 never pass
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm 9 debian-hvm-install fail in 
50411 never pass
 test-amd64-amd64-xl-pvh-amd  11 guest-start   fail in 50411 never pass
 test-amd64-i386-libvirt-xsm  11 guest-start  fail   never pass
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm 9 debian-hvm-install fail never 
pass
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm 9 debian-hvm-install fail never 
pass
 test-amd64-amd64-xl-pvh-intel 11 guest-start  fail  never pass
 test-amd64-amd64-libvirt-xsm 11 guest-start  fail   never pass
 test-armhf-armhf-xl-xsm   6 xen-boot fail   never pass
 test-armhf-armhf-xl-arndale   6 xen-boot fail   never pass
 test-armhf-armhf-xl-sedf  6 xen-boot fail   never pass
 test-armhf-armhf-xl   6 xen-boot fail   never pass
 test-armhf-armhf-xl-cubietruck  6 xen-boot fail never pass
 test-armhf-armhf-xl-multivcpu  6 xen-boot fail  never pass
 test-armhf-armhf-xl-credit2   6 xen-boot fail   never pass
 test-armhf-armhf-xl-sedf-pin  6 xen-boot fail   never pass
 test-amd64-amd64-libvirt 12 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemuu-win7-amd64 16 guest-stop  fail never pass
 test-amd64-amd64-xl-win7-amd64 16 guest-stop   fail never pass
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-stop  fail never pass
 test-amd64-amd64-xl-qemut-winxpsp3 16 guest-stop   fail never pass
 test-amd64-amd64-xl-qemuu-winxpsp3 16 guest-stop   fail never pass
 test-amd64-amd64-xl-qemut-win7-amd64 16 guest-stop fail never pass
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1 16 guest-stop fail never pass
 test-amd64-i386-xl-win7-amd64 16 guest-stop   fail  never pass
 test-amd64-i386-xl-winxpsp3-vcpus1 16 guest-stop   fail never pass
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1 16 guest-stop fail never pass
 test-armhf-armhf-libvirt  6 xen-boot fail   never pass
 test-armhf-armhf-libvirt-xsm  6 xen-boot fail   never pass
 test-amd64-i386-xl-winxpsp3  16 guest-stop   fail   never pass
 test-amd64-amd64-xl-winxpsp3 16 guest-stop   fail   never pass
 test-amd64-i386-xl-qemuu-winxpsp3 16 guest-stopfail never pass

version targeted for testing:
 linuxc9ef473a544f0c10e631c25e631f31f9dc0eaed7
baseline version:
 linux73895725a9401bd3454757fcfa7d691270ac7498


People who touched revisions under test:
  Andrew Morton a...@linux-foundation.org
  Bart Van Assche bart.vanass...@sandisk.com
  Bob Copeland m...@bobcopeland.com
  Charles Keepax ckee...@opensource.wolfsonmicro.com
  Dan Carpenter dan.carpen...@oracle.com
  David S. Miller da...@davemloft.net
  Eric Nelson eric.nel...@boundarydevices.com
  Greg Kroah-Hartman gre...@linuxfoundation.org
  Greg Kroah-Hartman gre...@linuxfoundation.org
  Hin-Tak Leung ht...@users.sourceforge.net
  Ingo Molnar mi...@kernel.org
  Johannes Berg johannes.b...@intel.com
  Lars-Peter 

[Xen-devel] [qemu-mainline test] 50651: trouble: blocked/broken

2015-04-19 Thread osstest service user
flight 50651 qemu-mainline real [real]
http://logs.test-lab.xenproject.org/osstest/logs/50651/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-armhf-xsm   3 host-install(3) broken REGR. vs. 50391
 build-armhf   3 host-install(3) broken REGR. vs. 50391
 build-i386-pvops  3 host-install(3) broken REGR. vs. 50391
 build-amd64-xsm   3 host-install(3) broken REGR. vs. 50391
 build-i386-xsm3 host-install(3) broken REGR. vs. 50391
 build-amd64-pvops 3 host-install(3) broken REGR. vs. 50391
 build-amd64   3 host-install(3) broken REGR. vs. 50391
 build-i3863 host-install(3) broken REGR. vs. 50391
 build-armhf-pvops 3 host-install(3) broken REGR. vs. 50391

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-pvh-amd   1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 test-amd64-i386-xl-xsm1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt-xsm   1 build-check(1)   blocked  n/a
 test-amd64-i386-freebsd10-i386  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-xsm   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm  1 build-check(1)blocked n/a
 test-amd64-amd64-xl-pvh-intel  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm  1 build-check(1) blocked n/a
 build-amd64-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-i386-freebsd10-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl   1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-multivcpu  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-arndale   1 build-check(1)   blocked  n/a
 test-amd64-amd64-libvirt  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf-pin  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-credit2   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-winxpsp3  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-i386-qemut-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-amd64-amd64-xl-qemut-winxpsp3  1 build-check(1)   blocked n/a
 test-amd64-i386-xl-qemut-win7-amd64  1 build-check(1)  blocked n/a
 test-amd64-amd64-xl-qemut-debianhvm-amd64  1 build-check(1)blocked n/a
 test-amd64-i386-qemut-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-amd64-amd64-pair 1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1  1 build-check(1) blocked n/a
 test-armhf-armhf-xl   1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-credit2   1 build-check(1)   blocked  n/a
 test-amd64-i386-libvirt   1 build-check(1)   blocked  n/a
 test-amd64-i386-xl1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-amd  1 build-check(1)   blocked n/a
 test-armhf-armhf-xl-sedf  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-sedf-pin  1 build-check(1)   blocked  n/a
 test-amd64-i386-qemuu-rhel6hvm-intel  1 build-check(1) blocked n/a
 test-armhf-armhf-xl-multivcpu  1 build-check(1)   blocked  n/a
 test-amd64-i386-rhel6hvm-intel  1 build-check(1)   blocked  n/a
 build-i386-libvirt1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-win7-amd64  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-sedf  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemut-win7-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-winxpsp3  1 build-check(1)   blocked  n/a
 test-armhf-armhf-libvirt  1 build-check(1)   blocked  n/a
 test-amd64-i386-rhel6hvm-amd  1 build-check(1)   blocked  n/a
 test-armhf-armhf-xl-cubietruck  1 build-check(1)   blocked  n/a
 test-armhf-armhf-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-amd64-i386-xl-qemut-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-xl-qemuu-debianhvm-amd64  1 build-check(1) blocked n/a
 test-amd64-i386-pair  1 build-check(1)   blocked  

[Xen-devel] [Patch V3 01/15] xen: sync with xen headers

2015-04-19 Thread Juergen Gross
Use the newest headers from the xen tree to get some new structure
layouts.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/include/asm/xen/interface.h | 96 
 include/xen/interface/xen.h  | 10 ++--
 2 files changed, 93 insertions(+), 13 deletions(-)

diff --git a/arch/x86/include/asm/xen/interface.h 
b/arch/x86/include/asm/xen/interface.h
index 3400dba..3b88eea 100644
--- a/arch/x86/include/asm/xen/interface.h
+++ b/arch/x86/include/asm/xen/interface.h
@@ -3,12 +3,38 @@
  *
  * Guest OS interface to x86 Xen.
  *
- * Copyright (c) 2004, K A Fraser
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the Software), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (c) 2004-2006, K A Fraser
  */
 
 #ifndef _ASM_X86_XEN_INTERFACE_H
 #define _ASM_X86_XEN_INTERFACE_H
 
+/*
+ * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field
+ * in a struct in memory.
+ * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an
+ * hypercall argument.
+ * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but
+ * they might not be on other architectures.
+ */
 #ifdef __XEN__
 #define __DEFINE_GUEST_HANDLE(name, type) \
 typedef struct { type *p; } __guest_handle_ ## name
@@ -88,13 +114,16 @@ DEFINE_GUEST_HANDLE(xen_ulong_t);
  * start of the GDT because some stupid OSes export hard-coded selector values
  * in their ABI. These hard-coded values are always near the start of the GDT,
  * so Xen places itself out of the way, at the far end of the GDT.
+ *
+ * NB The LDT is set using the MMUEXT_SET_LDT op of HYPERVISOR_mmuext_op
  */
 #define FIRST_RESERVED_GDT_PAGE  14
 #define FIRST_RESERVED_GDT_BYTE  (FIRST_RESERVED_GDT_PAGE * 4096)
 #define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8)
 
 /*
- * Send an array of these to HYPERVISOR_set_trap_table()
+ * Send an array of these to HYPERVISOR_set_trap_table().
+ * Terminate the array with a sentinel entry, with traps[].address==0.
  * The privilege level specifies which modes may enter a trap via a software
  * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate
  * privilege levels as follows:
@@ -118,10 +147,41 @@ struct trap_info {
 DEFINE_GUEST_HANDLE_STRUCT(trap_info);
 
 struct arch_shared_info {
-unsigned long max_pfn;  /* max pfn that appears in table */
-/* Frame containing list of mfns containing list of mfns containing p2m. */
-unsigned long pfn_to_mfn_frame_list_list;
-unsigned long nmi_reason;
+   /*
+* Number of valid entries in the p2m table(s) anchored at
+* pfn_to_mfn_frame_list_list and/or p2m_vaddr.
+*/
+   unsigned long max_pfn;
+   /*
+* Frame containing list of mfns containing list of mfns containing p2m.
+* A value of 0 indicates it has not yet been set up, ~0 indicates it
+* has been set to invalid e.g. due to the p2m being too large for the
+* 3-level p2m tree. In this case the linear mapper p2m list anchored
+* at p2m_vaddr is to be used.
+*/
+   xen_pfn_t pfn_to_mfn_frame_list_list;
+   unsigned long nmi_reason;
+   /*
+* Following three fields are valid if p2m_cr3 contains a value
+* different from 0.
+* p2m_cr3 is the root of the address space where p2m_vaddr is valid.
+* p2m_cr3 is in the same format as a cr3 value in the vcpu register
+* state and holds the folded machine frame number (via xen_pfn_to_cr3)
+* of a L3 or L4 page table.
+* p2m_vaddr holds the virtual address of the linear p2m list. All
+* entries in the range [0...max_pfn[ are accessible via this pointer.
+* p2m_generation will be incremented by the guest before and after each
+* change of the mappings of the p2m list. p2m_generation starts at 0
+* and a value with the least significant bit set indicates that a
+* mapping 

[Xen-devel] [Patch V3 04/15] xen: eliminate scalability issues from initial mapping setup

2015-04-19 Thread Juergen Gross
Direct Xen to place the initial P-M table outside of the initial
mapping, as otherwise the 1G (implementation) / 2G (theoretical)
restriction on the size of the initial mapping limits the amount
of memory a domain can be handed initially.

As the initial P-M table is copied rather early during boot to
domain private memory and it's initial virtual mapping is dropped,
the easiest way to avoid virtual address conflicts with other
addresses in the kernel is to use a user address area for the
virtual address of the initial P-M table. This allows us to just
throw away the page tables of the initial mapping after the copy
without having to care about address invalidation.

It should be noted that this patch won't enable a pv-domain to USE
more than 512 GB of RAM. It just enables it to be started with a
P-M table covering more memory. This is especially important for
being able to boot a Dom0 on a system with more than 512 GB memory.

Signed-off-by: Juergen Gross jgr...@suse.com
Based-on-patch-by: Jan Beulich jbeul...@suse.com
---
 arch/x86/xen/mmu.c  | 126 
 arch/x86/xen/setup.c|  67 ++---
 arch/x86/xen/xen-head.S |   2 +
 3 files changed, 156 insertions(+), 39 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index dd151b2..c04e14e 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1114,6 +1114,77 @@ static void __init xen_cleanhighmap(unsigned long vaddr,
xen_mc_flush();
 }
 
+/*
+ * Make a page range writeable and free it.
+ */
+static void __init xen_free_ro_pages(unsigned long paddr, unsigned long size)
+{
+   void *vaddr = __va(paddr);
+   void *vaddr_end = vaddr + size;
+
+   for (; vaddr  vaddr_end; vaddr += PAGE_SIZE)
+   make_lowmem_page_readwrite(vaddr);
+
+   memblock_free(paddr, size);
+}
+
+static void __init xen_cleanmfnmap_free_pgtbl(void *pgtbl)
+{
+   unsigned long pa = __pa(pgtbl)  PHYSICAL_PAGE_MASK;
+
+   ClearPagePinned(virt_to_page(__va(pa)));
+   xen_free_ro_pages(pa, PAGE_SIZE);
+}
+
+/*
+ * Since it is well isolated we can (and since it is perhaps large we should)
+ * also free the page tables mapping the initial P-M table.
+ */
+static void __init xen_cleanmfnmap(unsigned long vaddr)
+{
+   unsigned long va = vaddr  PMD_MASK;
+   unsigned long pa;
+   pgd_t *pgd = pgd_offset_k(va);
+   pud_t *pud_page = pud_offset(pgd, 0);
+   pud_t *pud;
+   pmd_t *pmd;
+   pte_t *pte;
+   unsigned int i;
+
+   set_pgd(pgd, __pgd(0));
+   do {
+   pud = pud_page + pud_index(va);
+   if (pud_none(*pud)) {
+   va += PUD_SIZE;
+   } else if (pud_large(*pud)) {
+   pa = pud_val(*pud)  PHYSICAL_PAGE_MASK;
+   xen_free_ro_pages(pa, PUD_SIZE);
+   va += PUD_SIZE;
+   } else {
+   pmd = pmd_offset(pud, va);
+   if (pmd_large(*pmd)) {
+   pa = pmd_val(*pmd)  PHYSICAL_PAGE_MASK;
+   xen_free_ro_pages(pa, PMD_SIZE);
+   } else if (!pmd_none(*pmd)) {
+   pte = pte_offset_kernel(pmd, va);
+   for (i = 0; i  PTRS_PER_PTE; ++i) {
+   if (pte_none(pte[i]))
+   break;
+   pa = pte_pfn(pte[i])  PAGE_SHIFT;
+   xen_free_ro_pages(pa, PAGE_SIZE);
+   }
+   xen_cleanmfnmap_free_pgtbl(pte);
+   }
+   va += PMD_SIZE;
+   if (pmd_index(va))
+   continue;
+   xen_cleanmfnmap_free_pgtbl(pmd);
+   }
+
+   } while (pud_index(va) || pmd_index(va));
+   xen_cleanmfnmap_free_pgtbl(pud_page);
+}
+
 static void __init xen_pagetable_p2m_free(void)
 {
unsigned long size;
@@ -1128,18 +1199,25 @@ static void __init xen_pagetable_p2m_free(void)
/* using __ka address and sticking INVALID_P2M_ENTRY! */
memset((void *)xen_start_info-mfn_list, 0xff, size);
 
-   /* We should be in __ka space. */
-   BUG_ON(xen_start_info-mfn_list  __START_KERNEL_map);
addr = xen_start_info-mfn_list;
-   /* We roundup to the PMD, which means that if anybody at this stage is
-* using the __ka address of xen_start_info or 
xen_start_info-shared_info
-* they are in going to crash. Fortunatly we have already revectored
-* in xen_setup_kernel_pagetable and in xen_setup_shared_info. */
+   /*
+* We could be in __ka space.
+* We roundup to the PMD, which means that if anybody at this stage is
+* using the __ka address of xen_start_info or
+* 

[Xen-devel] [Patch V3 10/15] xen: check pre-allocated page tables for conflict with memory map

2015-04-19 Thread Juergen Gross
Check whether the page tables built by the domain builder are at
memory addresses which are in conflict with the target memory map.
If this is the case just panic instead of running into problems
later.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 arch/x86/xen/mmu.c | 19 ---
 arch/x86/xen/setup.c   |  6 ++
 arch/x86/xen/xen-ops.h |  1 +
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index c04e14e..1982617 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -116,6 +116,7 @@ static pud_t level3_user_vsyscall[PTRS_PER_PUD] 
__page_aligned_bss;
 DEFINE_PER_CPU(unsigned long, xen_cr3); /* cr3 stored as physaddr */
 DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */
 
+static phys_addr_t xen_pt_base, xen_pt_size __initdata;
 
 /*
  * Just beyond the highest usermode address.  STACK_TOP_MAX has a
@@ -1998,7 +1999,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, 
unsigned long max_pfn)
check_pt_base(pt_base, pt_end, addr[i]);
 
/* Our (by three pages) smaller Xen pagetable that we are using */
-   memblock_reserve(PFN_PHYS(pt_base), (pt_end - pt_base) * PAGE_SIZE);
+   xen_pt_base = PFN_PHYS(pt_base);
+   xen_pt_size = (pt_end - pt_base) * PAGE_SIZE;
+   memblock_reserve(xen_pt_base, xen_pt_size);
/* protect xen_start_info */
memblock_reserve(__pa(xen_start_info), PAGE_SIZE);
/* Revector the xen_start_info */
@@ -2074,11 +2077,21 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, 
unsigned long max_pfn)
  PFN_DOWN(__pa(initial_page_table)));
xen_write_cr3(__pa(initial_page_table));
 
-   memblock_reserve(__pa(xen_start_info-pt_base),
-xen_start_info-nr_pt_frames * PAGE_SIZE);
+   xen_pt_base = __pa(xen_start_info-pt_base);
+   xen_pt_size = xen_start_info-nr_pt_frames * PAGE_SIZE;
+
+   memblock_reserve(xen_pt_base, xen_pt_size);
 }
 #endif /* CONFIG_X86_64 */
 
+void __init xen_pt_check_e820(void)
+{
+   if (xen_is_e820_reserved(xen_pt_base, xen_pt_size)) {
+   xen_raw_console_write(Xen hypervisor allocated page table 
memory conflicts with E820 map\n);
+   BUG();
+   }
+}
+
 static unsigned char dummy_mapping[PAGE_SIZE] __page_aligned_bss;
 
 static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 9bd3f35..3fca9c1 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -802,6 +802,12 @@ char * __init xen_memory_setup(void)
BUG();
}
 
+   /*
+* Check for a conflict of the hypervisor supplied page tables with
+* the target E820 map.
+*/
+   xen_pt_check_e820();
+
xen_reserve_xen_mfnlist();
 
/*
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 3f1669c..553abd8 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -35,6 +35,7 @@ void xen_build_mfn_list_list(void);
 void xen_setup_machphys_mapping(void);
 void xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn);
 void xen_reserve_top(void);
+void __init xen_pt_check_e820(void);
 
 void xen_mm_pin_all(void);
 void xen_mm_unpin_all(void);
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 02/15] xen: save linear p2m list address in shared info structure

2015-04-19 Thread Juergen Gross
The virtual address of the linear p2m list should be stored in the
shared info structure read by the Xen tools to be able to support
64 bit pv-domains larger than 512 GB. Additionally the linear p2m
list interface includes a generation count which is changed prior
to and after each mapping change of the p2m list. Reading the
generation count the Xen tools can detect changes of the mappings
and re-read the p2m list eventually.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/p2m.c | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index b47124d..703f803 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -262,6 +262,10 @@ void xen_setup_mfn_list_list(void)
HYPERVISOR_shared_info-arch.pfn_to_mfn_frame_list_list =
virt_to_mfn(p2m_top_mfn);
HYPERVISOR_shared_info-arch.max_pfn = xen_max_p2m_pfn;
+   HYPERVISOR_shared_info-arch.p2m_generation = 0;
+   HYPERVISOR_shared_info-arch.p2m_vaddr = (unsigned long)xen_p2m_addr;
+   HYPERVISOR_shared_info-arch.p2m_cr3 =
+   xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir));
 }
 
 /* Set up p2m_top to point to the domain-builder provided p2m pages */
@@ -477,8 +481,12 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t 
*pte_pg)
 
ptechk = lookup_address(vaddr, level);
if (ptechk == pte_pg) {
+   HYPERVISOR_shared_info-arch.p2m_generation++;
+   wmb(); /* Tools are synchronizing via p2m_generation. */
set_pmd(pmdp,
__pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE));
+   wmb(); /* Tools are synchronizing via p2m_generation. */
+   HYPERVISOR_shared_info-arch.p2m_generation++;
pte_newpg[i] = NULL;
}
 
@@ -576,8 +584,12 @@ static bool alloc_p2m(unsigned long pfn)
spin_lock_irqsave(p2m_update_lock, flags);
 
if (pte_pfn(*ptep) == p2m_pfn) {
+   HYPERVISOR_shared_info-arch.p2m_generation++;
+   wmb(); /* Tools are synchronizing via p2m_generation. */
set_pte(ptep,
pfn_pte(PFN_DOWN(__pa(p2m)), PAGE_KERNEL));
+   wmb(); /* Tools are synchronizing via p2m_generation. */
+   HYPERVISOR_shared_info-arch.p2m_generation++;
if (mid_mfn)
mid_mfn[mididx] = virt_to_mfn(p2m);
p2m = NULL;
@@ -629,6 +641,11 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned 
long mfn)
return true;
}
 
+   /*
+* The interface requires atomic updates on p2m elements.
+* xen_safe_write_ulong() is using __put_user which does an atomic
+* store via asm().
+*/
if (likely(!xen_safe_write_ulong(xen_p2m_addr + pfn, mfn)))
return true;
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 07/15] xen: check memory area against e820 map

2015-04-19 Thread Juergen Gross
Provide a service routine to check a physical memory area against the
E820 map. The routine will return false if the complete area is RAM
according to the E820 map and true otherwise.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/setup.c   | 23 +++
 arch/x86/xen/xen-ops.h |  1 +
 2 files changed, 24 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 87251b4..99ef82c 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -573,6 +573,29 @@ static unsigned long __init xen_count_remap_pages(unsigned 
long max_pfn)
return extra;
 }
 
+bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size)
+{
+   struct e820entry *entry;
+   unsigned mapcnt;
+   phys_addr_t end;
+
+   if (!size)
+   return false;
+
+   end = start + size;
+   entry = xen_e820_map;
+
+   for (mapcnt = 0; mapcnt  xen_e820_map_entries; mapcnt++) {
+   if (entry-type == E820_RAM  entry-addr = start 
+   (entry-addr + entry-size) = end)
+   return false;
+
+   entry++;
+   }
+
+   return true;
+}
+
 /*
  * Reserve Xen mfn_list.
  * See comment above struct start_info in xen/interface/xen.h
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 9e195c6..c1385b8 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -39,6 +39,7 @@ void xen_reserve_top(void);
 void xen_mm_pin_all(void);
 void xen_mm_unpin_all(void);
 
+bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size);
 unsigned long __ref xen_chk_extra_mem(unsigned long pfn);
 void __init xen_inv_extra_mem(void);
 void __init xen_remap_memory(void);
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 15/15] xen: remove no longer needed p2m.h

2015-04-19 Thread Juergen Gross
Cleanup by removing arch/x86/xen/p2m.h as it isn't needed any more.

Most definitions in this file are used in p2m.c only. Move those into
p2m.c.

set_phys_range_identity() is already declared in
arch/x86/include/asm/xen/page.h, add __init annotation there.

MAX_REMAP_RANGES isn't used at all, just delete it.

The only define left is P2M_PER_PAGE which is moved to page.h as well.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 arch/x86/include/asm/xen/page.h |  6 --
 arch/x86/xen/p2m.c  |  6 +-
 arch/x86/xen/p2m.h  | 15 ---
 arch/x86/xen/setup.c|  1 -
 4 files changed, 9 insertions(+), 19 deletions(-)
 delete mode 100644 arch/x86/xen/p2m.h

diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 18a11f2..b858592 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -35,6 +35,8 @@ typedef struct xpaddr {
 #define FOREIGN_FRAME(m)   ((m) | FOREIGN_FRAME_BIT)
 #define IDENTITY_FRAME(m)  ((m) | IDENTITY_FRAME_BIT)
 
+#define P2M_PER_PAGE   (PAGE_SIZE / sizeof(unsigned long))
+
 extern unsigned long *machine_to_phys_mapping;
 extern unsigned long  machine_to_phys_nr;
 extern unsigned long *xen_p2m_addr;
@@ -44,8 +46,8 @@ extern unsigned long  xen_max_p2m_pfn;
 extern unsigned long get_phys_to_machine(unsigned long pfn);
 extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
 extern bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn);
-extern unsigned long set_phys_range_identity(unsigned long pfn_s,
-unsigned long pfn_e);
+extern unsigned long __init set_phys_range_identity(unsigned long pfn_s,
+   unsigned long pfn_e);
 
 extern int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops,
   struct gnttab_map_grant_ref *kmap_ops,
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 365a64a..1f63ad2 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -78,10 +78,14 @@
 #include xen/balloon.h
 #include xen/grant_table.h
 
-#include p2m.h
 #include multicalls.h
 #include xen-ops.h
 
+#define P2M_MID_PER_PAGE   (PAGE_SIZE / sizeof(unsigned long *))
+#define P2M_TOP_PER_PAGE   (PAGE_SIZE / sizeof(unsigned long **))
+
+#define MAX_P2M_PFN(P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * P2M_PER_PAGE)
+
 #define PMDS_PER_MID_PAGE  (P2M_MID_PER_PAGE / PTRS_PER_PTE)
 
 unsigned long *xen_p2m_addr __read_mostly;
diff --git a/arch/x86/xen/p2m.h b/arch/x86/xen/p2m.h
deleted file mode 100644
index ad8aee2..000
--- a/arch/x86/xen/p2m.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef _XEN_P2M_H
-#define _XEN_P2M_H
-
-#define P2M_PER_PAGE(PAGE_SIZE / sizeof(unsigned long))
-#define P2M_MID_PER_PAGE(PAGE_SIZE / sizeof(unsigned long *))
-#define P2M_TOP_PER_PAGE(PAGE_SIZE / sizeof(unsigned long **))
-
-#define MAX_P2M_PFN (P2M_TOP_PER_PAGE * P2M_MID_PER_PAGE * 
P2M_PER_PAGE)
-
-#define MAX_REMAP_RANGES10
-
-extern unsigned long __init set_phys_range_identity(unsigned long pfn_s,
-  unsigned long pfn_e);
-
-#endif  /* _XEN_P2M_H */
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index f960021..a1a77ea 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -30,7 +30,6 @@
 #include xen/hvc-console.h
 #include xen-ops.h
 #include vdso.h
-#include p2m.h
 #include mmu.h
 
 #define GB(x) ((uint64_t)(x) * 1024 * 1024 * 1024)
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 12/15] mm: provide early_memremap_ro to establish read-only mapping

2015-04-19 Thread Juergen Gross
During early boot as Xen pv domain the kernel needs to map some page
tables supplied by the hypervisor read only. This is needed to be
able to relocate some data structures conflicting with the physical
memory map especially on systems with huge RAM (above 512GB).

Provide the function early_memremap_ro() to provide this read only
mapping.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 include/asm-generic/early_ioremap.h |  2 ++
 include/asm-generic/fixmap.h|  3 +++
 mm/early_ioremap.c  | 11 +++
 3 files changed, 16 insertions(+)

diff --git a/include/asm-generic/early_ioremap.h 
b/include/asm-generic/early_ioremap.h
index a5de55c..316bd04 100644
--- a/include/asm-generic/early_ioremap.h
+++ b/include/asm-generic/early_ioremap.h
@@ -11,6 +11,8 @@ extern void __iomem *early_ioremap(resource_size_t phys_addr,
   unsigned long size);
 extern void *early_memremap(resource_size_t phys_addr,
unsigned long size);
+extern void *early_memremap_ro(resource_size_t phys_addr,
+  unsigned long size);
 extern void early_iounmap(void __iomem *addr, unsigned long size);
 extern void early_memunmap(void *addr, unsigned long size);
 
diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index f23174f..d8cc637 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -46,6 +46,9 @@ static inline unsigned long virt_to_fix(const unsigned long 
vaddr)
 #ifndef FIXMAP_PAGE_NORMAL
 #define FIXMAP_PAGE_NORMAL PAGE_KERNEL
 #endif
+#ifndef FIXMAP_PAGE_RO
+#define FIXMAP_PAGE_RO PAGE_KERNEL_RO
+#endif
 #ifndef FIXMAP_PAGE_NOCACHE
 #define FIXMAP_PAGE_NOCACHE PAGE_KERNEL_NOCACHE
 #endif
diff --git a/mm/early_ioremap.c b/mm/early_ioremap.c
index e10ccd2..e4ffaac 100644
--- a/mm/early_ioremap.c
+++ b/mm/early_ioremap.c
@@ -217,6 +217,12 @@ early_memremap(resource_size_t phys_addr, unsigned long 
size)
return (__force void *)__early_ioremap(phys_addr, size,
   FIXMAP_PAGE_NORMAL);
 }
+void __init *
+early_memremap_ro(resource_size_t phys_addr, unsigned long size)
+{
+   return (__force void *)__early_ioremap(phys_addr, size,
+  FIXMAP_PAGE_RO);
+}
 #else /* CONFIG_MMU */
 
 void __init __iomem *
@@ -231,6 +237,11 @@ early_memremap(resource_size_t phys_addr, unsigned long 
size)
 {
return (void *)phys_addr;
 }
+void __init *
+early_memremap_ro(resource_size_t phys_addr, unsigned long size)
+{
+   return (void *)phys_addr;
+}
 
 void __init early_iounmap(void __iomem *addr, unsigned long size)
 {
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 14/15] xen: allow more than 512 GB of RAM for 64 bit pv-domains

2015-04-19 Thread Juergen Gross
64 bit pv-domains under Xen are limited to 512 GB of RAM today. The
main reason has been the 3 level p2m tree, which was replaced by the
virtual mapped linear p2m list. Parallel to the p2m list which is
being used by the kernel itself there is a 3 level mfn tree for usage
by the Xen tools and eventually for crash dump analysis. For this tree
the linear p2m list can serve as a replacement, too. As the kernel
can't know whether the tools are capable of dealing with the p2m list
instead of the mfn tree, the limit of 512 GB can't be dropped in all
cases.

This patch replaces the hard limit by a kernel parameter which tells
the kernel to obey the 512 GB limit or not. The default is selected by
a configuration parameter which specifies whether the 512 GB limit
should be active per default for domUs (domain save/restore/migration
and crash dump analysis are affected).

Memory above the domain limit is returned to the hypervisor instead of
being identity mapped, which was wrong anyway.

The kernel configuration parameter to specify the maximum size of a
domain can be deleted, as it is not relevant any more.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 Documentation/kernel-parameters.txt |  7 +
 arch/x86/include/asm/xen/page.h |  4 ---
 arch/x86/xen/Kconfig| 20 -
 arch/x86/xen/p2m.c  | 10 +++
 arch/x86/xen/setup.c| 59 +++--
 5 files changed, 73 insertions(+), 27 deletions(-)

diff --git a/Documentation/kernel-parameters.txt 
b/Documentation/kernel-parameters.txt
index 274252f..87b7a50 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -3999,6 +3999,13 @@ bytes respectively. Such letter suffixes can also be 
entirely omitted.
plus one apbt timer for broadcast timer.
x86_intel_mid_timer=apbt_only | lapic_and_apbt
 
+   xen_512gb_limit [KNL,X86-64,XEN]
+   Restricts the kernel running paravirtualized under Xen
+   to use only up to 512 GB of RAM. The reason to do so is
+   crash analysis tools and Xen tools for doing domain
+   save/restore/migration must be enabled to handle larger
+   domains.
+
xen_emul_unplug=[HW,X86,XEN]
Unplug Xen emulated devices
Format: [unplug0,][unplug1]
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index 358dcd3..18a11f2 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -35,10 +35,6 @@ typedef struct xpaddr {
 #define FOREIGN_FRAME(m)   ((m) | FOREIGN_FRAME_BIT)
 #define IDENTITY_FRAME(m)  ((m) | IDENTITY_FRAME_BIT)
 
-/* Maximum amount of memory we can handle in a domain in pages */
-#define MAX_DOMAIN_PAGES   \
-((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / 
PAGE_SIZE))
-
 extern unsigned long *machine_to_phys_mapping;
 extern unsigned long  machine_to_phys_nr;
 extern unsigned long *xen_p2m_addr;
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index e88fda8..7bcf21b 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -23,14 +23,18 @@ config XEN_PVHVM
def_bool y
depends on XEN  PCI  X86_LOCAL_APIC
 
-config XEN_MAX_DOMAIN_MEMORY
-   int
-   default 500 if X86_64
-   default 64 if X86_32
-   depends on XEN
-   help
- This only affects the sizing of some bss arrays, the unused
- portions of which are freed.
+config XEN_512GB
+   bool Limit Xen pv-domain memory to 512GB
+   depends on XEN  X86_64
+   default y
+   help
+ Limit paravirtualized user domains to 512GB of RAM.
+
+ The Xen tools and crash dump analysis tools might not support
+ pv-domains with more than 512 GB of RAM. This option controls the
+ default setting of the kernel to use only up to 512 GB or more.
+ It is always possible to change the default via specifying the
+ boot parameter xen_512gb_limit.
 
 config XEN_SAVE_RESTORE
bool
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 6f80cd3..365a64a 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -516,7 +516,7 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t 
*pte_pg)
  */
 static bool alloc_p2m(unsigned long pfn)
 {
-   unsigned topidx, mididx;
+   unsigned topidx;
unsigned long *top_mfn_p, *mid_mfn;
pte_t *ptep, *pte_pg;
unsigned int level;
@@ -524,9 +524,6 @@ static bool alloc_p2m(unsigned long pfn)
unsigned long addr = (unsigned long)(xen_p2m_addr + pfn);
unsigned long p2m_pfn;
 
-   topidx = p2m_top_index(pfn);
-   mididx = p2m_mid_index(pfn);
-
ptep = lookup_address(addr, level);
BUG_ON(!ptep || level 

[Xen-devel] [Patch V3 05/15] xen: move static e820 map to global scope

2015-04-19 Thread Juergen Gross
Instead of using a function local static e820 map in xen_memory_setup()
and calling various functions in the same source with the map as a
parameter use a map directly accessible by all functions in the source.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/setup.c | 96 +++-
 1 file changed, 49 insertions(+), 47 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index adad417..ab6c36e 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -38,6 +38,10 @@ struct xen_memory_region 
xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 /* Number of pages released from the initial allocation. */
 unsigned long xen_released_pages;
 
+/* E820 map used during setting up memory. */
+static struct e820entry xen_e820_map[E820MAX] __initdata;
+static u32 xen_e820_map_entries __initdata;
+
 /*
  * Buffer used to remap identity mapped pages. We only need the virtual space.
  * The physical page behind this address is remapped as needed to different
@@ -164,15 +168,13 @@ void __init xen_inv_extra_mem(void)
  * This function updates min_pfn with the pfn found and returns
  * the size of that range or zero if not found.
  */
-static unsigned long __init xen_find_pfn_range(
-   const struct e820entry *list, size_t map_size,
-   unsigned long *min_pfn)
+static unsigned long __init xen_find_pfn_range(unsigned long *min_pfn)
 {
-   const struct e820entry *entry;
+   const struct e820entry *entry = xen_e820_map;
unsigned int i;
unsigned long done = 0;
 
-   for (i = 0, entry = list; i  map_size; i++, entry++) {
+   for (i = 0; i  xen_e820_map_entries; i++, entry++) {
unsigned long s_pfn;
unsigned long e_pfn;
 
@@ -356,9 +358,9 @@ static void __init xen_do_set_identity_and_remap_chunk(
  * to Xen and not remapped.
  */
 static unsigned long __init xen_set_identity_and_remap_chunk(
-const struct e820entry *list, size_t map_size, unsigned long start_pfn,
-   unsigned long end_pfn, unsigned long nr_pages, unsigned long remap_pfn,
-   unsigned long *released, unsigned long *remapped)
+   unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
+   unsigned long remap_pfn, unsigned long *released,
+   unsigned long *remapped)
 {
unsigned long pfn;
unsigned long i = 0;
@@ -379,8 +381,7 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
if (cur_pfn + size  nr_pages)
size = nr_pages - cur_pfn;
 
-   remap_range_size = xen_find_pfn_range(list, map_size,
- remap_pfn);
+   remap_range_size = xen_find_pfn_range(remap_pfn);
if (!remap_range_size) {
pr_warning(Unable to find available pfn range, not 
remapping identity pages\n);
xen_set_identity_and_release_chunk(cur_pfn,
@@ -411,13 +412,12 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
return remap_pfn;
 }
 
-static void __init xen_set_identity_and_remap(
-   const struct e820entry *list, size_t map_size, unsigned long nr_pages,
-   unsigned long *released, unsigned long *remapped)
+static void __init xen_set_identity_and_remap(unsigned long nr_pages,
+   unsigned long *released, unsigned long *remapped)
 {
phys_addr_t start = 0;
unsigned long last_pfn = nr_pages;
-   const struct e820entry *entry;
+   const struct e820entry *entry = xen_e820_map;
unsigned long num_released = 0;
unsigned long num_remapped = 0;
int i;
@@ -433,9 +433,9 @@ static void __init xen_set_identity_and_remap(
 * example) the DMI tables in a reserved region that begins on
 * a non-page boundary.
 */
-   for (i = 0, entry = list; i  map_size; i++, entry++) {
+   for (i = 0; i  xen_e820_map_entries; i++, entry++) {
phys_addr_t end = entry-addr + entry-size;
-   if (entry-type == E820_RAM || i == map_size - 1) {
+   if (entry-type == E820_RAM || i == xen_e820_map_entries - 1) {
unsigned long start_pfn = PFN_DOWN(start);
unsigned long end_pfn = PFN_UP(end);
 
@@ -444,9 +444,9 @@ static void __init xen_set_identity_and_remap(
 
if (start_pfn  end_pfn)
last_pfn = xen_set_identity_and_remap_chunk(
-   list, map_size, start_pfn,
-   end_pfn, nr_pages, last_pfn,
-   num_released, num_remapped);
+   start_pfn, end_pfn, nr_pages,
+   last_pfn, num_released,
+

Re: [Xen-devel] [PATCH V3 3/6] libxl: add pvusb API

2015-04-19 Thread Juergen Gross

On 04/19/2015 05:50 AM, Chunyan Liu wrote:

Add pvusb APIs, including:
  - attach/detach (create/destroy) virtual usb controller.
  - attach/detach usb device
  - list usb controller and usb devices
  - some other helper functions

Signed-off-by: Chunyan Liu cy...@suse.com
Signed-off-by: Simon Cao caobosi...@gmail.com
---
Changes to v2:
   * remove qemu emulated usb related definitions, keep the work pure pvusb.
 In last patch, will do all refactor work to unify pvusb and qemu emulated
 usb.
   * use bus.addr as user interface instead of busid to do usb-attach|detach
   * remove usb-assignable-list APIs and some other unnecessary APIs
   * reuse libxl_read_file_contents function instead of another new function
 to handle getting sysfs file content
   * fix build on different platforms as pci does
   * fix many coding style problems
   * address other comments in last version
   * adjust codes to let it look better

  tools/libxl/Makefile |2 +-
  tools/libxl/libxl.c  |2 +
  tools/libxl/libxl.h  |   45 ++
  tools/libxl/libxl_internal.h |   11 +-
  tools/libxl/libxl_osdeps.h   |   13 +
  tools/libxl/libxl_pvusb.c| 1201 ++
  tools/libxl/libxl_types.idl  |   41 ++
  tools/libxl/libxl_types_internal.idl |1 +
  8 files changed, 1314 insertions(+), 2 deletions(-)
  create mode 100644 tools/libxl/libxl_pvusb.c


...

diff --git a/tools/libxl/libxl_pvusb.c b/tools/libxl/libxl_pvusb.c
new file mode 100644
index 000..4e4975a
--- /dev/null
+++ b/tools/libxl/libxl_pvusb.c

...

+static int libxl__usbctrl_add_xenstore(libxl__gc *gc, uint32_t domid,
+   libxl_device_usbctrl *usbctrl)
+{
+flexarray_t *front;
+flexarray_t *back;
+libxl__device *device;
+xs_transaction_t t = XBT_NULL;
+int rc = 0;
+libxl_domain_config d_config;
+libxl_device_usbctrl usbctrl_saved;
+libxl__domain_userdata_lock *lock = NULL;
+
+libxl_domain_config_init(d_config);
+libxl_device_usbctrl_init(usbctrl_saved);
+libxl_device_usbctrl_copy(CTX, usbctrl_saved, usbctrl);
+
+GCNEW(device);
+libxl__device_from_usbctrl(gc, domid, usbctrl, device);
+
+front = flexarray_make(gc, 4, 1);
+back = flexarray_make(gc, 12, 1);
+
+flexarray_append_pair(back, frontend-id, GCSPRINTF(%d, domid));
+flexarray_append_pair(back, online, 1);
+flexarray_append_pair(back, state, 1);
+flexarray_append_pair(back, usb-ver, GCSPRINTF(%d, usbctrl-version));
+flexarray_append_pair(back, num-ports, GCSPRINTF(%d, usbctrl-ports));
+flexarray_append_pair(front, backend-id, GCSPRINTF(%d, 
usbctrl-backend_domid));
+flexarray_append_pair(front, state, 1);
+
+lock = libxl__lock_domain_userdata(gc, domid);
+if (!lock) {
+rc = ERROR_LOCK_FAIL;
+goto out;
+}
+
+rc = libxl__get_domain_configuration(gc, domid, d_config);
+if (rc) goto out;
+
+DEVICE_ADD(usbctrl, usbctrls, domid, usbctrl_saved, COMPARE_USBCTRL, 
d_config);
+
+for (;;) {
+rc = libxl__xs_transaction_start(gc, t);
+if (rc) goto out;
+
+rc = libxl__device_exists(gc, t, device);
+if (rc  0) goto out;
+if (rc == 1) {
+/* already exists in xenstore */
+LOG(ERROR, device already exists in xenstore);
+rc = ERROR_DEVICE_EXISTS;
+goto out;
+}
+
+rc = libxl__set_domain_configuration(gc, domid, d_config);
+if (rc) goto out;
+
+libxl__device_generic_add(gc, t, device,
+  libxl__xs_kvs_of_flexarray(gc, back,
+ back-count),
+  libxl__xs_kvs_of_flexarray(gc, front,
+ front-count),
+  NULL);
+libxl__usbport_add_xenstore(gc, t, domid, usbctrl);


Still no rc check.


+rc = libxl__xs_transaction_commit(gc, t);
+if (!rc) break;
+if (rc  0) goto out;
+}
+
+out:
+if (lock) libxl__unlock_domain_userdata(lock);
+libxl_device_usbctrl_dispose(usbctrl_saved);
+libxl_domain_config_dispose(d_config);
+return rc;
+}

...

+static int
+libxl__device_usbctrl_remove_common(libxl_ctx *ctx, uint32_t domid,
+libxl_device_usbctrl *usbctrl,
+const libxl_asyncop_how *ao_how,
+int force)
+{
+AO_CREATE(ctx, domid, ao_how);
+libxl__device *device;
+libxl__ao_device *aodev;
+libxl_device_usbctrl *usbctrls = NULL;
+libxl_device_usbctrl *usbctrl_find = NULL;
+int numctrl = 0;
+libxl_device_usb *usbs = NULL;
+int numusb = 0;
+int i, rc;
+
+assert(usbctrl-devid != -1);
+
+usbctrls = libxl_device_usbctrl_list(ctx, domid, numctrl);
+if 

[Xen-devel] [Patch V3 08/15] xen: find unused contiguous memory area

2015-04-19 Thread Juergen Gross
For being able to relocate pre-allocated data areas like initrd or
p2m list it is mandatory to find a contiguous memory area which is
not yet in use and doesn't conflict with the memory map we want to
be in effect.

In case such an area is found reserve it at once as this will be
required to be done in any case.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/setup.c   | 34 ++
 arch/x86/xen/xen-ops.h |  1 +
 2 files changed, 35 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 99ef82c..973d294 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -597,6 +597,40 @@ bool __init xen_is_e820_reserved(phys_addr_t start, 
phys_addr_t size)
 }
 
 /*
+ * Find a free area in physical memory not yet reserved and compliant with
+ * E820 map.
+ * Used to relocate pre-allocated areas like initrd or p2m list which are in
+ * conflict with the to be used E820 map.
+ * In case no area is found, return 0. Otherwise return the physical address
+ * of the area which is already reserved for convenience.
+ */
+phys_addr_t __init xen_find_free_area(phys_addr_t size)
+{
+   unsigned mapcnt;
+   phys_addr_t addr, start;
+   struct e820entry *entry = xen_e820_map;
+
+   for (mapcnt = 0; mapcnt  xen_e820_map_entries; mapcnt++, entry++) {
+   if (entry-type != E820_RAM || entry-size  size)
+   continue;
+   start = entry-addr;
+   for (addr = start; addr  start + size; addr += PAGE_SIZE) {
+   if (!memblock_is_reserved(addr))
+   continue;
+   start = addr + PAGE_SIZE;
+   if (start + size  entry-addr + entry-size)
+   break;
+   }
+   if (addr = start + size) {
+   memblock_reserve(start, size);
+   return start;
+   }
+   }
+
+   return 0;
+}
+
+/*
  * Reserve Xen mfn_list.
  * See comment above struct start_info in xen/interface/xen.h
  * We tried to make the the memblock_reserve more selective so
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index c1385b8..3f1669c 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -43,6 +43,7 @@ bool __init xen_is_e820_reserved(phys_addr_t start, 
phys_addr_t size);
 unsigned long __ref xen_chk_extra_mem(unsigned long pfn);
 void __init xen_inv_extra_mem(void);
 void __init xen_remap_memory(void);
+phys_addr_t __init xen_find_free_area(phys_addr_t size);
 char * __init xen_memory_setup(void);
 char * xen_auto_xlated_memory_setup(void);
 void __init xen_arch_setup(void);
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 03/15] xen: don't build mfn tree if tools don't need it

2015-04-19 Thread Juergen Gross
In case the Xen tools indicate they don't need the p2m 3 level tree
as they support the virtual mapped linear p2m list, just omit building
the tree.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/p2m.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 703f803..6f80cd3 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -198,7 +198,8 @@ void __ref xen_build_mfn_list_list(void)
unsigned int level, topidx, mididx;
unsigned long *mid_mfn_p;
 
-   if (xen_feature(XENFEAT_auto_translated_physmap))
+   if (xen_feature(XENFEAT_auto_translated_physmap) ||
+   xen_start_info-flags  SIF_VIRT_P2M_4TOOLS)
return;
 
/* Pre-initialize p2m_top_mfn to be completely missing */
@@ -259,8 +260,11 @@ void xen_setup_mfn_list_list(void)
 
BUG_ON(HYPERVISOR_shared_info == xen_dummy_shared_info);
 
-   HYPERVISOR_shared_info-arch.pfn_to_mfn_frame_list_list =
-   virt_to_mfn(p2m_top_mfn);
+   if (xen_start_info-flags  SIF_VIRT_P2M_4TOOLS)
+   HYPERVISOR_shared_info-arch.pfn_to_mfn_frame_list_list = ~0UL;
+   else
+   HYPERVISOR_shared_info-arch.pfn_to_mfn_frame_list_list =
+   virt_to_mfn(p2m_top_mfn);
HYPERVISOR_shared_info-arch.max_pfn = xen_max_p2m_pfn;
HYPERVISOR_shared_info-arch.p2m_generation = 0;
HYPERVISOR_shared_info-arch.p2m_vaddr = (unsigned long)xen_p2m_addr;
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 11/15] xen: check for initrd conflicting with e820 map

2015-04-19 Thread Juergen Gross
Check whether the initrd is placed at a location which is conflicting
with the target E820 map. If this is the case relocate it to a new
area unused up to now and compliant to the E820 map.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/setup.c | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 3fca9c1..0d7f881 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -632,6 +632,36 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size)
 }
 
 /*
+ * Like memcpy, but with physical addresses for dest and src.
+ */
+static void __init xen_phys_memcpy(phys_addr_t dest, phys_addr_t src,
+  phys_addr_t n)
+{
+   phys_addr_t dest_off, src_off, dest_len, src_len, len;
+   void *from, *to;
+
+   while (n) {
+   dest_off = dest  ~PAGE_MASK;
+   src_off = src  ~PAGE_MASK;
+   dest_len = n;
+   if (dest_len  (NR_FIX_BTMAPS  PAGE_SHIFT) - dest_off)
+   dest_len = (NR_FIX_BTMAPS  PAGE_SHIFT) - dest_off;
+   src_len = n;
+   if (src_len  (NR_FIX_BTMAPS  PAGE_SHIFT) - src_off)
+   src_len = (NR_FIX_BTMAPS  PAGE_SHIFT) - src_off;
+   len = min(dest_len, src_len);
+   to = early_memremap(dest - dest_off, dest_len + dest_off);
+   from = early_memremap(src - src_off, src_len + src_off);
+   memcpy(to, from, len);
+   early_memunmap(to, dest_len + dest_off);
+   early_memunmap(from, src_len + src_off);
+   n -= len;
+   dest += len;
+   src += len;
+   }
+}
+
+/*
  * Reserve Xen mfn_list.
  * See comment above struct start_info in xen/interface/xen.h
  * We tried to make the the memblock_reserve more selective so
@@ -810,6 +840,27 @@ char * __init xen_memory_setup(void)
 
xen_reserve_xen_mfnlist();
 
+   /* Check for a conflict of the initrd with the target E820 map. */
+   if (xen_is_e820_reserved(boot_params.hdr.ramdisk_image,
+boot_params.hdr.ramdisk_size)) {
+   phys_addr_t new_area, start, size;
+
+   new_area = xen_find_free_area(boot_params.hdr.ramdisk_size);
+   if (!new_area) {
+   xen_raw_console_write(Can't find new memory area for 
initrd needed due to E820 map conflict\n);
+   BUG();
+   }
+
+   start = boot_params.hdr.ramdisk_image;
+   size = boot_params.hdr.ramdisk_size;
+   xen_phys_memcpy(new_area, start, size);
+   pr_info(initrd moved from [mem %#010llx-%#010llx] to [mem 
%#010llx-%#010llx]\n,
+   start, start + size, new_area, new_area + size);
+   memblock_free(start, size);
+   boot_params.hdr.ramdisk_image = new_area;
+   boot_params.ext_ramdisk_image = new_area  32;
+   }
+
/*
 * Set identity map on non-RAM pages and prepare remapping the
 * underlying RAM.
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 06/15] xen: split counting of extra memory pages from remapping

2015-04-19 Thread Juergen Gross
Memory pages in the initial memory setup done by the Xen hypervisor
conflicting with the target E820 map are remapped. In order to do this
those pages are counted and remapped in xen_set_identity_and_remap().

Split the counting from the remapping operation to be able to setup
the needed memory sizes in time but doing the remap operation at a
later time. This enables us to simplify the interface to
xen_set_identity_and_remap() as the number of remapped and released
pages is no longer needed here.

Finally move the remapping further down to prepare relocating
conflicting memory contents before the memory might be clobbered by
xen_set_identity_and_remap(). This requires to not destroy the Xen
E820 map when the one for the system is being constructed.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 arch/x86/xen/setup.c | 98 +++-
 1 file changed, 58 insertions(+), 40 deletions(-)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index ab6c36e..87251b4 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -223,7 +223,7 @@ static int __init xen_free_mfn(unsigned long mfn)
  * as a fallback if the remapping fails.
  */
 static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,
-   unsigned long end_pfn, unsigned long nr_pages, unsigned long *released)
+   unsigned long end_pfn, unsigned long nr_pages)
 {
unsigned long pfn, end;
int ret;
@@ -243,7 +243,7 @@ static void __init 
xen_set_identity_and_release_chunk(unsigned long start_pfn,
WARN(ret != 1, Failed to release pfn %lx err=%d\n, pfn, ret);
 
if (ret == 1) {
-   (*released)++;
+   xen_released_pages++;
if (!__set_phys_to_machine(pfn, INVALID_P2M_ENTRY))
break;
} else
@@ -359,8 +359,7 @@ static void __init xen_do_set_identity_and_remap_chunk(
  */
 static unsigned long __init xen_set_identity_and_remap_chunk(
unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
-   unsigned long remap_pfn, unsigned long *released,
-   unsigned long *remapped)
+   unsigned long remap_pfn)
 {
unsigned long pfn;
unsigned long i = 0;
@@ -385,7 +384,7 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
if (!remap_range_size) {
pr_warning(Unable to find available pfn range, not 
remapping identity pages\n);
xen_set_identity_and_release_chunk(cur_pfn,
-   cur_pfn + left, nr_pages, released);
+   cur_pfn + left, nr_pages);
break;
}
/* Adjust size to fit in current e820 RAM region */
@@ -397,7 +396,6 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
/* Update variables to reflect new mappings. */
i += size;
remap_pfn += size;
-   *remapped += size;
}
 
/*
@@ -412,14 +410,11 @@ static unsigned long __init 
xen_set_identity_and_remap_chunk(
return remap_pfn;
 }
 
-static void __init xen_set_identity_and_remap(unsigned long nr_pages,
-   unsigned long *released, unsigned long *remapped)
+static void __init xen_set_identity_and_remap(unsigned long nr_pages)
 {
phys_addr_t start = 0;
unsigned long last_pfn = nr_pages;
const struct e820entry *entry = xen_e820_map;
-   unsigned long num_released = 0;
-   unsigned long num_remapped = 0;
int i;
 
/*
@@ -445,16 +440,12 @@ static void __init xen_set_identity_and_remap(unsigned 
long nr_pages,
if (start_pfn  end_pfn)
last_pfn = xen_set_identity_and_remap_chunk(
start_pfn, end_pfn, nr_pages,
-   last_pfn, num_released,
-   num_remapped);
+   last_pfn);
start = end;
}
}
 
-   *released = num_released;
-   *remapped = num_remapped;
-
-   pr_info(Released %ld page(s)\n, num_released);
+   pr_info(Released %ld page(s)\n, xen_released_pages);
 }
 
 /*
@@ -560,6 +551,28 @@ static void __init xen_ignore_unusable(void)
}
 }
 
+static unsigned long __init xen_count_remap_pages(unsigned long max_pfn)
+{
+   unsigned long extra = 0;
+   const struct e820entry *entry = xen_e820_map;
+   int i;
+
+   for (i = 0; i  xen_e820_map_entries; i++, entry++) {
+   unsigned long start_pfn = PFN_DOWN(entry-addr);
+   unsigned long end_pfn = PFN_UP(entry-addr + entry-size);
+
+   if (start_pfn = max_pfn)
+   

[Xen-devel] [Patch V3 00/15] xen: support pv-domains larger than 512GB

2015-04-19 Thread Juergen Gross
Support 64 bit pv-domains with more than 512GB of memory.

Tested with 64 bit dom0 on machines with 8GB and 1TB and 32 bit dom0 on a
8GB machine. Conflicts between E820 map and different hypervisor populated
memory areas have been tested via a fake E820 map reserved area on the
8GB machine.

Changes in V3:
- rename xen_chk_e820_reserved() to xen_is_e820_reserved() as requested by
  David Vrabel
- add __initdata tag to global variables in patch 10
- move initrd conflict checking after reserving p2m memory (patch 11)

Changes in V2:
- some clarifications and better explanations in commit messages 
- add header changes of include/xen/interface/xen.h (patch 01)
- add wmb() when incrementing p2m_generation (patch 02)
- add new patch 03 (don't build mfn tree if tools don't need it)
- add new patch 06 (split counting of extra memory pages from remapping)
- add new patch 07 (check memory area against e820 map)
- replace early_iounmap() with early_memunmap() (patch 07-patch 08)
- rework patch 09 (check for kernel memory conflicting with memory layout)
- rework patch 10 (check pre-allocated page tables for conflict with memory map)
- combine old patches 08 and 11 into patch 11
- add new patch 12 (provide early_memremap_ro to establish read-only mapping)
- rework old patch 12 (if p2m list located in to be remapped region delay
  remapping) to copy p2m list in case of a conflict (now patch 13)
- correct Kconfig dependency (patch 13-14)
- don't limit dom0 to 512GB (patch 13-14)
- modify parameter parsing to work in very early boot (patch 13-14)
- add new patch 15 to do some cleanup
- remove old patch 05 (simplify xen_set_identity_and_remap() by using global
  variables)
- remove old patch 08 (detect pre-allocated memory interfering with e820 map)


Juergen Gross (15):
  xen: sync with xen headers
  xen: save linear p2m list address in shared info structure
  xen: don't build mfn tree if tools don't need it
  xen: eliminate scalability issues from initial mapping setup
  xen: move static e820 map to global scope
  xen: split counting of extra memory pages from remapping
  xen: check memory area against e820 map
  xen: find unused contiguous memory area
  xen: check for kernel memory conflicting with memory layout
  xen: check pre-allocated page tables for conflict with memory map
  xen: check for initrd conflicting with e820 map
  mm: provide early_memremap_ro to establish read-only mapping
  xen: move p2m list if conflicting with e820 map
  xen: allow more than 512 GB of RAM for 64 bit pv-domains
  xen: remove no longer needed p2m.h

 Documentation/kernel-parameters.txt  |   7 +
 arch/x86/include/asm/xen/interface.h |  96 +++-
 arch/x86/include/asm/xen/page.h  |   8 +-
 arch/x86/xen/Kconfig |  20 +-
 arch/x86/xen/mmu.c   | 367 +--
 arch/x86/xen/p2m.c   |  43 +++-
 arch/x86/xen/p2m.h   |  15 --
 arch/x86/xen/setup.c | 414 ++-
 arch/x86/xen/xen-head.S  |   2 +
 arch/x86/xen/xen-ops.h   |   6 +
 include/asm-generic/early_ioremap.h  |   2 +
 include/asm-generic/fixmap.h |   3 +
 include/xen/interface/xen.h  |  10 +-
 mm/early_ioremap.c   |  11 +
 14 files changed, 822 insertions(+), 182 deletions(-)
 delete mode 100644 arch/x86/xen/p2m.h

-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 09/15] xen: check for kernel memory conflicting with memory layout

2015-04-19 Thread Juergen Gross
Checks whether the pre-allocated memory of the loaded kernel is in
conflict with the target memory map. If this is the case, just panic
instead of run into problems later, as there is nothing we can do
to repair this situation.

Signed-off-by: Juergen Gross jgr...@suse.com
Reviewed-by: David Vrabel david.vra...@citrix.com
---
 arch/x86/xen/setup.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 973d294..9bd3f35 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -27,6 +27,7 @@
 #include xen/interface/memory.h
 #include xen/interface/physdev.h
 #include xen/features.h
+#include xen/hvc-console.h
 #include xen-ops.h
 #include vdso.h
 #include p2m.h
@@ -790,6 +791,17 @@ char * __init xen_memory_setup(void)
 
sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), e820.nr_map);
 
+   /*
+* Check whether the kernel itself conflicts with the target E820 map.
+* Failing now is better than running into weird problems later due
+* to relocating (and even reusing) pages with kernel text or data.
+*/
+   if (xen_is_e820_reserved(__pa_symbol(_text),
+   __pa_symbol(__bss_stop) - __pa_symbol(_text))) {
+   xen_raw_console_write(Xen hypervisor allocated kernel memory 
conflicts with E820 map\n);
+   BUG();
+   }
+
xen_reserve_xen_mfnlist();
 
/*
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [Patch V3 13/15] xen: move p2m list if conflicting with e820 map

2015-04-19 Thread Juergen Gross
Check whether the hypervisor supplied p2m list is placed at a location
which is conflicting with the target E820 map. If this is the case
relocate it to a new area unused up to now and compliant to the E820
map.

As the p2m list might by huge (up to several GB) and is required to be
mapped virtually, set up a temporary mapping for the copied list.

For pvh domains just delete the p2m related information from start
info instead of reserving the p2m memory, as we don't need it at all.

For 32 bit kernels adjust the memblock_reserve() parameters in order
to cover the page tables only. This requires to memblock_reserve() the
start_info page on it's own.

Signed-off-by: Juergen Gross jgr...@suse.com
---
 arch/x86/xen/mmu.c | 232 ++---
 arch/x86/xen/setup.c   |  51 +--
 arch/x86/xen/xen-ops.h |   3 +
 3 files changed, 247 insertions(+), 39 deletions(-)

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 1982617..9694d79 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1094,6 +1094,16 @@ static void xen_exit_mmap(struct mm_struct *mm)
 
 static void xen_post_allocator_init(void);
 
+static void __init pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
+{
+   struct mmuext_op op;
+
+   op.cmd = cmd;
+   op.arg1.mfn = pfn_to_mfn(pfn);
+   if (HYPERVISOR_mmuext_op(op, 1, NULL, DOMID_SELF))
+   BUG();
+}
+
 #ifdef CONFIG_X86_64
 static void __init xen_cleanhighmap(unsigned long vaddr,
unsigned long vaddr_end)
@@ -1129,10 +1139,12 @@ static void __init xen_free_ro_pages(unsigned long 
paddr, unsigned long size)
memblock_free(paddr, size);
 }
 
-static void __init xen_cleanmfnmap_free_pgtbl(void *pgtbl)
+static void __init xen_cleanmfnmap_free_pgtbl(void *pgtbl, bool unpin)
 {
unsigned long pa = __pa(pgtbl)  PHYSICAL_PAGE_MASK;
 
+   if (unpin)
+   pin_pagetable_pfn(MMUEXT_UNPIN_TABLE, PFN_DOWN(pa));
ClearPagePinned(virt_to_page(__va(pa)));
xen_free_ro_pages(pa, PAGE_SIZE);
 }
@@ -1151,7 +1163,9 @@ static void __init xen_cleanmfnmap(unsigned long vaddr)
pmd_t *pmd;
pte_t *pte;
unsigned int i;
+   bool unpin;
 
+   unpin = (vaddr == 2 * PGDIR_SIZE);
set_pgd(pgd, __pgd(0));
do {
pud = pud_page + pud_index(va);
@@ -1168,22 +1182,24 @@ static void __init xen_cleanmfnmap(unsigned long vaddr)
xen_free_ro_pages(pa, PMD_SIZE);
} else if (!pmd_none(*pmd)) {
pte = pte_offset_kernel(pmd, va);
+   set_pmd(pmd, __pmd(0));
for (i = 0; i  PTRS_PER_PTE; ++i) {
if (pte_none(pte[i]))
break;
pa = pte_pfn(pte[i])  PAGE_SHIFT;
xen_free_ro_pages(pa, PAGE_SIZE);
}
-   xen_cleanmfnmap_free_pgtbl(pte);
+   xen_cleanmfnmap_free_pgtbl(pte, unpin);
}
va += PMD_SIZE;
if (pmd_index(va))
continue;
-   xen_cleanmfnmap_free_pgtbl(pmd);
+   set_pud(pud, __pud(0));
+   xen_cleanmfnmap_free_pgtbl(pmd, unpin);
}
 
} while (pud_index(va) || pmd_index(va));
-   xen_cleanmfnmap_free_pgtbl(pud_page);
+   xen_cleanmfnmap_free_pgtbl(pud_page, unpin);
 }
 
 static void __init xen_pagetable_p2m_free(void)
@@ -1219,6 +1235,12 @@ static void __init xen_pagetable_p2m_free(void)
} else {
xen_cleanmfnmap(addr);
}
+}
+
+static void __init xen_pagetable_cleanhighmap(void)
+{
+   unsigned long size;
+   unsigned long addr;
 
/* At this stage, cleanup_highmap has already cleaned __ka space
 * from _brk_limit way up to the max_pfn_mapped (which is the end of
@@ -1251,6 +1273,8 @@ static void __init xen_pagetable_p2m_setup(void)
 
 #ifdef CONFIG_X86_64
xen_pagetable_p2m_free();
+
+   xen_pagetable_cleanhighmap();
 #endif
/* And revector! Bye bye old array */
xen_start_info-mfn_list = (unsigned long)xen_p2m_addr;
@@ -1586,15 +1610,6 @@ static void __init xen_set_pte_init(pte_t *ptep, pte_t 
pte)
native_set_pte(ptep, pte);
 }
 
-static void __init pin_pagetable_pfn(unsigned cmd, unsigned long pfn)
-{
-   struct mmuext_op op;
-   op.cmd = cmd;
-   op.arg1.mfn = pfn_to_mfn(pfn);
-   if (HYPERVISOR_mmuext_op(op, 1, NULL, DOMID_SELF))
-   BUG();
-}
-
 /* Early in boot, while setting up the initial pagetable, assume
everything is pinned. */
 static void __init xen_alloc_pte_init(struct mm_struct *mm, unsigned long pfn)
@@