diff --git a/13161_xenapi.patch b/13161_xenapi.patch deleted file mode 100644 index 4d95695..0000000 --- a/13161_xenapi.patch +++ /dev/null @@ -1,34 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1167179881 0 -# Node ID a9a43705f26b0892f722da1b6db8e98db49bad35 -# Parent 6f8d650f3ab1cf23d00baf904abe62fb85b89377 -Fix HVM booting through Xen-API when the kernel is unspecified. - -Signed-off-by: Ewan Mellor - -diff -r 6f8d650f3ab1 -r a9a43705f26b tools/python/xen/xend/XendDomainInfo.py ---- a/tools/python/xen/xend/XendDomainInfo.py Wed Dec 27 00:35:27 2006 +0000 -+++ b/tools/python/xen/xend/XendDomainInfo.py Wed Dec 27 00:38:01 2006 +0000 -@@ -1555,6 +1555,8 @@ class XendDomainInfo: - if boot: - # HVM booting. - self.info['image']['type'] = 'hvm' -+ if not 'devices' in self.info['image']: -+ self.info['image']['devices'] = {} - self.info['image']['devices']['boot'] = boot - elif not blexec and kernel: - # Boot from dom0. Nothing left to do -- the kernel and ramdisk -diff -r 6f8d650f3ab1 -r a9a43705f26b tools/python/xen/xend/image.py ---- a/tools/python/xen/xend/image.py Wed Dec 27 00:35:27 2006 +0000 -+++ b/tools/python/xen/xend/image.py Wed Dec 27 00:38:01 2006 +0000 -@@ -311,6 +311,9 @@ class HVMImageHandler(ImageHandler): - - def configure(self, vmConfig, imageConfig, deviceConfig): - ImageHandler.configure(self, vmConfig, imageConfig, deviceConfig) -+ -+ if not self.kernel: -+ self.kernel = '/usr/lib/xen/boot/hvmloader' - - info = xc.xeninfo() - if 'hvm' not in info['xen_caps']: diff --git a/13201_xenapi.patch b/13201_xenapi.patch deleted file mode 100644 index 879d4e1..0000000 --- a/13201_xenapi.patch +++ /dev/null @@ -1,53 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1167743041 0 -# Node ID 7cd6c032689eca5509a1b8cffaaa50b3f45f5765 -# Parent 711c31232d71608fe4ea9f4f22ca2620d3faf8ff -Don't lose the image settings when rebooting domains. This fixes recent HVM -reboot problems -- we were passing 0 to shadow_mem_control, because Xend was -treating the domain as PV. - -Signed-off-by: Ewan Mellor - -diff -r 711c31232d71 -r 7cd6c032689e tools/python/xen/xend/XendConfig.py ---- a/tools/python/xen/xend/XendConfig.py Tue Jan 02 10:57:50 2007 +0000 -+++ b/tools/python/xen/xend/XendConfig.py Tue Jan 02 13:04:01 2007 +0000 -@@ -299,7 +299,7 @@ class XendConfig(dict): - self._sxp_to_xapi_unsupported(sxp_obj) - elif xapi: - self.update_with_xenapi_config(xapi) -- self._add_xapi_unsupported() -+ self._add_xapi_unsupported(xapi) - elif dominfo: - # output from xc.domain_getinfo - self._dominfo_to_xapi(dominfo) -@@ -728,19 +728,22 @@ class XendConfig(dict): - _set_cfg_if_exists('up_time') - _set_cfg_if_exists('status') # TODO, deprecated - -- def _add_xapi_unsupported(self): -+ def _add_xapi_unsupported(self, xapi_dict): - """Updates the configuration object with entries that are not - officially supported by the Xen API but is required for - the rest of Xend to function. - """ - - # populate image -- hvm = self['HVM_boot'] != '' -- self['image']['type'] = hvm and 'hvm' or 'linux' -- if hvm: -- self['image']['hvm'] = {} -- for xapi, cfgapi in XENAPI_HVM_CFG.items(): -- self['image']['hvm'][cfgapi] = self[xapi] -+ if 'image' in xapi_dict: -+ self['image'].update(xapi_dict['image']) -+ else: -+ hvm = self['HVM_boot'] != '' -+ self['image']['type'] = hvm and 'hvm' or 'linux' -+ if hvm: -+ self['image']['hvm'] = {} -+ for xapi, cfgapi in XENAPI_HVM_CFG.items(): -+ self['image']['hvm'][cfgapi] = self[xapi] - - - def _get_old_state_string(self): diff --git a/13226_xenapi.patch b/13226_xenapi.patch deleted file mode 100644 index 32d7aa3..0000000 --- a/13226_xenapi.patch +++ /dev/null @@ -1,17 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1167928289 0 -# Node ID b2ea5ae25a2665d927501a5ebaf4ff38bfd086fc -# Parent 292edc60d2603f744b5408cbf7795365fa8598ce -[XEND] Add VBD_MODE enum from XenAPI. - -Signed-off-by: Alastair Tse - -diff -r 292edc60d260 -r b2ea5ae25a26 tools/python/xen/xend/XendAPIConstants.py ---- a/tools/python/xen/xend/XendAPIConstants.py Thu Jan 04 16:30:20 2007 +0000 -+++ b/tools/python/xen/xend/XendAPIConstants.py Thu Jan 04 16:31:29 2007 +0000 -@@ -73,3 +73,4 @@ XEN_API_VBD_MODE = ['RO', 'RW'] - XEN_API_VBD_MODE = ['RO', 'RW'] - XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral'] - XEN_API_DRIVER_TYPE = ['ioemu', 'paravirtualised'] -+XEN_API_VBD_TYPE = ['CD', 'Disk'] diff --git a/13235_xenapi.patch b/13235_xenapi.patch deleted file mode 100644 index 0a34203..0000000 --- a/13235_xenapi.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1168000166 0 -# Node ID 36e00d04278d4fbdb0b034355a0e683372211752 -# Parent 68f0d46de55ab1e158c19e7e5890902e05d6f623 -Added permissiveness for floats. - -Signed-off-by: Ewan Mellor - -diff -r 68f0d46de55a -r 36e00d04278d tools/libxen/src/xen_common.c ---- a/tools/libxen/src/xen_common.c Fri Jan 05 11:03:16 2007 +0000 -+++ b/tools/libxen/src/xen_common.c Fri Jan 05 12:29:26 2007 +0000 -@@ -557,8 +557,14 @@ static void parse_into(xen_session *s, x - xmlChar *string = string_from_value(value_node, "double"); - if (string == NULL) - { -+#if PERMISSIVE -+ fprintf(stderr, -+ "Expected a Float from the server, but didn't get one\n"); -+ ((double *)value)[slot] = 0.0; -+#else - server_error( - s, "Expected a Float from the server, but didn't get one"); -+#endif - } - else - { diff --git a/13236_xenapi.patch b/13236_xenapi.patch deleted file mode 100644 index 1769e9a..0000000 --- a/13236_xenapi.patch +++ /dev/null @@ -1,72 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1168000232 0 -# Node ID bb8ae710d829d5a7805c5588d8ded2ea393686cf -# Parent 36e00d04278d4fbdb0b034355a0e683372211752 -Treat tags with no type tag inside as if they were strings (as required -by the XML-RPC spec). - -Signed-off-by: Ewan Mellor - -diff -r 36e00d04278d -r bb8ae710d829 tools/libxen/src/xen_common.c ---- a/tools/libxen/src/xen_common.c Fri Jan 05 12:29:26 2007 +0000 -+++ b/tools/libxen/src/xen_common.c Fri Jan 05 12:30:32 2007 +0000 -@@ -373,11 +373,18 @@ static void server_error_2(xen_session * - } - - --static bool is_container_node(xmlNode *n, char *type) -+static bool is_node(xmlNode *n, char *type) - { - return - n->type == XML_ELEMENT_NODE && -- 0 == strcmp((char *)n->name, type) && -+ 0 == strcmp((char *)n->name, type); -+} -+ -+ -+static bool is_container_node(xmlNode *n, char *type) -+{ -+ return -+ is_node(n, type) && - n->children != NULL && - n->children == n->last && - n->children->type == XML_ELEMENT_NODE; -@@ -390,13 +397,30 @@ static bool is_container_node(xmlNode *n - */ - static xmlChar *string_from_value(xmlNode *n, char *type) - { -- return -- is_container_node(n, "value") && -- 0 == strcmp((char *)n->children->name, type) ? -- (n->children->children == NULL ? -- xmlStrdup(BAD_CAST("")) : -- xmlNodeGetContent(n->children->children)) : -- NULL; -+ /* -+ XYZ is normal, but the XML-RPC spec also -+ allows XYZ where XYZ is to be interpreted as a string. -+ */ -+ -+ if (is_container_node(n, "value") && -+ 0 == strcmp((char *)n->children->name, type)) -+ { -+ return -+ n->children->children == NULL ? -+ xmlStrdup(BAD_CAST("")) : -+ xmlNodeGetContent(n->children->children); -+ } -+ else if (0 == strcmp(type, "string") && is_node(n, "value")) -+ { -+ return -+ n->children == NULL ? -+ xmlStrdup(BAD_CAST("")) : -+ xmlNodeGetContent(n->children); -+ } -+ else -+ { -+ return NULL; -+ } - } - - diff --git a/13574-win2k-mouse.patch b/13574-win2k-mouse.patch deleted file mode 100644 index b54d034..0000000 --- a/13574-win2k-mouse.patch +++ /dev/null @@ -1,51 +0,0 @@ -# HG changeset patch -# User kfraser@localhost.localdomain -# Date 1169635472 0 -# Node ID b064775fba7d838c99bcf11ca4fec6127e0e8792 -# Parent c9ac0bace498d1c25f07df95b88d8f8e89168514 -[QEMU] Clear TD status field explicitly when it's fetched. - -In current Qemu-dm, UHC will set some status bits of TD in status -updating stage, but never process the status bit if relevant condition -does not occur, leaving it as it is. When a TD is fetched with some -status bits are set to 1, it will return to Guest OS with these bits -set to 1 even this TD is executed successfully. Some Windows OS, -e.g. Windows 2000, will check status bits of TD in UHC interrupt -routine, treat it as a unsuccessful one if some status bits are set to -1 and discard the data. Other Windows OS just check USBSTS of UHC, -ignoring status field of TD unless the value of USBSTS indicates -occurrence of error. - -With this patch, USB mouse/tablet in Windows 2000 works correctly. - -Signed-off-by: Xinmei Huang - -Index: xen-3.0.4-testing/tools/ioemu/hw/usb-uhci.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/ioemu/hw/usb-uhci.c -+++ xen-3.0.4-testing/tools/ioemu/hw/usb-uhci.c -@@ -43,9 +43,15 @@ - #define TD_CTRL_IOC (1 << 24) - #define TD_CTRL_ACTIVE (1 << 23) - #define TD_CTRL_STALL (1 << 22) -+#define TD_CTRL_BUFFER (1 << 21) - #define TD_CTRL_BABBLE (1 << 20) - #define TD_CTRL_NAK (1 << 19) - #define TD_CTRL_TIMEOUT (1 << 18) -+#define TD_CTRL_BITSTUFF \ -+ (1 << 17) -+#define TD_CTRL_MASK \ -+ (TD_CTRL_BITSTUFF | TD_CTRL_TIMEOUT | TD_CTRL_NAK \ -+ | TD_CTRL_BABBLE | TD_CTRL_BUFFER | TD_CTRL_STALL) - - #define UHCI_PORT_RESET (1 << 9) - #define UHCI_PORT_LSDA (1 << 8) -@@ -428,6 +434,8 @@ static int uhci_handle_td(UHCIState *s, - ret = 1; - goto out; - } -+ /* Clear TD's status field explicitly */ -+ td->ctrl = td->ctrl & (~TD_CTRL_MASK); - - /* TD is active */ - max_len = ((td->token >> 21) + 1) & 0x7ff; diff --git a/13577_xenapi.patch b/13577_xenapi.patch deleted file mode 100644 index d2bab76..0000000 --- a/13577_xenapi.patch +++ /dev/null @@ -1,52 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1169640474 0 -# Node ID 4f5772324e679e9794ccd72848023c081d7300da -# Parent 8331aca2f29ca29704f4bafabe0e542f312d6950 -[XEND] Strip suffix from device name and add support for 'VBD.type' - -Signed-off-by: Alastair Tse - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -1040,6 +1040,7 @@ class XendAPI: - 'VDI', - 'device', - 'mode', -+ 'type', - 'driver'] - - VBD_attr_inst = VBD_attr_rw + ['image'] -@@ -1117,6 +1118,11 @@ class XendAPI: - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, - 'driver')) - -+ def VBD_get_type(self, session, vbd_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref, -+ 'type')) -+ - # Xen API: Class VIF - # ---------------------------------------------------------------- - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1988,6 +1988,14 @@ class XendDomainInfo: - if dev_class == 'vbd': - config['VDI'] = config.get('VDI', '') - config['device'] = config.get('dev', '') -+ if ':' in config['device']: -+ vbd_name, vbd_type = config['device'].split(':', 1) -+ config['device'] = vbd_name -+ if vbd_type == 'cdrom': -+ config['type'] = XEN_API_VBD_TYPE[0] -+ else: -+ config['type'] = XEN_API_VBD_TYPE[1] -+ - config['driver'] = 'paravirtualised' # TODO - config['image'] = config.get('uname', '') - config['io_read_kbs'] = 0.0 diff --git a/13585_xenapi.patch b/13585_xenapi.patch deleted file mode 100644 index d9ad785..0000000 --- a/13585_xenapi.patch +++ /dev/null @@ -1,451 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1169648721 0 -# Node ID bea3d48576c66663e559fbba1bcd9f840a3d1b25 -# Parent 6a54b1d8d1053c4facfef8c3c1da871950a5b29c -[XEND] Add missing Xen API methods - -* Added session.get_all, task.get_by_name_label, - host.get_by_name_label, VM.add_to_otherConfig, - VM.remove_from_otherConfig - -* Added implementations for VM.get_VCPUs_policy, - VM.get_platform_std_vga, VM.get_vm_by_uuid, - VM.get_platform_localtime, VM.get_platform_clock_offset, - VM.get_platform_enable_audio, VM.get_platform_keymap, - VM.get_otherConfig, VM.set_actions_after_shutdown, - VM.set_actions_after_reboot, VM.set_actions_after_suspend, - VM.set_actions_after_crash, VM.set_platform_std_VGA, - VM.set_platform_serial, VM.set_platform_keymap, - VM.set_platform_localtime, VM.set_platform_clock_offset, - VM.set_platform_enable_audio, VM.set_otherConfig, VBD.destroy, - VBD.get_io_read_kbs, VBD.get_io_write_kbs, VBD.get_all, VIF.destroy, - VIF.get_VM, VIF.get_name, VIF.get_MTU, VIF.get_MAC, VIF.get_type, - VIF.get_device, VIF.get_io_read_kbs, VIF.get_io_write_kbs, - VIF.get_all, VTPM.destroy, VTPM.get_all - -* Save devid of a device on creation in XendDomainInfo - -Signed-off-by: Alastair Tse - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -406,7 +406,6 @@ class XendAPI: - return xen_api_error(XEND_ERROR_AUTHENTICATION_FAILED) - session_login_with_password.api = 'session.login_with_password' - -- - # object methods - def session_logout(self, session): - auth_manager().logout(session) -@@ -417,7 +416,9 @@ class XendAPI: - record = {'this_host': XendNode.instance().uuid, - 'this_user': auth_manager().get_user(session)} - return xen_api_success(record) -- -+ def session_get_all(self): -+ return xen_api_error(XEND_ERROR_UNSUPPORTED) -+ - # attributes (ro) - def session_get_this_host(self, session): - return xen_api_success(XendNode.instance().uuid) -@@ -504,6 +505,11 @@ class XendAPI: - return xen_api_success((XendNode.instance().uuid,)) - def host_create(self, session, struct): - return xen_api_error(XEND_ERROR_UNSUPPORTED) -+ def host_get_by_name_label(self, session, name): -+ if XendNode.instance().name == name: -+ return xen_api_success((XendNode.instance().uuid,)) -+ return xen_api_success([]) -+ - - # Xen API: Class Host_CPU - # ---------------------------------------------------------------- -@@ -514,9 +520,6 @@ class XendAPI: - 'utilisation'] - - # attributes -- def host_cpu_get_uuid(self, session, host_cpu_ref): -- uuid = XendNode.instance().get_host_cpu_uuid(host_cpu_ref) -- return xen_api_success(uuid) - def host_cpu_get_host(self, session, host_cpu_ref): - return xen_api_success(XendNode.instance().uuid) - def host_cpu_get_features(self, session, host_cpu_ref): -@@ -752,7 +755,7 @@ class XendAPI: - - def VM_get_VCPUs_policy(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() # need to access scheduler -+ return dom.get_vcpus_policy() - - def VM_get_VCPUs_params(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -@@ -776,7 +779,7 @@ class XendAPI: - - def VM_get_actions_after_suspend(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success(dom.get_on_suspend()) -+ return xen_api_success(dom.get_on_suspend()) - - def VM_get_actions_after_crash(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -@@ -802,31 +805,30 @@ class XendAPI: - - def VM_get_platform_std_VGA(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_std_vga()) - - def VM_get_platform_serial(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_serial()) - - def VM_get_platform_localtime(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_localtime()) - - def VM_get_platform_clock_offset(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_clock_offset()) - - def VM_get_platform_enable_audio(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_enable_audio()) - - def VM_get_platform_keymap(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return xen_api_success(dom.get_platform_keymap()) - - def VM_get_otherConfig(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return self.VM_get('otherConfig', session, vm_ref) - - def VM_set_name_label(self, session, vm_ref, label): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -@@ -870,20 +872,24 @@ class XendAPI: - return xen_api_success_void() - - def VM_set_actions_after_shutdown(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ if action not in XEN_API_ON_NORMAL_EXIST: -+ return xen_api_error(['VM_ON_NORMAL_EXIT_INVALID', vm_ref]) -+ return self.VM_set('actions_after_shutdown', session, vm_ref, action) - - def VM_set_actions_after_reboot(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ if action not in XEN_API_ON_NORMAL_EXIST: -+ return xen_api_error(['VM_ON_NORMAL_EXIT_INVALID', vm_ref]) -+ return self.VM_set('actions_after_reboot', session, vm_ref, action) - - def VM_set_actions_after_suspend(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ if action not in XEN_API_ON_NORMAL_EXIT: -+ return xen_api_error(['VM_ON_NORMAL_EXIT_INVALID', vm_ref]) -+ return self.VM_set('actions_after_suspend', session, vm_ref, action) - - def VM_set_actions_after_crash(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ if action not in XEN_API_ON_CRASH_BEHAVIOUR: -+ return xen_api_error(['VM_ON_CRASH_BEHAVIOUR_INVALID', vm_ref]) -+ return self.VM_set('actions_after_crash', session, vm_ref, action) - - def VM_set_HVM_boot(self, session, vm_ref, value): - return self.VM_set('HVM_boot', session, vm_ref, value) -@@ -903,29 +909,26 @@ class XendAPI: - def VM_set_PV_bootloader_args(self, session, vm_ref, value): - return self.VM_set('PV_bootloader_args', session, vm_ref, value) - -- def VM_set_platform_std_VGA(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -- -- def VM_set_platform_serial(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ def VM_set_platform_std_VGA(self, session, vm_ref, value): -+ return self.VM_set('platform_std_vga', session, vm_ref, value) - -- def VM_set_platform_localtime(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ def VM_set_platform_serial(self, session, vm_ref, value): -+ return self.VM_set('platform_serial', session, vm_ref, value) -+ -+ def VM_set_platform_keymap(self, session, vm_ref, value): -+ return self.VM_set('platform_keymap', session, vm_ref, value) -+ -+ def VM_set_platform_localtime(self, session, vm_ref, value): -+ return self.VM_set('platform_localtime', session, vm_ref, value) - -- def VM_set_platform_clock_offset(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ def VM_set_platform_clock_offset(self, session, vm_ref, value): -+ return self.VM_set('platform_clock_offset', session, vm_ref, value) - -- def VM_set_platform_enable_audio(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ def VM_set_platform_enable_audio(self, session, vm_ref, value): -+ return self.VM_set('platform_enable_audio', session, vm_ref, value) - -- def VM_set_otherConfig(self, session, vm_ref): -- dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_success_void() -+ def VM_set_otherConfig(self, session, vm_ref, value): -+ return self.VM_set('otherconfig', session, vm_ref, value) - - # class methods - def VM_get_all(self, session): -@@ -995,7 +998,7 @@ class XendAPI: - 'platform_keymap': xeninfo.get_platform_keymap(), - 'PCI_bus': xeninfo.get_pci_bus(), - 'tools_version': xeninfo.get_tools_version(), -- 'otherConfig': xeninfo.get_other_config() -+ 'otherConfig': xeninfo.info.get('otherconfig'), - } - return xen_api_success(record) - -@@ -1030,8 +1033,6 @@ class XendAPI: - - # Xen API: Class VBD - # ---------------------------------------------------------------- -- # Note: accepts a non-API standard 'image' attribute to emulate -- # regular xm created VBDs - - VBD_attr_ro = ['image', - 'io_read_kbs', -@@ -1097,6 +1098,16 @@ class XendAPI: - xendom.managed_config_save(dom) - return xen_api_success(vbd_ref) - -+ -+ def VBD_destroy(self, session, vbd_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('vbd', vbd_ref) -+ if not vm: -+ return xen_api_error(['VBD_HANDLE_INVALID', vbd_ref]) -+ -+ vm.destroy_vbd(vbd_ref) -+ return xen_api_success_void() -+ - # attributes (rw) - def VBD_get_VM(self, session, vbd_ref): - xendom = XendDomain.instance() -@@ -1123,6 +1134,18 @@ class XendAPI: - return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref, - 'type')) - -+ def VBD_get_io_read_kbs(self, session, vbd_ref): -+ return xen_api_todo() -+ -+ def VBD_get_io_write_kbs(self, session, vbd_ref): -+ return xen_api_todo() -+ -+ def VBD_get_all(self, session): -+ xendom = XendDomain.instance() -+ vbds = [d.get_vbds() for d in XendDomain.instance().list('all')] -+ vbds = reduce(lambda x, y: x + y, vbds) -+ return xen_api_success(vbds) -+ - # Xen API: Class VIF - # ---------------------------------------------------------------- - -@@ -1173,6 +1196,59 @@ class XendAPI: - return xen_api_error(XEND_ERROR_DOMAIN_INVALID) - - -+ def VIF_destroy(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('vif', vif_ref) -+ if not vm: -+ return xen_api_error(['VIF_HANDLE_INVALID', vif_ref]) -+ -+ vm.destroy_vif(vif_ref) -+ return xen_api_success_void() -+ -+ # getters/setters -+ def VIF_get_VM(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('vif', vif_ref) -+ return xen_api_success(vm.get_uuid()) -+ -+ def VIF_get_name(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -+ 'name')) -+ def VIF_get_MTU(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -+ 'MTU')) -+ def VIF_get_MAC(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -+ 'MAC')) -+ -+ def VIF_get_type(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -+ 'type')) -+ -+ -+ def VIF_get_device(self, session, vif_ref): -+ xendom = XendDomain.instance() -+ return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -+ 'device')) -+ -+ -+ def VIF_get_io_read_kbs(self, session, vif_ref): -+ return xen_api_todo() -+ -+ def VIF_get_io_write_kbs(self, session, vif_ref): -+ return xen_api_todo() -+ -+ def VIF_get_all(self, session): -+ xendom = XendDomain.instance() -+ vifs = [d.get_vifs() for d in XendDomain.instance().list('all')] -+ vifs = reduce(lambda x, y: x + y, vifs) -+ return xen_api_success(vifs) -+ -+ - # Xen API: Class VDI - # ---------------------------------------------------------------- - VDI_attr_ro = ['VBDs', -@@ -1401,6 +1477,15 @@ class XendAPI: - xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vtpm', vtpm_ref, 'VM')) - -+ def VTPM_destroy(self, session, vtpm_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) -+ if not vm: -+ return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref]) -+ -+ vm.destroy_vtpm(vtpm_ref) -+ return xen_api_success_void() -+ - # class methods - def VTPM_create(self, session, vtpm_struct): - xendom = XendDomain.instance() -@@ -1415,6 +1500,12 @@ class XendAPI: - else: - return xen_api_error(XEND_ERROR_DOMAIN_INVALID) - -+ def VTPM_get_all(self, session): -+ xendom = XendDomain.instance() -+ vtpms = [d.get_vtpms() for d in XendDomain.instance().list('all')] -+ vtpms = reduce(lambda x, y: x + y, vtpms) -+ return xen_api_success(vtpms) -+ - - # Xen API: Class SR - # ---------------------------------------------------------------- -@@ -1451,9 +1542,6 @@ class XendAPI: - def SR_create(self, session): - return xen_api_error(XEND_ERROR_UNSUPPORTED) - -- def SR_get_by_uuid(self, session): -- return xen_api_success(XendNode.instance().get_sr().uuid) -- - # Class Methods - def SR_clone(self, session, sr_ref): - return xen_api_error(XEND_ERROR_UNSUPPORTED) -Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -@@ -954,6 +954,8 @@ class XendConfig(dict): - # dev_info['vifname'] = cfg_xenapi.get('device') - if cfg_xenapi.get('type'): - dev_info['type'] = cfg_xenapi.get('type') -+ if cfg_xenapi.get('name'): -+ dev_info['name'] = cfg_xenapi.get('name') - - dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) - dev_info['uuid'] = dev_uuid -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -525,8 +525,6 @@ class XendDomainInfo: - - return self.getDeviceController(deviceClass).destroyDevice(devid, force) - -- -- - def getDeviceSxprs(self, deviceClass): - if self.state == DOM_STATE_RUNNING: - return self.getDeviceController(deviceClass).sxprs() -@@ -1215,7 +1213,12 @@ class XendDomainInfo: - devclass, config = self.info['devices'][dev_uuid] - if devclass in XendDevices.valid_devices(): - log.info("createDevice: %s : %s" % (devclass, scrub_password(config))) -- self._createDevice(devclass, config) -+ dev_uuid = config.get('uuid') -+ devid = self._createDevice(devclass, config) -+ -+ # store devid in XendConfig for caching reasons -+ if dev_uuid in self.info['devices']: -+ self.info['devices'][dev_uuid][1]['devid'] = devid - - if self.image: - self.image.createDeviceModel() -@@ -1887,11 +1890,9 @@ class XendDomainInfo: - def get_platform_keymap(self): - return self.info.get('platform_keymap', '') - def get_pci_bus(self): -- return '' # TODO -+ return self.info.get('pci_bus', '') - def get_tools_version(self): -- return {} # TODO -- def get_other_config(self): -- return {} # TODO -+ return self.info.get('tools_version', {}) - - def get_on_shutdown(self): - after_shutdown = self.info.get('action_after_shutdown') -@@ -2112,6 +2113,32 @@ class XendDomainInfo: - - return dev_uuid - -+ def destroy_device_by_uuid(self, dev_type, dev_uuid): -+ if dev_uuid not in self.info['devices']: -+ raise XendError('Device does not exist') -+ -+ try: -+ if self.state == XEN_API_VM_POWER_STATE_RUNNING: -+ _, config = self.info['devices'][dev_uuid] -+ devid = config.get('devid') -+ if devid != None: -+ self.getDeviceController(dev_type).destroyDevice(devid, force = False) -+ else: -+ raise XendError('Unable to get devid for device: %s:%s' % -+ (dev_type, dev_uuid)) -+ finally: -+ del self.info['devices'][dev_uuid] -+ self.info['%s_refs' % dev_type].remove(dev_uuid) -+ -+ def destroy_vbd(self, dev_uuid): -+ self.destroy_device_by_uuid('vbd', dev_uuid) -+ -+ def destroy_vif(self, dev_uuid): -+ self.destroy_device_by_uuid('vif', dev_uuid) -+ -+ def destroy_vtpm(self, dev_uuid): -+ self.destroy_device_by_uuid('vtpm', dev_uuid) -+ - def has_device(self, dev_class, dev_uuid): - return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) - diff --git a/13615_xenapi.patch b/13615_xenapi.patch deleted file mode 100644 index b18a20f..0000000 --- a/13615_xenapi.patch +++ /dev/null @@ -1,151 +0,0 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -412,8 +412,11 @@ class HVMImageHandler(ImageHandler): - - # Handle booleans gracefully - if a in ['localtime', 'std-vga', 'isa', 'usb', 'acpi']: -- if v != None: v = int(v) -- if v: ret.append("-%s" % a) -+ try: -+ if v != None: v = int(v) -+ if v: ret.append("-%s" % a) -+ except (ValueError, TypeError): -+ pass # if we can't convert it to a sane type, ignore it - else: - if v: - ret.append("-%s" % a) -Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -@@ -106,7 +106,6 @@ XENAPI_HVM_CFG = { - 'platform_std_vga': 'stdvga', - 'platform_serial' : 'serial', - 'platform_localtime': 'localtime', -- 'platform_enable_audio': 'soundhw', - 'platform_keymap' : 'keymap', - } - -@@ -248,17 +247,19 @@ LEGACY_IMAGE_HVM_DEVICES_CFG = [ - ('boot', str), - ('fda', str), - ('fdb', str), -- ('isa', str), -+ ('isa', int), - ('keymap', str), -- ('localtime', str), -+ ('localtime', int), - ('serial', str), - ('stdvga', int), - ('soundhw', str), -- ('usb', str), -+ ('usb', int), - ('usbdevice', str), - ('vcpus', int), - ] - -+LEGACY_DM = '/usr/lib/xen/bin/qemu-dm' -+ - ## - ## Config Choices - ## -@@ -731,9 +732,18 @@ class XendConfig(dict): - hvm = self['HVM_boot'] != '' - self['image']['type'] = hvm and 'hvm' or 'linux' - if hvm: -- self['image']['hvm'] = {} -+ self['image']['hvm'] = {'devices': {}} - for xapi, cfgapi in XENAPI_HVM_CFG.items(): -- self['image']['hvm'][cfgapi] = self[xapi] -+ if xapi in self: -+ self['image']['hvm']['devices'][cfgapi] = self[xapi] -+ -+ # currently unsupported options -+ self['image']['hvm']['device_model'] = LEGACY_DM -+ self['image']['vnc'] = 0 -+ self['image']['hvm']['pae'] = 1 -+ -+ if self['platform_enable_audio']: -+ self['image']['hvm']['devices']['soundhw'] = 'sb16' - - - def _get_old_state_string(self): -@@ -946,7 +956,8 @@ class XendConfig(dict): - return dev_uuid - - if cfg_xenapi: -- dev_info = {} -+ dev_info = {} -+ dev_uuid = '' - if dev_type == 'vif': - if cfg_xenapi.get('MAC'): # don't add if blank - dev_info['mac'] = cfg_xenapi.get('MAC') -@@ -964,7 +975,6 @@ class XendConfig(dict): - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vif_refs'].append(dev_uuid) -- return dev_uuid - - elif dev_type in ('vbd', 'tap'): - if dev_type == 'vbd': -@@ -986,7 +996,6 @@ class XendConfig(dict): - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vbd_refs'].append(dev_uuid) -- return dev_uuid - - elif dev_type in ('vtpm'): - if cfg_xenapi.get('type'): -@@ -996,9 +1005,12 @@ class XendConfig(dict): - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vtpm_refs'].append(dev_uuid) -- return dev_uuid - -+ return dev_uuid -+ -+ # no valid device to add - return '' -+ - - def device_update(self, dev_uuid, cfg_sxp): - """Update an existing device with the new configuration. -@@ -1094,13 +1106,18 @@ class XendConfig(dict): - if 'hvm' in self['image']: - for arg, conv in LEGACY_IMAGE_HVM_CFG: - if self['image']['hvm'].get(arg): -- image.append([arg, self['image']['hvm'][arg]]) -+ image.append([arg, conv(self['image']['hvm'][arg])]) - - if 'hvm' in self['image'] and 'devices' in self['image']['hvm']: - for arg, conv in LEGACY_IMAGE_HVM_DEVICES_CFG: -- if self['image']['hvm']['devices'].get(arg): -- image.append([arg, -- self['image']['hvm']['devices'][arg]]) -+ val = self['image']['hvm']['devices'].get(arg) -+ if val != None: -+ try: -+ if conv: val = conv(val) -+ except (ValueError, TypeError): -+ if type(val) == bool: val = int(val) -+ -+ image.append([arg, val]) - - return image - -@@ -1144,8 +1161,11 @@ class XendConfig(dict): - for arg, conv in LEGACY_IMAGE_HVM_DEVICES_CFG: - val = sxp.child_value(image_sxp, arg, None) - if val != None: -- image_hvm_devices[arg] = conv(val) -- -+ try: -+ image_hvm_devices[arg] = conv(val) -+ except (ValueError, TypeError): -+ image_hvm_devices[arg] = val -+ - if image_hvm or image_hvm_devices: - image['hvm'] = image_hvm - image['hvm']['devices'] = image_hvm_devices diff --git a/13616_xenapi.patch b/13616_xenapi.patch deleted file mode 100644 index 41674ef..0000000 --- a/13616_xenapi.patch +++ /dev/null @@ -1,309 +0,0 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/server/DevController.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/server/DevController.py -+++ xen-3.0.4-testing/tools/python/xen/xend/server/DevController.py -@@ -75,7 +75,7 @@ class DevController: - - def __init__(self, vm): - self.vm = vm -- -+ self.hotplug = True - - def createDevice(self, config): - """Trigger the creation of a device with the given configuration. -@@ -151,6 +151,9 @@ class DevController: - - def waitForDevice(self, devid): - log.debug("Waiting for %s.", devid) -+ -+ if not self.hotplug: -+ return - - status = self.waitForBackend(devid) - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPIConstants.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPIConstants.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPIConstants.py -@@ -74,3 +74,4 @@ XEN_API_VBD_MODE = ['RO', 'RW'] - XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral'] - XEN_API_DRIVER_TYPE = ['ioemu', 'paravirtualised'] - XEN_API_VBD_TYPE = ['CD', 'Disk'] -+XEN_API_CONSOLE_PROTOCOL = ['vt100', 'rfb', 'rdp'] -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -227,6 +227,27 @@ def valid_vtpm(func): - - return check_vtpm_ref - -+def valid_console(func): -+ """Decorator to verify if console_ref is valid before calling method. -+ -+ @param func: function with params: (self, session, console_ref, ...) -+ @rtype: callable object -+ """ -+ def check_console_ref(self, session, console_ref, *args, **kwargs): -+ xendom = XendDomain.instance() -+ if type(console_ref) == type(str()) and \ -+ xendom.is_valid_dev('console', console_ref): -+ return func(self, session, console_ref, *args, **kwargs) -+ else: -+ return {'Status': 'Failure', -+ 'ErrorDescription': ('ECONSOLEINVALID', 'Console Invalid')} -+ -+ # make sure we keep the 'api' attribute -+ if hasattr(func, 'api'): -+ check_console_ref.api = func.api -+ -+ return check_console_ref -+ - def valid_sr(func): - """Decorator to verify if sr_ref is valid before calling - method. -@@ -299,6 +320,7 @@ class XendAPI: - 'VIF': (valid_vif, session_required), - 'VDI': (valid_vdi, session_required), - 'VTPM':(valid_vtpm, session_required), -+ 'console':(valid_console, session_required), - 'SR': (valid_sr, session_required)} - - # Cheat methods -@@ -719,14 +741,18 @@ class XendAPI: - def VM_get_VTPMs(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) - return xen_api_success(dom.get_vtpms()) -+ -+ def VM_get_consoles(self, session, vm_ref): -+ dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -+ return xen_api_success(dom.get_consoles()) - - def VM_get_PCI_bus(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() # unsupported by xc -+ return dom.get_pci_bus() - - def VM_get_tools_version(self, session, vm_ref): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) -- return xen_api_todo() -+ return dom.get_tools_version() - - # attributes (rw) - def VM_get_name_label(self, session, vm_ref): -@@ -1507,6 +1533,55 @@ class XendAPI: - return xen_api_success(vtpms) - - -+ # Xen API: Class console -+ # ---------------------------------------------------------------- -+ -+ -+ console_attr_ro = ['uri', 'protocol', 'VM'] -+ console_attr_rw = [] -+ -+ def console_get_all(self, session): -+ xendom = XendDomain.instance() -+ cons = [d.get_consoles() for d in XendDomain.instance().list('all')] -+ cons = reduce(lambda x, y: x + y, cons) -+ return xen_api_success(cons) -+ -+ def console_get_uri(self, session, console_ref): -+ return xen_api_success(xendom.get_dev_property_by_uuid('console', -+ console_ref, -+ 'uri')) -+ -+ def console_get_protocol(self, session, console_ref): -+ return xen_api_success(xendom.get_dev_property_by_uuid('console', -+ console_ref, -+ 'protocol')) -+ -+ def console_get_VM(self, session, console_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('console', console_ref) -+ return xen_api_success(vm.get_uuid()) -+ -+ # object methods -+ def console_get_record(self, session, console_ref): -+ xendom = XendDomain.instance() -+ vm = xendom.get_vm_with_dev_uuid('console', console_ref) -+ if not vm: -+ return xen_api_error(['CONSOLE_HANDLE_INVALID', console_ref]) -+ cfg = vm.get_dev_xenapi_config('console', console_ref) -+ if not cfg: -+ return xen_api_error(['CONSOLE_HANDLE_INVALID', console_ref]) -+ -+ valid_console_keys = self.console_attr_ro + self.console_attr_rw + \ -+ self.Base_attr_ro + self.Base_attr_rw -+ -+ return_cfg = {} -+ for k in cfg.keys(): -+ if k in valid_console_keys: -+ return_cfg[k] = cfg[k] -+ -+ return xen_api_success(return_cfg) -+ -+ - # Xen API: Class SR - # ---------------------------------------------------------------- - SR_attr_ro = ['VDIs', -Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -@@ -900,8 +900,7 @@ class XendConfig(dict): - if target == None: - target = self - -- if dev_type not in XendDevices.valid_devices() and \ -- dev_type not in XendDevices.pseudo_devices(): -+ if dev_type not in XendDevices.valid_devices(): - raise XendConfigError("XendConfig: %s not a valid device type" % - dev_type) - -@@ -909,10 +908,10 @@ class XendConfig(dict): - raise XendConfigError("XendConfig: device_add requires some " - "config.") - -- if cfg_sxp: -- log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) -- if cfg_xenapi: -- log.debug("XendConfig.device_add: %s" % str(cfg_xenapi)) -+ #if cfg_sxp: -+ # log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) -+ #if cfg_xenapi: -+ # log.debug("XendConfig.device_add: %s" % str(cfg_xenapi)) - - if cfg_sxp: - if sxp.child0(cfg_sxp) == 'device': -@@ -952,6 +951,11 @@ class XendConfig(dict): - target['vbd_refs'] = [] - if dev_uuid not in target['vbd_refs']: - target['vbd_refs'].append(dev_uuid) -+ elif dev_type in ('console',): -+ if 'console_refs' not in target: -+ target['console_refs'] = [] -+ if dev_uuid not in target['console_refs']: -+ target['console_refs'].append(dev_uuid) - - return dev_uuid - -@@ -1012,6 +1016,25 @@ class XendConfig(dict): - return '' - - -+ def console_add(self, protocol, uri): -+ dev_uuid = uuid.createString() -+ dev_info = { -+ 'uuid': dev_uuid, -+ 'protocol': protocol, -+ 'uri': uri -+ } -+ if 'devices' not in self: -+ self['devices'] = {} -+ -+ self['devices'][dev_uuid] = ('console', dev_info) -+ self['console_refs'].append(dev_uuid) -+ return dev_info -+ -+ def console_get_all(self, protocol): -+ consoles = [dinfo for dtype, dinfo in self['devices'].values() -+ if dtype == 'console'] -+ return [c for c in consoles if c.get('protocol') == protocol] -+ - def device_update(self, dev_uuid, cfg_sxp): - """Update an existing device with the new configuration. - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDevices.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDevices.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDevices.py -@@ -21,6 +21,7 @@ - - from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif, vfbif - from xen.xend.server.BlktapController import BlktapController -+from xen.xend.server.ConsoleController import ConsoleController - - class XendDevices: - """ An ugly halfway point between the module local device name -@@ -43,6 +44,7 @@ class XendDevices: - 'tap': BlktapController, - 'vfb': vfbif.VfbifController, - 'vkbd': vfbif.VkbdifController, -+ 'console': ConsoleController, - } - - #@classmethod -@@ -51,11 +53,6 @@ class XendDevices: - valid_devices = classmethod(valid_devices) - - #@classmethod -- def pseudo_devices(cls): -- return ['console'] -- pseudo_devices = classmethod(pseudo_devices) -- -- #@classmethod - def make_controller(cls, name, domain): - """Factory function to make device controllers per domain. - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -680,6 +680,29 @@ class XendDomainInfo: - for device in devices: - self.info.device_add(device[0], cfg_sxp = device) - -+ self._update_consoles() -+ -+ def _update_consoles(self): -+ if self.domid == None or self.domid == 0: -+ return -+ -+ # Update VT100 port if it exists -+ self.console_port = self.readDom('console/port') -+ if self.console_port is not None: -+ serial_consoles = self.info.console_get_all('vt100') -+ if not serial_consoles: -+ cfg = self.info.console_add('vt100', self.console_port) -+ self._createDevice('console', cfg) -+ -+ # Update VNC port if it exists -+ vnc_port = self.readDom('console/vnc-port') -+ if vnc_port is not None: -+ vnc_consoles = self.info.console_get_all('rfb') -+ if not vnc_consoles: -+ cfg = self.info.console_add('rfb', 'localhost:%s' % -+ str(vnc_port)) -+ self._createDevice('console', cfg) -+ - # - # Function to update xenstore /vm/* - # -@@ -1825,7 +1848,8 @@ class XendDomainInfo: - # TODO: we should eventually get rid of old_dom_states - - self.info.update_config(info) -- -+ self._update_consoles() -+ - if refresh: - self.refreshShutdown(info) - -@@ -1837,11 +1861,11 @@ class XendDomainInfo: - ignore_devices = ignore_store, - legacy_only = legacy_only) - -- if not ignore_store and self.dompath: -- vnc_port = self.readDom('console/vnc-port') -- if vnc_port is not None: -- result.append(['device', -- ['console', ['vnc-port', str(vnc_port)]]]) -+ #if not ignore_store and self.dompath: -+ # vnc_port = self.readDom('console/vnc-port') -+ # if vnc_port is not None: -+ # result.append(['device', -+ # ['console', ['vnc-port', str(vnc_port)]]]) - - return result - diff --git a/13628_xenapi.patch b/13628_xenapi.patch deleted file mode 100644 index 5f82f22..0000000 --- a/13628_xenapi.patch +++ /dev/null @@ -1,42 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1169779475 0 -# Node ID ba3ec84c9423a4eb7f7a4c1de052f9e935d17891 -# Parent 9d1d9877131de3aec3d56b277c03075d7f63f3a1 -[XEND] Add missing ConsoleController.py - -Signed-off-by: Alastair Tse - -diff -r 9d1d9877131d -r ba3ec84c9423 tools/python/xen/xend/server/ConsoleController.py ---- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/tools/python/xen/xend/server/ConsoleController.py Fri Jan 26 02:44:35 2007 +0000 -@@ -0,0 +1,29 @@ -+from xen.xend.server.DevController import DevController -+from xen.xend.XendLogging import log -+ -+from xen.xend.XendError import VmError -+ -+class ConsoleController(DevController): -+ """A dummy controller for us to represent serial and vnc -+ console devices with persistent UUIDs. -+ """ -+ -+ valid_cfg = ['uri', 'uuid', 'protocol'] -+ -+ def __init__(self, vm): -+ DevController.__init__(self, vm) -+ self.hotplug = False -+ -+ def getDeviceDetails(self, config): -+ back = dict([(k, config[k]) for k in self.valid_cfg if k in config]) -+ return (self.allocateDeviceID(), back, {}) -+ -+ -+ def getDeviceConfiguration(self, devid): -+ result = DevController.getDeviceConfiguration(self, devid) -+ devinfo = self.readBackend(devid, *self.valid_cfg) -+ config = dict(zip(self.valid_cfg, devinfo)) -+ config = dict([(key, val) for key, val in config.items() -+ if val != None]) -+ return config -+ diff --git a/13630-domctl.patch b/13630-domctl.patch deleted file mode 100644 index 59ff9d2..0000000 --- a/13630-domctl.patch +++ /dev/null @@ -1,93 +0,0 @@ -# HG changeset patch -# User kaf24@localhost.localdomain -# Node ID e0291e3ed603f5437d1e88c7b746b6617346792c -# Parent 2f8a7e5fd8bab112208c7cf51941aaa79afc615f -32-on-64: New set_address_size domctl for switching to compat mode. -From: Gerd Hoffmann -Signed-off-by: Keir Fraser - -Index: xen-3.0.4-testing/xen/arch/x86/domctl.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domctl.c -+++ xen-3.0.4-testing/xen/arch/x86/domctl.c -@@ -9,6 +9,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -293,6 +294,46 @@ _long arch_do_domctl( - } - break; - -+ case XEN_DOMCTL_set_address_size: -+ { -+ struct domain *d; -+ -+ ret = -ESRCH; -+ if ( (d = find_domain_by_id(domctl->domain)) == NULL ) -+ break; -+ -+ switch ( domctl->u.address_size.size ) -+ { -+#ifdef CONFIG_COMPAT -+ case 32: -+ ret = switch_compat(d); -+ break; -+ case 64: -+ ret = switch_native(d); -+ break; -+#endif -+ default: -+ ret = (domctl->u.address_size.size == BITS_PER_LONG) ? 0 : -EINVAL; -+ break; -+ } -+ -+ put_domain(d); -+ } -+ -+ case XEN_DOMCTL_get_address_size: -+ { -+ struct domain *d; -+ -+ ret = -ESRCH; -+ if ( (d = find_domain_by_id(domctl->domain)) == NULL ) -+ break; -+ -+ domctl->u.address_size.size = BITS_PER_GUEST_LONG(d); -+ -+ ret = 0; -+ put_domain(d); -+ } -+ - default: - ret = -ENOSYS; - break; -Index: xen-3.0.4-testing/xen/include/public/domctl.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/public/domctl.h -+++ xen-3.0.4-testing/xen/include/public/domctl.h -@@ -387,6 +387,13 @@ struct xen_domctl_settimeoffset { - typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t; - DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t); - -+#define XEN_DOMCTL_set_address_size 35 -+#define XEN_DOMCTL_get_address_size 36 -+typedef struct xen_domctl_address_size { -+ uint32_t size; -+} xen_domctl_address_size_t; -+DEFINE_XEN_GUEST_HANDLE(xen_domctl_address_size_t); -+ - #define XEN_DOMCTL_real_mode_area 26 - struct xen_domctl_real_mode_area { - uint32_t log; /* log2 of Real Mode Area size */ -@@ -423,6 +430,7 @@ struct xen_domctl { - struct xen_domctl_arch_setup arch_setup; - struct xen_domctl_settimeoffset settimeoffset; - struct xen_domctl_real_mode_area real_mode_area; -+ struct xen_domctl_address_size address_size; - uint8_t pad[128]; - } u; - }; diff --git a/13655_xenapi.patch b/13655_xenapi.patch deleted file mode 100644 index db2bc2f..0000000 --- a/13655_xenapi.patch +++ /dev/null @@ -1,19 +0,0 @@ -# HG changeset patch -# User kaf24@localhost.localdomain -# Date 1169977642 0 -# Node ID fbe161b1af160a605878c7f18c42f4e1a9d1e55f -# Parent 47e26ced172a971f7d347d367e7b29b9741ca9f6 -To avoid problems (hang) when doing migration, the Console Controller -needs to implement a (dummy) migrate method. - -Signed-off-by: Stefan Berger - -diff -r 47e26ced172a -r fbe161b1af16 tools/python/xen/xend/server/ConsoleController.py ---- a/tools/python/xen/xend/server/ConsoleController.py Sun Jan 28 09:46:09 2007 +0000 -+++ b/tools/python/xen/xend/server/ConsoleController.py Sun Jan 28 09:47:22 2007 +0000 -@@ -27,3 +27,5 @@ class ConsoleController(DevController): - if val != None]) - return config - -+ def migrate(self, deviceConfig, network, dst, step, domName): -+ return 0 diff --git a/13689_xenapi.patch b/13689_xenapi.patch deleted file mode 100644 index d488c98..0000000 --- a/13689_xenapi.patch +++ /dev/null @@ -1,951 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170029140 0 -# Node ID bb15af2c2b4a52ef8a3ce9646507b956e6eae322 -# Parent 9db1847845d695f28cf59010fd7c0837811a8e1d -Remove VBD.driver, VIF.type, VIF.name, VTPM.driver. This modelling was never -correct, and the values are best left implicit. - -Signed-off-by: Ewan Mellor - -Index: xen-3.0.4-testing/docs/xen-api/xenapi-datamodel.tex -=================================================================== ---- xen-3.0.4-testing.orig/docs/xen-api/xenapi-datamodel.tex -+++ xen-3.0.4-testing/docs/xen-api/xenapi-datamodel.tex -@@ -274,16 +274,6 @@ The following enumeration types are used - \end{longtable} - - \vspace{1cm} --\begin{longtable}{|ll|} --\hline --{\tt enum driver\_type} & \\ --\hline --\hspace{0.5cm}{\tt ioemu} & use hardware emulation \\ --\hspace{0.5cm}{\tt paravirtualised} & use paravirtualised driver \\ --\hline --\end{longtable} -- --\vspace{1cm} - - \newpage - \section{Class: session} -@@ -5950,8 +5940,6 @@ references to objects with match names - Quals & Field & Type & Description \\ - \hline - $\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ --$\mathit{RW}$ & {\tt name} & string & human-readable name of the interface \\ --$\mathit{RW}$ & {\tt type} & driver\_type & interface type \\ - $\mathit{RW}$ & {\tt device} & string & name of network device as exposed to guest e.g. eth0 \\ - $\mathit{RW}$ & {\tt network} & network ref & virtual network to which this vif is connected \\ - $\mathit{RW}$ & {\tt VM} & VM ref & virtual machine to which this vif is connected \\ -@@ -6060,72 +6048,6 @@ void - \vspace{0.3cm} - \vspace{0.3cm} - \vspace{0.3cm} --\subsubsection{RPC name:~get\_type} -- --{\bf Overview:} --Get the type field of the given VIF. -- -- \noindent {\bf Signature:} --\begin{verbatim} (driver_type) get_type (session_id s, VIF ref self)\end{verbatim} -- -- --\noindent{\bf Arguments:} -- -- --\vspace{0.3cm} --\begin{tabular}{|c|c|p{7cm}|} -- \hline --{\bf type} & {\bf name} & {\bf description} \\ \hline --{\tt VIF ref } & self & reference to the object \\ \hline -- --\end{tabular} -- --\vspace{0.3cm} -- -- \noindent {\bf Return Type:} --{\tt --driver\_type --} -- -- --value of the field --\vspace{0.3cm} --\vspace{0.3cm} --\vspace{0.3cm} --\subsubsection{RPC name:~set\_type} -- --{\bf Overview:} --Set the type field of the given VIF. -- -- \noindent {\bf Signature:} --\begin{verbatim} void set_type (session_id s, VIF ref self, driver_type value)\end{verbatim} -- -- --\noindent{\bf Arguments:} -- -- --\vspace{0.3cm} --\begin{tabular}{|c|c|p{7cm}|} -- \hline --{\bf type} & {\bf name} & {\bf description} \\ \hline --{\tt VIF ref } & self & reference to the object \\ \hline -- --{\tt driver\_type } & value & New value to set \\ \hline -- --\end{tabular} -- --\vspace{0.3cm} -- -- \noindent {\bf Return Type:} --{\tt --void --} -- -- -- --\vspace{0.3cm} --\vspace{0.3cm} --\vspace{0.3cm} - \subsubsection{RPC name:~get\_device} - - {\bf Overview:} -@@ -8782,7 +8704,6 @@ $\mathit{RW}$ & {\tt VDI} & VDI ref & t - $\mathit{RW}$ & {\tt device} & string & device seen by the guest e.g. hda1 \\ - $\mathit{RW}$ & {\tt mode} & vbd\_mode & the mode the disk should be mounted with \\ - $\mathit{RW}$ & {\tt type} & vbd\_type & how the VBD will appear to the guest (e.g. disk or CD) \\ --$\mathit{RW}$ & {\tt driver} & driver\_type & the style of driver \\ - $\mathit{RO}_\mathit{run}$ & {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\ - $\mathit{RO}_\mathit{run}$ & {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\ - \hline -@@ -9184,72 +9105,6 @@ void - \vspace{0.3cm} - \vspace{0.3cm} - \vspace{0.3cm} --\subsubsection{RPC name:~get\_driver} -- --{\bf Overview:} --Get the driver field of the given VBD. -- -- \noindent {\bf Signature:} --\begin{verbatim} (driver_type) get_driver (session_id s, VBD ref self)\end{verbatim} -- -- --\noindent{\bf Arguments:} -- -- --\vspace{0.3cm} --\begin{tabular}{|c|c|p{7cm}|} -- \hline --{\bf type} & {\bf name} & {\bf description} \\ \hline --{\tt VBD ref } & self & reference to the object \\ \hline -- --\end{tabular} -- --\vspace{0.3cm} -- -- \noindent {\bf Return Type:} --{\tt --driver\_type --} -- -- --value of the field --\vspace{0.3cm} --\vspace{0.3cm} --\vspace{0.3cm} --\subsubsection{RPC name:~set\_driver} -- --{\bf Overview:} --Set the driver field of the given VBD. -- -- \noindent {\bf Signature:} --\begin{verbatim} void set_driver (session_id s, VBD ref self, driver_type value)\end{verbatim} -- -- --\noindent{\bf Arguments:} -- -- --\vspace{0.3cm} --\begin{tabular}{|c|c|p{7cm}|} -- \hline --{\bf type} & {\bf name} & {\bf description} \\ \hline --{\tt VBD ref } & self & reference to the object \\ \hline -- --{\tt driver\_type } & value & New value to set \\ \hline -- --\end{tabular} -- --\vspace{0.3cm} -- -- \noindent {\bf Return Type:} --{\tt --void --} -- -- -- --\vspace{0.3cm} --\vspace{0.3cm} --\vspace{0.3cm} - \subsubsection{RPC name:~get\_io\_read\_kbs} - - {\bf Overview:} -@@ -9457,7 +9312,6 @@ Quals & Field & Type & Description \\ - $\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ - $\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & the virtual machine \\ - $\mathit{RO}_\mathit{ins}$ & {\tt backend} & VM ref & the domain where the backend is located \\ --$\mathit{RO}_\mathit{ins}$ & {\tt driver} & driver\_type & the style of driver \\ - $\mathit{RO}_\mathit{ins}$ & {\tt instance} & int & the instance number the virtual TPM represents \\ - \hline - \end{longtable} -@@ -9558,38 +9412,6 @@ value of the field - \vspace{0.3cm} - \vspace{0.3cm} - \vspace{0.3cm} --\subsubsection{RPC name:~get\_driver} -- --{\bf Overview:} --Get the driver field of the given VTPM. -- -- \noindent {\bf Signature:} --\begin{verbatim} (driver_type) get_driver (session_id s, VTPM ref self)\end{verbatim} -- -- --\noindent{\bf Arguments:} -- -- --\vspace{0.3cm} --\begin{tabular}{|c|c|p{7cm}|} -- \hline --{\bf type} & {\bf name} & {\bf description} \\ \hline --{\tt VTPM ref } & self & reference to the object \\ \hline -- --\end{tabular} -- --\vspace{0.3cm} -- -- \noindent {\bf Return Type:} --{\tt --driver\_type --} -- -- --value of the field --\vspace{0.3cm} --\vspace{0.3cm} --\vspace{0.3cm} - \subsubsection{RPC name:~get\_instance} - - {\bf Overview:} -Index: xen-3.0.4-testing/tools/libxen/include/xen_vbd.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_vbd.h -+++ xen-3.0.4-testing/tools/libxen/include/xen_vbd.h -@@ -20,7 +20,6 @@ - #define XEN_VBD_H - - #include "xen_common.h" --#include "xen_driver_type.h" - #include "xen_vbd_decl.h" - #include "xen_vbd_mode.h" - #include "xen_vdi_decl.h" -@@ -28,8 +27,8 @@ - - - /* -- * The VBD class. -- * -+ * The VBD class. -+ * - * A virtual block device. - */ - -@@ -71,7 +70,6 @@ typedef struct xen_vbd_record - char *device; - char *image; - enum xen_vbd_mode mode; -- enum xen_driver_type driver; - double io_read_kbs; - double io_write_kbs; - } xen_vbd_record; -@@ -219,13 +217,6 @@ xen_vbd_get_mode(xen_session *session, e - - - /** -- * Get the driver field of the given VBD. -- */ --extern bool --xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd); -- -- --/** - * Get the io/read_kbs field of the given VBD. - */ - extern bool -@@ -268,13 +259,6 @@ xen_vbd_set_mode(xen_session *session, x - - - /** -- * Set the driver field of the given VBD. -- */ --extern bool --xen_vbd_set_driver(xen_session *session, xen_vbd vbd, enum xen_driver_type driver); -- -- --/** - * Change the media in the device for CDROM-like devices only. For - * other devices, detach the VBD and attach a new one - */ -Index: xen-3.0.4-testing/tools/libxen/include/xen_vif.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_vif.h -+++ xen-3.0.4-testing/tools/libxen/include/xen_vif.h -@@ -20,15 +20,14 @@ - #define XEN_VIF_H - - #include "xen_common.h" --#include "xen_driver_type.h" - #include "xen_network_decl.h" - #include "xen_vif_decl.h" - #include "xen_vm_decl.h" - - - /* -- * The VIF class. -- * -+ * The VIF class. -+ * - * A virtual network interface. - */ - -@@ -65,8 +64,6 @@ typedef struct xen_vif_record - { - xen_vif handle; - char *uuid; -- char *name; -- enum xen_driver_type type; - char *device; - struct xen_network_record_opt *network; - struct xen_vm_record_opt *vm; -@@ -191,20 +188,6 @@ xen_vif_get_uuid(xen_session *session, c - - - /** -- * Get the name field of the given VIF. -- */ --extern bool --xen_vif_get_name(xen_session *session, char **result, xen_vif vif); -- -- --/** -- * Get the type field of the given VIF. -- */ --extern bool --xen_vif_get_type(xen_session *session, enum xen_driver_type *result, xen_vif vif); -- -- --/** - * Get the device field of the given VIF. - */ - extern bool -@@ -254,20 +237,6 @@ xen_vif_get_io_write_kbs(xen_session *se - - - /** -- * Set the name field of the given VIF. -- */ --extern bool --xen_vif_set_name(xen_session *session, xen_vif vif, char *name); -- -- --/** -- * Set the type field of the given VIF. -- */ --extern bool --xen_vif_set_type(xen_session *session, xen_vif vif, enum xen_driver_type type); -- -- --/** - * Set the device field of the given VIF. - */ - extern bool -Index: xen-3.0.4-testing/tools/libxen/include/xen_vtpm.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_vtpm.h -+++ xen-3.0.4-testing/tools/libxen/include/xen_vtpm.h -@@ -21,7 +21,6 @@ - #define XEN_VTPM_H - - #include "xen_common.h" --#include "xen_driver_type.h" - #include "xen_vm_decl.h" - #include "xen_vtpm_decl.h" - -@@ -67,7 +66,6 @@ typedef struct xen_vtpm_record - char *uuid; - struct xen_vm_record_opt *vm; - struct xen_vm_record_opt *backend; -- enum xen_driver_type driver; - int64_t instance; - } xen_vtpm_record; - -@@ -200,13 +198,6 @@ xen_vtpm_get_backend(xen_session *sessio - - - /** -- * Get the driver field of the given VTPM. -- */ --extern bool --xen_vtpm_get_driver(xen_session *session, enum xen_driver_type *result, xen_vtpm vtpm); -- -- --/** - * Get the instance field of the given VTPM. - */ - extern bool -Index: xen-3.0.4-testing/tools/libxen/src/xen_vbd.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/src/xen_vbd.c -+++ xen-3.0.4-testing/tools/libxen/src/xen_vbd.c -@@ -21,7 +21,6 @@ - #include - - #include "xen_common.h" --#include "xen_driver_type_internal.h" - #include "xen_internal.h" - #include "xen_vbd.h" - #include "xen_vbd_mode_internal.h" -@@ -58,9 +57,6 @@ static const struct_member xen_vbd_recor - { .key = "mode", - .type = &xen_vbd_mode_abstract_type_, - .offset = offsetof(xen_vbd_record, mode) }, -- { .key = "driver", -- .type = &xen_driver_type_abstract_type_, -- .offset = offsetof(xen_vbd_record, driver) }, - { .key = "io_read_kbs", - .type = &abstract_type_float, - .offset = offsetof(xen_vbd_record, io_read_kbs) }, -@@ -235,23 +231,6 @@ xen_vbd_get_mode(xen_session *session, e - - - bool --xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vbd } -- }; -- -- abstract_type result_type = xen_driver_type_abstract_type_; -- char *result_str = NULL; -- XEN_CALL_("VBD.get_driver"); -- *result = xen_driver_type_from_string(session, result_str); -- return session->ok; --} -- -- --bool - xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd) - { - abstract_value param_values[] = -@@ -348,22 +327,6 @@ xen_vbd_set_mode(xen_session *session, x - - - bool --xen_vbd_set_driver(xen_session *session, xen_vbd vbd, enum xen_driver_type driver) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vbd }, -- { .type = &xen_driver_type_abstract_type_, -- .u.string_val = xen_driver_type_to_string(driver) } -- }; -- -- xen_call_(session, "VBD.set_driver", param_values, 2, NULL, NULL); -- return session->ok; --} -- -- --bool - xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi) - { - abstract_value param_values[] = -Index: xen-3.0.4-testing/tools/libxen/src/xen_vif.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/src/xen_vif.c -+++ xen-3.0.4-testing/tools/libxen/src/xen_vif.c -@@ -21,7 +21,6 @@ - #include - - #include "xen_common.h" --#include "xen_driver_type_internal.h" - #include "xen_internal.h" - #include "xen_network.h" - #include "xen_vif.h" -@@ -42,12 +41,6 @@ static const struct_member xen_vif_recor - { .key = "uuid", - .type = &abstract_type_string, - .offset = offsetof(xen_vif_record, uuid) }, -- { .key = "name", -- .type = &abstract_type_string, -- .offset = offsetof(xen_vif_record, name) }, -- { .key = "type", -- .type = &xen_driver_type_abstract_type_, -- .offset = offsetof(xen_vif_record, type) }, - { .key = "device", - .type = &abstract_type_string, - .offset = offsetof(xen_vif_record, device) }, -@@ -90,7 +83,6 @@ xen_vif_record_free(xen_vif_record *reco - } - free(record->handle); - free(record->uuid); -- free(record->name); - free(record->device); - xen_network_record_opt_free(record->network); - xen_vm_record_opt_free(record->vm); -@@ -171,38 +163,6 @@ xen_vif_destroy(xen_session *session, xe - - - bool --xen_vif_get_name(xen_session *session, char **result, xen_vif vif) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vif } -- }; -- -- abstract_type result_type = abstract_type_string; -- -- *result = NULL; -- XEN_CALL_("VIF.get_name"); -- return session->ok; --} -- -- --bool --xen_vif_get_type(xen_session *session, enum xen_driver_type *result, xen_vif vif) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vif } -- }; -- -- abstract_type result_type = xen_driver_type_abstract_type_; -- XEN_CALL_("VIF.get_type"); -- return session->ok; --} -- -- --bool - xen_vif_get_device(xen_session *session, char **result, xen_vif vif) - { - abstract_value param_values[] = -@@ -319,38 +279,6 @@ xen_vif_get_io_write_kbs(xen_session *se - - - bool --xen_vif_set_name(xen_session *session, xen_vif vif, char *name) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vif }, -- { .type = &abstract_type_string, -- .u.string_val = name } -- }; -- -- xen_call_(session, "VIF.set_name", param_values, 2, NULL, NULL); -- return session->ok; --} -- -- --bool --xen_vif_set_type(xen_session *session, xen_vif vif, enum xen_driver_type type) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vif }, -- { .type = &xen_driver_type_abstract_type_, -- .u.string_val = xen_driver_type_to_string(type) } -- }; -- -- xen_call_(session, "VIF.set_type", param_values, 2, NULL, NULL); -- return session->ok; --} -- -- --bool - xen_vif_set_device(xen_session *session, xen_vif vif, char *device) - { - abstract_value param_values[] = -Index: xen-3.0.4-testing/tools/libxen/src/xen_vtpm.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/src/xen_vtpm.c -+++ xen-3.0.4-testing/tools/libxen/src/xen_vtpm.c -@@ -22,7 +22,6 @@ - #include - - #include "xen_common.h" --#include "xen_driver_type_internal.h" - #include "xen_internal.h" - #include "xen_vm.h" - #include "xen_vtpm.h" -@@ -48,9 +47,6 @@ static const struct_member xen_vtpm_reco - { .key = "backend", - .type = &abstract_type_ref, - .offset = offsetof(xen_vtpm_record, backend) }, -- { .key = "driver", -- .type = &xen_driver_type_abstract_type_, -- .offset = offsetof(xen_vtpm_record, driver) }, - { .key = "instance", - .type = &abstract_type_int, - .offset = offsetof(xen_vtpm_record, instance) } -@@ -187,21 +183,6 @@ xen_vtpm_get_backend(xen_session *sessio - - - bool --xen_vtpm_get_driver(xen_session *session, enum xen_driver_type *result, xen_vtpm vtpm) --{ -- abstract_value param_values[] = -- { -- { .type = &abstract_type_string, -- .u.string_val = vtpm } -- }; -- -- abstract_type result_type = xen_driver_type_abstract_type_; -- XEN_CALL_("VTPM.get_driver"); -- return session->ok; --} -- -- --bool - xen_vtpm_get_instance(xen_session *session, int64_t *result, xen_vtpm vtpm) - { - abstract_value param_values[] = -Index: xen-3.0.4-testing/tools/libxen/test/test_bindings.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/test/test_bindings.c -+++ xen-3.0.4-testing/tools/libxen/test/test_bindings.c -@@ -382,8 +382,7 @@ static xen_vm create_new_vm(xen_session - .vm = &vm_record_opt, - .vdi = &vdi0_record_opt, - .device = "xvda1", -- .mode = XEN_VBD_MODE_RW, -- .driver = XEN_DRIVER_TYPE_PARAVIRTUALISED -+ .mode = XEN_VBD_MODE_RW - }; - - xen_vbd vbd0; -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -1067,8 +1067,7 @@ class XendAPI: - 'VDI', - 'device', - 'mode', -- 'type', -- 'driver'] -+ 'type'] - - VBD_attr_inst = VBD_attr_rw + ['image'] - -@@ -1150,10 +1149,6 @@ class XendAPI: - xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, - 'mode')) -- def VBD_get_driver(self, session, vbd_ref): -- xendom = XendDomain.instance() -- return xen_api_success(xendom.get_dev_property('vbd', vbd_ref, -- 'driver')) - - def VBD_get_type(self, session, vbd_ref): - xendom = XendDomain.instance() -@@ -1177,9 +1172,7 @@ class XendAPI: - - VIF_attr_ro = ['io_read_kbs', - 'io_write_kbs'] -- VIF_attr_rw = ['name', -- 'type', -- 'device', -+ VIF_attr_rw = ['device', - 'network', - 'VM', - 'MAC', -@@ -1237,10 +1230,6 @@ class XendAPI: - vm = xendom.get_vm_with_dev_uuid('vif', vif_ref) - return xen_api_success(vm.get_uuid()) - -- def VIF_get_name(self, session, vif_ref): -- xendom = XendDomain.instance() -- return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -- 'name')) - def VIF_get_MTU(self, session, vif_ref): - xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -@@ -1250,17 +1239,10 @@ class XendAPI: - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, - 'MAC')) - -- def VIF_get_type(self, session, vif_ref): -- xendom = XendDomain.instance() -- return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, -- 'type')) -- -- - def VIF_get_device(self, session, vif_ref): - xendom = XendDomain.instance() - return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, - 'device')) -- - - def VIF_get_io_read_kbs(self, session, vif_ref): - return xen_api_todo() -@@ -1434,8 +1416,7 @@ class XendAPI: - VTPM_attr_rw = [ ] - VTPM_attr_ro = ['VM', - 'backend', -- 'instance', -- 'driver'] -+ 'instance'] - - VTPM_attr_inst = VTPM_attr_rw - -@@ -1471,20 +1452,6 @@ class XendAPI: - instance = -1 - return xen_api_success(instance) - -- def VTPM_get_driver(self, session, vtpm_ref): -- xendom = XendDomain.instance() -- vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) -- if not vm: -- return xen_api_error(XEND_ERROR_VTPM_INVALID) -- cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref) -- if not cfg: -- return xen_api_error(XEND_ERROR_VTPM_INVALID) -- if cfg.has_key('type'): -- driver = cfg['type'] -- else: -- driver = "Unknown" -- return xen_api_success(driver) -- - def VTPM_get_backend(self, session, vtpm_ref): - xendom = XendDomain.instance() - vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref) -Index: xen-3.0.4-testing/tools/libxen/include/xen_driver_type.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_driver_type.h -+++ /dev/null -@@ -1,77 +0,0 @@ --/* -- * Copyright (c) 2006, XenSource Inc. -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Lesser General Public -- * License as published by the Free Software Foundation; either -- * version 2.1 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Lesser General Public License for more details. -- * -- * You should have received a copy of the GNU Lesser General Public -- * License along with this library; if not, write to the Free Software -- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- */ -- --#ifndef XEN_DRIVER_TYPE_H --#define XEN_DRIVER_TYPE_H -- -- --#include "xen_common.h" -- -- --enum xen_driver_type --{ -- /** -- * use hardware emulation -- */ -- XEN_DRIVER_TYPE_IOEMU, -- -- /** -- * use paravirtualised driver -- */ -- XEN_DRIVER_TYPE_PARAVIRTUALISED --}; -- -- --typedef struct xen_driver_type_set --{ -- size_t size; -- enum xen_driver_type contents[]; --} xen_driver_type_set; -- --/** -- * Allocate a xen_driver_type_set of the given size. -- */ --extern xen_driver_type_set * --xen_driver_type_set_alloc(size_t size); -- --/** -- * Free the given xen_driver_type_set. The given set must have been -- * allocated by this library. -- */ --extern void --xen_driver_type_set_free(xen_driver_type_set *set); -- -- --/** -- * Return the name corresponding to the given code. This string must -- * not be modified or freed. -- */ --extern const char * --xen_driver_type_to_string(enum xen_driver_type val); -- -- --/** -- * Return the correct code for the given string, or set the session -- * object to failure and return an undefined value if the given string does -- * not match a known code. -- */ --extern enum xen_driver_type --xen_driver_type_from_string(xen_session *session, const char *str); -- -- --#endif -Index: xen-3.0.4-testing/tools/libxen/include/xen_driver_type_internal.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_driver_type_internal.h -+++ /dev/null -@@ -1,37 +0,0 @@ --/* -- * Copyright (c) 2006, XenSource Inc. -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Lesser General Public -- * License as published by the Free Software Foundation; either -- * version 2.1 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Lesser General Public License for more details. -- * -- * You should have received a copy of the GNU Lesser General Public -- * License along with this library; if not, write to the Free Software -- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- */ -- -- --/* -- * Declarations of the abstract types used during demarshalling of enum -- * xen_driver_type. Internal to this library -- do not use from outside. -- */ -- -- --#ifndef XEN_DRIVER_TYPE_INTERNAL_H --#define XEN_DRIVER_TYPE_INTERNAL_H -- -- --#include "xen_internal.h" -- -- --extern const abstract_type xen_driver_type_abstract_type_; --extern const abstract_type xen_driver_type_set_abstract_type_; -- -- --#endif -Index: xen-3.0.4-testing/tools/libxen/src/xen_driver_type.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/src/xen_driver_type.c -+++ /dev/null -@@ -1,81 +0,0 @@ --/* -- * Copyright (c) 2006, XenSource Inc. -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Lesser General Public -- * License as published by the Free Software Foundation; either -- * version 2.1 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Lesser General Public License for more details. -- * -- * You should have received a copy of the GNU Lesser General Public -- * License along with this library; if not, write to the Free Software -- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- */ -- --#include -- --#include "xen_internal.h" --#include "xen_driver_type.h" --#include "xen_driver_type_internal.h" -- -- --/* -- * Maintain this in the same order as the enum declaration! -- */ --static const char *lookup_table[] = --{ -- "ioemu", -- "paravirtualised" --}; -- -- --extern xen_driver_type_set * --xen_driver_type_set_alloc(size_t size) --{ -- return calloc(1, sizeof(xen_driver_type_set) + -- size * sizeof(enum xen_driver_type)); --} -- -- --extern void --xen_driver_type_set_free(xen_driver_type_set *set) --{ -- free(set); --} -- -- --const char * --xen_driver_type_to_string(enum xen_driver_type val) --{ -- return lookup_table[val]; --} -- -- --extern enum xen_driver_type --xen_driver_type_from_string(xen_session *session, const char *str) --{ -- return ENUM_LOOKUP(session, str, lookup_table); --} -- -- --const abstract_type xen_driver_type_abstract_type_ = -- { -- .typename = ENUM, -- .enum_marshaller = -- (const char *(*)(int))&xen_driver_type_to_string, -- .enum_demarshaller = -- (int (*)(xen_session *, const char *))&xen_driver_type_from_string -- }; -- -- --const abstract_type xen_driver_type_set_abstract_type_ = -- { -- .typename = SET, -- .child = &xen_driver_type_abstract_type_ -- }; -- -- diff --git a/13724_xenapi.patch b/13724_xenapi.patch deleted file mode 100644 index 3847786..0000000 --- a/13724_xenapi.patch +++ /dev/null @@ -1,157 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170170830 0 -# Node ID 2f3794098e22a15064fbf07d2208cf526f59010b -# Parent 7fdfa020d4ed63fe758395c4630dab018f13424a -Added VM.is_control_domain field. - -Signed-off-by: Ewan Mellor - -Index: xen-3.0.4-testing/docs/xen-api/xenapi-datamodel.tex -=================================================================== ---- xen-3.0.4-testing.orig/docs/xen-api/xenapi-datamodel.tex -+++ xen-3.0.4-testing/docs/xen-api/xenapi-datamodel.tex -@@ -3644,6 +3644,38 @@ void - \vspace{0.3cm} - \vspace{0.3cm} - \vspace{0.3cm} -+\subsubsection{RPC name:~get\_is\_control\_domain} -+ -+{\bf Overview:} -+Get the is\_control\_domain field of the given VM. -+ -+ \noindent {\bf Signature:} -+\begin{verbatim} bool get_is_control_domain (session_id s, VM ref self)\end{verbatim} -+ -+ -+\noindent{\bf Arguments:} -+ -+ -+\vspace{0.3cm} -+\begin{tabular}{|c|c|p{7cm}|} -+ \hline -+{\bf type} & {\bf name} & {\bf description} \\ \hline -+{\tt VM ref } & self & reference to the object \\ \hline -+ -+\end{tabular} -+ -+\vspace{0.3cm} -+ -+ \noindent {\bf Return Type:} -+{\tt -+bool -+} -+ -+ -+value of the field -+\vspace{0.3cm} -+\vspace{0.3cm} -+\vspace{0.3cm} - \subsubsection{RPC name:~get\_boot\_method} - - {\bf Overview:} -@@ -9312,7 +9344,6 @@ Quals & Field & Type & Description \\ - $\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\ - $\mathit{RO}_\mathit{ins}$ & {\tt VM} & VM ref & the virtual machine \\ - $\mathit{RO}_\mathit{ins}$ & {\tt backend} & VM ref & the domain where the backend is located \\ --$\mathit{RO}_\mathit{ins}$ & {\tt instance} & int & the instance number the virtual TPM represents \\ - \hline - \end{longtable} - \subsection{Additional RPCs associated with class: VTPM} -Index: xen-3.0.4-testing/tools/libxen/include/xen_vm.h -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/include/xen_vm.h -+++ xen-3.0.4-testing/tools/libxen/include/xen_vm.h -@@ -142,6 +142,7 @@ typedef struct xen_vm_record - char *pci_bus; - xen_string_string_map *tools_version; - xen_string_string_map *otherconfig; -+ bool is_control_domain; - } xen_vm_record; - - /** -@@ -562,6 +563,13 @@ xen_vm_get_otherconfig(xen_session *sess - - - /** -+ * Get the is_control_domain field of the given VM. -+ */ -+extern bool -+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm); -+ -+ -+/** - * Set the name/label field of the given VM. - */ - extern bool -Index: xen-3.0.4-testing/tools/libxen/src/xen_vm.c -=================================================================== ---- xen-3.0.4-testing.orig/tools/libxen/src/xen_vm.c -+++ xen-3.0.4-testing/tools/libxen/src/xen_vm.c -@@ -176,7 +176,10 @@ static const struct_member xen_vm_record - .offset = offsetof(xen_vm_record, tools_version) }, - { .key = "otherConfig", - .type = &abstract_type_string_string_map, -- .offset = offsetof(xen_vm_record, otherconfig) } -+ .offset = offsetof(xen_vm_record, otherconfig) }, -+ { .key = "is_control_domain", -+ .type = &abstract_type_bool, -+ .offset = offsetof(xen_vm_record, is_control_domain) } - }; - - const abstract_type xen_vm_record_abstract_type_ = -@@ -1006,6 +1009,22 @@ xen_vm_get_otherconfig(xen_session *sess - - - bool -+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm) -+{ -+ abstract_value param_values[] = -+ { -+ { .type = &abstract_type_string, -+ .u.string_val = vm } -+ }; -+ -+ abstract_type result_type = abstract_type_bool; -+ -+ XEN_CALL_("VM.get_is_control_domain"); -+ return session->ok; -+} -+ -+ -+bool - xen_vm_set_name_label(xen_session *session, xen_vm vm, char *label) - { - abstract_value param_values[] = -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -603,6 +603,7 @@ class XendAPI: - 'VTPMs', - 'PCI_bus', - 'tools_version', -+ 'is_control_domain', - ] - - VM_attr_rw = ['name_label', -@@ -856,6 +857,11 @@ class XendAPI: - def VM_get_otherConfig(self, session, vm_ref): - return self.VM_get('otherConfig', session, vm_ref) - -+ def VM_get_is_control_domain(self, session, vm_ref): -+ xd = XendDomain.instance() -+ return xen_api_success( -+ xd.get_vm_by_uuid(vm_ref) == xd.privilegedDomain()) -+ - def VM_set_name_label(self, session, vm_ref, label): - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) - dom.setName(label) -@@ -1025,6 +1031,7 @@ class XendAPI: - 'PCI_bus': xeninfo.get_pci_bus(), - 'tools_version': xeninfo.get_tools_version(), - 'otherConfig': xeninfo.info.get('otherconfig'), -+ 'is_control_domain': xeninfo == xendom.privilegedDomain(), - } - return xen_api_success(record) - diff --git a/13745_xenapi.patch b/13745_xenapi.patch deleted file mode 100644 index 872cda7..0000000 --- a/13745_xenapi.patch +++ /dev/null @@ -1,662 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1170249636 0 -# Node ID 3cccf8e6429666be58408972570dbd063a2bae1e -# Parent 7c992fd3b19ba3f7094e0c01205a481dc74661f8 -[XEND] Merge VFB support for PV and HVM guests. - -This patch merges the way VFB are represented inside Xend by making -HVM VNC consoles use the VFB as its configuration object. - -It preserves the way options are specified through xm but will create -a new VFB device that is used by image.py to put vnc config into -qemu-dm's command line. The parsing is moved into image.py's -parseDeviceModel() rather than in configVNC(). - -Through the Xen API, you can create a 'console' of protocol 'rfb' and -end up with a VNC console, on both HVM and PV guests. The location of -the connecting port is stored in the location attribute of the console -object. This is updated on each XendDomainInfo.update() if it -changes. - -Also fixes missing read of the vnclisten and HVM_boot from the -config when initialised via xm. Makes sure bootable attribute for VBD -is store as an int when making SXP config. - -Signed-off-by: Alastair Tse - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendAPI.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendAPI.py -@@ -1511,8 +1511,9 @@ class XendAPI: - # ---------------------------------------------------------------- - - -- console_attr_ro = ['uri', 'protocol', 'VM'] -- console_attr_rw = [] -+ console_attr_ro = ['location', 'protocol', 'VM'] -+ console_attr_rw = ['other_config'] -+ console_funcs = [('create', 'console')] - - def console_get_all(self, session): - xendom = XendDomain.instance() -@@ -1520,10 +1521,10 @@ class XendAPI: - cons = reduce(lambda x, y: x + y, cons) - return xen_api_success(cons) - -- def console_get_uri(self, session, console_ref): -+ def console_get_location(self, session, console_ref): - return xen_api_success(xendom.get_dev_property_by_uuid('console', - console_ref, -- 'uri')) -+ 'location')) - - def console_get_protocol(self, session, console_ref): - return xen_api_success(xendom.get_dev_property_by_uuid('console', -@@ -1555,6 +1556,22 @@ class XendAPI: - - return xen_api_success(return_cfg) - -+ def console_create(self, session, console_struct): -+ xendom = XendDomain.instance() -+ if not xendom.is_valid_vm(console_struct['VM']): -+ return xen_api_error(['VM_HANDLE_INVALID', console_struct['VM']]) -+ -+ dom = xendom.get_vm_by_uuid(console_struct['VM']) -+ try: -+ if 'protocol' not in console_struct: -+ return xen_api_error(['CONSOLE_PROTOCOL_INVALID', -+ 'No protocol specified']) -+ -+ console_ref = dom.create_console(console_struct) -+ xendom.managed_config_save(dom) -+ return xen_api_success(console_ref) -+ except XendError, e: -+ return xen_api_error([XEND_ERROR_TODO, str(e)]) - - # Xen API: Class SR - # ---------------------------------------------------------------- -Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -@@ -107,6 +107,7 @@ XENAPI_HVM_CFG = { - 'platform_serial' : 'serial', - 'platform_localtime': 'localtime', - 'platform_keymap' : 'keymap', -+ 'HVM_boot': 'boot', - } - - # List of XendConfig configuration keys that have no direct equivalent -@@ -230,7 +231,8 @@ LEGACY_IMAGE_CFG = [ - ('sdl', int), - ('vncdisplay', int), - ('vncunused', int), -- ('vncpasswd', str), -+ ('vncpasswd', str), -+ ('vnclisten', str), - ] - - LEGACY_IMAGE_HVM_CFG = [ -@@ -362,6 +364,7 @@ class XendConfig(dict): - 'vif_refs': [], - 'vbd_refs': [], - 'vtpm_refs': [], -+ 'other_config': {}, - } - - defaults['name_label'] = 'Domain-' + defaults['uuid'] -@@ -643,6 +646,25 @@ class XendConfig(dict): - self['vbd_refs'] = cfg.get('vbd_refs', []) - self['vtpm_refs'] = cfg.get('vtpm_refs', []) - -+ # coalesce hvm vnc frame buffer with vfb config -+ if self['image']['type'] == 'hvm' and self['image'].get('vnc', 0): -+ # add vfb device if it isn't there already -+ has_rfb = False -+ for console_uuid in self['console_refs']: -+ if self['devices'][console_uuid][1].get('protocol') == 'rfb': -+ has_rfb = True -+ break -+ -+ if not has_rfb: -+ dev_config = ['vfb'] -+ # copy VNC related params from image config to vfb dev conf -+ for key in ['vncpasswd', 'vncunused', 'vncdisplay', -+ 'vnclisten']: -+ if key in self['image']: -+ dev_config.append([key, self['image'][key]]) -+ -+ self.device_add('vfb', cfg_sxp = dev_config) -+ - - def _sxp_to_xapi_unsupported(self, sxp_cfg): - """Read in an SXP configuration object and populate -@@ -951,6 +973,26 @@ class XendConfig(dict): - target['vbd_refs'] = [] - if dev_uuid not in target['vbd_refs']: - target['vbd_refs'].append(dev_uuid) -+ elif dev_type == 'vfb': -+ # Populate other config with aux data that is associated -+ # with vfb -+ -+ other_config = {} -+ for key in ['vncunused', 'vncdisplay', 'vnclisten', -+ 'vncpasswd', 'type', 'display', 'xauthority', -+ 'keymap']: -+ if key in dev_info: -+ other_config[key] = dev_info[key] -+ target['devices'][dev_uuid][1]['other_config'] = other_config -+ -+ -+ if 'console_refs' not in target: -+ target['console_refs'] = [] -+ -+ # Treat VFB devices as console devices so they are found -+ # through Xen API -+ if dev_uuid not in target['console_refs']: -+ target['console_refs'].append(dev_uuid) - elif dev_type in ('console',): - if 'console_refs' not in target: - target['console_refs'] = [] -@@ -1010,49 +1052,118 @@ class XendConfig(dict): - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vtpm_refs'].append(dev_uuid) - -+ elif dev_type == 'console': -+ dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) -+ dev_info['uuid'] = dev_uuid -+ dev_info['protocol'] = cfg_xenapi.get('protocol', 'rfb') -+ dev_info['other_config'] = cfg_xenapi.get('other_config', {}) -+ if dev_info['protocol'] == 'rfb': -+ # collapse other config into devinfo for things -+ # such as vncpasswd, vncunused, etc. -+ dev_info.update(cfg_xenapi.get('other_config', {})) -+ dev_info['type'] = 'vnc' -+ target['devices'][dev_uuid] = ('vfb', dev_info) -+ target['console_refs'].append(dev_uuid) -+ -+ # Finally, if we are a pvfb, we need to make a vkbd -+ # as well that is not really exposed to Xen API -+ vkbd_uuid = uuid.createString() -+ target['devices'][vkbd_uuid] = ('vkbd', {}) -+ -+ elif dev_info['protocol'] == 'vt100': -+ # if someone tries to create a VT100 console -+ # via the Xen API, we'll have to ignore it -+ # because we create one automatically in -+ # XendDomainInfo._update_consoles -+ raise XendConfigError('Creating vt100 consoles via ' -+ 'Xen API is unsupported') -+ - return dev_uuid - - # no valid device to add - return '' - - -- def console_add(self, protocol, uri): -+ def console_add(self, protocol, location, other_config = {}): - dev_uuid = uuid.createString() -- dev_info = { -- 'uuid': dev_uuid, -- 'protocol': protocol, -- 'uri': uri -- } -- if 'devices' not in self: -- self['devices'] = {} -- -- self['devices'][dev_uuid] = ('console', dev_info) -- self['console_refs'].append(dev_uuid) -- return dev_info -- -+ if protocol == 'vt100': -+ dev_info = { -+ 'uuid': dev_uuid, -+ 'protocol': protocol, -+ 'location': location, -+ 'other_config': other_config, -+ } -+ -+ if 'devices' not in self: -+ self['devices'] = {} -+ -+ self['devices'][dev_uuid] = ('console', dev_info) -+ self['console_refs'].append(dev_uuid) -+ return dev_info -+ -+ return {} -+ -+ def console_update(self, console_uuid, key, value): -+ for dev_uuid, (dev_type, dev_info) in self['devices'].items(): -+ if dev_uuid == console_uuid: -+ dev_info[key] = value -+ break -+ - def console_get_all(self, protocol): -- consoles = [dinfo for dtype, dinfo in self['devices'].values() -- if dtype == 'console'] -- return [c for c in consoles if c.get('protocol') == protocol] -+ if protocol == 'vt100': -+ consoles = [dinfo for dtype, dinfo in self['devices'].values() -+ if dtype == 'console'] -+ return [c for c in consoles if c.get('protocol') == protocol] -+ -+ elif protocol == 'rfb': -+ vfbs = [dinfo for dtype, dinfo in self['devices'].values() -+ if dtype == 'vfb'] -+ -+ # move all non-console key values to other_config before -+ # returning console config -+ valid_keys = ['uuid', 'location'] -+ for vfb in vfbs: -+ other_config = {} -+ for key, val in vfb.items(): -+ if key not in valid_keys: -+ other_config[key] = vfb[key] -+ del vfb[key] -+ vfb['other_config'] = other_config -+ vfb['protocol'] = 'rfb' -+ -+ return vfbs -+ -+ else: -+ return [] - -- def device_update(self, dev_uuid, cfg_sxp): -- """Update an existing device with the new configuration. -+ def device_update(self, dev_uuid, cfg_sxp = [], cfg_xenapi = {}): -+ """Update an existing device with the new configuration. - - @rtype: boolean - @return: Returns True if succesfully found and updated a device conf - """ -- if dev_uuid in self['devices']: -- config = sxp.child0(cfg_sxp) -- dev_type = sxp.name(config) -- dev_info = {} -+ if dev_uuid in self['devices'] and cfg_sxp: -+ if sxp.child0(cfg_sxp) == 'device': -+ config = sxp.child0(cfg_sxp) -+ else: -+ config = cfg_sxp - -- try: -- for opt, val in config[1:]: -- self['devices'][opt] = val -- except ValueError: -- pass # SXP has no options for this device -- -+ dev_type, dev_info = self['devices'][dev_uuid] -+ for opt_val in config[1:]: -+ try: -+ opt, val = opt_val -+ dev_info[opt] = val -+ except (TypeError, ValueError): -+ pass # no value for this config option -+ -+ self['devices'][dev_uuid] = (dev_type, dev_info) - return True -+ -+ elif dev_uuid in self['devices'] and cfg_xenapi: -+ dev_type, dev_info = self['devices'][dev_uuid] -+ for key, val in cfg_xenapi.items(): -+ dev_info[key] = val -+ self['devices'][dev_uuid] = (dev_type, dev_info) - - return False - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -693,16 +693,29 @@ class XendDomainInfo: - if not serial_consoles: - cfg = self.info.console_add('vt100', self.console_port) - self._createDevice('console', cfg) -+ else: -+ console_uuid = serial_consoles[0].get('uuid') -+ self.info.console_update(console_uuid, 'location', -+ self.console_port) -+ - -- # Update VNC port if it exists -+ # Update VNC port if it exists and write to xenstore - vnc_port = self.readDom('console/vnc-port') - if vnc_port is not None: -- vnc_consoles = self.info.console_get_all('rfb') -- if not vnc_consoles: -- cfg = self.info.console_add('rfb', 'localhost:%s' % -- str(vnc_port)) -- self._createDevice('console', cfg) -- -+ for dev_uuid, (dev_type, dev_info) in self.info['devices'].items(): -+ if dev_type == 'vfb': -+ old_location = dev_info.get('location') -+ listen_host = dev_info.get('vnclisten', 'localhost') -+ new_location = '%s:%s' % (listen_host, str(vnc_port)) -+ if old_location == new_location: -+ break -+ -+ dev_info['location'] = new_location -+ self.info.device_update(dev_uuid, cfg_xenapi = dev_info) -+ vfb_ctrl = self.getDeviceController('vfb') -+ vfb_ctrl.reconfigureDevice(0, dev_info) -+ break -+ - # - # Function to update xenstore /vm/* - # -@@ -1952,21 +1965,18 @@ class XendDomainInfo: - - @rtype: dictionary - """ -- dev_type_config = self.info['devices'].get(dev_uuid) -+ dev_type, dev_config = self.info['devices'].get(dev_uuid, (None, None)) - - # shortcut if the domain isn't started because - # the devcontrollers will have no better information - # than XendConfig. - if self.state in (XEN_API_VM_POWER_STATE_HALTED,): -- if dev_type_config: -- return copy.deepcopy(dev_type_config[1]) -+ if dev_config: -+ return copy.deepcopy(dev_config) - return None - - # instead of using dev_class, we use the dev_type - # that is from XendConfig. -- # This will accomdate 'tap' as well as 'vbd' -- dev_type = dev_type_config[0] -- - controller = self.getDeviceController(dev_type) - if not controller: - return None -@@ -1975,14 +1985,14 @@ class XendDomainInfo: - if not all_configs: - return None - -- dev_config = copy.deepcopy(dev_type_config[1]) -+ updated_dev_config = copy.deepcopy(dev_config) - for _devid, _devcfg in all_configs.items(): - if _devcfg.get('uuid') == dev_uuid: -- dev_config.update(_devcfg) -- dev_config['id'] = _devid -- return dev_config -+ updated_dev_config.update(_devcfg) -+ updated_dev_config['id'] = _devid -+ return updated_dev_config - -- return dev_config -+ return updated_dev_config - - def get_dev_xenapi_config(self, dev_class, dev_uuid): - config = self.get_dev_config_by_uuid(dev_class, dev_uuid) -@@ -2137,6 +2147,21 @@ class XendDomainInfo: - - return dev_uuid - -+ def create_console(self, xenapi_console): -+ """ Create a console device from a Xen API struct. -+ -+ @return: uuid of device -+ @rtype: string -+ """ -+ if self.state not in (DOM_STATE_HALTED,): -+ raise VmError("Can only add console to a halted domain.") -+ -+ dev_uuid = self.info.device_add('console', cfg_xenapi = xenapi_console) -+ if not dev_uuid: -+ raise XendError('Failed to create device') -+ -+ return dev_uuid -+ - def destroy_device_by_uuid(self, dev_type, dev_uuid): - if dev_uuid not in self.info['devices']: - raise XendError('Device does not exist') -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -26,6 +26,7 @@ import xen.lowlevel.xc - from xen.xend.XendConstants import REVERSE_DOMAIN_SHUTDOWN_REASONS - from xen.xend.XendError import VmError, XendError - from xen.xend.XendLogging import log -+from xen.xend import XendRoot - from xen.xend.server.netif import randomMAC - from xen.xend.xenstore.xswatch import xswatch - from xen.xend import arch -@@ -361,8 +362,6 @@ class HVMImageHandler(ImageHandler): - - self.pid = None - -- self.dmargs += self.configVNC(imageConfig) -- - self.pae = imageConfig['hvm'].get('pae', 1) - self.apic = imageConfig['hvm'].get('apic', 0) - self.acpi = imageConfig['hvm']['devices'].get('acpi', 0) -@@ -462,49 +461,59 @@ class HVMImageHandler(ImageHandler): - net += ",bridge=%s" % (bridge,) - ret.append(net) - -- return ret - -- def configVNC(self, imageConfig): -- # Handle graphics library related options -- vnc = imageConfig.get('vnc') -- sdl = imageConfig.get('sdl') -- ret = [] -- nographic = imageConfig.get('nographic') -+ # -+ # Find RFB console device, and if it exists, make QEMU enable -+ # the VNC console. -+ # -+ if vmConfig['image'].get('nographic'): -+ # skip vnc init if nographic is set -+ ret.append('-nographic') -+ return ret - -- # get password from VM config (if password omitted, None) -- vncpasswd_vmconfig = imageConfig.get('vncpasswd') -+ vnc_config = {} -+ has_vfb = False -+ has_vnc = int(vmConfig['image'].get('vnc')) != 0 -+ for dev_uuid in vmConfig['console_refs']: -+ dev_type, dev_info = vmConfig['devices'][devuuid] -+ if dev_type == 'rfb': -+ vnc_config = dev_info.get('other_config', {}) -+ has_vfb = True -+ break -+ -+ if not vnc_config: -+ for key in ('vncunused', 'vnclisten', 'vncdisplay', 'vncpasswd'): -+ if key in vmConfig['image']: -+ vnc_config[key] = vmConfig['image'][key] - -- if nographic: -+ if not has_vfb and not has_vnc: - ret.append('-nographic') - return ret - -- if vnc: -- vncdisplay = imageConfig.get('vncdisplay', -- int(self.vm.getDomid())) -- vncunused = imageConfig.get('vncunused') -- -- if vncunused: -- ret += ['-vncunused'] -- else: -- ret += ['-vnc', '%d' % vncdisplay] -+ -+ if not vnc_config.get('vncunused', 0) and \ -+ vnc_config.get('vncdisplay', 0): -+ ret.append('-vnc') -+ ret.append(str(vncdisplay)) -+ else: -+ ret.append('-vncunused') - -- vnclisten = imageConfig.get('vnclisten') -+ vnclisten = vnc_config.get('vnclisten', -+ XendRoot.instance().get_vnclisten_address()) -+ ret.append('-vnclisten') -+ ret.append(str(vnclisten)) -+ -+ # Store vncpassword in xenstore -+ vncpasswd = vnc_config.get('vncpasswd') -+ if not vncpasswd: -+ vncpasswd = XendRoot.instance().get_vncpasswd_default() -+ -+ if vncpasswd is None: -+ raise VmError('vncpasswd is not setup in vmconfig or ' -+ 'xend-config.sxp') - -- if not(vnclisten): -- vnclisten = (xen.xend.XendRoot.instance(). -- get_vnclisten_address()) -- if vnclisten: -- ret += ['-vnclisten', vnclisten] -- -- vncpasswd = vncpasswd_vmconfig -- if vncpasswd is None: -- vncpasswd = (xen.xend.XendRoot.instance(). -- get_vncpasswd_default()) -- if vncpasswd is None: -- raise VmError('vncpasswd is not set up in ' + -- 'VMconfig and xend-config.') -- if vncpasswd != '': -- self.vm.storeVm("vncpasswd", vncpasswd) -+ if vncpasswd != '': -+ self.vm.storeVm('vncpasswd', vncpasswd) - - return ret - -Index: xen-3.0.4-testing/tools/python/xen/xend/server/ConsoleController.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/server/ConsoleController.py -+++ xen-3.0.4-testing/tools/python/xen/xend/server/ConsoleController.py -@@ -8,7 +8,7 @@ class ConsoleController(DevController): - console devices with persistent UUIDs. - """ - -- valid_cfg = ['uri', 'uuid', 'protocol'] -+ valid_cfg = ['location', 'uuid', 'protocol'] - - def __init__(self, vm): - DevController.__init__(self, vm) -@@ -29,3 +29,7 @@ class ConsoleController(DevController): - - def migrate(self, deviceConfig, network, dst, step, domName): - return 0 -+ -+ def destroyDevice(self, devid, force): -+ DevController.destroyDevice(self, devid, True) -+ -Index: xen-3.0.4-testing/tools/python/xen/xend/server/vfbif.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/server/vfbif.py -+++ xen-3.0.4-testing/tools/python/xen/xend/server/vfbif.py -@@ -14,7 +14,9 @@ def spawn_detached(path, args, env): - os.waitpid(p, 0) - - CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused', -- 'display', 'xauthority'] -+ 'display', 'xauthority', 'keymap', -+ 'uuid', 'location', 'protocol'] -+ - - class VfbifController(DevController): - """Virtual frame buffer controller. Handles all vfb devices for a domain. -@@ -27,10 +29,11 @@ class VfbifController(DevController): - def getDeviceDetails(self, config): - """@see DevController.getDeviceDetails""" - -- back = dict([(k, config[k]) for k in CONFIG_ENTRIES -+ back = dict([(k, str(config[k])) for k in CONFIG_ENTRIES - if config.has_key(k)]) - -- return (0, back, {}) -+ devid = 0 -+ return (devid, back, {}) - - - def getDeviceConfiguration(self, devid): -@@ -44,6 +47,10 @@ class VfbifController(DevController): - - def createDevice(self, config): - DevController.createDevice(self, config) -+ if self.vm.info.get('HVM_boot'): -+ # is HVM, so qemu-dm will handle the vfb. -+ return -+ - std_args = [ "--domid", "%d" % self.vm.getDomid(), - "--title", self.vm.getName() ] - t = config.get("type", None) -@@ -80,6 +87,42 @@ class VfbifController(DevController): - else: - raise VmError('Unknown vfb type %s (%s)' % (t, repr(config))) - -+ -+ def waitForDevice(self, devid): -+ if self.vm.info.get('HVM_boot'): -+ log.debug('skip waiting for HVM vfb') -+ # is a qemu-dm managed device, don't wait for hotplug for these. -+ return -+ -+ DevController.waitForDevice(self, devid) -+ -+ -+ def reconfigureDevice(self, _, config): -+ """ Only allow appending location information of vnc port into -+ xenstore.""" -+ -+ if 'location' in config: -+ (devid, back, front) = self.getDeviceDetails(config) -+ self.writeBackend(devid, 'location', config['location']) -+ return back.get('uuid') -+ -+ raise VmError('Refusing to reconfigure device vfb:%d' % devid) -+ -+ def destroyDevice(self, devid, force): -+ if self.vm.info.get('HVM_boot'): -+ # remove the backend xenstore entries for HVM guests no matter -+ # what -+ DevController.destroyDevice(self, devid, True) -+ else: -+ DevController.destroyDevice(self, devid, force) -+ -+ -+ def migrate(self, deviceConfig, network, dst, step, domName): -+ if self.vm.info.get('HVM_boot'): -+ return 0 -+ return DevController.migrate(self, deviceConfig, network, dst, step, -+ domName) -+ - class VkbdifController(DevController): - """Virtual keyboard controller. Handles all vkbd devices for a domain. - """ -@@ -90,3 +133,24 @@ class VkbdifController(DevController): - back = {} - front = {} - return (devid, back, front) -+ -+ def waitForDevice(self, config): -+ if self.vm.info.get('HVM_boot'): -+ # is a qemu-dm managed device, don't wait for hotplug for these. -+ return -+ -+ DevController.waitForDevice(self, config) -+ -+ def destroyDevice(self, devid, force): -+ if self.vm.info.get('HVM_boot'): -+ # remove the backend xenstore entries for HVM guests no matter -+ # what -+ DevController.destroyDevice(self, devid, True) -+ else: -+ DevController.destroyDevice(self, devid, force) -+ -+ def migrate(self, deviceConfig, network, dst, step, domName): -+ if self.vm.info.get('HVM_boot'): -+ return 0 -+ return DevController.migrate(self, deviceConfig, network, dst, step, -+ domName) diff --git a/13747_xenapi.patch b/13747_xenapi.patch deleted file mode 100644 index 878a215..0000000 --- a/13747_xenapi.patch +++ /dev/null @@ -1,27 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1170255740 0 -# Node ID dfa9e5565063455d96b78a84c22e6e6b607d9f4a -# Parent f63e1244b48dd6d8c064f4ed38b7d7cf2bdf62ee -[XEND] Hide other_config from console and vfb SXP to prevent string -representation of dict to appear in SXP. - -Signed-off-by: Alastair Tse - -diff -r f63e1244b48d -r dfa9e5565063 tools/python/xen/xend/XendConfig.py ---- a/tools/python/xen/xend/XendConfig.py Wed Jan 31 15:01:09 2007 +0000 -+++ b/tools/python/xen/xend/XendConfig.py Wed Jan 31 15:02:20 2007 +0000 -@@ -1223,7 +1223,12 @@ class XendConfig(dict): - "configuration dictionary.") - - sxpr.append(dev_type) -- config = [(opt, val) for opt, val in dev_info.items()] -+ if dev_type in ('console', 'vfb'): -+ config = [(opt, val) for opt, val in dev_info.items() -+ if opt != 'other_config'] -+ else: -+ config = [(opt, val) for opt, val in dev_info.items()] -+ - sxpr += config - - return sxpr diff --git a/13753_xenapi.patch b/13753_xenapi.patch deleted file mode 100644 index 1a8d4a6..0000000 --- a/13753_xenapi.patch +++ /dev/null @@ -1,26 +0,0 @@ -# HG changeset patch -# User Alastair Tse -# Date 1170256953 0 -# Node ID 3db881ef97c44dbe749c7b3e7679f97dd959262d -# Parent beb0b36de1560f5a0094461063e48fa659398a0f -[XEND] Fix typos in vfb/vnc detect in image.py - -Signed-off-by: Alastair Tse - -diff -r beb0b36de156 -r 3db881ef97c4 tools/python/xen/xend/image.py ---- a/tools/python/xen/xend/image.py Wed Jan 31 15:08:29 2007 +0000 -+++ b/tools/python/xen/xend/image.py Wed Jan 31 15:22:33 2007 +0000 -@@ -450,10 +450,10 @@ class HVMImageHandler(ImageHandler): - - vnc_config = {} - has_vfb = False -- has_vnc = int(vmConfig['image'].get('vnc')) != 0 -+ has_vnc = int(vmConfig['image'].get('vnc', 0)) != 0 - for dev_uuid in vmConfig['console_refs']: -- dev_type, dev_info = vmConfig['devices'][devuuid] -- if dev_type == 'rfb': -+ dev_type, dev_info = vmConfig['devices'][dev_uuid] -+ if dev_type == 'vfb': - vnc_config = dev_info.get('other_config', {}) - has_vfb = True - break diff --git a/13775_xenapi.patch b/13775_xenapi.patch deleted file mode 100644 index 9a56018..0000000 --- a/13775_xenapi.patch +++ /dev/null @@ -1,24 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170343822 0 -# Node ID 868babf6b1dd2b196de7fea6a158365a0e63675c -# Parent d34d43fb88ae23e78ea90048d6c20a7255193836 -Fix HVM save/restore wrt console handling. - -From Tim Deegan . - -Signed-off-by: Ewan Mellor - -diff -r d34d43fb88ae -r 868babf6b1dd tools/python/xen/xend/XendConfig.py ---- a/tools/python/xen/xend/XendConfig.py Thu Feb 01 15:03:55 2007 +0000 -+++ b/tools/python/xen/xend/XendConfig.py Thu Feb 01 15:30:22 2007 +0000 -@@ -679,6 +679,9 @@ class XendConfig(dict): - if self['devices'][console_uuid][1].get('protocol') == 'rfb': - has_rfb = True - break -+ if self['devices'][console_uuid][0] == 'vfb': -+ has_rfb = True -+ break - - if not has_rfb: - dev_config = ['vfb'] diff --git a/13777_xenapi.patch b/13777_xenapi.patch deleted file mode 100644 index dc0cdda..0000000 --- a/13777_xenapi.patch +++ /dev/null @@ -1,41 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170343936 0 -# Node ID 1fb0302683d34317d363f5e7b627fb432f1ac19e -# Parent 2b4b07391df2d63dc419701099b04f8a0c202111 -Fix handling of HVM boot. - -Signed-off-by: Ewan Mellor - -Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py -@@ -707,6 +707,7 @@ class XendConfig(dict): - val = sxp.child_value(image_sxp, imgkey, None) - if val != None: - self[apikey] = val -+ self._hvm_boot_params_from_sxp(image_sxp) - - # extract backend value - -@@ -1310,11 +1311,18 @@ class XendConfig(dict): - val = sxp.child_value(image_sxp, imgkey, None) - if val != None: - type_conv = XENAPI_CFG_TYPES[apikey] -- if callable(conv): -+ if callable(type_conv): - self[apikey] = type_conv(val) - else: - self[apikey] = val -+ self._hvm_boot_params_from_sxp(image_sxp) - -+ -+ def _hvm_boot_params_from_sxp(self, image_sxp): -+ boot = sxp.child_value(image_sxp, 'boot', None) -+ if boot is not None: -+ self['HVM_boot_policy'] = 'BIOS order' -+ self['HVM_boot_params'] = { 'order' : boot } - - # - # debugging diff --git a/13778_xenapi.patch b/13778_xenapi.patch deleted file mode 100644 index 553d8c7..0000000 --- a/13778_xenapi.patch +++ /dev/null @@ -1,98 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170344640 0 -# Node ID f84ba62ca615e67f297820455c76f4a061e32490 -# Parent 1fb0302683d34317d363f5e7b627fb432f1ac19e -Fix SDL option for HVM domains. - -Signed-off-by: Ewan Mellor - -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -472,48 +472,50 @@ class HVMImageHandler(ImageHandler): - return ret - - vnc_config = {} -- has_vfb = False - has_vnc = int(vmConfig['image'].get('vnc', 0)) != 0 -+ has_sdl = int(vmConfig['image'].get('sdl', 0)) != 0 - for dev_uuid in vmConfig['console_refs']: - dev_type, dev_info = vmConfig['devices'][dev_uuid] - if dev_type == 'vfb': - vnc_config = dev_info.get('other_config', {}) -- has_vfb = True -+ has_vnc = True - break - -- if not vnc_config: -- for key in ('vncunused', 'vnclisten', 'vncdisplay', 'vncpasswd'): -- if key in vmConfig['image']: -- vnc_config[key] = vmConfig['image'][key] -- -- if not has_vfb and not has_vnc: -- ret.append('-nographic') -- return ret -- -- -- if not vnc_config.get('vncunused', 0) and \ -- vnc_config.get('vncdisplay', 0): -- ret.append('-vnc') -- ret.append(str(vncdisplay)) -+ if has_vnc: -+ if not vnc_config: -+ for key in ('vncunused', 'vnclisten', 'vncdisplay', -+ 'vncpasswd'): -+ if key in vmConfig['image']: -+ vnc_config[key] = vmConfig['image'][key] -+ -+ if not vnc_config.get('vncunused', 0) and \ -+ vnc_config.get('vncdisplay', 0): -+ ret.append('-vnc') -+ ret.append(str(vncdisplay)) -+ else: -+ ret.append('-vncunused') -+ -+ vnclisten = vnc_config.get('vnclisten', -+ XendRoot.instance().get_vnclisten_address()) -+ ret.append('-vnclisten') -+ ret.append(str(vnclisten)) -+ -+ # Store vncpassword in xenstore -+ vncpasswd = vnc_config.get('vncpasswd') -+ if not vncpasswd: -+ vncpasswd = XendRoot.instance().get_vncpasswd_default() -+ -+ if vncpasswd is None: -+ raise VmError('vncpasswd is not setup in vmconfig or ' -+ 'xend-config.sxp') -+ -+ if vncpasswd != '': -+ self.vm.storeVm('vncpasswd', vncpasswd) -+ elif has_sdl: -+ # SDL is default in QEMU. -+ pass - else: -- ret.append('-vncunused') -- -- vnclisten = vnc_config.get('vnclisten', -- XendRoot.instance().get_vnclisten_address()) -- ret.append('-vnclisten') -- ret.append(str(vnclisten)) -- -- # Store vncpassword in xenstore -- vncpasswd = vnc_config.get('vncpasswd') -- if not vncpasswd: -- vncpasswd = XendRoot.instance().get_vncpasswd_default() -- -- if vncpasswd is None: -- raise VmError('vncpasswd is not setup in vmconfig or ' -- 'xend-config.sxp') -- -- if vncpasswd != '': -- self.vm.storeVm('vncpasswd', vncpasswd) -+ ret.append('-nographic') - - return ret - diff --git a/13784_xenapi.patch b/13784_xenapi.patch deleted file mode 100644 index 4b5b923..0000000 --- a/13784_xenapi.patch +++ /dev/null @@ -1,131 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170353736 0 -# Node ID e0b7ab2a1d5677ba95a3f2c29eb083fc248357e2 -# Parent b32a44bfb10ccd23cd6ac71883cea65fb4c7b1a0 -Treat the empty string as an absent UUID, not an invalid one. Fix to_sxp -wrt dictionaries. - -Signed-off-by: Ewan Mellor - -diff -r b32a44bfb10c -r e0b7ab2a1d56 tools/python/xen/xend/XendConfig.py ---- a/tools/python/xen/xend/XendConfig.py Thu Feb 01 18:14:40 2007 +0000 -+++ b/tools/python/xen/xend/XendConfig.py Thu Feb 01 18:15:36 2007 +0000 -@@ -349,7 +349,6 @@ class XendConfig(dict): - - def _defaults(self): - defaults = { -- 'uuid': uuid.createString(), - 'name_label': 'Domain-Unnamed', - 'actions_after_shutdown': 'destroy', - 'actions_after_reboot': 'restart', -@@ -385,7 +384,6 @@ class XendConfig(dict): - 'other_config': {}, - } - -- defaults['name_label'] = 'Domain-' + defaults['uuid'] - return defaults - - def _memory_sanity_check(self): -@@ -415,13 +413,21 @@ class XendConfig(dict): - - def _uuid_sanity_check(self): - """Make sure UUID is in proper string format with hyphens.""" -- self['uuid'] = uuid.toString(uuid.fromString(self['uuid'])) -+ if 'uuid' not in self or not self['uuid']: -+ self['uuid'] = uuid.createString() -+ else: -+ self['uuid'] = uuid.toString(uuid.fromString(self['uuid'])) -+ -+ def _name_sanity_check(self): -+ if 'name_label' not in self: -+ self['name_label'] = 'Domain-' + self['uuid'] - - def validate(self): -+ self._uuid_sanity_check() -+ self._name_sanity_check() - self._memory_sanity_check() - self._actions_sanity_check() - self._vcpus_sanity_check() -- self._uuid_sanity_check() - - def _dominfo_to_xapi(self, dominfo): - self['domid'] = dominfo['domid'] -@@ -840,8 +846,6 @@ class XendConfig(dict): - else: - self[key] = val - -- self.validate() -- - def to_sxp(self, domain = None, ignore_devices = False, ignore = [], - legacy_only = True): - """ Get SXP representation of this config object. -@@ -865,9 +869,13 @@ class XendConfig(dict): - sxpr.append(['domid', domain.getDomid()]) - - if not legacy_only: -- for name in XENAPI_CFG_TYPES.keys(): -+ for name, typ in XENAPI_CFG_TYPES.items(): - if name in self and self[name] not in (None, []): -- sxpr.append([name, str(self[name])]) -+ if typ == dict: -+ s = self[name].items() -+ else: -+ s = str(self[name]) -+ sxpr.append([name, s]) - - for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items(): - if self.has_key(xenapi) and self[xenapi] not in (None, []): -@@ -996,7 +1004,9 @@ class XendConfig(dict): - dev_info['driver'] = 'paravirtualised' - - # create uuid if it doesn't exist -- dev_uuid = dev_info.get('uuid', uuid.createString()) -+ dev_uuid = dev_info.get('uuid', None) -+ if not dev_uuid: -+ dev_uuid = uuid.createString() - dev_info['uuid'] = dev_uuid - - # store dev references by uuid for certain device types -@@ -1066,7 +1076,9 @@ class XendConfig(dict): - if cfg_xenapi.get('name'): - dev_info['name'] = cfg_xenapi.get('name') - -- dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) -+ dev_uuid = cfg_xenapi.get('uuid', None) -+ if not dev_uuid: -+ dev_uuid = uuid.createString() - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vif_refs'].append(dev_uuid) -@@ -1090,7 +1102,9 @@ class XendConfig(dict): - else: - dev_info['mode'] = 'r' - -- dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) -+ dev_uuid = cfg_xenapi.get('uuid', None) -+ if not dev_uuid: -+ dev_uuid = uuid.createString() - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vbd_refs'].append(dev_uuid) -@@ -1099,13 +1113,17 @@ class XendConfig(dict): - if cfg_xenapi.get('type'): - dev_info['type'] = cfg_xenapi.get('type') - -- dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) -+ dev_uuid = cfg_xenapi.get('uuid', None) -+ if not dev_uuid: -+ dev_uuid = uuid.createString() - dev_info['uuid'] = dev_uuid - target['devices'][dev_uuid] = (dev_type, dev_info) - target['vtpm_refs'].append(dev_uuid) - - elif dev_type == 'console': -- dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) -+ dev_uuid = cfg_xenapi.get('uuid', None) -+ if not dev_uuid: -+ dev_uuid = uuid.createString() - dev_info['uuid'] = dev_uuid - dev_info['protocol'] = cfg_xenapi.get('protocol', 'rfb') - dev_info['other_config'] = cfg_xenapi.get('other_config', {}) diff --git a/13786_xenapi.patch b/13786_xenapi.patch deleted file mode 100644 index 4e40a60..0000000 --- a/13786_xenapi.patch +++ /dev/null @@ -1,42 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170356417 0 -# Node ID a357bed2daf8096bb5c682d454a2b3af652fc73f -# Parent 23bf61e72279682f46342d8c01977bed63ceb5be -Make the string->string map and int->float map allocation functions set the -map size on allocation. - -Signed-off-by: Ewan Mellor - -diff -r 23bf61e72279 -r a357bed2daf8 tools/libxen/src/xen_int_float_map.c ---- a/tools/libxen/src/xen_int_float_map.c Thu Feb 01 18:45:50 2007 +0000 -+++ b/tools/libxen/src/xen_int_float_map.c Thu Feb 01 19:00:17 2007 +0000 -@@ -25,8 +25,10 @@ xen_int_float_map * - xen_int_float_map * - xen_int_float_map_alloc(size_t size) - { -- return calloc(1, sizeof(xen_int_float_map) + -- size * sizeof(struct xen_int_float_map_contents)); -+ xen_int_float_map *result = calloc(1, sizeof(xen_int_float_map) + -+ size * sizeof(struct xen_int_float_map_contents)); -+ result->size = size; -+ return result; - } - - -diff -r 23bf61e72279 -r a357bed2daf8 tools/libxen/src/xen_string_string_map.c ---- a/tools/libxen/src/xen_string_string_map.c Thu Feb 01 18:45:50 2007 +0000 -+++ b/tools/libxen/src/xen_string_string_map.c Thu Feb 01 19:00:17 2007 +0000 -@@ -25,8 +25,10 @@ xen_string_string_map * - xen_string_string_map * - xen_string_string_map_alloc(size_t size) - { -- return calloc(1, sizeof(xen_string_string_map) + -- size * sizeof(struct xen_string_string_map_contents)); -+ xen_string_string_map *result = calloc(1, sizeof(xen_string_string_map) + -+ size * sizeof(struct xen_string_string_map_contents)); -+ result->size = size; -+ return result; - } - - diff --git a/13787_xenapi.patch b/13787_xenapi.patch deleted file mode 100644 index ff4c784..0000000 --- a/13787_xenapi.patch +++ /dev/null @@ -1,215 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1170356533 0 -# Node ID 0fb5df09de9426b9144eabc0d9a93c0bbfe14070 -# Parent a357bed2daf8096bb5c682d454a2b3af652fc73f -Added support for maps inside structs, so that we can send the HVM boot params -and VCPU params. - -Signed-off-by: Ewan Mellor - -diff -r a357bed2daf8 -r 0fb5df09de94 tools/libxen/src/xen_common.c ---- a/tools/libxen/src/xen_common.c Thu Feb 01 19:00:17 2007 +0000 -+++ b/tools/libxen/src/xen_common.c Thu Feb 01 19:02:13 2007 +0000 -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2006 XenSource, Inc. -+ * Copyright (c) 2006-2007 XenSource, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public -@@ -86,6 +86,8 @@ add_param_struct(xmlNode *); - add_param_struct(xmlNode *); - static xmlNode * - add_struct_array(xmlNode *, const char *); -+static xmlNode * -+add_nested_struct(xmlNode *, const char *); - static void - add_struct_member(xmlNode *, const char *, const char *, const char *); - static void -@@ -106,6 +108,9 @@ parse_structmap_value(xen_session *, xml - void *); - - static size_t size_of_member(const abstract_type *); -+ -+static const char * -+get_val_as_string(const struct abstract_type *, void *, char *); - - - void -@@ -1174,37 +1179,12 @@ add_struct_value(const struct abstract_t - switch (type->typename) - { - case REF: -- { -- arbitrary_record_opt *val = *(arbitrary_record_opt **)value; -- if (val != NULL) -- { -- if (val->is_record) -- { -- adder(node, key, "string", val->u.record->handle); -- } -- else -- { -- adder(node, key, "string", val->u.handle); -- } -- } -- } -- break; -- - case STRING: -- { -- char *val = *(char **)value; -- if (val != NULL) -- { -- adder(node, key, "string", val); -- } -- } -- break; -- - case INT: -- { -- int64_t val = *(int64_t *)value; -- snprintf(buf, sizeof(buf), "%"PRId64, val); -- adder(node, key, "string", buf); -+ case ENUM: -+ { -+ const char *val_as_string = get_val_as_string(type, value, buf); -+ adder(node, key, "string", val_as_string); - } - break; - -@@ -1220,13 +1200,6 @@ add_struct_value(const struct abstract_t - { - bool val = *(bool *)value; - adder(node, key, "boolean", val ? "1" : "0"); -- } -- break; -- -- case ENUM: -- { -- int val = *(int *)value; -- adder(node, key, "string", type->enum_marshaller(val)); - } - break; - -@@ -1251,12 +1224,95 @@ add_struct_value(const struct abstract_t - break; - - case STRUCT: -- case MAP: -- { -+ { -+ assert(false); - /* XXX Nested structures aren't supported yet, but - fortunately we don't need them, because we don't have - any "deep create" calls. This will need to be -- fixed. We don't need maps either. */ -+ fixed. */ -+ } -+ break; -+ -+ case MAP: -+ { -+ size_t member_size = type->struct_size; -+ const struct abstract_type *l_type = type->members[0].type; -+ const struct abstract_type *r_type = type->members[1].type; -+ int l_offset = type->members[0].offset; -+ int r_offset = type->members[1].offset; -+ -+ arbitrary_map *map_val = *(arbitrary_map **)value; -+ -+ if (map_val != NULL) -+ { -+ xmlNode *struct_node = add_nested_struct(node, key); -+ -+ for (size_t i = 0; i < map_val->size; i++) -+ { -+ void *contents = (void *)map_val->contents; -+ void *l_value = contents + (i * member_size) + l_offset; -+ void *r_value = contents + (i * member_size) + r_offset; -+ -+ const char *l_value_as_string = -+ get_val_as_string(l_type, l_value, buf); -+ -+ add_struct_value(r_type, r_value, add_struct_member, -+ l_value_as_string, struct_node); -+ } -+ } -+ } -+ break; -+ -+ default: -+ assert(false); -+ } -+} -+ -+ -+static const char * -+get_val_as_string(const struct abstract_type *type, void *value, char *buf) -+{ -+ switch (type->typename) -+ { -+ case REF: -+ { -+ arbitrary_record_opt *val = *(arbitrary_record_opt **)value; -+ if (val != NULL) -+ { -+ if (val->is_record) -+ { -+ return val->u.record->handle; -+ } -+ else -+ { -+ return val->u.handle; -+ } -+ } -+ else -+ { -+ return NULL; -+ } -+ } -+ break; -+ -+ case STRING: -+ { -+ return *(char **)value; -+ } -+ break; -+ -+ case INT: -+ { -+ int64_t val = *(int64_t *)value; -+ snprintf(buf, sizeof(buf), "%"PRId64, val); -+ return buf; -+ } -+ break; -+ -+ case ENUM: -+ { -+ int val = *(int *)value; -+ return type->enum_marshaller(val); - } - break; - -@@ -1331,7 +1387,19 @@ add_struct_array(xmlNode *struct_node, c - xmlNode *array_node = add_container(value_node, "array"); - - return add_container(array_node, "data"); -- -+} -+ -+ -+static xmlNode * -+add_nested_struct(xmlNode *struct_node, const char *name) -+{ -+ xmlNode *member_node = add_container(struct_node, "member"); -+ -+ xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name); -+ -+ xmlNode *value_node = add_container(member_node, "value"); -+ -+ return add_container(value_node, "struct"); - } - - diff --git a/13903-domctl.patch b/13903-domctl.patch deleted file mode 100644 index 86f5513..0000000 --- a/13903-domctl.patch +++ /dev/null @@ -1,28 +0,0 @@ -# HG changeset patch -# User kfraser@localhost.localdomain -# Date 1171456536 0 -# Node ID 929868cd37150106c4235657c959ac3376e95aa2 -# Parent d08c2af538045c16366ab5e5e99e1c4bd01f8223 -Add missing breaks to {set,get}_address_size domctls. -Signed-off-by: Gerd Hoffmann - -Index: xen-3.0.4-testing/xen/arch/x86/domctl.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domctl.c -+++ xen-3.0.4-testing/xen/arch/x86/domctl.c -@@ -318,6 +318,7 @@ _long arch_do_domctl( - - put_domain(d); - } -+ break; - - case XEN_DOMCTL_get_address_size: - { -@@ -332,6 +333,7 @@ _long arch_do_domctl( - ret = 0; - put_domain(d); - } -+ break; - - default: - ret = -ENOSYS; diff --git a/13908-domctl.patch b/13908-domctl.patch deleted file mode 100644 index 1c32a82..0000000 --- a/13908-domctl.patch +++ /dev/null @@ -1,22 +0,0 @@ -# HG changeset patch -# User kfraser@localhost.localdomain -# Date 1171468487 0 -# Node ID d44eb9e7f97b05d648dc8b0d614ffb32df667354 -# Parent 6fd71faaaa3b00250d65879750e4350b79bf0060 -Another domctl fix to insert missing copy_to_guest. -Signed-off-by: Gerd Hoffmann - -Index: xen-3.0.4-testing/xen/arch/x86/domctl.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domctl.c -+++ xen-3.0.4-testing/xen/arch/x86/domctl.c -@@ -332,6 +332,9 @@ _long arch_do_domctl( - - ret = 0; - put_domain(d); -+ -+ if ( copy_to_guest(u_domctl, domctl, 1) ) -+ ret = -EFAULT; - } - break; - diff --git a/14022_xenapi.patch b/14022_xenapi.patch deleted file mode 100644 index 2c7711f..0000000 --- a/14022_xenapi.patch +++ /dev/null @@ -1,326 +0,0 @@ -# HG changeset patch -# User Ewan Mellor -# Date 1172000304 0 -# Node ID 988b90c6b4f3b628430a73b5562e65c859953173 -# Parent be35eed950da0f39d3d41f738f340707e01c4cbd -Added Console.other_config to the docs (Xend already has this). - -Signed-off-by: Ewan Mellor - -diff -r be35eed950da -r 988b90c6b4f3 docs/xen-api/xenapi-datamodel.tex ---- a/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 19:23:28 2007 +0000 -+++ b/docs/xen-api/xenapi-datamodel.tex Tue Feb 20 19:38:24 2007 +0000 -@@ -10887,6 +10887,7 @@ Quals & Field & Type & Description \\ - $\mathit{RO}_\mathit{run}$ & {\tt protocol} & console\_protocol & the protocol used by this console \\ - $\mathit{RO}_\mathit{run}$ & {\tt location} & string & URI for the console service \\ - $\mathit{RO}_\mathit{run}$ & {\tt VM} & VM ref & VM to which this console is attached \\ -+$\mathit{RW}$ & {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\ - \hline - \end{longtable} - \subsection{Additional RPCs associated with class: console} -@@ -11015,6 +11016,145 @@ VM ref - - - value of the field -+\vspace{0.3cm} -+\vspace{0.3cm} -+\vspace{0.3cm} -+\subsubsection{RPC name:~get\_other\_config} -+ -+{\bf Overview:} -+Get the other\_config field of the given console. -+ -+ \noindent {\bf Signature:} -+\begin{verbatim} ((string -> string) Map) get_other_config (session_id s, console ref self)\end{verbatim} -+ -+ -+\noindent{\bf Arguments:} -+ -+ -+\vspace{0.3cm} -+\begin{tabular}{|c|c|p{7cm}|} -+ \hline -+{\bf type} & {\bf name} & {\bf description} \\ \hline -+{\tt console ref } & self & reference to the object \\ \hline -+ -+\end{tabular} -+ -+\vspace{0.3cm} -+ -+ \noindent {\bf Return Type:} -+{\tt -+(string $\rightarrow$ string) Map -+} -+ -+ -+value of the field -+\vspace{0.3cm} -+\vspace{0.3cm} -+\vspace{0.3cm} -+\subsubsection{RPC name:~set\_other\_config} -+ -+{\bf Overview:} -+Set the other\_config field of the given console. -+ -+ \noindent {\bf Signature:} -+\begin{verbatim} void set_other_config (session_id s, console ref self, (string -> string) Map value)\end{verbatim} -+ -+ -+\noindent{\bf Arguments:} -+ -+ -+\vspace{0.3cm} -+\begin{tabular}{|c|c|p{7cm}|} -+ \hline -+{\bf type} & {\bf name} & {\bf description} \\ \hline -+{\tt console ref } & self & reference to the object \\ \hline -+ -+{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline -+ -+\end{tabular} -+ -+\vspace{0.3cm} -+ -+ \noindent {\bf Return Type:} -+{\tt -+void -+} -+ -+ -+ -+\vspace{0.3cm} -+\vspace{0.3cm} -+\vspace{0.3cm} -+\subsubsection{RPC name:~add\_to\_other\_config} -+ -+{\bf Overview:} -+Add the given key-value pair to the other\_config field of the given -+console. -+ -+ \noindent {\bf Signature:} -+\begin{verbatim} void add_to_other_config (session_id s, console ref self, string key, string value)\end{verbatim} -+ -+ -+\noindent{\bf Arguments:} -+ -+ -+\vspace{0.3cm} -+\begin{tabular}{|c|c|p{7cm}|} -+ \hline -+{\bf type} & {\bf name} & {\bf description} \\ \hline -+{\tt console ref } & self & reference to the object \\ \hline -+ -+{\tt string } & key & Key to add \\ \hline -+ -+{\tt string } & value & Value to add \\ \hline -+ -+\end{tabular} -+ -+\vspace{0.3cm} -+ -+ \noindent {\bf Return Type:} -+{\tt -+void -+} -+ -+ -+ -+\vspace{0.3cm} -+\vspace{0.3cm} -+\vspace{0.3cm} -+\subsubsection{RPC name:~remove\_from\_other\_config} -+ -+{\bf Overview:} -+Remove the given key and its corresponding value from the other\_config -+field of the given console. If the key is not in that Map, then do -+nothing. -+ -+ \noindent {\bf Signature:} -+\begin{verbatim} void remove_from_other_config (session_id s, console ref self, string key)\end{verbatim} -+ -+ -+\noindent{\bf Arguments:} -+ -+ -+\vspace{0.3cm} -+\begin{tabular}{|c|c|p{7cm}|} -+ \hline -+{\bf type} & {\bf name} & {\bf description} \\ \hline -+{\tt console ref } & self & reference to the object \\ \hline -+ -+{\tt string } & key & Key to remove \\ \hline -+ -+\end{tabular} -+ -+\vspace{0.3cm} -+ -+ \noindent {\bf Return Type:} -+{\tt -+void -+} -+ -+ -+ - \vspace{0.3cm} - \vspace{0.3cm} - \vspace{0.3cm} -diff -r be35eed950da -r 988b90c6b4f3 tools/libxen/include/xen_console.h ---- a/tools/libxen/include/xen_console.h Tue Feb 20 19:23:28 2007 +0000 -+++ b/tools/libxen/include/xen_console.h Tue Feb 20 19:38:24 2007 +0000 -@@ -22,6 +22,7 @@ - #include "xen_common.h" - #include "xen_console_decl.h" - #include "xen_console_protocol.h" -+#include "xen_string_string_map.h" - #include "xen_vm_decl.h" - - -@@ -67,6 +68,7 @@ typedef struct xen_console_record - enum xen_console_protocol protocol; - char *location; - struct xen_vm_record_opt *vm; -+ xen_string_string_map *other_config; - } xen_console_record; - - /** -@@ -204,4 +206,35 @@ xen_console_get_vm(xen_session *session, - xen_console_get_vm(xen_session *session, xen_vm *result, xen_console console); - - -+/** -+ * Get the other_config field of the given console. -+ */ -+extern bool -+xen_console_get_other_config(xen_session *session, xen_string_string_map **result, xen_console console); -+ -+ -+/** -+ * Set the other_config field of the given console. -+ */ -+extern bool -+xen_console_set_other_config(xen_session *session, xen_console console, xen_string_string_map *other_config); -+ -+ -+/** -+ * Add the given key-value pair to the other_config field of the given -+ * console. -+ */ -+extern bool -+xen_console_add_to_other_config(xen_session *session, xen_console console, char *key, char *value); -+ -+ -+/** -+ * Remove the given key and its corresponding value from the -+ * other_config field of the given console. If the key is not in that Map, -+ * then do nothing. -+ */ -+extern bool -+xen_console_remove_from_other_config(xen_session *session, xen_console console, char *key); -+ -+ - #endif -diff -r be35eed950da -r 988b90c6b4f3 tools/libxen/src/xen_console.c ---- a/tools/libxen/src/xen_console.c Tue Feb 20 19:23:28 2007 +0000 -+++ b/tools/libxen/src/xen_console.c Tue Feb 20 19:38:24 2007 +0000 -@@ -24,6 +24,7 @@ - #include "xen_console.h" - #include "xen_console_protocol_internal.h" - #include "xen_internal.h" -+#include "xen_string_string_map.h" - #include "xen_vm.h" - - -@@ -49,7 +50,10 @@ static const struct_member xen_console_r - .offset = offsetof(xen_console_record, location) }, - { .key = "VM", - .type = &abstract_type_ref, -- .offset = offsetof(xen_console_record, vm) } -+ .offset = offsetof(xen_console_record, vm) }, -+ { .key = "other_config", -+ .type = &abstract_type_string_string_map, -+ .offset = offsetof(xen_console_record, other_config) } - }; - - const abstract_type xen_console_record_abstract_type_ = -@@ -73,6 +77,7 @@ xen_console_record_free(xen_console_reco - free(record->uuid); - free(record->location); - xen_vm_record_opt_free(record->vm); -+ xen_string_string_map_free(record->other_config); - free(record); - } - -@@ -198,6 +203,73 @@ xen_console_get_vm(xen_session *session, - - - bool -+xen_console_get_other_config(xen_session *session, xen_string_string_map **result, xen_console console) -+{ -+ abstract_value param_values[] = -+ { -+ { .type = &abstract_type_string, -+ .u.string_val = console } -+ }; -+ -+ abstract_type result_type = abstract_type_string_string_map; -+ -+ *result = NULL; -+ XEN_CALL_("console.get_other_config"); -+ return session->ok; -+} -+ -+ -+bool -+xen_console_set_other_config(xen_session *session, xen_console console, xen_string_string_map *other_config) -+{ -+ abstract_value param_values[] = -+ { -+ { .type = &abstract_type_string, -+ .u.string_val = console }, -+ { .type = &abstract_type_string_string_map, -+ .u.set_val = (arbitrary_set *)other_config } -+ }; -+ -+ xen_call_(session, "console.set_other_config", param_values, 2, NULL, NULL); -+ return session->ok; -+} -+ -+ -+bool -+xen_console_add_to_other_config(xen_session *session, xen_console console, char *key, char *value) -+{ -+ abstract_value param_values[] = -+ { -+ { .type = &abstract_type_string, -+ .u.string_val = console }, -+ { .type = &abstract_type_string, -+ .u.string_val = key }, -+ { .type = &abstract_type_string, -+ .u.string_val = value } -+ }; -+ -+ xen_call_(session, "console.add_to_other_config", param_values, 3, NULL, NULL); -+ return session->ok; -+} -+ -+ -+bool -+xen_console_remove_from_other_config(xen_session *session, xen_console console, char *key) -+{ -+ abstract_value param_values[] = -+ { -+ { .type = &abstract_type_string, -+ .u.string_val = console }, -+ { .type = &abstract_type_string, -+ .u.string_val = key } -+ }; -+ -+ xen_call_(session, "console.remove_from_other_config", param_values, 2, NULL, NULL); -+ return session->ok; -+} -+ -+ -+bool - xen_console_get_uuid(xen_session *session, char **result, xen_console console) - { - *result = session->ok ? xen_strdup_((char *)console) : NULL; diff --git a/32on64-acmop.patch b/32on64-acmop.patch deleted file mode 100644 index ec496b2..0000000 --- a/32on64-acmop.patch +++ /dev/null @@ -1,147 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_acm_op. - -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:00.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:01.000000000 +0100 -@@ -278,7 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_acm_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous - #define compat_domctl domain_crash_synchronous -Index: 2007-01-08/xen/common/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/Makefile 2007-01-08 15:19:22.000000000 +0100 -+++ 2007-01-08/xen/common/Makefile 2007-01-08 15:20:01.000000000 +0100 -@@ -42,6 +42,7 @@ version.o: $(BASEDIR)/include/xen/compil - - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies -+acm_ops.o: compat/acm_ops.c - grant_table.o: compat/grant_table.c - schedule.o: compat/schedule.c - endif -Index: 2007-01-08/xen/common/acm_ops.c -=================================================================== ---- 2007-01-08.orig/xen/common/acm_ops.c 2007-01-08 15:04:23.000000000 +0100 -+++ 2007-01-08/xen/common/acm_ops.c 2007-01-08 15:20:01.000000000 +0100 -@@ -15,6 +15,7 @@ - * - */ - -+#ifndef COMPAT - #include - #include - #include -@@ -28,6 +29,10 @@ - #include - #include - -+typedef long ret_t; -+ -+#endif /* !COMPAT */ -+ - #ifndef ACM_SECURITY - - -@@ -40,6 +45,7 @@ long do_acm_op(int cmd, XEN_GUEST_HANDLE - #else - - -+#ifndef COMPAT - int acm_authorize_acm_ops(struct domain *d) - { - /* currently, policy management functions are restricted to privileged domains */ -@@ -47,11 +53,12 @@ int acm_authorize_acm_ops(struct domain - return -EPERM; - return 0; - } -+#endif - - --long do_acm_op(int cmd, XEN_GUEST_HANDLE(void) arg) -+ret_t do_acm_op(int cmd, XEN_GUEST_HANDLE(void) arg) - { -- long rc = -EFAULT; -+ ret_t rc = -EFAULT; - - if (acm_authorize_acm_ops(current->domain)) - return -EPERM; -@@ -219,6 +226,10 @@ long do_acm_op(int cmd, XEN_GUEST_HANDLE - - #endif - -+#if defined(CONFIG_COMPAT) && !defined(COMPAT) -+#include "compat/acm_ops.c" -+#endif -+ - /* - * Local variables: - * mode: C -Index: 2007-01-08/xen/common/compat/acm_ops.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/acm_ops.c 2007-01-08 15:20:01.000000000 +0100 -@@ -0,0 +1,47 @@ -+/****************************************************************************** -+ * compat/acm_ops.c -+ */ -+ -+#include -+#include -+ -+#define COMPAT -+#define ret_t int -+ -+#define do_acm_op compat_acm_op -+ -+static inline XEN_GUEST_HANDLE(void) acm_xlat_handle(COMPAT_HANDLE(void) cmp) -+{ -+ XEN_GUEST_HANDLE(void) nat; -+ -+ guest_from_compat_handle(nat, cmp); -+ return nat; -+} -+ -+#define acm_setpolicy compat_acm_setpolicy -+#define acm_set_policy(h, sz) acm_set_policy(acm_xlat_handle(h), sz) -+ -+#define acm_getpolicy compat_acm_getpolicy -+#define acm_get_policy(h, sz) acm_get_policy(acm_xlat_handle(h), sz) -+ -+#define acm_dumpstats compat_acm_dumpstats -+#define acm_dump_statistics(h, sz) acm_dump_statistics(acm_xlat_handle(h), sz) -+ -+#define acm_getssid compat_acm_getssid -+#define acm_get_ssid(r, h, sz) acm_get_ssid(r, acm_xlat_handle(h), sz) -+ -+#define xen_acm_getdecision acm_getdecision -+CHECK_acm_getdecision; -+#undef xen_acm_getdecision -+ -+#include "../acm_ops.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:19:22.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:20:24.000000000 +0100 -@@ -9,6 +9,7 @@ - ! cpu_user_regs arch-@arch@/xen-@subarch@.h - ! trap_info arch-@arch@/xen.h - ! vcpu_guest_context arch-@arch@/xen.h -+? acm_getdecision acm_ops.h - ? evtchn_alloc_unbound event_channel.h - ? evtchn_bind_interdomain event_channel.h - ? evtchn_bind_ipi event_channel.h diff --git a/32on64-base.patch b/32on64-base.patch deleted file mode 100644 index bc4695f..0000000 --- a/32on64-base.patch +++ /dev/null @@ -1,1058 +0,0 @@ -Introduce _DOMF_compat and infrastructure as well as several conditionals -dealing with operations that need to distinguish between native and -compatibility mode guests. - -Index: 2007-01-08/config/x86_64.mk -=================================================================== ---- 2007-01-08.orig/config/x86_64.mk 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/config/x86_64.mk 2007-01-08 14:45:40.000000000 +0100 -@@ -2,6 +2,7 @@ CONFIG_X86 := y - CONFIG_X86_64 := y - CONFIG_X86_$(XEN_OS) := y - -+CONFIG_COMPAT := y - CONFIG_HVM := y - CONFIG_MIGRATE := y - CONFIG_XCUTILS := y -Index: 2007-01-08/tools/libxc/xc_linux_build.c -=================================================================== ---- 2007-01-08.orig/tools/libxc/xc_linux_build.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/tools/libxc/xc_linux_build.c 2007-01-08 14:45:40.000000000 +0100 -@@ -595,6 +595,7 @@ static int compat_check(int xc_handle, s - return 0; - } - -+#ifndef __x86_64__//temp - if (strstr(xen_caps, "xen-3.0-x86_32p")) { - if (dsi->pae_kernel == PAEKERN_bimodal) { - dsi->pae_kernel = PAEKERN_extended_cr3; -@@ -612,6 +613,7 @@ static int compat_check(int xc_handle, s - return 0; - } - } -+#endif - - return 1; - } -Index: 2007-01-08/xen/arch/x86/boot/x86_64.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/boot/x86_64.S 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/boot/x86_64.S 2007-01-08 14:45:40.000000000 +0100 -@@ -226,15 +226,34 @@ high_start: - .align PAGE_SIZE, 0 - ENTRY(gdt_table) - .quad 0x0000000000000000 /* unused */ -- .quad 0x00cf9a000000ffff /* 0xe008 ring 0 code, compatibility */ -- .quad 0x00af9a000000ffff /* 0xe010 ring 0 code, 64-bit mode */ -- .quad 0x00cf92000000ffff /* 0xe018 ring 0 data */ -+ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ -+ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ -+ .quad 0x0000000000000000 /* reserved */ - .quad 0x00cffa000000ffff /* 0xe023 ring 3 code, compatibility */ - .quad 0x00cff2000000ffff /* 0xe02b ring 3 data */ - .quad 0x00affa000000ffff /* 0xe033 ring 3 code, 64-bit mode */ -- .quad 0x0000000000000000 /* unused */ -+ .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */ -+ .org gdt_table - FIRST_RESERVED_GDT_BYTE + __TSS(0) * 8 - .fill 4*NR_CPUS,8,0 /* space for TSS and LDT per CPU */ - -+#ifdef CONFIG_COMPAT -+ .align PAGE_SIZE, 0 -+/* NB. Even rings != 0 get access to the full 4Gb, as only the */ -+/* (compatibility) machine->physical mapping table lives there. */ -+ENTRY(compat_gdt_table) -+ .quad 0x0000000000000000 /* unused */ -+ .quad 0x00af9a000000ffff /* 0xe008 ring 0 code, 64-bit mode */ -+ .quad 0x00cf92000000ffff /* 0xe010 ring 0 data */ -+ .quad 0x00cfba000000ffff /* 0xe019 ring 1 code, compatibility */ -+ .quad 0x00cfb2000000ffff /* 0xe021 ring 1 data */ -+ .quad 0x00cffa000000ffff /* 0xe02b ring 3 code, compatibility */ -+ .quad 0x00cff2000000ffff /* 0xe033 ring 3 data */ -+ .quad 0x00cf9a000000ffff /* 0xe038 ring 0 code, compatibility */ -+ .org compat_gdt_table - FIRST_RESERVED_GDT_BYTE + __TSS(0) * 8 -+ .fill 4*NR_CPUS,8,0 /* space for TSS and LDT per CPU */ -+# undef LIMIT -+#endif -+ - /* Initial PML4 -- level-4 page table. */ - .align PAGE_SIZE, 0 - ENTRY(idle_pg_table) -Index: 2007-01-08/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain.c 2007-01-08 14:45:40.000000000 +0100 -@@ -287,17 +287,18 @@ int arch_set_info_guest( - - if ( !is_hvm_vcpu(v) ) - { -- fixup_guest_stack_selector(c->user_regs.ss); -- fixup_guest_stack_selector(c->kernel_ss); -- fixup_guest_code_selector(c->user_regs.cs); -- --#ifdef __i386__ -- fixup_guest_code_selector(c->event_callback_cs); -- fixup_guest_code_selector(c->failsafe_callback_cs); --#endif -+ fixup_guest_stack_selector(d, c->user_regs.ss); -+ fixup_guest_stack_selector(d, c->kernel_ss); -+ fixup_guest_code_selector(d, c->user_regs.cs); -+ -+ if ( CONFIG_PAGING_LEVELS < 4 || IS_COMPAT(d) ) -+ { -+ fixup_guest_code_selector(d, c->event_callback_cs); -+ fixup_guest_code_selector(d, c->failsafe_callback_cs); -+ } - - for ( i = 0; i < 256; i++ ) -- fixup_guest_code_selector(c->trap_ctxt[i].cs); -+ fixup_guest_code_selector(d, c->trap_ctxt[i].cs); - - /* LDT safety checks. */ - if ( ((c->ldt_base & (PAGE_SIZE-1)) != 0) || -@@ -502,27 +503,30 @@ static void load_segments(struct vcpu *n - all_segs_okay &= loadsegment(gs, nctxt->user_regs.gs); - } - -- /* This can only be non-zero if selector is NULL. */ -- if ( nctxt->fs_base ) -- wrmsr(MSR_FS_BASE, -- nctxt->fs_base, -- nctxt->fs_base>>32); -- -- /* Most kernels have non-zero GS base, so don't bother testing. */ -- /* (This is also a serialising instruction, avoiding AMD erratum #88.) */ -- wrmsr(MSR_SHADOW_GS_BASE, -- nctxt->gs_base_kernel, -- nctxt->gs_base_kernel>>32); -- -- /* This can only be non-zero if selector is NULL. */ -- if ( nctxt->gs_base_user ) -- wrmsr(MSR_GS_BASE, -- nctxt->gs_base_user, -- nctxt->gs_base_user>>32); -- -- /* If in kernel mode then switch the GS bases around. */ -- if ( n->arch.flags & TF_kernel_mode ) -- __asm__ __volatile__ ( "swapgs" ); -+ if ( !IS_COMPAT(n->domain) ) -+ { -+ /* This can only be non-zero if selector is NULL. */ -+ if ( nctxt->fs_base ) -+ wrmsr(MSR_FS_BASE, -+ nctxt->fs_base, -+ nctxt->fs_base>>32); -+ -+ /* Most kernels have non-zero GS base, so don't bother testing. */ -+ /* (This is also a serialising instruction, avoiding AMD erratum #88.) */ -+ wrmsr(MSR_SHADOW_GS_BASE, -+ nctxt->gs_base_kernel, -+ nctxt->gs_base_kernel>>32); -+ -+ /* This can only be non-zero if selector is NULL. */ -+ if ( nctxt->gs_base_user ) -+ wrmsr(MSR_GS_BASE, -+ nctxt->gs_base_user, -+ nctxt->gs_base_user>>32); -+ -+ /* If in kernel mode then switch the GS bases around. */ -+ if ( (n->arch.flags & TF_kernel_mode) ) -+ __asm__ __volatile__ ( "swapgs" ); -+ } - - if ( unlikely(!all_segs_okay) ) - { -@@ -533,6 +537,55 @@ static void load_segments(struct vcpu *n - (unsigned long *)nctxt->kernel_sp; - unsigned long cs_and_mask, rflags; - -+ if ( IS_COMPAT(n->domain) ) -+ { -+ unsigned int *esp = ring_1(regs) ? -+ (unsigned int *)regs->rsp : -+ (unsigned int *)nctxt->kernel_sp; -+ unsigned int cs_and_mask, eflags; -+ int ret = 0; -+ -+ /* CS longword also contains full evtchn_upcall_mask. */ -+ cs_and_mask = (unsigned short)regs->cs | -+ ((unsigned int)n->vcpu_info->evtchn_upcall_mask << 16); -+ /* Fold upcall mask into RFLAGS.IF. */ -+ eflags = regs->_eflags & ~X86_EFLAGS_IF; -+ eflags |= !n->vcpu_info->evtchn_upcall_mask << 9; -+ -+ if ( !ring_1(regs) ) -+ { -+ ret = put_user(regs->ss, esp-1); -+ ret |= put_user(regs->_esp, esp-2); -+ esp -= 2; -+ } -+ -+ if ( ret | -+ put_user(eflags, esp-1) | -+ put_user(cs_and_mask, esp-2) | -+ put_user(regs->_eip, esp-3) | -+ put_user(nctxt->user_regs.gs, esp-4) | -+ put_user(nctxt->user_regs.fs, esp-5) | -+ put_user(nctxt->user_regs.es, esp-6) | -+ put_user(nctxt->user_regs.ds, esp-7) ) -+ { -+ gdprintk(XENLOG_ERR, "Error while creating compat " -+ "failsafe callback frame.\n"); -+ domain_crash(n->domain); -+ } -+ -+ if ( test_bit(_VGCF_failsafe_disables_events, -+ &n->arch.guest_context.flags) ) -+ n->vcpu_info->evtchn_upcall_mask = 1; -+ -+ regs->entry_vector = TRAP_syscall; -+ regs->_eflags &= 0xFFFCBEFFUL; -+ regs->ss = FLAT_COMPAT_KERNEL_SS; -+ regs->_esp = (unsigned long)(esp-7); -+ regs->cs = FLAT_COMPAT_KERNEL_CS; -+ regs->_eip = nctxt->failsafe_callback_eip; -+ return; -+ } -+ - if ( !(n->arch.flags & TF_kernel_mode) ) - toggle_guest_mode(n); - else -@@ -594,7 +647,7 @@ static void save_segments(struct vcpu *v - if ( regs->es ) - dirty_segment_mask |= DIRTY_ES; - -- if ( regs->fs ) -+ if ( regs->fs || IS_COMPAT(v->domain) ) - { - dirty_segment_mask |= DIRTY_FS; - ctxt->fs_base = 0; /* != 0 selector kills fs_base */ -@@ -604,7 +657,7 @@ static void save_segments(struct vcpu *v - dirty_segment_mask |= DIRTY_FS_BASE; - } - -- if ( regs->gs ) -+ if ( regs->gs || IS_COMPAT(v->domain) ) - { - dirty_segment_mask |= DIRTY_GS; - ctxt->gs_base_user = 0; /* != 0 selector kills gs_base_user */ -@@ -736,6 +789,23 @@ void context_switch(struct vcpu *prev, s - { - __context_switch(); - -+#ifdef CONFIG_COMPAT -+ if ( is_idle_vcpu(prev) -+ || IS_COMPAT(prev->domain) != IS_COMPAT(next->domain) ) -+ { -+ uint32_t efer_lo, efer_hi; -+ -+ local_flush_tlb_one(GDT_VIRT_START(next) + FIRST_RESERVED_GDT_BYTE); -+ -+ rdmsr(MSR_EFER, efer_lo, efer_hi); -+ if ( !IS_COMPAT(next->domain) == !(efer_lo & EFER_SCE) ) -+ { -+ efer_lo ^= EFER_SCE; -+ wrmsr(MSR_EFER, efer_lo, efer_hi); -+ } -+ } -+#endif -+ - /* Re-enable interrupts before restoring state which may fault. */ - local_irq_enable(); - -@@ -948,6 +1018,10 @@ void domain_relinquish_resources(struct - put_page(mfn_to_page(pfn)); - else - put_page_and_type(mfn_to_page(pfn)); -+#ifdef __x86_64__ -+ if ( pfn == pagetable_get_pfn(v->arch.guest_table_user) ) -+ v->arch.guest_table_user = pagetable_null(); -+#endif - v->arch.guest_table = pagetable_null(); - } - -Index: 2007-01-08/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain_build.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain_build.c 2007-01-08 15:34:55.000000000 +0100 -@@ -319,10 +319,38 @@ int construct_dom0(struct domain *d, - - nr_pages = compute_dom0_nr_pages(); - -- if ( (rc = parseelfimage(&dsi)) != 0 ) -- return rc; -+ rc = parseelfimage(&dsi); -+#ifdef CONFIG_COMPAT -+ if ( rc == -ENOSYS -+ && (rc = parseelf32image(&dsi)) == 0 ) -+ { -+ l1_pgentry_t gdt_l1e; -+ -+ set_bit(_DOMF_compat, &d->domain_flags); -+ -+ if ( nr_pages != (unsigned int)nr_pages ) -+ nr_pages = UINT_MAX; -+ -+ /* -+ * Map compatibility Xen segments into every VCPU's GDT. See -+ * arch_domain_create() for further comments. -+ */ -+ gdt_l1e = l1e_from_page(virt_to_page(compat_gdt_table), -+ PAGE_HYPERVISOR); -+ for ( i = 0; i < MAX_VIRT_CPUS; i++ ) -+ d->arch.mm_perdomain_pt[((i << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; -+ local_flush_tlb_one(GDT_LDT_VIRT_START + FIRST_RESERVED_GDT_BYTE); -+ } -+#endif -+ if ( rc != 0) -+ { -+ if ( rc == -ENOSYS ) -+ printk("DOM0 image is not a Xen-compatible Elf image.\n"); -+ return rc; -+ } - -- xen_pae = (CONFIG_PAGING_LEVELS == 3); -+ xen_pae = (CONFIG_PAGING_LEVELS == 3) || IS_COMPAT(d); - if (dsi.pae_kernel == PAEKERN_bimodal) - dom0_pae = xen_pae; - else -@@ -338,7 +366,13 @@ int construct_dom0(struct domain *d, - dsi.pae_kernel == PAEKERN_bimodal) ) - set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist); - -- if ( (p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES)) != NULL ) -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ p = xen_elf32note_string(&dsi, XEN_ELFNOTE_FEATURES); -+ else -+#endif -+ p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES); -+ if ( p != NULL ) - { - parse_features(p, - dom0_features_supported, -@@ -590,6 +624,12 @@ int construct_dom0(struct domain *d, - return -EINVAL; - } - -+ if ( IS_COMPAT(d) ) -+ { -+ v->arch.guest_context.failsafe_callback_cs = FLAT_COMPAT_KERNEL_CS; -+ v->arch.guest_context.event_callback_cs = FLAT_COMPAT_KERNEL_CS; -+ } -+ - /* WARNING: The new domain must have its 'processor' field filled in! */ - maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table; - l4start = l4tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; -@@ -599,6 +639,8 @@ int construct_dom0(struct domain *d, - l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] = - l4e_from_paddr(__pa(d->arch.mm_perdomain_l3), __PAGE_HYPERVISOR); - v->arch.guest_table = pagetable_from_paddr(__pa(l4start)); -+ if ( IS_COMPAT(d) ) -+ v->arch.guest_table_user = v->arch.guest_table; - - l4tab += l4_table_offset(dsi.v_start); - mfn = alloc_spfn; -@@ -711,10 +753,20 @@ int construct_dom0(struct domain *d, - write_ptbase(v); - - /* Copy the OS image and free temporary buffer. */ -- (void)loadelfimage(&dsi); -- -- hypercall_page = -- xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &hypercall_page_defined); -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ { -+ (void)loadelf32image(&dsi); -+ hypercall_page = -+ xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &hypercall_page_defined); -+ } -+ else -+#endif -+ { -+ (void)loadelfimage(&dsi); -+ hypercall_page = -+ xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &hypercall_page_defined); -+ } - if ( hypercall_page_defined ) - { - if ( (hypercall_page < dsi.v_start) || (hypercall_page >= v_end) ) -@@ -747,7 +799,7 @@ int construct_dom0(struct domain *d, - si->mfn_list = vphysmap_start; - sprintf(si->magic, "xen-%i.%i-x86_%d%s", - xen_major_version(), xen_minor_version(), -- BITS_PER_LONG, xen_pae ? "p" : ""); -+ !IS_COMPAT(d) ? BITS_PER_LONG : 32, xen_pae ? "p" : ""); - - /* Write the phys->machine and machine->phys table entries. */ - for ( pfn = 0; pfn < d->tot_pages; pfn++ ) -@@ -819,9 +871,11 @@ int construct_dom0(struct domain *d, - * [EAX,EBX,ECX,EDX,EDI,EBP are zero] - */ - regs = &v->arch.guest_context.user_regs; -- regs->ds = regs->es = regs->fs = regs->gs = FLAT_KERNEL_DS; -- regs->ss = FLAT_KERNEL_SS; -- regs->cs = FLAT_KERNEL_CS; -+ regs->ds = regs->es = regs->fs = regs->gs = !IS_COMPAT(d) -+ ? FLAT_KERNEL_DS -+ : FLAT_COMPAT_KERNEL_DS; -+ regs->ss = !IS_COMPAT(d) ? FLAT_KERNEL_SS : FLAT_COMPAT_KERNEL_SS; -+ regs->cs = !IS_COMPAT(d) ? FLAT_KERNEL_CS : FLAT_COMPAT_KERNEL_CS; - regs->eip = dsi.v_kernentry; - regs->esp = vstack_end; - regs->esi = vstartinfo_start; -@@ -906,13 +960,28 @@ int elf_sanity_check(const Elf_Ehdr *ehd - (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) || - (ehdr->e_type != ET_EXEC) ) - { -- printk("DOM0 image is not a Xen-compatible Elf image.\n"); - return 0; - } - - return 1; - } - -+#ifdef CONFIG_COMPAT -+int elf32_sanity_check(const Elf32_Ehdr *ehdr) -+{ -+ if ( !IS_ELF(*ehdr) || -+ (ehdr->e_ident[EI_CLASS] != ELFCLASS32) || -+ (ehdr->e_machine != EM_386) || -+ (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) || -+ (ehdr->e_type != ET_EXEC) ) -+ { -+ return 0; -+ } -+ -+ return 1; -+} -+#endif -+ - /* - * Local variables: - * mode: C -Index: 2007-01-08/xen/arch/x86/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/mm.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/mm.c 2007-01-08 14:45:40.000000000 +0100 -@@ -401,7 +401,7 @@ static int alloc_segdesc_page(struct pag - descs = map_domain_page(page_to_mfn(page)); - - for ( i = 0; i < 512; i++ ) -- if ( unlikely(!check_descriptor(&descs[i])) ) -+ if ( unlikely(!check_descriptor(page_get_owner(page), &descs[i])) ) - goto fail; - - unmap_domain_page(descs); -@@ -2833,7 +2833,7 @@ long do_update_descriptor(u64 pa, u64 de - mfn = gmfn_to_mfn(dom, gmfn); - if ( (((unsigned int)pa % sizeof(struct desc_struct)) != 0) || - !mfn_valid(mfn) || -- !check_descriptor(&d) ) -+ !check_descriptor(dom, &d) ) - { - UNLOCK_BIGLOCK(dom); - return -EINVAL; -Index: 2007-01-08/xen/arch/x86/setup.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/setup.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/setup.c 2007-01-08 14:45:40.000000000 +0100 -@@ -791,6 +791,9 @@ void arch_get_xen_caps(xen_capabilities_ - #elif defined(CONFIG_X86_64) - - p += sprintf(p, "xen-%d.%d-x86_64 ", major, minor); -+#ifdef CONFIG_COMPAT -+ p += sprintf(p, "xen-%d.%d-x86_32p ", major, minor); -+#endif - if ( hvm_enabled ) - { - p += sprintf(p, "hvm-%d.%d-x86_32 ", major, minor); -Index: 2007-01-08/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/traps.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/traps.c 2007-01-08 14:45:40.000000000 +0100 -@@ -398,7 +398,7 @@ static int do_guest_trap( - if ( TI_GET_IF(ti) ) - tb->flags |= TBF_INTERRUPT; - -- if ( unlikely(null_trap_bounce(tb)) ) -+ if ( unlikely(null_trap_bounce(v, tb)) ) - gdprintk(XENLOG_WARNING, "Unhandled %s fault/trap [#%d] in " - "domain %d on VCPU %d [ec=%04x]\n", - trapstr(trapnr), trapnr, v->domain->domain_id, v->vcpu_id, -@@ -689,7 +689,7 @@ void propagate_page_fault(unsigned long - tb->eip = ti->address; - if ( TI_GET_IF(ti) ) - tb->flags |= TBF_INTERRUPT; -- if ( unlikely(null_trap_bounce(tb)) ) -+ if ( unlikely(null_trap_bounce(v, tb)) ) - { - printk("Unhandled page fault in domain %d on VCPU %d (ec=%04X)\n", - v->domain->domain_id, v->vcpu_id, error_code); -@@ -1801,6 +1801,13 @@ void set_tss_desc(unsigned int n, void * - (unsigned long)addr, - offsetof(struct tss_struct, __cacheline_filler) - 1, - 9); -+#ifdef CONFIG_COMPAT -+ _set_tssldt_desc( -+ compat_gdt_table + __TSS(n) - FIRST_RESERVED_GDT_ENTRY, -+ (unsigned long)addr, -+ offsetof(struct tss_struct, __cacheline_filler) - 1, -+ 11); -+#endif - } - - void __init trap_init(void) -@@ -1875,7 +1882,7 @@ long do_set_trap_table(XEN_GUEST_HANDLE( - if ( cur.address == 0 ) - break; - -- fixup_guest_code_selector(cur.cs); -+ fixup_guest_code_selector(current->domain, cur.cs); - - memcpy(&dst[cur.vector], &cur, sizeof(cur)); - -Index: 2007-01-08/xen/arch/x86/x86_32/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_32/mm.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_32/mm.c 2007-01-08 14:45:40.000000000 +0100 -@@ -230,7 +230,7 @@ long do_stack_switch(unsigned long ss, u - int nr = smp_processor_id(); - struct tss_struct *t = &init_tss[nr]; - -- fixup_guest_stack_selector(ss); -+ fixup_guest_stack_selector(current->domain, ss); - - current->arch.guest_context.kernel_ss = ss; - current->arch.guest_context.kernel_sp = esp; -@@ -241,7 +241,7 @@ long do_stack_switch(unsigned long ss, u - } - - /* Returns TRUE if given descriptor is valid for GDT or LDT. */ --int check_descriptor(struct desc_struct *d) -+int check_descriptor(const struct domain *dom, struct desc_struct *d) - { - unsigned long base, limit; - u32 a = d->a, b = d->b; -@@ -261,8 +261,8 @@ int check_descriptor(struct desc_struct - * gates (consider a call gate pointing at another kernel descriptor with - * DPL 0 -- this would get the OS ring-0 privileges). - */ -- if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) ) -- d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13); -+ if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL(dom) << 13) ) -+ d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL(dom) << 13); - - if ( !(b & _SEGMENT_S) ) - { -@@ -284,8 +284,8 @@ int check_descriptor(struct desc_struct - - /* Validate and fix up the target code selector. */ - cs = a >> 16; -- fixup_guest_code_selector(cs); -- if ( !guest_gate_selector_okay(cs) ) -+ fixup_guest_code_selector(dom, cs); -+ if ( !guest_gate_selector_okay(dom, cs) ) - goto bad; - a = d->a = (d->a & 0xffffU) | (cs << 16); - -Index: 2007-01-08/xen/arch/x86/x86_32/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_32/traps.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_32/traps.c 2007-01-08 14:45:40.000000000 +0100 -@@ -296,7 +296,7 @@ void init_int80_direct_trap(struct vcpu - * switch to the Xen stack and we need to swap back to the guest - * kernel stack before passing control to the system call entry point. - */ -- if ( TI_GET_IF(ti) || !guest_gate_selector_okay(ti->cs) || -+ if ( TI_GET_IF(ti) || !guest_gate_selector_okay(v->domain, ti->cs) || - supervisor_mode_kernel ) - { - v->arch.int80_desc.a = v->arch.int80_desc.b = 0; -@@ -326,7 +326,7 @@ static long register_guest_callback(stru - long ret = 0; - struct vcpu *v = current; - -- fixup_guest_code_selector(reg->address.cs); -+ fixup_guest_code_selector(v->domain, reg->address.cs); - - switch ( reg->type ) - { -Index: 2007-01-08/xen/arch/x86/x86_64/asm-offsets.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/asm-offsets.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/asm-offsets.c 2007-01-08 14:45:40.000000000 +0100 -@@ -58,12 +58,16 @@ void __dummy__(void) - OFFSET(VCPU_thread_flags, struct vcpu, arch.flags); - OFFSET(VCPU_event_addr, struct vcpu, - arch.guest_context.event_callback_eip); -+ OFFSET(VCPU_event_sel, struct vcpu, -+ arch.guest_context.event_callback_cs); - OFFSET(VCPU_failsafe_addr, struct vcpu, - arch.guest_context.failsafe_callback_eip); -+ OFFSET(VCPU_failsafe_sel, struct vcpu, -+ arch.guest_context.failsafe_callback_cs); - OFFSET(VCPU_syscall_addr, struct vcpu, - arch.guest_context.syscall_callback_eip); -- OFFSET(VCPU_kernel_sp, struct vcpu, -- arch.guest_context.kernel_sp); -+ OFFSET(VCPU_kernel_sp, struct vcpu, arch.guest_context.kernel_sp); -+ OFFSET(VCPU_kernel_ss, struct vcpu, arch.guest_context.kernel_ss); - OFFSET(VCPU_guest_context_flags, struct vcpu, arch.guest_context.flags); - OFFSET(VCPU_arch_guest_fpu_ctxt, struct vcpu, arch.guest_context.fpu_ctxt); - OFFSET(VCPU_flags, struct vcpu, vcpu_flags); -Index: 2007-01-08/xen/arch/x86/x86_64/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/mm.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/mm.c 2007-01-08 14:45:40.000000000 +0100 -@@ -231,7 +231,7 @@ long subarch_memory_op(int op, XEN_GUEST - - long do_stack_switch(unsigned long ss, unsigned long esp) - { -- fixup_guest_stack_selector(ss); -+ fixup_guest_stack_selector(current->domain, ss); - current->arch.guest_context.kernel_ss = ss; - current->arch.guest_context.kernel_sp = esp; - return 0; -@@ -291,7 +291,7 @@ long do_set_segment_base(unsigned int wh - - - /* Returns TRUE if given descriptor is valid for GDT or LDT. */ --int check_descriptor(struct desc_struct *d) -+int check_descriptor(const struct domain *dom, struct desc_struct *d) - { - u32 a = d->a, b = d->b; - u16 cs; -@@ -301,8 +301,8 @@ int check_descriptor(struct desc_struct - goto good; - - /* Check and fix up the DPL. */ -- if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL << 13) ) -- d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL << 13); -+ if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL(dom) << 13) ) -+ d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL(dom) << 13); - - /* All code and data segments are okay. No base/limit checking. */ - if ( (b & _SEGMENT_S) ) -@@ -318,8 +318,8 @@ int check_descriptor(struct desc_struct - - /* Validate and fix up the target code selector. */ - cs = a >> 16; -- fixup_guest_code_selector(cs); -- if ( !guest_gate_selector_okay(cs) ) -+ fixup_guest_code_selector(dom, cs); -+ if ( !guest_gate_selector_okay(dom, cs) ) - goto bad; - a = d->a = (d->a & 0xffffU) | (cs << 16); - -Index: 2007-01-08/xen/arch/x86/x86_64/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/traps.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/traps.c 2007-01-08 14:45:40.000000000 +0100 -@@ -178,6 +178,8 @@ asmlinkage void do_double_fault(struct c - - void toggle_guest_mode(struct vcpu *v) - { -+ if ( IS_COMPAT(v->domain) ) -+ return; - v->arch.flags ^= TF_kernel_mode; - __asm__ __volatile__ ( "swapgs" ); - update_cr3(v); -Index: 2007-01-08/xen/common/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/Makefile 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/common/Makefile 2007-01-08 14:45:40.000000000 +0100 -@@ -3,6 +3,7 @@ obj-y += bitmap.o - obj-y += domctl.o - obj-y += domain.o - obj-y += elf.o -+obj-$(CONFIG_COMPAT) += elf32.o - obj-y += event_channel.o - obj-y += grant_table.o - obj-y += kernel.o -Index: 2007-01-08/xen/common/elf.c -=================================================================== ---- 2007-01-08.orig/xen/common/elf.c 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/common/elf.c 2007-01-08 14:45:40.000000000 +0100 -@@ -203,7 +203,7 @@ int parseelfimage(struct domain_setup_in - int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined; - - if ( !elf_sanity_check(ehdr) ) -- return -EINVAL; -+ return -ENOSYS; - - if ( (ehdr->e_phoff + (ehdr->e_phnum*ehdr->e_phentsize)) > image_len ) - { -Index: 2007-01-08/xen/common/elf32.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/elf32.c 2007-01-08 14:45:40.000000000 +0100 -@@ -0,0 +1,19 @@ -+/****************************************************************************** -+ * elf32.c -+ * -+ * Stub to support 32-bit ELF images on 64-bit platforms. -+ */ -+ -+#include -+#undef ELFSIZE -+#define ELFSIZE 32 -+#include -+#include -+ -+#define xen_elfnote_string xen_elf32note_string -+#define xen_elfnote_numeric xen_elf32note_numeric -+#define parseelfimage parseelf32image -+#define loadelfimage loadelf32image -+#define elf_sanity_check elf32_sanity_check -+ -+#include "elf.c" -Index: 2007-01-08/xen/include/asm-x86/config.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/config.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/config.h 2007-01-08 14:45:40.000000000 +0100 -@@ -91,6 +91,7 @@ extern unsigned long _end; /* standard E - #if defined(__x86_64__) - - #define CONFIG_X86_64 1 -+#define CONFIG_COMPAT 1 - - #define asmlinkage - -@@ -185,13 +186,21 @@ extern unsigned long _end; /* standard E - #define DIRECTMAP_VIRT_START (PML4_ADDR(262)) - #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*2) - -+#define __HYPERVISOR_COMPAT_VIRT_START 0xF5800000 -+#define HYPERVISOR_COMPAT_VIRT_START \ -+ mk_unsigned_long(__HYPERVISOR_COMPAT_VIRT_START) -+#define MACH2PHYS_COMPAT_VIRT_START HYPERVISOR_COMPAT_VIRT_START -+#define MACH2PHYS_COMPAT_VIRT_END 0xFFE00000 -+#define MACH2PHYS_COMPAT_NR_ENTRIES \ -+ ((MACH2PHYS_COMPAT_VIRT_END-MACH2PHYS_COMPAT_VIRT_START)>>2) -+ - #define PGT_base_page_table PGT_l4_page_table - --#define __HYPERVISOR_CS64 0xe010 --#define __HYPERVISOR_CS32 0xe008 -+#define __HYPERVISOR_CS64 0xe008 -+#define __HYPERVISOR_CS32 0xe038 - #define __HYPERVISOR_CS __HYPERVISOR_CS64 - #define __HYPERVISOR_DS64 0x0000 --#define __HYPERVISOR_DS32 0xe018 -+#define __HYPERVISOR_DS32 0xe010 - #define __HYPERVISOR_DS __HYPERVISOR_DS64 - - /* For generic assembly code: use macros to define operation/operand sizes. */ -Index: 2007-01-08/xen/include/asm-x86/desc.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/desc.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/desc.h 2007-01-08 14:45:40.000000000 +0100 -@@ -18,31 +18,76 @@ - - #define LDT_ENTRY_SIZE 8 - -+#if defined(__x86_64__) -+ -+#define FLAT_COMPAT_RING1_CS 0xe019 /* GDT index 259 */ -+#define FLAT_COMPAT_RING1_DS 0xe021 /* GDT index 260 */ -+#define FLAT_COMPAT_RING1_SS 0xe021 /* GDT index 260 */ -+#define FLAT_COMPAT_RING3_CS 0xe02b /* GDT index 261 */ -+#define FLAT_COMPAT_RING3_DS 0xe033 /* GDT index 262 */ -+#define FLAT_COMPAT_RING3_SS 0xe033 /* GDT index 262 */ -+ -+#define FLAT_COMPAT_KERNEL_DS FLAT_COMPAT_RING1_DS -+#define FLAT_COMPAT_KERNEL_CS FLAT_COMPAT_RING1_CS -+#define FLAT_COMPAT_KERNEL_SS FLAT_COMPAT_RING1_SS -+#define FLAT_COMPAT_USER_DS FLAT_COMPAT_RING3_DS -+#define FLAT_COMPAT_USER_CS FLAT_COMPAT_RING3_CS -+#define FLAT_COMPAT_USER_SS FLAT_COMPAT_RING3_SS -+ -+#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) -+#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 2) -+ -+#define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY) -+#define __LDT(n) (((n)<<2) + __FIRST_LDT_ENTRY) -+ -+#elif defined(__i386__) -+ -+#define FLAT_COMPAT_KERNEL_CS FLAT_KERNEL_CS -+#define FLAT_COMPAT_KERNEL_DS FLAT_KERNEL_DS -+#define FLAT_COMPAT_KERNEL_SS FLAT_KERNEL_SS -+#define FLAT_COMPAT_USER_CS FLAT_USER_CS -+#define FLAT_COMPAT_USER_DS FLAT_USER_DS -+#define FLAT_COMPAT_USER_SS FLAT_USER_SS -+ -+#define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY -+ -+#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) -+#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 1) -+ -+#define __TSS(n) (((n)<<1) + __FIRST_TSS_ENTRY) -+#define __LDT(n) (((n)<<1) + __FIRST_LDT_ENTRY) -+ -+#endif -+ -+#ifndef __ASSEMBLY__ -+ - #define load_TR(n) __asm__ __volatile__ ("ltr %%ax" : : "a" (__TSS(n)<<3) ) - - #if defined(__x86_64__) --#define GUEST_KERNEL_RPL 3 -+#define GUEST_KERNEL_RPL(d) (!IS_COMPAT(d) ? 3 : 1) - #elif defined(__i386__) --#define GUEST_KERNEL_RPL 1 -+#define GUEST_KERNEL_RPL(d) ((void)(d), 1) - #endif - - /* Fix up the RPL of a guest segment selector. */ --#define __fixup_guest_selector(sel) \ -- ((sel) = (((sel) & 3) >= GUEST_KERNEL_RPL) ? (sel) : \ -- (((sel) & ~3) | GUEST_KERNEL_RPL)) -+#define __fixup_guest_selector(d, sel) \ -+({ \ -+ uint16_t _rpl = GUEST_KERNEL_RPL(d); \ -+ (sel) = (((sel) & 3) >= _rpl) ? (sel) : (((sel) & ~3) | _rpl); \ -+}) - - /* Stack selectors don't need fixing up if the kernel runs in ring 0. */ - #ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL --#define fixup_guest_stack_selector(ss) ((void)0) -+#define fixup_guest_stack_selector(d, ss) ((void)0) - #else --#define fixup_guest_stack_selector(ss) __fixup_guest_selector(ss) -+#define fixup_guest_stack_selector(d, ss) __fixup_guest_selector(d, ss) - #endif - - /* - * Code selectors are always fixed up. It allows the Xen exit stub to detect - * return to guest context, even when the guest kernel runs in ring 0. - */ --#define fixup_guest_code_selector(cs) __fixup_guest_selector(cs) -+#define fixup_guest_code_selector(d, cs) __fixup_guest_selector(d, cs) - - /* - * We need this function because enforcing the correct guest kernel RPL is -@@ -57,11 +102,15 @@ - * DPL < CPL then they'll be cleared automatically. If SS RPL or DPL differs - * from CS RPL then we'll #GP. - */ --#define guest_gate_selector_okay(sel) \ -+#define guest_gate_selector_okay(d, sel) \ - ((((sel)>>3) < FIRST_RESERVED_GDT_ENTRY) || /* Guest seg? */ \ -- ((sel) == FLAT_KERNEL_CS) || /* Xen default seg? */ \ -+ ((sel) == (!IS_COMPAT(d) ? \ -+ FLAT_KERNEL_CS : /* Xen default seg? */ \ -+ FLAT_COMPAT_KERNEL_CS)) || /* Xen default compat seg? */ \ - ((sel) & 4)) /* LDT seg? */ - -+#endif /* __ASSEMBLY__ */ -+ - /* These are bitmasks for the high 32 bits of a descriptor table entry. */ - #define _SEGMENT_TYPE (15<< 8) - #define _SEGMENT_EC ( 1<<10) /* Expand-down or Conforming segment */ -@@ -81,12 +130,6 @@ struct desc_struct { - - #if defined(__x86_64__) - --#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) --#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 2) -- --#define __TSS(n) (((n)<<2) + __FIRST_TSS_ENTRY) --#define __LDT(n) (((n)<<2) + __FIRST_LDT_ENTRY) -- - typedef struct { - u64 a, b; - } idt_entry_t; -@@ -118,14 +161,6 @@ do { - - #elif defined(__i386__) - --#define __DOUBLEFAULT_TSS_ENTRY FIRST_RESERVED_GDT_ENTRY -- --#define __FIRST_TSS_ENTRY (FIRST_RESERVED_GDT_ENTRY + 8) --#define __FIRST_LDT_ENTRY (__FIRST_TSS_ENTRY + 1) -- --#define __TSS(n) (((n)<<1) + __FIRST_TSS_ENTRY) --#define __LDT(n) (((n)<<1) + __FIRST_LDT_ENTRY) -- - typedef struct desc_struct idt_entry_t; - - #define _set_gate(gate_addr,type,dpl,addr) \ -@@ -155,6 +190,11 @@ __asm__ __volatile__ ("movw %w3,0(%2)\n\ - #endif - - extern struct desc_struct gdt_table[]; -+#ifdef CONFIG_COMPAT -+extern struct desc_struct compat_gdt_table[]; -+#else -+# define compat_gdt_table gdt_table -+#endif - - struct Xgt_desc_struct { - unsigned short size; -Index: 2007-01-08/xen/include/asm-x86/ldt.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/ldt.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/ldt.h 2007-01-08 14:45:40.000000000 +0100 -@@ -17,7 +17,8 @@ static inline void load_LDT(struct vcpu - else - { - cpu = smp_processor_id(); -- desc = gdt_table + __LDT(cpu) - FIRST_RESERVED_GDT_ENTRY; -+ desc = (!IS_COMPAT(v->domain) ? gdt_table : compat_gdt_table) -+ + __LDT(cpu) - FIRST_RESERVED_GDT_ENTRY; - _set_tssldt_desc(desc, LDT_VIRT_START(v), ents*8-1, 2); - __asm__ __volatile__ ( "lldt %%ax" : : "a" (__LDT(cpu)<<3) ); - } -Index: 2007-01-08/xen/include/asm-x86/mm.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/mm.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/mm.h 2007-01-08 14:45:40.000000000 +0100 -@@ -244,7 +244,7 @@ unsigned long - pae_copy_root(struct vcpu *v, l3_pgentry_t *l3tab); - #endif /* CONFIG_PAGING_LEVELS == 3 */ - --int check_descriptor(struct desc_struct *d); -+int check_descriptor(const struct domain *, struct desc_struct *d); - - /* - * The MPT (machine->physical mapping table) is an array of word-sized -Index: 2007-01-08/xen/include/asm-x86/regs.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/regs.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/regs.h 2007-01-08 14:45:40.000000000 +0100 -@@ -38,7 +38,8 @@ enum EFLAGS { - ASSERT(diff < STACK_SIZE); \ - /* If a guest frame, it must be have guest privs (unless HVM guest). */ \ - /* We permit CS==0 which can come from an uninitialised trap entry. */ \ -- ASSERT((diff != 0) || vm86_mode(r) || ((r->cs&3) >= GUEST_KERNEL_RPL) || \ -+ ASSERT((diff != 0) || vm86_mode(r) || \ -+ ((r->cs&3) >= GUEST_KERNEL_RPL(current->domain)) || \ - (r->cs == 0) || is_hvm_vcpu(current)); \ - /* If not a guest frame, it must be a hypervisor frame. */ \ - ASSERT((diff == 0) || (!vm86_mode(r) && (r->cs == __HYPERVISOR_CS))); \ -Index: 2007-01-08/xen/include/asm-x86/x86_32/regs.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/x86_32/regs.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/x86_32/regs.h 2007-01-08 14:45:40.000000000 +0100 -@@ -17,7 +17,7 @@ - ((dpl) >= (vm86_mode(r) ? 3 : ((r)->cs & 3))) - - /* Check for null trap callback handler: Is the selector null (0-3)? */ --#define null_trap_bounce(tb) (((tb)->cs & ~3) == 0) -+#define null_trap_bounce(v, tb) (((tb)->cs & ~3) == 0) - - /* Number of bytes of on-stack execution state to be context-switched. */ - #define CTXT_SWITCH_STACK_BYTES (sizeof(struct cpu_user_regs)) -Index: 2007-01-08/xen/include/asm-x86/x86_64/regs.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/x86_64/regs.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/x86_64/regs.h 2007-01-08 14:45:40.000000000 +0100 -@@ -11,13 +11,16 @@ - #define ring_3(r) (((r)->cs & 3) == 3) - - #define guest_kernel_mode(v, r) \ -- (ring_3(r) && ((v)->arch.flags & TF_kernel_mode)) -+ (!IS_COMPAT((v)->domain) ? \ -+ ring_3(r) && ((v)->arch.flags & TF_kernel_mode) : \ -+ ring_1(r)) - - #define permit_softint(dpl, v, r) \ - ((dpl) >= (guest_kernel_mode(v, r) ? 1 : 3)) - - /* Check for null trap callback handler: Is the EIP null? */ --#define null_trap_bounce(tb) ((tb)->eip == 0) -+#define null_trap_bounce(v, tb) \ -+ (!IS_COMPAT((v)->domain) ? (tb)->eip == 0 : ((tb)->cs & ~3) == 0) - - /* Number of bytes of on-stack execution state to be context-switched. */ - /* NB. Segment registers and bases are not saved/restored on x86/64 stack. */ -Index: 2007-01-08/xen/include/public/arch-x86/xen.h -=================================================================== ---- 2007-01-08.orig/xen/include/public/arch-x86/xen.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/public/arch-x86/xen.h 2007-01-08 14:52:24.000000000 +0100 -@@ -141,8 +141,18 @@ struct vcpu_guest_context { - #else - unsigned long event_callback_eip; - unsigned long failsafe_callback_eip; -+#ifdef __XEN__ -+ union { -+ unsigned long syscall_callback_eip; -+ struct { -+ unsigned int event_callback_cs; /* compat CS of event cb */ -+ unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */ -+ }; -+ }; -+#else - unsigned long syscall_callback_eip; - #endif -+#endif - unsigned long vm_assist; /* VMASST_TYPE_* bitmap */ - #ifdef __x86_64__ - /* Segment base addresses. */ -Index: 2007-01-08/xen/include/public/arch-x86/xen-x86_64.h -=================================================================== ---- 2007-01-08.orig/xen/include/public/arch-x86/xen-x86_64.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/public/arch-x86/xen-x86_64.h 2007-01-08 14:52:13.000000000 +0100 -@@ -141,7 +141,10 @@ struct iret_context { - - #ifdef __GNUC__ - /* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */ --#define __DECL_REG(name) union { uint64_t r ## name, e ## name; } -+#define __DECL_REG(name) union { \ -+ uint64_t r ## name, e ## name; \ -+ uint32_t _e ## name; \ -+} - #else - /* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */ - #define __DECL_REG(name) uint64_t r ## name -Index: 2007-01-08/xen/include/xen/elf.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/elf.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/xen/elf.h 2007-01-08 14:47:11.000000000 +0100 -@@ -525,6 +525,15 @@ extern unsigned long long xen_elfnote_nu - int type, int *defined); - extern const char *xen_elfnote_string(struct domain_setup_info *dsi, int type); - -+#ifdef CONFIG_COMPAT -+extern int elf32_sanity_check(const Elf32_Ehdr *ehdr); -+extern int loadelf32image(struct domain_setup_info *); -+extern int parseelf32image(struct domain_setup_info *); -+extern unsigned long long xen_elf32note_numeric(struct domain_setup_info *, -+ int type, int *defined); -+extern const char *xen_elf32note_string(struct domain_setup_info *, int type); -+#endif -+ - #ifdef Elf_Ehdr - extern int elf_sanity_check(const Elf_Ehdr *ehdr); - #endif -Index: 2007-01-08/xen/include/xen/sched.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/sched.h 2007-01-08 15:34:30.000000000 +0100 -+++ 2007-01-08/xen/include/xen/sched.h 2007-01-08 14:45:40.000000000 +0100 -@@ -422,6 +422,9 @@ extern struct domain *domain_list; - /* Domain is paused by the hypervisor? */ - #define _DOMF_paused 5 - #define DOMF_paused (1UL<<_DOMF_paused) -+ /* Domain is a compatibility one? */ -+#define _DOMF_compat 6 -+#define DOMF_compat (1UL<<_DOMF_compat) - - static inline int vcpu_runnable(struct vcpu *v) - { -@@ -458,6 +461,13 @@ static inline void vcpu_unblock(struct v - - #define IS_PRIV(_d) ((_d)->is_privileged) - -+#ifdef CONFIG_COMPAT -+#define IS_COMPAT(_d) \ -+ (test_bit(_DOMF_compat, &(_d)->domain_flags)) -+#else -+#define IS_COMPAT(_d) 0 -+#endif -+ - #define VM_ASSIST(_d,_t) (test_bit((_t), &(_d)->vm_assist)) - - #define is_hvm_domain(d) ((d)->is_hvm) diff --git a/32on64-call-gates.patch b/32on64-call-gates.patch deleted file mode 100644 index 34fcfea..0000000 --- a/32on64-call-gates.patch +++ /dev/null @@ -1,484 +0,0 @@ -Index: 2007-01-31/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/traps.c 2007-01-31 09:39:19.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/traps.c 2007-01-31 09:41:46.000000000 +0100 -@@ -1051,6 +1051,63 @@ static int read_descriptor(unsigned int - return 1; - } - -+#ifdef CONFIG_COMPAT/* XXX __x86_64__ */ -+static int read_gate_descriptor(unsigned int gate_sel, -+ const struct vcpu *v, -+ unsigned int *sel, -+ unsigned long *off, -+ unsigned int *ar) -+{ -+ struct desc_struct desc; -+ const struct desc_struct *pdesc; -+ -+ -+ pdesc = (const struct desc_struct *)(!(gate_sel & 4) ? -+ GDT_VIRT_START(v) : -+ LDT_VIRT_START(v)) -+ + (gate_sel >> 3); -+ if ( gate_sel < 4 || -+ (gate_sel >= FIRST_RESERVED_GDT_BYTE && !(gate_sel & 4)) || -+ __get_user(desc, pdesc) ) -+ return 0; -+ -+ *sel = (desc.a >> 16) & 0x0000fffc; -+ *off = (desc.a & 0x0000ffff) | (desc.b & 0xffff0000); -+ *ar = desc.b & 0x0000ffff; -+ /* -+ * check_descriptor() clears the DPL field and stores the -+ * guest requested DPL in the selector's RPL field. -+ */ -+ ASSERT(!(*ar & _SEGMENT_DPL)); -+ *ar |= (desc.a >> (16 - 13)) & _SEGMENT_DPL; -+ -+ if ( !IS_COMPAT(v->domain) ) -+ { -+ if ( (*ar & 0x1f00) != 0x0c00 || -+ (gate_sel >= FIRST_RESERVED_GDT_BYTE - 8 && !(gate_sel & 4)) || -+ __get_user(desc, pdesc + 1) || -+ (desc.b & 0x1f00) ) -+ return 0; -+ -+ *off |= (unsigned long)desc.a << 32; -+ return 1; -+ } -+ -+ switch ( *ar & 0x1f00 ) -+ { -+ case 0x0400: -+ *off &= 0xffff; -+ break; -+ case 0x0c00: -+ break; -+ default: -+ return 0; -+ } -+ -+ return 1; -+} -+#endif -+ - /* Has the guest requested sufficient permission for this I/O access? */ - static inline int guest_io_okay( - unsigned int port, unsigned int bytes, -@@ -1118,6 +1175,8 @@ unsigned long guest_to_host_gpr_switch(u - #define insn_fetch(type, base, eip, limit) \ - ({ unsigned long _rc, _ptr = (base) + (eip); \ - type _x; \ -+ if ( ad_default < 8 ) \ -+ _ptr = (unsigned int)_ptr; \ - if ( (limit) < sizeof(_x) - 1 || (eip) > (limit) - (sizeof(_x) - 1) ) \ - goto fail; \ - if ( (_rc = copy_from_user(&_x, (type *)_ptr, sizeof(_x))) != 0 ) \ -@@ -1714,6 +1773,336 @@ static int emulate_privileged_op(struct - return 0; - } - -+static inline int check_stack_limit(unsigned int ar, unsigned int limit, -+ unsigned int esp, unsigned int decr) -+{ -+ return esp - decr < esp - 1 && -+ (!(ar & _SEGMENT_EC) ? esp - 1 <= limit : esp - decr > limit); -+} -+ -+static int emulate_gate_op(struct cpu_user_regs *regs) -+{ -+#ifdef CONFIG_COMPAT/* XXX __x86_64__ */ -+ struct vcpu *v = current; -+ unsigned int sel, ar, dpl, nparm, opnd_sel; -+ unsigned int op_default, op_bytes, ad_default, ad_bytes; -+ unsigned long off, eip, opnd_off, base, limit; -+ int jump; -+ -+ /* Check whether this fault is due to the use of a call gate. */ -+ if ( !read_gate_descriptor(regs->error_code, v, &sel, &off, &ar) || -+ ((ar >> 13) & 3) < (regs->cs & 3) || -+ (ar & _SEGMENT_TYPE) != 0xc00 ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ if ( !(ar & _SEGMENT_P) ) -+ return do_guest_trap(TRAP_no_segment, regs, 1); -+ dpl = (ar >> 13) & 3; -+ nparm = ar & 0x1f; -+ -+ /* -+ * Decode instruction (and perhaps operand) to determine RPL, -+ * whether this is a jump or a call, and the call return offset. -+ */ -+ if ( !read_descriptor(regs->cs, v, regs, &base, &limit, &ar, 0) || -+ !(ar & _SEGMENT_S) || -+ !(ar & _SEGMENT_P) || -+ !(ar & _SEGMENT_CODE) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ -+ op_bytes = op_default = ar & _SEGMENT_DB ? 4 : 2; -+ ad_default = ad_bytes = op_default; -+ opnd_sel = opnd_off = 0; -+ jump = -1; -+ for ( eip = regs->eip; eip - regs->_eip < 10; ) -+ { -+ switch ( insn_fetch(u8, base, eip, limit) ) -+ { -+ case 0x66: /* operand-size override */ -+ op_bytes = op_default ^ 6; /* switch between 2/4 bytes */ -+ continue; -+ case 0x67: /* address-size override */ -+ ad_bytes = ad_default != 4 ? 4 : 2; /* switch to 2/4 bytes */ -+ continue; -+ case 0x2e: /* CS override */ -+ opnd_sel = regs->cs; -+ ASSERT(opnd_sel); -+ continue; -+ case 0x3e: /* DS override */ -+ opnd_sel = read_sreg(regs, ds); -+ if ( !opnd_sel ) -+ opnd_sel = dpl; -+ continue; -+ case 0x26: /* ES override */ -+ opnd_sel = read_sreg(regs, es); -+ if ( !opnd_sel ) -+ opnd_sel = dpl; -+ continue; -+ case 0x64: /* FS override */ -+ opnd_sel = read_sreg(regs, fs); -+ if ( !opnd_sel ) -+ opnd_sel = dpl; -+ continue; -+ case 0x65: /* GS override */ -+ opnd_sel = read_sreg(regs, gs); -+ if ( !opnd_sel ) -+ opnd_sel = dpl; -+ continue; -+ case 0x36: /* SS override */ -+ opnd_sel = regs->ss; -+ if ( !opnd_sel ) -+ opnd_sel = dpl; -+ continue; -+ case 0xea: -+ ++jump; -+ /* FALLTHROUGH */ -+ case 0x9a: -+ ++jump; -+ opnd_sel = regs->cs; -+ opnd_off = eip; -+ ad_bytes = ad_default; -+ eip += op_bytes + 2; -+ break; -+ case 0xff: -+ { -+ unsigned int modrm; -+ -+ switch ( (modrm = insn_fetch(u8, base, eip, limit)) & 0xf8 ) -+ { -+ case 0x28: case 0x68: case 0xa8: -+ ++jump; -+ /* FALLTHROUGH */ -+ case 0x18: case 0x58: case 0x98: -+ ++jump; -+ if ( ad_bytes != 2 ) -+ { -+ if ( (modrm & 7) == 4 ) -+ { -+ unsigned int sib = insn_fetch(u8, base, eip, limit); -+ -+ modrm = (modrm & ~7) | (sib & 7); -+ if ( (sib >>= 3) != 4 ) -+ opnd_off = *(unsigned long *)decode_register(sib & 7, regs, 0); -+ opnd_off <<= sib >> 3; -+ } -+ if ( (modrm & 7) != 5 || (modrm & 0xc0) ) -+ opnd_off += *(unsigned long *)decode_register(modrm & 7, regs, 0); -+ else -+ modrm |= 0x87; -+ if ( !opnd_sel ) -+ { -+ switch ( modrm & 7 ) -+ { -+ default: -+ opnd_sel = read_sreg(regs, ds); -+ break; -+ case 4: case 5: -+ opnd_sel = regs->ss; -+ break; -+ } -+ } -+ } -+ else -+ { -+ switch ( modrm & 7 ) -+ { -+ case 0: case 1: case 7: -+ opnd_off = regs->ebx; -+ break; -+ case 6: -+ if ( !(modrm & 0xc0) ) -+ modrm |= 0x80; -+ else -+ case 2: case 3: -+ { -+ opnd_off = regs->ebp; -+ if ( !opnd_sel ) -+ opnd_sel = regs->ss; -+ } -+ break; -+ } -+ if ( !opnd_sel ) -+ opnd_sel = read_sreg(regs, ds); -+ switch ( modrm & 7 ) -+ { -+ case 0: case 2: case 4: -+ opnd_off += regs->esi; -+ break; -+ case 1: case 3: case 5: -+ opnd_off += regs->edi; -+ break; -+ } -+ } -+ switch ( modrm & 0xc0 ) -+ { -+ case 0x40: -+ opnd_off += insn_fetch(s8, base, eip, limit); -+ break; -+ case 0x80: -+ opnd_off += insn_fetch(s32, base, eip, limit); -+ break; -+ } -+ if ( ad_bytes == 4 ) -+ opnd_off = (unsigned int)opnd_off; -+ else if ( ad_bytes == 2 ) -+ opnd_off = (unsigned short)opnd_off; -+ break; -+ } -+ } -+ break; -+ } -+ break; -+ } -+ -+ if ( jump < 0 ) -+ { -+ fail: -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ } -+ -+ if ( (opnd_sel != regs->cs && -+ !read_descriptor(opnd_sel, v, regs, &base, &limit, &ar, 0)) || -+ !(ar & _SEGMENT_S) || -+ !(ar & _SEGMENT_P) || -+ ((ar & _SEGMENT_CODE) && !(ar & _SEGMENT_WR)) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ -+ opnd_off += op_bytes; -+#define ad_default ad_bytes -+ opnd_sel = insn_fetch(u16, base, opnd_off, limit); -+#undef ad_default -+ ASSERT((opnd_sel & ~3) == regs->error_code); -+ if ( dpl < (opnd_sel & 3) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ -+ if ( !read_descriptor(sel, v, regs, &base, &limit, &ar, 0) || -+ !(ar & _SEGMENT_S) || -+ !(ar & _SEGMENT_CODE) || -+ (!jump || (ar & _SEGMENT_EC) ? -+ ((ar >> 13) & 3) > (regs->cs & 3) : -+ ((ar >> 13) & 3) != (regs->cs & 3)) ) -+ { -+ regs->error_code = sel; -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ } -+ if ( !(ar & _SEGMENT_P) ) -+ { -+ regs->error_code = sel; -+ return do_guest_trap(TRAP_no_segment, regs, 1); -+ } -+ if ( off > limit ) -+ { -+ regs->error_code = 0; -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ } -+ -+ if ( !jump ) -+ { -+ unsigned int ss, esp, *stkp; -+ int rc; -+#define push(item) do \ -+ { \ -+ --stkp; \ -+ esp -= 4; \ -+ rc = __put_user(item, stkp); \ -+ if ( rc ) \ -+ { \ -+ propagate_page_fault((unsigned long)(stkp + 1) - rc, \ -+ PFEC_write_access); \ -+ return 0; \ -+ } \ -+ } while ( 0 ) -+ -+ if ( ((ar >> 13) & 3) < (regs->cs & 3) ) -+ { -+ sel |= (ar >> 13) & 3; -+ /* Inner stack known only for kernel ring. */ -+ if ( (sel & 3) != GUEST_KERNEL_RPL(v->domain) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ esp = v->arch.guest_context.kernel_sp; -+ ss = v->arch.guest_context.kernel_ss; -+ if ( (ss & 3) != (sel & 3) || -+ !read_descriptor(ss, v, regs, &base, &limit, &ar, 0) || -+ ((ar >> 13) & 3) != (sel & 3) || -+ !(ar & _SEGMENT_S) || -+ (ar & _SEGMENT_CODE) || -+ !(ar & _SEGMENT_WR) ) -+ { -+ regs->error_code = ss & ~3; -+ return do_guest_trap(TRAP_invalid_tss, regs, 1); -+ } -+ if ( !(ar & _SEGMENT_P) || -+ !check_stack_limit(ar, limit, esp, (4 + nparm) * 4) ) -+ { -+ regs->error_code = ss & ~3; -+ return do_guest_trap(TRAP_stack_error, regs, 1); -+ } -+ stkp = (unsigned int *)(unsigned long)((unsigned int)base + esp); -+ if ( !compat_access_ok(stkp - 4 - nparm, (4 + nparm) * 4) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ push(regs->ss); -+ push(regs->esp); -+ if ( nparm ) -+ { -+ const unsigned int *ustkp; -+ -+ if ( !read_descriptor(regs->ss, v, regs, &base, &limit, &ar, 0) || -+ ((ar >> 13) & 3) != (regs->cs & 3) || -+ !(ar & _SEGMENT_S) || -+ (ar & _SEGMENT_CODE) || -+ !(ar & _SEGMENT_WR) || -+ !check_stack_limit(ar, limit, esp + nparm * 4, nparm * 4) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ ustkp = (unsigned int *)(unsigned long)((unsigned int)base + regs->_esp + nparm * 4); -+ if ( !compat_access_ok(ustkp - nparm, nparm * 4) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ do -+ { -+ unsigned int parm; -+ -+ --ustkp; -+ rc = __get_user(parm, ustkp); -+ if ( rc ) -+ { -+ propagate_page_fault((unsigned long)(ustkp + 1) - rc, 0); -+ return 0; -+ } -+ push(parm); -+ } while ( --nparm ); -+ } -+ } -+ else -+ { -+ sel |= (regs->cs & 3); -+ esp = regs->esp; -+ ss = regs->ss; -+ if ( !read_descriptor(ss, v, regs, &base, &limit, &ar, 0) || -+ ((ar >> 13) & 3) != (sel & 3) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ if ( !check_stack_limit(ar, limit, esp, 2 * 4) ) -+ { -+ regs->error_code = 0; -+ return do_guest_trap(TRAP_stack_error, regs, 1); -+ } -+ stkp = (unsigned int *)(unsigned long)((unsigned int)base + esp); -+ if ( !compat_access_ok(stkp - 2, 2 * 4) ) -+ return do_guest_trap(TRAP_gp_fault, regs, 1); -+ } -+ push(regs->cs); -+ push(eip); -+#undef push -+ regs->esp = esp; -+ regs->ss = ss; -+ } -+ else -+ sel |= (regs->cs & 3); -+ -+ regs->eip = off; -+ regs->cs = sel; -+#endif -+ -+ return 0; -+} -+ - asmlinkage int do_general_protection(struct cpu_user_regs *regs) - { - struct vcpu *v = current; -@@ -1759,6 +2148,8 @@ asmlinkage int do_general_protection(str - return do_guest_trap(vector, regs, 0); - } - } -+ else if ( IS_COMPAT(v->domain) && regs->error_code ) -+ return emulate_gate_op(regs); - - /* Emulate some simple privileged and I/O instructions. */ - if ( (regs->error_code == 0) && -Index: 2007-01-31/xen/arch/x86/x86_64/mm.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/x86_64/mm.c 2007-01-31 09:29:17.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/x86_64/mm.c 2007-01-31 09:41:46.000000000 +0100 -@@ -366,14 +366,16 @@ int check_descriptor(const struct domain - { - u32 a = d->a, b = d->b; - u16 cs; -+ unsigned int dpl; - - /* A not-present descriptor will always fault, so is safe. */ - if ( !(b & _SEGMENT_P) ) - goto good; - - /* Check and fix up the DPL. */ -- if ( (b & _SEGMENT_DPL) < (GUEST_KERNEL_RPL(dom) << 13) ) -- d->b = b = (b & ~_SEGMENT_DPL) | (GUEST_KERNEL_RPL(dom) << 13); -+ dpl = (b >> 13) & 3; -+ __fixup_guest_selector(dom, dpl); -+ b = (b & ~_SEGMENT_DPL) | (dpl << 13); - - /* All code and data segments are okay. No base/limit checking. */ - if ( (b & _SEGMENT_S) ) -@@ -391,18 +393,33 @@ int check_descriptor(const struct domain - if ( (b & _SEGMENT_TYPE) != 0xc00 ) - goto bad; - -- /* Validate and fix up the target code selector. */ -+ /* Validate the target code selector. */ - cs = a >> 16; -- fixup_guest_code_selector(dom, cs); - if ( !guest_gate_selector_okay(dom, cs) ) - goto bad; -- a = d->a = (d->a & 0xffffU) | (cs << 16); -+#ifdef __x86_64__ -+ /* -+ * Force DPL to zero, causing a GP fault with its error code indicating -+ * the gate in use, allowing emulation. This is necessary because with -+ * native guests (kernel in ring 3) call gates cannot be used directly -+ * to transition from user to kernel mode (and whether a gate is used -+ * to enter the kernel can only be determined when the gate is being -+ * used), and with compat guests call gates cannot be used at all as -+ * there are only 64-bit ones. -+ * Store the original DPL in the selector's RPL field. -+ */ -+ b &= ~_SEGMENT_DPL; -+ cs = (cs & ~3) | dpl; -+#endif -+ a = (a & 0xffffU) | (cs << 16); - - /* Reserved bits must be zero. */ -- if ( (b & 0xe0) != 0 ) -+ if ( b & (CONFIG_PAGING_LEVELS < 4 || IS_COMPAT(dom) ? 0xe0 : 0xff) ) - goto bad; - - good: -+ d->a = a; -+ d->b = b; - return 1; - bad: - return 0; diff --git a/32on64-domctl.patch b/32on64-domctl.patch deleted file mode 100644 index b0b6900..0000000 --- a/32on64-domctl.patch +++ /dev/null @@ -1,1336 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_domctl. Also add logic -to switch a domain to/from compatibility mode (supposed to happen early -after domain creation only). - -Index: 2007-01-08/xen/arch/ia64/xen/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/ia64/xen/domain.c 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/arch/ia64/xen/domain.c 2007-01-08 15:20:39.000000000 +0100 -@@ -522,14 +522,14 @@ void arch_domain_destroy(struct domain * - deallocate_rid_range(d); - } - --void arch_getdomaininfo_ctxt(struct vcpu *v, struct vcpu_guest_context *c) -+void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) - { - int i; -- struct vcpu_extra_regs *er = &c->extra_regs; -+ struct vcpu_extra_regs *er = &c.nat->extra_regs; - -- c->user_regs = *vcpu_regs (v); -- c->privregs_pfn = get_gpfn_from_mfn(virt_to_maddr(v->arch.privregs) >> -- PAGE_SHIFT); -+ c.nat->user_regs = *vcpu_regs(v); -+ c.nat->privregs_pfn = get_gpfn_from_mfn(virt_to_maddr(v->arch.privregs) >> -+ PAGE_SHIFT); - - /* Fill extra regs. */ - for (i = 0; i < 8; i++) { -@@ -549,12 +549,12 @@ void arch_getdomaininfo_ctxt(struct vcpu - er->iva = v->arch.iva; - } - --int arch_set_info_guest(struct vcpu *v, struct vcpu_guest_context *c) -+int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c) - { - struct pt_regs *regs = vcpu_regs (v); - struct domain *d = v->domain; - -- *regs = c->user_regs; -+ *regs = c.nat->user_regs; - - if (!d->arch.is_vti) { - /* domain runs at PL2/3 */ -@@ -562,9 +562,9 @@ int arch_set_info_guest(struct vcpu *v, - regs->ar_rsc |= (2 << 2); /* force PL2/3 */ - } - -- if (c->flags & VGCF_EXTRA_REGS) { -+ if (c.nat->flags & VGCF_EXTRA_REGS) { - int i; -- struct vcpu_extra_regs *er = &c->extra_regs; -+ struct vcpu_extra_regs *er = &c.nat->extra_regs; - - for (i = 0; i < 8; i++) { - vcpu_set_itr(v, i, er->itrs[i].pte, -Index: 2007-01-08/xen/arch/powerpc/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/powerpc/domain.c 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/arch/powerpc/domain.c 2007-01-08 15:20:39.000000000 +0100 -@@ -150,9 +150,9 @@ void vcpu_destroy(struct vcpu *v) - { - } - --int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_t *c) -+int arch_set_info_guest(struct vcpu *v, vcpu_guest_context_u c) - { -- memcpy(&v->arch.ctxt, &c->user_regs, sizeof(c->user_regs)); -+ memcpy(&v->arch.ctxt, &c.nat->user_regs, sizeof(c.nat->user_regs)); - - printk("Domain[%d].%d: initializing\n", - v->domain->domain_id, v->vcpu_id); -Index: 2007-01-08/xen/arch/powerpc/domctl.c -=================================================================== ---- 2007-01-08.orig/xen/arch/powerpc/domctl.c 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/arch/powerpc/domctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -22,6 +22,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -29,10 +30,9 @@ - #include - #include - --void arch_getdomaininfo_ctxt(struct vcpu *, vcpu_guest_context_t *); --void arch_getdomaininfo_ctxt(struct vcpu *v, vcpu_guest_context_t *c) -+void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) - { -- memcpy(&c->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs)); -+ memcpy(&c.nat->user_regs, &v->arch.ctxt, sizeof(struct cpu_user_regs)); - /* XXX fill in rest of vcpu_guest_context_t */ - } - -Index: 2007-01-08/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain.c 2007-01-08 15:19:19.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain.c 2007-01-08 15:20:39.000000000 +0100 -@@ -16,6 +16,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -250,6 +251,69 @@ static void release_compat_l4(struct vcp - v->arch.guest_table_user = pagetable_null(); - } - -+static inline int may_switch_mode(struct domain *d) -+{ -+ return 1; /* XXX */ -+} -+ -+int switch_native(struct domain *d) -+{ -+ l1_pgentry_t gdt_l1e; -+ unsigned int vcpuid; -+ -+ if ( !d ) -+ return -EINVAL; -+ if ( !may_switch_mode(d) ) -+ return -EACCES; -+ if ( !IS_COMPAT(d) ) -+ return 0; -+ -+ clear_bit(_DOMF_compat, &d->domain_flags); -+ release_arg_xlat_area(d); -+ -+ /* switch gdt */ -+ gdt_l1e = l1e_from_page(virt_to_page(gdt_table), PAGE_HYPERVISOR); -+ for ( vcpuid = 0; vcpuid < MAX_VIRT_CPUS; vcpuid++ ) -+ { -+ d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; -+ if (d->vcpu[vcpuid]) -+ release_compat_l4(d->vcpu[vcpuid]); -+ } -+ -+ return 0; -+} -+ -+int switch_compat(struct domain *d) -+{ -+ l1_pgentry_t gdt_l1e; -+ unsigned int vcpuid; -+ -+ if ( !d ) -+ return -EINVAL; -+ if ( compat_disabled ) -+ return -ENOSYS; -+ if ( !may_switch_mode(d) ) -+ return -EACCES; -+ if ( IS_COMPAT(d) ) -+ return 0; -+ -+ set_bit(_DOMF_compat, &d->domain_flags); -+ -+ /* switch gdt */ -+ gdt_l1e = l1e_from_page(virt_to_page(compat_gdt_table), PAGE_HYPERVISOR); -+ for ( vcpuid = 0; vcpuid < MAX_VIRT_CPUS; vcpuid++ ) -+ { -+ d->arch.mm_perdomain_pt[((vcpuid << GDT_LDT_VCPU_SHIFT) + -+ FIRST_RESERVED_GDT_PAGE)] = gdt_l1e; -+ if (d->vcpu[vcpuid] -+ && setup_compat_l4(d->vcpu[vcpuid]) != 0) -+ return -ENOMEM; -+ } -+ -+ return 0; -+} -+ - #else - #define release_arg_xlat_area(d) ((void)0) - #define setup_compat_l4(v) 0 -@@ -420,43 +484,80 @@ void arch_domain_destroy(struct domain * - - /* This is called by arch_final_setup_guest and do_boot_vcpu */ - int arch_set_info_guest( -- struct vcpu *v, struct vcpu_guest_context *c) -+ struct vcpu *v, vcpu_guest_context_u c) - { - struct domain *d = v->domain; -+#ifdef CONFIG_COMPAT -+#define c(fld) (!IS_COMPAT(d) ? (c.nat->fld) : (c.cmp->fld)) -+#else -+#define c(fld) (c.nat->fld) -+#endif - unsigned long cr3_pfn = INVALID_MFN; -+ unsigned long flags = c(flags); - int i, rc; - - if ( !is_hvm_vcpu(v) ) - { -- fixup_guest_stack_selector(d, c->user_regs.ss); -- fixup_guest_stack_selector(d, c->kernel_ss); -- fixup_guest_code_selector(d, c->user_regs.cs); -- -- if ( CONFIG_PAGING_LEVELS < 4 || IS_COMPAT(d) ) -+ if ( !IS_COMPAT(d) ) - { -- fixup_guest_code_selector(d, c->event_callback_cs); -- fixup_guest_code_selector(d, c->failsafe_callback_cs); -- } -+ fixup_guest_stack_selector(d, c.nat->user_regs.ss); -+ fixup_guest_stack_selector(d, c.nat->kernel_ss); -+ fixup_guest_code_selector(d, c.nat->user_regs.cs); -+#ifdef __i386__ -+ fixup_guest_code_selector(d, c.nat->event_callback_cs); -+ fixup_guest_code_selector(d, c.nat->failsafe_callback_cs); -+#endif - -- for ( i = 0; i < 256; i++ ) -- fixup_guest_code_selector(d, c->trap_ctxt[i].cs); -+ for ( i = 0; i < 256; i++ ) -+ fixup_guest_code_selector(d, c.nat->trap_ctxt[i].cs); - -- /* LDT safety checks. */ -- if ( ((c->ldt_base & (PAGE_SIZE-1)) != 0) || -- (c->ldt_ents > 8192) || -- !array_access_ok(c->ldt_base, c->ldt_ents, LDT_ENTRY_SIZE) ) -- return -EINVAL; -+ /* LDT safety checks. */ -+ if ( ((c.nat->ldt_base & (PAGE_SIZE-1)) != 0) || -+ (c.nat->ldt_ents > 8192) || -+ !array_access_ok(c.nat->ldt_base, -+ c.nat->ldt_ents, -+ LDT_ENTRY_SIZE) ) -+ return -EINVAL; -+ } -+#ifdef CONFIG_COMPAT -+ else -+ { -+ fixup_guest_stack_selector(d, c.cmp->user_regs.ss); -+ fixup_guest_stack_selector(d, c.cmp->kernel_ss); -+ fixup_guest_code_selector(d, c.cmp->user_regs.cs); -+ fixup_guest_code_selector(d, c.cmp->event_callback_cs); -+ fixup_guest_code_selector(d, c.cmp->failsafe_callback_cs); -+ -+ for ( i = 0; i < 256; i++ ) -+ fixup_guest_code_selector(d, c.cmp->trap_ctxt[i].cs); -+ -+ /* LDT safety checks. */ -+ if ( ((c.cmp->ldt_base & (PAGE_SIZE-1)) != 0) || -+ (c.cmp->ldt_ents > 8192) || -+ !compat_array_access_ok(c.cmp->ldt_base, -+ c.cmp->ldt_ents, -+ LDT_ENTRY_SIZE) ) -+ return -EINVAL; -+ } -+#endif - } - - clear_bit(_VCPUF_fpu_initialised, &v->vcpu_flags); -- if ( c->flags & VGCF_i387_valid ) -+ if ( flags & VGCF_I387_VALID ) - set_bit(_VCPUF_fpu_initialised, &v->vcpu_flags); - - v->arch.flags &= ~TF_kernel_mode; -- if ( (c->flags & VGCF_in_kernel) || is_hvm_vcpu(v)/*???*/ ) -+ if ( (flags & VGCF_in_kernel) || is_hvm_vcpu(v)/*???*/ ) - v->arch.flags |= TF_kernel_mode; - -- memcpy(&v->arch.guest_context, c, sizeof(*c)); -+ if ( !IS_COMPAT(v->domain) ) -+ memcpy(&v->arch.guest_context, c.nat, sizeof(*c.nat)); -+#ifdef CONFIG_COMPAT -+ else -+ { -+ XLAT_vcpu_guest_context(&v->arch.guest_context, c.cmp); -+ } -+#endif - - /* Only CR0.TS is modifiable by guest or admin. */ - v->arch.guest_context.ctrlreg[0] &= X86_CR0_TS; -@@ -484,19 +585,34 @@ int arch_set_info_guest( - memset(v->arch.guest_context.debugreg, 0, - sizeof(v->arch.guest_context.debugreg)); - for ( i = 0; i < 8; i++ ) -- (void)set_debugreg(v, i, c->debugreg[i]); -+ (void)set_debugreg(v, i, c(debugreg[i])); - - if ( v->vcpu_id == 0 ) -- d->vm_assist = c->vm_assist; -+ d->vm_assist = c(vm_assist); - - if ( !is_hvm_vcpu(v) ) - { -- if ( (rc = (int)set_gdt(v, c->gdt_frames, c->gdt_ents)) != 0 ) -+ if ( !IS_COMPAT(d) ) -+ rc = (int)set_gdt(v, c.nat->gdt_frames, c.nat->gdt_ents); -+#ifdef CONFIG_COMPAT -+ else -+ { -+ unsigned long gdt_frames[ARRAY_SIZE(c.cmp->gdt_frames)]; -+ unsigned int i, n = (c.cmp->gdt_ents + 511) / 512; -+ -+ if ( n > ARRAY_SIZE(c.cmp->gdt_frames) ) -+ return -EINVAL; -+ for ( i = 0; i < n; ++i ) -+ gdt_frames[i] = c.cmp->gdt_frames[i]; -+ rc = (int)set_gdt(v, gdt_frames, c.cmp->gdt_ents); -+ } -+#endif -+ if ( rc != 0 ) - return rc; - - if ( !IS_COMPAT(d) ) - { -- cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c->ctrlreg[3])); -+ cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c.nat->ctrlreg[3])); - - if ( shadow_mode_refcounts(d) - ? !get_page(mfn_to_page(cr3_pfn), d) -@@ -514,7 +630,7 @@ int arch_set_info_guest( - { - l4_pgentry_t *l4tab; - -- cr3_pfn = gmfn_to_mfn(d, compat_cr3_to_pfn(c->ctrlreg[3])); -+ cr3_pfn = gmfn_to_mfn(d, compat_cr3_to_pfn(c.cmp->ctrlreg[3])); - - if ( shadow_mode_refcounts(d) - ? !get_page(mfn_to_page(cr3_pfn), d) -@@ -552,6 +668,7 @@ int arch_set_info_guest( - update_cr3(v); - - return 0; -+#undef c - } - - long -Index: 2007-01-08/xen/arch/x86/domctl.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domctl.c 2007-01-08 15:19:14.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -23,12 +24,21 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - --long arch_do_domctl( -+#ifndef COMPAT -+#define _long long -+#define copy_from_xxx_offset copy_from_guest_offset -+#define copy_to_xxx_offset copy_to_guest_offset -+#endif -+ -+_long arch_do_domctl( - struct xen_domctl *domctl, - XEN_GUEST_HANDLE(xen_domctl_t) u_domctl) - { -- long ret = 0; -+ _long ret = 0; - - switch ( domctl->cmd ) - { -@@ -40,7 +50,9 @@ long arch_do_domctl( - d = find_domain_by_id(domctl->domain); - if ( d != NULL ) - { -- ret = shadow_domctl(d, &domctl->u.shadow_op, u_domctl); -+ ret = shadow_domctl(d, -+ &domctl->u.shadow_op, -+ guest_handle_cast(u_domctl, void)); - put_domain(d); - copy_to_guest(u_domctl, domctl, 1); - } -@@ -123,12 +135,12 @@ long arch_do_domctl( - - case XEN_DOMCTL_getpageframeinfo2: - { --#define GPF2_BATCH (PAGE_SIZE / sizeof(long)) -+#define GPF2_BATCH (PAGE_SIZE / sizeof(_long)) - int n,j; - int num = domctl->u.getpageframeinfo2.num; - domid_t dom = domctl->domain; - struct domain *d; -- unsigned long *l_arr; -+ unsigned _long *l_arr; - ret = -ESRCH; - - if ( unlikely((d = find_domain_by_id(dom)) == NULL) ) -@@ -148,9 +160,9 @@ long arch_do_domctl( - { - int k = ((num-n)>GPF2_BATCH)?GPF2_BATCH:(num-n); - -- if ( copy_from_guest_offset(l_arr, -- domctl->u.getpageframeinfo2.array, -- n, k) ) -+ if ( copy_from_xxx_offset(l_arr, -+ domctl->u.getpageframeinfo2.array, -+ n, k) ) - { - ret = -EINVAL; - break; -@@ -159,13 +171,13 @@ long arch_do_domctl( - for ( j = 0; j < k; j++ ) - { - struct page_info *page; -- unsigned long mfn = l_arr[j]; -+ unsigned _long mfn = l_arr[j]; - - page = mfn_to_page(mfn); - - if ( likely(mfn_valid(mfn) && get_page(page, d)) ) - { -- unsigned long type = 0; -+ unsigned _long type = 0; - - switch( page->u.inuse.type_info & PGT_type_mask ) - { -@@ -193,8 +205,8 @@ long arch_do_domctl( - - } - -- if ( copy_to_guest_offset(domctl->u.getpageframeinfo2.array, -- n, l_arr, k) ) -+ if ( copy_to_xxx_offset(domctl->u.getpageframeinfo2.array, -+ n, l_arr, k) ) - { - ret = -EINVAL; - break; -@@ -214,7 +226,7 @@ long arch_do_domctl( - int i; - struct domain *d = find_domain_by_id(domctl->domain); - unsigned long max_pfns = domctl->u.getmemlist.max_pfns; -- unsigned long mfn; -+ xen_pfn_t mfn; - struct list_head *list_ent; - - ret = -EINVAL; -@@ -229,8 +241,8 @@ long arch_do_domctl( - { - mfn = page_to_mfn(list_entry( - list_ent, struct page_info, list)); -- if ( copy_to_guest_offset(domctl->u.getmemlist.buffer, -- i, &mfn, 1) ) -+ if ( copy_to_xxx_offset(domctl->u.getmemlist.buffer, -+ i, &mfn, 1) ) - { - ret = -EFAULT; - break; -@@ -289,37 +301,68 @@ long arch_do_domctl( - return ret; - } - --void arch_getdomaininfo_ctxt( -- struct vcpu *v, struct vcpu_guest_context *c) -+#ifndef COMPAT -+void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c) - { -- memcpy(c, &v->arch.guest_context, sizeof(*c)); -+#ifdef CONFIG_COMPAT -+#define c(fld) (!IS_COMPAT(v->domain) ? (c.nat->fld) : (c.cmp->fld)) -+#else -+#define c(fld) (c.nat->fld) -+#endif -+ unsigned long flags; -+ -+ if ( !IS_COMPAT(v->domain) ) -+ memcpy(c.nat, &v->arch.guest_context, sizeof(*c.nat)); -+#ifdef CONFIG_COMPAT -+ else -+ { -+ XLAT_vcpu_guest_context(c.cmp, &v->arch.guest_context); -+ } -+#endif - - if ( is_hvm_vcpu(v) ) - { -- hvm_store_cpu_guest_regs(v, &c->user_regs, c->ctrlreg); -+ if ( !IS_COMPAT(v->domain) ) -+ hvm_store_cpu_guest_regs(v, &c.nat->user_regs, c.nat->ctrlreg); -+#ifdef CONFIG_COMPAT -+ else -+ { -+ struct cpu_user_regs user_regs; -+ typeof(c.nat->ctrlreg) ctrlreg; -+ unsigned i; -+ -+ hvm_store_cpu_guest_regs(v, &user_regs, ctrlreg); -+ XLAT_cpu_user_regs(&c.cmp->user_regs, &user_regs); -+ for ( i = 0; i < ARRAY_SIZE(c.cmp->ctrlreg); ++i ) -+ c.cmp->ctrlreg[i] = ctrlreg[i]; -+ } -+#endif - } - else - { - /* IOPL privileges are virtualised: merge back into returned eflags. */ -- BUG_ON((c->user_regs.eflags & EF_IOPL) != 0); -- c->user_regs.eflags |= v->arch.iopl << 12; -+ BUG_ON((c(user_regs.eflags) & EF_IOPL) != 0); -+ c(user_regs.eflags |= v->arch.iopl << 12); - } - -- c->flags = 0; -+ flags = 0; - if ( test_bit(_VCPUF_fpu_initialised, &v->vcpu_flags) ) -- c->flags |= VGCF_i387_valid; -+ flags |= VGCF_i387_valid; - if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) ) -- c->flags |= VGCF_in_kernel; -+ flags |= VGCF_in_kernel; -+ c(flags = flags); - - if ( !IS_COMPAT(v->domain) ) -- c->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+ c.nat->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); - #ifdef CONFIG_COMPAT - else -- c->ctrlreg[3] = compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+ c.cmp->ctrlreg[3] = compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); - #endif - -- c->vm_assist = v->domain->vm_assist; -+ c(vm_assist = v->domain->vm_assist); -+#undef c - } -+#endif - - /* - * Local variables: -Index: 2007-01-08/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/mm/shadow/common.c 2007-01-08 15:19:11.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/mm/shadow/common.c 2007-01-08 15:20:39.000000000 +0100 -@@ -3211,7 +3211,7 @@ void sh_do_mark_dirty(struct domain *d, - - int shadow_domctl(struct domain *d, - xen_domctl_shadow_op_t *sc, -- XEN_GUEST_HANDLE(xen_domctl_t) u_domctl) -+ XEN_GUEST_HANDLE(void) u_domctl) - { - int rc, preempted = 0; - -Index: 2007-01-08/xen/arch/x86/x86_32/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_32/traps.c 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_32/traps.c 2007-01-08 15:20:39.000000000 +0100 -@@ -193,7 +193,7 @@ unsigned long do_iret(void) - - /* - * Pop, fix up and restore EFLAGS. We fix up in a local staging area -- * to avoid firing the BUG_ON(IOPL) check in arch_getdomaininfo_ctxt. -+ * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest. - */ - if ( unlikely(__copy_from_user(&eflags, (void __user *)regs->esp, 4)) ) - goto exit_and_crash; -Index: 2007-01-08/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/Makefile 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/Makefile 2007-01-08 15:20:39.000000000 +0100 -@@ -5,6 +5,7 @@ obj-y += traps.o - - obj-$(CONFIG_COMPAT) += compat.o - obj-$(CONFIG_COMPAT) += domain.o -+obj-$(CONFIG_COMPAT) += domctl.o - obj-$(CONFIG_COMPAT) += physdev.o - obj-$(CONFIG_COMPAT) += platform_hypercall.o - obj-$(CONFIG_COMPAT) += sysctl.o -@@ -12,6 +13,7 @@ obj-$(CONFIG_COMPAT) += sysctl.o - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies - compat.o: ../compat.c -+domctl.o: ../domctl.c - entry.o: compat/entry.S - mm.o: compat/mm.c - physdev.o: ../physdev.c -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:39.000000000 +0100 -@@ -278,8 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_domctl domain_crash_synchronous -- - ENTRY(compat_hypercall_table) - .quad compat_set_trap_table /* 0 */ - .quad do_mmu_update -Index: 2007-01-08/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:19:19.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:20:39.000000000 +0100 -@@ -49,7 +49,7 @@ unsigned int compat_iret(void) - - /* - * Fix up and restore EFLAGS. We fix up in a local staging area -- * to avoid firing the BUG_ON(IOPL) check in arch_getdomaininfo_ctxt. -+ * to avoid firing the BUG_ON(IOPL) check in arch_get_info_guest. - */ - if ( unlikely(__get_user(eflags, (u32 __user *)regs->rsp + 3)) ) - goto exit_and_crash; -Index: 2007-01-08/xen/arch/x86/x86_64/domctl.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/arch/x86/x86_64/domctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -0,0 +1,111 @@ -+/****************************************************************************** -+ * Arch-specific compatibility domctl.c -+ */ -+ -+#include -+#include -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(compat_domctl_t); -+#define xen_domctl compat_domctl -+#define xen_domctl_t compat_domctl_t -+#define arch_do_domctl(x, h) arch_compat_domctl(x, _##h) -+ -+static int compat_shadow_domctl(struct domain *d, -+ compat_domctl_shadow_op_t *csc, -+ XEN_GUEST_HANDLE(void) u_domctl) -+{ -+ xen_domctl_shadow_op_t nsc; -+ int rc, mode; -+ -+#define XLAT_domctl_shadow_op_HNDL_dirty_bitmap(_d_, _s_) \ -+ do \ -+ { \ -+ if ( (_s_)->op != XEN_DOMCTL_SHADOW_OP_CLEAN \ -+ && (_s_)->op != XEN_DOMCTL_SHADOW_OP_PEEK ) \ -+ { \ -+ set_xen_guest_handle((_d_)->dirty_bitmap, NULL); \ -+ mode = -1; \ -+ } \ -+ else if ( compat_handle_is_null((_s_)->dirty_bitmap) \ -+ || (((_s_)->pages - 1) \ -+ & (BITS_PER_LONG - COMPAT_BITS_PER_LONG)) \ -+ == BITS_PER_LONG - COMPAT_BITS_PER_LONG ) \ -+ { \ -+ XEN_GUEST_HANDLE(void) tmp; \ -+ guest_from_compat_handle(tmp, (_s_)->dirty_bitmap); \ -+ (_d_)->dirty_bitmap = guest_handle_cast(tmp, ulong); \ -+ mode = 0; \ -+ } \ -+ else if ( (_s_)->pages > COMPAT_ARG_XLAT_SIZE * 8 ) \ -+ { \ -+ printk("Cannot translate compatibility mode XEN_DOMCTL_SHADOW_OP_{CLEAN,PEEK} (0x%lX)\n", \ -+ (_s_)->pages); \ -+ return -E2BIG; \ -+ } \ -+ else \ -+ { \ -+ set_xen_guest_handle((_d_)->dirty_bitmap, \ -+ (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id)); \ -+ mode = 1; \ -+ } \ -+ } while (0) -+ XLAT_domctl_shadow_op(&nsc, csc); -+#undef XLAT_domctl_shadow_op_HNDL_dirty_bitmap -+ rc = shadow_domctl(d, &nsc, u_domctl); -+ if ( rc != __HYPERVISOR_domctl ) -+ { -+ BUG_ON(rc > 0); -+#define XLAT_domctl_shadow_op_HNDL_dirty_bitmap(_d_, _s_) \ -+ do \ -+ { \ -+ if ( rc == 0 \ -+ && mode > 0 \ -+ && copy_to_compat((_d_)->dirty_bitmap, \ -+ (unsigned int *)(_s_)->dirty_bitmap.p, \ -+ ((_s_)->pages + COMPAT_BITS_PER_LONG - 1) / COMPAT_BITS_PER_LONG) ) \ -+ rc = -EFAULT; \ -+ } while (0) -+ XLAT_domctl_shadow_op(csc, &nsc); -+#undef XLAT_domctl_shadow_op_HNDL_dirty_bitmap -+ } -+ return rc; -+} -+#define xen_domctl_shadow_op compat_domctl_shadow_op -+#define xen_domctl_shadow_op_t compat_domctl_shadow_op_t -+#define shadow_domctl(d, sc, u) compat_shadow_domctl(d, sc, u) -+ -+#define xen_domctl_ioport_permission compat_domctl_ioport_permission -+#define xen_domctl_ioport_permission_t compat_domctl_ioport_permission_t -+ -+#define xen_domctl_getpageframeinfo compat_domctl_getpageframeinfo -+#define xen_domctl_getpageframeinfo_t compat_domctl_getpageframeinfo_t -+ -+#define xen_domctl_getpageframeinfo2 compat_domctl_getpageframeinfo2 -+#define xen_domctl_getpageframeinfo2_t compat_domctl_getpageframeinfo2_t -+ -+#define xen_domctl_getmemlist compat_domctl_getmemlist -+#define xen_domctl_getmemlist_t compat_domctl_getmemlist_t -+#define xen_pfn_t compat_pfn_t -+ -+#define xen_domctl_hypercall_init compat_domctl_hypercall_init -+#define xen_domctl_hypercall_init_t compat_domctl_hypercall_init_t -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+#define _long int -+#define copy_from_xxx_offset copy_from_compat_offset -+#define copy_to_xxx_offset copy_to_compat_offset -+ -+#include "../domctl.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/compat/Makefile 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 15:20:39.000000000 +0100 -@@ -1,4 +1,5 @@ - obj-y += domain.o -+obj-y += domctl.o - obj-y += kernel.o - obj-y += memory.o - obj-y += multicall.o -@@ -6,6 +7,7 @@ obj-y += sysctl.o - obj-y += xlat.o - - # extra dependencies -+domctl.o: ../domctl.c - kernel.o: ../kernel.c - multicall.o: ../multicall.c - sysctl.o: ../sysctl.c -Index: 2007-01-08/xen/common/compat/domain.c -=================================================================== ---- 2007-01-08.orig/xen/common/compat/domain.c 2007-01-08 15:19:19.000000000 +0100 -+++ 2007-01-08/xen/common/compat/domain.c 2007-01-08 15:20:39.000000000 +0100 -@@ -28,7 +28,6 @@ int compat_vcpu_op(int cmd, int vcpuid, - case VCPUOP_initialise: - { - struct compat_vcpu_guest_context *cmp_ctxt; -- struct vcpu_guest_context *nat_ctxt; - - if ( (cmp_ctxt = xmalloc(struct compat_vcpu_guest_context)) == NULL ) - { -@@ -43,23 +42,13 @@ int compat_vcpu_op(int cmd, int vcpuid, - break; - } - -- if ( (nat_ctxt = xmalloc(struct vcpu_guest_context)) == NULL ) -- { -- rc = -ENOMEM; -- break; -- } -- -- memset(nat_ctxt, 0, sizeof(*nat_ctxt)); -- XLAT_vcpu_guest_context(nat_ctxt, cmp_ctxt); -- xfree(cmp_ctxt); -- - LOCK_BIGLOCK(d); - rc = -EEXIST; - if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) ) -- rc = boot_vcpu(d, vcpuid, nat_ctxt); -+ rc = boot_vcpu(d, vcpuid, cmp_ctxt); - UNLOCK_BIGLOCK(d); - -- xfree(nat_ctxt); -+ xfree(cmp_ctxt); - break; - } - -Index: 2007-01-08/xen/common/compat/domctl.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/domctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -0,0 +1,137 @@ -+/****************************************************************************** -+ * compat/domctl.c -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(compat_domctl_t); -+#define xen_domctl compat_domctl -+#define xen_domctl_t compat_domctl_t -+#define do_domctl(h) compat_domctl(_##h) -+#define arch_do_domctl(x, h) arch_compat_domctl(x, _##h) -+ -+#define xen_domain_handle_t compat_domain_handle_t -+ -+#define xen_domctl_vcpucontext compat_domctl_vcpucontext -+#define xen_domctl_vcpucontext_t compat_domctl_vcpucontext_t -+ -+#define xen_domctl_createdomain compat_domctl_createdomain -+#define xen_domctl_createdomain_t compat_domctl_createdomain_t -+ -+#define xen_domctl_max_vcpus compat_domctl_max_vcpus -+#define xen_domctl_max_vcpus_t compat_domctl_max_vcpus_t -+ -+static void cpumask_to_compat_ctl_cpumap( -+ struct compat_ctl_cpumap *cmpctl_cpumap, cpumask_t *cpumask) -+{ -+ unsigned int guest_bytes, copy_bytes, i; -+ /*static const*/ uint8_t zero = 0; -+ -+ if ( compat_handle_is_null(cmpctl_cpumap->bitmap) ) -+ return; -+ -+ guest_bytes = (cmpctl_cpumap->nr_cpus + 7) / 8; -+ copy_bytes = min_t(unsigned int, guest_bytes, (NR_CPUS + 7) / 8); -+ -+ copy_to_compat(cmpctl_cpumap->bitmap, -+ (uint8_t *)cpus_addr(*cpumask), -+ copy_bytes); -+ -+ for ( i = copy_bytes; i < guest_bytes; i++ ) -+ copy_to_compat_offset(cmpctl_cpumap->bitmap, i, &zero, 1); -+} -+#define cpumask_to_xenctl_cpumap cpumask_to_compat_ctl_cpumap -+ -+void compat_ctl_cpumap_to_cpumask( -+ cpumask_t *cpumask, struct compat_ctl_cpumap *cmpctl_cpumap) -+{ -+ unsigned int guest_bytes, copy_bytes; -+ -+ guest_bytes = (cmpctl_cpumap->nr_cpus + 7) / 8; -+ copy_bytes = min_t(unsigned int, guest_bytes, (NR_CPUS + 7) / 8); -+ -+ cpus_clear(*cpumask); -+ -+ if ( compat_handle_is_null(cmpctl_cpumap->bitmap) ) -+ return; -+ -+ copy_from_compat((uint8_t *)cpus_addr(*cpumask), -+ cmpctl_cpumap->bitmap, -+ copy_bytes); -+} -+#define xenctl_cpumap_to_cpumask compat_ctl_cpumap_to_cpumask -+ -+#define xen_domctl_vcpuaffinity compat_domctl_vcpuaffinity -+#define xen_domctl_vcpuaffinity_t compat_domctl_vcpuaffinity_t -+ -+static int compat_sched_adjust(struct domain *d, -+ struct compat_domctl_scheduler_op *cop) -+{ -+ struct xen_domctl_scheduler_op nop; -+ int ret; -+ enum XLAT_domctl_scheduler_op_u u; -+ -+ switch ( cop->sched_id ) -+ { -+ case XEN_SCHEDULER_SEDF: u = XLAT_domctl_scheduler_op_u_sedf; break; -+ case XEN_SCHEDULER_CREDIT: u = XLAT_domctl_scheduler_op_u_credit; break; -+ default: return -EINVAL; -+ } -+ XLAT_domctl_scheduler_op(&nop, cop); -+ ret = sched_adjust(d, &nop); -+ XLAT_domctl_scheduler_op(cop, &nop); -+ -+ return ret; -+} -+#define sched_adjust(d, op) compat_sched_adjust(d, op) -+#define xen_domctl_scheduler_op compat_domctl_scheduler_op -+#define xen_domctl_scheduler_op_t compat_domctl_scheduler_op_t -+ -+#define xen_domctl_getdomaininfo compat_domctl_getdomaininfo -+#define xen_domctl_getdomaininfo_t compat_domctl_getdomaininfo_t -+#define getdomaininfo(d, i) compat_getdomaininfo(d, i) -+ -+#define xen_domctl_getvcpuinfo compat_domctl_getvcpuinfo -+#define xen_domctl_getvcpuinfo_t compat_domctl_getvcpuinfo_t -+ -+#define xen_domctl_max_mem compat_domctl_max_mem -+#define xen_domctl_max_mem_t compat_domctl_max_mem_t -+ -+#define xen_domctl_setdomainhandle compat_domctl_setdomainhandle -+#define xen_domctl_setdomainhandle_t compat_domctl_setdomainhandle_t -+ -+#define xen_domctl_setdebugging compat_domctl_setdebugging -+#define xen_domctl_setdebugging_t compat_domctl_setdebugging_t -+ -+#define xen_domctl_irq_permission compat_domctl_irq_permission -+#define xen_domctl_irq_permission_t compat_domctl_irq_permission_t -+ -+#define xen_domctl_iomem_permission compat_domctl_iomem_permission -+#define xen_domctl_iomem_permission_t compat_domctl_iomem_permission_t -+ -+#define xen_domctl_settimeoffset compat_domctl_settimeoffset -+#define xen_domctl_settimeoffset_t compat_domctl_settimeoffset_t -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+#define _u_domctl u_domctl -+//#undef guest_handle_cast -+//#define guest_handle_cast compat_handle_cast -+//#define copy_to_xxx_offset copy_to_compat_offset -+typedef int ret_t; -+ -+#include "../domctl.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/compat/sysctl.c -=================================================================== ---- 2007-01-08.orig/xen/common/compat/sysctl.c 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/common/compat/sysctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -40,13 +40,6 @@ static int compat_tb_control(struct comp - #define xen_sysctl_sched_id compat_sysctl_sched_id - #define xen_sysctl_sched_id_t compat_sysctl_sched_id_t - --static void compat_getdomaininfo(struct domain *d, struct compat_domctl_getdomaininfo *ci) --{ -- struct xen_domctl_getdomaininfo ni; -- -- getdomaininfo(d, &ni); -- XLAT_domctl_getdomaininfo(ci, &ni); --} - #define xen_sysctl_getdomaininfolist compat_sysctl_getdomaininfolist - #define xen_sysctl_getdomaininfolist_t compat_sysctl_getdomaininfolist_t - #define xen_domctl_getdomaininfo compat_domctl_getdomaininfo -Index: 2007-01-08/xen/common/domain.c -=================================================================== ---- 2007-01-08.orig/xen/common/domain.c 2007-01-08 15:19:11.000000000 +0100 -+++ 2007-01-08/xen/common/domain.c 2007-01-08 15:20:39.000000000 +0100 -@@ -26,6 +26,9 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - - /* Both these structures are protected by the domlist_lock. */ - DEFINE_RWLOCK(domlist_lock); -@@ -451,32 +454,64 @@ void domain_unpause_by_systemcontroller( - * the userspace dom0 domain builder. - */ - int set_info_guest(struct domain *d, -- xen_domctl_vcpucontext_t *vcpucontext) -+ xen_domctl_vcpucontext_u vcpucontext) - { - int rc = 0; -- struct vcpu_guest_context *c = NULL; -- unsigned long vcpu = vcpucontext->vcpu; -+ vcpu_guest_context_u c; -+#ifdef CONFIG_COMPAT -+ CHECK_FIELD(domctl_vcpucontext, vcpu); -+#endif -+ unsigned long vcpu = vcpucontext.nat->vcpu; - struct vcpu *v; - - if ( (vcpu >= MAX_VIRT_CPUS) || ((v = d->vcpu[vcpu]) == NULL) ) - return -EINVAL; - -- if ( (c = xmalloc(struct vcpu_guest_context)) == NULL ) -+#ifdef CONFIG_COMPAT -+ BUILD_BUG_ON(sizeof(struct vcpu_guest_context) -+ < sizeof(struct compat_vcpu_guest_context)); -+#endif -+ if ( (c.nat = xmalloc(struct vcpu_guest_context)) == NULL ) - return -ENOMEM; - - domain_pause(d); - -- rc = -EFAULT; -- if ( copy_from_guest(c, vcpucontext->ctxt, 1) == 0 ) -+ if ( !IS_COMPAT(v->domain) ) -+ { -+ if ( !IS_COMPAT(current->domain) -+ ? copy_from_guest(c.nat, vcpucontext.nat->ctxt, 1) -+#ifndef CONFIG_COMPAT -+ : 0 ) -+#else -+ : copy_from_guest(c.nat, -+ compat_handle_cast(vcpucontext.cmp->ctxt, -+ void), -+ 1) ) -+#endif -+ rc = -EFAULT; -+ } -+#ifdef CONFIG_COMPAT -+ else -+ { -+ if ( !IS_COMPAT(current->domain) -+ ? copy_from_guest(c.cmp, -+ guest_handle_cast(vcpucontext.nat->ctxt, void), -+ 1) -+ : copy_from_compat(c.cmp, vcpucontext.cmp->ctxt, 1) ) -+ rc = -EFAULT; -+ } -+#endif -+ -+ if ( rc == 0 ) - rc = arch_set_info_guest(v, c); - - domain_unpause(d); - -- xfree(c); -+ xfree(c.nat); - return rc; - } - --int boot_vcpu(struct domain *d, int vcpuid, struct vcpu_guest_context *ctxt) -+int boot_vcpu(struct domain *d, int vcpuid, vcpu_guest_context_u ctxt) - { - struct vcpu *v = d->vcpu[vcpuid]; - -Index: 2007-01-08/xen/common/domctl.c -=================================================================== ---- 2007-01-08.orig/xen/common/domctl.c 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/common/domctl.c 2007-01-08 15:20:39.000000000 +0100 -@@ -18,14 +18,22 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - #include - #include - #include - --extern long arch_do_domctl( -+#ifndef COMPAT -+typedef long ret_t; -+#define copy_to_xxx_offset copy_to_guest_offset -+#endif -+ -+extern ret_t arch_do_domctl( - struct xen_domctl *op, XEN_GUEST_HANDLE(xen_domctl_t) u_domctl); --extern void arch_getdomaininfo_ctxt( -- struct vcpu *, struct vcpu_guest_context *); -+ -+#ifndef COMPAT - - void cpumask_to_xenctl_cpumap( - struct xenctl_cpumap *xenctl_cpumap, cpumask_t *cpumask) -@@ -65,6 +73,8 @@ void xenctl_cpumap_to_cpumask( - copy_bytes); - } - -+#endif /* COMPAT */ -+ - static inline int is_free_domid(domid_t dom) - { - struct domain *d; -@@ -169,9 +179,9 @@ static unsigned int default_vcpu0_locati - return cpu; - } - --long do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl) -+ret_t do_domctl(XEN_GUEST_HANDLE(xen_domctl_t) u_domctl) - { -- long ret = 0; -+ ret_t ret = 0; - struct xen_domctl curop, *op = &curop; - void *ssid = NULL; /* save security ptr between pre and post/fail hooks */ - static DEFINE_SPINLOCK(domctl_lock); -@@ -283,11 +293,36 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - if ( (d = domain_create(dom, domcr_flags)) == NULL ) - break; - -+ ret = 0; -+ switch ( (op->u.createdomain.flags >> XEN_DOMCTL_CDF_WORDSIZE_SHIFT) -+ & XEN_DOMCTL_CDF_WORDSIZE_MASK ) -+ { -+ case 0: -+ if ( !IS_COMPAT(current->domain) ) -+ op->u.createdomain.flags |= BITS_PER_LONG -+ << XEN_DOMCTL_CDF_WORDSIZE_SHIFT; -+#ifdef CONFIG_COMPAT -+ else -+ { -+ op->u.createdomain.flags |= COMPAT_BITS_PER_LONG -+ << XEN_DOMCTL_CDF_WORDSIZE_SHIFT; -+ case COMPAT_BITS_PER_LONG: -+ ret = switch_compat(d); -+ } -+#endif -+ break; -+ case BITS_PER_LONG: -+ break; -+ default: -+ ret = -EINVAL; -+ break; -+ } -+ if ( ret ) -+ break; -+ - memcpy(d->handle, op->u.createdomain.handle, - sizeof(xen_domain_handle_t)); - -- ret = 0; -- - op->domain = d->domain_id; - if ( copy_to_guest(u_domctl, op, 1) ) - ret = -EFAULT; -@@ -446,7 +481,7 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - - case XEN_DOMCTL_getvcpucontext: - { -- struct vcpu_guest_context *c; -+ vcpu_guest_context_u c; - struct domain *d; - struct vcpu *v; - -@@ -466,23 +501,48 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) ) - goto getvcpucontext_out; - -+#ifdef CONFIG_COMPAT -+ BUILD_BUG_ON(sizeof(struct vcpu_guest_context) -+ < sizeof(struct compat_vcpu_guest_context)); -+#endif - ret = -ENOMEM; -- if ( (c = xmalloc(struct vcpu_guest_context)) == NULL ) -+ if ( (c.nat = xmalloc(struct vcpu_guest_context)) == NULL ) - goto getvcpucontext_out; - - if ( v != current ) - vcpu_pause(v); - -- arch_getdomaininfo_ctxt(v,c); -+ arch_get_info_guest(v, c); - ret = 0; - - if ( v != current ) - vcpu_unpause(v); - -- if ( copy_to_guest(op->u.vcpucontext.ctxt, c, 1) ) -- ret = -EFAULT; -+ if ( !IS_COMPAT(v->domain) ) -+ { -+#ifndef COMPAT -+ if ( copy_to_guest(op->u.vcpucontext.ctxt, c.nat, 1) ) -+#else -+ if ( copy_to_guest(compat_handle_cast(op->u.vcpucontext.ctxt, -+ void), -+ c.nat, 1) ) -+#endif -+ ret = -EFAULT; -+ } -+#ifdef CONFIG_COMPAT -+ else -+ { -+#ifndef COMPAT -+ if ( copy_to_guest(guest_handle_cast(op->u.vcpucontext.ctxt, void), -+ c.cmp, 1) ) -+#else -+ if ( copy_to_compat(op->u.vcpucontext.ctxt, c.cmp, 1) ) -+#endif -+ ret = -EFAULT; -+ } -+#endif - -- xfree(c); -+ xfree(c.nat); - - if ( copy_to_guest(u_domctl, op, 1) ) - ret = -EFAULT; -@@ -646,6 +706,16 @@ long do_domctl(XEN_GUEST_HANDLE(xen_domc - } - break; - -+#ifdef CONFIG_COMPAT -+ case XEN_DOMCTL_set_compat: -+ ret = switch_compat(find_domain_by_id(op->domain)); -+ break; -+ -+ case XEN_DOMCTL_set_native: -+ ret = switch_native(find_domain_by_id(op->domain)); -+ break; -+#endif -+ - default: - ret = arch_do_domctl(op, u_domctl); - break; -Index: 2007-01-08/xen/common/schedule.c -=================================================================== ---- 2007-01-08.orig/xen/common/schedule.c 2007-01-08 15:19:21.000000000 +0100 -+++ 2007-01-08/xen/common/schedule.c 2007-01-08 15:20:39.000000000 +0100 -@@ -33,8 +33,6 @@ - #include - #include - --extern void arch_getdomaininfo_ctxt(struct vcpu *, -- struct vcpu_guest_context *); - /* opt_sched: scheduler - default to credit */ - static char opt_sched[10] = "credit"; - string_param("sched", opt_sched); -Index: 2007-01-08/xen/include/asm-x86/shadow.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/shadow.h 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/shadow.h 2007-01-08 15:20:39.000000000 +0100 -@@ -315,7 +315,7 @@ int shadow_test_enable(struct domain *d) - * and log-dirty bitmap ops all happen through here. */ - int shadow_domctl(struct domain *d, - xen_domctl_shadow_op_t *sc, -- XEN_GUEST_HANDLE(xen_domctl_t) u_domctl); -+ XEN_GUEST_HANDLE(void) u_domctl); - - /* Call when destroying a domain */ - void shadow_teardown(struct domain *d); -Index: 2007-01-08/xen/include/public/domctl.h -=================================================================== ---- 2007-01-08.orig/xen/include/public/domctl.h 2007-01-08 15:04:22.000000000 +0100 -+++ 2007-01-08/xen/include/public/domctl.h 2007-01-08 15:20:39.000000000 +0100 -@@ -53,6 +53,8 @@ struct xen_domctl_createdomain { - /* Is this an HVM guest (as opposed to a PV guest)? */ - #define _XEN_DOMCTL_CDF_hvm_guest 0 - #define XEN_DOMCTL_CDF_hvm_guest (1U<<_XEN_DOMCTL_CDF_hvm_guest) -+#define XEN_DOMCTL_CDF_WORDSIZE_MASK 255 -+#define XEN_DOMCTL_CDF_WORDSIZE_SHIFT 24 - uint32_t flags; - }; - typedef struct xen_domctl_createdomain xen_domctl_createdomain_t; -@@ -392,6 +394,9 @@ struct xen_domctl_real_mode_area { - typedef struct xen_domctl_real_mode_area xen_domctl_real_mode_area_t; - DEFINE_XEN_GUEST_HANDLE(xen_domctl_real_mode_area_t); - -+#define XEN_DOMCTL_set_compat 42 -+#define XEN_DOMCTL_set_native 43 -+ - struct xen_domctl { - uint32_t cmd; - uint32_t interface_version; /* XEN_DOMCTL_INTERFACE_VERSION */ -Index: 2007-01-08/xen/include/xen/compat.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/compat.h 2007-01-08 15:19:19.000000000 +0100 -+++ 2007-01-08/xen/include/xen/compat.h 2007-01-08 15:20:39.000000000 +0100 -@@ -166,6 +166,9 @@ void xlat_start_info(struct start_info * - struct vcpu_runstate_info; - void xlat_vcpu_runstate_info(struct vcpu_runstate_info *); - -+int switch_compat(struct domain *); -+int switch_native(struct domain *); -+ - #define BITS_PER_GUEST_LONG(d) (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG) - - #else -Index: 2007-01-08/xen/include/xen/domain.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/domain.h 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/include/xen/domain.h 2007-01-08 15:20:39.000000000 +0100 -@@ -2,10 +2,15 @@ - #ifndef __XEN_DOMAIN_H__ - #define __XEN_DOMAIN_H__ - -+typedef union { -+ struct vcpu_guest_context *nat; -+ struct compat_vcpu_guest_context *cmp; -+} vcpu_guest_context_u __attribute__((__transparent_union__)); -+ - struct vcpu *alloc_vcpu( - struct domain *d, unsigned int vcpu_id, unsigned int cpu_id); - int boot_vcpu( -- struct domain *d, int vcpuid, struct vcpu_guest_context *ctxt); -+ struct domain *d, int vcpuid, vcpu_guest_context_u ctxt); - struct vcpu *alloc_idle_vcpu(unsigned int cpu_id); - - struct domain *alloc_domain(domid_t domid); -@@ -14,6 +19,9 @@ void free_domain(struct domain *d); - struct xen_domctl_getdomaininfo; - void getdomaininfo( - struct domain *d, struct xen_domctl_getdomaininfo *info); -+struct compat_domctl_getdomaininfo; -+void compat_getdomaininfo( -+ struct domain *d, struct compat_domctl_getdomaininfo *info); - - /* - * Arch-specifics. -@@ -37,7 +45,8 @@ int arch_domain_create(struct domain *d) - - void arch_domain_destroy(struct domain *d); - --int arch_set_info_guest(struct vcpu *v, struct vcpu_guest_context *c); -+int arch_set_info_guest(struct vcpu *, vcpu_guest_context_u); -+void arch_get_info_guest(struct vcpu *, vcpu_guest_context_u); - - void domain_relinquish_resources(struct domain *d); - -Index: 2007-01-08/xen/include/xen/sched.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/sched.h 2007-01-08 15:19:19.000000000 +0100 -+++ 2007-01-08/xen/include/xen/sched.h 2007-01-08 15:20:39.000000000 +0100 -@@ -275,7 +275,13 @@ int construct_dom0( - unsigned long image_start, unsigned long image_len, - unsigned long initrd_start, unsigned long initrd_len, - char *cmdline); --int set_info_guest(struct domain *d, xen_domctl_vcpucontext_t *); -+ -+typedef union { -+ struct xen_domctl_vcpucontext *nat; -+ struct compat_domctl_vcpucontext *cmp; -+} xen_domctl_vcpucontext_u __attribute__((__transparent_union__)); -+ -+int set_info_guest(struct domain *d, xen_domctl_vcpucontext_u); - - struct domain *find_domain_by_id(domid_t dom); - void domain_destroy(struct domain *d); -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:20:32.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:20:39.000000000 +0100 -@@ -11,7 +11,9 @@ - ! vcpu_guest_context arch-@arch@/xen.h - ? acm_getdecision acm_ops.h - ! ctl_cpumap domctl.h --! domctl_getdomaininfo domctl.h -+! domctl_scheduler_op domctl.h -+! domctl_shadow_op domctl.h -+! domctl_shadow_op_stats domctl.h - ? evtchn_alloc_unbound event_channel.h - ? evtchn_bind_interdomain event_channel.h - ? evtchn_bind_ipi event_channel.h diff --git a/32on64-emul.patch b/32on64-emul.patch deleted file mode 100644 index d860710..0000000 --- a/32on64-emul.patch +++ /dev/null @@ -1,647 +0,0 @@ -Adjust emulation code to deal with compatibility mode guests. This -includes enhancements to emulate_privileged_op() that aren't directly -related to such guests. - -Index: 2006-12-18/xen/arch/x86/domain.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/domain.c 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/domain.c 2006-12-18 09:49:18.000000000 +0100 -@@ -1065,6 +1065,20 @@ void domain_relinquish_resources(struct - { - /* Drop ref to guest_table (from new_guest_cr3(), svm/vmx cr3 handling, - * or sh_update_paging_modes()) */ -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ { -+ pfn = l4e_get_pfn(*(l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table))); -+ if ( pfn != 0 ) -+ { -+ if ( shadow_mode_refcounts(d) ) -+ put_page(mfn_to_page(pfn)); -+ else -+ put_page_and_type(mfn_to_page(pfn)); -+ } -+ continue; -+ } -+#endif - pfn = pagetable_get_pfn(v->arch.guest_table); - if ( pfn != 0 ) - { -Index: 2006-12-18/xen/arch/x86/mm.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/mm.c 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/mm.c 2006-12-18 09:49:18.000000000 +0100 -@@ -1759,6 +1759,33 @@ int new_guest_cr3(unsigned long mfn) - if ( is_hvm_domain(d) && !hvm_paging_enabled(v) ) - return 0; - -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ { -+ l4_pgentry_t l4e = l4e_from_pfn(mfn, _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED); -+ -+ if ( shadow_mode_refcounts(d) ) -+ { -+ okay = get_page_from_pagenr(mfn, d); -+ old_base_mfn = l4e_get_pfn(l4e); -+ if ( okay && old_base_mfn ) -+ put_page(mfn_to_page(old_base_mfn)); -+ } -+ else -+ okay = mod_l4_entry(__va(pagetable_get_paddr(v->arch.guest_table)), -+ l4e, 0); -+ if ( unlikely(!okay) ) -+ { -+ MEM_LOG("Error while installing new compat baseptr %lx", mfn); -+ return 0; -+ } -+ -+ invalidate_shadow_ldt(v); -+ write_ptbase(v); -+ -+ return 1; -+ } -+#endif - if ( shadow_mode_refcounts(d) ) - { - okay = get_page_from_pagenr(mfn, d); -@@ -3212,7 +3239,7 @@ static int ptwr_emulated_update( - nl1e = l1e_from_intpte(val); - if ( unlikely(!get_page_from_l1e(gl1e_to_ml1e(d, nl1e), d)) ) - { -- if ( (CONFIG_PAGING_LEVELS == 3) && -+ if ( (CONFIG_PAGING_LEVELS == 3 || IS_COMPAT(d)) && - (bytes == 4) && - !do_cmpxchg && - (l1e_get_flags(nl1e) & _PAGE_PRESENT) ) -@@ -3356,7 +3383,7 @@ int ptwr_do_page_fault(struct vcpu *v, u - goto bail; - - ptwr_ctxt.ctxt.regs = guest_cpu_user_regs(); -- ptwr_ctxt.ctxt.mode = X86EMUL_MODE_HOST; -+ ptwr_ctxt.ctxt.mode = !IS_COMPAT(d) ? X86EMUL_MODE_HOST : X86EMUL_MODE_PROT32; - ptwr_ctxt.cr2 = addr; - ptwr_ctxt.pte = pte; - if ( x86_emulate_memop(&ptwr_ctxt.ctxt, &ptwr_emulate_ops) ) -Index: 2006-12-18/xen/arch/x86/traps.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/traps.c 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/traps.c 2006-12-18 17:53:52.000000000 +0100 -@@ -993,6 +993,64 @@ long do_fpu_taskswitch(int set) - return 0; - } - -+static int read_descriptor(unsigned int sel, -+ const struct vcpu *v, -+ const struct cpu_user_regs * regs, -+ unsigned long *base, -+ unsigned long *limit, -+ unsigned int *ar, -+ unsigned int vm86attr) -+{ -+ struct desc_struct desc; -+ -+ if ( !vm86_mode(regs) ) -+ { -+ if ( sel < 4) -+ desc.b = desc.a = 0; -+ else if ( __get_user(desc, -+ (const struct desc_struct *)(!(sel & 4) -+ ? GDT_VIRT_START(v) -+ : LDT_VIRT_START(v)) -+ + (sel >> 3)) ) -+ return 0; -+ if ( !(vm86attr & _SEGMENT_CODE) ) -+ desc.b &= ~_SEGMENT_L; -+ } -+ else -+ { -+ desc.a = (sel << 20) | 0xffff; -+ desc.b = vm86attr | (sel >> 12); -+ } -+ -+ *ar = desc.b & 0x00f0ff00; -+ if ( !(desc.b & _SEGMENT_L) ) -+ { -+ *base = (desc.a >> 16) + ((desc.b & 0xff) << 16) + (desc.b & 0xff000000); -+ *limit = (desc.a & 0xffff) | (desc.b & 0x000f0000); -+ if ( desc.b & _SEGMENT_G ) -+ *limit = ((*limit + 1) << 12) - 1; -+#ifndef NDEBUG -+ if ( !vm86_mode(regs) && sel > 3 ) -+ { -+ unsigned int a, l; -+ unsigned char valid; -+ -+ __asm__("larl %2, %0\n\tsetz %1" : "=r" (a), "=rm" (valid) : "rm" (sel)); -+ BUG_ON(valid && (a & 0x00f0ff00) != *ar); -+ __asm__("lsll %2, %0\n\tsetz %1" : "=r" (l), "=rm" (valid) : "rm" (sel)); -+ BUG_ON(valid && l != *limit); -+ } -+#endif -+ } -+ else -+ { -+ *base = 0UL; -+ *limit = ~0UL; -+ } -+ -+ return 1; -+} -+ - /* Has the guest requested sufficient permission for this I/O access? */ - static inline int guest_io_okay( - unsigned int port, unsigned int bytes, -@@ -1057,65 +1115,113 @@ unsigned long guest_to_host_gpr_switch(u - __attribute__((__regparm__(1))); - - /* Instruction fetch with error handling. */ --#define insn_fetch(_type, _size, cs, eip) \ --({ unsigned long _rc, _x, _ptr = eip; \ -- if ( vm86_mode(regs) ) \ -- _ptr += cs << 4; \ -- if ( (_rc = copy_from_user(&_x, (_type *)_ptr, sizeof(_type))) != 0 ) \ -+#define insn_fetch(type, base, eip, limit) \ -+({ unsigned long _rc, _ptr = (base) + (eip); \ -+ type _x; \ -+ if ( (limit) < sizeof(_x) - 1 || (eip) > (limit) - (sizeof(_x) - 1) ) \ -+ goto fail; \ -+ if ( (_rc = copy_from_user(&_x, (type *)_ptr, sizeof(_x))) != 0 ) \ - { \ -- propagate_page_fault(eip + sizeof(_type) - _rc, 0); \ -+ propagate_page_fault(_ptr + sizeof(_x) - _rc, 0); \ - return EXCRET_fault_fixed; \ - } \ -- eip += _size; (_type)_x; }) -+ (eip) += sizeof(_x); _x; }) -+ -+#if defined(CONFIG_X86_32) -+# define read_sreg(regs, sr) ((regs)->sr) -+#elif defined(CONFIG_X86_64) -+# define read_sreg(regs, sr) read_segment_register(sr) -+#endif - - static int emulate_privileged_op(struct cpu_user_regs *regs) - { - struct vcpu *v = current; -- unsigned long *reg, eip = regs->eip, cs = regs->cs, res; -- u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0; -- unsigned int port, i, op_bytes = 4, data, rc; -+ unsigned long *reg, eip = regs->eip, res; -+ u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0, rex = 0; -+ enum { lm_seg_none, lm_seg_fs, lm_seg_gs } lm_ovr = lm_seg_none; -+ unsigned int port, i, data_sel, ar, data, rc; -+ unsigned int op_bytes, op_default, ad_bytes, ad_default; -+#define rd_ad(reg) (ad_bytes >= sizeof(regs->reg) \ -+ ? regs->reg \ -+ : ad_bytes == 4 \ -+ ? (u32)regs->reg \ -+ : (u16)regs->reg) -+#define wr_ad(reg, val) (ad_bytes >= sizeof(regs->reg) \ -+ ? regs->reg = (val) \ -+ : ad_bytes == 4 \ -+ ? (*(u32 *)®s->reg = (val)) \ -+ : (*(u16 *)®s->reg = (val))) -+ unsigned long code_base, code_limit; - char io_emul_stub[16]; - void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1))); - u32 l, h; - -+ if ( !read_descriptor(regs->cs, v, regs, -+ &code_base, &code_limit, &ar, -+ _SEGMENT_CODE|_SEGMENT_S|_SEGMENT_DPL|_SEGMENT_P) ) -+ goto fail; -+ op_default = op_bytes = (ar & (_SEGMENT_L|_SEGMENT_DB)) ? 4 : 2; -+ ad_default = ad_bytes = (ar & _SEGMENT_L) ? 8 : op_default; -+ if ( !(ar & (_SEGMENT_CODE|_SEGMENT_S|_SEGMENT_P)) ) -+ goto fail; -+ -+ /* emulating only opcodes not allowing SS to be default */ -+ data_sel = read_sreg(regs, ds); -+ - /* Legacy prefixes. */ -- for ( i = 0; i < 8; i++ ) -+ for ( i = 0; i < 8; i++, rex == opcode || (rex = 0) ) - { -- switch ( opcode = insn_fetch(u8, 1, cs, eip) ) -+ switch ( opcode = insn_fetch(u8, code_base, eip, code_limit) ) - { - case 0x66: /* operand-size override */ -- op_bytes ^= 6; /* switch between 2/4 bytes */ -- break; -+ op_bytes = op_default ^ 6; /* switch between 2/4 bytes */ -+ continue; - case 0x67: /* address-size override */ -+ ad_bytes = ad_default != 4 ? 4 : 2; /* switch to 2/4 bytes */ -+ continue; - case 0x2e: /* CS override */ -+ data_sel = regs->cs; -+ continue; - case 0x3e: /* DS override */ -+ data_sel = read_sreg(regs, ds); -+ continue; - case 0x26: /* ES override */ -+ data_sel = read_sreg(regs, es); -+ continue; - case 0x64: /* FS override */ -+ data_sel = read_sreg(regs, fs); -+ lm_ovr = lm_seg_fs; -+ continue; - case 0x65: /* GS override */ -+ data_sel = read_sreg(regs, gs); -+ lm_ovr = lm_seg_gs; -+ continue; - case 0x36: /* SS override */ -+ data_sel = regs->ss; -+ continue; - case 0xf0: /* LOCK */ -+ continue; - case 0xf2: /* REPNE/REPNZ */ -- break; - case 0xf3: /* REP/REPE/REPZ */ - rep_prefix = 1; -- break; -+ continue; - default: -- goto done_prefixes; -+ if ( (ar & _SEGMENT_L) && (opcode & 0xf0) == 0x40 ) -+ { -+ rex = opcode; -+ continue; -+ } -+ break; - } -+ break; - } -- done_prefixes: - --#ifdef __x86_64__ - /* REX prefix. */ -- if ( (opcode & 0xf0) == 0x40 ) -- { -- modrm_reg = (opcode & 4) << 1; /* REX.R */ -- modrm_rm = (opcode & 1) << 3; /* REX.B */ -- -- /* REX.W and REX.X do not need to be decoded. */ -- opcode = insn_fetch(u8, 1, cs, eip); -- } --#endif -+ if ( rex & 8 ) /* REX.W */ -+ op_bytes = 4; /* emulating only opcodes not supporting 64-bit operands */ -+ modrm_reg = (rex & 4) << 1; /* REX.R */ -+ /* REX.X does not need to be decoded. */ -+ modrm_rm = (rex & 1) << 3; /* REX.B */ - - if ( opcode == 0x0f ) - goto twobyte_opcode; -@@ -1123,16 +1229,68 @@ static int emulate_privileged_op(struct - /* Input/Output String instructions. */ - if ( (opcode >= 0x6c) && (opcode <= 0x6f) ) - { -- if ( rep_prefix && (regs->ecx == 0) ) -+ unsigned long data_base, data_limit; -+ -+ if ( rep_prefix && (rd_ad(ecx) == 0) ) - goto done; - -+ if ( !(opcode & 2) ) -+ { -+ data_sel = read_sreg(regs, es); -+ lm_ovr = lm_seg_none; -+ } -+ -+ if ( !(ar & _SEGMENT_L) ) -+ { -+ if ( !read_descriptor(data_sel, v, regs, -+ &data_base, &data_limit, &ar, -+ _SEGMENT_WR|_SEGMENT_S|_SEGMENT_DPL|_SEGMENT_P) ) -+ goto fail; -+ if ( !(ar & (_SEGMENT_S|_SEGMENT_P)) || -+ (opcode & 2 ? -+ (ar & _SEGMENT_CODE) && !(ar & _SEGMENT_WR) : -+ (ar & _SEGMENT_CODE) || !(ar & _SEGMENT_WR)) ) -+ goto fail; -+ } -+#ifdef CONFIG_X86_64 -+ else -+ { -+ if ( lm_ovr == lm_seg_none || data_sel < 4 ) -+ { -+ switch ( lm_ovr ) -+ { -+ case lm_seg_none: -+ data_base = 0UL; -+ break; -+ case lm_seg_fs: -+ data_base = v->arch.guest_context.fs_base; -+ break; -+ case lm_seg_gs: -+ if ( guest_kernel_mode(v, regs) ) -+ data_base = v->arch.guest_context.gs_base_kernel; -+ else -+ data_base = v->arch.guest_context.gs_base_user; -+ break; -+ } -+ } -+ else -+ read_descriptor(data_sel, v, regs, -+ &data_base, &data_limit, &ar, -+ 0); -+ data_limit = ~0UL; -+ ar = _SEGMENT_WR|_SEGMENT_S|_SEGMENT_DPL|_SEGMENT_P; -+ } -+#endif -+ - continue_io_string: - switch ( opcode ) - { - case 0x6c: /* INSB */ - op_bytes = 1; - case 0x6d: /* INSW/INSL */ -- if ( !guest_io_okay((u16)regs->edx, op_bytes, v, regs) ) -+ if ( data_limit < op_bytes - 1 || -+ rd_ad(edi) > data_limit - (op_bytes - 1) || -+ !guest_io_okay((u16)regs->edx, op_bytes, v, regs) ) - goto fail; - port = (u16)regs->edx; - switch ( op_bytes ) -@@ -1150,24 +1308,26 @@ static int emulate_privileged_op(struct - data = (u32)(guest_inl_okay(port, v, regs) ? inl(port) : ~0); - break; - } -- if ( (rc = copy_to_user((void *)regs->edi, &data, op_bytes)) != 0 ) -+ if ( (rc = copy_to_user((void *)data_base + rd_ad(edi), &data, op_bytes)) != 0 ) - { -- propagate_page_fault(regs->edi + op_bytes - rc, -+ propagate_page_fault(data_base + rd_ad(edi) + op_bytes - rc, - PFEC_write_access); - return EXCRET_fault_fixed; - } -- regs->edi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes); -+ wr_ad(edi, regs->edi + (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes)); - break; - - case 0x6e: /* OUTSB */ - op_bytes = 1; - case 0x6f: /* OUTSW/OUTSL */ -- if ( !guest_io_okay((u16)regs->edx, op_bytes, v, regs) ) -+ if ( data_limit < op_bytes - 1 || -+ rd_ad(esi) > data_limit - (op_bytes - 1) || -+ !guest_io_okay((u16)regs->edx, op_bytes, v, regs) ) - goto fail; -- rc = copy_from_user(&data, (void *)regs->esi, op_bytes); -+ rc = copy_from_user(&data, (void *)data_base + rd_ad(esi), op_bytes); - if ( rc != 0 ) - { -- propagate_page_fault(regs->esi + op_bytes - rc, 0); -+ propagate_page_fault(data_base + rd_ad(esi) + op_bytes - rc, 0); - return EXCRET_fault_fixed; - } - port = (u16)regs->edx; -@@ -1188,11 +1348,11 @@ static int emulate_privileged_op(struct - outl((u32)data, port); - break; - } -- regs->esi += (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes); -+ wr_ad(esi, regs->esi + (int)((regs->eflags & EF_DF) ? -op_bytes : op_bytes)); - break; - } - -- if ( rep_prefix && (--regs->ecx != 0) ) -+ if ( rep_prefix && (wr_ad(ecx, regs->ecx - 1) != 0) ) - { - if ( !hypercall_preempt_check() ) - goto continue_io_string; -@@ -1232,7 +1392,7 @@ static int emulate_privileged_op(struct - case 0xe4: /* IN imm8,%al */ - op_bytes = 1; - case 0xe5: /* IN imm8,%eax */ -- port = insn_fetch(u8, 1, cs, eip); -+ port = insn_fetch(u8, code_base, eip, code_limit); - io_emul_stub[7] = port; /* imm8 */ - exec_in: - if ( !guest_io_okay(port, op_bytes, v, regs) ) -@@ -1274,7 +1434,7 @@ static int emulate_privileged_op(struct - case 0xe6: /* OUT %al,imm8 */ - op_bytes = 1; - case 0xe7: /* OUT %eax,imm8 */ -- port = insn_fetch(u8, 1, cs, eip); -+ port = insn_fetch(u8, code_base, eip, code_limit); - io_emul_stub[7] = port; /* imm8 */ - exec_out: - if ( !guest_io_okay(port, op_bytes, v, regs) ) -@@ -1327,7 +1487,7 @@ static int emulate_privileged_op(struct - goto fail; - - /* Privileged (ring 0) instructions. */ -- opcode = insn_fetch(u8, 1, cs, eip); -+ opcode = insn_fetch(u8, code_base, eip, code_limit); - switch ( opcode ) - { - case 0x06: /* CLTS */ -@@ -1345,7 +1505,7 @@ static int emulate_privileged_op(struct - break; - - case 0x20: /* MOV CR?, */ -- opcode = insn_fetch(u8, 1, cs, eip); -+ opcode = insn_fetch(u8, code_base, eip, code_limit); - modrm_reg |= (opcode >> 3) & 7; - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); -@@ -1361,8 +1521,14 @@ static int emulate_privileged_op(struct - break; - - case 3: /* Read CR3 */ -- *reg = xen_pfn_to_cr3(mfn_to_gmfn( -- v->domain, pagetable_get_pfn(v->arch.guest_table))); -+ if ( !IS_COMPAT(v->domain) ) -+ *reg = xen_pfn_to_cr3(mfn_to_gmfn( -+ v->domain, pagetable_get_pfn(v->arch.guest_table))); -+#ifdef CONFIG_COMPAT -+ else -+ *reg = compat_pfn_to_cr3(mfn_to_gmfn( -+ v->domain, l4e_get_pfn(*(l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table))))); -+#endif - break; - - case 4: /* Read CR4 */ -@@ -1379,7 +1545,7 @@ static int emulate_privileged_op(struct - break; - - case 0x21: /* MOV DR?, */ -- opcode = insn_fetch(u8, 1, cs, eip); -+ opcode = insn_fetch(u8, code_base, eip, code_limit); - modrm_reg |= (opcode >> 3) & 7; - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); -@@ -1389,7 +1555,7 @@ static int emulate_privileged_op(struct - break; - - case 0x22: /* MOV ,CR? */ -- opcode = insn_fetch(u8, 1, cs, eip); -+ opcode = insn_fetch(u8, code_base, eip, code_limit); - modrm_reg |= (opcode >> 3) & 7; - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); -@@ -1412,7 +1578,12 @@ static int emulate_privileged_op(struct - - case 3: /* Write CR3 */ - LOCK_BIGLOCK(v->domain); -- rc = new_guest_cr3(gmfn_to_mfn(v->domain, xen_cr3_to_pfn(*reg))); -+ if ( !IS_COMPAT(v->domain) ) -+ rc = new_guest_cr3(gmfn_to_mfn(v->domain, xen_cr3_to_pfn(*reg))); -+#ifdef CONFIG_COMPAT -+ else -+ rc = new_guest_cr3(gmfn_to_mfn(v->domain, compat_cr3_to_pfn(*reg))); -+#endif - UNLOCK_BIGLOCK(v->domain); - if ( rc == 0 ) /* not okay */ - goto fail; -@@ -1432,7 +1603,7 @@ static int emulate_privileged_op(struct - break; - - case 0x23: /* MOV ,DR? */ -- opcode = insn_fetch(u8, 1, cs, eip); -+ opcode = insn_fetch(u8, code_base, eip, code_limit); - modrm_reg |= (opcode >> 3) & 7; - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); -@@ -1445,18 +1616,24 @@ static int emulate_privileged_op(struct - { - #ifdef CONFIG_X86_64 - case MSR_FS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - if ( wrmsr_safe(MSR_FS_BASE, regs->eax, regs->edx) ) - goto fail; - v->arch.guest_context.fs_base = - ((u64)regs->edx << 32) | regs->eax; - break; - case MSR_GS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - if ( wrmsr_safe(MSR_GS_BASE, regs->eax, regs->edx) ) - goto fail; - v->arch.guest_context.gs_base_kernel = - ((u64)regs->edx << 32) | regs->eax; - break; - case MSR_SHADOW_GS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - if ( wrmsr_safe(MSR_SHADOW_GS_BASE, regs->eax, regs->edx) ) - goto fail; - v->arch.guest_context.gs_base_user = -@@ -1481,14 +1658,20 @@ static int emulate_privileged_op(struct - { - #ifdef CONFIG_X86_64 - case MSR_FS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - regs->eax = v->arch.guest_context.fs_base & 0xFFFFFFFFUL; - regs->edx = v->arch.guest_context.fs_base >> 32; - break; - case MSR_GS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - regs->eax = v->arch.guest_context.gs_base_kernel & 0xFFFFFFFFUL; - regs->edx = v->arch.guest_context.gs_base_kernel >> 32; - break; - case MSR_SHADOW_GS_BASE: -+ if ( IS_COMPAT(v->domain) ) -+ goto fail; - regs->eax = v->arch.guest_context.gs_base_user & 0xFFFFFFFFUL; - regs->edx = v->arch.guest_context.gs_base_user >> 32; - break; -@@ -1517,6 +1700,9 @@ static int emulate_privileged_op(struct - goto fail; - } - -+#undef wr_ad -+#undef rd_ad -+ - done: - regs->eip = eip; - return EXCRET_fault_fixed; -Index: 2006-12-18/xen/arch/x86/x86_64/mm.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/mm.c 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/mm.c 2006-12-18 09:49:18.000000000 +0100 -@@ -376,7 +376,11 @@ int check_descriptor(const struct domain - - /* All code and data segments are okay. No base/limit checking. */ - if ( (b & _SEGMENT_S) ) -- goto good; -+ { -+ if ( !IS_COMPAT(dom) || !(b & _SEGMENT_L) ) -+ goto good; -+ goto bad; -+ } - - /* Invalid type 0 is harmless. It is used for 2nd half of a call gate. */ - if ( (b & _SEGMENT_TYPE) == 0x000 ) -Index: 2006-12-18/xen/include/asm-x86/desc.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/desc.h 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/desc.h 2006-12-18 09:49:18.000000000 +0100 -@@ -113,12 +113,19 @@ - - /* These are bitmasks for the high 32 bits of a descriptor table entry. */ - #define _SEGMENT_TYPE (15<< 8) -+#define _SEGMENT_WR ( 1<< 9) /* Writeable (data) or Readable (code) -+ segment */ - #define _SEGMENT_EC ( 1<<10) /* Expand-down or Conforming segment */ - #define _SEGMENT_CODE ( 1<<11) /* Code (vs data) segment for non-system - segments */ - #define _SEGMENT_S ( 1<<12) /* System descriptor (yes iff S==0) */ - #define _SEGMENT_DPL ( 3<<13) /* Descriptor Privilege Level */ - #define _SEGMENT_P ( 1<<15) /* Segment Present */ -+#ifdef __x86_64 -+#define _SEGMENT_L ( 1<<21) /* 64-bit segment */ -+#else -+#define _SEGMENT_L 0 -+#endif - #define _SEGMENT_DB ( 1<<22) /* 16- or 32-bit segment */ - #define _SEGMENT_G ( 1<<23) /* Granularity */ - -Index: 2006-12-18/xen/include/asm-x86/mm.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/mm.h 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/mm.h 2006-12-18 09:49:18.000000000 +0100 -@@ -279,6 +279,11 @@ int check_descriptor(const struct domain - - #define INVALID_MFN (~0UL) - -+#ifdef CONFIG_COMPAT -+#define compat_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20)) -+#define compat_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20)) -+#endif -+ - #ifdef MEMORY_GUARD - void memguard_init(void); - void memguard_guard_range(void *p, unsigned long l); -Index: 2006-12-18/xen/include/asm-x86/x86_32/uaccess.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/x86_32/uaccess.h 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/x86_32/uaccess.h 2006-12-18 09:49:18.000000000 +0100 -@@ -83,7 +83,7 @@ do { \ - case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; \ - case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break; \ - case 8: __get_user_u64(x,ptr,retval,errret);break; \ -- default: (x) = __get_user_bad(); \ -+ default: __get_user_bad(); \ - } \ - } while (0) - -Index: 2006-12-18/xen/include/asm-x86/x86_64/uaccess.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/x86_64/uaccess.h 2006-12-18 17:53:11.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/x86_64/uaccess.h 2006-12-18 09:49:18.000000000 +0100 -@@ -48,7 +48,7 @@ do { \ - case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; \ - case 4: __get_user_asm(x,ptr,retval,"l","k","=r",errret);break; \ - case 8: __get_user_asm(x,ptr,retval,"q","","=r",errret); break; \ -- default: (x) = __get_user_bad(); \ -+ default: __get_user_bad(); \ - } \ - } while (0) - diff --git a/32on64-fixes.patch b/32on64-fixes.patch deleted file mode 100644 index e279e81..0000000 --- a/32on64-fixes.patch +++ /dev/null @@ -1,110 +0,0 @@ -Index: 2007-01-08/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/traps.c 2007-01-25 13:53:38.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/traps.c 2007-01-25 16:01:23.000000000 +0100 -@@ -1162,7 +1162,9 @@ static int emulate_privileged_op(struct - goto fail; - op_default = op_bytes = (ar & (_SEGMENT_L|_SEGMENT_DB)) ? 4 : 2; - ad_default = ad_bytes = (ar & _SEGMENT_L) ? 8 : op_default; -- if ( !(ar & (_SEGMENT_CODE|_SEGMENT_S|_SEGMENT_P)) ) -+ if ( !(ar & _SEGMENT_S) || -+ !(ar & _SEGMENT_P) || -+ !(ar & _SEGMENT_CODE) ) - goto fail; - - /* emulating only opcodes not allowing SS to be default */ -@@ -1246,7 +1248,8 @@ static int emulate_privileged_op(struct - &data_base, &data_limit, &ar, - _SEGMENT_WR|_SEGMENT_S|_SEGMENT_DPL|_SEGMENT_P) ) - goto fail; -- if ( !(ar & (_SEGMENT_S|_SEGMENT_P)) || -+ if ( !(ar & _SEGMENT_S) || -+ !(ar & _SEGMENT_P) || - (opcode & 2 ? - (ar & _SEGMENT_CODE) && !(ar & _SEGMENT_WR) : - (ar & _SEGMENT_CODE) || !(ar & _SEGMENT_WR)) ) -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-25 13:53:38.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-25 16:01:22.000000000 +0100 -@@ -23,7 +23,9 @@ ENTRY(compat_hypercall) - movq %rsp,%rdi - movl $0xDEADBEEF,%eax - rep stosq -- popq %r9 ; popq %r8 ; popq %rcx; popq %rdx; popq %rsi; popq %rdi -+ popq %r8 ; popq %r9 ; xchgl %r8d,%r9d -+ popq %rdx; popq %rcx; xchgl %edx,%ecx -+ popq %rdi; popq %rsi; xchgl %edi,%esi - movl UREGS_rax(%rsp),%eax - pushq %rax - pushq UREGS_rip+8(%rsp) -@@ -31,8 +33,9 @@ ENTRY(compat_hypercall) - movl %eax,%eax - movl %ebp,%r9d - movl %edi,%r8d -- xchgl %ecx,%esi -+ xchgl %ecx,%esi - movl UREGS_rbx(%rsp),%edi -+ movl %edx,%edx - #endif - leaq compat_hypercall_table(%rip),%r10 - PERFC_INCR(PERFC_hypercalls, %rax) -Index: 2007-01-08/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/mm.c 2007-01-12 17:22:50.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/mm.c 2007-01-10 16:06:16.000000000 +0100 -@@ -1,6 +1,7 @@ - #ifdef CONFIG_COMPAT - - #include -+#include - #include - #include - -@@ -289,20 +290,27 @@ int compat_mmuext_op(XEN_GUEST_HANDLE(mm - if ( err == __HYPERVISOR_mmuext_op ) - { - struct cpu_user_regs *regs = guest_cpu_user_regs(); -- unsigned int left = regs->ecx & ~MMU_UPDATE_PREEMPTED; -+ struct mc_state *mcs = &this_cpu(mc_state); -+ unsigned int arg1 = !test_bit(_MCSF_in_multicall, &mcs->flags) -+ ? regs->ecx -+ : mcs->call.args[1]; -+ unsigned int left = arg1 & ~MMU_UPDATE_PREEMPTED; - -- BUG_ON(!(regs->ecx & MMU_UPDATE_PREEMPTED)); -+ BUG_ON(left == arg1); - BUG_ON(left > count); - guest_handle_add_offset(nat_ops, count - left); - BUG_ON(left + i < count); - guest_handle_add_offset(cmp_uops, (signed int)(count - left - i)); - left = 1; - BUG_ON(!hypercall_xlat_continuation(&left, 0x01, nat_ops, cmp_uops)); -- BUG_ON(left != regs->ecx); -- regs->ecx += count - i; -+ BUG_ON(left != arg1); -+ if (!test_bit(_MCSF_in_multicall, &mcs->flags)) -+ regs->_ecx += count - i; -+ else -+ mcs->compat_call.args[1] += count - i; - } - else -- BUG_ON(rc > 0); -+ BUG_ON(err > 0); - rc = err; - } - -Index: 2007-01-08/xen/include/asm-x86/x86_64/uaccess.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/x86_64/uaccess.h 2006-12-18 09:49:18.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/x86_64/uaccess.h 2007-01-25 15:18:37.000000000 +0100 -@@ -20,7 +20,8 @@ - #define __compat_addr_ok(addr) \ - ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START(current->domain)) - --#define compat_access_ok(addr, size) __compat_addr_ok((addr) + (size)) -+#define compat_access_ok(addr, size) \ -+ __compat_addr_ok((unsigned long)(addr) + ((size) ? (size) - 1 : 0)) - - #define compat_array_access_ok(addr,count,size) \ - (likely((count) < (~0U / (size))) && \ diff --git a/32on64-gnttabop.patch b/32on64-gnttabop.patch deleted file mode 100644 index f75b544..0000000 --- a/32on64-gnttabop.patch +++ /dev/null @@ -1,281 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_grant_table_op. - -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:49:57.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:50:00.000000000 +0100 -@@ -279,7 +279,6 @@ CFIX14: - .section .rodata, "a", @progbits - - #define compat_platform_op domain_crash_synchronous --#define compat_grant_table_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous -Index: 2006-12-18/xen/common/Makefile -=================================================================== ---- 2006-12-18.orig/xen/common/Makefile 2006-12-18 09:49:57.000000000 +0100 -+++ 2006-12-18/xen/common/Makefile 2006-12-18 09:50:00.000000000 +0100 -@@ -42,5 +42,6 @@ version.o: $(BASEDIR)/include/xen/compil - - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies -+grant_table.o: compat/grant_table.c - schedule.o: compat/schedule.c - endif -Index: 2006-12-18/xen/common/compat/grant_table.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/common/compat/grant_table.c 2006-12-18 09:50:00.000000000 +0100 -@@ -0,0 +1,218 @@ -+/****************************************************************************** -+ * common/compat/grant_table.c -+ * -+ */ -+ -+#include -+ -+#define xen_grant_entry grant_entry -+CHECK_grant_entry; -+#undef xen_grant_entry -+ -+#define xen_gnttab_map_grant_ref gnttab_map_grant_ref -+CHECK_gnttab_map_grant_ref; -+#undef xen_gnttab_map_grant_ref -+ -+#define xen_gnttab_unmap_grant_ref gnttab_unmap_grant_ref -+CHECK_gnttab_unmap_grant_ref; -+#undef xen_gnttab_unmap_grant_ref -+ -+DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_compat_t); -+DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_compat_t); -+DEFINE_XEN_GUEST_HANDLE(gnttab_copy_compat_t); -+ -+#define xen_gnttab_dump_table gnttab_dump_table -+CHECK_gnttab_dump_table; -+#undef xen_gnttab_dump_table -+ -+int compat_grant_table_op(unsigned int cmd, -+ XEN_GUEST_HANDLE(void) cmp_uop, -+ unsigned int count) -+{ -+ int rc = 0; -+ unsigned int i; -+ -+ switch ( cmd ) -+ { -+#define CASE(name) \ -+ case GNTTABOP_##name: \ -+ if ( unlikely(!guest_handle_okay(guest_handle_cast(cmp_uop, \ -+ gnttab_##name##_compat_t), \ -+ count)) ) \ -+ rc = -EFAULT; \ -+ break -+ -+#ifndef CHECK_gnttab_map_grant_ref -+ CASE(map_grant_ref); -+#endif -+ -+#ifndef CHECK_gnttab_unmap_grant_ref -+ CASE(unmap_grant_ref); -+#endif -+ -+#ifndef CHECK_gnttab_setup_table -+ CASE(setup_table); -+#endif -+ -+#ifndef CHECK_gnttab_transfer -+ CASE(transfer); -+#endif -+ -+#ifndef CHECK_gnttab_copy -+ CASE(copy); -+#endif -+ -+#ifndef CHECK_gnttab_dump_table -+ CASE(dump_table); -+#endif -+ -+#undef CASE -+ default: -+ return do_grant_table_op(cmd, cmp_uop, count); -+ } -+ -+ if ( count > 512 ) -+ rc = -EINVAL; -+ -+ for ( i = 0; i < count && rc == 0; ) -+ { -+ unsigned int n; -+ union { -+ XEN_GUEST_HANDLE(void) uop; -+ struct gnttab_setup_table *setup; -+ struct gnttab_transfer *xfer; -+ struct gnttab_copy *copy; -+ } nat; -+ union { -+ struct compat_gnttab_setup_table setup; -+ struct compat_gnttab_transfer xfer; -+ struct compat_gnttab_copy copy; -+ } cmp; -+ -+ set_xen_guest_handle(nat.uop, (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id)); -+ switch ( cmd ) -+ { -+ case GNTTABOP_setup_table: -+ if ( unlikely(count > 1) ) -+ rc = -EINVAL; -+ else if ( unlikely(__copy_from_guest(&cmp.setup, cmp_uop, 1)) ) -+ rc = -EFAULT; -+ else if ( unlikely(!compat_handle_okay(cmp.setup.frame_list, cmp.setup.nr_frames)) ) -+ rc = -EFAULT; -+ else -+ { -+ BUILD_BUG_ON((COMPAT_ARG_XLAT_SIZE - sizeof(*nat.setup)) / sizeof(*nat.setup->frame_list.p) < NR_GRANT_FRAMES); -+#define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \ -+ set_xen_guest_handle((_d_)->frame_list, (unsigned long *)(nat.setup + 1)) -+ XLAT_gnttab_setup_table(nat.setup, &cmp.setup); -+#undef XLAT_gnttab_setup_table_HNDL_frame_list -+ rc = gnttab_setup_table(guest_handle_cast(nat.uop, gnttab_setup_table_t), 1); -+ } -+ if ( rc == 0 ) -+ { -+ BUG_ON(nat.setup->nr_frames > NR_GRANT_FRAMES); -+#define XLAT_gnttab_setup_table_HNDL_frame_list(_d_, _s_) \ -+ do \ -+ { \ -+ if ( (_s_)->status == GNTST_okay ) \ -+ { \ -+ for ( i = 0; i < (_s_)->nr_frames; ++i ) \ -+ { \ -+ unsigned int frame = (_s_)->frame_list.p[i]; \ -+ BUG_ON(frame != (_s_)->frame_list.p[i]); \ -+ (void)__copy_to_compat_offset((_d_)->frame_list, i, &frame, 1); \ -+ } \ -+ } \ -+ } while (0) -+ XLAT_gnttab_setup_table(&cmp.setup, nat.setup); -+#undef XLAT_gnttab_setup_table_HNDL_frame_list -+ if ( unlikely(__copy_to_guest(cmp_uop, &cmp.setup, 1)) ) -+ rc = -EFAULT; -+ else -+ i = 1; -+ } -+ break; -+ -+ case GNTTABOP_transfer: -+ for ( n = 0; i < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.xfer) && i < count && rc == 0; ++i, ++n ) -+ { -+ if ( unlikely(__copy_from_guest_offset(&cmp.xfer, cmp_uop, i, 1)) ) -+ rc = -EFAULT; -+ else -+ { -+ XLAT_gnttab_transfer(nat.xfer + n, &cmp.xfer); -+ } -+ } -+ if ( rc == 0 ) -+ rc = gnttab_transfer(guest_handle_cast(nat.uop, gnttab_transfer_t), n); -+ if ( rc == 0 ) -+ { -+ XEN_GUEST_HANDLE(gnttab_transfer_compat_t) xfer; -+ -+ xfer = guest_handle_cast(cmp_uop, gnttab_transfer_compat_t); -+ guest_handle_add_offset(xfer, i); -+ while ( n-- ) -+ { -+ guest_handle_add_offset(xfer, -1); -+ if ( __copy_field_to_guest(xfer, nat.xfer, status) ) -+ rc = -EFAULT; -+ } -+ } -+ break; -+ -+ case GNTTABOP_copy: -+ for ( n = 0; i < COMPAT_ARG_XLAT_SIZE / sizeof(*nat.copy) && i < count && rc == 0; ++i, ++n ) -+ { -+ if ( unlikely(__copy_from_guest_offset(&cmp.copy, cmp_uop, i, 1)) ) -+ rc = -EFAULT; -+ else -+ { -+ enum XLAT_gnttab_copy_source_u source_u; -+ enum XLAT_gnttab_copy_dest_u dest_u; -+ -+ if ( cmp.copy.flags & GNTCOPY_source_gref ) -+ source_u = XLAT_gnttab_copy_source_u_ref; -+ else -+ source_u = XLAT_gnttab_copy_source_u_gmfn; -+ if ( cmp.copy.flags & GNTCOPY_dest_gref ) -+ dest_u = XLAT_gnttab_copy_dest_u_ref; -+ else -+ dest_u = XLAT_gnttab_copy_dest_u_gmfn; -+ XLAT_gnttab_copy(nat.copy + n, &cmp.copy); -+ } -+ } -+ if ( rc == 0 ) -+ rc = gnttab_copy(guest_handle_cast(nat.uop, gnttab_copy_t), n); -+ if ( rc == 0 ) -+ { -+ XEN_GUEST_HANDLE(gnttab_copy_compat_t) copy; -+ -+ copy = guest_handle_cast(cmp_uop, gnttab_copy_compat_t); -+ guest_handle_add_offset(copy, i); -+ while ( n-- ) -+ { -+ guest_handle_add_offset(copy, -1); -+ if ( __copy_field_to_guest(copy, nat.copy, status) ) -+ rc = -EFAULT; -+ } -+ } -+ break; -+ -+ default: -+ domain_crash(current->domain); -+ break; -+ } -+ } -+ -+ return rc; -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-18/xen/common/grant_table.c -=================================================================== ---- 2006-12-18.orig/xen/common/grant_table.c 2006-12-13 11:15:54.000000000 +0100 -+++ 2006-12-18/xen/common/grant_table.c 2006-12-18 09:50:00.000000000 +0100 -@@ -1048,6 +1048,10 @@ do_grant_table_op( - return rc; - } - -+#ifdef CONFIG_COMPAT -+#include "compat/grant_table.c" -+#endif -+ - int - grant_table_create( - struct domain *d) -Index: 2006-12-18/xen/include/xlat.lst -=================================================================== ---- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:49:57.000000000 +0100 -+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:50:00.000000000 +0100 -@@ -20,6 +20,13 @@ - ? evtchn_send event_channel.h - ? evtchn_status event_channel.h - ? evtchn_unmask event_channel.h -+! gnttab_copy grant_table.h -+? gnttab_dump_table grant_table.h -+? gnttab_map_grant_ref grant_table.h -+! gnttab_setup_table grant_table.h -+! gnttab_transfer grant_table.h -+? gnttab_unmap_grant_ref grant_table.h -+? grant_entry grant_table.h - ! add_to_physmap memory.h - ! foreign_memory_map memory.h - ! memory_exchange memory.h diff --git a/32on64-hvm.patch b/32on64-hvm.patch deleted file mode 100644 index 471b482..0000000 --- a/32on64-hvm.patch +++ /dev/null @@ -1,184 +0,0 @@ -unstable c/s 13276: Support for save and restore of compatibility guests - -Signed-off-by: Emmanuel Ackaouy - -unstable c/s 13279: Initial support for HVM compat guests - -Signed-off-by: Emmanuel Ackaouy - -Index: 2007-01-31/tools/libxc/xc_linux_save.c -=================================================================== ---- 2007-01-31.orig/tools/libxc/xc_linux_save.c 2007-01-31 09:19:49.000000000 +0100 -+++ 2007-01-31/tools/libxc/xc_linux_save.c 2007-01-31 09:33:01.000000000 +0100 -@@ -44,6 +44,7 @@ static xen_pfn_t *live_p2m = NULL; - - /* Live mapping of system MFN to PFN table. */ - static xen_pfn_t *live_m2p = NULL; -+static unsigned long m2p_mfn0; - - /* grep fodder: machine_to_phys */ - -@@ -467,13 +468,23 @@ static int canonicalize_pagetable(unsign - ** that this check will fail for other L2s. - */ - if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) { -+ int hstart; -+ unsigned long he; - --/* XXX index of the L2 entry in PAE mode which holds the guest LPT */ --#define PAE_GLPT_L2ENTRY (495) -- pte = ((const uint64_t*)spage)[PAE_GLPT_L2ENTRY]; -+ hstart = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff; -+ he = ((const uint64_t *) spage)[hstart]; - -- if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn]) -- xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff; -+ if ( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) { -+ /* hvirt starts with xen stuff... */ -+ xen_start = hstart; -+ } else if ( hvirt_start != 0xf5800000 ) { -+ /* old L2s from before hole was shrunk... */ -+ hstart = (0xf5800000 >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff; -+ he = ((const uint64_t *) spage)[hstart]; -+ -+ if( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) -+ xen_start = hstart; -+ } - } - - if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) { -@@ -577,6 +588,8 @@ static xen_pfn_t *xc_map_m2p(int xc_hand - return NULL; - } - -+ m2p_mfn0 = entries[0].mfn; -+ - free(extent_start); - free(entries); - -Index: 2007-01-31/tools/libxc/xg_save_restore.h -=================================================================== ---- 2007-01-31.orig/tools/libxc/xg_save_restore.h 2007-01-08 14:16:35.000000000 +0100 -+++ 2007-01-31/tools/libxc/xg_save_restore.h 2007-01-31 09:33:01.000000000 +0100 -@@ -53,8 +53,17 @@ static int get_platform_info(int xc_hand - - *hvirt_start = xen_params.virt_start; - -+ /* -+ * XXX For now, 32bit dom0's can only save/restore 32bit domUs -+ * on 64bit hypervisors, so no need to check which type of domain -+ * we're dealing with. -+ */ - if (strstr(xen_caps, "xen-3.0-x86_64")) -+#if defined(__i386__) -+ *pt_levels = 3; -+#else - *pt_levels = 4; -+#endif - else if (strstr(xen_caps, "xen-3.0-x86_32p")) - *pt_levels = 3; - else if (strstr(xen_caps, "xen-3.0-x86_32")) -Index: 2007-01-31/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domain.c 2007-01-31 09:31:01.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domain.c 2007-01-31 09:34:52.000000000 +0100 -@@ -1405,7 +1405,11 @@ void domain_relinquish_resources(struct - #ifdef CONFIG_COMPAT - if ( IS_COMPAT(d) ) - { -- pfn = l4e_get_pfn(*(l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table))); -+ if ( is_hvm_vcpu(v) ) -+ pfn = pagetable_get_pfn(v->arch.guest_table); -+ else -+ pfn = l4e_get_pfn(*(l4_pgentry_t *)__va(pagetable_get_paddr(v->arch.guest_table))); -+ - if ( pfn != 0 ) - { - if ( shadow_mode_refcounts(d) ) -Index: 2007-01-31/xen/arch/x86/domctl.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domctl.c 2007-01-31 09:29:26.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domctl.c 2007-01-31 09:33:01.000000000 +0100 -@@ -356,7 +356,10 @@ void arch_get_info_guest(struct vcpu *v, - c.nat->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); - #ifdef CONFIG_COMPAT - else -- c.cmp->ctrlreg[3] = compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+ { -+ l4_pgentry_t *l4e = __va(pagetable_get_paddr(v->arch.guest_table)); -+ c.cmp->ctrlreg[3] = compat_pfn_to_cr3(l4e_get_pfn(*l4e)); -+ } - #endif - - c(vm_assist = v->domain->vm_assist); -Index: 2007-01-31/xen/arch/x86/hvm/intercept.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/hvm/intercept.c 2006-12-13 11:15:53.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/hvm/intercept.c 2007-01-31 09:34:52.000000000 +0100 -@@ -180,7 +180,7 @@ int hvm_buffered_io_intercept(ioreq_t *p - spin_lock(buffered_io_lock); - - if ( buffered_iopage->write_pointer - buffered_iopage->read_pointer == -- (unsigned long)IOREQ_BUFFER_SLOT_NUM ) { -+ (unsigned int)IOREQ_BUFFER_SLOT_NUM ) { - /* the queue is full. - * send the iopacket through the normal path. - * NOTE: The arithimetic operation could handle the situation for -Index: 2007-01-31/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-31 09:29:27.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/x86_64/compat/entry.S 2007-01-31 09:34:52.000000000 +0100 -@@ -313,7 +313,7 @@ ENTRY(compat_hypercall_table) - .quad compat_xenoprof_op - .quad do_event_channel_op - .quad compat_physdev_op -- .quad compat_ni_hypercall -+ .quad do_hvm_op - .quad compat_sysctl /* 35 */ - .quad compat_domctl - .quad compat_kexec_op -@@ -356,7 +356,7 @@ ENTRY(compat_hypercall_args_table) - .byte 2 /* compat_xenoprof_op */ - .byte 2 /* compat_event_channel_op */ - .byte 2 /* compat_physdev_op */ -- .byte 0 /* compat_ni_hypercall */ -+ .byte 2 /* do_hvm_op */ - .byte 1 /* compat_sysctl */ /* 35 */ - .byte 1 /* compat_domctl */ - .byte 2 /* compat_kexec_op */ -Index: 2007-01-31/xen/include/asm-x86/x86_64/page.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/x86_64/page.h 2007-01-31 09:29:11.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/x86_64/page.h 2007-01-31 09:33:01.000000000 +0100 -@@ -96,7 +96,7 @@ typedef l4_pgentry_t root_pgentry_t; - #define L3_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */) - #define L4_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */) - --#define COMPAT_L3_DISALLOW_MASK 0xFFFFF1E6U /* must-be-zero */ -+#define COMPAT_L3_DISALLOW_MASK L3_DISALLOW_MASK - - #define PAGE_HYPERVISOR (__PAGE_HYPERVISOR | _PAGE_GLOBAL) - #define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL) -Index: 2007-01-31/xen/include/public/hvm/ioreq.h -=================================================================== ---- 2007-01-31.orig/xen/include/public/hvm/ioreq.h 2006-12-13 11:15:56.000000000 +0100 -+++ 2007-01-31/xen/include/public/hvm/ioreq.h 2007-01-31 09:34:52.000000000 +0100 -@@ -56,6 +56,7 @@ struct ioreq { - uint8_t dir:1; /* 1=read, 0=write */ - uint8_t df:1; - uint8_t type; /* I/O type */ -+ uint8_t _pad0[6]; - uint64_t io_count; /* How many IO done on a vcpu */ - }; - typedef struct ioreq ioreq_t; -@@ -74,8 +75,8 @@ typedef struct shared_iopage shared_iopa - - #define IOREQ_BUFFER_SLOT_NUM 80 - struct buffered_iopage { -- unsigned long read_pointer; -- unsigned long write_pointer; -+ unsigned int read_pointer; -+ unsigned int write_pointer; - ioreq_t ioreq[IOREQ_BUFFER_SLOT_NUM]; - }; /* sizeof this structure must be in one page */ - typedef struct buffered_iopage buffered_iopage_t; diff --git a/32on64-hypercall.patch b/32on64-hypercall.patch deleted file mode 100644 index 1c9b08b..0000000 --- a/32on64-hypercall.patch +++ /dev/null @@ -1,900 +0,0 @@ -Add entry points for handling hypercalls from and returning to -compatibility mode guests. - -Index: 2006-12-18/xen/arch/x86/traps.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/traps.c 2006-12-18 09:37:45.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/traps.c 2006-12-18 09:43:08.000000000 +0100 -@@ -139,6 +139,12 @@ static void show_guest_stack(struct cpu_ - if ( is_hvm_vcpu(current) ) - return; - -+ if ( IS_COMPAT(container_of(regs, struct cpu_info, guest_cpu_user_regs)->current_vcpu->domain) ) -+ { -+ compat_show_guest_stack(regs, debug_stack_lines); -+ return; -+ } -+ - if ( vm86_mode(regs) ) - { - stack = (unsigned long *)((regs->ss << 4) + (regs->esp & 0xffff)); -Index: 2006-12-18/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/Makefile 2006-12-13 11:15:54.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/Makefile 2006-12-18 09:43:08.000000000 +0100 -@@ -2,3 +2,9 @@ obj-y += entry.o - obj-y += gpr_switch.o - obj-y += mm.o - obj-y += traps.o -+ -+ifeq ($(CONFIG_COMPAT),y) -+# extra dependencies -+entry.o: compat/entry.S -+traps.o: compat/traps.c -+endif -Index: 2006-12-18/xen/arch/x86/x86_64/asm-offsets.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/asm-offsets.c 2006-12-18 09:37:45.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/asm-offsets.c 2006-12-18 09:43:08.000000000 +0100 -@@ -53,6 +53,7 @@ void __dummy__(void) - BLANK(); - - OFFSET(VCPU_processor, struct vcpu, processor); -+ OFFSET(VCPU_domain, struct vcpu, domain); - OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info); - OFFSET(VCPU_trap_bounce, struct vcpu, arch.trap_bounce); - OFFSET(VCPU_thread_flags, struct vcpu, arch.flags); -@@ -87,6 +88,10 @@ void __dummy__(void) - OFFSET(VCPU_vmx_cr2, struct vcpu, arch.hvm_vmx.cpu_cr2); - BLANK(); - -+ OFFSET(DOMAIN_domain_flags, struct domain, domain_flags); -+ DEFINE(_DOMF_compat, _DOMF_compat); -+ BLANK(); -+ - OFFSET(VMCB_rax, struct vmcb_struct, rax); - OFFSET(VMCB_tsc_offset, struct vmcb_struct, tsc_offset); - BLANK(); -@@ -95,6 +100,7 @@ void __dummy__(void) - OFFSET(VCPUINFO_upcall_mask, vcpu_info_t, evtchn_upcall_mask); - BLANK(); - -+ OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu); - DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info)); - BLANK(); - -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:43:08.000000000 +0100 -@@ -0,0 +1,395 @@ -+/* -+ * Compatibility hypercall routines. -+ */ -+ -+#include -+ -+.text -+ -+ENTRY(compat_hypercall) -+ pushq $0 -+ movl $TRAP_syscall,4(%rsp) -+ SAVE_ALL -+ GET_CURRENT(%rbx) -+ -+ cmpl $NR_hypercalls,%eax -+ jae compat_bad_hypercall -+#ifndef NDEBUG -+ /* Deliberately corrupt parameter regs not used by this hypercall. */ -+ pushq UREGS_rbx(%rsp); pushq %rcx; pushq %rdx; pushq %rsi; pushq %rdi; pushq UREGS_rbp+5*8(%rsp) -+ leaq compat_hypercall_args_table(%rip),%r10 -+ movq $6,%rcx -+ subb (%r10,%rax,1),%cl -+ movq %rsp,%rdi -+ movl $0xDEADBEEF,%eax -+ rep stosq -+ popq %r9 ; popq %r8 ; popq %rcx; popq %rdx; popq %rsi; popq %rdi -+ movl UREGS_rax(%rsp),%eax -+ pushq %rax -+ pushq UREGS_rip+8(%rsp) -+#else -+ movl %eax,%eax -+ movl %ebp,%r9d -+ movl %edi,%r8d -+ xchgl %ecx,%esi -+ movl UREGS_rbx(%rsp),%edi -+#endif -+ leaq compat_hypercall_table(%rip),%r10 -+ PERFC_INCR(PERFC_hypercalls, %rax) -+ callq *(%r10,%rax,8) -+#ifndef NDEBUG -+ /* Deliberately corrupt parameter regs used by this hypercall. */ -+ popq %r10 # Shadow RIP -+ cmpq %r10,UREGS_rip+8(%rsp) -+ popq %rcx # Shadow hypercall index -+ jne compat_skip_clobber /* If RIP has changed then don't clobber. */ -+ leaq compat_hypercall_args_table(%rip),%r10 -+ movb (%r10,%rcx,1),%cl -+ movl $0xDEADBEEF,%r10d -+ testb %cl,%cl; jz compat_skip_clobber; movl %r10d,UREGS_rbx(%rsp) -+ cmpb $2, %cl; jb compat_skip_clobber; movl %r10d,UREGS_rcx(%rsp) -+ cmpb $3, %cl; jb compat_skip_clobber; movl %r10d,UREGS_rdx(%rsp) -+ cmpb $4, %cl; jb compat_skip_clobber; movl %r10d,UREGS_rsi(%rsp) -+ cmpb $5, %cl; jb compat_skip_clobber; movl %r10d,UREGS_rdi(%rsp) -+ cmpb $6, %cl; jb compat_skip_clobber; movl %r10d,UREGS_rbp(%rsp) -+compat_skip_clobber: -+#endif -+ movl %eax,UREGS_rax(%rsp) # save the return value -+ -+/* %rbx: struct vcpu */ -+compat_test_all_events: -+ cli # tests must not race interrupts -+/*compat_test_softirqs:*/ -+ movl VCPU_processor(%rbx),%eax -+ shlq $IRQSTAT_shift,%rax -+ leaq irq_stat(%rip),%rcx -+ testl $~0,(%rcx,%rax,1) -+ jnz compat_process_softirqs -+ btrq $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+ jc compat_process_nmi -+compat_test_guest_events: -+ movq VCPU_vcpu_info(%rbx),%rax -+ testb $0xFF,VCPUINFO_upcall_mask(%rax) -+ jnz compat_restore_all_guest -+ testb $0xFF,VCPUINFO_upcall_pending(%rax) -+ jz compat_restore_all_guest -+/*compat_process_guest_events:*/ -+ sti -+ leaq VCPU_trap_bounce(%rbx),%rdx -+ movl VCPU_event_addr(%rbx),%eax -+ movl %eax,TRAPBOUNCE_eip(%rdx) -+ movl VCPU_event_sel(%rbx),%eax -+ movl %eax,TRAPBOUNCE_cs(%rdx) -+ movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) -+ call compat_create_bounce_frame -+ jmp compat_test_all_events -+ -+ ALIGN -+/* %rbx: struct vcpu */ -+compat_process_softirqs: -+ sti -+ call do_softirq -+ jmp compat_test_all_events -+ -+ ALIGN -+/* %rbx: struct vcpu */ -+compat_process_nmi: -+ movl VCPU_nmi_addr(%rbx),%eax -+ testl %eax,%eax -+ jz compat_test_all_events -+ btsq $_VCPUF_nmi_masked,VCPU_flags(%rbx) -+ jc 1f -+ sti -+ leaq VCPU_trap_bounce(%rbx),%rdx -+ movl %eax,TRAPBOUNCE_eip(%rdx) -+ movl $FLAT_COMPAT_KERNEL_CS,TRAPBOUNCE_cs(%rdx) -+ movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) -+ call compat_create_bounce_frame -+ jmp compat_test_all_events -+1: -+ btsq $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+ jmp compat_test_guest_events -+ -+compat_bad_hypercall: -+ movl $-ENOSYS,UREGS_rax(%rsp) -+ jmp compat_test_all_events -+ -+/* %rbx: struct vcpu, interrupts disabled */ -+compat_restore_all_guest: -+ RESTORE_ALL -+ addq $8,%rsp -+CFLT0: iretq -+ -+.section .fixup,"ax" -+CFIX0: popq -15*8-8(%rsp) # error_code/entry_vector -+ SAVE_ALL # 15*8 bytes pushed -+ movq -8(%rsp),%rsi # error_code/entry_vector -+ sti # after stack abuse (-1024(%rsp)) -+ pushq $__HYPERVISOR_DS # SS -+ leaq 8(%rsp),%rax -+ pushq %rax # RSP -+ pushfq # RFLAGS -+ pushq $__HYPERVISOR_CS # CS -+ leaq CDBLFLT0(%rip),%rax -+ pushq %rax # RIP -+ pushq %rsi # error_code/entry_vector -+ jmp handle_exception -+CDBLFLT0:GET_CURRENT(%rbx) -+ jmp compat_test_all_events -+compat_failsafe_callback: -+ GET_CURRENT(%rbx) -+ leaq VCPU_trap_bounce(%rbx),%rdx -+ movl VCPU_failsafe_addr(%rbx),%eax -+ movl %eax,TRAPBOUNCE_eip(%rdx) -+ movl VCPU_failsafe_sel(%rbx),%eax -+ movl %eax,TRAPBOUNCE_cs(%rdx) -+ movw $TBF_FAILSAFE,TRAPBOUNCE_flags(%rdx) -+ btq $_VGCF_failsafe_disables_events,VCPU_guest_context_flags(%rbx) -+ jnc 1f -+ orw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) -+1: -+ call compat_create_bounce_frame -+ jmp compat_test_all_events -+.previous -+.section __pre_ex_table,"a" -+ .quad CFLT0,CFIX0 -+.previous -+.section __ex_table,"a" -+ .quad CDBLFLT0,compat_failsafe_callback -+.previous -+ -+/* %rdx: trap_bounce, %rbx: struct vcpu */ -+compat_post_handle_exception: -+ testb $TBF_EXCEPTION,TRAPBOUNCE_flags(%rdx) -+ jz compat_test_all_events -+ call compat_create_bounce_frame -+ jmp compat_test_all_events -+ -+/* CREATE A BASIC EXCEPTION FRAME ON GUEST OS (RING-1) STACK: */ -+/* {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]} */ -+/* %rdx: trap_bounce, %rbx: struct vcpu */ -+/* On return only %rbx is guaranteed non-clobbered. */ -+compat_create_bounce_frame: -+ mov %fs,%edi -+ testb $2,UREGS_cs+8(%rsp) -+ jz 1f -+ /* Push new frame at registered guest-OS stack base. */ -+ movl VCPU_kernel_sp(%rbx),%esi -+CFLT1: mov VCPU_kernel_ss(%rbx),%fs -+ subl $2*4,%esi -+ movl UREGS_rsp+8(%rsp),%eax -+CFLT2: movl %eax,%fs:(%rsi) -+ movl UREGS_ss+8(%rsp),%eax -+CFLT3: movl %eax,%fs:4(%rsi) -+ jmp 2f -+1: /* In kernel context already: push new frame at existing %rsp. */ -+ movl UREGS_rsp+8(%rsp),%esi -+CFLT4: mov UREGS_ss+8(%rsp),%fs -+2: -+ movb TRAPBOUNCE_flags(%rdx),%cl -+ subl $3*4,%esi -+ movq VCPU_vcpu_info(%rbx),%rax -+ pushq VCPUINFO_upcall_mask(%rax) -+ testb $TBF_INTERRUPT,%cl -+ setnz %ch # TBF_INTERRUPT -> set upcall mask -+ orb %ch,VCPUINFO_upcall_mask(%rax) -+ popq %rax -+ shll $16,%eax # Bits 16-23: saved_upcall_mask -+ movw UREGS_cs+8(%rsp),%ax # Bits 0-15: CS -+CFLT5: movl %eax,%fs:4(%rsi) # CS / saved_upcall_mask -+ shrl $16,%eax -+ testb %al,%al # Bits 0-7: saved_upcall_mask -+ setz %ch # %ch == !saved_upcall_mask -+ movl UREGS_eflags+8(%rsp),%eax -+ andl $~X86_EFLAGS_IF,%eax -+ shlb $1,%ch # Bit 9 (EFLAGS.IF) -+ orb %ch,%ah # Fold EFLAGS.IF into %eax -+CFLT6: movl %eax,%fs:2*4(%rsi) # EFLAGS -+ movl UREGS_rip+8(%rsp),%eax -+CFLT7: movl %eax,%fs:(%rsi) # EIP -+ testb $TBF_EXCEPTION_ERRCODE,%cl -+ jz 1f -+ subl $4,%esi -+ movl TRAPBOUNCE_error_code(%rdx),%eax -+CFLT8: movl %eax,%fs:(%rsi) # ERROR CODE -+1: -+ testb $TBF_FAILSAFE,%cl -+ jz 2f -+ subl $4*4,%esi -+ movl %gs,%eax -+CFLT9: movl %eax,%fs:3*4(%rsi) # GS -+CFLT10: movl %edi,%fs:2*4(%rsi) # FS -+ movl %es,%eax -+CFLT11: movl %eax,%fs:1*4(%rsi) # ES -+ movl %ds,%eax -+CFLT12: movl %eax,%fs:0*4(%rsi) # DS -+2: -+ /* Rewrite our stack frame and return to guest-OS mode. */ -+ /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */ -+ movl $TRAP_syscall,UREGS_entry_vector+8(%rsp) -+ andl $~(X86_EFLAGS_VM|X86_EFLAGS_RF|\ -+ X86_EFLAGS_NT|X86_EFLAGS_TF),UREGS_eflags+8(%rsp) -+ mov %fs,UREGS_ss+8(%rsp) -+ movl %esi,UREGS_rsp+8(%rsp) -+CFLT13: mov %edi,%fs -+ movzwl TRAPBOUNCE_cs(%rdx),%eax -+ /* Null selectors (0-3) are not allowed. */ -+ testl $~3,%eax -+ jz domain_crash_synchronous -+ movl %eax,UREGS_cs+8(%rsp) -+ movl TRAPBOUNCE_eip(%rdx),%eax -+ movl %eax,UREGS_rip+8(%rsp) -+ movb $0,TRAPBOUNCE_flags(%rdx) -+ ret -+.section .fixup,"ax" -+CFIX13: -+ xorl %edi,%edi -+ jmp CFLT13 -+.previous -+.section __ex_table,"a" -+ .quad CFLT1,domain_crash_synchronous , CFLT2,compat_crash_page_fault -+ .quad CFLT3,compat_crash_page_fault_4 , CFLT4,domain_crash_synchronous -+ .quad CFLT5,compat_crash_page_fault_4 , CFLT6,compat_crash_page_fault_8 -+ .quad CFLT7,compat_crash_page_fault , CFLT8,compat_crash_page_fault -+ .quad CFLT9,compat_crash_page_fault_12, CFLT10,compat_crash_page_fault_8 -+ .quad CFLT11,compat_crash_page_fault_4 , CFLT12,compat_crash_page_fault -+ .quad CFLT13,CFIX13 -+.previous -+ -+compat_crash_page_fault_12: -+ addl $4,%esi -+compat_crash_page_fault_8: -+ addl $4,%esi -+compat_crash_page_fault_4: -+ addl $4,%esi -+compat_crash_page_fault: -+CFLT14: mov %edi,%fs -+ movl %esi,%edi -+ call show_page_walk -+ jmp domain_crash_synchronous -+.section .fixup,"ax" -+CFIX14: -+ xorl %edi,%edi -+ jmp CFLT14 -+.previous -+.section __ex_table,"a" -+ .quad CFLT14,CFIX14 -+.previous -+ -+.section .rodata, "a", @progbits -+ -+#define compat_set_trap_table domain_crash_synchronous -+#define compat_mmu_update domain_crash_synchronous -+#define compat_set_gdt domain_crash_synchronous -+#define compat_stack_switch domain_crash_synchronous -+#define compat_fpu_taskswitch domain_crash_synchronous -+#define compat_arch_sched_op_compat domain_crash_synchronous -+#define compat_platform_op domain_crash_synchronous -+#define compat_set_debugreg domain_crash_synchronous -+#define compat_get_debugreg domain_crash_synchronous -+#define compat_update_descriptor domain_crash_synchronous -+#define compat_memory_op domain_crash_synchronous -+#define compat_multicall domain_crash_synchronous -+#define compat_update_va_mapping domain_crash_synchronous -+#define compat_set_timer_op domain_crash_synchronous -+#define compat_event_channel_op_compat domain_crash_synchronous -+#define compat_xen_version domain_crash_synchronous -+#define compat_console_io domain_crash_synchronous -+#define compat_physdev_op_compat domain_crash_synchronous -+#define compat_grant_table_op domain_crash_synchronous -+#define compat_vm_assist domain_crash_synchronous -+#define compat_update_va_mapping_otherdomain domain_crash_synchronous -+#define compat_vcpu_op domain_crash_synchronous -+#define compat_mmuext_op domain_crash_synchronous -+#define compat_acm_op domain_crash_synchronous -+#define compat_nmi_op domain_crash_synchronous -+#define compat_arch_sched_op domain_crash_synchronous -+#define compat_xenoprof_op domain_crash_synchronous -+#define compat_event_channel_op domain_crash_synchronous -+#define compat_physdev_op domain_crash_synchronous -+#define compat_sysctl domain_crash_synchronous -+#define compat_domctl domain_crash_synchronous -+ -+ENTRY(compat_hypercall_table) -+ .quad compat_set_trap_table /* 0 */ -+ .quad compat_mmu_update -+ .quad compat_set_gdt -+ .quad compat_stack_switch -+ .quad compat_set_callbacks -+ .quad compat_fpu_taskswitch /* 5 */ -+ .quad compat_arch_sched_op_compat -+ .quad compat_platform_op -+ .quad compat_set_debugreg -+ .quad compat_get_debugreg -+ .quad compat_update_descriptor /* 10 */ -+ .quad do_ni_hypercall -+ .quad compat_memory_op -+ .quad compat_multicall -+ .quad compat_update_va_mapping -+ .quad compat_set_timer_op /* 15 */ -+ .quad compat_event_channel_op_compat -+ .quad compat_xen_version -+ .quad compat_console_io -+ .quad compat_physdev_op_compat -+ .quad compat_grant_table_op /* 20 */ -+ .quad compat_vm_assist -+ .quad compat_update_va_mapping_otherdomain -+ .quad compat_iret -+ .quad compat_vcpu_op -+ .quad do_ni_hypercall /* 25 */ -+ .quad compat_mmuext_op -+ .quad compat_acm_op -+ .quad compat_nmi_op -+ .quad compat_arch_sched_op -+ .quad compat_callback_op /* 30 */ -+ .quad compat_xenoprof_op -+ .quad compat_event_channel_op -+ .quad compat_physdev_op -+ .quad do_ni_hypercall -+ .quad compat_sysctl /* 35 */ -+ .quad compat_domctl -+ .rept NR_hypercalls-((.-compat_hypercall_table)/8) -+ .quad do_ni_hypercall -+ .endr -+ -+ENTRY(compat_hypercall_args_table) -+ .byte 1 /* compat_set_trap_table */ /* 0 */ -+ .byte 4 /* compat_mmu_update */ -+ .byte 2 /* compat_set_gdt */ -+ .byte 2 /* compat_stack_switch */ -+ .byte 4 /* compat_set_callbacks */ -+ .byte 1 /* compat_fpu_taskswitch */ /* 5 */ -+ .byte 2 /* compat_arch_sched_op_compat */ -+ .byte 1 /* compat_platform_op */ -+ .byte 2 /* compat_set_debugreg */ -+ .byte 1 /* compat_get_debugreg */ -+ .byte 4 /* compat_update_descriptor */ /* 10 */ -+ .byte 0 /* do_ni_hypercall */ -+ .byte 2 /* compat_memory_op */ -+ .byte 2 /* compat_multicall */ -+ .byte 4 /* compat_update_va_mapping */ -+ .byte 2 /* compat_set_timer_op */ /* 15 */ -+ .byte 1 /* compat_event_channel_op_compat */ -+ .byte 2 /* compat_xen_version */ -+ .byte 3 /* compat_console_io */ -+ .byte 1 /* compat_physdev_op_compat */ -+ .byte 3 /* compat_grant_table_op */ /* 20 */ -+ .byte 2 /* compat_vm_assist */ -+ .byte 5 /* compat_update_va_mapping_otherdomain */ -+ .byte 0 /* compat_iret */ -+ .byte 3 /* compat_vcpu_op */ -+ .byte 0 /* do_ni_hypercall */ /* 25 */ -+ .byte 4 /* compat_mmuext_op */ -+ .byte 1 /* compat_acm_op */ -+ .byte 2 /* compat_nmi_op */ -+ .byte 2 /* compat_arch_sched_op */ -+ .byte 2 /* compat_callback_op */ /* 30 */ -+ .byte 2 /* compat_xenoprof_op */ -+ .byte 2 /* compat_event_channel_op */ -+ .byte 2 /* compat_physdev_op */ -+ .byte 0 /* do_ni_hypercall */ -+ .byte 1 /* compat_sysctl */ /* 35 */ -+ .byte 1 /* compat_domctl */ -+ .rept NR_hypercalls-(.-compat_hypercall_args_table) -+ .byte 0 /* do_ni_hypercall */ -+ .endr -Index: 2006-12-18/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/traps.c 2006-12-18 09:43:08.000000000 +0100 -@@ -0,0 +1,312 @@ -+#ifdef CONFIG_COMPAT -+ -+#if 0 /* XXX */ -+#include -+#else -+struct compat_xen_callback { -+ unsigned int cs; -+ unsigned int eip; -+}; -+typedef struct compat_xen_callback xen_callback_compat_t; -+ -+struct compat_callback_register { -+ uint16_t type; -+ uint16_t flags; -+ xen_callback_compat_t address; -+}; -+ -+struct compat_callback_unregister { -+ uint16_t type; -+ uint16_t _unused; -+}; -+#endif -+ -+void compat_show_guest_stack(struct cpu_user_regs *regs, int debug_stack_lines) -+{ -+ unsigned int i, *stack, addr; -+ -+ stack = (unsigned int *)(unsigned long)regs->_esp; -+ printk("Guest stack trace from esp=%08lx:\n ", (unsigned long)stack); -+ -+ for ( i = 0; i < debug_stack_lines * 8; i++ ) -+ { -+ if ( (((long)stack + 3) & (STACK_SIZE - 4)) == 0 ) -+ break; -+ if ( get_user(addr, stack) ) -+ { -+ if ( i != 0 ) -+ printk("\n "); -+ printk("Fault while accessing guest memory."); -+ i = 1; -+ break; -+ } -+ if ( (i != 0) && ((i % 8) == 0) ) -+ printk("\n "); -+ printk(" %08x", addr); -+ stack++; -+ } -+ if ( i == 0 ) -+ printk("Stack empty."); -+ printk("\n"); -+} -+ -+unsigned int compat_iret(void) -+{ -+ struct cpu_user_regs *regs = guest_cpu_user_regs(); -+ u32 eflags; -+ -+ /* Restore EAX (clobbered by hypercall). */ -+ if ( unlikely(__get_user(regs->_eax, (u32 __user *)regs->rsp)) ) -+ goto exit_and_crash; -+ -+ /* Restore CS and EIP. */ -+ if ( unlikely(__get_user(regs->_eip, (u32 __user *)regs->rsp + 1)) || -+ unlikely(__get_user(regs->cs, (u32 __user *)regs->rsp + 2)) ) -+ goto exit_and_crash; -+ -+ /* -+ * Fix up and restore EFLAGS. We fix up in a local staging area -+ * to avoid firing the BUG_ON(IOPL) check in arch_getdomaininfo_ctxt. -+ */ -+ if ( unlikely(__get_user(eflags, (u32 __user *)regs->rsp + 3)) ) -+ goto exit_and_crash; -+ regs->_eflags = (eflags & ~X86_EFLAGS_IOPL) | X86_EFLAGS_IF; -+ -+ if ( unlikely(eflags & X86_EFLAGS_VM) ) -+ { -+ /* -+ * Cannot return to VM86 mode: inject a GP fault instead. Note that -+ * the GP fault is reported on the first VM86 mode instruction, not on -+ * the IRET (which is why we can simply leave the stack frame as-is -+ * (except for perhaps having to copy it), which in turn seems better -+ * than teaching create_bounce_frame() to needlessly deal with vm86 -+ * mode frames). -+ */ -+ const struct trap_info *ti; -+ u32 x, ksp = current->arch.guest_context.kernel_sp - 40; -+ unsigned int i; -+ int rc = 0; -+ -+ gdprintk(XENLOG_ERR, "VM86 mode unavailable (ksp:%08X->%08X)\n", -+ regs->_esp, ksp); -+ if ( ksp < regs->_esp ) -+ { -+ for (i = 1; i < 10; ++i) -+ { -+ rc |= __get_user(x, (u32 __user *)regs->rsp + i); -+ rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i); -+ } -+ } -+ else if ( ksp > regs->_esp ) -+ { -+ for (i = 9; i > 0; ++i) -+ { -+ rc |= __get_user(x, (u32 __user *)regs->rsp + i); -+ rc |= __put_user(x, (u32 __user *)(unsigned long)ksp + i); -+ } -+ } -+ if ( rc ) -+ goto exit_and_crash; -+ regs->_esp = ksp; -+ regs->ss = current->arch.guest_context.kernel_ss; -+ -+ ti = ¤t->arch.guest_context.trap_ctxt[13]; -+ if ( TI_GET_IF(ti) ) -+ eflags &= ~X86_EFLAGS_IF; -+ regs->_eflags = eflags & ~(X86_EFLAGS_VM|X86_EFLAGS_RF| -+ X86_EFLAGS_NT|X86_EFLAGS_TF); -+ -+ if ( unlikely(__put_user(0, (u32 __user *)regs->rsp)) ) -+ goto exit_and_crash; -+ regs->_eip = ti->address; -+ regs->cs = ti->cs; -+ } -+ else if ( unlikely(ring_0(regs)) ) -+ goto exit_and_crash; -+ else if ( !ring_1(regs) ) -+ { -+ /* Return to ring 2/3: restore ESP and SS. */ -+ if ( __get_user(regs->ss, (u32 __user *)regs->rsp + 5) -+ || __get_user(regs->_esp, (u32 __user *)regs->rsp + 4)) -+ goto exit_and_crash; -+ } -+ else -+ regs->_esp += 16; -+ -+ /* No longer in NMI context. */ -+ clear_bit(_VCPUF_nmi_masked, ¤t->vcpu_flags); -+ -+ /* Restore upcall mask from supplied EFLAGS.IF. */ -+ current->vcpu_info->evtchn_upcall_mask = !(eflags & X86_EFLAGS_IF); -+ -+ /* -+ * The hypercall exit path will overwrite EAX with this return -+ * value. -+ */ -+ return regs->_eax; -+ -+ exit_and_crash: -+ gdprintk(XENLOG_ERR, "Fatal error\n"); -+ domain_crash(current->domain); -+ return 0; -+} -+ -+static long compat_register_guest_callback(struct compat_callback_register *reg) -+{ -+ long ret = 0; -+ struct vcpu *v = current; -+ -+ fixup_guest_code_selector(v->domain, reg->address.cs); -+ -+ switch ( reg->type ) -+ { -+ case CALLBACKTYPE_event: -+ v->arch.guest_context.event_callback_cs = reg->address.cs; -+ v->arch.guest_context.event_callback_eip = reg->address.eip; -+ break; -+ -+ case CALLBACKTYPE_failsafe: -+ v->arch.guest_context.failsafe_callback_cs = reg->address.cs; -+ v->arch.guest_context.failsafe_callback_eip = reg->address.eip; -+ if ( reg->flags & CALLBACKF_mask_events ) -+ set_bit(_VGCF_failsafe_disables_events, -+ &v->arch.guest_context.flags); -+ else -+ clear_bit(_VGCF_failsafe_disables_events, -+ &v->arch.guest_context.flags); -+ break; -+ -+ case CALLBACKTYPE_nmi: -+ ret = register_guest_nmi_callback(reg->address.eip); -+ break; -+ -+ default: -+ ret = -EINVAL; -+ break; -+ } -+ -+ return ret; -+} -+ -+static long compat_unregister_guest_callback(struct compat_callback_unregister *unreg) -+{ -+ long ret; -+ -+ switch ( unreg->type ) -+ { -+ case CALLBACKTYPE_nmi: -+ ret = unregister_guest_nmi_callback(); -+ break; -+ -+ default: -+ ret = -EINVAL; -+ break; -+ } -+ -+ return ret; -+} -+ -+ -+long compat_callback_op(int cmd, XEN_GUEST_HANDLE(void) arg) -+{ -+ long ret; -+ -+ switch ( cmd ) -+ { -+ case CALLBACKOP_register: -+ { -+ struct compat_callback_register reg; -+ -+ ret = -EFAULT; -+ if ( copy_from_guest(®, arg, 1) ) -+ break; -+ -+ ret = compat_register_guest_callback(®); -+ } -+ break; -+ -+ case CALLBACKOP_unregister: -+ { -+ struct compat_callback_unregister unreg; -+ -+ ret = -EFAULT; -+ if ( copy_from_guest(&unreg, arg, 1) ) -+ break; -+ -+ ret = compat_unregister_guest_callback(&unreg); -+ } -+ break; -+ -+ default: -+ ret = -EINVAL; -+ break; -+ } -+ -+ return ret; -+} -+ -+long compat_set_callbacks(unsigned long event_selector, -+ unsigned long event_address, -+ unsigned long failsafe_selector, -+ unsigned long failsafe_address) -+{ -+ struct compat_callback_register event = { -+ .type = CALLBACKTYPE_event, -+ .address = { -+ .cs = event_selector, -+ .eip = event_address -+ } -+ }; -+ struct compat_callback_register failsafe = { -+ .type = CALLBACKTYPE_failsafe, -+ .address = { -+ .cs = failsafe_selector, -+ .eip = failsafe_address -+ } -+ }; -+ -+ compat_register_guest_callback(&event); -+ compat_register_guest_callback(&failsafe); -+ -+ return 0; -+} -+ -+#endif /* CONFIG_COMPAT */ -+ -+static void hypercall_page_initialise_ring1_kernel(void *hypercall_page) -+{ -+ char *p; -+ int i; -+ -+ /* Fill in all the transfer points with template machine code. */ -+ -+ for ( i = 0; i < (PAGE_SIZE / 32); i++ ) -+ { -+ p = (char *)(hypercall_page + (i * 32)); -+ *(u8 *)(p+ 0) = 0xb8; /* mov $,%eax */ -+ *(u32 *)(p+ 1) = i; -+ *(u16 *)(p+ 5) = 0x82cd; /* int $0x82 */ -+ *(u8 *)(p+ 7) = 0xc3; /* ret */ -+ } -+ -+ /* -+ * HYPERVISOR_iret is special because it doesn't return and expects a -+ * special stack frame. Guests jump at this transfer point instead of -+ * calling it. -+ */ -+ p = (char *)(hypercall_page + (__HYPERVISOR_iret * 32)); -+ *(u8 *)(p+ 0) = 0x50; /* push %eax */ -+ *(u8 *)(p+ 1) = 0xb8; /* mov $__HYPERVISOR_iret,%eax */ -+ *(u32 *)(p+ 2) = __HYPERVISOR_iret; -+ *(u16 *)(p+ 6) = 0x82cd; /* int $0x82 */ -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-18/xen/arch/x86/x86_64/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/entry.S 2006-12-18 09:36:35.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/entry.S 2006-12-18 09:43:08.000000000 +0100 -@@ -337,7 +337,16 @@ domain_crash_synchronous: - GET_GUEST_REGS(%rax) - movq %rax,%rsp - # create_bounce_frame() temporarily clobbers CS.RPL. Fix up. -+#ifdef CONFIG_COMPAT -+ movq CPUINFO_current_vcpu(%rax),%rax -+ movq VCPU_domain(%rax),%rax -+ btl $_DOMF_compat,DOMAIN_domain_flags(%rax) -+ setnc %al -+ leal (%rax,%rax,2),%eax -+ orb %al,UREGS_cs(%rsp) -+#else - orb $3,UREGS_cs(%rsp) -+#endif - # printk(domain_crash_synchronous_string) - leaq domain_crash_synchronous_string(%rip),%rdi - xorl %eax,%eax -@@ -349,8 +358,15 @@ domain_crash_synchronous: - ENTRY(ret_from_intr) - GET_CURRENT(%rbx) - testb $3,UREGS_cs(%rsp) -- jnz test_all_events -- jmp restore_all_xen -+ jz restore_all_xen -+#ifndef CONFIG_COMPAT -+ jmp test_all_events -+#else -+ movq VCPU_domain(%rbx),%rax -+ btl $_DOMF_compat,DOMAIN_domain_flags(%rax) -+ jnc test_all_events -+ jmp compat_test_all_events -+#endif - - ALIGN - /* No special register assumptions. */ -@@ -368,6 +384,11 @@ handle_exception: - testb $3,UREGS_cs(%rsp) - jz restore_all_xen - leaq VCPU_trap_bounce(%rbx),%rdx -+#ifdef CONFIG_COMPAT -+ movq VCPU_domain(%rbx),%rax -+ btl $_DOMF_compat,DOMAIN_domain_flags(%rax) -+ jc compat_post_handle_exception -+#endif - testb $TBF_EXCEPTION,TRAPBOUNCE_flags(%rdx) - jz test_all_events - call create_bounce_frame -@@ -625,3 +646,7 @@ ENTRY(hypercall_args_table) - .rept NR_hypercalls-(.-hypercall_args_table) - .byte 0 /* do_ni_hypercall */ - .endr -+ -+#ifdef CONFIG_COMPAT -+#include "compat/entry.S" -+#endif -Index: 2006-12-18/xen/arch/x86/x86_64/traps.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/traps.c 2006-12-18 09:37:45.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/traps.c 2006-12-18 09:43:08.000000000 +0100 -@@ -246,6 +246,7 @@ unsigned long do_iret(void) - } - - asmlinkage void syscall_enter(void); -+asmlinkage void compat_hypercall(void); - void __init percpu_traps_init(void) - { - char *stack_bottom, *stack; -@@ -257,6 +258,11 @@ void __init percpu_traps_init(void) - set_intr_gate(TRAP_double_fault, &double_fault); - idt_table[TRAP_double_fault].a |= 1UL << 32; /* IST1 */ - idt_table[TRAP_nmi].a |= 2UL << 32; /* IST2 */ -+ -+#ifdef CONFIG_COMPAT -+ /* The hypercall entry vector is only accessible from ring 1. */ -+ _set_gate(idt_table+HYPERCALL_VECTOR, 15, 1, &compat_hypercall); -+#endif - } - - stack_bottom = (char *)get_stack_bottom(); -@@ -503,12 +509,16 @@ static void hypercall_page_initialise_ri - *(u16 *)(p+ 9) = 0x050f; /* syscall */ - } - -+#include "compat/traps.c" -+ - void hypercall_page_initialise(struct domain *d, void *hypercall_page) - { - if ( is_hvm_domain(d) ) - hvm_hypercall_page_initialise(d, hypercall_page); -- else -+ else if ( !IS_COMPAT(d) ) - hypercall_page_initialise_ring3_kernel(hypercall_page); -+ else -+ hypercall_page_initialise_ring1_kernel(hypercall_page); - } - - /* -Index: 2006-12-18/xen/include/asm-x86/processor.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/processor.h 2006-12-13 11:15:56.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/processor.h 2006-12-18 09:43:08.000000000 +0100 -@@ -559,6 +559,12 @@ void show_execution_state(struct cpu_use - void show_page_walk(unsigned long addr); - asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs); - -+#ifdef CONFIG_COMPAT -+void compat_show_guest_stack(struct cpu_user_regs *, int lines); -+#else -+#define compat_show_guest_stack(regs, lines) ((void)0) -+#endif -+ - /* Dumps current register and stack state. */ - #define dump_execution_state() \ - /* NB. Needs interrupts enabled else we end up in fatal_trap(). */ \ diff --git a/32on64-interface.patch b/32on64-interface.patch deleted file mode 100644 index 983f68b..0000000 --- a/32on64-interface.patch +++ /dev/null @@ -1,616 +0,0 @@ -Add logic to generate headers reflecting the compatibility mode layout -of hypercall arguments. Provide infrastructure for accessing handles -passed from compatibility mode guests. Vector those hypercalls not -needing any translation to their native implementations. - -Index: 2007-01-08/xen/Makefile -=================================================================== ---- 2007-01-08.orig/xen/Makefile 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/Makefile 2007-01-08 15:17:29.000000000 +0100 -@@ -48,6 +48,7 @@ _debug: - .PHONY: _clean - _clean: delete-unfresh-files - $(MAKE) -C tools clean -+ $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C acm clean -@@ -69,6 +70,7 @@ $(TARGET): delete-unfresh-files - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/acm_policy.h - [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm -+ $(MAKE) -f $(BASEDIR)/Rules.mk -C include - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s - $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $(TARGET) -Index: 2007-01-08/xen/Rules.mk -=================================================================== ---- 2007-01-08.orig/xen/Rules.mk 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/Rules.mk 2007-01-08 15:17:29.000000000 +0100 -@@ -34,6 +34,7 @@ TARGET := $(BASEDIR)/xen - - HDRS := $(wildcard $(BASEDIR)/include/xen/*.h) - HDRS += $(wildcard $(BASEDIR)/include/public/*.h) -+HDRS += $(wildcard $(BASEDIR)/include/compat/*.h) - HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/*.h) - HDRS += $(wildcard $(BASEDIR)/include/asm-$(TARGET_ARCH)/$(TARGET_SUBARCH)/*.h) - -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:17:29.000000000 +0100 -@@ -281,28 +281,19 @@ CFIX14: - #define compat_set_trap_table domain_crash_synchronous - #define compat_mmu_update domain_crash_synchronous - #define compat_set_gdt domain_crash_synchronous --#define compat_stack_switch domain_crash_synchronous --#define compat_fpu_taskswitch domain_crash_synchronous --#define compat_arch_sched_op_compat domain_crash_synchronous - #define compat_platform_op domain_crash_synchronous --#define compat_set_debugreg domain_crash_synchronous --#define compat_get_debugreg domain_crash_synchronous - #define compat_update_descriptor domain_crash_synchronous - #define compat_memory_op domain_crash_synchronous - #define compat_multicall domain_crash_synchronous - #define compat_update_va_mapping domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous - #define compat_event_channel_op_compat domain_crash_synchronous --#define compat_xen_version domain_crash_synchronous --#define compat_console_io domain_crash_synchronous - #define compat_physdev_op_compat domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous --#define compat_vm_assist domain_crash_synchronous - #define compat_update_va_mapping_otherdomain domain_crash_synchronous - #define compat_vcpu_op domain_crash_synchronous - #define compat_mmuext_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous --#define compat_nmi_op domain_crash_synchronous - #define compat_arch_sched_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous - #define compat_event_channel_op domain_crash_synchronous -@@ -314,29 +305,29 @@ ENTRY(compat_hypercall_table) - .quad compat_set_trap_table /* 0 */ - .quad compat_mmu_update - .quad compat_set_gdt -- .quad compat_stack_switch -+ .quad do_stack_switch - .quad compat_set_callbacks -- .quad compat_fpu_taskswitch /* 5 */ -- .quad compat_arch_sched_op_compat -+ .quad do_fpu_taskswitch /* 5 */ -+ .quad do_sched_op_compat - .quad compat_platform_op -- .quad compat_set_debugreg -- .quad compat_get_debugreg -+ .quad do_set_debugreg -+ .quad do_get_debugreg - .quad compat_update_descriptor /* 10 */ -- .quad do_ni_hypercall -+ .quad compat_ni_hypercall - .quad compat_memory_op - .quad compat_multicall - .quad compat_update_va_mapping - .quad compat_set_timer_op /* 15 */ - .quad compat_event_channel_op_compat - .quad compat_xen_version -- .quad compat_console_io -+ .quad do_console_io - .quad compat_physdev_op_compat - .quad compat_grant_table_op /* 20 */ - .quad compat_vm_assist - .quad compat_update_va_mapping_otherdomain - .quad compat_iret - .quad compat_vcpu_op -- .quad do_ni_hypercall /* 25 */ -+ .quad compat_ni_hypercall /* 25 */ - .quad compat_mmuext_op - .quad compat_acm_op - .quad compat_nmi_op -@@ -345,11 +336,11 @@ ENTRY(compat_hypercall_table) - .quad compat_xenoprof_op - .quad compat_event_channel_op - .quad compat_physdev_op -- .quad do_ni_hypercall -+ .quad compat_ni_hypercall - .quad compat_sysctl /* 35 */ - .quad compat_domctl - .rept NR_hypercalls-((.-compat_hypercall_table)/8) -- .quad do_ni_hypercall -+ .quad compat_ni_hypercall - .endr - - ENTRY(compat_hypercall_args_table) -@@ -359,12 +350,12 @@ ENTRY(compat_hypercall_args_table) - .byte 2 /* compat_stack_switch */ - .byte 4 /* compat_set_callbacks */ - .byte 1 /* compat_fpu_taskswitch */ /* 5 */ -- .byte 2 /* compat_arch_sched_op_compat */ -+ .byte 2 /* compat_sched_op_compat */ - .byte 1 /* compat_platform_op */ - .byte 2 /* compat_set_debugreg */ - .byte 1 /* compat_get_debugreg */ - .byte 4 /* compat_update_descriptor */ /* 10 */ -- .byte 0 /* do_ni_hypercall */ -+ .byte 0 /* compat_ni_hypercall */ - .byte 2 /* compat_memory_op */ - .byte 2 /* compat_multicall */ - .byte 4 /* compat_update_va_mapping */ -@@ -378,7 +369,7 @@ ENTRY(compat_hypercall_args_table) - .byte 5 /* compat_update_va_mapping_otherdomain */ - .byte 0 /* compat_iret */ - .byte 3 /* compat_vcpu_op */ -- .byte 0 /* do_ni_hypercall */ /* 25 */ -+ .byte 0 /* compat_ni_hypercall */ /* 25 */ - .byte 4 /* compat_mmuext_op */ - .byte 1 /* compat_acm_op */ - .byte 2 /* compat_nmi_op */ -@@ -387,9 +378,9 @@ ENTRY(compat_hypercall_args_table) - .byte 2 /* compat_xenoprof_op */ - .byte 2 /* compat_event_channel_op */ - .byte 2 /* compat_physdev_op */ -- .byte 0 /* do_ni_hypercall */ -+ .byte 0 /* compat_ni_hypercall */ - .byte 1 /* compat_sysctl */ /* 35 */ - .byte 1 /* compat_domctl */ - .rept NR_hypercalls-(.-compat_hypercall_args_table) -- .byte 0 /* do_ni_hypercall */ -+ .byte 0 /* compat_ni_hypercall */ - .endr -Index: 2007-01-08/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:17:29.000000000 +0100 -@@ -1,25 +1,6 @@ - #ifdef CONFIG_COMPAT - --#if 0 /* XXX */ - #include --#else --struct compat_xen_callback { -- unsigned int cs; -- unsigned int eip; --}; --typedef struct compat_xen_callback xen_callback_compat_t; -- --struct compat_callback_register { -- uint16_t type; -- uint16_t flags; -- xen_callback_compat_t address; --}; -- --struct compat_callback_unregister { -- uint16_t type; -- uint16_t _unused; --}; --#endif - - void compat_show_guest_stack(struct cpu_user_regs *regs, int debug_stack_lines) - { -Index: 2007-01-08/xen/common/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/Makefile 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/common/Makefile 2007-01-08 15:17:29.000000000 +0100 -@@ -35,5 +35,7 @@ obj-$(xenoprof) += xenoprof.o - - obj-$(CONFIG_XENCOMM) += xencomm.o - -+subdir-$(CONFIG_COMPAT) += compat -+ - # Object file contains changeset and compiler information. - version.o: $(BASEDIR)/include/xen/compile.h -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 15:17:29.000000000 +0100 -@@ -0,0 +1,4 @@ -+obj-y += kernel.o -+ -+# extra dependencies -+kernel.o: ../kernel.c -Index: 2007-01-08/xen/common/compat/kernel.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/kernel.c 2007-01-08 15:17:29.000000000 +0100 -@@ -0,0 +1,59 @@ -+/****************************************************************************** -+ * kernel.c -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define xen_extraversion compat_extraversion -+#define xen_extraversion_t compat_extraversion_t -+ -+#define xen_compile_info compat_compile_info -+#define xen_compile_info_t compat_compile_info_t -+ -+CHECK_TYPE(capabilities_info); -+ -+#define xen_platform_parameters compat_platform_parameters -+#define xen_platform_parameters_t compat_platform_parameters_t -+#undef HYPERVISOR_VIRT_START -+#define HYPERVISOR_VIRT_START HYPERVISOR_COMPAT_VIRT_START -+ -+#define xen_changeset_info compat_changeset_info -+#define xen_changeset_info_t compat_changeset_info_t -+ -+#define xen_feature_info compat_feature_info -+#define xen_feature_info_t compat_feature_info_t -+ -+CHECK_TYPE(domain_handle); -+ -+#define xennmi_callback compat_nmi_callback -+#define xennmi_callback_t compat_nmi_callback_t -+ -+#define DO(fn) int compat_##fn -+#define COMPAT -+ -+#include "../kernel.c" -+ -+int compat_disabled = 0; -+boolean_param("no-pv-compat", compat_disabled); -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/kernel.c -=================================================================== ---- 2007-01-08.orig/xen/common/kernel.c 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/common/kernel.c 2007-01-08 15:17:29.000000000 +0100 -@@ -11,11 +11,14 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - -+#ifndef COMPAT -+ - int tainted; - - void cmdline_parse(char *cmdline) -@@ -116,11 +119,15 @@ void add_taint(unsigned flag) - tainted |= flag; - } - -+# define DO(fn) long do_##fn -+ -+#endif -+ - /* - * Simple hypercalls. - */ - --long do_xen_version(int cmd, XEN_GUEST_HANDLE(void) arg) -+DO(xen_version)(int cmd, XEN_GUEST_HANDLE(void) arg) - { - switch ( cmd ) - { -@@ -230,6 +237,8 @@ long do_xen_version(int cmd, XEN_GUEST_H - return -ENOSYS; - } - -+#ifndef COMPAT -+ - long register_guest_nmi_callback(unsigned long address) - { - struct vcpu *v = current; -@@ -260,7 +269,9 @@ long unregister_guest_nmi_callback(void) - return 0; - } - --long do_nmi_op(unsigned int cmd, XEN_GUEST_HANDLE(void) arg) -+#endif -+ -+DO(nmi_op)(unsigned int cmd, XEN_GUEST_HANDLE(void) arg) - { - struct xennmi_callback cb; - long rc = 0; -@@ -284,12 +295,12 @@ long do_nmi_op(unsigned int cmd, XEN_GUE - return rc; - } - --long do_vm_assist(unsigned int cmd, unsigned int type) -+DO(vm_assist)(unsigned int cmd, unsigned int type) - { - return vm_assist(current->domain, cmd, type); - } - --long do_ni_hypercall(void) -+DO(ni_hypercall)(void) - { - /* No-op hypercall. */ - return -ENOSYS; -Index: 2007-01-08/xen/include/Makefile -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/Makefile 2007-01-08 15:18:26.000000000 +0100 -@@ -0,0 +1,60 @@ -+ifneq ($(CONFIG_COMPAT),) -+ -+compat-subarch-$(CONFIG_X86) := x86_32 -+compat-arch-$(CONFIG_X86) := x86 -+ -+headers-y := $(shell echo public/*.h | sed -e 's,[^[:space:]]*-[^[:space:]]*,,g' -e 's,public/,compat/,g') -+headers-y := $(filter-out %/dom0_ops.h,$(headers-y)) -+headers-y += compat/arch-$(compat-subarch-y).h -+headers-y += compat/arch-$(compat-arch-y)/xen.h -+headers-y += compat/arch-$(compat-arch-y)/xen-$(compat-subarch-y).h -+ -+cppflags-y := -include public/xen-compat.h -+cppflags-$(CONFIG_X86) += -m32 -+ -+# 8-byte types are 4-byte aligned on x86_32 ... -+prefix-$(CONFIG_X86) := \#pragma pack(push, 4) -+suffix-$(CONFIG_X86) := \#pragma pack(pop) -+ -+endif -+ -+.PHONY: all -+all: $(headers-y) -+ -+compat/%.h: compat/%.i Makefile -+ id=_$$(echo $@ | sed 'y,abcdefghijklmnopqrstuvwxyz-/.,ABCDEFGHIJKLMNOPQRSTUVWXYZ___,'); \ -+ echo "#ifndef $$id" >$@.new; \ -+ echo "#define $$id" >>$@.new; \ -+ echo "#include " >>$@.new; \ -+ $(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst compat/%,public/%,$@)>" >>$@.new;) \ -+ $(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \ -+ grep -v '^# [[:digit:]]' $< | \ -+ sed -e 's,__InClUdE__,#include,' \ -+ -e 's,"xen-compat.h",,' \ -+ -e 's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),\1 compat_\3,g' \ -+ -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \ -+ -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \ -+ -e 's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g' \ -+ -e 's,\(^\|[^[:alnum:]_]\)XEN_\?,\1COMPAT_,' \ -+ -e 's,\(^\|[^[:alnum:]_]\)Xen_\?,\1Compat_,' \ -+ -e 's,\(^\|[^[:alnum:]]\)long\([^[:alnum:]]\|$$\),\1int\2,g' | \ -+ uniq >>$@.new; \ -+ $(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \ -+ echo "#endif /* $$id */" >>$@.new -+ mv -f $@.new $@ -+ -+compat/%.i: compat/%.c Makefile -+ $(CPP) $(CFLAGS) $(cppflags-y) -o $@ $< -+ -+compat/%.c: public/%.h Makefile -+ mkdir -p $(@D) -+ grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \ -+ sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' \ -+ -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define HIDE_\1,' \ -+ -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define hide_\1,' \ -+ -e 's,XEN_GUEST_HANDLE\(_[[:xdigit:]]\+\)\?,COMPAT_HANDLE,g' \ -+ >$@.new -+ mv -f $@.new $@ -+ -+clean:: -+ rm -rf compat -Index: 2007-01-08/xen/include/asm-x86/compat.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/asm-x86/compat.h 2007-01-08 15:17:29.000000000 +0100 -@@ -0,0 +1,6 @@ -+/****************************************************************************** -+ * compat.h -+ */ -+ -+typedef uint32_t compat_ptr_t; -+typedef unsigned long full_ptr_t; -Index: 2007-01-08/xen/include/asm-x86/x86_64/uaccess.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/x86_64/uaccess.h 2007-01-08 15:17:24.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/x86_64/uaccess.h 2007-01-08 15:17:29.000000000 +0100 -@@ -15,6 +15,19 @@ - - #define array_access_ok(addr, count, size) (__addr_ok(addr)) - -+#ifdef CONFIG_COMPAT -+ -+#define __compat_addr_ok(addr) \ -+ ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START) -+ -+#define compat_access_ok(addr, size) __compat_addr_ok((addr) + (size)) -+ -+#define compat_array_access_ok(addr,count,size) \ -+ (likely((count) < (~0U / (size))) && \ -+ compat_access_ok(addr, (count) * (size))) -+ -+#endif -+ - #define __put_user_size(x,ptr,size,retval,errret) \ - do { \ - retval = 0; \ -Index: 2007-01-08/xen/include/xen/compat.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/xen/compat.h 2007-01-08 15:17:29.000000000 +0100 -@@ -0,0 +1,167 @@ -+/****************************************************************************** -+ * compat.h -+ */ -+ -+#ifndef __XEN_COMPAT_H__ -+#define __XEN_COMPAT_H__ -+ -+#include -+ -+#ifdef CONFIG_COMPAT -+ -+#include -+#include -+#include -+ -+#define __DEFINE_COMPAT_HANDLE(name, type) \ -+ typedef struct { \ -+ compat_ptr_t c; \ -+ type *_[0] __attribute__((__packed__)); \ -+ } __compat_handle_ ## name -+ -+#define DEFINE_COMPAT_HANDLE(name) __DEFINE_COMPAT_HANDLE(name, name) -+#define COMPAT_HANDLE(name) __compat_handle_ ## name -+ -+/* Is the compat handle a NULL reference? */ -+#define compat_handle_is_null(hnd) ((hnd).c == 0) -+ -+/* Offset the given compat handle into the array it refers to. */ -+#define compat_handle_add_offset(hnd, nr) \ -+ ((hnd).c += (nr) * sizeof(**(hnd)._)) -+ -+/* Cast a compat handle to the specified type of handle. */ -+#define compat_handle_cast(chnd, type) ({ \ -+ type *_x = (__typeof__(**(chnd)._) *)(full_ptr_t)(chnd).c; \ -+ (XEN_GUEST_HANDLE(type)) { _x }; \ -+}) -+ -+#define guest_from_compat_handle(ghnd, chnd) \ -+ set_xen_guest_handle(ghnd, \ -+ (__typeof__(**(chnd)._) *)(full_ptr_t)(chnd).c) -+ -+/* -+ * Copy an array of objects to guest context via a compat handle, -+ * specifying an offset into the guest array. -+ */ -+#define copy_to_compat_offset(hnd, off, ptr, nr) ({ \ -+ const typeof(ptr) _x = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \ -+ const typeof(*(ptr)) *const _y = (ptr); \ -+ copy_to_user(_x + (off), _y, sizeof(*_x) * (nr)); \ -+}) -+ -+/* -+ * Copy an array of objects from guest context via a compat handle, -+ * specifying an offset into the guest array. -+ */ -+#define copy_from_compat_offset(ptr, hnd, off, nr) ({ \ -+ const typeof(ptr) _x = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \ -+ const typeof(ptr) _y = (ptr); \ -+ copy_from_user(_y, _x + (off), sizeof(*_x) * (nr)); \ -+}) -+ -+#define copy_to_compat(hnd, ptr, nr) \ -+ copy_to_compat_offset(hnd, 0, ptr, nr) -+ -+#define copy_from_compat(ptr, hnd, nr) \ -+ copy_from_compat_offset(ptr, hnd, 0, nr) -+ -+/* Copy sub-field of a structure to guest context via a compat handle. */ -+#define copy_field_to_compat(hnd, ptr, field) ({ \ -+ typeof((ptr)->field) *const _x = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field; \ -+ const typeof((ptr)->field) *const _y = &(ptr)->field; \ -+ copy_to_user(_x, _y, sizeof(*_x)); \ -+}) -+ -+/* Copy sub-field of a structure from guest context via a compat handle. */ -+#define copy_field_from_compat(ptr, hnd, field) ({ \ -+ typeof((ptr)->field) *const _x = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field; \ -+ typeof((ptr)->field) *const _y = &(ptr)->field; \ -+ copy_from_user(_y, _x, sizeof(*_x)); \ -+}) -+ -+/* -+ * Pre-validate a guest handle. -+ * Allows use of faster __copy_* functions. -+ */ -+#define compat_handle_okay(hnd, nr) \ -+ compat_array_access_ok((void *)(full_ptr_t)(hnd).c, (nr), sizeof(**(hnd)._)) -+ -+#define __copy_to_compat_offset(hnd, off, ptr, nr) ({ \ -+ const typeof(ptr) _x = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \ -+ const typeof(*(ptr)) *const _y = (ptr); \ -+ __copy_to_user(_x + (off), _y, sizeof(*_x) * (nr)); \ -+}) -+ -+#define __copy_from_compat_offset(ptr, hnd, off, nr) ({ \ -+ const typeof(ptr) _x = (typeof(**(hnd)._) *)(full_ptr_t)(hnd).c; \ -+ const typeof(ptr) _y = (ptr); \ -+ __copy_from_user(_y, _x + (off), sizeof(*_x) * (nr)); \ -+}) -+ -+#define __copy_to_compat(hnd, ptr, nr) \ -+ __copy_to_compat_offset(hnd, 0, ptr, nr) -+ -+#define __copy_from_compat(ptr, hnd, nr) \ -+ __copy_from_compat_offset(ptr, hnd, 0, nr) -+ -+#define __copy_field_to_compat(hnd, ptr, field) ({ \ -+ typeof((ptr)->field) *const _x = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field; \ -+ const typeof((ptr)->field) *const _y = &(ptr)->field; \ -+ __copy_to_user(_x, _y, sizeof(*_x)); \ -+}) -+ -+#define __copy_field_from_compat(ptr, hnd, field) ({ \ -+ typeof((ptr)->field) *const _x = &((typeof(**(hnd)._) *)(full_ptr_t)(hnd).c)->field; \ -+ typeof((ptr)->field) *const _y = &(ptr)->field; \ -+ __copy_from_user(_y, _x, sizeof(*_x)); \ -+}) -+ -+ -+#define CHECK_TYPE(name) \ -+ typedef int __checkT ## name[1 - ((xen_ ## name ## _t *)0 != \ -+ (compat_ ## name ## _t *)0) * 2] -+#define CHECK_TYPE_(k, n) \ -+ typedef int __checkT ## k ## _ ## n[1 - ((k xen_ ## n *)0 != \ -+ (k compat_ ## n *)0) * 2] -+ -+#define CHECK_SIZE(name) \ -+ typedef int __checkS ## name[1 - (sizeof(xen_ ## name ## _t) != \ -+ sizeof(compat_ ## name ## _t)) * 2] -+#define CHECK_SIZE_(k, n) \ -+ typedef int __checkS ## k ## _ ## n[1 - (sizeof(k xen_ ## n) != \ -+ sizeof(k compat_ ## n)) * 2] -+ -+#define CHECK_FIELD(t, f) \ -+ typedef int __checkF ## t ## __ ## f[1 - (&((xen_ ## t ## _t *)0)->f != \ -+ &((compat_ ## t ## _t *)0)->f) * 2] -+#define CHECK_FIELD_(k, n, f) \ -+ typedef int __checkF ## k ## _ ## n ## __ ## f[1 - (&((k xen_ ## n *)0)->f != \ -+ &((k compat_ ## n *)0)->f) * 2] -+ -+#define CHECK_SUBFIELD_1(t, f1, f2) \ -+ typedef int __checkF1 ## t ## __ ## f1 ## __ ## f2 \ -+ [1 - (&((xen_ ## t ## _t *)0)->f1.f2 != \ -+ &((compat_ ## t ## _t *)0)->f1.f2) * 2] -+#define CHECK_SUBFIELD_1_(k, n, f1, f2) \ -+ typedef int __checkF1 ## k ## _ ## n ## __ ## f1 ## __ ## f2 \ -+ [1 - (&((k xen_ ## n *)0)->f1.f2 != \ -+ &((k compat_ ## n *)0)->f1.f2) * 2] -+ -+#define CHECK_SUBFIELD_2(t, f1, f2, f3) \ -+ typedef int __checkF2 ## t ## __ ## f1 ## __ ## f2 ## __ ## f3 \ -+ [1 - (&((xen_ ## t ## _t *)0)->f1.f2.f3 != \ -+ &((compat_ ## t ## _t *)0)->f1.f2.f3) * 2] -+#define CHECK_SUBFIELD_2_(k, n, f1, f2, f3) \ -+ typedef int __checkF2 ## k ## _ ## n ## __ ## f1 ## __ ## f2 ## __ ## f3 \ -+ [1 - (&((k xen_ ## n *)0)->f1.f2.f3 != \ -+ &((k compat_ ## n *)0)->f1.f2.f3) * 2] -+ -+extern int compat_disabled; -+ -+/* In-place translation functons: */ -+struct start_info; -+void xlat_start_info(struct start_info *, enum XLAT_start_info_console); -+ -+#endif -+ -+#endif /* __XEN_COMPAT_H__ */ diff --git a/32on64-kexec.patch b/32on64-kexec.patch deleted file mode 100644 index 38baebd..0000000 --- a/32on64-kexec.patch +++ /dev/null @@ -1,226 +0,0 @@ -Enable compatibility mode operation for kexec. - -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:50:12.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:52:27.000000000 +0100 -@@ -316,6 +316,7 @@ ENTRY(compat_hypercall_table) - .quad compat_ni_hypercall - .quad compat_sysctl /* 35 */ - .quad compat_domctl -+ .quad compat_kexec_op - .rept NR_hypercalls-((.-compat_hypercall_table)/8) - .quad compat_ni_hypercall - .endr -@@ -358,6 +359,7 @@ ENTRY(compat_hypercall_args_table) - .byte 0 /* compat_ni_hypercall */ - .byte 1 /* compat_sysctl */ /* 35 */ - .byte 1 /* compat_domctl */ -+ .byte 2 /* compat_kexec_op */ - .rept NR_hypercalls-(.-compat_hypercall_args_table) - .byte 0 /* compat_ni_hypercall */ - .endr -Index: 2006-12-18/xen/common/Makefile -=================================================================== ---- 2006-12-18.orig/xen/common/Makefile 2006-12-18 09:50:08.000000000 +0100 -+++ 2006-12-18/xen/common/Makefile 2006-12-18 09:52:27.000000000 +0100 -@@ -44,6 +44,7 @@ ifeq ($(CONFIG_COMPAT),y) - # extra dependencies - acm_ops.o: compat/acm_ops.c - grant_table.o: compat/grant_table.c -+kexec.o: compat/kexec.c - schedule.o: compat/schedule.c - xenoprof.o: compat/xenoprof.c - endif -Index: 2006-12-18/xen/common/compat/kexec.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/common/compat/kexec.c 2006-12-18 09:52:27.000000000 +0100 -@@ -0,0 +1,33 @@ -+/* -+ * compat/kexec.c -+ */ -+ -+#include -+ -+#define COMPAT -+#define ret_t int -+ -+#define do_kexec_op compat_kexec_op -+ -+#undef kexec_get -+#define kexec_get(x) compat_kexec_get_##x -+#define xen_kexec_range compat_kexec_range -+#define xen_kexec_range_t compat_kexec_range_t -+ -+#define kexec_load_unload compat_kexec_load_unload -+#define xen_kexec_load compat_kexec_load -+#define xen_kexec_load_t compat_kexec_load_t -+ -+CHECK_kexec_exec; -+ -+#include "../kexec.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-18/xen/common/kexec.c -=================================================================== ---- 2006-12-18.orig/xen/common/kexec.c 2006-12-15 16:33:59.000000000 +0100 -+++ 2006-12-18/xen/common/kexec.c 2006-12-18 09:52:27.000000000 +0100 -@@ -22,6 +22,10 @@ - #include - #include - -+#ifndef COMPAT -+ -+typedef long ret_t; -+ - DEFINE_PER_CPU (crash_note_t, crash_notes); - cpumask_t crash_saved_cpus; - -@@ -143,7 +147,11 @@ static __init int register_crashdump_tri - } - __initcall(register_crashdump_trigger); - --static int kexec_get_reserve(xen_kexec_range_t *range) -+#define kexec_get(x) kexec_get_##x -+ -+#endif -+ -+static int kexec_get(reserve)(xen_kexec_range_t *range) - { - range->start = kexec_crash_area.start; - range->size = kexec_crash_area.size; -@@ -152,14 +160,14 @@ static int kexec_get_reserve(xen_kexec_r - - extern unsigned long _text; - --static int kexec_get_xen(xen_kexec_range_t *range) -+static int kexec_get(xen)(xen_kexec_range_t *range) - { - range->start = virt_to_maddr(&_text); - range->size = (unsigned long)&_end - (unsigned long)&_text; - return 0; - } - --static int kexec_get_cpu(xen_kexec_range_t *range) -+static int kexec_get(cpu)(xen_kexec_range_t *range) - { - if ( range->nr < 0 || range->nr >= num_present_cpus() ) - return -EINVAL; -@@ -169,7 +177,7 @@ static int kexec_get_cpu(xen_kexec_range - return 0; - } - --static int kexec_get_range(XEN_GUEST_HANDLE(void) uarg) -+static int kexec_get(range)(XEN_GUEST_HANDLE(void) uarg) - { - xen_kexec_range_t range; - int ret = -EINVAL; -@@ -180,13 +188,13 @@ static int kexec_get_range(XEN_GUEST_HAN - switch ( range.range ) - { - case KEXEC_RANGE_MA_CRASH: -- ret = kexec_get_reserve(&range); -+ ret = kexec_get(reserve)(&range); - break; - case KEXEC_RANGE_MA_XEN: -- ret = kexec_get_xen(&range); -+ ret = kexec_get(xen)(&range); - break; - case KEXEC_RANGE_MA_CPU: -- ret = kexec_get_cpu(&range); -+ ret = kexec_get(cpu)(&range); - break; - } - -@@ -196,6 +204,8 @@ static int kexec_get_range(XEN_GUEST_HAN - return ret; - } - -+#ifndef COMPAT -+ - static int kexec_load_get_bits(int type, int *base, int *bit) - { - switch ( type ) -@@ -214,6 +224,8 @@ static int kexec_load_get_bits(int type, - return 0; - } - -+#endif -+ - static int kexec_load_unload(unsigned long op, XEN_GUEST_HANDLE(void) uarg) - { - xen_kexec_load_t load; -@@ -236,7 +248,11 @@ static int kexec_load_unload(unsigned lo - - BUG_ON(test_bit((base + !pos), &kexec_flags)); /* must be free */ - -+#ifndef COMPAT - memcpy(image, &load.image, sizeof(*image)); -+#else -+ XLAT_kexec_image(image, &load.image); -+#endif - - if ( !(ret = machine_kexec_load(load.type, base + !pos, image)) ) - { -@@ -261,6 +277,8 @@ static int kexec_load_unload(unsigned lo - return ret; - } - -+#ifndef COMPAT -+ - static int kexec_exec(XEN_GUEST_HANDLE(void) uarg) - { - xen_kexec_exec_t exec; -@@ -294,7 +312,9 @@ static int kexec_exec(XEN_GUEST_HANDLE(v - return -EINVAL; /* never reached */ - } - --long do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg) -+#endif -+ -+ret_t do_kexec_op(unsigned long op, XEN_GUEST_HANDLE(void) uarg) - { - unsigned long flags; - int ret = -EINVAL; -@@ -305,7 +325,7 @@ long do_kexec_op(unsigned long op, XEN_G - switch ( op ) - { - case KEXEC_CMD_kexec_get_range: -- ret = kexec_get_range(uarg); -+ ret = kexec_get(range)(uarg); - break; - case KEXEC_CMD_kexec_load: - case KEXEC_CMD_kexec_unload: -@@ -324,6 +344,10 @@ long do_kexec_op(unsigned long op, XEN_G - return ret; - } - -+#if defined(CONFIG_COMPAT) && !defined(COMPAT) -+#include "compat/kexec.c" -+#endif -+ - /* - * Local variables: - * mode: C -Index: 2006-12-18/xen/include/xlat.lst -=================================================================== ---- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:52:23.000000000 +0100 -+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:52:27.000000000 +0100 -@@ -32,6 +32,8 @@ - ! gnttab_transfer grant_table.h - ? gnttab_unmap_grant_ref grant_table.h - ? grant_entry grant_table.h -+? kexec_exec kexec.h -+! kexec_image kexec.h - ! add_to_physmap memory.h - ! foreign_memory_map memory.h - ! memory_exchange memory.h diff --git a/32on64-m2p.patch b/32on64-m2p.patch deleted file mode 100644 index 4ae0192..0000000 --- a/32on64-m2p.patch +++ /dev/null @@ -1,1192 +0,0 @@ -Add page table setup and handling, including the creation of an m2p table -meaningful to compatibility mode guests. - -Index: 2007-01-31/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domain.c 2007-01-31 09:29:10.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domain.c 2007-01-31 09:29:11.000000000 +0100 -@@ -127,6 +127,28 @@ void free_vcpu_struct(struct vcpu *v) - xfree(v); - } - -+#ifdef CONFIG_COMPAT -+static int setup_compat_l4(struct vcpu *v) -+{ -+ struct page_info *pg = alloc_domheap_page(NULL); -+ l4_pgentry_t *l4tab; -+ -+ if ( !pg ) -+ return -ENOMEM; -+ l4tab = copy_page(page_to_virt(pg), idle_pg_table); -+ l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] = -+ l4e_from_page(pg, __PAGE_HYPERVISOR); -+ l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] = -+ l4e_from_paddr(__pa(v->domain->arch.mm_perdomain_l3), __PAGE_HYPERVISOR); -+ v->arch.guest_table = pagetable_from_page(pg); -+ v->arch.guest_table_user = v->arch.guest_table; -+ -+ return 0; -+} -+#else -+#define setup_compat_l4(v) 0 -+#endif -+ - int vcpu_initialise(struct vcpu *v) - { - struct domain *d = v->domain; -@@ -161,11 +183,16 @@ int vcpu_initialise(struct vcpu *v) - v->arch.perdomain_ptes = - d->arch.mm_perdomain_pt + (v->vcpu_id << GDT_LDT_VCPU_SHIFT); - -+ if ( IS_COMPAT(d) && (rc = setup_compat_l4(v)) != 0 ) -+ return rc; -+ - return 0; - } - - void vcpu_destroy(struct vcpu *v) - { -+ if ( IS_COMPAT(v->domain) ) -+ free_domheap_page(pagetable_get_page(v->arch.guest_table)); - } - - int arch_domain_create(struct domain *d) -@@ -218,6 +245,10 @@ int arch_domain_create(struct domain *d) - - #endif /* __x86_64__ */ - -+#ifdef CONFIG_COMPAT -+ HYPERVISOR_COMPAT_VIRT_START(d) = __HYPERVISOR_COMPAT_VIRT_START; -+#endif -+ - shadow_lock_init(d); - for ( i = 0; i <= SHADOW_MAX_ORDER; i++ ) - INIT_LIST_HEAD(&d->arch.shadow.freelists[i]); -@@ -353,18 +384,41 @@ int arch_set_info_guest( - if ( (rc = (int)set_gdt(v, c->gdt_frames, c->gdt_ents)) != 0 ) - return rc; - -- cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c->ctrlreg[3])); -- -- if ( shadow_mode_refcounts(d) -- ? !get_page(mfn_to_page(cr3_pfn), d) -- : !get_page_and_type(mfn_to_page(cr3_pfn), d, -- PGT_base_page_table) ) -+ if ( !IS_COMPAT(d) ) - { -- destroy_gdt(v); -- return -EINVAL; -+ cr3_pfn = gmfn_to_mfn(d, xen_cr3_to_pfn(c->ctrlreg[3])); -+ -+ if ( shadow_mode_refcounts(d) -+ ? !get_page(mfn_to_page(cr3_pfn), d) -+ : !get_page_and_type(mfn_to_page(cr3_pfn), d, -+ PGT_base_page_table) ) -+ { -+ destroy_gdt(v); -+ return -EINVAL; -+ } -+ -+ v->arch.guest_table = pagetable_from_pfn(cr3_pfn); - } -+#ifdef CONFIG_COMPAT -+ else -+ { -+ l4_pgentry_t *l4tab; -+ -+ cr3_pfn = gmfn_to_mfn(d, compat_cr3_to_pfn(c->ctrlreg[3])); - -- v->arch.guest_table = pagetable_from_pfn(cr3_pfn); -+ if ( shadow_mode_refcounts(d) -+ ? !get_page(mfn_to_page(cr3_pfn), d) -+ : !get_page_and_type(mfn_to_page(cr3_pfn), d, -+ PGT_l3_page_table) ) -+ { -+ destroy_gdt(v); -+ return -EINVAL; -+ } -+ -+ l4tab = __va(pagetable_get_paddr(v->arch.guest_table)); -+ *l4tab = l4e_from_pfn(cr3_pfn, _PAGE_PRESENT|_PAGE_RW|_PAGE_USER|_PAGE_ACCESSED); -+ } -+#endif - } - - /* Shadow: make sure the domain has enough shadow memory to -Index: 2007-01-31/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domain_build.c 2007-01-31 09:29:10.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domain_build.c 2007-01-31 09:29:11.000000000 +0100 -@@ -91,9 +91,11 @@ string_param("dom0_ioports_disable", opt - #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) - #define L3_PROT (_PAGE_PRESENT) - #elif defined(__x86_64__) --/* Allow ring-3 access in long mode as guest cannot use ring 1. */ -+/* Allow ring-3 access in long mode as guest cannot use ring 1 ... */ - #define BASE_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_USER) - #define L1_PROT (BASE_PROT|_PAGE_GUEST_KERNEL) -+/* ... except for compatibility mode guests. */ -+#define COMPAT_L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) - #define L2_PROT (BASE_PROT|_PAGE_DIRTY) - #define L3_PROT (BASE_PROT|_PAGE_DIRTY) - #define L4_PROT (BASE_PROT|_PAGE_DIRTY) -@@ -262,8 +264,8 @@ int construct_dom0(struct domain *d, - start_info_t *si; - struct vcpu *v = d->vcpu[0]; - const char *p; -- unsigned long hypercall_page; -- int hypercall_page_defined; -+ unsigned long long value; -+ int value_defined; - #if defined(__i386__) - char *image_start = (char *)_image_start; /* use lowmem mappings */ - char *initrd_start = (char *)_initrd_start; /* use lowmem mappings */ -@@ -323,6 +325,7 @@ int construct_dom0(struct domain *d, - rc = parseelfimage(&dsi); - #ifdef CONFIG_COMPAT - if ( rc == -ENOSYS -+ && !compat_disabled - && (rc = parseelf32image(&dsi)) == 0 ) - { - l1_pgentry_t gdt_l1e; -@@ -370,10 +373,37 @@ int construct_dom0(struct domain *d, - - #ifdef CONFIG_COMPAT - if ( IS_COMPAT(d) ) -+ { -+ value = xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HV_START_LOW, &value_defined); - p = xen_elf32note_string(&dsi, XEN_ELFNOTE_FEATURES); -+ } - else - #endif -+ { -+ value = xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HV_START_LOW, &value_defined); - p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES); -+ } -+ if ( value_defined ) -+ { -+#if CONFIG_PAGING_LEVELS < 4 -+ unsigned long mask = (1UL << L2_PAGETABLE_SHIFT) - 1; -+#else -+ unsigned long mask = !IS_COMPAT(d) -+ ? (1UL << L4_PAGETABLE_SHIFT) - 1 -+ : (1UL << L2_PAGETABLE_SHIFT) - 1; -+#endif -+ -+ value = (value + mask) & ~mask; -+#ifdef CONFIG_COMPAT -+ HYPERVISOR_COMPAT_VIRT_START(d) = max_t(unsigned int, m2p_compat_vstart, value); -+ if ( value > (!IS_COMPAT(d) ? -+ HYPERVISOR_VIRT_START : -+ __HYPERVISOR_COMPAT_VIRT_START) ) -+#else -+ if ( value > HYPERVISOR_VIRT_START ) -+#endif -+ panic("Domain 0 expects too high a hypervisor start address.\n"); -+ } - if ( p != NULL ) - { - parse_features(p, -@@ -400,7 +430,9 @@ int construct_dom0(struct domain *d, - vinitrd_start = round_pgup(dsi.v_end); - vinitrd_end = vinitrd_start + initrd_len; - vphysmap_start = round_pgup(vinitrd_end); -- vphysmap_end = vphysmap_start + (nr_pages * sizeof(unsigned long)); -+ vphysmap_end = vphysmap_start + (nr_pages * (!IS_COMPAT(d) ? -+ sizeof(unsigned long) : -+ sizeof(unsigned int))); - vstartinfo_start = round_pgup(vphysmap_end); - vstartinfo_end = (vstartinfo_start + - sizeof(struct start_info) + -@@ -429,7 +461,9 @@ int construct_dom0(struct domain *d, - ((_l) & ~((1UL<<(_s))-1))) >> (_s)) - if ( (1 + /* # L4 */ - NR(dsi.v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */ -- NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT) + /* # L2 */ -+ (!IS_COMPAT(d) ? -+ NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT) : /* # L2 */ -+ 4) + /* # compat L2 */ - NR(dsi.v_start, v_end, L2_PAGETABLE_SHIFT)) /* # L1 */ - <= nr_pt_pages ) - break; -@@ -619,8 +653,10 @@ int construct_dom0(struct domain *d, - #elif defined(__x86_64__) - - /* Overlap with Xen protected area? */ -- if ( (dsi.v_start < HYPERVISOR_VIRT_END) && -- (v_end > HYPERVISOR_VIRT_START) ) -+ if ( !IS_COMPAT(d) ? -+ ((dsi.v_start < HYPERVISOR_VIRT_END) && -+ (v_end > HYPERVISOR_VIRT_START)) : -+ (v_end > HYPERVISOR_COMPAT_VIRT_START(d)) ) - { - printk("DOM0 image overlaps with Xen private area.\n"); - return -EINVAL; -@@ -633,8 +669,18 @@ int construct_dom0(struct domain *d, - } - - /* WARNING: The new domain must have its 'processor' field filled in! */ -- maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table; -- l4start = l4tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; -+ if ( !IS_COMPAT(d) ) -+ { -+ maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l4_page_table; -+ l4start = l4tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; -+ } -+ else -+ { -+ page = alloc_domheap_page(NULL); -+ if ( !page ) -+ panic("Not enough RAM for domain 0 PML4.\n"); -+ l4start = l4tab = page_to_virt(page); -+ } - memcpy(l4tab, idle_pg_table, PAGE_SIZE); - l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] = - l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR); -@@ -679,7 +725,7 @@ int construct_dom0(struct domain *d, - *l2tab = l2e_from_paddr(__pa(l1start), L2_PROT); - l2tab++; - } -- *l1tab = l1e_from_pfn(mfn, L1_PROT); -+ *l1tab = l1e_from_pfn(mfn, !IS_COMPAT(d) ? L1_PROT : COMPAT_L1_PROT); - l1tab++; - - page = mfn_to_page(mfn); -@@ -690,6 +736,30 @@ int construct_dom0(struct domain *d, - mfn++; - } - -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ { -+ /* Ensure the first four L3 entries are all populated. */ -+ for ( i = 0, l3tab = l3start; i < 4; ++i, ++l3tab ) -+ { -+ if ( !l3e_get_intpte(*l3tab) ) -+ { -+ maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l2_page_table; -+ l2tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; -+ clear_page(l2tab); -+ *l3tab = l3e_from_paddr(__pa(l2tab), L3_PROT); -+ } -+ if ( i == 3 ) -+ l3e_get_page(*l3tab)->u.inuse.type_info |= PGT_pae_xen_l2; -+ } -+ /* Install read-only guest visible MPT mapping. */ -+ l2tab = l3e_to_l2e(l3start[3]); -+ memcpy(&l2tab[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], -+ &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -+ COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*l2tab)); -+ } -+#endif -+ - /* Pages that are part of page tables must be read only. */ - l4tab = l4start + l4_table_offset(vpt_start); - l3start = l3tab = l4e_to_l3e(*l4tab); -@@ -708,7 +778,8 @@ int construct_dom0(struct domain *d, - page->u.inuse.type_info |= PGT_validated | 1; - - /* Top-level p.t. is pinned. */ -- if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_l4_page_table ) -+ if ( (page->u.inuse.type_info & PGT_type_mask) == -+ (!IS_COMPAT(d) ? PGT_l4_page_table : PGT_l3_page_table) ) - { - page->count_info += 1; - page->u.inuse.type_info += 1 | PGT_pinned; -@@ -761,26 +832,26 @@ int construct_dom0(struct domain *d, - if ( IS_COMPAT(d) ) - { - (void)loadelf32image(&dsi); -- hypercall_page = -- xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &hypercall_page_defined); -+ value = -+ xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &value_defined); - } - else - #endif - { - (void)loadelfimage(&dsi); -- hypercall_page = -- xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &hypercall_page_defined); -+ value = -+ xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &value_defined); - } -- if ( hypercall_page_defined ) -+ if ( value_defined ) - { -- if ( (hypercall_page < dsi.v_start) || (hypercall_page >= v_end) ) -+ if ( (value < dsi.v_start) || (value >= v_end) ) - { - write_ptbase(current); - local_irq_enable(); - printk("Invalid HYPERCALL_PAGE field in ELF notes.\n"); - return -1; - } -- hypercall_page_initialise(d, (void *)hypercall_page); -+ hypercall_page_initialise(d, (void *)(unsigned long)value); - } - - /* Copy the initial ramdisk. */ -@@ -798,7 +869,7 @@ int construct_dom0(struct domain *d, - si->shared_info = virt_to_maddr(d->shared_info); - - si->flags = SIF_PRIVILEGED | SIF_INITDOMAIN; -- si->pt_base = vpt_start; -+ si->pt_base = vpt_start + 2 * PAGE_SIZE * !!IS_COMPAT(d); - si->nr_pt_frames = nr_pt_pages; - si->mfn_list = vphysmap_start; - sprintf(si->magic, "xen-%i.%i-x86_%d%s", -@@ -814,7 +885,10 @@ int construct_dom0(struct domain *d, - if ( pfn > REVERSE_START ) - mfn = alloc_epfn - (pfn - REVERSE_START); - #endif -- ((unsigned long *)vphysmap_start)[pfn] = mfn; -+ if ( !IS_COMPAT(d) ) -+ ((unsigned long *)vphysmap_start)[pfn] = mfn; -+ else -+ ((unsigned int *)vphysmap_start)[pfn] = mfn; - set_gpfn_from_mfn(mfn, pfn); - } - while ( pfn < nr_pages ) -@@ -827,7 +901,10 @@ int construct_dom0(struct domain *d, - #ifndef NDEBUG - #define pfn (nr_pages - 1 - (pfn - (alloc_epfn - alloc_spfn))) - #endif -- ((unsigned long *)vphysmap_start)[pfn] = mfn; -+ if ( !IS_COMPAT(d) ) -+ ((unsigned long *)vphysmap_start)[pfn] = mfn; -+ else -+ ((unsigned int *)vphysmap_start)[pfn] = mfn; - set_gpfn_from_mfn(mfn, pfn); - #undef pfn - page++; pfn++; -Index: 2007-01-31/xen/arch/x86/domctl.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domctl.c 2006-12-13 11:15:53.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domctl.c 2007-01-31 09:29:11.000000000 +0100 -@@ -311,7 +311,12 @@ void arch_getdomaininfo_ctxt( - if ( guest_kernel_mode(v, &v->arch.guest_context.user_regs) ) - c->flags |= VGCF_in_kernel; - -- c->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+ if ( !IS_COMPAT(v->domain) ) -+ c->ctrlreg[3] = xen_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+#ifdef CONFIG_COMPAT -+ else -+ c->ctrlreg[3] = compat_pfn_to_cr3(pagetable_get_pfn(v->arch.guest_table)); -+#endif - - c->vm_assist = v->domain->vm_assist; - } -Index: 2007-01-31/xen/arch/x86/e820.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/e820.c 2006-12-13 11:15:53.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/e820.c 2007-01-31 09:29:11.000000000 +0100 -@@ -1,6 +1,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -341,6 +342,39 @@ static void __init clip_4gb(void) - #define clip_4gb() ((void)0) - #endif - -+#ifdef CONFIG_COMPAT -+static void __init clip_compat(void) -+{ -+ unsigned long long limit; -+ unsigned int i; -+ -+ if ( compat_disabled ) -+ return; -+ /* 32-bit guests restricted to 166 GB (with current memory allocator). */ -+ limit = (unsigned long long)(MACH2PHYS_COMPAT_VIRT_END - -+ __HYPERVISOR_COMPAT_VIRT_START) << 10; -+ for ( i = 0; i < e820.nr_map; i++ ) -+ { -+ if ( (e820.map[i].addr + e820.map[i].size) <= limit ) -+ continue; -+ printk("WARNING: Only the first %Lu GB of the physical memory map " -+ "can be accessed\n" -+ " by compatibility mode guests. " -+ "Truncating the memory map...\n", -+ limit >> 30); -+ if ( e820.map[i].addr >= limit ) -+ e820.nr_map = i; -+ else -+ { -+ e820.map[i].size = limit - e820.map[i].addr; -+ e820.nr_map = i + 1; -+ } -+ } -+} -+#else -+#define clip_compat() ((void)0) -+#endif -+ - static void __init clip_mem(void) - { - int i; -@@ -374,6 +408,7 @@ static void __init machine_specific_memo - *raw_nr = nr; - (void)copy_e820_map(raw, nr); - clip_4gb(); -+ clip_compat(); - clip_mem(); - } - -Index: 2007-01-31/xen/arch/x86/mm.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/mm.c 2007-01-31 09:29:03.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/mm.c 2007-01-31 09:29:11.000000000 +0100 -@@ -126,13 +126,6 @@ - */ - #define MMU_UPDATE_PREEMPTED (~(~0U>>1)) - --static void free_l2_table(struct page_info *page); --static void free_l1_table(struct page_info *page); -- --static int mod_l2_entry(l2_pgentry_t *, l2_pgentry_t, unsigned long, -- unsigned long type); --static int mod_l1_entry(l1_pgentry_t *, l1_pgentry_t, unsigned long gl1mfn); -- - /* Used to defer flushing of memory structures. */ - struct percpu_mm_info { - #define DOP_FLUSH_TLB (1<<0) /* Flush the local TLB. */ -@@ -158,6 +151,15 @@ struct page_info *frame_table; - unsigned long max_page; - unsigned long total_pages; - -+#ifdef CONFIG_COMPAT -+l2_pgentry_t *compat_idle_pg_table_l2 = NULL; -+#define l3_disallow_mask(d) (!IS_COMPAT(d) ? \ -+ L3_DISALLOW_MASK : \ -+ COMPAT_L3_DISALLOW_MASK) -+#else -+#define l3_disallow_mask(d) L3_DISALLOW_MASK -+#endif -+ - void __init init_frametable(void) - { - unsigned long nr_pages, page_step, i, mfn; -@@ -629,9 +631,9 @@ get_page_from_l3e( - if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) - return 1; - -- if ( unlikely((l3e_get_flags(l3e) & L3_DISALLOW_MASK)) ) -+ if ( unlikely((l3e_get_flags(l3e) & l3_disallow_mask(d))) ) - { -- MEM_LOG("Bad L3 flags %x", l3e_get_flags(l3e) & L3_DISALLOW_MASK); -+ MEM_LOG("Bad L3 flags %x", l3e_get_flags(l3e) & l3_disallow_mask(d)); - return 0; - } - -@@ -668,9 +670,10 @@ get_page_from_l4e( - #ifdef __x86_64__ - - #ifdef USER_MAPPINGS_ARE_GLOBAL --#define adjust_guest_l1e(pl1e) \ -+#define adjust_guest_l1e(pl1e, d) \ - do { \ -- if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) ) \ -+ if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) && \ -+ likely(!IS_COMPAT(d)) ) \ - { \ - /* _PAGE_GUEST_KERNEL page cannot have the Global bit set. */ \ - if ( (l1e_get_flags((pl1e)) & (_PAGE_GUEST_KERNEL|_PAGE_GLOBAL)) \ -@@ -684,39 +687,55 @@ get_page_from_l4e( - } \ - } while ( 0 ) - #else --#define adjust_guest_l1e(pl1e) \ -+#define adjust_guest_l1e(pl1e, d) \ - do { \ -- if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) ) \ -+ if ( likely(l1e_get_flags((pl1e)) & _PAGE_PRESENT) && \ -+ likely(!IS_COMPAT(d)) ) \ - l1e_add_flags((pl1e), _PAGE_USER); \ - } while ( 0 ) - #endif - --#define adjust_guest_l2e(pl2e) \ -+#define adjust_guest_l2e(pl2e, d) \ - do { \ -- if ( likely(l2e_get_flags((pl2e)) & _PAGE_PRESENT) ) \ -+ if ( likely(l2e_get_flags((pl2e)) & _PAGE_PRESENT) && \ -+ likely(!IS_COMPAT(d)) ) \ - l2e_add_flags((pl2e), _PAGE_USER); \ - } while ( 0 ) - --#define adjust_guest_l3e(pl3e) \ -+#define adjust_guest_l3e(pl3e, d) \ - do { \ - if ( likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ -- l3e_add_flags((pl3e), _PAGE_USER); \ -+ l3e_add_flags((pl3e), likely(!IS_COMPAT(d)) ? \ -+ _PAGE_USER : \ -+ _PAGE_USER|_PAGE_RW); \ - } while ( 0 ) - --#define adjust_guest_l4e(pl4e) \ -+#define adjust_guest_l4e(pl4e, d) \ - do { \ -- if ( likely(l4e_get_flags((pl4e)) & _PAGE_PRESENT) ) \ -+ if ( likely(l4e_get_flags((pl4e)) & _PAGE_PRESENT) && \ -+ likely(!IS_COMPAT(d)) ) \ - l4e_add_flags((pl4e), _PAGE_USER); \ - } while ( 0 ) - - #else /* !defined(__x86_64__) */ - --#define adjust_guest_l1e(_p) ((void)0) --#define adjust_guest_l2e(_p) ((void)0) --#define adjust_guest_l3e(_p) ((void)0) -+#define adjust_guest_l1e(_p, _d) ((void)(_d)) -+#define adjust_guest_l2e(_p, _d) ((void)(_d)) -+#define adjust_guest_l3e(_p, _d) ((void)(_d)) - - #endif - -+#ifdef CONFIG_COMPAT -+#define unadjust_guest_l3e(pl3e, d) \ -+ do { \ -+ if ( unlikely(IS_COMPAT(d)) && \ -+ likely(l3e_get_flags((pl3e)) & _PAGE_PRESENT) ) \ -+ l3e_remove_flags((pl3e), _PAGE_USER|_PAGE_RW|_PAGE_ACCESSED); \ -+ } while ( 0 ) -+#else -+#define unadjust_guest_l3e(_p, _d) ((void)(_d)) -+#endif -+ - void put_page_from_l1e(l1_pgentry_t l1e, struct domain *d) - { - unsigned long pfn = l1e_get_pfn(l1e); -@@ -818,7 +837,7 @@ static int alloc_l1_table(struct page_in - unlikely(!get_page_from_l1e(pl1e[i], d)) ) - goto fail; - -- adjust_guest_l1e(pl1e[i]); -+ adjust_guest_l1e(pl1e[i], d); - } - - unmap_domain_page(pl1e); -@@ -834,13 +853,20 @@ static int alloc_l1_table(struct page_in - return 0; - } - --#ifdef CONFIG_X86_PAE --static int create_pae_xen_mappings(l3_pgentry_t *pl3e) -+#if defined(CONFIG_X86_PAE) || defined(CONFIG_COMPAT) -+static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e) - { - struct page_info *page; -- l2_pgentry_t *pl2e, l2e; -+ l2_pgentry_t *pl2e; - l3_pgentry_t l3e3; -+#ifndef CONFIG_COMPAT -+ l2_pgentry_t l2e; - int i; -+#else -+ -+ if ( !IS_COMPAT(d) ) -+ return 1; -+#endif - - pl3e = (l3_pgentry_t *)((unsigned long)pl3e & PAGE_MASK); - -@@ -873,6 +899,7 @@ static int create_pae_xen_mappings(l3_pg - - /* Xen private mappings. */ - pl2e = map_domain_page(l3e_get_pfn(l3e3)); -+#ifndef CONFIG_COMPAT - memcpy(&pl2e[L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES-1)], - &idle_pg_table_l2[L2_PAGETABLE_FIRST_XEN_SLOT], - L2_PAGETABLE_XEN_SLOTS * sizeof(l2_pgentry_t)); -@@ -890,11 +917,20 @@ static int create_pae_xen_mappings(l3_pg - l2e = l2e_from_pfn(l3e_get_pfn(pl3e[i]), __PAGE_HYPERVISOR); - l2e_write(&pl2e[l2_table_offset(LINEAR_PT_VIRT_START) + i], l2e); - } -+#else -+ memcpy(&pl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], -+ &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -+ COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*pl2e)); -+#endif - unmap_domain_page(pl2e); - - return 1; - } -+#else -+# define create_pae_xen_mappings(d, pl3e) (1) -+#endif - -+#ifdef CONFIG_X86_PAE - /* Flush a pgdir update into low-memory caches. */ - static void pae_flush_pgd( - unsigned long mfn, unsigned int idx, l3_pgentry_t nl3e) -@@ -929,12 +965,8 @@ static void pae_flush_pgd( - - flush_tlb_mask(d->domain_dirty_cpumask); - } -- --#elif CONFIG_X86_64 --# define create_pae_xen_mappings(pl3e) (1) --# define pae_flush_pgd(mfn, idx, nl3e) ((void)0) - #else --# define create_pae_xen_mappings(pl3e) (1) -+# define pae_flush_pgd(mfn, idx, nl3e) ((void)0) - #endif - - static int alloc_l2_table(struct page_info *page, unsigned long type) -@@ -948,11 +980,11 @@ static int alloc_l2_table(struct page_in - - for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) - { -- if ( is_guest_l2_slot(type, i) && -+ if ( is_guest_l2_slot(d, type, i) && - unlikely(!get_page_from_l2e(pl2e[i], pfn, d)) ) - goto fail; - -- adjust_guest_l2e(pl2e[i]); -+ adjust_guest_l2e(pl2e[i], d); - } - - #if CONFIG_PAGING_LEVELS == 2 -@@ -975,7 +1007,7 @@ static int alloc_l2_table(struct page_in - fail: - MEM_LOG("Failure in alloc_l2_table: entry %d", i); - while ( i-- > 0 ) -- if ( is_guest_l2_slot(type, i) ) -+ if ( is_guest_l2_slot(d, type, i) ) - put_page_from_l2e(pl2e[i], pfn); - - unmap_domain_page(pl2e); -@@ -1007,13 +1039,24 @@ static int alloc_l3_table(struct page_in - #endif - - pl3e = map_domain_page(pfn); -+ -+ /* -+ * PAE guests allocate full pages, but aren't required to initialize -+ * more than the first four entries; when running in compatibility -+ * mode, however, the full page is visible to the MMU, and hence all -+ * 512 entries must be valid/verified, which is most easily achieved -+ * by clearing them out. -+ */ -+ if ( IS_COMPAT(d) ) -+ memset(pl3e + 4, 0, (L3_PAGETABLE_ENTRIES - 4) * sizeof(*pl3e)); -+ - for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ ) - { --#ifdef CONFIG_X86_PAE -- if ( i == 3 ) -+#if defined(CONFIG_X86_PAE) || defined(CONFIG_COMPAT) -+ if ( (CONFIG_PAGING_LEVELS < 4 || IS_COMPAT(d)) && i == 3 ) - { - if ( !(l3e_get_flags(pl3e[i]) & _PAGE_PRESENT) || -- (l3e_get_flags(pl3e[i]) & L3_DISALLOW_MASK) || -+ (l3e_get_flags(pl3e[i]) & l3_disallow_mask(d)) || - !get_page_and_type_from_pagenr(l3e_get_pfn(pl3e[i]), - PGT_l2_page_table | - PGT_pae_xen_l2, -@@ -1026,10 +1069,10 @@ static int alloc_l3_table(struct page_in - unlikely(!get_page_from_l3e(pl3e[i], pfn, d)) ) - goto fail; - -- adjust_guest_l3e(pl3e[i]); -+ adjust_guest_l3e(pl3e[i], d); - } - -- if ( !create_pae_xen_mappings(pl3e) ) -+ if ( !create_pae_xen_mappings(d, pl3e) ) - goto fail; - - unmap_domain_page(pl3e); -@@ -1062,7 +1105,7 @@ static int alloc_l4_table(struct page_in - unlikely(!get_page_from_l4e(pl4e[i], pfn, d)) ) - goto fail; - -- adjust_guest_l4e(pl4e[i]); -+ adjust_guest_l4e(pl4e[i], d); - } - - /* Xen private mappings. */ -@@ -1110,6 +1153,9 @@ static void free_l1_table(struct page_in - - static void free_l2_table(struct page_info *page) - { -+#ifdef CONFIG_COMPAT -+ struct domain *d = page_get_owner(page); -+#endif - unsigned long pfn = page_to_mfn(page); - l2_pgentry_t *pl2e; - int i; -@@ -1117,7 +1163,7 @@ static void free_l2_table(struct page_in - pl2e = map_domain_page(pfn); - - for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ ) -- if ( is_guest_l2_slot(page->u.inuse.type_info, i) ) -+ if ( is_guest_l2_slot(d, page->u.inuse.type_info, i) ) - put_page_from_l2e(pl2e[i], pfn); - - unmap_domain_page(pl2e); -@@ -1130,6 +1176,7 @@ static void free_l2_table(struct page_in - - static void free_l3_table(struct page_info *page) - { -+ struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l3_pgentry_t *pl3e; - int i; -@@ -1138,7 +1185,10 @@ static void free_l3_table(struct page_in - - for ( i = 0; i < L3_PAGETABLE_ENTRIES; i++ ) - if ( is_guest_l3_slot(i) ) -+ { - put_page_from_l3e(pl3e[i], pfn); -+ unadjust_guest_l3e(pl3e[i], d); -+ } - - unmap_domain_page(pl3e); - } -@@ -1234,7 +1284,7 @@ static int mod_l1_entry(l1_pgentry_t *pl - return 0; - } - -- adjust_guest_l1e(nl1e); -+ adjust_guest_l1e(nl1e, d); - - /* Fast path for identical mapping, r/w and presence. */ - if ( !l1e_has_changed(ol1e, nl1e, _PAGE_RW | _PAGE_PRESENT) ) -@@ -1297,8 +1347,9 @@ static int mod_l2_entry(l2_pgentry_t *pl - unsigned long type) - { - l2_pgentry_t ol2e; -+ struct domain *d = current->domain; - -- if ( unlikely(!is_guest_l2_slot(type,pgentry_ptr_to_slot(pl2e))) ) -+ if ( unlikely(!is_guest_l2_slot(d, type, pgentry_ptr_to_slot(pl2e))) ) - { - MEM_LOG("Illegal L2 update attempt in Xen-private area %p", pl2e); - return 0; -@@ -1316,7 +1367,7 @@ static int mod_l2_entry(l2_pgentry_t *pl - return 0; - } - -- adjust_guest_l2e(nl2e); -+ adjust_guest_l2e(nl2e, d); - - /* Fast path for identical mapping and presence. */ - if ( !l2e_has_changed(ol2e, nl2e, _PAGE_PRESENT)) -@@ -1348,6 +1399,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - unsigned long pfn) - { - l3_pgentry_t ol3e; -+ struct domain *d = current->domain; - int okay; - - if ( unlikely(!is_guest_l3_slot(pgentry_ptr_to_slot(pl3e))) ) -@@ -1356,12 +1408,13 @@ static int mod_l3_entry(l3_pgentry_t *pl - return 0; - } - --#ifdef CONFIG_X86_PAE -+#if defined(CONFIG_X86_PAE) || defined(CONFIG_COMPAT) - /* - * Disallow updates to final L3 slot. It contains Xen mappings, and it - * would be a pain to ensure they remain continuously valid throughout. - */ -- if ( pgentry_ptr_to_slot(pl3e) >= 3 ) -+ if ( (CONFIG_PAGING_LEVELS < 4 || IS_COMPAT(d)) && -+ pgentry_ptr_to_slot(pl3e) >= 3 ) - return 0; - #endif - -@@ -1370,14 +1423,14 @@ static int mod_l3_entry(l3_pgentry_t *pl - - if ( l3e_get_flags(nl3e) & _PAGE_PRESENT ) - { -- if ( unlikely(l3e_get_flags(nl3e) & L3_DISALLOW_MASK) ) -+ if ( unlikely(l3e_get_flags(nl3e) & l3_disallow_mask(d)) ) - { - MEM_LOG("Bad L3 flags %x", -- l3e_get_flags(nl3e) & L3_DISALLOW_MASK); -+ l3e_get_flags(nl3e) & l3_disallow_mask(d)); - return 0; - } - -- adjust_guest_l3e(nl3e); -+ adjust_guest_l3e(nl3e, d); - - /* Fast path for identical mapping and presence. */ - if (!l3e_has_changed(ol3e, nl3e, _PAGE_PRESENT)) -@@ -1397,7 +1450,7 @@ static int mod_l3_entry(l3_pgentry_t *pl - return 0; - } - -- okay = create_pae_xen_mappings(pl3e); -+ okay = create_pae_xen_mappings(d, pl3e); - BUG_ON(!okay); - - pae_flush_pgd(pfn, pgentry_ptr_to_slot(pl3e), nl3e); -@@ -1435,7 +1488,7 @@ static int mod_l4_entry(l4_pgentry_t *pl - return 0; - } - -- adjust_guest_l4e(nl4e); -+ adjust_guest_l4e(nl4e, current->domain); - - /* Fast path for identical mapping and presence. */ - if (!l4e_has_changed(ol4e, nl4e, _PAGE_PRESENT)) -@@ -2259,8 +2312,7 @@ int do_mmu_update( - case PGT_l2_page_table: - { - l2_pgentry_t l2e = l2e_from_intpte(req.val); -- okay = mod_l2_entry( -- (l2_pgentry_t *)va, l2e, mfn, type_info); -+ okay = mod_l2_entry(va, l2e, mfn, type_info); - } - break; - #if CONFIG_PAGING_LEVELS >= 3 -@@ -2273,11 +2325,12 @@ int do_mmu_update( - #endif - #if CONFIG_PAGING_LEVELS >= 4 - case PGT_l4_page_table: -- { -- l4_pgentry_t l4e = l4e_from_intpte(req.val); -- okay = mod_l4_entry(va, l4e, mfn); -- } -- break; -+ if ( !IS_COMPAT(FOREIGNDOM) ) -+ { -+ l4_pgentry_t l4e = l4e_from_intpte(req.val); -+ okay = mod_l4_entry(va, l4e, mfn); -+ } -+ break; - #endif - } - -@@ -2385,7 +2438,7 @@ static int create_grant_pte_mapping( - - ASSERT(spin_is_locked(&d->big_lock)); - -- adjust_guest_l1e(nl1e); -+ adjust_guest_l1e(nl1e, d); - - gmfn = pte_addr >> PAGE_SHIFT; - mfn = gmfn_to_mfn(d, gmfn); -@@ -2506,7 +2559,7 @@ static int create_grant_va_mapping( - - ASSERT(spin_is_locked(&d->big_lock)); - -- adjust_guest_l1e(nl1e); -+ adjust_guest_l1e(nl1e, d); - - pl1e = guest_map_l1e(v, va, &gl1mfn); - if ( !pl1e ) -@@ -3181,7 +3234,7 @@ static int ptwr_emulated_update( - } - } - -- adjust_guest_l1e(nl1e); -+ adjust_guest_l1e(nl1e, d); - - /* Checked successfully: do the update (write or cmpxchg). */ - pl1e = map_domain_page(page_to_mfn(page)); -Index: 2007-01-31/xen/arch/x86/x86_64/mm.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/x86_64/mm.c 2007-01-31 09:29:03.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/x86_64/mm.c 2007-01-31 09:29:11.000000000 +0100 -@@ -31,6 +31,10 @@ - #include - #include - -+#ifdef CONFIG_COMPAT -+unsigned int m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START; -+#endif -+ - struct page_info *alloc_xen_pagetable(void) - { - extern int early_boot; -@@ -121,6 +125,47 @@ void __init paging_init(void) - l2_ro_mpt++; - } - -+#ifdef CONFIG_COMPAT -+ if ( !compat_disabled ) -+ { -+ /* Create user-accessible L2 directory to map the MPT for compatibility guests. */ -+ BUILD_BUG_ON(l4_table_offset(RDWR_MPT_VIRT_START) != -+ l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)); -+ l3_ro_mpt = l4e_to_l3e(idle_pg_table[l4_table_offset(HIRO_COMPAT_MPT_VIRT_START)]); -+ if ( (l2_pg = alloc_domheap_page(NULL)) == NULL ) -+ goto nomem; -+ compat_idle_pg_table_l2 = l2_ro_mpt = clear_page(page_to_virt(l2_pg)); -+ l3e_write(&l3_ro_mpt[l3_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -+ l3e_from_page(l2_pg, __PAGE_HYPERVISOR)); -+ l2_ro_mpt += l2_table_offset(HIRO_COMPAT_MPT_VIRT_START); -+ /* -+ * Allocate and map the compatibility mode machine-to-phys table. -+ */ -+ mpt_size = (mpt_size >> 1) + (1UL << (L2_PAGETABLE_SHIFT - 1)); -+ if ( mpt_size > RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START ) -+ mpt_size = RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START; -+ mpt_size &= ~((1UL << L2_PAGETABLE_SHIFT) - 1UL); -+ if ( m2p_compat_vstart + mpt_size < MACH2PHYS_COMPAT_VIRT_END ) -+ m2p_compat_vstart = MACH2PHYS_COMPAT_VIRT_END - mpt_size; -+ for ( i = 0; i < (mpt_size >> L2_PAGETABLE_SHIFT); i++ ) -+ { -+ if ( (l1_pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER, 0)) == NULL ) -+ goto nomem; -+ map_pages_to_xen( -+ RDWR_COMPAT_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT), -+ page_to_mfn(l1_pg), -+ 1UL << PAGETABLE_ORDER, -+ PAGE_HYPERVISOR); -+ memset((void *)(RDWR_COMPAT_MPT_VIRT_START + (i << L2_PAGETABLE_SHIFT)), -+ 0x55, -+ 1UL << L2_PAGETABLE_SHIFT); -+ /* NB. Cannot be GLOBAL as the pt entries get copied into per-VM space. */ -+ l2e_write(l2_ro_mpt, l2e_from_page(l1_pg, _PAGE_PSE|_PAGE_PRESENT)); -+ l2_ro_mpt++; -+ } -+ } -+#endif -+ - /* Set up linear page table mapping. */ - l4e_write(&idle_pg_table[l4_table_offset(LINEAR_PT_VIRT_START)], - l4e_from_paddr(__pa(idle_pg_table), __PAGE_HYPERVISOR)); -@@ -182,6 +227,30 @@ void subarch_init_memory(void) - share_xen_page_with_privileged_guests(page, XENSHARE_readonly); - } - } -+#ifdef CONFIG_COMPAT -+ if ( !compat_disabled ) -+ { -+ for ( v = RDWR_COMPAT_MPT_VIRT_START; -+ v != RDWR_COMPAT_MPT_VIRT_END; -+ v += 1 << L2_PAGETABLE_SHIFT ) -+ { -+ l3e = l4e_to_l3e(idle_pg_table[l4_table_offset(v)])[ -+ l3_table_offset(v)]; -+ if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) ) -+ continue; -+ l2e = l3e_to_l2e(l3e)[l2_table_offset(v)]; -+ if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) -+ continue; -+ m2p_start_mfn = l2e_get_pfn(l2e); -+ -+ for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ ) -+ { -+ struct page_info *page = mfn_to_page(m2p_start_mfn + i); -+ share_xen_page_with_privileged_guests(page, XENSHARE_readonly); -+ } -+ } -+ } -+#endif - } - - long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) -@@ -189,7 +258,8 @@ long subarch_memory_op(int op, XEN_GUEST - struct xen_machphys_mfn_list xmml; - l3_pgentry_t l3e; - l2_pgentry_t l2e; -- unsigned long mfn, v; -+ unsigned long v; -+ xen_pfn_t mfn; - unsigned int i; - long rc = 0; - -Index: 2007-01-31/xen/common/compat/kernel.c -=================================================================== ---- 2007-01-31.orig/xen/common/compat/kernel.c 2007-01-31 09:29:09.000000000 +0100 -+++ 2007-01-31/xen/common/compat/kernel.c 2007-01-31 09:29:11.000000000 +0100 -@@ -27,7 +27,7 @@ CHECK_TYPE(capabilities_info); - #define xen_platform_parameters compat_platform_parameters - #define xen_platform_parameters_t compat_platform_parameters_t - #undef HYPERVISOR_VIRT_START --#define HYPERVISOR_VIRT_START HYPERVISOR_COMPAT_VIRT_START -+#define HYPERVISOR_VIRT_START HYPERVISOR_COMPAT_VIRT_START(current->domain) - - #define xen_changeset_info compat_changeset_info - #define xen_changeset_info_t compat_changeset_info_t -Index: 2007-01-31/xen/include/asm-x86/config.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/config.h 2007-01-31 09:29:03.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/config.h 2007-01-31 09:29:11.000000000 +0100 -@@ -133,7 +133,11 @@ extern unsigned long _end; /* standard E - * Page-frame information array. - * 0xffff828800000000 - 0xffff828bffffffff [16GB, 2^34 bytes, PML4:261] - * ioremap()/fixmap area. -- * 0xffff828c00000000 - 0xffff82ffffffffff [464GB, PML4:261] -+ * 0xffff828c00000000 - 0xffff828c3fffffff [1GB, 2^30 bytes, PML4:261] -+ * Compatibility machine-to-phys translation table. -+ * 0xffff828c40000000 - 0xffff828c7fffffff [1GB, 2^30 bytes, PML4:261] -+ * High read-only compatibility machine-to-phys translation table. -+ * 0xffff828c80000000 - 0xffff82ffffffffff [462GB, PML4:261] - * Reserved for future use. - * 0xffff830000000000 - 0xffff83ffffffffff [1TB, 2^40 bytes, PML4:262-263] - * 1:1 direct mapping of all physical memory. Xen and its heap live here. -@@ -182,17 +186,33 @@ extern unsigned long _end; /* standard E - /* Slot 261: ioremap()/fixmap area (16GB). */ - #define IOREMAP_VIRT_START (FRAMETABLE_VIRT_END) - #define IOREMAP_VIRT_END (IOREMAP_VIRT_START + (16UL<<30)) -+/* Slot 261: compatibility machine-to-phys conversion table (1GB). */ -+#define RDWR_COMPAT_MPT_VIRT_START IOREMAP_VIRT_END -+#define RDWR_COMPAT_MPT_VIRT_END (RDWR_COMPAT_MPT_VIRT_START + (1UL << 30)) -+/* Slot 261: high read-only compatibility machine-to-phys conversion table (1GB). */ -+#define HIRO_COMPAT_MPT_VIRT_START RDWR_COMPAT_MPT_VIRT_END -+#define HIRO_COMPAT_MPT_VIRT_END (HIRO_COMPAT_MPT_VIRT_START + (1UL << 30)) - /* Slot 262-263: A direct 1:1 mapping of all of physical memory. */ - #define DIRECTMAP_VIRT_START (PML4_ADDR(262)) - #define DIRECTMAP_VIRT_END (DIRECTMAP_VIRT_START + PML4_ENTRY_BYTES*2) - -+#ifndef __ASSEMBLY__ -+ -+/* This is not a fixed value, just a lower limit. */ - #define __HYPERVISOR_COMPAT_VIRT_START 0xF5800000 --#define HYPERVISOR_COMPAT_VIRT_START \ -- mk_unsigned_long(__HYPERVISOR_COMPAT_VIRT_START) -+#define HYPERVISOR_COMPAT_VIRT_START(d) ((d)->arch.hv_compat_vstart) - #define MACH2PHYS_COMPAT_VIRT_START HYPERVISOR_COMPAT_VIRT_START - #define MACH2PHYS_COMPAT_VIRT_END 0xFFE00000 --#define MACH2PHYS_COMPAT_NR_ENTRIES \ -- ((MACH2PHYS_COMPAT_VIRT_END-MACH2PHYS_COMPAT_VIRT_START)>>2) -+#define MACH2PHYS_COMPAT_NR_ENTRIES(d) \ -+ ((MACH2PHYS_COMPAT_VIRT_END-MACH2PHYS_COMPAT_VIRT_START(d))>>2) -+ -+#define COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d) \ -+ l2_table_offset(HYPERVISOR_COMPAT_VIRT_START(d)) -+#define COMPAT_L2_PAGETABLE_LAST_XEN_SLOT l2_table_offset(~0U) -+#define COMPAT_L2_PAGETABLE_XEN_SLOTS(d) \ -+ (COMPAT_L2_PAGETABLE_LAST_XEN_SLOT - COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d) + 1) -+ -+#endif - - #define PGT_base_page_table PGT_l4_page_table - -Index: 2007-01-31/xen/include/asm-x86/domain.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/domain.h 2007-01-31 09:19:50.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/domain.h 2007-01-31 09:29:11.000000000 +0100 -@@ -98,6 +98,10 @@ struct arch_domain - struct mapcache mapcache; - #endif - -+#ifdef CONFIG_COMPAT -+ unsigned int hv_compat_vstart; -+#endif -+ - /* I/O-port admin-specified access capabilities. */ - struct rangeset *ioport_caps; - -Index: 2007-01-31/xen/include/asm-x86/mm.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/mm.h 2007-01-31 09:29:03.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/mm.h 2007-01-31 09:29:11.000000000 +0100 -@@ -257,7 +257,16 @@ int check_descriptor(const struct domain - #define INVALID_M2P_ENTRY (~0UL) - #define VALID_M2P(_e) (!((_e) & (1UL<<(BITS_PER_LONG-1)))) - -+#ifdef CONFIG_COMPAT -+#define compat_machine_to_phys_mapping ((unsigned int *)RDWR_COMPAT_MPT_VIRT_START) -+#define set_gpfn_from_mfn(mfn, pfn) \ -+ ((void)(compat_disabled || \ -+ (mfn) >= (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) / 4 || \ -+ (compat_machine_to_phys_mapping[(mfn)] = (unsigned int)(pfn))), \ -+ machine_to_phys_mapping[(mfn)] = (pfn)) -+#else - #define set_gpfn_from_mfn(mfn, pfn) (machine_to_phys_mapping[(mfn)] = (pfn)) -+#endif - #define get_gpfn_from_mfn(mfn) (machine_to_phys_mapping[(mfn)]) - - -Index: 2007-01-31/xen/include/asm-x86/page.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/page.h 2007-01-31 09:19:50.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/page.h 2007-01-31 09:29:11.000000000 +0100 -@@ -206,6 +206,7 @@ typedef struct { u32 pfn; } pagetable_t; - typedef struct { u64 pfn; } pagetable_t; - #endif - #define pagetable_get_paddr(x) ((paddr_t)(x).pfn << PAGE_SHIFT) -+#define pagetable_get_page(x) mfn_to_page((x).pfn) - #define pagetable_get_pfn(x) ((x).pfn) - #define pagetable_is_null(x) ((x).pfn == 0) - #define pagetable_from_pfn(pfn) ((pagetable_t) { (pfn) }) -@@ -284,6 +285,10 @@ extern l2_pgentry_t idle_pg_table_l2[R - #else - extern root_pgentry_t idle_pg_table[ROOT_PAGETABLE_ENTRIES]; - extern l2_pgentry_t idle_pg_table_l2[ROOT_PAGETABLE_ENTRIES]; -+#ifdef CONFIG_COMPAT -+extern l2_pgentry_t *compat_idle_pg_table_l2; -+extern unsigned int m2p_compat_vstart; -+#endif - #endif - void paging_init(void); - void setup_idle_pagetable(void); -Index: 2007-01-31/xen/include/asm-x86/x86_32/page-2level.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/x86_32/page-2level.h 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/x86_32/page-2level.h 2007-01-31 09:29:11.000000000 +0100 -@@ -42,7 +42,7 @@ typedef l2_pgentry_t root_pgentry_t; - - /* misc */ - #define is_guest_l1_slot(_s) (1) --#define is_guest_l2_slot(_t,_s) ((_s) < L2_PAGETABLE_FIRST_XEN_SLOT) -+#define is_guest_l2_slot(_d, _t,_s) ((_s) < L2_PAGETABLE_FIRST_XEN_SLOT) - - /* - * PTE pfn and flags: -Index: 2007-01-31/xen/include/asm-x86/x86_32/page-3level.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/x86_32/page-3level.h 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/x86_32/page-3level.h 2007-01-31 09:29:11.000000000 +0100 -@@ -67,7 +67,7 @@ typedef l3_pgentry_t root_pgentry_t; - - /* misc */ - #define is_guest_l1_slot(s) (1) --#define is_guest_l2_slot(t,s) \ -+#define is_guest_l2_slot(d,t,s) \ - ( !((t) & PGT_pae_xen_l2) || \ - ((s) < (L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES - 1))) ) - #define is_guest_l3_slot(s) (1) -Index: 2007-01-31/xen/include/asm-x86/x86_64/page.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/x86_64/page.h 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/x86_64/page.h 2007-01-31 09:29:11.000000000 +0100 -@@ -54,7 +54,10 @@ typedef l4_pgentry_t root_pgentry_t; - #define l4_linear_offset(_a) (((_a) & VADDR_MASK) >> L4_PAGETABLE_SHIFT) - - #define is_guest_l1_slot(_s) (1) --#define is_guest_l2_slot(_t, _s) (1) -+#define is_guest_l2_slot(_d, _t, _s) \ -+ ( !IS_COMPAT(_d) || \ -+ !((_t) & PGT_pae_xen_l2) || \ -+ ((_s) < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_d)) ) - #define is_guest_l3_slot(_s) (1) - #define is_guest_l4_slot(_s) \ - (((_s) < ROOT_PAGETABLE_FIRST_XEN_SLOT) || \ -@@ -93,6 +96,8 @@ typedef l4_pgentry_t root_pgentry_t; - #define L3_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */) - #define L4_DISALLOW_MASK (BASE_DISALLOW_MASK | 0x180U /* must-be-zero */) - -+#define COMPAT_L3_DISALLOW_MASK 0xFFFFF1E6U /* must-be-zero */ -+ - #define PAGE_HYPERVISOR (__PAGE_HYPERVISOR | _PAGE_GLOBAL) - #define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL) - -Index: 2007-01-31/xen/include/asm-x86/x86_64/uaccess.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/x86_64/uaccess.h 2007-01-31 09:29:09.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/x86_64/uaccess.h 2007-01-31 09:29:11.000000000 +0100 -@@ -18,7 +18,7 @@ - #ifdef CONFIG_COMPAT - - #define __compat_addr_ok(addr) \ -- ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START) -+ ((unsigned long)(addr) < HYPERVISOR_COMPAT_VIRT_START(current->domain)) - - #define compat_access_ok(addr, size) __compat_addr_ok((addr) + (size)) - diff --git a/32on64-memop.patch b/32on64-memop.patch deleted file mode 100644 index 9d80af5..0000000 --- a/32on64-memop.patch +++ /dev/null @@ -1,1196 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_memory_op, -HYPERVISOR_update_descriptor, HYPERVISOR_update_va_mapping. This also -introduces infrastructure to do argument translation. - -Index: 2007-01-08/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain.c 2006-12-18 09:49:18.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain.c 2007-01-08 14:53:55.000000000 +0100 -@@ -128,10 +128,98 @@ void free_vcpu_struct(struct vcpu *v) - } - - #ifdef CONFIG_COMPAT -+ -+int setup_arg_xlat_area(struct vcpu *v, l4_pgentry_t *l4tab) -+{ -+ struct domain *d = v->domain; -+ unsigned i; -+ struct page_info *pg; -+ -+ if ( !d->arch.mm_arg_xlat_l3 ) -+ { -+ pg = alloc_domheap_page(NULL); -+ if ( !pg ) -+ return -ENOMEM; -+ d->arch.mm_arg_xlat_l3 = clear_page(page_to_virt(pg)); -+ } -+ -+ l4tab[l4_table_offset(COMPAT_ARG_XLAT_VIRT_BASE)] = -+ l4e_from_paddr(__pa(d->arch.mm_arg_xlat_l3), __PAGE_HYPERVISOR); -+ -+ for ( i = 0; i < COMPAT_ARG_XLAT_PAGES; ++i ) -+ { -+ unsigned long va = COMPAT_ARG_XLAT_VIRT_START(v->vcpu_id) + i * PAGE_SIZE; -+ l2_pgentry_t *l2tab; -+ l1_pgentry_t *l1tab; -+ -+ if ( !l3e_get_intpte(d->arch.mm_arg_xlat_l3[l3_table_offset(va)]) ) -+ { -+ pg = alloc_domheap_page(NULL); -+ if ( !pg ) -+ return -ENOMEM; -+ clear_page(page_to_virt(pg)); -+ d->arch.mm_arg_xlat_l3[l3_table_offset(va)] = l3e_from_page(pg, __PAGE_HYPERVISOR); -+ } -+ l2tab = l3e_to_l2e(d->arch.mm_arg_xlat_l3[l3_table_offset(va)]); -+ if ( !l2e_get_intpte(l2tab[l2_table_offset(va)]) ) -+ { -+ pg = alloc_domheap_page(NULL); -+ if ( !pg ) -+ return -ENOMEM; -+ clear_page(page_to_virt(pg)); -+ l2tab[l2_table_offset(va)] = l2e_from_page(pg, __PAGE_HYPERVISOR); -+ } -+ l1tab = l2e_to_l1e(l2tab[l2_table_offset(va)]); -+ BUG_ON(l1e_get_intpte(l1tab[l1_table_offset(va)])); -+ pg = alloc_domheap_page(NULL); -+ if ( !pg ) -+ return -ENOMEM; -+ l1tab[l1_table_offset(va)] = l1e_from_page(pg, PAGE_HYPERVISOR); -+ } -+ -+ return 0; -+} -+ -+static void release_arg_xlat_area(struct domain *d) -+{ -+ if ( d->arch.mm_arg_xlat_l3 ) -+ { -+ unsigned l3; -+ -+ for ( l3 = 0; l3 < L3_PAGETABLE_ENTRIES; ++l3 ) -+ { -+ if ( l3e_get_intpte(d->arch.mm_arg_xlat_l3[l3]) ) -+ { -+ l2_pgentry_t *l2tab = l3e_to_l2e(d->arch.mm_arg_xlat_l3[l3]); -+ unsigned l2; -+ -+ for ( l2 = 0; l2 < L2_PAGETABLE_ENTRIES; ++l2 ) -+ { -+ if ( l2e_get_intpte(l2tab[l2]) ) -+ { -+ l1_pgentry_t *l1tab = l2e_to_l1e(l2tab[l2]); -+ unsigned l1; -+ -+ for ( l1 = 0; l1 < L1_PAGETABLE_ENTRIES; ++l1 ) -+ { -+ if ( l1e_get_intpte(l1tab[l1]) ) -+ free_domheap_page(l1e_get_page(l1tab[l1])); -+ } -+ free_domheap_page(l2e_get_page(l2tab[l2])); -+ } -+ } -+ free_domheap_page(l3e_get_page(d->arch.mm_arg_xlat_l3[l3])); -+ } -+ } -+ free_domheap_page(virt_to_page(d->arch.mm_arg_xlat_l3)); -+ } -+} -+ - static int setup_compat_l4(struct vcpu *v) - { - struct page_info *pg = alloc_domheap_page(NULL); - l4_pgentry_t *l4tab; -+ int rc; - - if ( !pg ) - return -ENOMEM; -@@ -143,10 +231,26 @@ static int setup_compat_l4(struct vcpu * - v->arch.guest_table = pagetable_from_page(pg); - v->arch.guest_table_user = v->arch.guest_table; - -+ if ( (rc = setup_arg_xlat_area(v, l4tab)) < 0 ) -+ { -+ free_domheap_page(pg); -+ return rc; -+ } -+ - return 0; - } -+ -+static void release_compat_l4(struct vcpu *v) -+{ -+ free_domheap_page(pagetable_get_page(v->arch.guest_table)); -+ v->arch.guest_table = pagetable_null(); -+ v->arch.guest_table_user = pagetable_null(); -+} -+ - #else -+#define release_arg_xlat_area(d) ((void)0) - #define setup_compat_l4(v) 0 -+#define release_compat_l4(v) ((void)0) - #endif - - int vcpu_initialise(struct vcpu *v) -@@ -192,7 +296,7 @@ int vcpu_initialise(struct vcpu *v) - void vcpu_destroy(struct vcpu *v) - { - if ( IS_COMPAT(v->domain) ) -- free_domheap_page(pagetable_get_page(v->arch.guest_table)); -+ release_compat_l4(v); - } - - int arch_domain_create(struct domain *d) -@@ -305,6 +409,9 @@ void arch_domain_destroy(struct domain * - free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3)); - #endif - -+ if ( IS_COMPAT(d) ) -+ release_arg_xlat_area(d); -+ - free_xenheap_page(d->shared_info); - } - -@@ -945,55 +1052,153 @@ unsigned long hypercall_create_continuat - - for ( i = 0; *p != '\0'; i++ ) - mcs->call.args[i] = next_arg(p, args); -+ if ( IS_COMPAT(current->domain) ) -+ { -+ for ( ; i < 6; i++ ) -+ mcs->call.args[i] = 0; -+ } - } - else - { - regs = guest_cpu_user_regs(); --#if defined(__i386__) - regs->eax = op; -+ regs->eip -= 2; /* re-execute 'syscall' / 'int 0x82' */ - -- if ( supervisor_mode_kernel || is_hvm_vcpu(current) ) -- regs->eip &= ~31; /* re-execute entire hypercall entry stub */ -+#ifdef __x86_64__ -+ if ( !IS_COMPAT(current->domain) ) -+ { -+ for ( i = 0; *p != '\0'; i++ ) -+ { -+ arg = next_arg(p, args); -+ switch ( i ) -+ { -+ case 0: regs->rdi = arg; break; -+ case 1: regs->rsi = arg; break; -+ case 2: regs->rdx = arg; break; -+ case 3: regs->r10 = arg; break; -+ case 4: regs->r8 = arg; break; -+ case 5: regs->r9 = arg; break; -+ } -+ } -+ } - else -- regs->eip -= 2; /* re-execute 'int 0x82' */ -- -- for ( i = 0; *p != '\0'; i++ ) -+#endif - { -- arg = next_arg(p, args); -- switch ( i ) -+ if ( supervisor_mode_kernel || is_hvm_vcpu(current) ) -+ regs->eip &= ~31; /* re-execute entire hypercall entry stub */ -+ -+ for ( i = 0; *p != '\0'; i++ ) - { -- case 0: regs->ebx = arg; break; -- case 1: regs->ecx = arg; break; -- case 2: regs->edx = arg; break; -- case 3: regs->esi = arg; break; -- case 4: regs->edi = arg; break; -- case 5: regs->ebp = arg; break; -+ arg = next_arg(p, args); -+ switch ( i ) -+ { -+ case 0: regs->ebx = arg; break; -+ case 1: regs->ecx = arg; break; -+ case 2: regs->edx = arg; break; -+ case 3: regs->esi = arg; break; -+ case 4: regs->edi = arg; break; -+ case 5: regs->ebp = arg; break; -+ } - } - } --#elif defined(__x86_64__) -- regs->rax = op; -- regs->rip -= 2; /* re-execute 'syscall' */ -+ } - -- for ( i = 0; *p != '\0'; i++ ) -+ va_end(args); -+ -+ return op; -+} -+ -+#ifdef CONFIG_COMPAT -+int hypercall_xlat_continuation(unsigned int *id, unsigned int mask, ...) -+{ -+ int rc = 0; -+ struct mc_state *mcs = &this_cpu(mc_state); -+ struct cpu_user_regs *regs; -+ unsigned int i, cval = 0; -+ unsigned long nval = 0; -+ va_list args; -+ -+ BUG_ON(*id > 5); -+ BUG_ON(mask & (1U << *id)); -+ -+ va_start(args, mask); -+ -+ if ( test_bit(_MCSF_in_multicall, &mcs->flags) ) -+ { -+ if ( !test_bit(_MCSF_call_preempted, &mcs->flags) ) -+ return 0; -+ for ( i = 0; i < 6; ++i, mask >>= 1 ) -+ { -+ if ( mask & 1 ) -+ { -+ nval = va_arg(args, unsigned long); -+ cval = va_arg(args, unsigned int); -+ if ( cval == nval ) -+ mask &= ~1U; -+ else -+ BUG_ON(nval == (unsigned int)nval); -+ } -+ else if ( id && *id == i ) -+ { -+ *id = mcs->call.args[i]; -+ id = NULL; -+ } -+ if ( (mask & 1) && mcs->call.args[i] == nval ) -+ ++rc; -+ else -+ { -+ cval = mcs->call.args[i]; -+ BUG_ON(mcs->call.args[i] != cval); -+ } -+ mcs->compat_call.args[i] = cval; -+ } -+ } -+ else -+ { -+ regs = guest_cpu_user_regs(); -+ for ( i = 0; i < 6; ++i, mask >>= 1 ) - { -- arg = next_arg(p, args); -+ unsigned long *reg; -+ - switch ( i ) - { -- case 0: regs->rdi = arg; break; -- case 1: regs->rsi = arg; break; -- case 2: regs->rdx = arg; break; -- case 3: regs->r10 = arg; break; -- case 4: regs->r8 = arg; break; -- case 5: regs->r9 = arg; break; -+ case 0: reg = ®s->ebx; break; -+ case 1: reg = ®s->ecx; break; -+ case 2: reg = ®s->edx; break; -+ case 3: reg = ®s->esi; break; -+ case 4: reg = ®s->edi; break; -+ case 5: reg = ®s->ebp; break; -+ default: BUG(); reg = NULL; break; - } -+ if ( (mask & 1) ) -+ { -+ nval = va_arg(args, unsigned long); -+ cval = va_arg(args, unsigned int); -+ if ( cval == nval ) -+ mask &= ~1U; -+ else -+ BUG_ON(nval == (unsigned int)nval); -+ } -+ else if ( id && *id == i ) -+ { -+ *id = *reg; -+ id = NULL; -+ } -+ if ( (mask & 1) && *reg == nval ) -+ { -+ *reg = cval; -+ ++rc; -+ } -+ else -+ BUG_ON(*reg != (unsigned int)*reg); - } --#endif - } - - va_end(args); - -- return op; -+ return rc; - } -+#endif - - static void relinquish_memory(struct domain *d, struct list_head *list) - { -Index: 2007-01-08/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain_build.c 2007-01-08 15:35:48.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain_build.c 2007-01-08 15:35:59.000000000 +0100 -@@ -688,7 +688,11 @@ int construct_dom0(struct domain *d, - l4e_from_paddr(__pa(d->arch.mm_perdomain_l3), __PAGE_HYPERVISOR); - v->arch.guest_table = pagetable_from_paddr(__pa(l4start)); - if ( IS_COMPAT(d) ) -+ { - v->arch.guest_table_user = v->arch.guest_table; -+ if ( setup_arg_xlat_area(v, l4start) < 0 ) -+ panic("Not enough RAM for domain 0 hypercall argument translation.\n"); -+ } - - l4tab += l4_table_offset(dsi.v_start); - mfn = alloc_spfn; -Index: 2007-01-08/xen/arch/x86/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/mm.c 2006-12-18 09:49:18.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/mm.c 2007-01-08 14:53:55.000000000 +0100 -@@ -1115,9 +1115,12 @@ static int alloc_l4_table(struct page_in - pl4e[l4_table_offset(LINEAR_PT_VIRT_START)] = - l4e_from_pfn(pfn, __PAGE_HYPERVISOR); - pl4e[l4_table_offset(PERDOMAIN_VIRT_START)] = -- l4e_from_page( -- virt_to_page(page_get_owner(page)->arch.mm_perdomain_l3), -- __PAGE_HYPERVISOR); -+ l4e_from_page(virt_to_page(d->arch.mm_perdomain_l3), -+ __PAGE_HYPERVISOR); -+ if ( IS_COMPAT(d) ) -+ pl4e[l4_table_offset(COMPAT_ARG_XLAT_VIRT_BASE)] = -+ l4e_from_page(virt_to_page(d->arch.mm_arg_xlat_l3), -+ __PAGE_HYPERVISOR); - - return 1; - -@@ -2754,7 +2757,9 @@ int do_update_va_mapping(unsigned long v - flush_tlb_mask(d->domain_dirty_cpumask); - break; - default: -- if ( unlikely(get_user(vmask, (unsigned long *)bmap_ptr)) ) -+ if ( unlikely(!IS_COMPAT(d) ? -+ get_user(vmask, (unsigned long *)bmap_ptr) : -+ get_user(vmask, (unsigned int *)bmap_ptr)) ) - rc = -EFAULT; - pmask = vcpumask_to_pcpumask(d, vmask); - flush_tlb_mask(pmask); -Index: 2007-01-08/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/Makefile 2006-12-18 09:43:08.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/Makefile 2007-01-08 14:53:55.000000000 +0100 -@@ -6,5 +6,6 @@ obj-y += traps.o - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies - entry.o: compat/entry.S -+mm.o: compat/mm.c - traps.o: compat/traps.c - endif -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:19:11.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 14:53:55.000000000 +0100 -@@ -282,15 +282,11 @@ CFIX14: - #define compat_mmu_update domain_crash_synchronous - #define compat_set_gdt domain_crash_synchronous - #define compat_platform_op domain_crash_synchronous --#define compat_update_descriptor domain_crash_synchronous --#define compat_memory_op domain_crash_synchronous - #define compat_multicall domain_crash_synchronous --#define compat_update_va_mapping domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous - #define compat_event_channel_op_compat domain_crash_synchronous - #define compat_physdev_op_compat domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous --#define compat_update_va_mapping_otherdomain domain_crash_synchronous - #define compat_vcpu_op domain_crash_synchronous - #define compat_mmuext_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous -Index: 2007-01-08/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/mm.c 2007-01-08 14:53:55.000000000 +0100 -@@ -0,0 +1,148 @@ -+#ifdef CONFIG_COMPAT -+ -+#include -+ -+int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi) -+{ -+ return do_update_descriptor(pa_lo | ((u64)pa_hi << 32), -+ desc_lo | ((u64)desc_hi << 32)); -+} -+ -+int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg) -+{ -+ struct compat_machphys_mfn_list xmml; -+ l2_pgentry_t l2e; -+ unsigned long v; -+ compat_pfn_t mfn; -+ unsigned int i; -+ int rc = 0; -+ -+ switch ( op ) -+ { -+ case XENMEM_add_to_physmap: -+ { -+ struct compat_add_to_physmap cmp; -+ struct xen_add_to_physmap *nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id); -+ -+ if ( copy_from_guest(&cmp, arg, 1) ) -+ return -EFAULT; -+ -+ XLAT_add_to_physmap(nat, &cmp); -+ rc = arch_memory_op(op, guest_handle_from_ptr(nat, void)); -+ -+ break; -+ } -+ -+ case XENMEM_set_memory_map: -+ { -+ struct compat_foreign_memory_map cmp; -+ struct xen_foreign_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id); -+ -+ if ( copy_from_guest(&cmp, arg, 1) ) -+ return -EFAULT; -+ -+#define XLAT_memory_map_HNDL_buffer(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->buffer, (_s_)->buffer) -+ XLAT_foreign_memory_map(nat, &cmp); -+#undef XLAT_memory_map_HNDL_buffer -+ -+ rc = arch_memory_op(op, guest_handle_from_ptr(nat, void)); -+ -+ break; -+ } -+ -+ case XENMEM_memory_map: -+ case XENMEM_machine_memory_map: -+ { -+ struct compat_memory_map cmp; -+ struct xen_memory_map *nat = (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id); -+ -+ if ( copy_from_guest(&cmp, arg, 1) ) -+ return -EFAULT; -+ -+#define XLAT_memory_map_HNDL_buffer(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->buffer, (_s_)->buffer) -+ XLAT_memory_map(nat, &cmp); -+#undef XLAT_memory_map_HNDL_buffer -+ -+ rc = arch_memory_op(op, guest_handle_from_ptr(nat, void)); -+ if ( rc < 0 ) -+ break; -+ -+#define XLAT_memory_map_HNDL_buffer(_d_, _s_) ((void)0) -+ XLAT_memory_map(&cmp, nat); -+#undef XLAT_memory_map_HNDL_buffer -+ if ( copy_to_guest(arg, &cmp, 1) ) -+ rc = -EFAULT; -+ -+ break; -+ } -+ -+ case XENMEM_machphys_mapping: -+ { -+ struct domain *d = current->domain; -+ struct compat_machphys_mapping mapping = { -+ .v_start = MACH2PHYS_COMPAT_VIRT_START(d), -+ .v_end = MACH2PHYS_COMPAT_VIRT_END, -+ .max_mfn = MACH2PHYS_COMPAT_NR_ENTRIES(d) - 1 -+ }; -+ -+ if ( copy_to_guest(arg, &mapping, 1) ) -+ rc = -EFAULT; -+ -+ break; -+ } -+ -+ case XENMEM_machphys_mfn_list: -+ if ( copy_from_guest(&xmml, arg, 1) ) -+ return -EFAULT; -+ -+ for ( i = 0, v = RDWR_COMPAT_MPT_VIRT_START; -+ (i != xmml.max_extents) && (v != RDWR_COMPAT_MPT_VIRT_END); -+ i++, v += 1 << L2_PAGETABLE_SHIFT ) -+ { -+ l2e = compat_idle_pg_table_l2[l2_table_offset(v)]; -+ if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ) -+ break; -+ mfn = l2e_get_pfn(l2e) + l1_table_offset(v); -+ if ( copy_to_compat_offset(xmml.extent_start, i, &mfn, 1) ) -+ return -EFAULT; -+ } -+ -+ xmml.nr_extents = i; -+ if ( copy_to_guest(arg, &xmml, 1) ) -+ rc = -EFAULT; -+ -+ break; -+ -+ default: -+ rc = -ENOSYS; -+ break; -+ } -+ -+ return rc; -+} -+ -+int compat_update_va_mapping(unsigned int va, u32 lo, u32 hi, -+ unsigned int flags) -+{ -+ return do_update_va_mapping(va, lo | ((u64)hi << 32), flags); -+} -+ -+int compat_update_va_mapping_otherdomain(unsigned long va, u32 lo, u32 hi, -+ unsigned long flags, -+ domid_t domid) -+{ -+ return do_update_va_mapping_otherdomain(va, lo | ((u64)hi << 32), flags, domid); -+} -+#endif /* CONFIG_COMPAT */ -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/arch/x86/x86_64/mm.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/mm.c 2006-12-18 09:49:18.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/mm.c 2007-01-08 14:53:55.000000000 +0100 -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -407,6 +408,8 @@ int check_descriptor(const struct domain - return 0; - } - -+#include "compat/mm.c" -+ - /* - * Local variables: - * mode: C -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/compat/Makefile 2007-01-08 15:18:32.000000000 +0100 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 14:53:55.000000000 +0100 -@@ -1,4 +1,5 @@ - obj-y += kernel.o -+obj-y += memory.o - obj-y += xlat.o - - # extra dependencies -Index: 2007-01-08/xen/common/compat/memory.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/memory.c 2007-01-08 14:53:55.000000000 +0100 -@@ -0,0 +1,364 @@ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+int compat_memory_op(unsigned int cmd, XEN_GUEST_HANDLE(void) compat) -+{ -+ int rc, split, op = cmd & MEMOP_CMD_MASK; -+ unsigned int start_extent = cmd >> MEMOP_EXTENT_SHIFT; -+ -+ do -+ { -+ unsigned int i, end_extent = 0; -+ union { -+ XEN_GUEST_HANDLE(void) hnd; -+ struct xen_memory_reservation *rsrv; -+ struct xen_memory_exchange *xchg; -+ struct xen_translate_gpfn_list *xlat; -+ } nat; -+ union { -+ struct compat_memory_reservation rsrv; -+ struct compat_memory_exchange xchg; -+ struct compat_translate_gpfn_list xlat; -+ } cmp; -+ -+ set_xen_guest_handle(nat.hnd, (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id)); -+ split = 0; -+ switch ( op ) -+ { -+ xen_pfn_t *space; -+ -+ case XENMEM_increase_reservation: -+ case XENMEM_decrease_reservation: -+ case XENMEM_populate_physmap: -+ if ( copy_from_guest(&cmp.rsrv, compat, 1) ) -+ return start_extent; -+ -+ /* Is size too large for us to encode a continuation? */ -+ if ( cmp.rsrv.nr_extents > (UINT_MAX >> MEMOP_EXTENT_SHIFT) ) -+ return start_extent; -+ -+ if ( !compat_handle_is_null(cmp.rsrv.extent_start) && -+ !compat_handle_okay(cmp.rsrv.extent_start, cmp.rsrv.nr_extents) ) -+ return start_extent; -+ -+ end_extent = start_extent + (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.rsrv)) / -+ sizeof(*space); -+ if ( end_extent > cmp.rsrv.nr_extents ) -+ end_extent = cmp.rsrv.nr_extents; -+ -+ space = (xen_pfn_t *)(nat.rsrv + 1); -+#define XLAT_memory_reservation_HNDL_extent_start(_d_, _s_) \ -+ do \ -+ { \ -+ if ( !compat_handle_is_null((_s_)->extent_start) ) \ -+ { \ -+ set_xen_guest_handle((_d_)->extent_start, space - start_extent); \ -+ if ( op != XENMEM_increase_reservation ) \ -+ { \ -+ for ( i = start_extent; i < end_extent; ++i ) \ -+ { \ -+ compat_pfn_t pfn; \ -+ if ( __copy_from_compat_offset(&pfn, (_s_)->extent_start, i, 1) ) \ -+ { \ -+ end_extent = i; \ -+ split = -1; \ -+ break; \ -+ } \ -+ *space++ = pfn; \ -+ } \ -+ } \ -+ } \ -+ else \ -+ { \ -+ set_xen_guest_handle((_d_)->extent_start, NULL); \ -+ end_extent = cmp.rsrv.nr_extents; \ -+ } \ -+ } while (0) -+ XLAT_memory_reservation(nat.rsrv, &cmp.rsrv); -+#undef XLAT_memory_reservation_HNDL_extent_start -+ -+ if ( end_extent < cmp.rsrv.nr_extents ) -+ { -+ nat.rsrv->nr_extents = end_extent; -+ ++split; -+ } -+ -+ break; -+ -+ case XENMEM_exchange: -+ { -+ int order_delta; -+ -+ if ( copy_from_guest(&cmp.xchg, compat, 1) ) -+ return -EFAULT; -+ -+ order_delta = cmp.xchg.out.extent_order - cmp.xchg.in.extent_order; -+ /* Various sanity checks. */ -+ if ( (cmp.xchg.nr_exchanged > cmp.xchg.in.nr_extents) || -+ (order_delta > 0 && (cmp.xchg.nr_exchanged & ((1U << order_delta) - 1))) || -+ /* Sizes of input and output lists do not overflow an int? */ -+ ((~0U >> cmp.xchg.in.extent_order) < cmp.xchg.in.nr_extents) || -+ ((~0U >> cmp.xchg.out.extent_order) < cmp.xchg.out.nr_extents) || -+ /* Sizes of input and output lists match? */ -+ ((cmp.xchg.in.nr_extents << cmp.xchg.in.extent_order) != -+ (cmp.xchg.out.nr_extents << cmp.xchg.out.extent_order)) ) -+ return -EINVAL; -+ -+ start_extent = cmp.xchg.nr_exchanged; -+ end_extent = (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.xchg)) / -+ (((1U << __builtin_abs(order_delta)) + 1) * -+ sizeof(*space)); -+ if ( end_extent == 0 ) -+ { -+ printk("Cannot translate compatibility mode XENMEM_exchange extents (%u,%u)\n", -+ cmp.xchg.in.extent_order, cmp.xchg.out.extent_order); -+ return -E2BIG; -+ } -+ if ( order_delta > 0 ) -+ end_extent <<= order_delta; -+ end_extent += start_extent; -+ if ( end_extent > cmp.xchg.in.nr_extents ) -+ end_extent = cmp.xchg.in.nr_extents; -+ -+ space = (xen_pfn_t *)(nat.xchg + 1); -+ /* Code below depends upon .in preceding .out. */ -+ BUILD_BUG_ON(offsetof(xen_memory_exchange_t, in) > offsetof(xen_memory_exchange_t, out)); -+#define XLAT_memory_reservation_HNDL_extent_start(_d_, _s_) \ -+ do \ -+ { \ -+ set_xen_guest_handle((_d_)->extent_start, space - start_extent); \ -+ for ( i = start_extent; i < end_extent; ++i ) \ -+ { \ -+ compat_pfn_t pfn; \ -+ if ( __copy_from_compat_offset(&pfn, (_s_)->extent_start, i, 1) ) \ -+ return -EFAULT; \ -+ *space++ = pfn; \ -+ } \ -+ if ( order_delta > 0 ) \ -+ { \ -+ start_extent >>= order_delta; \ -+ end_extent >>= order_delta; \ -+ } \ -+ else \ -+ { \ -+ start_extent <<= -order_delta; \ -+ end_extent <<= -order_delta; \ -+ } \ -+ order_delta = -order_delta; \ -+ } while (0) -+ XLAT_memory_exchange(nat.xchg, &cmp.xchg); -+#undef XLAT_memory_reservation_HNDL_extent_start -+ -+ if ( end_extent < cmp.xchg.in.nr_extents ) -+ { -+ nat.xchg->in.nr_extents = end_extent; -+ if ( order_delta >= 0 ) -+ nat.xchg->out.nr_extents = end_extent >> order_delta; -+ else -+ nat.xchg->out.nr_extents = end_extent << order_delta; -+ ++split; -+ } -+ -+ break; -+ } -+ -+ case XENMEM_current_reservation: -+ case XENMEM_maximum_reservation: -+ { -+#define xen_domid_t domid_t -+#define compat_domid_t domid_compat_t -+ CHECK_TYPE(domid); -+#undef compat_domid_t -+#undef xen_domid_t -+ } -+ case XENMEM_maximum_ram_page: -+ nat.hnd = compat; -+ break; -+ -+ case XENMEM_translate_gpfn_list: -+ if ( copy_from_guest(&cmp.xlat, compat, 1) ) -+ return -EFAULT; -+ -+ /* Is size too large for us to encode a continuation? */ -+ if ( cmp.xlat.nr_gpfns > (UINT_MAX >> MEMOP_EXTENT_SHIFT) ) -+ return -EINVAL; -+ -+ if ( !compat_handle_okay(cmp.xlat.gpfn_list, cmp.xlat.nr_gpfns) || -+ !compat_handle_okay(cmp.xlat.mfn_list, cmp.xlat.nr_gpfns) ) -+ return -EFAULT; -+ -+ end_extent = start_extent + (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.xlat)) / -+ sizeof(*space); -+ if ( end_extent > cmp.xlat.nr_gpfns ) -+ end_extent = cmp.xlat.nr_gpfns; -+ -+ space = (xen_pfn_t *)(nat.xlat + 1); -+ /* Code below depends upon .gpfn_list preceding .mfn_list. */ -+ BUILD_BUG_ON(offsetof(xen_translate_gpfn_list_t, gpfn_list) > offsetof(xen_translate_gpfn_list_t, mfn_list)); -+#define XLAT_translate_gpfn_list_HNDL_gpfn_list(_d_, _s_) \ -+ do \ -+ { \ -+ set_xen_guest_handle((_d_)->gpfn_list, space - start_extent); \ -+ for ( i = start_extent; i < end_extent; ++i ) \ -+ { \ -+ compat_pfn_t pfn; \ -+ if ( __copy_from_compat_offset(&pfn, (_s_)->gpfn_list, i, 1) ) \ -+ return -EFAULT; \ -+ *space++ = pfn; \ -+ } \ -+ } while (0) -+#define XLAT_translate_gpfn_list_HNDL_mfn_list(_d_, _s_) \ -+ (_d_)->mfn_list = (_d_)->gpfn_list -+ XLAT_translate_gpfn_list(nat.xlat, &cmp.xlat); -+#undef XLAT_translate_gpfn_list_HNDL_mfn_list -+#undef XLAT_translate_gpfn_list_HNDL_gpfn_list -+ -+ if ( end_extent < cmp.xlat.nr_gpfns ) -+ { -+ nat.xlat->nr_gpfns = end_extent; -+ ++split; -+ } -+ -+ break; -+ -+ default: -+ return compat_arch_memory_op(cmd, compat); -+ } -+ -+ rc = do_memory_op(cmd, nat.hnd); -+ if ( rc < 0 ) -+ return rc; -+ -+ cmd = 0; -+ if ( hypercall_xlat_continuation(&cmd, 0x02, nat.hnd, compat) ) -+ { -+ BUG_ON(rc != __HYPERVISOR_memory_op); -+ BUG_ON((cmd & MEMOP_CMD_MASK) != op); -+ split = -1; -+ } -+ -+ switch ( op ) -+ { -+ case XENMEM_increase_reservation: -+ case XENMEM_decrease_reservation: -+ case XENMEM_populate_physmap: -+ end_extent = split >= 0 ? rc : cmd >> MEMOP_EXTENT_SHIFT; -+ if ( op != XENMEM_decrease_reservation && -+ !guest_handle_is_null(nat.rsrv->extent_start) ) -+ { -+ for ( ; start_extent < end_extent; ++start_extent ) -+ { -+ compat_pfn_t pfn = nat.rsrv->extent_start.p[start_extent]; -+ -+ BUG_ON(pfn != nat.rsrv->extent_start.p[start_extent]); -+ if ( __copy_to_compat_offset(cmp.rsrv.extent_start, start_extent, &pfn, 1) ) -+ { -+ if ( split >= 0 ) -+ { -+ rc = start_extent; -+ split = 0; -+ } -+ else -+ /* -+ * Short of being able to cancel the continuation, -+ * force it to restart here; eventually we shall -+ * get out of this state. -+ */ -+ rc = (start_extent << MEMOP_EXTENT_SHIFT) | op; -+ break; -+ } -+ } -+ } -+ else -+ start_extent = end_extent; -+ break; -+ -+ case XENMEM_exchange: -+ { -+ DEFINE_XEN_GUEST_HANDLE(compat_memory_exchange_t); -+ int order_delta; -+ -+ BUG_ON(split >= 0 && rc); -+ BUG_ON(end_extent < nat.xchg->nr_exchanged); -+ end_extent = nat.xchg->nr_exchanged; -+ -+ order_delta = cmp.xchg.out.extent_order - cmp.xchg.in.extent_order; -+ if ( order_delta > 0 ) -+ { -+ start_extent >>= order_delta; -+ BUG_ON(end_extent & ((1U << order_delta) - 1)); -+ end_extent >>= order_delta; -+ } -+ else -+ { -+ start_extent <<= -order_delta; -+ end_extent <<= -order_delta; -+ } -+ -+ for ( ; start_extent < end_extent; ++start_extent ) -+ { -+ compat_pfn_t pfn = nat.xchg->out.extent_start.p[start_extent]; -+ -+ BUG_ON(pfn != nat.xchg->out.extent_start.p[start_extent]); -+ /* Note that we ignore errors accessing the output extent list. */ -+ __copy_to_compat_offset(cmp.xchg.out.extent_start, start_extent, &pfn, 1); -+ } -+ -+ cmp.xchg.nr_exchanged = nat.xchg->nr_exchanged; -+ if ( copy_field_to_guest(guest_handle_cast(compat, compat_memory_exchange_t), -+ &cmp.xchg, nr_exchanged) ) -+ { -+ if ( split < 0 ) -+ /* Cannot cancel the continuation... */ -+ domain_crash(current->domain); -+ return -EFAULT; -+ } -+ break; -+ } -+ -+ case XENMEM_maximum_ram_page: -+ case XENMEM_current_reservation: -+ case XENMEM_maximum_reservation: -+ break; -+ -+ case XENMEM_translate_gpfn_list: -+ if ( split < 0 ) -+ end_extent = cmd >> MEMOP_EXTENT_SHIFT; -+ else -+ BUG_ON(rc); -+ -+ for ( ; start_extent < end_extent; ++start_extent ) -+ { -+ compat_pfn_t pfn = nat.xlat->mfn_list.p[start_extent]; -+ -+ BUG_ON(pfn != nat.xlat->mfn_list.p[start_extent]); -+ if ( __copy_to_compat_offset(cmp.xlat.mfn_list, start_extent, &pfn, 1) ) -+ { -+ if ( split < 0 ) -+ /* Cannot cancel the continuation... */ -+ domain_crash(current->domain); -+ return -EFAULT; -+ } -+ } -+ break; -+ -+ default: -+ domain_crash(current->domain); -+ split = 0; -+ break; -+ } -+ -+ cmd = op | (start_extent << MEMOP_EXTENT_SHIFT); -+ if ( split > 0 && hypercall_preempt_check() ) -+ return hypercall_create_continuation( -+ __HYPERVISOR_memory_op, "ih", cmd, compat); -+ } while ( split > 0 ); -+ -+ return rc; -+} -Index: 2007-01-08/xen/common/memory.c -=================================================================== ---- 2007-01-08.orig/xen/common/memory.c 2007-01-08 15:34:15.000000000 +0100 -+++ 2007-01-08/xen/common/memory.c 2007-01-08 14:53:55.000000000 +0100 -@@ -17,18 +17,12 @@ - #include - #include - #include -+#include - #include - #include - #include - #include - --/* -- * To allow safe resume of do_memory_op() after preemption, we need to know -- * at what point in the page list to resume. For this purpose I steal the -- * high-order bits of the @cmd parameter, which are otherwise unused and zero. -- */ --#define START_EXTENT_SHIFT 4 /* cmd[:4] == start_extent */ -- - struct memop_args { - /* INPUT */ - struct domain *domain; /* Domain to be affected. */ -@@ -236,7 +230,7 @@ static long translate_gpfn_list( - return -EFAULT; - - /* Is size too large for us to encode a continuation? */ -- if ( op.nr_gpfns > (ULONG_MAX >> START_EXTENT_SHIFT) ) -+ if ( op.nr_gpfns > (ULONG_MAX >> MEMOP_EXTENT_SHIFT) ) - return -EINVAL; - - if ( !guest_handle_okay(op.gpfn_list, op.nr_gpfns) || -@@ -511,20 +505,20 @@ long do_memory_op(unsigned long cmd, XEN - struct memop_args args; - domid_t domid; - -- op = cmd & ((1 << START_EXTENT_SHIFT) - 1); -+ op = cmd & MEMOP_CMD_MASK; - - switch ( op ) - { - case XENMEM_increase_reservation: - case XENMEM_decrease_reservation: - case XENMEM_populate_physmap: -- start_extent = cmd >> START_EXTENT_SHIFT; -+ start_extent = cmd >> MEMOP_EXTENT_SHIFT; - - if ( copy_from_guest(&reservation, arg, 1) ) - return start_extent; - - /* Is size too large for us to encode a continuation? */ -- if ( reservation.nr_extents > (ULONG_MAX >> START_EXTENT_SHIFT) ) -+ if ( reservation.nr_extents > (ULONG_MAX >> MEMOP_EXTENT_SHIFT) ) - return start_extent; - - if ( unlikely(start_extent > reservation.nr_extents) ) -@@ -574,7 +568,7 @@ long do_memory_op(unsigned long cmd, XEN - if ( args.preempted ) - return hypercall_create_continuation( - __HYPERVISOR_memory_op, "lh", -- op | (rc << START_EXTENT_SHIFT), arg); -+ op | (rc << MEMOP_EXTENT_SHIFT), arg); - - break; - -@@ -606,14 +600,14 @@ long do_memory_op(unsigned long cmd, XEN - break; - - case XENMEM_translate_gpfn_list: -- progress = cmd >> START_EXTENT_SHIFT; -+ progress = cmd >> MEMOP_EXTENT_SHIFT; - rc = translate_gpfn_list( - guest_handle_cast(arg, xen_translate_gpfn_list_t), - &progress); - if ( rc == -EAGAIN ) - return hypercall_create_continuation( - __HYPERVISOR_memory_op, "lh", -- op | (progress << START_EXTENT_SHIFT), arg); -+ op | (progress << MEMOP_EXTENT_SHIFT), arg); - break; - - default: -Index: 2007-01-08/xen/include/asm-x86/config.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/config.h 2007-01-08 14:53:50.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/config.h 2007-01-08 14:53:55.000000000 +0100 -@@ -112,7 +112,7 @@ extern unsigned long _end; /* standard E - /* - * Memory layout: - * 0x0000000000000000 - 0x00007fffffffffff [128TB, 2^47 bytes, PML4:0-255] -- * Guest-defined use. -+ * Guest-defined use (see below for compatibility mode guests). - * 0x0000800000000000 - 0xffff7fffffffffff [16EB] - * Inaccessible: current arch only supports 48-bit sign-extended VAs. - * 0xffff800000000000 - 0xffff803fffffffff [256GB, 2^38 bytes, PML4:256] -@@ -145,6 +145,18 @@ extern unsigned long _end; /* standard E - * Reserved for future use. - * 0xffff880000000000 - 0xffffffffffffffff [120TB, PML4:272-511] - * Guest-defined use. -+ * -+ * Compatibility guest area layout: -+ * 0x0000000000000000 - 0x00000000f57fffff [3928MB, PML4:0] -+ * Guest-defined use. -+ * 0x0000000f58000000 - 0x00000000ffffffff [168MB, PML4:0] -+ * Read-only machine-to-phys translation table (GUEST ACCESSIBLE). -+ * 0x0000000000000000 - 0x00000000ffffffff [508GB, PML4:0] -+ * Unused. -+ * 0x0000008000000000 - 0x000000ffffffffff [512GB, 2^39 bytes, PML4:1] -+ * Hypercall argument translation area. -+ * 0x0000010000000000 - 0x00007fffffffffff [127TB, 2^46 bytes, PML4:2-255] -+ * Reserved for future use. - */ - - -@@ -214,6 +226,14 @@ extern unsigned long _end; /* standard E - - #endif - -+#define COMPAT_ARG_XLAT_VIRT_BASE (1UL << ROOT_PAGETABLE_SHIFT) -+#define COMPAT_ARG_XLAT_SHIFT 0 -+#define COMPAT_ARG_XLAT_PAGES (1U << COMPAT_ARG_XLAT_SHIFT) -+#define COMPAT_ARG_XLAT_SIZE (COMPAT_ARG_XLAT_PAGES << PAGE_SHIFT) -+#define COMPAT_ARG_XLAT_VIRT_START(vcpu_id) \ -+ (COMPAT_ARG_XLAT_VIRT_BASE + ((unsigned long)(vcpu_id) << \ -+ (PAGE_SHIFT + COMPAT_ARG_XLAT_SHIFT + 1))) -+ - #define PGT_base_page_table PGT_l4_page_table - - #define __HYPERVISOR_CS64 0xe008 -Index: 2007-01-08/xen/include/asm-x86/domain.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/domain.h 2007-01-08 14:53:50.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/domain.h 2007-01-08 14:53:55.000000000 +0100 -@@ -100,6 +100,7 @@ struct arch_domain - - #ifdef CONFIG_COMPAT - unsigned int hv_compat_vstart; -+ l3_pgentry_t *mm_arg_xlat_l3; - #endif - - /* I/O-port admin-specified access capabilities. */ -Index: 2007-01-08/xen/include/asm-x86/mm.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/mm.h 2006-12-18 09:49:18.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/mm.h 2007-01-08 14:53:55.000000000 +0100 -@@ -329,10 +329,20 @@ int __sync_lazy_execstate(void); - /* Arch-specific portion of memory_op hypercall. */ - long arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg); - long subarch_memory_op(int op, XEN_GUEST_HANDLE(void) arg); -+#ifdef CONFIG_COMPAT -+int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void)); -+int compat_subarch_memory_op(int op, XEN_GUEST_HANDLE(void)); -+#endif - - int steal_page( - struct domain *d, struct page_info *page, unsigned int memflags); - - int map_ldt_shadow_page(unsigned int); - -+#ifdef CONFIG_COMPAT -+int setup_arg_xlat_area(struct vcpu *, l4_pgentry_t *); -+#else -+# define setup_arg_xlat_area(vcpu, l4tab) 0 -+#endif -+ - #endif /* __ASM_X86_MM_H__ */ -Index: 2007-01-08/xen/include/xen/hypercall.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/hypercall.h 2007-01-08 15:34:15.000000000 +0100 -+++ 2007-01-08/xen/include/xen/hypercall.h 2007-01-08 14:53:55.000000000 +0100 -@@ -42,9 +42,17 @@ extern long - do_platform_op( - XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op); - -+/* -+ * To allow safe resume of do_memory_op() after preemption, we need to know -+ * at what point in the page list to resume. For this purpose I steal the -+ * high-order bits of the @cmd parameter, which are otherwise unused and zero. -+ */ -+#define MEMOP_EXTENT_SHIFT 4 /* cmd[:4] == start_extent */ -+#define MEMOP_CMD_MASK ((1 << MEMOP_EXTENT_SHIFT) - 1) -+ - extern long - do_memory_op( -- int cmd, -+ unsigned long cmd, - XEN_GUEST_HANDLE(void) arg); - - extern long -@@ -108,4 +116,13 @@ do_kexec_op( - int arg1, - XEN_GUEST_HANDLE(void) arg); - -+#ifdef CONFIG_COMPAT -+ -+extern int -+compat_memory_op( -+ unsigned int cmd, -+ XEN_GUEST_HANDLE(void) arg); -+ -+#endif -+ - #endif /* __XEN_HYPERCALL_H__ */ -Index: 2007-01-08/xen/include/xen/compat.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/compat.h 2007-01-08 15:19:11.000000000 +0100 -+++ 2007-01-08/xen/include/xen/compat.h 2007-01-08 14:53:55.000000000 +0100 -@@ -158,6 +158,8 @@ - - extern int compat_disabled; - -+int hypercall_xlat_continuation(unsigned int *id, unsigned int mask, ...); -+ - /* In-place translation functons: */ - struct start_info; - void xlat_start_info(struct start_info *, enum XLAT_start_info_console); -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:19:11.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 14:53:55.000000000 +0100 -@@ -4,3 +4,9 @@ - ? dom0_vga_console_info xen.h - ! start_info xen.h - ? vcpu_time_info xen.h -+! add_to_physmap memory.h -+! foreign_memory_map memory.h -+! memory_exchange memory.h -+! memory_map memory.h -+! memory_reservation memory.h -+! translate_gpfn_list memory.h diff --git a/32on64-migrate.patch b/32on64-migrate.patch deleted file mode 100644 index 900b85c..0000000 --- a/32on64-migrate.patch +++ /dev/null @@ -1,793 +0,0 @@ -# HG changeset 13995 patch -# User Emmanuel Ackaouy -# Node ID 9c2e6f8f3aa7a4e2a1f3af3204789568edf975cd -# Parent 0b882c911b885a51308eee3ec80bc4a5a230d7ce -[XEN] 32on64 shadowing / live migration support for PV PAE compat guests -PAE compat guests on 64bit hypervisors are shadowed -using 4-on-4 with special handling for the top level -L4 page and the L2E M2P mappings. - -Signed-off-by: Emmanuel Ackaouy - -Index: 2007-02-20/xen/arch/x86/mm.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm.c 2007-02-20 11:01:49.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm.c 2007-02-20 11:01:50.000000000 +0100 -@@ -1095,7 +1095,7 @@ static int alloc_l4_table(struct page_in - - for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ ) - { -- if ( is_guest_l4_slot(i) && -+ if ( is_guest_l4_slot(d, i) && - unlikely(!get_page_from_l4e(pl4e[i], pfn, d)) ) - goto fail; - -@@ -1123,7 +1123,7 @@ static int alloc_l4_table(struct page_in - fail: - MEM_LOG("Failure in alloc_l4_table: entry %d", i); - while ( i-- > 0 ) -- if ( is_guest_l4_slot(i) ) -+ if ( is_guest_l4_slot(d, i) ) - put_page_from_l4e(pl4e[i], pfn); - - return 0; -@@ -1198,12 +1198,13 @@ static void free_l3_table(struct page_in - - static void free_l4_table(struct page_info *page) - { -+ struct domain *d = page_get_owner(page); - unsigned long pfn = page_to_mfn(page); - l4_pgentry_t *pl4e = page_to_virt(page); - int i; - - for ( i = 0; i < L4_PAGETABLE_ENTRIES; i++ ) -- if ( is_guest_l4_slot(i) ) -+ if ( is_guest_l4_slot(d, i) ) - put_page_from_l4e(pl4e[i], pfn); - } - -@@ -1463,13 +1464,14 @@ static int mod_l3_entry(l3_pgentry_t *pl - #if CONFIG_PAGING_LEVELS >= 4 - - /* Update the L4 entry at pl4e to new value nl4e. pl4e is within frame pfn. */ --static int mod_l4_entry(l4_pgentry_t *pl4e, -+static int mod_l4_entry(struct domain *d, -+ l4_pgentry_t *pl4e, - l4_pgentry_t nl4e, - unsigned long pfn) - { - l4_pgentry_t ol4e; - -- if ( unlikely(!is_guest_l4_slot(pgentry_ptr_to_slot(pl4e))) ) -+ if ( unlikely(!is_guest_l4_slot(d, pgentry_ptr_to_slot(pl4e))) ) - { - MEM_LOG("Illegal L4 update attempt in Xen-private area %p", pl4e); - return 0; -@@ -1771,8 +1773,10 @@ int new_guest_cr3(unsigned long mfn) - put_page(mfn_to_page(old_base_mfn)); - } - else -- okay = mod_l4_entry(__va(pagetable_get_paddr(v->arch.guest_table)), -- l4e, 0); -+ okay = mod_l4_entry(d, -+ __va(pagetable_get_paddr(v->arch.guest_table)), -+ l4e, -+ pagetable_get_pfn(v->arch.guest_table)); - if ( unlikely(!okay) ) - { - MEM_LOG("Error while installing new compat baseptr %lx", mfn); -@@ -2360,7 +2364,7 @@ int do_mmu_update( - if ( !IS_COMPAT(FOREIGNDOM) ) - { - l4_pgentry_t l4e = l4e_from_intpte(req.val); -- okay = mod_l4_entry(va, l4e, mfn); -+ okay = mod_l4_entry(d, va, l4e, mfn); - } - break; - #endif -Index: 2007-02-20/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/common.c 2007-02-20 11:01:43.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/common.c 2007-02-20 11:02:03.000000000 +0100 -@@ -472,7 +472,11 @@ void shadow_demote(struct vcpu *v, mfn_t - { - struct page_info *page = mfn_to_page(gmfn); - -- ASSERT(test_bit(_PGC_page_table, &page->count_info)); -+#ifdef CONFIG_COMPAT -+ if ( !IS_COMPAT(v->domain) || type != SH_type_l4_64_shadow ) -+#endif -+ ASSERT(test_bit(_PGC_page_table, &page->count_info)); -+ - ASSERT(test_bit(type, &page->shadow_flags)); - - clear_bit(type, &page->shadow_flags); -@@ -555,6 +559,9 @@ __shadow_validate_guest_entry(struct vcp - if ( page->shadow_flags & SHF_L2_64 ) - result |= SHADOW_INTERNAL_NAME(sh_map_and_validate_gl2e, 4, 4) - (v, gmfn, entry, size); -+ if ( page->shadow_flags & SHF_L2H_64 ) -+ result |= SHADOW_INTERNAL_NAME(sh_map_and_validate_gl2he, 4, 4) -+ (v, gmfn, entry, size); - if ( page->shadow_flags & SHF_L3_64 ) - result |= SHADOW_INTERNAL_NAME(sh_map_and_validate_gl3e, 4, 4) - (v, gmfn, entry, size); -@@ -563,7 +570,7 @@ __shadow_validate_guest_entry(struct vcp - (v, gmfn, entry, size); - #else /* 32-bit/PAE hypervisor does not support 64-bit guests */ - ASSERT((page->shadow_flags -- & (SHF_L4_64|SHF_L3_64|SHF_L2_64|SHF_L1_64)) == 0); -+ & (SHF_L4_64|SHF_L3_64|SHF_L2H_64|SHF_L2_64|SHF_L1_64)) == 0); - #endif - - return result; -@@ -674,7 +681,7 @@ static inline u32 - shadow_order(unsigned int shadow_type) - { - #if CONFIG_PAGING_LEVELS > 2 -- static const u32 type_to_order[16] = { -+ static const u32 type_to_order[SH_type_unused] = { - 0, /* SH_type_none */ - 1, /* SH_type_l1_32_shadow */ - 1, /* SH_type_fl1_32_shadow */ -@@ -686,12 +693,13 @@ shadow_order(unsigned int shadow_type) - 0, /* SH_type_l1_64_shadow */ - 0, /* SH_type_fl1_64_shadow */ - 0, /* SH_type_l2_64_shadow */ -+ 0, /* SH_type_l2h_64_shadow */ - 0, /* SH_type_l3_64_shadow */ - 0, /* SH_type_l4_64_shadow */ - 2, /* SH_type_p2m_table */ - 0 /* SH_type_monitor_table */ - }; -- ASSERT(shadow_type < 16); -+ ASSERT(shadow_type < SH_type_unused); - return type_to_order[shadow_type]; - #else /* 32-bit Xen only ever shadows 32-bit guests on 32-bit shadows. */ - return 0; -@@ -1849,6 +1857,9 @@ void sh_destroy_shadow(struct vcpu *v, m - t == SH_type_fl1_pae_shadow || - t == SH_type_fl1_64_shadow || - t == SH_type_monitor_table || -+#ifdef CONFIG_COMPAT -+ (IS_COMPAT(v->domain) && t == SH_type_l4_64_shadow) || -+#endif - (page_get_owner(mfn_to_page(_mfn(sp->backpointer))) - == v->domain)); - -@@ -1890,6 +1901,8 @@ void sh_destroy_shadow(struct vcpu *v, m - case SH_type_fl1_64_shadow: - SHADOW_INTERNAL_NAME(sh_destroy_l1_shadow, 4, 4)(v, smfn); - break; -+ case SH_type_l2h_64_shadow: -+ ASSERT( IS_COMPAT(v->domain) ); - case SH_type_l2_64_shadow: - SHADOW_INTERNAL_NAME(sh_destroy_l2_shadow, 4, 4)(v, smfn); - break; -@@ -1918,7 +1931,7 @@ int shadow_remove_write_access(struct vc - unsigned long fault_addr) - { - /* Dispatch table for getting per-type functions */ -- static hash_callback_t callbacks[16] = { -+ static hash_callback_t callbacks[SH_type_unused] = { - NULL, /* none */ - #if CONFIG_PAGING_LEVELS == 2 - SHADOW_INTERNAL_NAME(sh_remove_write_access,2,2), /* l1_32 */ -@@ -1945,6 +1958,7 @@ int shadow_remove_write_access(struct vc - NULL, /* fl1_64 */ - #endif - NULL, /* l2_64 */ -+ NULL, /* l2h_64 */ - NULL, /* l3_64 */ - NULL, /* l4_64 */ - NULL, /* p2m */ -@@ -2107,7 +2121,7 @@ int shadow_remove_all_mappings(struct vc - int expected_count; - - /* Dispatch table for getting per-type functions */ -- static hash_callback_t callbacks[16] = { -+ static hash_callback_t callbacks[SH_type_unused] = { - NULL, /* none */ - #if CONFIG_PAGING_LEVELS == 2 - SHADOW_INTERNAL_NAME(sh_remove_all_mappings,2,2), /* l1_32 */ -@@ -2134,6 +2148,7 @@ int shadow_remove_all_mappings(struct vc - NULL, /* fl1_64 */ - #endif - NULL, /* l2_64 */ -+ NULL, /* l2h_64 */ - NULL, /* l3_64 */ - NULL, /* l4_64 */ - NULL, /* p2m */ -@@ -2233,6 +2248,7 @@ static int sh_remove_shadow_via_pointer( - #if CONFIG_PAGING_LEVELS >= 4 - case SH_type_l1_64_shadow: - case SH_type_l2_64_shadow: -+ case SH_type_l2h_64_shadow: - case SH_type_l3_64_shadow: - case SH_type_l4_64_shadow: - SHADOW_INTERNAL_NAME(sh_clear_shadow_entry,4,4)(v, vaddr, pmfn); -@@ -2267,7 +2283,7 @@ void sh_remove_shadows(struct vcpu *v, m - - /* Dispatch table for getting per-type functions: each level must - * be called with the function to remove a lower-level shadow. */ -- static hash_callback_t callbacks[16] = { -+ static hash_callback_t callbacks[SH_type_unused] = { - NULL, /* none */ - NULL, /* l1_32 */ - NULL, /* fl1_32 */ -@@ -2289,10 +2305,12 @@ void sh_remove_shadows(struct vcpu *v, m - NULL, /* fl1_64 */ - #if CONFIG_PAGING_LEVELS >= 4 - SHADOW_INTERNAL_NAME(sh_remove_l1_shadow,4,4), /* l2_64 */ -+ SHADOW_INTERNAL_NAME(sh_remove_l1_shadow,4,4), /* l2h_64 */ - SHADOW_INTERNAL_NAME(sh_remove_l2_shadow,4,4), /* l3_64 */ - SHADOW_INTERNAL_NAME(sh_remove_l3_shadow,4,4), /* l4_64 */ - #else - NULL, /* l2_64 */ -+ NULL, /* l2h_64 */ - NULL, /* l3_64 */ - NULL, /* l4_64 */ - #endif -@@ -2301,7 +2319,7 @@ void sh_remove_shadows(struct vcpu *v, m - }; - - /* Another lookup table, for choosing which mask to use */ -- static unsigned int masks[16] = { -+ static unsigned int masks[SH_type_unused] = { - 0, /* none */ - 1 << SH_type_l2_32_shadow, /* l1_32 */ - 0, /* fl1_32 */ -@@ -2311,9 +2329,11 @@ void sh_remove_shadows(struct vcpu *v, m - 0, /* fl1_pae */ - 0, /* l2_pae */ - 0, /* l2h_pae */ -- 1 << SH_type_l2_64_shadow, /* l1_64 */ -+ ((1 << SH_type_l2h_64_shadow) -+ | (1 << SH_type_l2_64_shadow)), /* l1_64 */ - 0, /* fl1_64 */ - 1 << SH_type_l3_64_shadow, /* l2_64 */ -+ 1 << SH_type_l3_64_shadow, /* l2h_64 */ - 1 << SH_type_l4_64_shadow, /* l3_64 */ - 0, /* l4_64 */ - 0, /* p2m */ -@@ -2360,6 +2380,7 @@ void sh_remove_shadows(struct vcpu *v, m - #if CONFIG_PAGING_LEVELS >= 4 - if ( sh_flags & SHF_L1_64 ) DO_UNSHADOW(SH_type_l1_64_shadow); - if ( sh_flags & SHF_L2_64 ) DO_UNSHADOW(SH_type_l2_64_shadow); -+ if ( sh_flags & SHF_L2H_64 ) DO_UNSHADOW(SH_type_l2h_64_shadow); - if ( sh_flags & SHF_L3_64 ) DO_UNSHADOW(SH_type_l3_64_shadow); - if ( sh_flags & SHF_L4_64 ) DO_UNSHADOW(SH_type_l4_64_shadow); - #endif -@@ -2426,10 +2447,7 @@ void sh_update_paging_modes(struct vcpu - /// PV guest - /// - #if CONFIG_PAGING_LEVELS == 4 -- if ( pv_32bit_guest(v) ) -- v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,3,3); -- else -- v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,4,4); -+ v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,4,4); - #elif CONFIG_PAGING_LEVELS == 3 - v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,3,3); - #elif CONFIG_PAGING_LEVELS == 2 -@@ -2938,6 +2956,11 @@ static int shadow_log_dirty_enable(struc - goto out; - } - -+#if (SHADOW_OPTIMIZATIONS & SHOPT_LINUX_L3_TOPLEVEL) -+ if ( IS_COMPAT(d) ) -+ d->arch.shadow.opt_flags = SHOPT_LINUX_L3_TOPLEVEL; -+#endif -+ - ret = sh_alloc_log_dirty_bitmap(d); - if ( ret != 0 ) - { -@@ -3290,7 +3313,7 @@ int shadow_domctl(struct domain *d, - void shadow_audit_tables(struct vcpu *v) - { - /* Dispatch table for getting per-type functions */ -- static hash_callback_t callbacks[16] = { -+ static hash_callback_t callbacks[SH_type_unused] = { - NULL, /* none */ - #if CONFIG_PAGING_LEVELS == 2 - SHADOW_INTERNAL_NAME(sh_audit_l1_table,2,2), /* l1_32 */ -@@ -3308,6 +3331,7 @@ void shadow_audit_tables(struct vcpu *v) - SHADOW_INTERNAL_NAME(sh_audit_l1_table,4,4), /* l1_64 */ - SHADOW_INTERNAL_NAME(sh_audit_fl1_table,4,4), /* fl1_64 */ - SHADOW_INTERNAL_NAME(sh_audit_l2_table,4,4), /* l2_64 */ -+ SHADOW_INTERNAL_NAME(sh_audit_l2_table,4,4), /* l2h_64 */ - SHADOW_INTERNAL_NAME(sh_audit_l3_table,4,4), /* l3_64 */ - SHADOW_INTERNAL_NAME(sh_audit_l4_table,4,4), /* l4_64 */ - #endif /* CONFIG_PAGING_LEVELS >= 4 */ -@@ -3330,7 +3354,7 @@ void shadow_audit_tables(struct vcpu *v) - case 3: mask = (SHF_L1_PAE|SHF_FL1_PAE|SHF_L2_PAE - |SHF_L2H_PAE); break; - case 4: mask = (SHF_L1_64|SHF_FL1_64|SHF_L2_64 -- |SHF_L3_64|SHF_L4_64); break; -+ |SHF_L2H_64|SHF_L3_64|SHF_L4_64); break; - default: BUG(); - } - } -Index: 2007-02-20/xen/arch/x86/mm/shadow/multi.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/multi.c 2007-02-20 11:01:43.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/multi.c 2007-02-20 11:01:50.000000000 +0100 -@@ -162,8 +162,13 @@ set_shadow_status(struct vcpu *v, mfn_t - else - mfn_to_shadow_page(smfn)->logdirty = 0; - -- res = get_page(mfn_to_page(gmfn), d); -- ASSERT(res == 1); -+#ifdef CONFIG_COMPAT -+ if ( !IS_COMPAT(d) || shadow_type != SH_type_l4_64_shadow ) -+#endif -+ { -+ res = get_page(mfn_to_page(gmfn), d); -+ ASSERT(res == 1); -+ } - - shadow_hash_insert(v, mfn_x(gmfn), shadow_type, smfn); - } -@@ -185,7 +190,10 @@ delete_shadow_status(struct vcpu *v, mfn - v->domain->domain_id, v->vcpu_id, - mfn_x(gmfn), shadow_type, mfn_x(smfn)); - shadow_hash_delete(v, mfn_x(gmfn), shadow_type, smfn); -- put_page(mfn_to_page(gmfn)); -+#ifdef CONFIG_COMPAT -+ if ( !IS_COMPAT(v->domain) || shadow_type != SH_type_l4_64_shadow ) -+#endif -+ put_page(mfn_to_page(gmfn)); - } - - /**************************************************************************/ -@@ -764,7 +772,7 @@ _sh_propagate(struct vcpu *v, - // PV guests in 64-bit mode use two different page tables for user vs - // supervisor permissions, making the guest's _PAGE_USER bit irrelevant. - // It is always shadowed as present... -- if ( (GUEST_PAGING_LEVELS == 4) && !is_hvm_domain(d) ) -+ if ( (GUEST_PAGING_LEVELS == 4) && !IS_COMPAT(d) && !is_hvm_domain(d) ) - { - sflags |= _PAGE_USER; - } -@@ -1235,9 +1243,10 @@ do { - #if GUEST_PAGING_LEVELS == 2 && SHADOW_PAGING_LEVELS > 2 - - /* 32-bit l2 on PAE/64: four pages, touch every second entry, and avoid Xen */ --#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _xen, _code) \ -+#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ - do { \ - int _i, _j, __done = 0; \ -+ int _xen = !shadow_mode_external(_dom); \ - ASSERT(mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2_32_shadow); \ - for ( _j = 0; _j < 4 && !__done; _j++ ) \ - { \ -@@ -1261,9 +1270,10 @@ do { - #elif GUEST_PAGING_LEVELS == 2 - - /* 32-bit on 32-bit: avoid Xen entries */ --#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _xen, _code) \ -+#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ - do { \ - int _i; \ -+ int _xen = !shadow_mode_external(_dom); \ - shadow_l2e_t *_sp = map_shadow_page((_sl2mfn)); \ - ASSERT(mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2_32_shadow); \ - for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ ) \ -@@ -1283,9 +1293,10 @@ do { - #elif GUEST_PAGING_LEVELS == 3 - - /* PAE: if it's an l2h, don't touch Xen mappings */ --#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _xen, _code) \ -+#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ - do { \ - int _i; \ -+ int _xen = !shadow_mode_external(_dom); \ - shadow_l2e_t *_sp = map_shadow_page((_sl2mfn)); \ - ASSERT(mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2_pae_shadow \ - || mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2h_pae_shadow);\ -@@ -1306,21 +1317,29 @@ do { - - #else - --/* 64-bit l2: touch all entries */ --#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _xen, _code) \ --do { \ -- int _i; \ -- shadow_l2e_t *_sp = map_shadow_page((_sl2mfn)); \ -- ASSERT(mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2_64_shadow); \ -- for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ ) \ -- { \ -- (_sl2e) = _sp + _i; \ -- if ( shadow_l2e_get_flags(*(_sl2e)) & _PAGE_PRESENT ) \ -- {_code} \ -- if ( _done ) break; \ -- increment_ptr_to_guest_entry(_gl2p); \ -- } \ -- unmap_shadow_page(_sp); \ -+/* 64-bit l2: touch all entries except for PAE compat guests. */ -+#define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code) \ -+do { \ -+ int _i; \ -+ int _xen = !shadow_mode_external(_dom); \ -+ shadow_l2e_t *_sp = map_shadow_page((_sl2mfn)); \ -+ ASSERT(mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2_64_shadow || \ -+ mfn_to_shadow_page(_sl2mfn)->type == SH_type_l2h_64_shadow); \ -+ for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ ) \ -+ { \ -+ if ( (!(_xen)) \ -+ || !IS_COMPAT(_dom) \ -+ || mfn_to_shadow_page(_sl2mfn)->type != SH_type_l2h_64_shadow \ -+ || (_i < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_dom)) ) \ -+ { \ -+ (_sl2e) = _sp + _i; \ -+ if ( shadow_l2e_get_flags(*(_sl2e)) & _PAGE_PRESENT ) \ -+ {_code} \ -+ if ( _done ) break; \ -+ increment_ptr_to_guest_entry(_gl2p); \ -+ } \ -+ } \ -+ unmap_shadow_page(_sp); \ - } while (0) - - #endif /* different kinds of l2 */ -@@ -1345,14 +1364,15 @@ do { - } while (0) - - /* 64-bit l4: avoid Xen mappings */ --#define SHADOW_FOREACH_L4E(_sl4mfn, _sl4e, _gl4p, _done, _xen, _code) \ -+#define SHADOW_FOREACH_L4E(_sl4mfn, _sl4e, _gl4p, _done, _dom, _code) \ - do { \ -- int _i; \ - shadow_l4e_t *_sp = map_shadow_page((_sl4mfn)); \ -+ int _xen = !shadow_mode_external(_dom); \ -+ int _i; \ - ASSERT(mfn_to_shadow_page(_sl4mfn)->type == SH_type_l4_64_shadow); \ - for ( _i = 0; _i < SHADOW_L4_PAGETABLE_ENTRIES; _i++ ) \ - { \ -- if ( (!(_xen)) || is_guest_l4_slot(_i) ) \ -+ if ( (!(_xen)) || is_guest_l4_slot(_dom, _i) ) \ - { \ - (_sl4e) = _sp + _i; \ - if ( shadow_l4e_get_flags(*(_sl4e)) & _PAGE_PRESENT ) \ -@@ -1419,17 +1439,25 @@ void sh_install_xen_entries_in_l4(struct - __PAGE_HYPERVISOR); - } - -+ if ( IS_COMPAT(v->domain) ) -+ { -+ /* install compat arg xlat entry */ -+ sl4e[shadow_l4_table_offset(COMPAT_ARG_XLAT_VIRT_BASE)] = -+ shadow_l4e_from_mfn( -+ page_to_mfn(virt_to_page(d->arch.mm_arg_xlat_l3)), -+ __PAGE_HYPERVISOR); -+ } -+ - sh_unmap_domain_page(sl4e); - } - #endif - --#if (CONFIG_PAGING_LEVELS == 3 || defined(CONFIG_COMPAT)) && GUEST_PAGING_LEVELS == 3 -+#if CONFIG_PAGING_LEVELS >= 3 && GUEST_PAGING_LEVELS >= 3 - // For 3-on-3 PV guests, we need to make sure the xen mappings are in - // place, which means that we need to populate the l2h entry in the l3 - // table. - --void sh_install_xen_entries_in_l2h(struct vcpu *v, -- mfn_t sl2hmfn) -+static void sh_install_xen_entries_in_l2h(struct vcpu *v, mfn_t sl2hmfn) - { - struct domain *d = v->domain; - shadow_l2e_t *sl2e; -@@ -1491,9 +1519,10 @@ void sh_install_xen_entries_in_l2h(struc - #else - - /* Copy the common Xen mappings from the idle domain */ -- memcpy(&sl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], -- &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -- COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*sl2e)); -+ memcpy( -+ &sl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], -+ &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -+ COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*sl2e)); - - #endif - -@@ -1619,8 +1648,11 @@ sh_make_shadow(struct vcpu *v, mfn_t gmf - case SH_type_l4_shadow: - sh_install_xen_entries_in_l4(v, gmfn, smfn); break; - #endif --#if CONFIG_PAGING_LEVELS == 3 && GUEST_PAGING_LEVELS == 3 -+#if CONFIG_PAGING_LEVELS >= 3 && GUEST_PAGING_LEVELS >= 3 - case SH_type_l2h_shadow: -+#ifdef CONFIG_COMPAT -+ ASSERT( IS_COMPAT(v->domain) ); -+#endif - sh_install_xen_entries_in_l2h(v, smfn); break; - #endif - #if CONFIG_PAGING_LEVELS == 2 && GUEST_PAGING_LEVELS == 2 -@@ -1834,12 +1866,21 @@ static shadow_l2e_t * shadow_get_and_cre - { - int r; - shadow_l3e_t new_sl3e; -+ unsigned int t = SH_type_l2_shadow; -+ -+#ifdef CONFIG_COMPAT -+ /* Tag compat L2 containing hypervisor (m2p) mappings */ -+ if ( IS_COMPAT(v->domain) && -+ guest_l4_table_offset(gw->va) == 0 && -+ guest_l3_table_offset(gw->va) == 3 ) -+ t = SH_type_l2h_shadow; -+#endif - /* No l2 shadow installed: find and install it. */ -- *sl2mfn = get_shadow_status(v, gw->l2mfn, SH_type_l2_shadow); -+ *sl2mfn = get_shadow_status(v, gw->l2mfn, t); - if ( !mfn_valid(*sl2mfn) ) - { - /* No l2 shadow of this page exists at all: make one. */ -- *sl2mfn = sh_make_shadow(v, gw->l2mfn, SH_type_l2_shadow); -+ *sl2mfn = sh_make_shadow(v, gw->l2mfn, t); - } - /* Install the new sl2 table in the sl3e */ - l3e_propagate_from_guest(v, gw->l3e, gw->l3mfn, -@@ -1960,7 +2001,6 @@ void sh_destroy_l4_shadow(struct vcpu *v - shadow_l4e_t *sl4e; - u32 t = mfn_to_shadow_page(smfn)->type; - mfn_t gmfn, sl4mfn; -- int xen_mappings; - - SHADOW_DEBUG(DESTROY_SHADOW, - "%s(%05lx)\n", __func__, mfn_x(smfn)); -@@ -1971,9 +2011,8 @@ void sh_destroy_l4_shadow(struct vcpu *v - delete_shadow_status(v, gmfn, t, smfn); - shadow_demote(v, gmfn, t); - /* Decrement refcounts of all the old entries */ -- xen_mappings = (!shadow_mode_external(v->domain)); - sl4mfn = smfn; -- SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, xen_mappings, { -+ SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, v->domain, { - if ( shadow_l4e_get_flags(*sl4e) & _PAGE_PRESENT ) - { - sh_put_ref(v, shadow_l4e_get_mfn(*sl4e), -@@ -2021,12 +2060,15 @@ void sh_destroy_l2_shadow(struct vcpu *v - shadow_l2e_t *sl2e; - u32 t = mfn_to_shadow_page(smfn)->type; - mfn_t gmfn, sl2mfn; -- int xen_mappings; - - SHADOW_DEBUG(DESTROY_SHADOW, - "%s(%05lx)\n", __func__, mfn_x(smfn)); -- ASSERT(t == SH_type_l2_shadow -- || t == SH_type_l2h_pae_shadow); -+ -+#if GUEST_PAGING_LEVELS >= 3 -+ ASSERT(t == SH_type_l2_shadow || t == SH_type_l2h_shadow); -+#else -+ ASSERT(t == SH_type_l2_shadow); -+#endif - - /* Record that the guest page isn't shadowed any more (in this type) */ - gmfn = _mfn(mfn_to_shadow_page(smfn)->backpointer); -@@ -2035,11 +2077,7 @@ void sh_destroy_l2_shadow(struct vcpu *v - - /* Decrement refcounts of all the old entries */ - sl2mfn = smfn; -- xen_mappings = (!shadow_mode_external(v->domain) && -- ((GUEST_PAGING_LEVELS == 2) || -- ((GUEST_PAGING_LEVELS == 3) && -- (t == SH_type_l2h_pae_shadow)))); -- SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, xen_mappings, { -+ SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, v->domain, { - if ( shadow_l2e_get_flags(*sl2e) & _PAGE_PRESENT ) - sh_put_ref(v, shadow_l2e_get_mfn(*sl2e), - (((paddr_t)mfn_x(sl2mfn)) << PAGE_SHIFT) -@@ -2140,8 +2178,7 @@ void sh_destroy_monitor_table(struct vcp - void sh_unhook_32b_mappings(struct vcpu *v, mfn_t sl2mfn) - { - shadow_l2e_t *sl2e; -- int xen_mappings = !shadow_mode_external(v->domain); -- SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, xen_mappings, { -+ SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, v->domain, { - (void) shadow_set_l2e(v, sl2e, shadow_l2e_empty(), sl2mfn); - }); - } -@@ -2152,8 +2189,7 @@ void sh_unhook_pae_mappings(struct vcpu - /* Walk a PAE l2 shadow, unhooking entries from all the subshadows */ - { - shadow_l2e_t *sl2e; -- int xen_mappings = !shadow_mode_external(v->domain); -- SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, xen_mappings, { -+ SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, 0, v->domain, { - (void) shadow_set_l2e(v, sl2e, shadow_l2e_empty(), sl2mfn); - }); - } -@@ -2163,8 +2199,7 @@ void sh_unhook_pae_mappings(struct vcpu - void sh_unhook_64b_mappings(struct vcpu *v, mfn_t sl4mfn) - { - shadow_l4e_t *sl4e; -- int xen_mappings = !shadow_mode_external(v->domain); -- SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, xen_mappings, { -+ SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, 0, v->domain, { - (void) shadow_set_l4e(v, sl4e, shadow_l4e_empty(), sl4mfn); - }); - } -@@ -2210,7 +2245,7 @@ static int validate_gl4e(struct vcpu *v, - { - int shadow_index = (((unsigned long)sl4p & ~PAGE_MASK) / - sizeof(shadow_l4e_t)); -- int reserved_xen_slot = !is_guest_l4_slot(shadow_index); -+ int reserved_xen_slot = !is_guest_l4_slot(v->domain, shadow_index); - - if ( unlikely(reserved_xen_slot) ) - { -@@ -2473,7 +2508,7 @@ int - sh_map_and_validate_gl2he(struct vcpu *v, mfn_t gl2mfn, - void *new_gl2p, u32 size) - { --#if GUEST_PAGING_LEVELS == 3 -+#if GUEST_PAGING_LEVELS >= 3 - return sh_map_and_validate(v, gl2mfn, new_gl2p, size, - SH_type_l2h_shadow, - shadow_l2_index, -@@ -3350,7 +3385,12 @@ sh_set_toplevel_shadow(struct vcpu *v, - - #if SHADOW_OPTIMIZATIONS & SHOPT_EARLY_UNSHADOW - /* Once again OK to unhook entries from this table if we see fork/exit */ -- ASSERT(sh_mfn_is_a_page_table(gmfn)); -+#if CONFIG_PAGING_LEVELS == 4 -+ if ( IS_COMPAT(d) ) -+ ASSERT(!sh_mfn_is_a_page_table(gmfn)); -+ else -+#endif -+ ASSERT(sh_mfn_is_a_page_table(gmfn)); - mfn_to_page(gmfn)->shadow_flags &= ~SHF_unhooked_mappings; - #endif - -@@ -3746,7 +3786,7 @@ void sh_clear_shadow_entry(struct vcpu * - case SH_type_l1_shadow: - (void) shadow_set_l1e(v, ep, shadow_l1e_empty(), smfn); break; - case SH_type_l2_shadow: --#if GUEST_PAGING_LEVELS == 3 -+#if GUEST_PAGING_LEVELS >= 3 - case SH_type_l2h_shadow: - #endif - (void) shadow_set_l2e(v, ep, shadow_l2e_empty(), smfn); break; -@@ -3766,11 +3806,8 @@ int sh_remove_l1_shadow(struct vcpu *v, - shadow_l2e_t *sl2e; - int done = 0; - int flags; --#if GUEST_PAGING_LEVELS != 4 -- int xen_mappings = !shadow_mode_external(v->domain); --#endif - -- SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, done, xen_mappings, -+ SHADOW_FOREACH_L2E(sl2mfn, sl2e, 0, done, v->domain, - { - flags = shadow_l2e_get_flags(*sl2e); - if ( (flags & _PAGE_PRESENT) -@@ -3813,9 +3850,9 @@ int sh_remove_l3_shadow(struct vcpu *v, - { - shadow_l4e_t *sl4e; - int done = 0; -- int flags, xen_mappings = !shadow_mode_external(v->domain); -+ int flags; - -- SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, done, xen_mappings, -+ SHADOW_FOREACH_L4E(sl4mfn, sl4e, 0, done, v->domain, - { - flags = shadow_l4e_get_flags(*sl4e); - if ( (flags & _PAGE_PRESENT) -@@ -4153,14 +4190,11 @@ int sh_audit_l2_table(struct vcpu *v, mf - gfn_t gfn; - char *s; - int done = 0; --#if GUEST_PAGING_LEVELS != 4 -- int xen_mappings = !shadow_mode_external(v->domain); --#endif - - /* Follow the backpointer */ - gl2mfn = _mfn(mfn_to_shadow_page(sl2mfn)->backpointer); - gl2e = gp = sh_map_domain_page(gl2mfn); -- SHADOW_FOREACH_L2E(sl2mfn, sl2e, &gl2e, done, xen_mappings, { -+ SHADOW_FOREACH_L2E(sl2mfn, sl2e, &gl2e, done, v->domain, { - - s = sh_audit_flags(v, 2, guest_l2e_get_flags(*gl2e), - shadow_l2e_get_flags(*sl2e)); -@@ -4212,10 +4246,11 @@ int sh_audit_l3_table(struct vcpu *v, mf - gfn = guest_l3e_get_gfn(*gl3e); - mfn = shadow_l3e_get_mfn(*sl3e); - gmfn = get_shadow_status(v, audit_gfn_to_mfn(v, gfn, gl3mfn), -- (GUEST_PAGING_LEVELS == 3 -+ ((GUEST_PAGING_LEVELS == 3 || -+ IS_COMPAT(v->domain)) - && !shadow_mode_external(v->domain) - && (guest_index(gl3e) % 4) == 3) -- ? SH_type_l2h_pae_shadow -+ ? SH_type_l2h_shadow - : SH_type_l2_shadow); - if ( mfn_x(gmfn) != mfn_x(mfn) ) - AUDIT_FAIL(3, "bad translation: gfn %" SH_PRI_gfn -@@ -4235,12 +4270,11 @@ int sh_audit_l4_table(struct vcpu *v, mf - gfn_t gfn; - char *s; - int done = 0; -- int xen_mappings = !shadow_mode_external(v->domain); - - /* Follow the backpointer */ - gl4mfn = _mfn(mfn_to_shadow_page(sl4mfn)->backpointer); - gl4e = gp = sh_map_domain_page(gl4mfn); -- SHADOW_FOREACH_L4E(sl4mfn, sl4e, &gl4e, done, xen_mappings, -+ SHADOW_FOREACH_L4E(sl4mfn, sl4e, &gl4e, done, v->domain, - { - s = sh_audit_flags(v, 4, guest_l4e_get_flags(*gl4e), - shadow_l4e_get_flags(*sl4e)); -Index: 2007-02-20/xen/arch/x86/mm/shadow/private.h -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/private.h 2007-02-20 11:01:43.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/private.h 2007-02-20 11:01:50.000000000 +0100 -@@ -190,12 +190,13 @@ static inline void shadow_check_page_str - #define SH_type_l1_64_shadow (8U) /* shadowing a 64-bit L1 page */ - #define SH_type_fl1_64_shadow (9U) /* L1 shadow for 64-bit 2M superpg */ - #define SH_type_l2_64_shadow (10U) /* shadowing a 64-bit L2 page */ --#define SH_type_l3_64_shadow (11U) /* shadowing a 64-bit L3 page */ --#define SH_type_l4_64_shadow (12U) /* shadowing a 64-bit L4 page */ --#define SH_type_max_shadow (12U) --#define SH_type_p2m_table (13U) /* in use as the p2m table */ --#define SH_type_monitor_table (14U) /* in use as a monitor table */ --#define SH_type_unused (15U) -+#define SH_type_l2h_64_shadow (11U) /* shadowing a compat PAE L2 high page */ -+#define SH_type_l3_64_shadow (12U) /* shadowing a 64-bit L3 page */ -+#define SH_type_l4_64_shadow (13U) /* shadowing a 64-bit L4 page */ -+#define SH_type_max_shadow (13U) -+#define SH_type_p2m_table (14U) /* in use as the p2m table */ -+#define SH_type_monitor_table (15U) /* in use as a monitor table */ -+#define SH_type_unused (16U) - - /* - * What counts as a pinnable shadow? -@@ -246,6 +247,7 @@ static inline int sh_type_is_pinnable(st - #define SHF_L1_64 (1u << SH_type_l1_64_shadow) - #define SHF_FL1_64 (1u << SH_type_fl1_64_shadow) - #define SHF_L2_64 (1u << SH_type_l2_64_shadow) -+#define SHF_L2H_64 (1u << SH_type_l2h_64_shadow) - #define SHF_L3_64 (1u << SH_type_l3_64_shadow) - #define SHF_L4_64 (1u << SH_type_l4_64_shadow) - -@@ -284,7 +286,6 @@ void shadow_unhook_mappings(struct vcpu - - /* Install the xen mappings in various flavours of shadow */ - void sh_install_xen_entries_in_l4(struct vcpu *v, mfn_t gl4mfn, mfn_t sl4mfn); --void sh_install_xen_entries_in_l2h(struct vcpu *v, mfn_t sl2hmfn); - void sh_install_xen_entries_in_l2(struct vcpu *v, mfn_t gl2mfn, mfn_t sl2mfn); - - -Index: 2007-02-20/xen/arch/x86/mm/shadow/types.h -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/types.h 2007-02-20 11:01:43.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/types.h 2007-02-20 11:01:50.000000000 +0100 -@@ -389,6 +389,7 @@ static inline guest_l4e_t guest_l4e_from - #define SH_type_l1_shadow SH_type_l1_64_shadow - #define SH_type_fl1_shadow SH_type_fl1_64_shadow - #define SH_type_l2_shadow SH_type_l2_64_shadow -+#define SH_type_l2h_shadow SH_type_l2h_64_shadow - #define SH_type_l3_shadow SH_type_l3_64_shadow - #define SH_type_l4_shadow SH_type_l4_64_shadow - #endif -Index: 2007-02-20/xen/include/asm-x86/x86_64/page.h -=================================================================== ---- 2007-02-20.orig/xen/include/asm-x86/x86_64/page.h 2007-02-20 11:01:43.000000000 +0100 -+++ 2007-02-20/xen/include/asm-x86/x86_64/page.h 2007-02-20 11:01:50.000000000 +0100 -@@ -59,9 +59,11 @@ typedef l4_pgentry_t root_pgentry_t; - !((_t) & PGT_pae_xen_l2) || \ - ((_s) < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_d)) ) - #define is_guest_l3_slot(_s) (1) --#define is_guest_l4_slot(_s) \ -- (((_s) < ROOT_PAGETABLE_FIRST_XEN_SLOT) || \ -- ((_s) > ROOT_PAGETABLE_LAST_XEN_SLOT)) -+#define is_guest_l4_slot(_d, _s) \ -+ ( IS_COMPAT(_d) \ -+ ? ((_s) == 0) \ -+ : (((_s) < ROOT_PAGETABLE_FIRST_XEN_SLOT) || \ -+ ((_s) > ROOT_PAGETABLE_LAST_XEN_SLOT))) - - #define root_get_pfn l4e_get_pfn - #define root_get_flags l4e_get_flags diff --git a/32on64-mmuop.patch b/32on64-mmuop.patch deleted file mode 100644 index 81d42a7..0000000 --- a/32on64-mmuop.patch +++ /dev/null @@ -1,292 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_mmu_update and -HYPERVISOR_mmuext_op. - -Index: 2006-12-18/xen/arch/x86/mm.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/mm.c 2006-12-18 09:49:30.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/mm.c 2006-12-18 09:49:35.000000000 +0100 -@@ -106,6 +106,7 @@ - #include - #include - #include -+#include - #include - - #define MEM_LOG(_f, _a...) gdprintk(XENLOG_WARNING , _f "\n" , ## _a) -@@ -119,13 +120,6 @@ - #define PTE_UPDATE_WITH_CMPXCHG - #endif - --/* -- * Both do_mmuext_op() and do_mmu_update(): -- * We steal the m.s.b. of the @count parameter to indicate whether this -- * invocation of do_mmu_update() is resuming a previously preempted call. -- */ --#define MMU_UPDATE_PREEMPTED (~(~0U>>1)) -- - /* Used to defer flushing of memory structures. */ - struct percpu_mm_info { - #define DOP_FLUSH_TLB (1<<0) /* Flush the local TLB. */ -@@ -2027,6 +2021,8 @@ int do_mmuext_op( - goto pin_page; - - case MMUEXT_PIN_L4_TABLE: -+ if ( IS_COMPAT(FOREIGNDOM) ) -+ break; - type = PGT_l4_page_table; - - pin_page: -@@ -2090,7 +2086,11 @@ int do_mmuext_op( - - #ifdef __x86_64__ - case MMUEXT_NEW_USER_BASEPTR: -- okay = 1; -+ if ( IS_COMPAT(FOREIGNDOM) ) -+ { -+ okay = 0; -+ break; -+ } - if (likely(mfn != 0)) - { - if ( shadow_mode_refcounts(d) ) -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:49:30.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:49:35.000000000 +0100 -@@ -279,7 +279,6 @@ CFIX14: - .section .rodata, "a", @progbits - - #define compat_set_trap_table domain_crash_synchronous --#define compat_mmu_update domain_crash_synchronous - #define compat_set_gdt domain_crash_synchronous - #define compat_platform_op domain_crash_synchronous - #define compat_multicall domain_crash_synchronous -@@ -288,7 +287,6 @@ CFIX14: - #define compat_physdev_op_compat domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous - #define compat_vcpu_op domain_crash_synchronous --#define compat_mmuext_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous - #define compat_arch_sched_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous -@@ -299,7 +297,7 @@ CFIX14: - - ENTRY(compat_hypercall_table) - .quad compat_set_trap_table /* 0 */ -- .quad compat_mmu_update -+ .quad do_mmu_update - .quad compat_set_gdt - .quad do_stack_switch - .quad compat_set_callbacks -Index: 2006-12-18/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/mm.c 2006-12-18 09:49:30.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/mm.c 2006-12-18 09:49:35.000000000 +0100 -@@ -1,6 +1,8 @@ - #ifdef CONFIG_COMPAT - -+#include - #include -+#include - - int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi) - { -@@ -135,6 +137,152 @@ int compat_update_va_mapping_otherdomain - { - return do_update_va_mapping_otherdomain(va, lo | ((u64)hi << 32), flags, domid); - } -+ -+DEFINE_XEN_GUEST_HANDLE(mmuext_op_compat_t); -+ -+int compat_mmuext_op(XEN_GUEST_HANDLE(mmuext_op_compat_t) cmp_uops, -+ unsigned int count, -+ XEN_GUEST_HANDLE(uint) pdone, -+ unsigned int foreigndom) -+{ -+ unsigned int i, preempt_mask; -+ int rc = 0; -+ XEN_GUEST_HANDLE(mmuext_op_t) nat_ops; -+ -+ preempt_mask = count & MMU_UPDATE_PREEMPTED; -+ count ^= preempt_mask; -+ -+ if ( unlikely(!guest_handle_okay(cmp_uops, count)) ) -+ return -EFAULT; -+ -+ set_xen_guest_handle(nat_ops, (void *)COMPAT_ARG_XLAT_VIRT_START(current->vcpu_id)); -+ -+ for ( ; count; count -= i ) -+ { -+ mmuext_op_t *nat_op = nat_ops.p; -+ unsigned int limit; -+ int err; -+ -+ if ( hypercall_preempt_check() ) -+ { -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_mmuext_op, "hihi", -+ cmp_uops, count | MMU_UPDATE_PREEMPTED, pdone, foreigndom); -+ break; -+ } -+ -+ limit = COMPAT_ARG_XLAT_SIZE / sizeof(*nat_op); -+ -+ for ( i = 0; i < min(limit, count); ++i ) -+ { -+ mmuext_op_compat_t cmp_op; -+ enum XLAT_mmuext_op_arg1 arg1; -+ enum XLAT_mmuext_op_arg2 arg2; -+ -+ if ( unlikely(__copy_from_guest(&cmp_op, cmp_uops, 1) != 0) ) -+ { -+ rc = -EFAULT; -+ break; -+ } -+ -+ switch ( cmp_op.cmd ) -+ { -+ case MMUEXT_PIN_L1_TABLE: -+ case MMUEXT_PIN_L2_TABLE: -+ case MMUEXT_PIN_L3_TABLE: -+ case MMUEXT_PIN_L4_TABLE: -+ case MMUEXT_UNPIN_TABLE: -+ case MMUEXT_NEW_BASEPTR: -+ arg1 = XLAT_mmuext_op_arg1_mfn; -+ break; -+ default: -+ arg1 = XLAT_mmuext_op_arg1_linear_addr; -+ break; -+ case MMUEXT_NEW_USER_BASEPTR: -+ rc = -EINVAL; -+ case MMUEXT_TLB_FLUSH_LOCAL: -+ case MMUEXT_TLB_FLUSH_MULTI: -+ case MMUEXT_TLB_FLUSH_ALL: -+ case MMUEXT_FLUSH_CACHE: -+ arg1 = -1; -+ break; -+ } -+ -+ if ( rc ) -+ break; -+ -+ switch ( cmp_op.cmd ) -+ { -+ case MMUEXT_SET_LDT: -+ arg2 = XLAT_mmuext_op_arg2_nr_ents; -+ break; -+ case MMUEXT_TLB_FLUSH_MULTI: -+ case MMUEXT_INVLPG_MULTI: -+ arg2 = XLAT_mmuext_op_arg2_vcpumask; -+ break; -+ default: -+ arg2 = -1; -+ break; -+ } -+ -+#define XLAT_mmuext_op_HNDL_arg2_vcpumask(_d_, _s_) \ -+ do \ -+ { \ -+ unsigned int vcpumask; \ -+ if ( i < --limit ) \ -+ { \ -+ (_d_)->arg2.vcpumask.p = (void *)(nat_ops.p + limit); \ -+ if ( copy_from_compat(&vcpumask, (_s_)->arg2.vcpumask, 1) == 0 ) \ -+ *(unsigned long *)(_d_)->arg2.vcpumask.p = vcpumask; \ -+ else \ -+ rc = -EFAULT; \ -+ } \ -+ } while(0) -+ XLAT_mmuext_op(nat_op, &cmp_op); -+#undef XLAT_mmuext_op_HNDL_arg2_vcpumask -+ -+ if ( rc || i >= limit ) -+ break; -+ -+ guest_handle_add_offset(cmp_uops, 1); -+ ++nat_op; -+ } -+ -+ err = do_mmuext_op(nat_ops, i | preempt_mask, pdone, foreigndom); -+ -+ if ( err ) -+ { -+ BUILD_BUG_ON(__HYPERVISOR_mmuext_op <= 0); -+ if ( err == __HYPERVISOR_mmuext_op ) -+ { -+ struct cpu_user_regs *regs = guest_cpu_user_regs(); -+ unsigned int left = regs->ecx & ~MMU_UPDATE_PREEMPTED; -+ -+ BUG_ON(!(regs->ecx & MMU_UPDATE_PREEMPTED)); -+ BUG_ON(left > count); -+ guest_handle_add_offset(nat_ops, count - left); -+ BUG_ON(left + i < count); -+ guest_handle_add_offset(cmp_uops, (signed int)(count - left - i)); -+ left = 1; -+ BUG_ON(!hypercall_xlat_continuation(&left, 0x01, nat_ops, cmp_uops)); -+ BUG_ON(left != regs->ecx); -+ regs->ecx += count - i; -+ } -+ else -+ BUG_ON(rc > 0); -+ rc = err; -+ } -+ -+ if ( rc ) -+ break; -+ -+ /* Force do_mmuext_op() to not start counting from zero again. */ -+ preempt_mask = MMU_UPDATE_PREEMPTED; -+ } -+ -+ return rc; -+} -+ - #endif /* CONFIG_COMPAT */ - - /* -Index: 2006-12-18/xen/common/compat/xlat.c -=================================================================== ---- 2006-12-18.orig/xen/common/compat/xlat.c 2006-12-18 09:46:14.000000000 +0100 -+++ 2006-12-18/xen/common/compat/xlat.c 2006-12-18 09:49:35.000000000 +0100 -@@ -21,6 +21,10 @@ void xlat_start_info(struct start_info * - CHECK_dom0_vga_console_info; - #undef dom0_vga_console_info - -+#define xen_mmu_update mmu_update -+CHECK_mmu_update; -+#undef xen_mmu_update -+ - #define xen_vcpu_time_info vcpu_time_info - CHECK_vcpu_time_info; - #undef xen_vcpu_time_info -Index: 2006-12-18/xen/include/asm-x86/hypercall.h -=================================================================== ---- 2006-12-18.orig/xen/include/asm-x86/hypercall.h 2006-12-13 11:15:56.000000000 +0100 -+++ 2006-12-18/xen/include/asm-x86/hypercall.h 2006-12-18 09:49:35.000000000 +0100 -@@ -8,6 +8,13 @@ - #include - #include - -+/* -+ * Both do_mmuext_op() and do_mmu_update(): -+ * We steal the m.s.b. of the @count parameter to indicate whether this -+ * invocation of do_mmu_update() is resuming a previously preempted call. -+ */ -+#define MMU_UPDATE_PREEMPTED (~(~0U>>1)) -+ - extern long - do_event_channel_op_compat( - XEN_GUEST_HANDLE(evtchn_op_t) uop); -Index: 2006-12-18/xen/include/xlat.lst -=================================================================== ---- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:49:30.000000000 +0100 -+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:49:35.000000000 +0100 -@@ -2,6 +2,8 @@ - # ! - needs translation - # ? - needs checking - ? dom0_vga_console_info xen.h -+? mmu_update xen.h -+! mmuext_op xen.h - ! start_info xen.h - ? vcpu_time_info xen.h - ! add_to_physmap memory.h diff --git a/32on64-multicall.patch b/32on64-multicall.patch deleted file mode 100644 index a4204ae..0000000 --- a/32on64-multicall.patch +++ /dev/null @@ -1,168 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_multicall. - -Index: 2006-12-11/xen/arch/x86/x86_64/asm-offsets.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/asm-offsets.c 2006-12-15 15:28:41.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/asm-offsets.c 2006-12-15 15:33:03.000000000 +0100 -@@ -135,5 +135,17 @@ void __dummy__(void) - OFFSET(MULTICALL_result, struct multicall_entry, result); - BLANK(); - -+#ifdef CONFIG_COMPAT -+ OFFSET(COMPAT_MULTICALL_op, struct compat_multicall_entry, op); -+ OFFSET(COMPAT_MULTICALL_arg0, struct compat_multicall_entry, args[0]); -+ OFFSET(COMPAT_MULTICALL_arg1, struct compat_multicall_entry, args[1]); -+ OFFSET(COMPAT_MULTICALL_arg2, struct compat_multicall_entry, args[2]); -+ OFFSET(COMPAT_MULTICALL_arg3, struct compat_multicall_entry, args[3]); -+ OFFSET(COMPAT_MULTICALL_arg4, struct compat_multicall_entry, args[4]); -+ OFFSET(COMPAT_MULTICALL_arg5, struct compat_multicall_entry, args[5]); -+ OFFSET(COMPAT_MULTICALL_result, struct compat_multicall_entry, result); -+ BLANK(); -+#endif -+ - DEFINE(IRQSTAT_shift, LOG_2(sizeof(irq_cpustat_t))); - } -Index: 2006-12-11/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:32:58.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:33:03.000000000 +0100 -@@ -279,7 +279,6 @@ CFIX14: - .section .rodata, "a", @progbits - - #define compat_platform_op domain_crash_synchronous --#define compat_multicall domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous -Index: 2006-12-11/xen/common/compat/Makefile -=================================================================== ---- 2006-12-11.orig/xen/common/compat/Makefile 2006-12-15 15:32:56.000000000 +0100 -+++ 2006-12-11/xen/common/compat/Makefile 2006-12-15 15:33:03.000000000 +0100 -@@ -1,7 +1,9 @@ - obj-y += domain.o - obj-y += kernel.o - obj-y += memory.o -+obj-y += multicall.o - obj-y += xlat.o - - # extra dependencies - kernel.o: ../kernel.c -+multicall.o: ../multicall.c -Index: 2006-12-11/xen/common/compat/multicall.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-11/xen/common/compat/multicall.c 2006-12-15 15:33:03.000000000 +0100 -@@ -0,0 +1,31 @@ -+/****************************************************************************** -+ * multicall.c -+ */ -+ -+#include -+#include -+#include -+ -+#define COMPAT -+typedef int ret_t; -+#undef do_multicall_call -+ -+DEFINE_XEN_GUEST_HANDLE(multicall_entry_compat_t); -+#define multicall_entry compat_multicall_entry -+#define multicall_entry_t multicall_entry_compat_t -+#define do_multicall_call compat_multicall_call -+#define call compat_call -+#define do_multicall(l, n) compat_multicall(_##l, n) -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+ -+#include "../multicall.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-11/xen/common/multicall.c -=================================================================== ---- 2006-12-11.orig/xen/common/multicall.c 2006-12-15 15:20:37.000000000 +0100 -+++ 2006-12-11/xen/common/multicall.c 2006-12-15 15:33:03.000000000 +0100 -@@ -13,9 +13,12 @@ - #include - #include - -+#ifndef COMPAT - DEFINE_PER_CPU(struct mc_state, mc_state); -+typedef long ret_t; -+#endif - --long -+ret_t - do_multicall( - XEN_GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls) - { -Index: 2006-12-11/xen/include/asm-x86/multicall.h -=================================================================== ---- 2006-12-11.orig/xen/include/asm-x86/multicall.h 2006-12-15 15:20:34.000000000 +0100 -+++ 2006-12-11/xen/include/asm-x86/multicall.h 2006-12-15 15:33:03.000000000 +0100 -@@ -35,6 +35,31 @@ - "r8", "r9", "r10", "r11" ); \ - } while ( 0 ) - -+#define compat_multicall_call(_call) \ -+ do { \ -+ __asm__ __volatile__ ( \ -+ " movl "STR(COMPAT_MULTICALL_op)"(%0),%%eax; " \ -+ " leaq compat_hypercall_table(%%rip),%%rdi; " \ -+ " cmpl $("STR(NR_hypercalls)"),%%eax; " \ -+ " jae 2f; " \ -+ " movq (%%rdi,%%rax,8),%%rax; " \ -+ " movl "STR(COMPAT_MULTICALL_arg0)"(%0),%%edi; " \ -+ " movl "STR(COMPAT_MULTICALL_arg1)"(%0),%%esi; " \ -+ " movl "STR(COMPAT_MULTICALL_arg2)"(%0),%%edx; " \ -+ " movl "STR(COMPAT_MULTICALL_arg3)"(%0),%%ecx; " \ -+ " movl "STR(COMPAT_MULTICALL_arg4)"(%0),%%r8d; " \ -+ " callq *%%rax; " \ -+ "1: movl %%eax,"STR(COMPAT_MULTICALL_result)"(%0)\n"\ -+ ".section .fixup,\"ax\"\n" \ -+ "2: movl $-"STR(ENOSYS)",%%eax\n" \ -+ " jmp 1b\n" \ -+ ".previous\n" \ -+ : : "b" (_call) \ -+ /* all the caller-saves registers */ \ -+ : "rax", "rcx", "rdx", "rsi", "rdi", \ -+ "r8", "r9", "r10", "r11" ); \ -+ } while ( 0 ) -+ - #else - - #define do_multicall_call(_call) \ -Index: 2006-12-11/xen/include/xen/multicall.h -=================================================================== ---- 2006-12-11.orig/xen/include/xen/multicall.h 2006-12-15 15:20:37.000000000 +0100 -+++ 2006-12-11/xen/include/xen/multicall.h 2006-12-15 15:33:42.000000000 +0100 -@@ -7,6 +7,9 @@ - - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - - #define _MCSF_in_multicall 0 - #define _MCSF_call_preempted 1 -@@ -14,7 +17,12 @@ - #define MCSF_call_preempted (1<<_MCSF_call_preempted) - struct mc_state { - unsigned long flags; -- struct multicall_entry call; -+ union { -+ struct multicall_entry call; -+#ifdef CONFIG_COMPAT -+ struct compat_multicall_entry compat_call; -+#endif -+ }; - }; - - DECLARE_PER_CPU(struct mc_state, mc_state); diff --git a/32on64-per-domain-pa-bits.patch b/32on64-per-domain-pa-bits.patch deleted file mode 100644 index efbd436..0000000 --- a/32on64-per-domain-pa-bits.patch +++ /dev/null @@ -1,78 +0,0 @@ -Index: 2007-02-20/xen/arch/x86/domain.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/domain.c 2007-02-26 15:41:28.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/domain.c 2007-01-08 14:54:35.000000000 +0100 -@@ -253,7 +253,7 @@ static void release_compat_l4(struct vcp - - static inline int may_switch_mode(struct domain *d) - { -- return 1; /* XXX */ -+ return d->tot_pages == 0; - } - - int switch_native(struct domain *d) -@@ -281,6 +281,8 @@ int switch_native(struct domain *d) - release_compat_l4(d->vcpu[vcpuid]); - } - -+ d->pa_bitsize = 0; -+ - return 0; - } - -@@ -311,6 +313,9 @@ int switch_compat(struct domain *d) - return -ENOMEM; - } - -+ d->pa_bitsize = fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1 -+ + (PAGE_SIZE - 2); -+ - return 0; - } - -Index: 2007-02-20/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/domain_build.c 2007-02-26 15:41:28.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/domain_build.c 2007-02-26 15:42:27.000000000 +0100 -@@ -396,6 +396,8 @@ int construct_dom0(struct domain *d, - value = (value + mask) & ~mask; - #ifdef CONFIG_COMPAT - HYPERVISOR_COMPAT_VIRT_START(d) = max_t(unsigned int, m2p_compat_vstart, value); -+ d->pa_bitsize = !IS_COMPAT(d) ? 0 : -+ fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1 + (PAGE_SIZE - 2); - if ( value > (!IS_COMPAT(d) ? - HYPERVISOR_VIRT_START : - __HYPERVISOR_COMPAT_VIRT_START) ) -Index: 2007-02-20/xen/common/page_alloc.c -=================================================================== ---- 2007-02-20.orig/xen/common/page_alloc.c 2007-02-26 15:41:28.000000000 +0100 -+++ 2007-02-20/xen/common/page_alloc.c 2007-01-08 14:54:35.000000000 +0100 -@@ -718,7 +718,12 @@ struct page_info *__alloc_domheap_pages( - if ( bits && bits <= PAGE_SHIFT + 1 ) - return NULL; - -- zone_hi = bits - PAGE_SHIFT - 1; -+#ifdef CONFIG_COMPAT -+ if ( d && d->pa_bitsize && bits > d->pa_bitsize ) -+ zone_hi = d->pa_bitsize - PAGE_SHIFT - 1; -+ else -+#endif -+ zone_hi = bits - PAGE_SHIFT - 1; - if ( zone_hi >= NR_ZONES ) - zone_hi = NR_ZONES - 1; - -Index: 2007-02-20/xen/include/xen/sched.h -=================================================================== ---- 2007-02-20.orig/xen/include/xen/sched.h 2007-02-26 15:41:28.000000000 +0100 -+++ 2007-02-20/xen/include/xen/sched.h 2007-01-08 14:54:35.000000000 +0100 -@@ -165,6 +165,10 @@ struct domain - - unsigned long domain_flags; - -+#ifdef CONFIG_COMPAT -+ unsigned int pa_bitsize; -+#endif -+ - /* Boolean: Is this an HVM guest? */ - char is_hvm; - diff --git a/32on64-physdevop.patch b/32on64-physdevop.patch deleted file mode 100644 index bbd9d8a..0000000 --- a/32on64-physdevop.patch +++ /dev/null @@ -1,316 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_physdev_op and -HYPERVISOR_event_channel_op. - -Index: 2006-12-11/xen/arch/x86/compat.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/compat.c 2006-12-15 15:20:34.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/compat.c 2006-12-15 15:32:54.000000000 +0100 -@@ -9,17 +9,23 @@ - #include - #include - -+#ifndef COMPAT -+typedef long ret_t; -+#endif -+ - /* Legacy hypercall (as of 0x00030202). */ --long do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop) -+ret_t do_physdev_op_compat(XEN_GUEST_HANDLE(physdev_op_t) uop) - { - struct physdev_op op; - - if ( unlikely(copy_from_guest(&op, uop, 1) != 0) ) - return -EFAULT; - -- return do_physdev_op(op.cmd, (XEN_GUEST_HANDLE(void)) { &uop.p->u }); -+ return do_physdev_op(op.cmd, guest_handle_from_ptr(&uop.p->u, void)); - } - -+#ifndef COMPAT -+ - /* Legacy hypercall (as of 0x00030202). */ - long do_event_channel_op_compat(XEN_GUEST_HANDLE(evtchn_op_t) uop) - { -@@ -28,5 +34,7 @@ long do_event_channel_op_compat(XEN_GUES - if ( unlikely(copy_from_guest(&op, uop, 1) != 0) ) - return -EFAULT; - -- return do_event_channel_op(op.cmd, (XEN_GUEST_HANDLE(void)) {&uop.p->u }); -+ return do_event_channel_op(op.cmd, guest_handle_from_ptr(&uop.p->u, void)); - } -+ -+#endif -Index: 2006-12-11/xen/arch/x86/physdev.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/physdev.c 2006-12-15 15:20:34.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/physdev.c 2006-12-15 15:32:54.000000000 +0100 -@@ -9,9 +9,14 @@ - #include - #include - #include -+#include - #include - #include - -+#ifndef COMPAT -+typedef long ret_t; -+#endif -+ - int - ioapic_guest_read( - unsigned long physbase, unsigned int reg, u32 *pval); -@@ -19,10 +24,10 @@ int - ioapic_guest_write( - unsigned long physbase, unsigned int reg, u32 pval); - --long do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) -+ret_t do_physdev_op(int cmd, XEN_GUEST_HANDLE(void) arg) - { - int irq; -- long ret; -+ ret_t ret; - - switch ( cmd ) - { -@@ -129,7 +134,11 @@ long do_physdev_op(int cmd, XEN_GUEST_HA - (set_iobitmap.nr_ports > 65536) ) - break; - ret = 0; -+#ifndef COMPAT - current->arch.iobmp = set_iobitmap.bitmap; -+#else -+ guest_from_compat_handle(current->arch.iobmp, set_iobitmap.bitmap); -+#endif - current->arch.iobmp_limit = set_iobitmap.nr_ports; - break; - } -Index: 2006-12-11/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/Makefile 2006-12-15 15:29:19.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/Makefile 2006-12-15 15:32:54.000000000 +0100 -@@ -3,9 +3,14 @@ obj-y += gpr_switch.o - obj-y += mm.o - obj-y += traps.o - -+obj-$(CONFIG_COMPAT) += compat.o -+obj-$(CONFIG_COMPAT) += physdev.o -+ - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies -+compat.o: ../compat.c - entry.o: compat/entry.S - mm.o: compat/mm.c -+physdev.o: ../physdev.c - traps.o: compat/traps.c - endif -Index: 2006-12-11/xen/arch/x86/x86_64/compat.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-11/xen/arch/x86/x86_64/compat.c 2006-12-15 15:32:54.000000000 +0100 -@@ -0,0 +1,30 @@ -+/****************************************************************************** -+ * compat.c -+ */ -+ -+#include -+#include -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(physdev_op_compat_t); -+#define physdev_op compat_physdev_op -+#define physdev_op_t physdev_op_compat_t -+#define do_physdev_op compat_physdev_op -+#define do_physdev_op_compat(x) compat_physdev_op_compat(_##x) -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+typedef int ret_t; -+ -+#include "../compat.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-11/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:32:08.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:32:54.000000000 +0100 -@@ -283,15 +283,11 @@ CFIX14: - #define compat_platform_op domain_crash_synchronous - #define compat_multicall domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous --#define compat_event_channel_op_compat domain_crash_synchronous --#define compat_physdev_op_compat domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous - #define compat_vcpu_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous - #define compat_arch_sched_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous --#define compat_event_channel_op domain_crash_synchronous --#define compat_physdev_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous - #define compat_domctl domain_crash_synchronous - -@@ -312,7 +308,7 @@ ENTRY(compat_hypercall_table) - .quad compat_multicall - .quad compat_update_va_mapping - .quad compat_set_timer_op /* 15 */ -- .quad compat_event_channel_op_compat -+ .quad do_event_channel_op_compat - .quad compat_xen_version - .quad do_console_io - .quad compat_physdev_op_compat -@@ -328,7 +324,7 @@ ENTRY(compat_hypercall_table) - .quad compat_arch_sched_op - .quad compat_callback_op /* 30 */ - .quad compat_xenoprof_op -- .quad compat_event_channel_op -+ .quad do_event_channel_op - .quad compat_physdev_op - .quad compat_ni_hypercall - .quad compat_sysctl /* 35 */ -Index: 2006-12-11/xen/arch/x86/x86_64/physdev.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-11/xen/arch/x86/x86_64/physdev.c 2006-12-15 15:32:54.000000000 +0100 -@@ -0,0 +1,48 @@ -+/****************************************************************************** -+ * physdev.c -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#define do_physdev_op compat_physdev_op -+ -+#define physdev_apic compat_physdev_apic -+#define physdev_apic_t physdev_apic_compat_t -+ -+#define physdev_eoi compat_physdev_eoi -+#define physdev_eoi_t physdev_eoi_compat_t -+ -+#define physdev_set_iobitmap compat_physdev_set_iobitmap -+#define physdev_set_iobitmap_t physdev_set_iobitmap_compat_t -+ -+#define physdev_set_iopl compat_physdev_set_iopl -+#define physdev_set_iopl_t physdev_set_iopl_compat_t -+ -+#define physdev_irq compat_physdev_irq -+#define physdev_irq_t physdev_irq_compat_t -+ -+#define physdev_irq_status_query compat_physdev_irq_status_query -+#define physdev_irq_status_query_t physdev_irq_status_query_compat_t -+ -+#define COMPAT -+#undef guest_handle_okay -+#define guest_handle_okay compat_handle_okay -+typedef int ret_t; -+ -+#include "../physdev.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-11/xen/common/compat/xlat.c -=================================================================== ---- 2006-12-11.orig/xen/common/compat/xlat.c 2006-12-15 15:32:08.000000000 +0100 -+++ 2006-12-11/xen/common/compat/xlat.c 2006-12-15 15:32:54.000000000 +0100 -@@ -4,8 +4,8 @@ - - #include - #include --#include - #include -+#include - - /* In-place translation functons: */ - void xlat_start_info(struct start_info *native, -@@ -21,6 +21,30 @@ void xlat_start_info(struct start_info * - CHECK_dom0_vga_console_info; - #undef dom0_vga_console_info - -+#define xen_evtchn_alloc_unbound evtchn_alloc_unbound -+#define xen_evtchn_bind_interdomain evtchn_bind_interdomain -+#define xen_evtchn_bind_ipi evtchn_bind_ipi -+#define xen_evtchn_bind_pirq evtchn_bind_pirq -+#define xen_evtchn_bind_vcpu evtchn_bind_vcpu -+#define xen_evtchn_bind_virq evtchn_bind_virq -+#define xen_evtchn_close evtchn_close -+#define xen_evtchn_op evtchn_op -+#define xen_evtchn_send evtchn_send -+#define xen_evtchn_status evtchn_status -+#define xen_evtchn_unmask evtchn_unmask -+CHECK_evtchn_op; -+#undef xen_evtchn_alloc_unbound -+#undef xen_evtchn_bind_interdomain -+#undef xen_evtchn_bind_ipi -+#undef xen_evtchn_bind_pirq -+#undef xen_evtchn_bind_vcpu -+#undef xen_evtchn_bind_virq -+#undef xen_evtchn_close -+#undef xen_evtchn_op -+#undef xen_evtchn_send -+#undef xen_evtchn_status -+#undef xen_evtchn_unmask -+ - #define xen_mmu_update mmu_update - CHECK_mmu_update; - #undef xen_mmu_update -Index: 2006-12-11/xen/include/asm-x86/hypercall.h -=================================================================== ---- 2006-12-11.orig/xen/include/asm-x86/hypercall.h 2006-12-15 15:32:08.000000000 +0100 -+++ 2006-12-11/xen/include/asm-x86/hypercall.h 2006-12-15 15:32:54.000000000 +0100 -@@ -123,4 +123,13 @@ do_set_callbacks( - - #endif - -+#ifdef CONFIG_COMPAT -+ -+extern int -+compat_physdev_op( -+ int cmd, -+ XEN_GUEST_HANDLE(void) arg); -+ -+#endif -+ - #endif /* __ASM_X86_HYPERCALL_H__ */ -Index: 2006-12-11/xen/include/xlat.lst -=================================================================== ---- 2006-12-11.orig/xen/include/xlat.lst 2006-12-15 15:32:08.000000000 +0100 -+++ 2006-12-11/xen/include/xlat.lst 2006-12-15 15:32:54.000000000 +0100 -@@ -6,6 +6,17 @@ - ! mmuext_op xen.h - ! start_info xen.h - ? vcpu_time_info xen.h -+? evtchn_alloc_unbound event_channel.h -+? evtchn_bind_interdomain event_channel.h -+? evtchn_bind_ipi event_channel.h -+? evtchn_bind_pirq event_channel.h -+? evtchn_bind_vcpu event_channel.h -+? evtchn_bind_virq event_channel.h -+? evtchn_close event_channel.h -+? evtchn_op event_channel.h -+? evtchn_send event_channel.h -+? evtchn_status event_channel.h -+? evtchn_unmask event_channel.h - ! add_to_physmap memory.h - ! foreign_memory_map memory.h - ! memory_exchange memory.h diff --git a/32on64-pltop.patch b/32on64-pltop.patch deleted file mode 100644 index 52631bd..0000000 --- a/32on64-pltop.patch +++ /dev/null @@ -1,108 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_platformop. - -Index: 2006-12-11/xen/arch/x86/platform_hypercall.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/platform_hypercall.c 2006-12-15 15:20:33.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/platform_hypercall.c 2006-12-15 15:37:24.000000000 +0100 -@@ -23,11 +23,17 @@ - #include - #include "cpu/mtrr/mtrr.h" - --long do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) -+#ifndef COMPAT -+typedef long ret_t; -+DEFINE_SPINLOCK(xenpf_lock); -+#else -+extern spinlock_t xenpf_lock; -+#endif -+ -+ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op) - { -- long ret = 0; -+ ret_t ret = 0; - struct xen_platform_op curop, *op = &curop; -- static DEFINE_SPINLOCK(xenpf_lock); - - if ( !IS_PRIV(current->domain) ) - return -EPERM; -@@ -105,8 +111,15 @@ long do_platform_op(XEN_GUEST_HANDLE(xen - case XENPF_microcode_update: - { - extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len); -+#ifndef COMPAT - ret = microcode_update(op->u.microcode.data, - op->u.microcode.length); -+#else -+ XEN_GUEST_HANDLE(void) data; -+ -+ guest_from_compat_handle(data, op->u.microcode.data); -+ ret = microcode_update(data, op->u.microcode.length); -+#endif - } - break; - -Index: 2006-12-11/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/Makefile 2006-12-15 15:37:19.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/Makefile 2006-12-15 15:37:24.000000000 +0100 -@@ -6,6 +6,7 @@ obj-y += traps.o - obj-$(CONFIG_COMPAT) += compat.o - obj-$(CONFIG_COMPAT) += domain.o - obj-$(CONFIG_COMPAT) += physdev.o -+obj-$(CONFIG_COMPAT) += platform_hypercall.o - - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies -@@ -13,5 +14,6 @@ compat.o: ../compat.c - entry.o: compat/entry.S - mm.o: compat/mm.c - physdev.o: ../physdev.c -+platform_hypercall.o: ../platform_hypercall.c - traps.o: compat/traps.c - endif -Index: 2006-12-11/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:37:22.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:37:24.000000000 +0100 -@@ -278,7 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_platform_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous -Index: 2006-12-11/xen/arch/x86/x86_64/platform_hypercall.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-11/xen/arch/x86/x86_64/platform_hypercall.c 2006-12-15 15:37:24.000000000 +0100 -@@ -0,0 +1,29 @@ -+/****************************************************************************** -+ * platform_hypercall.c -+ * -+ */ -+ -+#include -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(compat_platform_op_t); -+#define xen_platform_op compat_platform_op -+#define xen_platform_op_t compat_platform_op_t -+#define do_platform_op(x) compat_platform_op(_##x) -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+typedef int ret_t; -+ -+#include "../platform_hypercall.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ diff --git a/32on64-schedop.patch b/32on64-schedop.patch deleted file mode 100644 index 3e27dae..0000000 --- a/32on64-schedop.patch +++ /dev/null @@ -1,167 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_sched_op and -HYPERVISOR_set_timer_op. - -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:49:55.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:49:57.000000000 +0100 -@@ -279,10 +279,8 @@ CFIX14: - .section .rodata, "a", @progbits - - #define compat_platform_op domain_crash_synchronous --#define compat_set_timer_op domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous --#define compat_arch_sched_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous - #define compat_domctl domain_crash_synchronous -@@ -317,7 +315,7 @@ ENTRY(compat_hypercall_table) - .quad compat_mmuext_op - .quad compat_acm_op - .quad compat_nmi_op -- .quad compat_arch_sched_op -+ .quad compat_sched_op - .quad compat_callback_op /* 30 */ - .quad compat_xenoprof_op - .quad do_event_channel_op -@@ -359,7 +357,7 @@ ENTRY(compat_hypercall_args_table) - .byte 4 /* compat_mmuext_op */ - .byte 1 /* compat_acm_op */ - .byte 2 /* compat_nmi_op */ -- .byte 2 /* compat_arch_sched_op */ -+ .byte 2 /* compat_sched_op */ - .byte 2 /* compat_callback_op */ /* 30 */ - .byte 2 /* compat_xenoprof_op */ - .byte 2 /* compat_event_channel_op */ -Index: 2006-12-18/xen/common/Makefile -=================================================================== ---- 2006-12-18.orig/xen/common/Makefile 2006-12-18 09:43:12.000000000 +0100 -+++ 2006-12-18/xen/common/Makefile 2006-12-18 09:49:57.000000000 +0100 -@@ -39,3 +39,8 @@ subdir-$(CONFIG_COMPAT) += compat - - # Object file contains changeset and compiler information. - version.o: $(BASEDIR)/include/xen/compile.h -+ -+ifeq ($(CONFIG_COMPAT),y) -+# extra dependencies -+schedule.o: compat/schedule.c -+endif -Index: 2006-12-18/xen/common/compat/schedule.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/common/compat/schedule.c 2006-12-18 09:49:57.000000000 +0100 -@@ -0,0 +1,51 @@ -+/**************************************************************************** -+ * schedule.c -+ * -+ */ -+ -+#include -+ -+#define COMPAT -+#define ret_t int -+ -+#define do_sched_op compat_sched_op -+ -+#define xen_sched_shutdown sched_shutdown -+CHECK_sched_shutdown; -+#undef xen_sched_shutdown -+ -+#define xen_sched_remote_shutdown sched_remote_shutdown -+CHECK_sched_remote_shutdown; -+#undef xen_sched_remote_shutdown -+ -+static int compat_poll(struct compat_sched_poll *compat) -+{ -+ struct sched_poll native; -+ -+#define XLAT_sched_poll_HNDL_ports(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->ports, (_s_)->ports) -+ XLAT_sched_poll(&native, compat); -+#undef XLAT_sched_poll_HNDL_ports -+ -+ return do_poll(&native); -+} -+ -+#define do_poll compat_poll -+#define sched_poll compat_sched_poll -+ -+#include "../schedule.c" -+ -+int compat_set_timer_op(u32 lo, s32 hi) -+{ -+ return do_set_timer_op(((s64)hi << 32) | lo); -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-18/xen/common/schedule.c -=================================================================== ---- 2006-12-18.orig/xen/common/schedule.c 2006-12-18 09:46:14.000000000 +0100 -+++ 2006-12-18/xen/common/schedule.c 2006-12-18 09:49:57.000000000 +0100 -@@ -13,6 +13,7 @@ - * - */ - -+#ifndef COMPAT - #include - #include - #include -@@ -366,9 +367,13 @@ long do_sched_op_compat(int cmd, unsigne - return ret; - } - --long do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg) -+typedef long ret_t; -+ -+#endif /* !COMPAT */ -+ -+ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE(void) arg) - { -- long ret = 0; -+ ret_t ret = 0; - - switch ( cmd ) - { -@@ -445,6 +450,8 @@ long do_sched_op(int cmd, XEN_GUEST_HAND - return ret; - } - -+#ifndef COMPAT -+ - /* Per-domain one-shot-timer hypercall. */ - long do_set_timer_op(s_time_t timeout) - { -@@ -736,6 +743,12 @@ void dump_runq(unsigned char key) - local_irq_restore(flags); - } - -+#ifdef CONFIG_COMPAT -+#include "compat/schedule.c" -+#endif -+ -+#endif /* !COMPAT */ -+ - /* - * Local variables: - * mode: C -Index: 2006-12-18/xen/include/xlat.lst -=================================================================== ---- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:49:49.000000000 +0100 -+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:49:57.000000000 +0100 -@@ -26,4 +26,7 @@ - ! memory_map memory.h - ! memory_reservation memory.h - ! translate_gpfn_list memory.h -+! sched_poll sched.h -+? sched_remote_shutdown sched.h -+? sched_shutdown sched.h - ! vcpu_runstate_info vcpu.h diff --git a/32on64-settrap.patch b/32on64-settrap.patch deleted file mode 100644 index 6795236..0000000 --- a/32on64-settrap.patch +++ /dev/null @@ -1,123 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_set_trap_table and -HYPERVISOR_set_gdt. - -Index: 2006-12-11/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:32:56.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:32:58.000000000 +0100 -@@ -278,8 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_set_trap_table domain_crash_synchronous --#define compat_set_gdt domain_crash_synchronous - #define compat_platform_op domain_crash_synchronous - #define compat_multicall domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous -Index: 2006-12-11/xen/arch/x86/x86_64/compat/mm.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/mm.c 2006-12-15 15:32:08.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/mm.c 2006-12-15 15:32:58.000000000 +0100 -@@ -4,6 +4,39 @@ - #include - #include - -+int compat_set_gdt(XEN_GUEST_HANDLE(uint) frame_list, unsigned int entries) -+{ -+ unsigned int i, nr_pages = (entries + 511) / 512; -+ unsigned long frames[16]; -+ long ret; -+ -+ /* Rechecked in set_gdt, but ensures a sane limit for copy_from_user(). */ -+ if ( entries > FIRST_RESERVED_GDT_ENTRY ) -+ return -EINVAL; -+ -+ if ( !guest_handle_okay(frame_list, nr_pages) ) -+ return -EFAULT; -+ -+ for ( i = 0; i < nr_pages; ++i ) -+ { -+ unsigned int frame; -+ -+ if ( __copy_from_guest(&frame, frame_list, 1) ) -+ return -EFAULT; -+ frames[i] = frame; -+ guest_handle_add_offset(frame_list, 1); -+ } -+ -+ LOCK_BIGLOCK(current->domain); -+ -+ if ( (ret = set_gdt(current, frames, entries)) == 0 ) -+ local_flush_tlb(); -+ -+ UNLOCK_BIGLOCK(current->domain); -+ -+ return ret; -+} -+ - int compat_update_descriptor(u32 pa_lo, u32 pa_hi, u32 desc_lo, u32 desc_hi) - { - return do_update_descriptor(pa_lo | ((u64)pa_hi << 32), -Index: 2006-12-11/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/traps.c 2006-12-15 15:28:41.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/traps.c 2006-12-15 15:32:58.000000000 +0100 -@@ -1,6 +1,8 @@ - #ifdef CONFIG_COMPAT - -+#include - #include -+#include - - void compat_show_guest_stack(struct cpu_user_regs *regs, int debug_stack_lines) - { -@@ -252,6 +254,49 @@ long compat_set_callbacks(unsigned long - return 0; - } - -+DEFINE_XEN_GUEST_HANDLE(trap_info_compat_t); -+ -+int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps) -+{ -+ struct compat_trap_info cur; -+ struct trap_info *dst = current->arch.guest_context.trap_ctxt; -+ long rc = 0; -+ -+ /* If no table is presented then clear the entire virtual IDT. */ -+ if ( guest_handle_is_null(traps) ) -+ { -+ memset(dst, 0, 256 * sizeof(*dst)); -+ return 0; -+ } -+ -+ for ( ; ; ) -+ { -+ if ( hypercall_preempt_check() ) -+ { -+ rc = hypercall_create_continuation( -+ __HYPERVISOR_set_trap_table, "h", traps); -+ break; -+ } -+ -+ if ( copy_from_guest(&cur, traps, 1) ) -+ { -+ rc = -EFAULT; -+ break; -+ } -+ -+ if ( cur.address == 0 ) -+ break; -+ -+ fixup_guest_code_selector(current->domain, cur.cs); -+ -+ XLAT_trap_info(dst + cur.vector, &cur); -+ -+ guest_handle_add_offset(traps, 1); -+ } -+ -+ return rc; -+} -+ - #endif /* CONFIG_COMPAT */ - - static void hypercall_page_initialise_ring1_kernel(void *hypercall_page) diff --git a/32on64-shadow.patch b/32on64-shadow.patch deleted file mode 100644 index 2343031..0000000 --- a/32on64-shadow.patch +++ /dev/null @@ -1,199 +0,0 @@ -Preliminary, likely incomplete and/or wrong, adjustments to shadow code. - -unstable c/s 13296: [HVM] Fix shadow memory tracking -Fixes a missing free from cset 13275, and a missing prealloc. -Signed-off-by: Tim Deegan - -Index: 2007-01-31/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/mm/shadow/common.c 2007-01-31 09:31:33.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/mm/shadow/common.c 2007-01-31 09:36:44.000000000 +0100 -@@ -2427,7 +2427,7 @@ void sh_update_paging_modes(struct vcpu - /// - #if CONFIG_PAGING_LEVELS == 4 - if ( pv_32bit_guest(v) ) -- v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,4,3); -+ v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,3,3); - else - v->arch.shadow.mode = &SHADOW_INTERNAL_NAME(sh_paging_mode,4,4); - #elif CONFIG_PAGING_LEVELS == 3 -Index: 2007-01-31/xen/arch/x86/mm/shadow/multi.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/mm/shadow/multi.c 2007-01-31 09:31:33.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/mm/shadow/multi.c 2007-01-31 09:36:54.000000000 +0100 -@@ -1423,7 +1423,7 @@ void sh_install_xen_entries_in_l4(struct - } - #endif - --#if CONFIG_PAGING_LEVELS == 3 && GUEST_PAGING_LEVELS == 3 -+#if (CONFIG_PAGING_LEVELS == 3 || defined(CONFIG_COMPAT)) && GUEST_PAGING_LEVELS == 3 - // For 3-on-3 PV guests, we need to make sure the xen mappings are in - // place, which means that we need to populate the l2h entry in the l3 - // table. -@@ -1433,12 +1433,20 @@ void sh_install_xen_entries_in_l2h(struc - { - struct domain *d = v->domain; - shadow_l2e_t *sl2e; -+#if CONFIG_PAGING_LEVELS == 3 - int i; -+#else -+ -+ if ( !pv_32bit_guest(v) ) -+ return; -+#endif - - sl2e = sh_map_domain_page(sl2hmfn); - ASSERT(sl2e != NULL); - ASSERT(sizeof (l2_pgentry_t) == sizeof (shadow_l2e_t)); - -+#if CONFIG_PAGING_LEVELS == 3 -+ - /* Copy the common Xen mappings from the idle domain */ - memcpy(&sl2e[L2_PAGETABLE_FIRST_XEN_SLOT & (L2_PAGETABLE_ENTRIES-1)], - &idle_pg_table_l2[L2_PAGETABLE_FIRST_XEN_SLOT], -@@ -1479,6 +1487,15 @@ void sh_install_xen_entries_in_l2h(struc - } - sh_unmap_domain_page(p2m); - } -+ -+#else -+ -+ /* Copy the common Xen mappings from the idle domain */ -+ memcpy(&sl2e[COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(d)], -+ &compat_idle_pg_table_l2[l2_table_offset(HIRO_COMPAT_MPT_VIRT_START)], -+ COMPAT_L2_PAGETABLE_XEN_SLOTS(d) * sizeof(*sl2e)); -+ -+#endif - - sh_unmap_domain_page(sl2e); - } -@@ -1639,12 +1656,15 @@ make_fl1_shadow(struct vcpu *v, gfn_t gf - mfn_t - sh_make_monitor_table(struct vcpu *v) - { -+ struct domain *d = v->domain; - - ASSERT(pagetable_get_pfn(v->arch.monitor_table) == 0); - -+ /* Guarantee we can get the memory we need */ -+ shadow_prealloc(d, SHADOW_MAX_ORDER); -+ - #if CONFIG_PAGING_LEVELS == 4 - { -- struct domain *d = v->domain; - mfn_t m4mfn; - m4mfn = shadow_alloc(d, SH_type_monitor_table, 0); - sh_install_xen_entries_in_l4(v, m4mfn, m4mfn); -@@ -1661,6 +1681,19 @@ sh_make_monitor_table(struct vcpu *v) - l4e = sh_map_domain_page(m4mfn); - l4e[0] = l4e_from_pfn(mfn_x(m3mfn), __PAGE_HYPERVISOR); - sh_unmap_domain_page(l4e); -+ if ( pv_32bit_guest(v) ) -+ { -+ // Install a monitor l2 table in slot 3 of the l3 table. -+ // This is used for all Xen entries. -+ mfn_t m2mfn; -+ l3_pgentry_t *l3e; -+ m2mfn = shadow_alloc(d, SH_type_monitor_table, 0); -+ mfn_to_page(m2mfn)->shadow_flags = 2; -+ l3e = sh_map_domain_page(m3mfn); -+ l3e[3] = l3e_from_pfn(mfn_x(m2mfn), _PAGE_PRESENT); -+ sh_install_xen_entries_in_l2h(v, m2mfn); -+ sh_unmap_domain_page(l3e); -+ } - } - #endif /* SHADOW_PAGING_LEVELS < 4 */ - return m4mfn; -@@ -1669,7 +1702,6 @@ sh_make_monitor_table(struct vcpu *v) - #elif CONFIG_PAGING_LEVELS == 3 - - { -- struct domain *d = v->domain; - mfn_t m3mfn, m2mfn; - l3_pgentry_t *l3e; - l2_pgentry_t *l2e; -@@ -1703,7 +1735,6 @@ sh_make_monitor_table(struct vcpu *v) - #elif CONFIG_PAGING_LEVELS == 2 - - { -- struct domain *d = v->domain; - mfn_t m2mfn; - m2mfn = shadow_alloc(d, SH_type_monitor_table, 0); - sh_install_xen_entries_in_l2(v, m2mfn, m2mfn); -@@ -2066,9 +2097,19 @@ void sh_destroy_monitor_table(struct vcp - #if (CONFIG_PAGING_LEVELS == 4) && (SHADOW_PAGING_LEVELS != 4) - /* Need to destroy the l3 monitor page in slot 0 too */ - { -+ mfn_t m3mfn; - l4_pgentry_t *l4e = sh_map_domain_page(mmfn); - ASSERT(l4e_get_flags(l4e[0]) & _PAGE_PRESENT); -- shadow_free(d, _mfn(l4e_get_pfn(l4e[0]))); -+ m3mfn = _mfn(l4e_get_pfn(l4e[0])); -+ if ( pv_32bit_guest(v) ) -+ { -+ /* Need to destroy the l2 monitor page in slot 3 too */ -+ l3_pgentry_t *l3e = sh_map_domain_page(m3mfn); -+ ASSERT(l3e_get_flags(l3e[3]) & _PAGE_PRESENT); -+ shadow_free(d, _mfn(l3e_get_pfn(l3e[3]))); -+ sh_unmap_domain_page(l3e); -+ } -+ shadow_free(d, m3mfn); - sh_unmap_domain_page(l4e); - } - #elif CONFIG_PAGING_LEVELS == 3 -@@ -3048,12 +3089,15 @@ sh_update_linear_entries(struct vcpu *v) - - #elif (CONFIG_PAGING_LEVELS == 4) && (SHADOW_PAGING_LEVELS == 3) - -- /* This case only exists in HVM. To give ourselves a linear map of the -- * shadows, we need to extend a PAE shadow to 4 levels. We do this by -- * having a monitor l3 in slot 0 of the monitor l4 table, and -- * copying the PAE l3 entries into it. Then, by having the monitor l4e -- * for shadow pagetables also point to the monitor l4, we can use it -- * to access the shadows. */ -+ /* PV: XXX -+ * -+ * HVM: To give ourselves a linear map of the shadows, we need to -+ * extend a PAE shadow to 4 levels. We do this by having a monitor -+ * l3 in slot 0 of the monitor l4 table, and copying the PAE l3 -+ * entries into it. Then, by having the monitor l4e for shadow -+ * pagetables also point to the monitor l4, we can use it to access -+ * the shadows. -+ */ - - if ( shadow_mode_external(d) ) - { -@@ -3096,6 +3140,8 @@ sh_update_linear_entries(struct vcpu *v) - if ( v != current ) - sh_unmap_domain_page(ml3e); - } -+ else -+ domain_crash(d); /* XXX */ - - #elif CONFIG_PAGING_LEVELS == 3 - -Index: 2007-01-31/xen/include/asm-x86/shadow.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/shadow.h 2007-01-31 09:31:33.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/shadow.h 2007-01-31 09:36:44.000000000 +0100 -@@ -70,9 +70,9 @@ - - // How do we tell that we have a 32-bit PV guest in a 64-bit Xen? - #ifdef __x86_64__ --#define pv_32bit_guest(_v) 0 // not yet supported -+#define pv_32bit_guest(_v) (!is_hvm_vcpu(_v) && IS_COMPAT((_v)->domain)) - #else --#define pv_32bit_guest(_v) !is_hvm_vcpu(v) -+#define pv_32bit_guest(_v) (!is_hvm_vcpu(_v)) - #endif - - /* The shadow lock. -@@ -418,7 +418,7 @@ static inline void update_cr3(struct vcp - } - - #if CONFIG_PAGING_LEVELS == 4 -- if ( !(v->arch.flags & TF_kernel_mode) ) -+ if ( !(v->arch.flags & TF_kernel_mode) && !IS_COMPAT(v->domain) ) - cr3_mfn = pagetable_get_pfn(v->arch.guest_table_user); - else - #endif diff --git a/32on64-shared.patch b/32on64-shared.patch deleted file mode 100644 index 920db96..0000000 --- a/32on64-shared.patch +++ /dev/null @@ -1,900 +0,0 @@ -Handle shared info (having different layout for native and compatibility -mode guests) accesses. - -Index: 2007-01-08/xen/arch/x86/crash.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/crash.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/crash.c 2007-01-08 15:19:11.000000000 +0100 -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - - static atomic_t waiting_for_crash_ipi; -@@ -103,7 +104,7 @@ void machine_crash_shutdown(void) - - info = kexec_crash_save_info(); - info->dom0_pfn_to_mfn_frame_list_list = -- dom0->shared_info->arch.pfn_to_mfn_frame_list_list; -+ arch_get_pfn_to_mfn_frame_list_list(dom0); - } - - /* -Index: 2007-01-08/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain.c 2007-01-08 14:45:40.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain.c 2007-01-08 15:19:11.000000000 +0100 -@@ -547,10 +547,10 @@ static void load_segments(struct vcpu *n - - /* CS longword also contains full evtchn_upcall_mask. */ - cs_and_mask = (unsigned short)regs->cs | -- ((unsigned int)n->vcpu_info->evtchn_upcall_mask << 16); -+ ((unsigned int)vcpu_info(n, evtchn_upcall_mask) << 16); - /* Fold upcall mask into RFLAGS.IF. */ - eflags = regs->_eflags & ~X86_EFLAGS_IF; -- eflags |= !n->vcpu_info->evtchn_upcall_mask << 9; -+ eflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - - if ( !ring_1(regs) ) - { -@@ -575,7 +575,7 @@ static void load_segments(struct vcpu *n - - if ( test_bit(_VGCF_failsafe_disables_events, - &n->arch.guest_context.flags) ) -- n->vcpu_info->evtchn_upcall_mask = 1; -+ vcpu_info(n, evtchn_upcall_mask) = 1; - - regs->entry_vector = TRAP_syscall; - regs->_eflags &= 0xFFFCBEFFUL; -@@ -593,11 +593,11 @@ static void load_segments(struct vcpu *n - - /* CS longword also contains full evtchn_upcall_mask. */ - cs_and_mask = (unsigned long)regs->cs | -- ((unsigned long)n->vcpu_info->evtchn_upcall_mask << 32); -+ ((unsigned long)vcpu_info(n, evtchn_upcall_mask) << 32); - - /* Fold upcall mask into RFLAGS.IF. */ - rflags = regs->rflags & ~X86_EFLAGS_IF; -- rflags |= !n->vcpu_info->evtchn_upcall_mask << 9; -+ rflags |= !vcpu_info(n, evtchn_upcall_mask) << 9; - - if ( put_user(regs->ss, rsp- 1) | - put_user(regs->rsp, rsp- 2) | -@@ -618,7 +618,7 @@ static void load_segments(struct vcpu *n - - if ( test_bit(_VGCF_failsafe_disables_events, - &n->arch.guest_context.flags) ) -- n->vcpu_info->evtchn_upcall_mask = 1; -+ vcpu_info(n, evtchn_upcall_mask) = 1; - - regs->entry_vector = TRAP_syscall; - regs->rflags &= ~(X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF| -Index: 2007-01-08/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain_build.c 2007-01-08 15:35:20.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain_build.c 2007-01-08 15:35:36.000000000 +0100 -@@ -328,6 +328,7 @@ int construct_dom0(struct domain *d, - l1_pgentry_t gdt_l1e; - - set_bit(_DOMF_compat, &d->domain_flags); -+ v->vcpu_info = (void *)&d->shared_info->compat.vcpu_info[0]; - - if ( nr_pages != (unsigned int)nr_pages ) - nr_pages = UINT_MAX; -@@ -730,7 +731,7 @@ int construct_dom0(struct domain *d, - - /* Mask all upcalls... */ - for ( i = 0; i < MAX_VIRT_CPUS; i++ ) -- d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1; -+ shared_info(d, vcpu_info[i].evtchn_upcall_mask) = 1; - - if ( opt_dom0_max_vcpus == 0 ) - opt_dom0_max_vcpus = num_online_cpus(); -@@ -738,6 +739,8 @@ int construct_dom0(struct domain *d, - opt_dom0_max_vcpus = num_online_cpus(); - if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS ) - opt_dom0_max_vcpus = MAX_VIRT_CPUS; -+ if ( opt_dom0_max_vcpus > BITS_PER_GUEST_LONG(d) ) -+ opt_dom0_max_vcpus = BITS_PER_GUEST_LONG(d); - printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus); - - for ( i = 1; i < opt_dom0_max_vcpus; i++ ) -Index: 2007-01-08/xen/arch/x86/irq.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/irq.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/irq.c 2007-01-08 15:19:11.000000000 +0100 -@@ -13,6 +13,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -332,7 +333,7 @@ int pirq_guest_unmask(struct domain *d) - irq < NR_IRQS; - irq = find_next_bit(d->pirq_mask, NR_IRQS, irq+1) ) - { -- if ( !test_bit(d->pirq_to_evtchn[irq], s->evtchn_mask) ) -+ if ( !test_bit(d->pirq_to_evtchn[irq], __shared_info_addr(d, s, evtchn_mask)) ) - __pirq_guest_eoi(d, irq); - } - -@@ -624,14 +625,13 @@ static void dump_irqs(unsigned char key) - printk("%u(%c%c%c%c)", - d->domain_id, - (test_bit(d->pirq_to_evtchn[irq], -- d->shared_info->evtchn_pending) ? -+ shared_info_addr(d, evtchn_pending)) ? - 'P' : '-'), -- (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_LONG, -- &d->shared_info->vcpu_info[0]. -- evtchn_pending_sel) ? -+ (test_bit(d->pirq_to_evtchn[irq]/BITS_PER_GUEST_LONG(d), -+ vcpu_info_addr(d->vcpu[0], evtchn_pending_sel)) ? - 'S' : '-'), - (test_bit(d->pirq_to_evtchn[irq], -- d->shared_info->evtchn_mask) ? -+ shared_info_addr(d, evtchn_mask)) ? - 'M' : '-'), - (test_bit(irq, d->pirq_mask) ? - 'M' : '-')); -Index: 2007-01-08/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/mm/shadow/common.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/mm/shadow/common.c 2007-01-08 15:19:11.000000000 +0100 -@@ -36,6 +36,7 @@ - #include - #include - #include -+#include - #include "private.h" - - #if SHADOW_AUDIT -@@ -2890,7 +2891,7 @@ sh_alloc_log_dirty_bitmap(struct domain - { - ASSERT(d->arch.shadow.dirty_bitmap == NULL); - d->arch.shadow.dirty_bitmap_size = -- (d->shared_info->arch.max_pfn + (BITS_PER_LONG - 1)) & -+ (arch_get_max_pfn(d) + (BITS_PER_LONG - 1)) & - ~(BITS_PER_LONG - 1); - d->arch.shadow.dirty_bitmap = - xmalloc_array(unsigned long, -Index: 2007-01-08/xen/arch/x86/setup.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/setup.c 2007-01-08 15:18:32.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/setup.c 2007-01-08 15:19:11.000000000 +0100 -@@ -548,14 +548,13 @@ void __init __start_xen(multiboot_info_t - - BUILD_BUG_ON(sizeof(start_info_t) > PAGE_SIZE); - BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); -- BUILD_BUG_ON(sizeof(vcpu_info_t) != 64); -+ BUILD_BUG_ON(sizeof(struct vcpu_info) != 64); - - #ifdef CONFIG_COMPAT - BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) != - sizeof(((struct compat_platform_op *)0)->u.pad)); - BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE); -- BUILD_BUG_ON(sizeof(shared_info_compat_t) > PAGE_SIZE); -- BUILD_BUG_ON(sizeof(vcpu_info_compat_t) != 64); -+ BUILD_BUG_ON(sizeof(struct compat_vcpu_info) != 64); - #endif - - /* Check definitions in public headers match internal defs. */ -Index: 2007-01-08/xen/arch/x86/time.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/time.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/time.c 2007-01-08 15:19:11.000000000 +0100 -@@ -676,7 +676,7 @@ static inline void __update_vcpu_system_ - struct vcpu_time_info *u; - - t = &this_cpu(cpu_time); -- u = &v->vcpu_info->time; -+ u = &vcpu_info(v, time); - - version_update_begin(&u->version); - -@@ -690,7 +690,7 @@ static inline void __update_vcpu_system_ - - void update_vcpu_system_time(struct vcpu *v) - { -- if ( v->vcpu_info->time.tsc_timestamp != -+ if ( vcpu_info(v, time.tsc_timestamp) != - this_cpu(cpu_time).local_tsc_stamp ) - __update_vcpu_system_time(v); - } -@@ -698,10 +698,10 @@ void update_vcpu_system_time(struct vcpu - void update_domain_wallclock_time(struct domain *d) - { - spin_lock(&wc_lock); -- version_update_begin(&d->shared_info->wc_version); -- d->shared_info->wc_sec = wc_sec + d->time_offset_seconds; -- d->shared_info->wc_nsec = wc_nsec; -- version_update_end(&d->shared_info->wc_version); -+ version_update_begin(&shared_info(d, wc_version)); -+ shared_info(d, wc_sec) = wc_sec + d->time_offset_seconds; -+ shared_info(d, wc_nsec) = wc_nsec; -+ version_update_end(&shared_info(d, wc_version)); - spin_unlock(&wc_lock); - } - -Index: 2007-01-08/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/traps.c 2006-12-18 09:43:08.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/traps.c 2007-01-08 15:19:11.000000000 +0100 -@@ -58,6 +58,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -681,7 +682,7 @@ void propagate_page_fault(unsigned long - struct trap_bounce *tb = &v->arch.trap_bounce; - - v->arch.guest_context.ctrlreg[2] = addr; -- v->vcpu_info->arch.cr2 = addr; -+ arch_set_cr2(v, addr); - - /* Re-set error_code.user flag appropriately for the guest. */ - error_code &= ~PFEC_user_mode; -@@ -1406,7 +1407,7 @@ static int emulate_privileged_op(struct - - case 2: /* Write CR2 */ - v->arch.guest_context.ctrlreg[2] = *reg; -- v->vcpu_info->arch.cr2 = *reg; -+ arch_set_cr2(v, *reg); - break; - - case 3: /* Write CR3 */ -@@ -1617,7 +1618,7 @@ static void nmi_dom0_report(unsigned int - if ( ((d = dom0) == NULL) || ((v = d->vcpu[0]) == NULL) ) - return; - -- set_bit(reason_idx, &d->shared_info->arch.nmi_reason); -+ set_bit(reason_idx, nmi_reason(d)); - - if ( test_and_set_bit(_VCPUF_nmi_pending, &v->vcpu_flags) ) - raise_softirq(NMI_SOFTIRQ); /* not safe to wake up a vcpu here */ -Index: 2007-01-08/xen/arch/x86/x86_64/asm-offsets.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/asm-offsets.c 2006-12-18 09:43:08.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/asm-offsets.c 2007-01-08 15:19:11.000000000 +0100 -@@ -7,6 +7,9 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - #include - #include - -@@ -96,9 +99,15 @@ void __dummy__(void) - OFFSET(VMCB_tsc_offset, struct vmcb_struct, tsc_offset); - BLANK(); - -- OFFSET(VCPUINFO_upcall_pending, vcpu_info_t, evtchn_upcall_pending); -- OFFSET(VCPUINFO_upcall_mask, vcpu_info_t, evtchn_upcall_mask); -+ OFFSET(VCPUINFO_upcall_pending, struct vcpu_info, evtchn_upcall_pending); -+ OFFSET(VCPUINFO_upcall_mask, struct vcpu_info, evtchn_upcall_mask); -+ BLANK(); -+ -+#ifdef CONFIG_COMPAT -+ OFFSET(COMPAT_VCPUINFO_upcall_pending, struct compat_vcpu_info, evtchn_upcall_pending); -+ OFFSET(COMPAT_VCPUINFO_upcall_mask, struct compat_vcpu_info, evtchn_upcall_mask); - BLANK(); -+#endif - - OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu); - DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info)); -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:19:11.000000000 +0100 -@@ -69,9 +69,9 @@ compat_test_all_events: - jc compat_process_nmi - compat_test_guest_events: - movq VCPU_vcpu_info(%rbx),%rax -- testb $0xFF,VCPUINFO_upcall_mask(%rax) -+ testb $0xFF,COMPAT_VCPUINFO_upcall_mask(%rax) - jnz compat_restore_all_guest -- testb $0xFF,VCPUINFO_upcall_pending(%rax) -+ testb $0xFF,COMPAT_VCPUINFO_upcall_pending(%rax) - jz compat_restore_all_guest - /*compat_process_guest_events:*/ - sti -@@ -189,10 +189,10 @@ CFLT4: mov UREGS_ss+8(%rsp),%fs - movb TRAPBOUNCE_flags(%rdx),%cl - subl $3*4,%esi - movq VCPU_vcpu_info(%rbx),%rax -- pushq VCPUINFO_upcall_mask(%rax) -+ pushq COMPAT_VCPUINFO_upcall_mask(%rax) - testb $TBF_INTERRUPT,%cl - setnz %ch # TBF_INTERRUPT -> set upcall mask -- orb %ch,VCPUINFO_upcall_mask(%rax) -+ orb %ch,COMPAT_VCPUINFO_upcall_mask(%rax) - popq %rax - shll $16,%eax # Bits 16-23: saved_upcall_mask - movw UREGS_cs+8(%rsp),%ax # Bits 0-15: CS -Index: 2007-01-08/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/traps.c 2007-01-08 15:19:11.000000000 +0100 -@@ -118,7 +118,7 @@ unsigned int compat_iret(void) - clear_bit(_VCPUF_nmi_masked, ¤t->vcpu_flags); - - /* Restore upcall mask from supplied EFLAGS.IF. */ -- current->vcpu_info->evtchn_upcall_mask = !(eflags & X86_EFLAGS_IF); -+ vcpu_info(current, evtchn_upcall_mask) = !(eflags & X86_EFLAGS_IF); - - /* - * The hypercall exit path will overwrite EAX with this return -Index: 2007-01-08/xen/arch/x86/x86_64/traps.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/traps.c 2006-12-18 09:43:08.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/traps.c 2007-01-08 15:19:11.000000000 +0100 -@@ -17,6 +17,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -52,7 +53,7 @@ void show_registers(struct cpu_user_regs - if ( guest_mode(regs) ) - { - context = "guest"; -- fault_crs[2] = current->vcpu_info->arch.cr2; -+ fault_crs[2] = arch_get_cr2(current); - } - else - { -@@ -234,7 +235,7 @@ unsigned long do_iret(void) - clear_bit(_VCPUF_nmi_masked, ¤t->vcpu_flags); - - /* Restore upcall mask from supplied EFLAGS.IF. */ -- current->vcpu_info->evtchn_upcall_mask = !(iret_saved.rflags & EF_IE); -+ vcpu_info(current, evtchn_upcall_mask) = !(iret_saved.rflags & EF_IE); - - /* Saved %rax gets written back to regs->rax in entry.S. */ - return iret_saved.rax; -Index: 2007-01-08/xen/common/compat/xlat.c -=================================================================== ---- 2007-01-08.orig/xen/common/compat/xlat.c 2007-01-08 15:18:32.000000000 +0100 -+++ 2007-01-08/xen/common/compat/xlat.c 2007-01-08 15:19:11.000000000 +0100 -@@ -21,6 +21,10 @@ void xlat_start_info(struct start_info * - CHECK_dom0_vga_console_info; - #undef dom0_vga_console_info - -+#define xen_vcpu_time_info vcpu_time_info -+CHECK_vcpu_time_info; -+#undef xen_vcpu_time_info -+ - /* - * Local variables: - * mode: C -Index: 2007-01-08/xen/common/domain.c -=================================================================== ---- 2007-01-08.orig/xen/common/domain.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/common/domain.c 2007-01-08 15:19:11.000000000 +0100 -@@ -90,7 +90,7 @@ struct vcpu *alloc_vcpu( - - v->domain = d; - v->vcpu_id = vcpu_id; -- v->vcpu_info = &d->shared_info->vcpu_info[vcpu_id]; -+ v->vcpu_info = shared_info_addr(d, vcpu_info[vcpu_id]); - spin_lock_init(&v->pause_lock); - - v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline; -Index: 2007-01-08/xen/common/event_channel.c -=================================================================== ---- 2007-01-08.orig/xen/common/event_channel.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/common/event_channel.c 2007-01-08 15:19:11.000000000 +0100 -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - #include - -@@ -33,7 +34,7 @@ - #define bucket_from_port(d,p) \ - ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET]) - #define port_is_valid(d,p) \ -- (((p) >= 0) && ((p) < MAX_EVTCHNS) && \ -+ (((p) >= 0) && ((p) < MAX_EVTCHNS(d)) && \ - (bucket_from_port(d,p) != NULL)) - #define evtchn_from_port(d,p) \ - (&(bucket_from_port(d,p))[(p)&(EVTCHNS_PER_BUCKET-1)]) -@@ -82,7 +83,7 @@ static int get_free_port(struct domain * - if ( evtchn_from_port(d, port)->state == ECS_FREE ) - return port; - -- if ( port == MAX_EVTCHNS ) -+ if ( port == MAX_EVTCHNS(d) ) - return -ENOSPC; - - chn = xmalloc_array(struct evtchn, EVTCHNS_PER_BUCKET); -@@ -517,12 +518,12 @@ void evtchn_set_pending(struct vcpu *v, - * others may require explicit memory barriers. - */ - -- if ( test_and_set_bit(port, s->evtchn_pending) ) -+ if ( test_and_set_bit(port, __shared_info_addr(d, s, evtchn_pending)) ) - return; - -- if ( !test_bit (port, s->evtchn_mask) && -- !test_and_set_bit(port / BITS_PER_LONG, -- &v->vcpu_info->evtchn_pending_sel) ) -+ if ( !test_bit (port, __shared_info_addr(d, s, evtchn_mask)) && -+ !test_and_set_bit(port / BITS_PER_GUEST_LONG(d), -+ vcpu_info_addr(v, evtchn_pending_sel)) ) - { - vcpu_mark_events_pending(v); - } -@@ -720,10 +721,10 @@ static long evtchn_unmask(evtchn_unmask_ - * These operations must happen in strict order. Based on - * include/xen/event.h:evtchn_set_pending(). - */ -- if ( test_and_clear_bit(port, s->evtchn_mask) && -- test_bit (port, s->evtchn_pending) && -- !test_and_set_bit (port / BITS_PER_LONG, -- &v->vcpu_info->evtchn_pending_sel) ) -+ if ( test_and_clear_bit(port, __shared_info_addr(d, s, evtchn_mask)) && -+ test_bit (port, __shared_info_addr(d, s, evtchn_pending)) && -+ !test_and_set_bit (port / BITS_PER_GUEST_LONG(d), -+ vcpu_info_addr(v, evtchn_pending_sel)) ) - { - vcpu_mark_events_pending(v); - } -Index: 2007-01-08/xen/common/kernel.c -=================================================================== ---- 2007-01-08.orig/xen/common/kernel.c 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/common/kernel.c 2007-01-08 15:19:11.000000000 +0100 -@@ -16,6 +16,9 @@ - #include - #include - #include -+#ifdef CONFIG_X86 -+#include -+#endif - - #ifndef COMPAT - -@@ -253,7 +256,7 @@ long register_guest_nmi_callback(unsigne - * If no handler was registered we can 'lose the NMI edge'. Re-assert it - * now. - */ -- if ( d->shared_info->arch.nmi_reason != 0 ) -+ if ( arch_get_nmi_reason(d) != 0 ) - set_bit(_VCPUF_nmi_pending, &v->vcpu_flags); - #endif - -Index: 2007-01-08/xen/common/keyhandler.c -=================================================================== ---- 2007-01-08.orig/xen/common/keyhandler.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/common/keyhandler.c 2007-01-08 15:19:11.000000000 +0100 -@@ -12,6 +12,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -171,8 +172,8 @@ static void dump_domains(unsigned char k - v->vcpu_id, v->processor, - test_bit(_VCPUF_running, &v->vcpu_flags) ? 'T':'F', - v->vcpu_flags, -- v->vcpu_info->evtchn_upcall_pending, -- v->vcpu_info->evtchn_upcall_mask); -+ vcpu_info(v, evtchn_upcall_pending), -+ vcpu_info(v, evtchn_upcall_mask)); - cpuset_print(cpuset, sizeof(cpuset), v->vcpu_dirty_cpumask); - printk("dirty_cpus=%s ", cpuset); - cpuset_print(cpuset, sizeof(cpuset), v->cpu_affinity); -@@ -181,11 +182,11 @@ static void dump_domains(unsigned char k - printk(" Notifying guest (virq %d, port %d, stat %d/%d/%d)\n", - VIRQ_DEBUG, v->virq_to_evtchn[VIRQ_DEBUG], - test_bit(v->virq_to_evtchn[VIRQ_DEBUG], -- d->shared_info->evtchn_pending), -+ shared_info_addr(d, evtchn_pending)), - test_bit(v->virq_to_evtchn[VIRQ_DEBUG], -- d->shared_info->evtchn_mask), -- test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_LONG, -- &v->vcpu_info->evtchn_pending_sel)); -+ shared_info_addr(d, evtchn_mask)), -+ test_bit(v->virq_to_evtchn[VIRQ_DEBUG]/BITS_PER_GUEST_LONG(d), -+ vcpu_info_addr(v, evtchn_pending_sel))); - send_guest_vcpu_virq(v, VIRQ_DEBUG); - } - } -Index: 2007-01-08/xen/common/schedule.c -=================================================================== ---- 2007-01-08.orig/xen/common/schedule.c 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/common/schedule.c 2007-01-08 15:19:11.000000000 +0100 -@@ -277,10 +277,11 @@ static long do_block(void) - - static long do_poll(struct sched_poll *sched_poll) - { -- struct vcpu *v = current; -- evtchn_port_t port; -- long rc = 0; -- unsigned int i; -+ struct vcpu *v = current; -+ struct domain *d = v->domain; -+ evtchn_port_t port; -+ long rc = 0; -+ unsigned int i; - - /* Fairly arbitrary limit. */ - if ( sched_poll->nr_ports > 128 ) -@@ -292,7 +293,7 @@ static long do_poll(struct sched_poll *s - /* These operations must occur in order. */ - set_bit(_VCPUF_blocked, &v->vcpu_flags); - set_bit(_VCPUF_polling, &v->vcpu_flags); -- set_bit(_DOMF_polling, &v->domain->domain_flags); -+ set_bit(_DOMF_polling, &d->domain_flags); - - /* Check for events /after/ setting flags: avoids wakeup waiting race. */ - for ( i = 0; i < sched_poll->nr_ports; i++ ) -@@ -302,18 +303,18 @@ static long do_poll(struct sched_poll *s - goto out; - - rc = -EINVAL; -- if ( port >= MAX_EVTCHNS ) -+ if ( port >= MAX_EVTCHNS(d) ) - goto out; - - rc = 0; -- if ( test_bit(port, v->domain->shared_info->evtchn_pending) ) -+ if ( test_bit(port, shared_info_addr(d, evtchn_pending)) ) - goto out; - } - - if ( sched_poll->timeout != 0 ) - set_timer(&v->poll_timer, sched_poll->timeout); - -- TRACE_2D(TRC_SCHED_BLOCK, v->domain->domain_id, v->vcpu_id); -+ TRACE_2D(TRC_SCHED_BLOCK, d->domain_id, v->vcpu_id); - raise_softirq(SCHEDULE_SOFTIRQ); - - return 0; -Index: 2007-01-08/xen/include/Makefile -=================================================================== ---- 2007-01-08.orig/xen/include/Makefile 2007-01-08 15:18:58.000000000 +0100 -+++ 2007-01-08/xen/include/Makefile 2007-01-08 15:19:11.000000000 +0100 -@@ -32,6 +32,7 @@ compat/%.h: compat/%.i Makefile - sed -e 's,__InClUdE__,#include,' \ - -e 's,"xen-compat.h",,' \ - -e 's,\(struct\|union\|enum\)[[:space:]]\+\(xen_\?\)\?\([[:alpha:]_]\),\1 compat_\3,g' \ -+ -e 's,@KeeP@,,g' \ - -e 's,_t\([^[:alnum:]_]\|$$\),_compat_t\1,g' \ - -e 's,\(8\|16\|32\|64\)_compat_t\([^[:alnum:]_]\|$$\),\1_t\2,g' \ - -e 's,\(^\|[^[:alnum:]_]\)xen_\?\([[:alnum:]_]*\)_compat_t\([^[:alnum:]_]\|$$\),\1compat_\2_t\3,g' \ -@@ -46,13 +47,15 @@ compat/%.h: compat/%.i Makefile - compat/%.i: compat/%.c Makefile - $(CPP) $(CFLAGS) $(cppflags-y) -o $@ $< - --compat/%.c: public/%.h Makefile -+compat/%.c: public/%.h xlat.lst Makefile - mkdir -p $(@D) - grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \ - sed -e 's,^[[:space:]]*#[[:space:]]*include[[:space:]]\+,__InClUdE__ ,' \ - -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:upper:]_]*_GUEST_HANDLE\),#define HIDE_\1,' \ - -e 's,^[[:space:]]*#[[:space:]]*define[[:space:]]\+\([[:lower:]_]*_guest_handle\),#define hide_\1,' \ - -e 's,XEN_GUEST_HANDLE\(_[[:xdigit:]]\+\)\?,COMPAT_HANDLE,g' \ -+ $(foreach n,$(shell sed -n 's,^[[:space:]]*?[[:space:]]\+\([[:alnum:]_]*\)[[:space:]].*,\1,p' xlat.lst), \ -+ -e 's,\(struct\|union\)[[:space:]]\+\(xen_\?\)\?$n[[:space:]]\+\([[:alpha:]_]\),\1 @KeeP@\2$n \3,g') \ - >$@.new - mv -f $@.new $@ - -Index: 2007-01-08/xen/include/asm-ia64/shared.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/asm-ia64/shared.h 2007-01-08 15:19:11.000000000 +0100 -@@ -0,0 +1,4 @@ -+#ifndef __XEN_ASM_SHARED_H__ -+#define __XEN_ASM_SHARED_H__ -+ -+#endif /* __XEN_ASM_SHARED_H__ */ -Index: 2007-01-08/xen/include/asm-powerpc/shared.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/asm-powerpc/shared.h 2007-01-08 15:19:11.000000000 +0100 -@@ -0,0 +1,4 @@ -+#ifndef __XEN_ASM_SHARED_H__ -+#define __XEN_ASM_SHARED_H__ -+ -+#endif /* __XEN_ASM_SHARED_H__ */ -Index: 2007-01-08/xen/include/asm-x86/shared.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/asm-x86/shared.h 2007-01-08 15:19:11.000000000 +0100 -@@ -0,0 +1,78 @@ -+#ifndef __XEN_X86_SHARED_H__ -+#define __XEN_X86_SHARED_H__ -+ -+#ifdef CONFIG_COMPAT -+ -+#define nmi_reason(d) (!IS_COMPAT(d) ? \ -+ (void *)&(d)->shared_info->native.arch.nmi_reason : \ -+ (void *)&(d)->shared_info->compat.arch.nmi_reason) -+ -+#define GET_SET_SHARED(type, field) \ -+static inline type arch_get_##field(const struct domain *d) \ -+{ \ -+ return !IS_COMPAT(d) ? \ -+ d->shared_info->native.arch.field : \ -+ d->shared_info->compat.arch.field; \ -+} \ -+static inline void arch_set_##field(struct domain *d, \ -+ type val) \ -+{ \ -+ if ( !IS_COMPAT(d) ) \ -+ d->shared_info->native.arch.field = val; \ -+ else \ -+ d->shared_info->compat.arch.field = val; \ -+} -+ -+#define GET_SET_VCPU(type, field) \ -+static inline type arch_get_##field(const struct vcpu *v) \ -+{ \ -+ return !IS_COMPAT(v->domain) ? \ -+ v->vcpu_info->native.arch.field : \ -+ v->vcpu_info->compat.arch.field; \ -+} \ -+static inline void arch_set_##field(struct vcpu *v, \ -+ type val) \ -+{ \ -+ if ( !IS_COMPAT(v->domain) ) \ -+ v->vcpu_info->native.arch.field = val; \ -+ else \ -+ v->vcpu_info->compat.arch.field = val; \ -+} -+ -+#else -+ -+#define nmi_reason(d) ((void *)&(d)->shared_info->arch.nmi_reason) -+ -+#define GET_SET_SHARED(type, field) \ -+static inline type arch_get_##field(const struct domain *d) \ -+{ \ -+ return d->shared_info->arch.field; \ -+} \ -+static inline void arch_set_##field(struct domain *d, \ -+ type val) \ -+{ \ -+ d->shared_info->arch.field = val; \ -+} -+ -+#define GET_SET_VCPU(type, field) \ -+static inline type arch_get_##field(const struct vcpu *v) \ -+{ \ -+ return v->vcpu_info->arch.field; \ -+} \ -+static inline void arch_set_##field(struct vcpu *v, \ -+ type val) \ -+{ \ -+ v->vcpu_info->arch.field = val; \ -+} -+#endif -+ -+GET_SET_SHARED(unsigned long, max_pfn) -+GET_SET_SHARED(xen_pfn_t, pfn_to_mfn_frame_list_list) -+GET_SET_SHARED(unsigned long, nmi_reason) -+ -+GET_SET_VCPU(unsigned long, cr2) -+ -+#undef GET_SET_VCPU -+#undef GET_SET_SHARED -+ -+#endif /* __XEN_X86_SHARED_H__ */ -Index: 2007-01-08/xen/include/asm-x86/compat.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/compat.h 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/compat.h 2007-01-08 15:19:11.000000000 +0100 -@@ -2,5 +2,7 @@ - * compat.h - */ - -+#define COMPAT_BITS_PER_LONG 32 -+ - typedef uint32_t compat_ptr_t; - typedef unsigned long full_ptr_t; -Index: 2007-01-08/xen/include/asm-x86/event.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/event.h 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/event.h 2007-01-08 15:19:11.000000000 +0100 -@@ -9,6 +9,8 @@ - #ifndef __ASM_EVENT_H__ - #define __ASM_EVENT_H__ - -+#include -+ - static inline void vcpu_kick(struct vcpu *v) - { - /* -@@ -28,7 +30,7 @@ static inline void vcpu_kick(struct vcpu - - static inline void vcpu_mark_events_pending(struct vcpu *v) - { -- if ( !test_and_set_bit(0, &v->vcpu_info->evtchn_upcall_pending) ) -+ if ( !test_and_set_bit(0, &vcpu_info(v, evtchn_upcall_pending)) ) - vcpu_kick(v); - } - -@@ -36,23 +38,23 @@ static inline int local_events_need_deli - { - struct vcpu *v = current; - /* Note: Bitwise operations result in fast code with no branches. */ -- return (!!v->vcpu_info->evtchn_upcall_pending & -- !v->vcpu_info->evtchn_upcall_mask); -+ return (!!vcpu_info(v, evtchn_upcall_pending) & -+ !vcpu_info(v, evtchn_upcall_mask)); - } - - static inline int local_event_delivery_is_enabled(void) - { -- return !current->vcpu_info->evtchn_upcall_mask; -+ return !vcpu_info(current, evtchn_upcall_mask); - } - - static inline void local_event_delivery_disable(void) - { -- current->vcpu_info->evtchn_upcall_mask = 1; -+ vcpu_info(current, evtchn_upcall_mask) = 1; - } - - static inline void local_event_delivery_enable(void) - { -- current->vcpu_info->evtchn_upcall_mask = 0; -+ vcpu_info(current, evtchn_upcall_mask) = 0; - } - - /* No arch specific virq definition now. Default to global. */ -Index: 2007-01-08/xen/include/public/xen.h -=================================================================== ---- 2007-01-08.orig/xen/include/public/xen.h 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/xen/include/public/xen.h 2007-01-08 15:19:11.000000000 +0100 -@@ -408,7 +408,9 @@ struct vcpu_info { - struct arch_vcpu_info arch; - struct vcpu_time_info time; - }; /* 64 bytes (x86) */ -+#ifndef __XEN__ - typedef struct vcpu_info vcpu_info_t; -+#endif - - /* - * Xen/kernel shared data -- pointer provided in start_info. -@@ -466,7 +468,9 @@ struct shared_info { - struct arch_shared_info arch; - - }; -+#ifndef __XEN__ - typedef struct shared_info shared_info_t; -+#endif - - /* - * Start-of-day memory layout for the initial domain (DOM0): -Index: 2007-01-08/xen/include/xen/compat.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/compat.h 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/include/xen/compat.h 2007-01-08 15:19:11.000000000 +0100 -@@ -162,6 +162,12 @@ extern int compat_disabled; - struct start_info; - void xlat_start_info(struct start_info *, enum XLAT_start_info_console); - -+#define BITS_PER_GUEST_LONG(d) (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG) -+ -+#else -+ -+#define BITS_PER_GUEST_LONG(d) BITS_PER_LONG -+ - #endif - - #endif /* __XEN_COMPAT_H__ */ -Index: 2007-01-08/xen/include/xen/sched.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/sched.h 2007-01-08 14:45:40.000000000 +0100 -+++ 2007-01-08/xen/include/xen/sched.h 2007-01-08 15:19:11.000000000 +0100 -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -23,9 +24,15 @@ extern rwlock_t domlist_lock; - /* A global pointer to the initial domain (DOM0). */ - extern struct domain *dom0; - --#define MAX_EVTCHNS NR_EVENT_CHANNELS -+#ifndef CONFIG_COMPAT -+#define MAX_EVTCHNS(d) NR_EVENT_CHANNELS -+#else -+#define MAX_EVTCHNS(d) (!IS_COMPAT(d) ? \ -+ NR_EVENT_CHANNELS : \ -+ sizeof(unsigned int) * sizeof(unsigned int) * 64) -+#endif - #define EVTCHNS_PER_BUCKET 128 --#define NR_EVTCHN_BUCKETS (MAX_EVTCHNS / EVTCHNS_PER_BUCKET) -+#define NR_EVTCHN_BUCKETS (NR_EVENT_CHANNELS / EVTCHNS_PER_BUCKET) - - struct evtchn - { -Index: 2007-01-08/xen/include/xen/shared.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/xen/shared.h 2007-01-08 15:19:11.000000000 +0100 -@@ -0,0 +1,54 @@ -+#ifndef __XEN_SHARED_H__ -+#define __XEN_SHARED_H__ -+ -+#include -+ -+#ifdef CONFIG_COMPAT -+ -+#include -+ -+typedef union { -+ struct shared_info native; -+ struct compat_shared_info compat; -+} shared_info_t; -+ -+#define __shared_info(d, s, field) (*(!IS_COMPAT(d) ? \ -+ &(s)->native.field : \ -+ &(s)->compat.field)) -+#define __shared_info_addr(d, s, field) (!IS_COMPAT(d) ? \ -+ (void *)&(s)->native.field : \ -+ (void *)&(s)->compat.field) -+ -+#define shared_info(d, field) __shared_info(d, (d)->shared_info, field) -+#define shared_info_addr(d, field) __shared_info_addr(d, (d)->shared_info, field) -+ -+typedef union { -+ struct vcpu_info native; -+ struct compat_vcpu_info compat; -+} vcpu_info_t; -+ -+#define vcpu_info(v, field) (*(!IS_COMPAT((v)->domain) ? \ -+ &(v)->vcpu_info->native.field : \ -+ &(v)->vcpu_info->compat.field)) -+#define vcpu_info_addr(v, field) (!IS_COMPAT((v)->domain) ? \ -+ (void *)&(v)->vcpu_info->native.field : \ -+ (void *)&(v)->vcpu_info->compat.field) -+ -+#else -+ -+typedef struct shared_info shared_info_t; -+ -+#define __shared_info(d, s, field) ((s)->field) -+#define __shared_info_addr(d, s, field) ((void *)&(s)->field) -+ -+#define shared_info(d, field) ((d)->shared_info->field) -+#define shared_info_addr(d, field) ((void *)&(d)->shared_info->field) -+ -+typedef struct vcpu_info vcpu_info_t; -+ -+#define vcpu_info(v, field) ((v)->vcpu_info->field) -+#define vcpu_info_addr(v, field) ((void *)&(v)->vcpu_info->field) -+ -+#endif -+ -+#endif /* __XEN_SHARED_H__ */ -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:18:32.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:19:11.000000000 +0100 -@@ -3,3 +3,4 @@ - # ? - needs checking - ? dom0_vga_console_info xen.h - ! start_info xen.h -+? vcpu_time_info xen.h diff --git a/32on64-startup.patch b/32on64-startup.patch deleted file mode 100644 index 737ce0c..0000000 --- a/32on64-startup.patch +++ /dev/null @@ -1,584 +0,0 @@ -Handle the creation of startup info for compatibility mode guests. This -includes a script to auto-generate checking or translation code between -native and compatibility mode hypercall argument structures. - -Index: 2007-01-08/Config.mk -=================================================================== ---- 2007-01-08.orig/Config.mk 2007-01-08 15:34:16.000000000 +0100 -+++ 2007-01-08/Config.mk 2007-01-08 15:18:32.000000000 +0100 -@@ -11,6 +11,8 @@ XEN_OS ?= $(shell uname -s) - - CONFIG_$(XEN_OS) := y - -+SHELL ?= /bin/sh -+ - # Tools to run on system hosting the build - HOSTCC = gcc - HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer -Index: 2007-01-08/xen/arch/x86/domain_build.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain_build.c 2007-01-08 15:34:55.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain_build.c 2007-01-08 15:35:20.000000000 +0100 -@@ -19,6 +19,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -848,6 +849,11 @@ int construct_dom0(struct domain *d, - si->console.dom0.info_size = sizeof(struct dom0_vga_console_info); - } - -+#ifdef CONFIG_COMPAT -+ if ( IS_COMPAT(d) ) -+ xlat_start_info(si, XLAT_start_info_console_dom0); -+#endif -+ - /* Reinstate the caller's page tables. */ - write_ptbase(current); - local_irq_enable(); -Index: 2007-01-08/xen/arch/x86/setup.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/setup.c 2007-01-08 14:45:40.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/setup.c 2007-01-08 15:18:32.000000000 +0100 -@@ -18,6 +18,10 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#include -+#endif - #include - #include - #include -@@ -546,6 +550,14 @@ void __init __start_xen(multiboot_info_t - BUILD_BUG_ON(sizeof(shared_info_t) > PAGE_SIZE); - BUILD_BUG_ON(sizeof(vcpu_info_t) != 64); - -+#ifdef CONFIG_COMPAT -+ BUILD_BUG_ON(sizeof(((struct compat_platform_op *)0)->u) != -+ sizeof(((struct compat_platform_op *)0)->u.pad)); -+ BUILD_BUG_ON(sizeof(start_info_compat_t) > PAGE_SIZE); -+ BUILD_BUG_ON(sizeof(shared_info_compat_t) > PAGE_SIZE); -+ BUILD_BUG_ON(sizeof(vcpu_info_compat_t) != 64); -+#endif -+ - /* Check definitions in public headers match internal defs. */ - BUILD_BUG_ON(__HYPERVISOR_VIRT_START != HYPERVISOR_VIRT_START); - #ifdef HYPERVISOR_VIRT_END -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/compat/Makefile 2007-01-08 15:17:29.000000000 +0100 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 15:18:32.000000000 +0100 -@@ -1,4 +1,5 @@ - obj-y += kernel.o -+obj-y += xlat.o - - # extra dependencies - kernel.o: ../kernel.c -Index: 2007-01-08/xen/common/compat/xlat.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/xlat.c 2007-01-08 15:18:32.000000000 +0100 -@@ -0,0 +1,32 @@ -+/****************************************************************************** -+ * xlat.c -+ */ -+ -+#include -+#include -+#include -+#include -+ -+/* In-place translation functons: */ -+void xlat_start_info(struct start_info *native, -+ enum XLAT_start_info_console console) -+{ -+ struct compat_start_info *compat = (void *)native; -+ -+ BUILD_BUG_ON(sizeof(*native) < sizeof(*compat)); -+ XLAT_start_info(compat, native); -+} -+ -+#define xen_dom0_vga_console_info dom0_vga_console_info -+CHECK_dom0_vga_console_info; -+#undef dom0_vga_console_info -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/include/Makefile -=================================================================== ---- 2007-01-08.orig/xen/include/Makefile 2007-01-08 15:18:26.000000000 +0100 -+++ 2007-01-08/xen/include/Makefile 2007-01-08 15:18:58.000000000 +0100 -@@ -5,7 +5,7 @@ compat-arch-$(CONFIG_X86) := x86 - - headers-y := $(shell echo public/*.h | sed -e 's,[^[:space:]]*-[^[:space:]]*,,g' -e 's,public/,compat/,g') - headers-y := $(filter-out %/dom0_ops.h,$(headers-y)) --headers-y += compat/arch-$(compat-subarch-y).h -+headers-y += compat/arch-$(compat-subarch-y).h compat/xlat.h - headers-y += compat/arch-$(compat-arch-y)/xen.h - headers-y += compat/arch-$(compat-arch-y)/xen-$(compat-subarch-y).h - -@@ -56,5 +56,12 @@ compat/%.c: public/%.h Makefile - >$@.new - mv -f $@.new $@ - -+compat/xlat.h: xlat.lst $(filter-out compat/xlat.h,$(headers-y)) $(BASEDIR)/tools/get-fields.sh Makefile -+ grep -v '^[[:space:]]*#' xlat.lst | \ -+ while read what name hdr; do \ -+ $(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $$(echo compat/$$hdr | sed -e 's,@arch@,$(compat-arch-y),g' -e 's,@subarch@,$(compat-subarch-y),g') || exit $$?; \ -+ done >$@.new -+ mv -f $@.new $@ -+ - clean:: - rm -rf compat -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:18:32.000000000 +0100 -@@ -0,0 +1,5 @@ -+# First column indicator: -+# ! - needs translation -+# ? - needs checking -+? dom0_vga_console_info xen.h -+! start_info xen.h -Index: 2007-01-08/xen/tools/get-fields.sh -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/tools/get-fields.sh 2007-01-08 15:18:32.000000000 +0100 -@@ -0,0 +1,425 @@ -+#!/bin/sh -+test -n "$1" -a -n "$2" -a -n "$3" -+set -ef -+ -+get_fields() { -+ local level=1 aggr=0 name= fields= -+ for token in $2 -+ do -+ case "$token" in -+ struct|union) -+ test $level != 1 || aggr=1 fields= name= -+ ;; -+ "{") -+ level=$(expr $level + 1) -+ ;; -+ "}") -+ level=$(expr $level - 1) -+ if [ $level = 1 -a $name = $1 ] -+ then -+ echo "$fields }" -+ return 0 -+ fi -+ ;; -+ [[:alpha:]_]*) -+ test $aggr = 0 -o -n "$name" || name="$token" -+ ;; -+ esac -+ test $aggr = 0 || fields="$fields $token" -+ done -+} -+ -+build_enums() { -+ local level=1 kind= fields= members= named= id= token -+ for token in $2 -+ do -+ case "$token" in -+ struct|union) -+ test $level != 2 || fields=" " -+ kind="$token;$kind" -+ ;; -+ "{") -+ level=$(expr $level + 1) -+ ;; -+ "}") -+ level=$(expr $level - 1) -+ if [ $level = 1 ] -+ then -+ if [ "${kind%%;*}" = union ] -+ then -+ echo -+ echo "enum XLAT_$1 {" -+ for m in $members -+ do -+ echo " XLAT_${1}_$m," -+ done -+ echo "};" -+ fi -+ return 0 -+ elif [ $level = 2 ] -+ then -+ named='?' -+ fi -+ ;; -+ [[:alpha:]]*) -+ id=$token -+ if [ -n "$named" -a -n "${kind#*;}" ] -+ then -+ build_enums ${1}_$token "$fields" -+ named='!' -+ fi -+ ;; -+ ",") -+ test $level != 2 || members="$members $id" -+ ;; -+ ";") -+ test $level != 2 || members="$members $id" -+ test -z "$named" || kind=${kind#*;} -+ named= -+ ;; -+ esac -+ test -z "$fields" || fields="$fields $token" -+ done -+} -+ -+handle_field() { -+ if [ -z "$5" ] -+ then -+ echo " \\" -+ if [ -z "$4" ] -+ then -+ echo -n "$1(_d_)->$3 = (_s_)->$3;" -+ else -+ echo -n "$1XLAT_${2}_HNDL_$(echo $3 | sed 's,\.,_,g')(_d_, _s_);" -+ fi -+ elif [ -z "$(echo "$5" | sed 's,[^{}],,g')" ] -+ then -+ local tag=$(echo "$5" | sed 's,[[:space:]]*\(struct\|union\)[[:space:]]\+\(compat_\)\?\([[:alnum:]_]\+\)[[:space:]].*,\3,') -+ echo " \\" -+ echo -n "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);" -+ else -+ local level=1 kind= fields= id= array= arrlvl=1 array_type= type= token -+ for token in $5 -+ do -+ case "$token" in -+ struct|union) -+ test $level != 2 || fields=" " -+ if [ $level == 1 ] -+ then -+ kind=$token -+ if [ $kind = union ] -+ then -+ echo " \\" -+ echo -n "${1}switch ($(echo $3 | sed 's,\.,_,g')) {" -+ fi -+ fi -+ ;; -+ "{") -+ level=$(expr $level + 1) id= -+ ;; -+ "}") -+ level=$(expr $level - 1) id= -+ if [ $level == 1 -a $kind = union ] -+ then -+ echo " \\" -+ echo -n "$1}" -+ fi -+ ;; -+ "[") -+ if [ $level != 2 -o $arrlvl != 1 ] -+ then -+ : -+ elif [ -z "$array" ] -+ then -+ array=" " -+ else -+ array="$array;" -+ fi -+ arrlvl=$(expr $arrlvl + 1) -+ ;; -+ "]") -+ arrlvl=$(expr $arrlvl - 1) -+ ;; -+ COMPAT_HANDLE\(*\)) -+ if [ $level == 2 -a -z "$id" ] -+ then -+ type=${token#COMPAT_HANDLE?} -+ type=${type%?} -+ type=${type#compat_} -+ fi -+ ;; -+ compat_domain_handle_t) -+ if [ $level == 2 -a -z "$id" ] -+ then -+ array_type=$token -+ fi -+ ;; -+ [[:alpha:]]*) -+ id=$token -+ ;; -+ [\,\;]) -+ if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ] -+ then -+ if [ $kind = union ] -+ then -+ echo " \\" -+ echo -n "${1}case XLAT_${2}_$(echo $3.$id | sed 's,\.,_,g'):" -+ handle_field "$1 " $2 $3.$id "$type" "$fields" -+ elif [ -z "$array" -a -z "$array_type" ] -+ then -+ handle_field "$1" $2 $3.$id "$type" "$fields" -+ elif [ -z "$array" ] -+ then -+ copy_array " " $3.$id -+ else -+ handle_array "$1" $2 $3.$id "${array#*;}" "$type" "$fields" -+ fi -+ test "$token" != ";" || fields= id= type= -+ array= -+ if [ $kind = union ] -+ then -+ echo " \\" -+ echo -n "$1 break;" -+ fi -+ fi -+ ;; -+ *) -+ if [ -n "$array" ] -+ then -+ array="$array $token" -+ fi -+ ;; -+ esac -+ test -z "$fields" || fields="$fields $token" -+ done -+ fi -+} -+ -+copy_array() { -+ echo " \\" -+ echo "${1}if ((_d_)->$2 != (_s_)->$2) \\" -+ echo -n "$1 memcpy((_d_)->$2, (_s_)->$2, sizeof((_d_)->$2));" -+} -+ -+handle_array() { -+ local i="i$(echo $4 | sed 's,[^;], ,g' | wc -w)" -+ echo " \\" -+ echo "$1{ \\" -+ echo "$1 unsigned int $i; \\" -+ echo -n "$1 for ($i = 0; $i < "${4%%;*}"; ++$i) {" -+ if [ "$4" = "${4#*;}" ] -+ then -+ handle_field "$1 " $2 $3[$i] "$5" "$6" -+ else -+ handle_array "$1 " $2 $3[$i] "${4#*;}" "$5" "$6" -+ fi -+ echo " \\" -+ echo "$1 } \\" -+ echo -n "$1}" -+} -+ -+build_body() { -+ echo -+ echo -n "#define XLAT_$1(_d_, _s_)" -+ local level=1 fields= id= array= arrlvl=1 array_type= type= token -+ for token in $2 -+ do -+ case "$token" in -+ struct|union) -+ test $level != 2 || fields=" " -+ ;; -+ "{") -+ level=$(expr $level + 1) id= -+ ;; -+ "}") -+ level=$(expr $level - 1) id= -+ ;; -+ "[") -+ if [ $level != 2 -o $arrlvl != 1 ] -+ then -+ : -+ elif [ -z "$array" ] -+ then -+ array=" " -+ else -+ array="$array;" -+ fi -+ arrlvl=$(expr $arrlvl + 1) -+ ;; -+ "]") -+ arrlvl=$(expr $arrlvl - 1) -+ ;; -+ COMPAT_HANDLE\(*\)) -+ if [ $level == 2 -a -z "$id" ] -+ then -+ type=${token#COMPAT_HANDLE?} -+ type=${type%?} -+ type=${type#compat_} -+ fi -+ ;; -+ compat_domain_handle_t) -+ if [ $level == 2 -a -z "$id" ] -+ then -+ array_type=$token -+ fi -+ ;; -+ [[:alpha:]_]*) -+ if [ -n "$array" ] -+ then -+ array="$array $token" -+ else -+ id=$token -+ fi -+ ;; -+ [\,\;]) -+ if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ] -+ then -+ if [ -z "$array" -a -z "$array_type" ] -+ then -+ handle_field " " $1 $id "$type" "$fields" -+ elif [ -z "$array" ] -+ then -+ copy_array " " $id -+ else -+ handle_array " " $1 $id "${array#*;}" "$type" "$fields" -+ fi -+ test "$token" != ";" || fields= id= type= -+ array= -+ fi -+ ;; -+ *) -+ if [ -n "$array" ] -+ then -+ array="$array $token" -+ fi -+ ;; -+ esac -+ test -z "$fields" || fields="$fields $token" -+ done -+ echo "" -+} -+ -+check_field() { -+ if [ -z "$(echo "$4" | sed 's,[^{}],,g')" ] -+ then -+ echo "; \\" -+ local n=$(echo $3 | sed 's,[^.], ,g' | wc -w) -+ if [ -n "$4" ] -+ then -+ for n in $4 -+ do -+ case $n in -+ struct|union) -+ ;; -+ [[:alpha:]_]*) -+ echo -n " CHECK_$n" -+ break -+ ;; -+ *) -+ echo "Malformed compound declaration: '$n'" >&2 -+ exit 1 -+ ;; -+ esac -+ done -+ elif [ $n = 0 ] -+ then -+ echo -n " CHECK_FIELD_($1, $2, $3)" -+ else -+ echo -n " CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | sed 's!\.!, !g'))" -+ fi -+ else -+ local level=1 fields= id= token -+ for token in $4 -+ do -+ case "$token" in -+ struct|union) -+ test $level != 2 || fields=" " -+ ;; -+ "{") -+ level=$(expr $level + 1) id= -+ ;; -+ "}") -+ level=$(expr $level - 1) id= -+ ;; -+ [[:alpha:]]*) -+ id=$token -+ ;; -+ [\,\;]) -+ if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ] -+ then -+ check_field $1 $2 $3.$id "$fields" -+ test "$token" != ";" || fields= id= -+ fi -+ ;; -+ esac -+ test -z "$fields" || fields="$fields $token" -+ done -+ fi -+} -+ -+build_check() { -+ echo -+ echo "#define CHECK_$1 \\" -+ local level=1 fields= kind= id= arrlvl=1 token -+ for token in $2 -+ do -+ case "$token" in -+ struct|union) -+ if [ $level == 1 ] -+ then -+ kind=$token -+ echo -n " CHECK_SIZE_($kind, $1)" -+ elif [ $level == 2 ] -+ then -+ fields=" " -+ fi -+ ;; -+ "{") -+ level=$(expr $level + 1) id= -+ ;; -+ "}") -+ level=$(expr $level - 1) id= -+ ;; -+ "[") -+ arrlvl=$(expr $arrlvl + 1) -+ ;; -+ "]") -+ arrlvl=$(expr $arrlvl - 1) -+ ;; -+ [[:alpha:]_]*) -+ test $level != 2 -o $arrlvl != 1 || id=$token -+ ;; -+ [\,\;]) -+ if [ $level == 2 -a -n "$(echo $id | sed 's,^_pad[[:digit:]]*,,')" ] -+ then -+ check_field $kind $1 $id "$fields" -+ test "$token" != ";" || fields= id= -+ fi -+ ;; -+ esac -+ test -z "$fields" || fields="$fields $token" -+ done -+ echo "" -+} -+ -+fields="$(get_fields $(echo $2 | sed 's,^compat_xen,compat_,') "$(sed -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)")" -+if [ -z "$fields" ] -+then -+ echo "Fields of '$2' not found in '$3'" >&2 -+ exit 1 -+fi -+name=${2#compat_} -+name=${name#xen} -+case "$1" in -+"!") -+ build_enums $name "$fields" -+ build_body $name "$fields" -+ ;; -+"?") -+ build_check $name "$fields" -+ ;; -+*) -+ echo "Invalid translation indicator: '$1'" >&2 -+ exit 1 -+ ;; -+esac diff --git a/32on64-sysctl.patch b/32on64-sysctl.patch deleted file mode 100644 index 9a962f0..0000000 --- a/32on64-sysctl.patch +++ /dev/null @@ -1,312 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_sysctl. - -Index: 2007-01-08/xen/arch/x86/sysctl.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/sysctl.c 2007-01-08 15:04:23.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/sysctl.c 2007-01-08 15:20:32.000000000 +0100 -@@ -25,10 +25,14 @@ - #include - #include - --long arch_do_sysctl( -+#ifndef COMPAT -+typedef long ret_t; -+#endif -+ -+ret_t arch_do_sysctl( - struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) - { -- long ret = 0; -+ ret_t ret = 0; - - switch ( sysctl->cmd ) - { -Index: 2007-01-08/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/Makefile 2007-01-08 15:20:00.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/Makefile 2007-01-08 15:20:32.000000000 +0100 -@@ -7,6 +7,7 @@ obj-$(CONFIG_COMPAT) += compat.o - obj-$(CONFIG_COMPAT) += domain.o - obj-$(CONFIG_COMPAT) += physdev.o - obj-$(CONFIG_COMPAT) += platform_hypercall.o -+obj-$(CONFIG_COMPAT) += sysctl.o - - ifeq ($(CONFIG_COMPAT),y) - # extra dependencies -@@ -15,5 +16,6 @@ entry.o: compat/entry.S - mm.o: compat/mm.c - physdev.o: ../physdev.c - platform_hypercall.o: ../platform_hypercall.c -+sysctl.o: ../sysctl.c - traps.o: compat/traps.c - endif -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:29.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:20:32.000000000 +0100 -@@ -278,7 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_sysctl domain_crash_synchronous - #define compat_domctl domain_crash_synchronous - - ENTRY(compat_hypercall_table) -Index: 2007-01-08/xen/arch/x86/x86_64/sysctl.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/arch/x86/x86_64/sysctl.c 2007-01-08 15:20:32.000000000 +0100 -@@ -0,0 +1,33 @@ -+/****************************************************************************** -+ * Arch-specific compatibility sysctl.c -+ */ -+ -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t); -+#define xen_sysctl compat_sysctl -+#define xen_sysctl_t compat_sysctl_t -+#define arch_do_sysctl(x, h) arch_compat_sysctl(x, _##h) -+ -+#define xen_sysctl_physinfo compat_sysctl_physinfo -+#define xen_sysctl_physinfo_t compat_sysctl_physinfo_t -+ -+#define xen_sysctl_ioport_emulation compat_sysctl_ioport_emulation -+#define xen_sysctl_ioport_emulation_t compat_sysctl_ioport_emulation_t -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+typedef int ret_t; -+ -+#include "../sysctl.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/compat/Makefile 2007-01-08 15:19:20.000000000 +0100 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 15:20:32.000000000 +0100 -@@ -2,8 +2,10 @@ obj-y += domain.o - obj-y += kernel.o - obj-y += memory.o - obj-y += multicall.o -+obj-y += sysctl.o - obj-y += xlat.o - - # extra dependencies - kernel.o: ../kernel.c - multicall.o: ../multicall.c -+sysctl.o: ../sysctl.c -Index: 2007-01-08/xen/common/compat/sysctl.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/sysctl.c 2007-01-08 15:20:32.000000000 +0100 -@@ -0,0 +1,102 @@ -+/****************************************************************************** -+ * compat/sysctl.c -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+DEFINE_XEN_GUEST_HANDLE(compat_sysctl_t); -+#define xen_sysctl compat_sysctl -+#define xen_sysctl_t compat_sysctl_t -+#define do_sysctl(h) compat_sysctl(_##h) -+#define arch_do_sysctl(x, h) arch_compat_sysctl(x, _##h) -+ -+#define xen_sysctl_readconsole compat_sysctl_readconsole -+#define xen_sysctl_readconsole_t compat_sysctl_readconsole_t -+ -+static int compat_tb_control(struct compat_sysctl_tbuf_op *cmp_tbc) -+{ -+ struct xen_sysctl_tbuf_op nat_tbc; -+ int ret; -+ -+#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->bitmap, (_s_)->bitmap) -+ XLAT_sysctl_tbuf_op(&nat_tbc, cmp_tbc); -+#undef XLAT_ctl_cpumap_HNDL_bitmap -+ ret = tb_control(&nat_tbc); -+#define XLAT_ctl_cpumap_HNDL_bitmap(_d_, _s_) ((void)0) -+ XLAT_sysctl_tbuf_op(cmp_tbc, &nat_tbc); -+#undef XLAT_ctl_cpumap_HNDL_bitmap -+ return ret; -+} -+#define xen_sysctl_tbuf_op compat_sysctl_tbuf_op -+#define xen_sysctl_tbuf_op_t compat_sysctl_tbuf_op_t -+#define tb_control(p) compat_tb_control(p) -+ -+#define xen_sysctl_sched_id compat_sysctl_sched_id -+#define xen_sysctl_sched_id_t compat_sysctl_sched_id_t -+ -+static void compat_getdomaininfo(struct domain *d, struct compat_domctl_getdomaininfo *ci) -+{ -+ struct xen_domctl_getdomaininfo ni; -+ -+ getdomaininfo(d, &ni); -+ XLAT_domctl_getdomaininfo(ci, &ni); -+} -+#define xen_sysctl_getdomaininfolist compat_sysctl_getdomaininfolist -+#define xen_sysctl_getdomaininfolist_t compat_sysctl_getdomaininfolist_t -+#define xen_domctl_getdomaininfo compat_domctl_getdomaininfo -+#define xen_domctl_getdomaininfo_t compat_domctl_getdomaininfo_t -+#define getdomaininfo(d, i) compat_getdomaininfo(d, i) -+ -+#ifdef PERF_COUNTERS -+static int compat_perfc_control(struct compat_sysctl_perfc_op *cmp_pc) -+{ -+ CHECK_sysctl_perfc_desc; -+ CHECK_TYPE(sysctl_perfc_val); -+ struct xen_sysctl_perfc_op nat_pc; -+ int ret; -+ -+#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->desc, (_s_)->desc) -+#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_) \ -+ guest_from_compat_handle((_d_)->val, (_s_)->val) -+ XLAT_sysctl_perfc_op(&nat_pc, cmp_pc); -+#undef XLAT_sysctl_perfc_op_HNDL_val -+#undef XLAT_sysctl_perfc_op_HNDL_desc -+ ret = perfc_control(&nat_pc); -+#define XLAT_sysctl_perfc_op_HNDL_desc(_d_, _s_) -+#define XLAT_sysctl_perfc_op_HNDL_val(_d_, _s_) -+ XLAT_sysctl_perfc_op(cmp_pc, &nat_pc); -+#undef XLAT_sysctl_perfc_op_HNDL_val -+#undef XLAT_sysctl_perfc_op_HNDL_desc -+ return ret; -+} -+#define xen_sysctl_perfc_op compat_sysctl_perfc_op -+#define xen_sysctl_perfc_op_t compat_sysctl_perfc_op_t -+#define perfc_control(p) compat_perfc_control(p) -+#endif -+ -+#define COMPAT -+#define _XEN_GUEST_HANDLE(t) XEN_GUEST_HANDLE(t) -+#define _u_sysctl u_sysctl -+#undef guest_handle_cast -+#define guest_handle_cast compat_handle_cast -+#define copy_to_xxx_offset copy_to_compat_offset -+typedef int ret_t; -+ -+#include "../sysctl.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/sysctl.c -=================================================================== ---- 2007-01-08.orig/xen/common/sysctl.c 2007-01-08 15:04:23.000000000 +0100 -+++ 2007-01-08/xen/common/sysctl.c 2007-01-08 15:20:32.000000000 +0100 -@@ -21,14 +21,17 @@ - #include - #include - --extern long arch_do_sysctl( -+#ifndef COMPAT -+typedef long ret_t; -+#define copy_to_xxx_offset copy_to_guest_offset -+#endif -+ -+extern ret_t arch_do_sysctl( - struct xen_sysctl *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl); --extern void getdomaininfo( -- struct domain *d, struct xen_domctl_getdomaininfo *info); - --long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) -+ret_t do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl) - { -- long ret = 0; -+ ret_t ret = 0; - struct xen_sysctl curop, *op = &curop; - static DEFINE_SPINLOCK(sysctl_lock); - -@@ -98,8 +101,8 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc - - put_domain(d); - -- if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer, -- num_domains, &info, 1) ) -+ if ( copy_to_xxx_offset(op->u.getdomaininfolist.buffer, -+ num_domains, &info, 1) ) - { - ret = -EFAULT; - break; -@@ -123,7 +126,6 @@ long do_sysctl(XEN_GUEST_HANDLE(xen_sysc - #ifdef PERF_COUNTERS - case XEN_SYSCTL_perfc_op: - { -- extern int perfc_control(xen_sysctl_perfc_op_t *); - ret = perfc_control(&op->u.perfc_op); - if ( copy_to_guest(u_sysctl, op, 1) ) - ret = -EFAULT; -Index: 2007-01-08/xen/include/xen/domain.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/domain.h 2007-01-08 15:04:23.000000000 +0100 -+++ 2007-01-08/xen/include/xen/domain.h 2007-01-08 15:20:32.000000000 +0100 -@@ -11,6 +11,10 @@ struct vcpu *alloc_idle_vcpu(unsigned in - struct domain *alloc_domain(domid_t domid); - void free_domain(struct domain *d); - -+struct xen_domctl_getdomaininfo; -+void getdomaininfo( -+ struct domain *d, struct xen_domctl_getdomaininfo *info); -+ - /* - * Arch-specifics. - */ -Index: 2007-01-08/xen/include/xen/perfc.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/perfc.h 2007-01-08 15:04:23.000000000 +0100 -+++ 2007-01-08/xen/include/xen/perfc.h 2007-01-08 15:20:32.000000000 +0100 -@@ -102,6 +102,9 @@ extern struct perfcounter perfcounters; - #else - #define perfc_incr_histo(_x,_v,_n) ((void)0) - #endif -+ -+struct xen_sysctl_perfc_op; -+int perfc_control(struct xen_sysctl_perfc_op *); - - #else /* PERF_COUNTERS */ - -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:20:29.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:20:32.000000000 +0100 -@@ -10,6 +10,8 @@ - ! trap_info arch-@arch@/xen.h - ! vcpu_guest_context arch-@arch@/xen.h - ? acm_getdecision acm_ops.h -+! ctl_cpumap domctl.h -+! domctl_getdomaininfo domctl.h - ? evtchn_alloc_unbound event_channel.h - ? evtchn_bind_interdomain event_channel.h - ? evtchn_bind_ipi event_channel.h -@@ -37,6 +39,9 @@ - ! sched_poll sched.h - ? sched_remote_shutdown sched.h - ? sched_shutdown sched.h -+? sysctl_perfc_desc sysctl.h -+! sysctl_perfc_op sysctl.h -+! sysctl_tbuf_op sysctl.h - ! vcpu_runstate_info vcpu.h - ? xenoprof_init xenoprof.h - ? xenoprof_passive xenoprof.h diff --git a/32on64-trace.patch b/32on64-trace.patch deleted file mode 100644 index 921f0e4..0000000 --- a/32on64-trace.patch +++ /dev/null @@ -1,142 +0,0 @@ -Enable compatibility mode operation for trace buffer access. - -Index: 2006-12-11/xen/common/trace.c -=================================================================== ---- 2006-12-11.orig/xen/common/trace.c 2006-12-15 15:20:32.000000000 +0100 -+++ 2006-12-11/xen/common/trace.c 2006-12-15 15:39:01.000000000 +0100 -@@ -32,13 +32,29 @@ - #include - #include - -+#ifdef CONFIG_COMPAT -+#include -+#define xen_t_buf t_buf -+CHECK_t_buf; -+#undef xen_t_buf -+#define TB_COMPAT IS_COMPAT(dom0) -+#else -+#define compat_t_rec t_rec -+#define TB_COMPAT 0 -+#endif -+ -+typedef union { -+ struct t_rec *nat; -+ struct compat_t_rec *cmp; -+} t_rec_u; -+ - /* opt_tbuf_size: trace buffer size (in pages) */ - static unsigned int opt_tbuf_size = 0; - integer_param("tbuf_size", opt_tbuf_size); - - /* Pointers to the meta-data objects for all system trace buffers */ - static DEFINE_PER_CPU(struct t_buf *, t_bufs); --static DEFINE_PER_CPU(struct t_rec *, t_recs); -+static DEFINE_PER_CPU(t_rec_u, t_recs); - static int nr_recs; - - /* High water mark for trace buffers; */ -@@ -87,7 +103,7 @@ static int alloc_trace_bufs(void) - nr_pages = num_online_cpus() * opt_tbuf_size; - order = get_order_from_pages(nr_pages); - nr_recs = (opt_tbuf_size * PAGE_SIZE - sizeof(struct t_buf)) / -- sizeof(struct t_rec); -+ (!TB_COMPAT ? sizeof(struct t_rec) : sizeof(struct compat_t_rec)); - - if ( (rawbuf = alloc_xenheap_pages(order)) == NULL ) - { -@@ -106,7 +122,7 @@ static int alloc_trace_bufs(void) - buf = per_cpu(t_bufs, i) = (struct t_buf *) - &rawbuf[i*opt_tbuf_size*PAGE_SIZE]; - buf->cons = buf->prod = 0; -- per_cpu(t_recs, i) = (struct t_rec *)(buf + 1); -+ per_cpu(t_recs, i).nat = (struct t_rec *)(buf + 1); - } - - t_buf_highwater = nr_recs >> 1; /* 50% high water */ -@@ -232,7 +248,7 @@ void trace(u32 event, unsigned long d1, - unsigned long d3, unsigned long d4, unsigned long d5) - { - struct t_buf *buf; -- struct t_rec *rec; -+ t_rec_u rec; - unsigned long flags; - - BUG_ON(!tb_init_done); -@@ -269,25 +285,51 @@ void trace(u32 event, unsigned long d1, - - if ( unlikely(this_cpu(lost_records) != 0) ) - { -- rec = &this_cpu(t_recs)[buf->prod % nr_recs]; -- memset(rec, 0, sizeof(*rec)); -- rec->cycles = (u64)get_cycles(); -- rec->event = TRC_LOST_RECORDS; -- rec->data[0] = this_cpu(lost_records); -- this_cpu(lost_records) = 0; -+ if ( !TB_COMPAT ) -+ { -+ rec.nat = &this_cpu(t_recs).nat[buf->prod % nr_recs]; -+ memset(rec.nat, 0, sizeof(*rec.nat)); -+ rec.nat->cycles = (u64)get_cycles(); -+ rec.nat->event = TRC_LOST_RECORDS; -+ rec.nat->data[0] = this_cpu(lost_records); -+ this_cpu(lost_records) = 0; -+ } -+ else -+ { -+ rec.cmp = &this_cpu(t_recs).cmp[buf->prod % nr_recs]; -+ memset(rec.cmp, 0, sizeof(*rec.cmp)); -+ rec.cmp->cycles = (u64)get_cycles(); -+ rec.cmp->event = TRC_LOST_RECORDS; -+ rec.cmp->data[0] = this_cpu(lost_records); -+ this_cpu(lost_records) = 0; -+ } - - wmb(); - buf->prod++; - } - -- rec = &this_cpu(t_recs)[buf->prod % nr_recs]; -- rec->cycles = (u64)get_cycles(); -- rec->event = event; -- rec->data[0] = d1; -- rec->data[1] = d2; -- rec->data[2] = d3; -- rec->data[3] = d4; -- rec->data[4] = d5; -+ if ( !TB_COMPAT ) -+ { -+ rec.nat = &this_cpu(t_recs).nat[buf->prod % nr_recs]; -+ rec.nat->cycles = (u64)get_cycles(); -+ rec.nat->event = event; -+ rec.nat->data[0] = d1; -+ rec.nat->data[1] = d2; -+ rec.nat->data[2] = d3; -+ rec.nat->data[3] = d4; -+ rec.nat->data[4] = d5; -+ } -+ else -+ { -+ rec.cmp = &this_cpu(t_recs).cmp[buf->prod % nr_recs]; -+ rec.cmp->cycles = (u64)get_cycles(); -+ rec.cmp->event = event; -+ rec.cmp->data[0] = d1; -+ rec.cmp->data[1] = d2; -+ rec.cmp->data[2] = d3; -+ rec.cmp->data[3] = d4; -+ rec.cmp->data[4] = d5; -+ } - - wmb(); - buf->prod++; -Index: 2006-12-11/xen/include/xlat.lst -=================================================================== ---- 2006-12-11.orig/xen/include/xlat.lst 2006-12-15 15:37:45.000000000 +0100 -+++ 2006-12-11/xen/include/xlat.lst 2006-12-15 15:39:01.000000000 +0100 -@@ -44,6 +44,7 @@ - ? sysctl_perfc_desc sysctl.h - ! sysctl_perfc_op sysctl.h - ! sysctl_tbuf_op sysctl.h -+? t_buf trace.h - ! vcpu_runstate_info vcpu.h - ? xenoprof_init xenoprof.h - ? xenoprof_passive xenoprof.h diff --git a/32on64-vcpuop.patch b/32on64-vcpuop.patch deleted file mode 100644 index a1a610c..0000000 --- a/32on64-vcpuop.patch +++ /dev/null @@ -1,379 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_vcpu_op. - -Index: 2007-01-08/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/domain.c 2007-01-08 15:07:36.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/domain.c 2007-01-08 15:07:40.000000000 +0100 -@@ -40,6 +40,9 @@ - #include - #include - #include -+#ifdef CONFIG_COMPAT -+#include -+#endif - - DEFINE_PER_CPU(struct vcpu *, curr_vcpu); - -@@ -572,16 +575,16 @@ arch_do_vcpu_op( - break; - - rc = 0; -- v->runstate_guest = area.addr.h; -+ runstate_guest(v) = area.addr.h; - - if ( v == current ) - { -- __copy_to_guest(v->runstate_guest, &v->runstate, 1); -+ __copy_to_guest(runstate_guest(v), &v->runstate, 1); - } - else - { - vcpu_runstate_get(v, &runstate); -- __copy_to_guest(v->runstate_guest, &runstate, 1); -+ __copy_to_guest(runstate_guest(v), &runstate, 1); - } - - break; -@@ -980,8 +983,20 @@ void context_switch(struct vcpu *prev, s - context_saved(prev); - - /* Update per-VCPU guest runstate shared memory area (if registered). */ -- if ( !guest_handle_is_null(next->runstate_guest) ) -- __copy_to_guest(next->runstate_guest, &next->runstate, 1); -+ if ( !guest_handle_is_null(runstate_guest(next)) ) -+ { -+ if ( !IS_COMPAT(next->domain) ) -+ __copy_to_guest(runstate_guest(next), &next->runstate, 1); -+#ifdef CONFIG_COMPAT -+ else -+ { -+ struct compat_vcpu_runstate_info info; -+ -+ XLAT_vcpu_runstate_info(&info, &next->runstate); -+ __copy_to_guest(next->runstate_guest.compat, &info, 1); -+ } -+#endif -+ } - - schedule_tail(next); - BUG(); -Index: 2007-01-08/xen/arch/x86/x86_64/Makefile -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/Makefile 2007-01-08 15:07:38.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/Makefile 2007-01-08 15:07:40.000000000 +0100 -@@ -4,6 +4,7 @@ obj-y += mm.o - obj-y += traps.o - - obj-$(CONFIG_COMPAT) += compat.o -+obj-$(CONFIG_COMPAT) += domain.o - obj-$(CONFIG_COMPAT) += physdev.o - - ifeq ($(CONFIG_COMPAT),y) -Index: 2007-01-08/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-01-08.orig/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:07:38.000000000 +0100 -+++ 2007-01-08/xen/arch/x86/x86_64/compat/entry.S 2007-01-08 15:07:40.000000000 +0100 -@@ -284,7 +284,6 @@ CFIX14: - #define compat_multicall domain_crash_synchronous - #define compat_set_timer_op domain_crash_synchronous - #define compat_grant_table_op domain_crash_synchronous --#define compat_vcpu_op domain_crash_synchronous - #define compat_acm_op domain_crash_synchronous - #define compat_arch_sched_op domain_crash_synchronous - #define compat_xenoprof_op domain_crash_synchronous -Index: 2007-01-08/xen/arch/x86/x86_64/domain.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/arch/x86/x86_64/domain.c 2007-01-08 15:07:40.000000000 +0100 -@@ -0,0 +1,68 @@ -+/****************************************************************************** -+ * arch/x86/x86_64/domain.c -+ * -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+int -+arch_compat_vcpu_op( -+ int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg) -+{ -+ long rc = 0; -+ -+ switch ( cmd ) -+ { -+ case VCPUOP_register_runstate_memory_area: -+ { -+ struct compat_vcpu_register_runstate_memory_area area; -+ struct compat_vcpu_runstate_info info; -+ -+ rc = -EFAULT; -+ if ( copy_from_guest(&area, arg, 1) ) -+ break; -+ -+ if ( area.addr.h.c != area.addr.p || -+ !compat_handle_okay(area.addr.h, 1) ) -+ break; -+ -+ rc = 0; -+ guest_from_compat_handle(v->runstate_guest.compat, area.addr.h); -+ -+ if ( v == current ) -+ { -+ XLAT_vcpu_runstate_info(&info, &v->runstate); -+ } -+ else -+ { -+ struct vcpu_runstate_info runstate; -+ -+ vcpu_runstate_get(v, &runstate); -+ XLAT_vcpu_runstate_info(&info, &v->runstate); -+ } -+ __copy_to_guest(v->runstate_guest.compat, &info, 1); -+ -+ break; -+ } -+ -+ default: -+ rc = -ENOSYS; -+ break; -+ } -+ -+ return rc; -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/compat/Makefile -=================================================================== ---- 2007-01-08.orig/xen/common/compat/Makefile 2007-01-08 15:07:36.000000000 +0100 -+++ 2007-01-08/xen/common/compat/Makefile 2007-01-08 15:07:40.000000000 +0100 -@@ -1,3 +1,4 @@ -+obj-y += domain.o - obj-y += kernel.o - obj-y += memory.o - obj-y += xlat.o -Index: 2007-01-08/xen/common/compat/domain.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-01-08/xen/common/compat/domain.c 2007-01-08 15:07:40.000000000 +0100 -@@ -0,0 +1,102 @@ -+/****************************************************************************** -+ * domain.c -+ * -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE(void) arg) -+{ -+ struct domain *d = current->domain; -+ struct vcpu *v; -+ long rc = 0; -+ -+ if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) ) -+ return -EINVAL; -+ -+ if ( (v = d->vcpu[vcpuid]) == NULL ) -+ return -ENOENT; -+ -+ switch ( cmd ) -+ { -+ case VCPUOP_initialise: -+ { -+ struct compat_vcpu_guest_context *cmp_ctxt; -+ struct vcpu_guest_context *nat_ctxt; -+ -+ if ( (cmp_ctxt = xmalloc(struct compat_vcpu_guest_context)) == NULL ) -+ { -+ rc = -ENOMEM; -+ break; -+ } -+ -+ if ( copy_from_guest(cmp_ctxt, arg, 1) ) -+ { -+ xfree(cmp_ctxt); -+ rc = -EFAULT; -+ break; -+ } -+ -+ if ( (nat_ctxt = xmalloc(struct vcpu_guest_context)) == NULL ) -+ { -+ rc = -ENOMEM; -+ break; -+ } -+ -+ memset(nat_ctxt, 0, sizeof(*nat_ctxt)); -+ XLAT_vcpu_guest_context(nat_ctxt, cmp_ctxt); -+ xfree(cmp_ctxt); -+ -+ LOCK_BIGLOCK(d); -+ rc = -EEXIST; -+ if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) ) -+ rc = boot_vcpu(d, vcpuid, nat_ctxt); -+ UNLOCK_BIGLOCK(d); -+ -+ xfree(nat_ctxt); -+ break; -+ } -+ -+ case VCPUOP_up: -+ case VCPUOP_down: -+ case VCPUOP_is_up: -+ rc = do_vcpu_op(cmd, vcpuid, arg); -+ break; -+ -+ case VCPUOP_get_runstate_info: -+ { -+ union { -+ struct vcpu_runstate_info nat; -+ struct compat_vcpu_runstate_info cmp; -+ } runstate; -+ -+ vcpu_runstate_get(v, &runstate.nat); -+ xlat_vcpu_runstate_info(&runstate.nat); -+ if ( copy_to_guest(arg, &runstate.cmp, 1) ) -+ rc = -EFAULT; -+ break; -+ } -+ -+ default: -+ rc = arch_compat_vcpu_op(cmd, v, arg); -+ break; -+ } -+ -+ return rc; -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2007-01-08/xen/common/compat/xlat.c -=================================================================== ---- 2007-01-08.orig/xen/common/compat/xlat.c 2007-01-08 15:07:38.000000000 +0100 -+++ 2007-01-08/xen/common/compat/xlat.c 2007-01-08 15:07:40.000000000 +0100 -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - - /* In-place translation functons: */ - void xlat_start_info(struct start_info *native, -@@ -17,6 +18,14 @@ void xlat_start_info(struct start_info * - XLAT_start_info(compat, native); - } - -+void xlat_vcpu_runstate_info(struct vcpu_runstate_info *native) -+{ -+ struct compat_vcpu_runstate_info *compat = (void *)native; -+ -+ BUILD_BUG_ON(sizeof(*native) < sizeof(*compat)); -+ XLAT_vcpu_runstate_info(compat, native); -+} -+ - #define xen_dom0_vga_console_info dom0_vga_console_info - CHECK_dom0_vga_console_info; - #undef dom0_vga_console_info -Index: 2007-01-08/xen/include/asm-x86/hypercall.h -=================================================================== ---- 2007-01-08.orig/xen/include/asm-x86/hypercall.h 2007-01-08 15:07:38.000000000 +0100 -+++ 2007-01-08/xen/include/asm-x86/hypercall.h 2007-01-08 15:07:40.000000000 +0100 -@@ -130,6 +130,10 @@ compat_physdev_op( - int cmd, - XEN_GUEST_HANDLE(void) arg); - -+extern int -+arch_compat_vcpu_op( -+ int cmd, struct vcpu *v, XEN_GUEST_HANDLE(void) arg); -+ - #endif - - #endif /* __ASM_X86_HYPERCALL_H__ */ -Index: 2007-01-08/xen/include/xen/compat.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/compat.h 2007-01-08 15:07:36.000000000 +0100 -+++ 2007-01-08/xen/include/xen/compat.h 2007-01-08 15:07:40.000000000 +0100 -@@ -163,6 +163,8 @@ int hypercall_xlat_continuation(unsigned - /* In-place translation functons: */ - struct start_info; - void xlat_start_info(struct start_info *, enum XLAT_start_info_console); -+struct vcpu_runstate_info; -+void xlat_vcpu_runstate_info(struct vcpu_runstate_info *); - - #define BITS_PER_GUEST_LONG(d) (!IS_COMPAT(d) ? BITS_PER_LONG : COMPAT_BITS_PER_LONG) - -Index: 2007-01-08/xen/include/xen/sched.h -=================================================================== ---- 2007-01-08.orig/xen/include/xen/sched.h 2007-01-08 15:07:28.000000000 +0100 -+++ 2007-01-08/xen/include/xen/sched.h 2007-01-08 15:07:40.000000000 +0100 -@@ -18,6 +18,11 @@ - #include - #include - -+#ifdef CONFIG_COMPAT -+#include -+DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t); -+#endif -+ - extern unsigned long volatile jiffies; - extern rwlock_t domlist_lock; - -@@ -82,7 +87,16 @@ struct vcpu - void *sched_priv; /* scheduler-specific data */ - - struct vcpu_runstate_info runstate; -+#ifndef CONFIG_COMPAT -+# define runstate_guest(v) ((v)->runstate_guest) - XEN_GUEST_HANDLE(vcpu_runstate_info_t) runstate_guest; /* guest address */ -+#else -+# define runstate_guest(v) ((v)->runstate_guest.native) -+ union { -+ XEN_GUEST_HANDLE(vcpu_runstate_info_t) native; -+ XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t) compat; -+ } runstate_guest; /* guest address */ -+#endif - - unsigned long vcpu_flags; - -Index: 2007-01-08/xen/include/xlat.lst -=================================================================== ---- 2007-01-08.orig/xen/include/xlat.lst 2007-01-08 15:07:38.000000000 +0100 -+++ 2007-01-08/xen/include/xlat.lst 2007-01-08 15:08:28.000000000 +0100 -@@ -6,6 +6,9 @@ - ! mmuext_op xen.h - ! start_info xen.h - ? vcpu_time_info xen.h -+! cpu_user_regs arch-@arch@/xen-@subarch@.h -+! trap_info arch-@arch@/xen.h -+! vcpu_guest_context arch-@arch@/xen.h - ? evtchn_alloc_unbound event_channel.h - ? evtchn_bind_interdomain event_channel.h - ? evtchn_bind_ipi event_channel.h -@@ -23,3 +26,4 @@ - ! memory_map memory.h - ! memory_reservation memory.h - ! translate_gpfn_list memory.h -+! vcpu_runstate_info vcpu.h diff --git a/32on64-xenoprof.patch b/32on64-xenoprof.patch deleted file mode 100644 index 34bbaf9..0000000 --- a/32on64-xenoprof.patch +++ /dev/null @@ -1,326 +0,0 @@ -Enable compatibility mode operation for HYPERVISOR_xenoprof_op. - -Index: 2006-12-18/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-18.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:50:05.000000000 +0100 -+++ 2006-12-18/xen/arch/x86/x86_64/compat/entry.S 2006-12-18 09:50:08.000000000 +0100 -@@ -278,7 +278,6 @@ CFIX14: - - .section .rodata, "a", @progbits - --#define compat_xenoprof_op domain_crash_synchronous - #define compat_sysctl domain_crash_synchronous - #define compat_domctl domain_crash_synchronous - -Index: 2006-12-18/xen/include/public/xenoprof.h -=================================================================== ---- 2006-12-18.orig/xen/include/public/xenoprof.h 2006-12-15 16:33:59.000000000 +0100 -+++ 2006-12-18/xen/include/public/xenoprof.h 2006-12-18 09:50:08.000000000 +0100 -@@ -74,8 +74,10 @@ struct xenoprof_buf { - uint64_t lost_samples; - struct event_log event_log[1]; - }; -+#ifndef __XEN__ - typedef struct xenoprof_buf xenoprof_buf_t; - DEFINE_XEN_GUEST_HANDLE(xenoprof_buf_t); -+#endif - - struct xenoprof_init { - int32_t num_events; -Index: 2006-12-18/xen/include/xen/xenoprof.h -=================================================================== ---- 2006-12-18.orig/xen/include/xen/xenoprof.h 2006-12-13 11:15:57.000000000 +0100 -+++ 2006-12-18/xen/include/xen/xenoprof.h 2006-12-18 09:50:08.000000000 +0100 -@@ -10,6 +10,7 @@ - #ifndef __XEN_XENOPROF_H__ - #define __XEN_XENOPROF_H__ - -+#include - #include - #include - -@@ -22,9 +23,19 @@ - #define XENOPROF_READY 2 - #define XENOPROF_PROFILING 3 - -+#ifndef CONFIG_COMPAT -+typedef struct xenoprof_buf xenoprof_buf_t; -+#else -+#include -+typedef union { -+ struct xenoprof_buf native; -+ struct compat_oprof_buf compat; -+} xenoprof_buf_t; -+#endif -+ - struct xenoprof_vcpu { - int event_size; -- struct xenoprof_buf *buffer; -+ xenoprof_buf_t *buffer; - }; - - struct xenoprof { -@@ -35,9 +46,22 @@ struct xenoprof { - int domain_type; - int domain_ready; - int is_primary; -+#ifdef CONFIG_COMPAT -+ int is_compat; -+#endif - struct xenoprof_vcpu vcpu [MAX_VIRT_CPUS]; - }; - -+#ifndef CONFIG_COMPAT -+#define XENOPROF_COMPAT(x) 0 -+#define xenoprof_buf(d, b, field) ((b)->field) -+#else -+#define XENOPROF_COMPAT(x) ((x)->is_compat) -+#define xenoprof_buf(d, b, field) (*(!(d)->xenoprof->is_compat ? \ -+ &(b)->native.field : \ -+ &(b)->compat.field)) -+#endif -+ - struct domain; - void free_xenoprof_pages(struct domain *d); - -Index: 2006-12-18/xen/include/xlat.lst -=================================================================== ---- 2006-12-18.orig/xen/include/xlat.lst 2006-12-18 09:50:05.000000000 +0100 -+++ 2006-12-18/xen/include/xlat.lst 2006-12-18 09:50:08.000000000 +0100 -@@ -38,3 +38,5 @@ - ? sched_remote_shutdown sched.h - ? sched_shutdown sched.h - ! vcpu_runstate_info vcpu.h -+? xenoprof_init xenoprof.h -+? xenoprof_passive xenoprof.h -Index: 2006-12-18/xen/common/Makefile -=================================================================== ---- 2006-12-18.orig/xen/common/Makefile 2006-12-18 09:50:05.000000000 +0100 -+++ 2006-12-18/xen/common/Makefile 2006-12-18 09:50:08.000000000 +0100 -@@ -45,4 +45,5 @@ ifeq ($(CONFIG_COMPAT),y) - acm_ops.o: compat/acm_ops.c - grant_table.o: compat/grant_table.c - schedule.o: compat/schedule.c -+xenoprof.o: compat/xenoprof.c - endif -Index: 2006-12-18/xen/common/compat/xenoprof.c -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2006-12-18/xen/common/compat/xenoprof.c 2006-12-18 09:50:08.000000000 +0100 -@@ -0,0 +1,40 @@ -+/* -+ * compat/xenoprof.c -+ */ -+ -+#include -+ -+#define COMPAT -+ -+#define do_xenoprof_op compat_xenoprof_op -+ -+#define xen_oprof_init xenoprof_init -+CHECK_oprof_init; -+#undef xen_oprof_init -+ -+#define xenoprof_get_buffer compat_oprof_get_buffer -+#define xenoprof_op_get_buffer compat_oprof_op_get_buffer -+ -+#define xen_domid_t domid_t -+#define compat_domid_t domid_compat_t -+CHECK_TYPE(domid); -+#undef compat_domid_t -+#undef xen_domid_t -+ -+#define xen_oprof_passive xenoprof_passive -+CHECK_oprof_passive; -+#undef xen_oprof_passive -+ -+#define xenoprof_counter compat_oprof_counter -+ -+#include "../xenoprof.c" -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: 2006-12-18/xen/common/xenoprof.c -=================================================================== ---- 2006-12-18.orig/xen/common/xenoprof.c 2006-12-13 11:15:54.000000000 +0100 -+++ 2006-12-18/xen/common/xenoprof.c 2006-12-18 09:50:08.000000000 +0100 -@@ -9,6 +9,7 @@ - * VA Linux Systems Japan K.K. - */ - -+#ifndef COMPAT - #include - #include - #include -@@ -72,7 +73,7 @@ static void xenoprof_reset_stat(void) - static void xenoprof_reset_buf(struct domain *d) - { - int j; -- struct xenoprof_buf *buf; -+ xenoprof_buf_t *buf; - - if ( d->xenoprof == NULL ) - { -@@ -86,8 +87,8 @@ static void xenoprof_reset_buf(struct do - buf = d->xenoprof->vcpu[j].buffer; - if ( buf != NULL ) - { -- buf->event_head = 0; -- buf->event_tail = 0; -+ xenoprof_buf(d, buf, event_head) = 0; -+ xenoprof_buf(d, buf, event_tail) = 0; - } - } - } -@@ -166,15 +167,24 @@ static int alloc_xenoprof_struct( - for_each_vcpu ( d, v ) - nvcpu++; - -+ bufsize = sizeof(struct xenoprof_buf); -+ i = sizeof(struct event_log); -+#ifdef CONFIG_COMPAT -+ d->xenoprof->is_compat = IS_COMPAT(is_passive ? dom0 : d); -+ if ( XENOPROF_COMPAT(d->xenoprof) ) -+ { -+ bufsize = sizeof(struct compat_oprof_buf); -+ i = sizeof(struct compat_event_log); -+ } -+#endif -+ - /* reduce max_samples if necessary to limit pages allocated */ - max_bufsize = (MAX_OPROF_SHARED_PAGES * PAGE_SIZE) / nvcpu; -- max_max_samples = ( (max_bufsize - sizeof(struct xenoprof_buf)) / -- sizeof(struct event_log) ) + 1; -+ max_max_samples = ( (max_bufsize - bufsize) / i ) + 1; - if ( (unsigned)max_samples > max_max_samples ) - max_samples = max_max_samples; - -- bufsize = sizeof(struct xenoprof_buf) + -- (max_samples - 1) * sizeof(struct event_log); -+ bufsize += (max_samples - 1) * i; - npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1; - - d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages)); -@@ -195,11 +205,12 @@ static int alloc_xenoprof_struct( - i = 0; - for_each_vcpu ( d, v ) - { -+ xenoprof_buf_t *buf = (xenoprof_buf_t *)&d->xenoprof->rawbuf[i * bufsize]; -+ - d->xenoprof->vcpu[v->vcpu_id].event_size = max_samples; -- d->xenoprof->vcpu[v->vcpu_id].buffer = -- (struct xenoprof_buf *)&d->xenoprof->rawbuf[i * bufsize]; -- d->xenoprof->vcpu[v->vcpu_id].buffer->event_size = max_samples; -- d->xenoprof->vcpu[v->vcpu_id].buffer->vcpu_id = v->vcpu_id; -+ d->xenoprof->vcpu[v->vcpu_id].buffer = buf; -+ xenoprof_buf(d, buf, event_size) = max_samples; -+ xenoprof_buf(d, buf, vcpu_id) = v->vcpu_id; - - i++; - /* in the unlikely case that the number of active vcpus changes */ -@@ -406,8 +417,9 @@ static int add_passive_list(XEN_GUEST_HA - void xenoprof_log_event( - struct vcpu *vcpu, unsigned long eip, int mode, int event) - { -+ struct domain *d = vcpu->domain; - struct xenoprof_vcpu *v; -- struct xenoprof_buf *buf; -+ xenoprof_buf_t *buf; - int head; - int tail; - int size; -@@ -417,13 +429,13 @@ void xenoprof_log_event( - - /* ignore samples of un-monitored domains */ - /* Count samples in idle separate from other unmonitored domains */ -- if ( !is_profiled(vcpu->domain) ) -+ if ( !is_profiled(d) ) - { - others_samples++; - return; - } - -- v = &vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id]; -+ v = &d->xenoprof->vcpu[vcpu->vcpu_id]; - - /* Sanity check. Should never happen */ - if ( v->buffer == NULL ) -@@ -432,10 +444,10 @@ void xenoprof_log_event( - return; - } - -- buf = vcpu->domain->xenoprof->vcpu[vcpu->vcpu_id].buffer; -+ buf = v->buffer; - -- head = buf->event_head; -- tail = buf->event_tail; -+ head = xenoprof_buf(d, buf, event_head); -+ tail = xenoprof_buf(d, buf, event_tail); - size = v->event_size; - - /* make sure indexes in shared buffer are sane */ -@@ -447,28 +459,28 @@ void xenoprof_log_event( - - if ( (head == tail - 1) || (head == size - 1 && tail == 0) ) - { -- buf->lost_samples++; -+ xenoprof_buf(d, buf, lost_samples)++; - lost_samples++; - } - else - { -- buf->event_log[head].eip = eip; -- buf->event_log[head].mode = mode; -- buf->event_log[head].event = event; -+ xenoprof_buf(d, buf, event_log[head].eip) = eip; -+ xenoprof_buf(d, buf, event_log[head].mode) = mode; -+ xenoprof_buf(d, buf, event_log[head].event) = event; - head++; - if ( head >= size ) - head = 0; -- buf->event_head = head; -+ xenoprof_buf(d, buf, event_head) = head; - if ( is_active(vcpu->domain) ) - active_samples++; - else - passive_samples++; - if ( mode == 0 ) -- buf->user_samples++; -+ xenoprof_buf(d, buf, user_samples)++; - else if ( mode == 1 ) -- buf->kernel_samples++; -+ xenoprof_buf(d, buf, kernel_samples)++; - else -- buf->xen_samples++; -+ xenoprof_buf(d, buf, xen_samples)++; - } - } - -@@ -494,6 +506,8 @@ static int xenoprof_op_init(XEN_GUEST_HA - return 0; - } - -+#endif /* !COMPAT */ -+ - static int xenoprof_op_get_buffer(XEN_GUEST_HANDLE(void) arg) - { - struct xenoprof_get_buffer xenoprof_get_buffer; -@@ -732,6 +746,10 @@ int do_xenoprof_op(int op, XEN_GUEST_HAN - return ret; - } - -+#if defined(CONFIG_COMPAT) && !defined(COMPAT) -+#include "compat/xenoprof.c" -+#endif -+ - /* - * Local variables: - * mode: C diff --git a/README.SuSE b/README.SuSE index 143bfc2..b1acb41 100644 --- a/README.SuSE +++ b/README.SuSE @@ -23,25 +23,19 @@ See the Xen homepage for more information: If you want to use Xen, you need to install the Xen hypervisor and a number of supporting packages. During the initial SUSE installation (or when installing from YaST) check-mark the "Xen Virtual Machine Host Server" pattern. If, -instead, you wish to install Xen manually later, install the following packages: - bridge-utils - kernel-xen or kernel-xenpae - python - xen - xen-libs - xen-tools - xen-tools-ioemu (Required for hardware-assisted virtualization) - multipath-tools (Required by xen-tools for domUloader) - xen-doc-* (Optional) +instead, you wish to install Xen manually later, click on the "Install +Hypervisor and Tools" icon in YaST. + +If you want to install and manage VMs graphically, be sure the following +optional packages are also installed: python-gtk (Optional, to install VMs graphically) virt-manager (Optional, to manage VMs graphically) - tightvnc (Optional, to view VMs) - yast2-vm (Optional, convenient icons to install/manage VMs) + tightvnc (Optional, to view VMs outside virt-manager) You then need to reboot your machine. Instead of booting a normal Linux kernel, you will boot the Xen hypervisor and a slightly changed Linux kernel. -This Linux kernel runs in the first virtual machine and will drive most of your -hardware. +This Linux kernel runs in the first virtual machine and will drive most of +your hardware. This approach is called para-virtualization, since it is a partial virtualization (the Linux kernel needs to be changed slightly, to make the @@ -174,14 +168,29 @@ through YaST's Control Center) is the recommended method to create VMs. This program handles creating both the VM's configuration file and disk(s). It can help install any operating system, not just SUSE. -From the command line, run "vm-install". If the DISPLAY environment -variable is set and the supporting packages (python-gtk) are installed, a -graphical wizard will start. Otherwise, a text wizard will start. +From the command line, run "vm-install". If the DISPLAY environment variable +is set and the supporting packages (python-gtk) are installed, a graphical +wizard will start. Otherwise, a text wizard will start. -Xen does not yet properly support removable media in VMs in paravirtual mode, -so installing an operating system from CDs can be difficult. We recommend -using a network installation source, a DVD, or a DVD ISO. CDs do, however, -work as expected in fully-virtual mode. +Each VM needs to have its own root filesystem. The root filesystem can live +on a block device (e.g., a hard disk partition, or an LVM2 or EVMS volume) or +in a file that holds the filesystem image. + +VMs can share filesystems, such as /usr or /opt, that are mounted read-only +from _all_ VMs. Never try to share a filesystem that is mounted read-write; +filesystem corruption will result. For sharing writable data between VMs, use +NFS or other networked or cluster filesystems. + +Xen does not yet properly support removable media in VMs, so installing an +operating system from CDs can be difficult. Consult the online documentation +for some detailed work-arounds. We recommend using a network installation +source, a DVD, or a DVD ISO. + +When defining the virtual network adapter(s), we recommend using a static MAC +for the VM rather than allowing Xen to randomly select one each time the VM +boots. (See "Network Troubleshooting" below.) XenSource has been allocated a +range of MAC addresses with the OUI of 00-16-3E. By using MACs from this +range you can be sure they will not conflict with any physical adapters. Note that older paravirtualized SUSE Linux (older than SLES 10 SP1) will default to using a text-based installation. To perform a graphical @@ -199,10 +208,8 @@ exist in /var/lib/xen/images, and a corresponding config file will exist in the VM. When the VM shuts down (because the installation -- or at least the first -stage of it -- is done), the wizard gives you a chance to finalize the VM's -configuration. This is useful, for example, if the installer and the -application that will run in the VM have different memory or network -requirements. +stage of it -- is done), the wizard finalizes the VM's configuration and +restarts the VM. The creation of VMs can be automated; read the vm-install man page for more details. The installation of an OS within the VM can be automated if the OS @@ -215,18 +222,9 @@ If you create a VM manually (as opposed to using vm-install, which is the recommended way), you will need to create a disk (or reuse an existing one) and a configuration file. -Each VM needs to have its own root filesystem. The root filesystem can live on -a block device (e.g., a hard disk partition, or an LVM2 or EVMS volume) or in -a file that holds the filesystem image. - -VMs can share filesystems, such as /usr or /opt, that are mounted read-only -from _all_ VMs. Never try to share a filesystem that is mounted read-write; -filesystem corruption will result. For sharing writable data between VMs, use -NFS or other networked or cluster filesystems. - If you are using a disk or disk image that is already installed with an -operating system, you'll probably need to replace its kernel with a Xen-enabled -kernel. +operating system, you'll probably need to replace its kernel with a +Xen-enabled kernel. The kernel and ramdisk used to bootstrap the VM must match any kernel modules that might be present in the VM's disk. It is possible to manually copy the @@ -243,27 +241,28 @@ suit your needs. For para-virtualized VMs, start with /etc/xen/examples/xmexample.hvm. You'll need to change (at very least) the "name" and "disk" parameters. -When defining the virtual network adapter(s), we recommend using a static MAC -for the VM rather than allowing Xen to randomly select one each time the VM -boots. (See "Network Troubleshooting" below.) XenSource has been allocated a -range of MAC addresses with the OUI of 00-16-3E. By using MACs from this -range you can be sure they will not conflict with any physical adapters. - Managing Virtual Machines ------------------------- VMs can be managed from the command line or from virt-manager. -To create a new VM from the command line, use a command like: - xm create my-vm +Before a VM can be started, xend must be informed of it. vm-install will +automatically import new VM configurations into xend. However, if you copy a +VM from another machine, or manually create a VM configuration file, you will +need to import it into xend with a command like: + xm new my-vm If your VM's configuration file is not located in /etc/xen/vm, you must -specify the full path. +specify the full path. This imports the configuration into xend (and +therefore virt-manager becomes aware of it, also). + +Now to start the VM: + xm start my-vm +or start it graphically from virt-manager. Have a look at running sessions with "xm list". Note the ID of the newly -created VM. Attach to that VM with "xm console " (replacing ID with the -VM's ID). Equivalently, you could have passed "-c" during creation to -immediately connect to the console. Attaching to multiple VM consoles is most -conveniently done with the terminal multiplexer "screen". +created VM. Attach to the VM's text console with "xm console " (replacing +ID with the VM's ID). Attaching to multiple VM consoles is most conveniently +done with the terminal multiplexer "screen". Have a look at the other xm commands by typing "xm help". Note that most xm commands must be done as root. @@ -271,11 +270,15 @@ commands must be done as root. Using the Mouse via VNC in Fully-Virtual Mode --------------------------------------------- -When accessing a fully-virtualized operating system via VNC, the mouse may be -difficult to control. By default, the VM is emulating a PS/2 mouse. PS/2 -provides mouse deltas, but VNC only provides absolute coordinates. The -solution is (when using VNC) to emulate a pointing device that offers absolute -coordinates. +In a fully virtualized VM, the mouse may be emulated as a PS/2 mouse, USB +mouse, or USB tablet. The vm-install tool selects the best emulation that is +known to be automatically detected and supported by the operating system. + +However, when accessing some fully-virtualized operating systems via VNC, the +mouse may be difficult to control if the VM is emulating a PS/2 mouse. PS/2 +provides mouse deltas, but VNC only provides absolute coordinates. In such +cases, you may want to manually switch the operating system and VM to use a +USB tablet. Emulation of a SummaSketch graphics tablet is provided for this reason. To use the Summa emulation, you will need to configure your fully-virtualized OS. @@ -307,22 +310,29 @@ Section "InputDevice" EndSection After making these changes, restart gpm and X. -Windows does not ship with a driver for the SummaSketch tablet. You can -obtain an appropriate driver from the device manufacturer's website, or one of -the large Windows driver websites. +To ensure the VM is emulating a USB tablet, add these lines to the +configuration file in /etc/xen/vm: + usb=1 + usbdevice='tablet' +Then re-import the configuration into xend: + xm new my-vm HVM Console in Fully-Virtual Mode --------------------------------- When running a VM in fully-virtual mode, a special console is available that provides some additional ways to control the VM. Press Ctrl-Alt-2 to access -the console; press Ctrl-Alt-1 to return to the VM. +the console; press Ctrl-Alt-1 to return to the VM. While at the console, +type "help" for help. The two most important commands are "send-key" and "change". The "send-key" command allows you to send any key sequence to the VM, which might otherwise -be intercepted by your local window manager. The "change" command allows the -target of a block device to be changed; for example, use it to change from one -CD ISO to another. Type "help" for more information. +be intercepted by your local window manager. + +The "change" command allows the target of a block device to be changed; for +example, use it to change from one CD ISO to another. Some versions of Xen +have this command disabled for security reasons. Consult the online +documentation for workarounds. Networking @@ -449,17 +459,16 @@ of a virtual machine is known. A VM is an effective jail. Limitations ----------- -When booting, Linux reserves data structures matching the amount of (virtual) -processors and RAM found. This has the side-effect that you can't dynamically -grow the virtual hardware beyond what the kernel has been booted with. But -you can trick domU Linux to prepare for a larger amount of RAM by passing the -mem= boot parameter. +When booting, Linux reserves data structures matching the amount of RAM found. +This has the side-effect that you can't dynamically grow the memory beyond +what the kernel has been booted with. But you can trick domU Linux to prepare +for a larger amount of RAM by passing the mem= boot parameter. The export of virtual hard disks from files in Xen can be handled via the -loopback driver (although in Xen 3.0.4, this is being replaced by the "blktap" -user-space driver.) If you are still using loopback, you can easily run out -of loopback devices, as by default only 8 are supported. You can change this -by inserting: +loopback driver (although in Xen 3.0.4, this is can be replaced by the +"blktap" user-space driver.) If you are still using loopback, you can easily +run out of loopback devices, as by default only 8 are supported. You can +change this by inserting: options loop max_loop=64 into /etc/modprobe.conf.local in domain 0. @@ -500,13 +509,23 @@ First try to get Linux running on bare iron before trying with Xen. Be sure your Xen hypervisor (xen) and VM kernels (kernel-xen) are compatible. The hypervisor and domain 0 kernel are a matched set, and usually must be -upgraded together. +upgraded together. Consult the online documentation for a matrix of supported +32- and 64-bit combinations + +On certain machines with 2GB or less of RAM, domain 0 Linux may fail to boot, +printing the following messages: +PCI-DMA: Using software bounce buffering for IO (SWIOTLB) +... +Kernel panic - not syncing: PCI-DMA: Memory would be corrupted +Fix this by adding "swiotlb=16" to the Linux kernel command line, which +reserves additional memory for the swiotlb. If you have trouble early in the boot, try passing pnpacpi=off to the Linux kernel. If you have trouble with interrupts or timers, passing lapic to Xen may help. Xen and Linux understand similar ACPI boot parameters. Try the -options acpi=off,force,strict,ht,noirq or acpi_skip_timer_override. Other -useful debugging options to Xen may be nosmp, noreboot, mem=1024M, +options acpi=off,force,strict,ht,noirq or acpi_skip_timer_override. + +Other useful debugging options to Xen may be nosmp, noreboot, mem=1024M, sync_console, noirqbalance (Dell). For a complete list of Xen boot options, consult chapter 11.3 of the Xen users' manual. diff --git a/balloon-early.patch b/balloon-early.patch new file mode 100644 index 0000000..51a5917 --- /dev/null +++ b/balloon-early.patch @@ -0,0 +1,14 @@ +Index: xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +=================================================================== +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -1444,6 +1444,9 @@ class XendDomainInfo: + "supported by your CPU and enabled in your " + "BIOS?") + ++ # The hypervisor needs some domheap pages to create the VM. ++ # Final ballooning for the domain's pages will be done later. ++ balloon.free(16 * 1024) + self.domid = xc.domain_create( + domid = 0, + ssidref = security.get_security_info(self.info, 'ssidref'), diff --git a/blktools-bimodal.diff b/blktools-bimodal.diff deleted file mode 100644 index 308e962..0000000 --- a/blktools-bimodal.diff +++ /dev/null @@ -1,71 +0,0 @@ -bimodal: blk tools - -Add one more option to the disk configuration, so one can specify the -protocol the frontend speaks in the config file. This is needed for -old frontends which don't advertise the protocol they are speaking -themself. - -I'm not that happy with this approach, but it works for now and I'm -kida lost in the stack of python classes doing domain and device -handling ... - -Signed-off-by: Gerd Hoffmann ---- - tools/python/xen/xend/server/blkif.py | 3 +++ - tools/python/xen/xm/create.py | 7 ++++++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -Index: build-64-release304-13133/tools/python/xen/xend/server/blkif.py -=================================================================== ---- build-64-release304-13133.orig/tools/python/xen/xend/server/blkif.py -+++ build-64-release304-13133/tools/python/xen/xend/server/blkif.py -@@ -38,6 +38,7 @@ class BlkifController(DevController): - """@see DevController.getDeviceDetails""" - uname = config.get('uname', '') - dev = config.get('dev', '') -+ protocol = config.get('protocol') - - if 'ioemu:' in dev: - (_, dev) = string.split(dev, ':', 1) -@@ -85,6 +86,8 @@ class BlkifController(DevController): - front = { 'virtual-device' : "%i" % devid, - 'device-type' : dev_type - } -+ if protocol: -+ front.update({ 'protocol' : protocol }); - - return (devid, back, front) - -Index: build-64-release304-13133/tools/python/xen/xm/create.py -=================================================================== ---- build-64-release304-13133.orig/tools/python/xen/xm/create.py -+++ build-64-release304-13133/tools/python/xen/xm/create.py -@@ -531,7 +531,7 @@ def configure_image(vals): - def configure_disks(config_devs, vals): - """Create the config for disks (virtual block devices). - """ -- for (uname, dev, mode, backend) in vals.disk: -+ for (uname, dev, mode, backend, protocol) in vals.disk: - if uname.startswith('tap:'): - cls = 'tap' - else: -@@ -543,6 +543,8 @@ def configure_disks(config_devs, vals): - ['mode', mode ] ] - if backend: - config_vbd.append(['backend', backend]) -+ if protocol: -+ config_vbd.append(['protocol', protocol]) - config_devs.append(['device', config_vbd]) - - def configure_pci(config_devs, vals): -@@ -787,7 +789,10 @@ def preprocess_disk(vals): - n = len(d) - if n == 3: - d.append(None) -+ d.append(None) - elif n == 4: -+ d.append(None) -+ elif n == 5: - pass - else: - err('Invalid disk specifier: ' + v) diff --git a/block-flags.diff b/block-flags.diff new file mode 100644 index 0000000..69f1110 --- /dev/null +++ b/block-flags.diff @@ -0,0 +1,32 @@ +Index: xen-unstable/tools/examples/block +=================================================================== +--- xen-unstable.orig/tools/examples/block ++++ xen-unstable/tools/examples/block +@@ -259,10 +259,13 @@ case "$command" in + ;; + + file) ++ lo_flags="" ++ [ "${mode/S}" = "$mode" ] || lo_flags="-y" + # Canonicalise the file, for sharing check comparison, and the mode + # for ease of use here. + file=$(readlink -f "$p") || fatal "$p does not exist." + mode=$(canonicalise_mode "$mode") ++ [ "$mode" = "r" ] && lo_flags="$lo_flags -r" + + claim_lock "block" + +@@ -370,11 +373,11 @@ mount it read-write in a guest domain." + fatal 'Failed to find an unused loop device' + fi + +- losetup "$loopdev" "$file" && losetup_failure="" && break ++ losetup $lo_flags "$loopdev" "$file" && losetup_failure="" && break + done + if [ "$losetup_failure" ] + then +- fatal 'losetup $loopdev $file' ++ fatal 'losetup $lo_flags $loopdev $file' + fi + + xenstore_write "$XENBUS_PATH/node" "$loopdev" diff --git a/block-losetup-retry.diff b/block-losetup-retry.diff index 2f5aa05..1623878 100644 --- a/block-losetup-retry.diff +++ b/block-losetup-retry.diff @@ -1,8 +1,48 @@ -Index: xen-3.0.4-testing/tools/examples/block +Index: xen-unstable/tools/examples/block =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/block -+++ xen-3.0.4-testing/tools/examples/block -@@ -390,8 +390,18 @@ mount it read-write in a guest domain." +--- xen-unstable.orig/tools/examples/block ++++ xen-unstable/tools/examples/block +@@ -274,9 +274,12 @@ case "$command" in + mount it read-write in a guest domain." + fi + +- loopdev='' +- for dev in /dev/loop* ++ losetup_failure=1 ++ for do_losetup in 1 2 3 + do ++ loopdev='' ++ for dev in /dev/loop* ++ do + if [ ! -b "$dev" ] + then + continue +@@ -360,14 +363,20 @@ mount it read-write in a guest domain." + loopdev="$dev" + fi + fi +- done ++ done ++ ++ if [ "$loopdev" = '' ] ++ then ++ fatal 'Failed to find an unused loop device' ++ fi + +- if [ "$loopdev" = '' ] ++ losetup "$loopdev" "$file" && losetup_failure="" && break ++ done ++ if [ "$losetup_failure" ] + then +- fatal 'Failed to find an unused loop device' ++ fatal 'losetup $loopdev $file' + fi + +- do_or_die losetup "$loopdev" "$file" + xenstore_write "$XENBUS_PATH/node" "$loopdev" + write_dev "$loopdev" + release_lock "block" +@@ -390,8 +399,18 @@ mount it read-write in a guest domain." file) node=$(xenstore_read "$XENBUS_PATH/node") diff --git a/block-sync.diff b/block-sync.diff deleted file mode 100644 index 862d376..0000000 --- a/block-sync.diff +++ /dev/null @@ -1,42 +0,0 @@ -Index: xen-3.0.4-testing/tools/examples/block -=================================================================== ---- xen-3.0.4-testing.orig/tools/examples/block -+++ xen-3.0.4-testing/tools/examples/block -@@ -42,6 +42,20 @@ canonicalise_mode() - fi - } - -+## -+# sync_flags mode -+# -+sync_flags() -+{ -+ local mode="$1" -+ if expr index "$mode" 'S' >/dev/null -+ then -+ echo "-y" -+ else -+ echo "" -+ fi -+} -+ - - ## - # check_sharing device mode -@@ -262,6 +276,7 @@ case "$command" in - # Canonicalise the file, for sharing check comparison, and the mode - # for ease of use here. - file=$(readlink -f "$p") || fatal "$p does not exist." -+ sync=$(sync_flags "$mode") - mode=$(canonicalise_mode "$mode") - - claim_lock "block" -@@ -367,7 +382,7 @@ mount it read-write in a guest domain." - fatal 'Failed to find an unused loop device' - fi - -- do_or_die losetup "$loopdev" "$file" -+ do_or_die losetup $sync "$loopdev" "$file" - xenstore_write "$XENBUS_PATH/node" "$loopdev" - write_dev "$loopdev" - release_lock "block" diff --git a/bridge-hostonly.diff b/bridge-hostonly.diff index 42ff9a8..b6650eb 100644 --- a/bridge-hostonly.diff +++ b/bridge-hostonly.diff @@ -22,11 +22,11 @@ Signed-off-by: Gerd Hoffmann tools/examples/network-bridge | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) -Index: build-32-unstable-11624/tools/examples/network-bridge +Index: xen-unstable/tools/examples/network-bridge =================================================================== ---- build-32-unstable-11624.orig/tools/examples/network-bridge -+++ build-32-unstable-11624/tools/examples/network-bridge -@@ -269,6 +269,31 @@ op_stop () { +--- xen-unstable.orig/tools/examples/network-bridge ++++ xen-unstable/tools/examples/network-bridge +@@ -277,6 +277,31 @@ op_stop () { brctl delbr ${bridge} } @@ -58,7 +58,7 @@ Index: build-32-unstable-11624/tools/examples/network-bridge # adds $dev to $bridge but waits for $dev to be in running state first add_to_bridge2() { local bridge=$1 -@@ -293,11 +318,19 @@ add_to_bridge2() { +@@ -301,11 +326,19 @@ add_to_bridge2() { case "$command" in start) diff --git a/bug.patch b/bug.patch deleted file mode 100644 index 7d0b9f7..0000000 --- a/bug.patch +++ /dev/null @@ -1,325 +0,0 @@ -Index: 2007-02-20/xen/arch/powerpc/backtrace.c -=================================================================== ---- 2007-02-20.orig/xen/arch/powerpc/backtrace.c 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-02-20/xen/arch/powerpc/backtrace.c 2007-02-20 10:56:04.000000000 +0100 -@@ -206,7 +206,7 @@ void show_backtrace_regs(struct cpu_user - console_end_sync(); - } - --void __warn(char *file, int line) -+void __warn(const char *file, int line) - { - ulong sp; - ulong lr; -Index: 2007-02-20/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/common.c 2007-02-20 10:55:36.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/common.c 2007-02-20 10:56:04.000000000 +0100 -@@ -948,6 +948,7 @@ mfn_t shadow_alloc(struct domain *d, - * we might free up higher-level pages that the caller is working on. */ - SHADOW_PRINTK("Can't allocate %i shadow pages!\n", 1 << order); - BUG(); -+ return _mfn(0); - } - - -Index: 2007-02-20/xen/arch/x86/mm/shadow/multi.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm/shadow/multi.c 2007-02-20 10:55:27.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm/shadow/multi.c 2007-02-20 10:56:04.000000000 +0100 -@@ -3195,7 +3195,7 @@ sh_update_linear_entries(struct vcpu *v) - */ - { - l2_pgentry_t *l2e, new_l2e; -- shadow_l3e_t *guest_l3e = NULL, *shadow_l3e; -+ shadow_l3e_t *guest_l3e = NULL, *shadow_l3e = NULL; - int i; - int unmap_l2e = 0; - -Index: 2007-02-20/xen/arch/x86/traps.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/traps.c 2007-02-20 10:56:00.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/traps.c 2007-02-20 10:56:04.000000000 +0100 -@@ -635,14 +635,50 @@ asmlinkage int do_invalid_op(struct cpu_ - - if ( unlikely(!guest_mode(regs)) ) - { -- char sig[5]; -- /* Signature (ud2; .ascii "dbg") indicates dump state and continue. */ -- if ( (__copy_from_user(sig, (char *)regs->eip, sizeof(sig)) == 0) && -- (memcmp(sig, "\xf\xb""dbg", sizeof(sig)) == 0) ) -- { -- show_execution_state(regs); -- regs->eip += sizeof(sig); -- return EXCRET_fault_fixed; -+ struct bug_frame f; -+ -+ if ( (__copy_from_user(&f, (char *)regs->eip, sizeof(f)) == 0) && -+ f.ud2[0] == 0x0f && f.ud2[1] == 0x0b && f.ret == 0xc2 ) -+ { -+ const char *text = NULL; -+ char file[40]; -+ -+ switch ( f.id ) -+ { -+ case bug_bug: -+ text = "BUG"; -+ break; -+ case bug_warn: -+ text = "Badness"; -+ break; -+ case bug_dump_state: -+ text = "State"; -+ break; -+ case bug_crash_dom: -+ text = "domain_crash called"; -+ break; -+ } -+ if ( text ) -+ { -+ const void *ptr; -+ -+ ptr = &((const struct bug_frame *)regs->eip)->id + f.file_rel; -+ if ( __addr_ok(ptr) || -+ __copy_from_user(file, ptr, sizeof(file) - 1) ) -+ text = NULL; -+ else -+ file[sizeof(file) - 1] = 0; -+ } -+ if ( text ) -+ { -+ printk("%s at %s:%d\n", text, file, f.line); -+ if ( f.id != bug_bug ) -+ { -+ show_execution_state(regs); -+ regs->eip += sizeof(f); -+ return EXCRET_fault_fixed; -+ } -+ } - } - DEBUGGER_trap_fatal(TRAP_invalid_op, regs); - show_execution_state(regs); -Index: 2007-02-20/xen/common/keyhandler.c -=================================================================== ---- 2007-02-20.orig/xen/common/keyhandler.c 2007-02-20 10:41:46.000000000 +0100 -+++ 2007-02-20/xen/common/keyhandler.c 2007-02-20 10:56:04.000000000 +0100 -@@ -94,7 +94,7 @@ static void show_handlers(unsigned char - - static void __dump_execstate(void *unused) - { -- dump_execution_state(); -+ DUMP_STATE(); - } - - static void dump_registers(unsigned char key, struct cpu_user_regs *regs) -Index: 2007-02-20/xen/drivers/char/console.c -=================================================================== ---- 2007-02-20.orig/xen/drivers/char/console.c 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-02-20/xen/drivers/char/console.c 2007-02-20 10:56:04.000000000 +0100 -@@ -880,15 +880,21 @@ void panic(const char *fmt, ...) - } - } - --void __bug(char *file, int line) -+void __bug(const char *file, int line) - { - console_start_sync(); - printk("BUG at %s:%d\n", file, line); -- dump_execution_state(); -+ DUMP_STATE(); - panic("BUG at %s:%d\n", file, line); - for ( ; ; ) ; - } - -+void __warn(const char *file, int line) __attribute__((__weak__)); -+void __warn(const char *file, int line) -+{ -+ printk("Badness at %s:%d\n", file, line); -+} -+ - /* - * Local variables: - * mode: C -Index: 2007-02-20/xen/include/asm-ia64/bug.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-02-20/xen/include/asm-ia64/bug.h 2007-02-20 10:56:04.000000000 +0100 -@@ -0,0 +1,6 @@ -+#ifndef __ASM_IA64_BUG_H__ -+#define __ASM_IA64_BUG_H__ -+ -+#define DUMP_STATE() printk("FIXME: implement ia64 dump_execution_state()\n"); -+ -+#endif /* __ASM_IA64_BUG_H__ */ -Index: 2007-02-20/xen/include/asm-ia64/linux-xen/asm/iosapic.h -=================================================================== ---- 2007-02-20.orig/xen/include/asm-ia64/linux-xen/asm/iosapic.h 2006-12-13 11:15:55.000000000 +0100 -+++ 2007-02-20/xen/include/asm-ia64/linux-xen/asm/iosapic.h 2007-02-20 10:56:04.000000000 +0100 -@@ -123,11 +123,10 @@ static inline void list_move(struct list - - #define move_irq(x) - --#define WARN_ON(condition) do { \ -- if (unlikely((condition)!=0)) { \ -- printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ -- dump_stack(); \ -- } \ -+#undef WARN -+#define WARN() do { \ -+ printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \ -+ dump_stack(); \ - } while (0) - - #ifdef nop -Index: 2007-02-20/xen/include/asm-ia64/xenprocessor.h -=================================================================== ---- 2007-02-20.orig/xen/include/asm-ia64/xenprocessor.h 2006-12-13 11:15:55.000000000 +0100 -+++ 2007-02-20/xen/include/asm-ia64/xenprocessor.h 2007-02-20 10:56:04.000000000 +0100 -@@ -237,6 +237,4 @@ typedef union { - u64 itir; - } ia64_itir_t; - --#define dump_execution_state() printk("FIXME: implement ia64 dump_execution_state()\n"); -- - #endif // _ASM_IA64_XENPROCESSOR_H -Index: 2007-02-20/xen/include/asm-powerpc/bug.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-02-20/xen/include/asm-powerpc/bug.h 2007-02-20 10:56:04.000000000 +0100 -@@ -0,0 +1,7 @@ -+#ifndef __ASM_PPC_BUG_H__ -+#define __ASM_PPC_BUG_H__ -+ -+extern void dump_execution_state(void); -+#define DUMP_STATE() dump_execution_state() -+ -+#endif /* __ASM_PPC_BUG_H__ */ -Index: 2007-02-20/xen/include/asm-powerpc/debugger.h -=================================================================== ---- 2007-02-20.orig/xen/include/asm-powerpc/debugger.h 2006-12-15 16:33:59.000000000 +0100 -+++ 2007-02-20/xen/include/asm-powerpc/debugger.h 2007-02-20 10:56:04.000000000 +0100 -@@ -67,10 +67,6 @@ static inline void unimplemented(void) - #endif - } - --extern void __warn(char *file, int line); --#define WARN() __warn(__FILE__, __LINE__) --#define WARN_ON(_p) do { if (_p) WARN(); } while ( 0 ) -- - extern void __attn(void); - #define ATTN() __attn(); - -Index: 2007-02-20/xen/include/asm-x86/bug.h -=================================================================== ---- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ 2007-02-20/xen/include/asm-x86/bug.h 2007-02-20 10:56:04.000000000 +0100 -@@ -0,0 +1,60 @@ -+#ifndef __ASM_X86_BUG_H__ -+#define __ASM_X86_BUG_H__ -+ -+enum bug_id { -+ bug_bug = 0xb8, -+ bug_warn, -+ bug_dump_state, -+ bug_crash_dom -+} __attribute__((__packed__)); -+ -+struct bug_frame { -+ unsigned char ud2[2]; -+ enum bug_id id; -+ signed int file_rel; -+ unsigned char ret; -+ unsigned short line; -+} __attribute__((__packed__)); -+ -+/* NB. These need interrupts enabled else we end up in fatal_trap(). */ -+ -+#define BUG() __asm__ __volatile__( \ -+ "pushf\n\t" \ -+ "sti\n\t" \ -+ "ud2\n\t" \ -+ "movl $%c0-.,%%eax\n\t" \ -+ "ret $%c1\n\t" \ -+ "popf" \ -+ : : "i" (__FILE__), "i" (__LINE__)) -+ -+#define WARN() __asm__ __volatile__( \ -+ "pushf\n\t" \ -+ "sti\n\t" \ -+ "ud2\n\t" \ -+ "movl $%c0-.,%%ecx\n\t" \ -+ "ret $%c1\n\t" \ -+ "popf" \ -+ : : "i" (__FILE__), "i" (__LINE__)) -+ -+#define DUMP_STATE() __asm__ __volatile__( \ -+ "pushf\n\t" \ -+ "sti\n\t" \ -+ "ud2\n\t" \ -+ "movl $%c0-.,%%edx\n\t" \ -+ "ret $%c1\n\t" \ -+ "popf" \ -+ : : "i" (__FILE__), "i" (__LINE__)) -+ -+#define CRASH_DOM(d) do { \ -+ __asm__ __volatile__( \ -+ "pushf\n\t" \ -+ "sti\n\t" \ -+ "ud2\n\t" \ -+ "movl $%c0-.,%%ebx\n\t" \ -+ "ret $%c1\n\t" \ -+ "popf" \ -+ : : "i" (__FILE__), "i" (__LINE__)); \ -+ __domain_crash(d); \ -+ } while (0) -+ -+#endif /* __ASM_X86_BUG_H__ */ -Index: 2007-02-20/xen/include/asm-x86/processor.h -=================================================================== ---- 2007-02-20.orig/xen/include/asm-x86/processor.h 2007-02-20 10:41:44.000000000 +0100 -+++ 2007-02-20/xen/include/asm-x86/processor.h 2007-02-20 10:56:04.000000000 +0100 -@@ -565,11 +565,6 @@ void compat_show_guest_stack(struct cpu_ - #define compat_show_guest_stack(regs, lines) ((void)0) - #endif - --/* Dumps current register and stack state. */ --#define dump_execution_state() \ -- /* NB. Needs interrupts enabled else we end up in fatal_trap(). */ \ -- __asm__ __volatile__ ( "pushf ; sti ; ud2 ; .ascii \"dbg\" ; popf" ) -- - extern void mtrr_ap_init(void); - extern void mtrr_bp_init(void); - -Index: 2007-02-20/xen/include/xen/lib.h -=================================================================== ---- 2007-02-20.orig/xen/include/xen/lib.h 2007-01-08 14:16:35.000000000 +0100 -+++ 2007-02-20/xen/include/xen/lib.h 2007-02-20 10:56:04.000000000 +0100 -@@ -7,10 +7,26 @@ - #include - #include - #include -+#include - --extern void __bug(char *file, int line) __attribute__((noreturn)); -+#ifndef BUG -+extern void __bug(const char *file, int line) __attribute__((noreturn)); - #define BUG() __bug(__FILE__, __LINE__) --#define BUG_ON(_p) do { if (_p) BUG(); } while ( 0 ) -+#endif -+ -+#ifndef WARN -+extern void __warn(const char *file, int line); -+#define WARN() __warn(__FILE__, __LINE__) -+#endif -+ -+#ifndef CRASH_DOM -+#define CRASH_DOM(d) domain_crash(d) -+#endif -+ -+#define BUG_ON(_p) do { if (unlikely(_p)) BUG(); } while ( 0 ) -+#define WARN_ON(_p) do { if (unlikely(_p)) WARN(); } while ( 0 ) -+#define DUMP_STATE_ON(_p) do { if (unlikely(_p)) DUMP_STATE(); } while ( 0 ) -+#define CRASH_DOM_ON(_d, _p) do { if (unlikely(_p)) CRASH_DOM(_d); } while ( 0 ) - - /* Force a compilation error if condition is true */ - #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) diff --git a/bugfix-246160-domctl.patch b/bugfix-246160-domctl.patch deleted file mode 100644 index 21907cb..0000000 --- a/bugfix-246160-domctl.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- - xen/common/domctl.c | 17 +++++++++++++---- - 1 file changed, 13 insertions(+), 4 deletions(-) - -Index: build-32-release304-13138/xen/common/domctl.c -=================================================================== ---- build-32-release304-13138.orig/xen/common/domctl.c -+++ build-32-release304-13138/xen/common/domctl.c -@@ -708,12 +708,21 @@ ret_t do_domctl(XEN_GUEST_HANDLE(xen_dom - - #ifdef CONFIG_COMPAT - case XEN_DOMCTL_set_compat: -- ret = switch_compat(find_domain_by_id(op->domain)); -- break; -- - case XEN_DOMCTL_set_native: -- ret = switch_native(find_domain_by_id(op->domain)); -+ { -+ struct domain *d; -+ -+ ret = -ESRCH; -+ d = find_domain_by_id(op->domain); -+ if (d) { -+ if (op->cmd == XEN_DOMCTL_set_compat) -+ ret = switch_compat(d); -+ else -+ ret = switch_native(d); -+ put_domain(d); -+ } - break; -+ } - #endif - - default: diff --git a/cross-build-fix.diff b/cross-build-fix.diff index ef4f696..f5d5bd5 100644 --- a/cross-build-fix.diff +++ b/cross-build-fix.diff @@ -13,11 +13,11 @@ Signed-off-by: Gerd Hoffmann tools/Makefile | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) -Index: build-32-unstable-12621/config/x86_32.mk +Index: xen-unstable/config/x86_32.mk =================================================================== ---- build-32-unstable-12621.orig/config/x86_32.mk -+++ build-32-unstable-12621/config/x86_32.mk -@@ -6,8 +6,10 @@ CONFIG_MIGRATE := y +--- xen-unstable.orig/config/x86_32.mk ++++ xen-unstable/config/x86_32.mk +@@ -7,8 +7,10 @@ CONFIG_MIGRATE := y CONFIG_XCUTILS := y CONFIG_IOEMU := y @@ -30,11 +30,11 @@ Index: build-32-unstable-12621/config/x86_32.mk # Use only if calling $(LD) directly. ifeq ($(XEN_OS),OpenBSD) -Index: build-32-unstable-12621/tools/Makefile +Index: xen-unstable/tools/Makefile =================================================================== ---- build-32-unstable-12621.orig/tools/Makefile -+++ build-32-unstable-12621/tools/Makefile -@@ -62,7 +62,7 @@ check_clean: +--- xen-unstable.orig/tools/Makefile ++++ xen-unstable/tools/Makefile +@@ -63,7 +63,7 @@ check_clean: $(MAKE) -C check clean .PHONY: ioemu ioemuinstall ioemuclean diff --git a/disable_emulated_device.diff b/disable_emulated_device.diff new file mode 100644 index 0000000..5a3138f --- /dev/null +++ b/disable_emulated_device.diff @@ -0,0 +1,20 @@ +Disable the emulated devices when we are loading PV drivers. + +Signed-off-by: K. Y. Srinivasan + +Index: xen-unstable/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +=================================================================== +--- xen-unstable.orig/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c ++++ xen-unstable/unmodified_drivers/linux-2.6/platform-pci/platform-pci.c +@@ -247,6 +247,11 @@ static int __devinit platform_pci_init(s + platform_mmio = mmio_addr; + platform_mmiolen = mmio_len; + ++ /* ++ * Disconnect the emulated devices. ++ */ ++ outl(1, (ioaddr + 4)); ++ + ret = get_hypercall_stubs(); + if (ret < 0) + goto out; diff --git a/dom0config b/dom0config new file mode 100644 index 0000000..f441955 --- /dev/null +++ b/dom0config @@ -0,0 +1,56 @@ +## Path: +## Description: +## Type: list(eth0 eth1 eth2 eth3) +## Default: "eth0 eth1 eth2" +## Config: +# +# Space delimited list of physical network +# devices to create traditional bridges on +# +NETDEV_LIST="eth0 eth1 eth2" + +## Path: +## Description: +## Type: list(0 1 2 3) +## Default: "4 5 6 7" +## Config: +# +# Space delimited list of bridge numbers to +# create empty bridges on. +# +EMPTY_BRIDGE_LIST="4 5 6 7" + +## Path: +## Description: +## Type: string(xenbr) +## Default: "xenbr" +## Config: +# +# Name of bridge to create (example: xenbr) +# +BRIDGE_NAME="xenbr" + +## Path: +## Description: +## Type: list(veth1,00:16:3E:01:00:01,172.16.0.1/16 veth2,00:16:3E:01:00:02,172.17.0.1/16) +## Default: "veth3,00:16:3E:01:00:03,172.16.0.1/16" +## Config: +# +# Space delimited list of virtual network devices,mac addresses +# and IP addresses to create host bridges on using the +# following format: +# +# ,, +# +HOST_BRIDGE_LIST="veth3,00:16:3E:01:00:03,172.16.0.1/16" + +## Path: +## Type: string(/etc/xen/scripts) +## Default: "/etc/xen/scripts" +## Config: +# +# Path to the directory containing the xen +# network-bridge script (typically /etc/xen/scripts) +# +SCRIPT_PATH="/etc/xen/scripts" + diff --git a/domUloader.py b/domUloader.py index 53c02b9..ec84852 100644 --- a/domUloader.py +++ b/domUloader.py @@ -428,7 +428,7 @@ def main(argv): try: sxpr = copyKernelAndRamdisk(disk, vdev, kernel, ramdisk) if in_args: - sxpr += "(args %s)" % in_args + sxpr += "(args '%s')" % in_args os.write(fd, sxpr) except Exception, e: error(str(e)) diff --git a/domheap-no-dma.patch b/domheap-no-dma.patch deleted file mode 100644 index c02b1ad..0000000 --- a/domheap-no-dma.patch +++ /dev/null @@ -1,168 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/domain_build.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domain_build.c -+++ xen-3.0.4-testing/xen/arch/x86/domain_build.c -@@ -473,11 +473,14 @@ int construct_dom0(struct domain *d, - if ( (1UL << order) > nr_pages ) - panic("Domain 0 allocation is too small for kernel image.\n"); - -- /* -- * Allocate from DMA pool: on i386 this ensures that our low-memory 1:1 -- * mapping covers the allocation. -- */ -- if ( (page = alloc_domheap_pages(d, order, MEMF_dma)) == NULL ) -+#ifdef __i386__ -+ /* Ensure that our low-memory 1:1 mapping covers the allocation. */ -+ page = alloc_domheap_pages(d, order, -+ MEMF_bits(30 + (dsi.v_start >> 31))); -+#else -+ page = alloc_domheap_pages(d, order, 0); -+#endif -+ if ( page == NULL ) - panic("Not enough RAM for domain 0 allocation.\n"); - alloc_spfn = page_to_mfn(page); - alloc_epfn = alloc_spfn + d->tot_pages; -Index: xen-3.0.4-testing/xen/common/memory.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/common/memory.c -+++ xen-3.0.4-testing/xen/common/memory.c -@@ -322,12 +322,12 @@ static long memory_exchange(XEN_GUEST_HA - (exch.out.address_bits < - (get_order_from_pages(max_page) + PAGE_SHIFT)) ) - { -- if ( exch.out.address_bits < dma_bitsize ) -+ if ( exch.out.address_bits <= PAGE_SHIFT ) - { - rc = -ENOMEM; - goto fail_early; - } -- memflags = MEMF_dma; -+ memflags = MEMF_bits(exch.out.address_bits); - } - - if ( exch.in.extent_order <= exch.out.extent_order ) -@@ -535,9 +535,9 @@ long do_memory_op(unsigned long cmd, XEN - (reservation.address_bits < - (get_order_from_pages(max_page) + PAGE_SHIFT)) ) - { -- if ( reservation.address_bits < dma_bitsize ) -+ if ( reservation.address_bits <= PAGE_SHIFT ) - return start_extent; -- args.memflags = MEMF_dma; -+ args.memflags = MEMF_bits(reservation.address_bits); - } - - if ( likely(reservation.domid == DOMID_SELF) ) -Index: xen-3.0.4-testing/xen/common/page_alloc.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/common/page_alloc.c -+++ xen-3.0.4-testing/xen/common/page_alloc.c -@@ -62,8 +62,8 @@ custom_param("lowmem_emergency_pool", pa - /* - * Bit width of the DMA heap. - */ --unsigned int dma_bitsize = CONFIG_DMA_BITSIZE; --unsigned long max_dma_mfn = (1UL << (CONFIG_DMA_BITSIZE - PAGE_SHIFT)) - 1; -+static unsigned int dma_bitsize = CONFIG_DMA_BITSIZE; -+static unsigned long max_dma_mfn = (1UL << (CONFIG_DMA_BITSIZE - PAGE_SHIFT)) - 1; - static void parse_dma_bits(char *s) - { - unsigned int v = simple_strtol(s, NULL, 0); -@@ -72,7 +72,7 @@ static void parse_dma_bits(char *s) - dma_bitsize = BITS_PER_LONG + PAGE_SHIFT; - max_dma_mfn = ~0UL; - } -- else if ( v > PAGE_SHIFT ) -+ else if ( v > PAGE_SHIFT + 1 ) - { - dma_bitsize = v; - max_dma_mfn = (1UL << (dma_bitsize - PAGE_SHIFT)) - 1; -@@ -725,12 +725,22 @@ struct page_info *__alloc_domheap_pages( - struct page_info *pg = NULL; - cpumask_t mask; - unsigned long i; -+ unsigned int bits = memflags >> _MEMF_bits, zone_hi; - - ASSERT(!in_irq()); - -- if ( !(memflags & MEMF_dma) ) -+ if ( bits && bits <= PAGE_SHIFT + 1 ) -+ return NULL; -+ -+ zone_hi = bits - PAGE_SHIFT - 1; -+ if ( zone_hi >= NR_ZONES ) -+ zone_hi = NR_ZONES - 1; -+ -+ if ( NR_ZONES + PAGE_SHIFT > dma_bitsize && -+ (!bits || bits > dma_bitsize) ) - { -- pg = alloc_heap_pages(dma_bitsize - PAGE_SHIFT, NR_ZONES - 1, cpu, order); -+ pg = alloc_heap_pages(dma_bitsize - PAGE_SHIFT, zone_hi, cpu, order); -+ - /* Failure? Then check if we can fall back to the DMA pool. */ - if ( unlikely(pg == NULL) && - ((order > MAX_ORDER) || -@@ -743,7 +753,7 @@ struct page_info *__alloc_domheap_pages( - - if ( pg == NULL ) - if ( (pg = alloc_heap_pages(MEMZONE_XEN + 1, -- dma_bitsize - PAGE_SHIFT - 1, -+ zone_hi, - cpu, order)) == NULL ) - return NULL; - -Index: xen-3.0.4-testing/xen/include/asm-ia64/config.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-ia64/config.h -+++ xen-3.0.4-testing/xen/include/asm-ia64/config.h -@@ -41,7 +41,7 @@ - #define CONFIG_IOSAPIC - #define supervisor_mode_kernel (0) - --#define CONFIG_DMA_BITSIZE 30 -+#define CONFIG_DMA_BITSIZE 32 - - /* If PERFC is used, include privop maps. */ - #ifdef PERF_COUNTERS -Index: xen-3.0.4-testing/xen/include/asm-x86/config.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/config.h -+++ xen-3.0.4-testing/xen/include/asm-x86/config.h -@@ -82,7 +82,7 @@ - /* Debug stack is restricted to 8kB by guard pages. */ - #define DEBUG_STACK_SIZE 8192 - --#define CONFIG_DMA_BITSIZE 30 -+#define CONFIG_DMA_BITSIZE 32 - - #ifndef __ASSEMBLY__ - extern unsigned long _end; /* standard ELF symbol */ -Index: xen-3.0.4-testing/xen/include/xen/mm.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/xen/mm.h -+++ xen-3.0.4-testing/xen/include/xen/mm.h -@@ -71,10 +71,10 @@ int assign_pages( - unsigned int memflags); - - /* memflags: */ --#define _MEMF_dma 0 --#define MEMF_dma (1U<<_MEMF_dma) --#define _MEMF_no_refcount 1 -+#define _MEMF_no_refcount 0 - #define MEMF_no_refcount (1U<<_MEMF_no_refcount) -+#define _MEMF_bits 24 -+#define MEMF_bits(n) ((n)<<_MEMF_bits) - - #ifdef CONFIG_PAGEALLOC_MAX_ORDER - #define MAX_ORDER CONFIG_PAGEALLOC_MAX_ORDER -@@ -82,10 +82,6 @@ int assign_pages( - #define MAX_ORDER 20 /* 2^20 contiguous pages */ - #endif - --/* DMA heap parameters. */ --extern unsigned int dma_bitsize; --extern unsigned long max_dma_mfn; -- - /* Automatic page scrubbing for dead domains. */ - extern struct list_head page_scrub_list; - #define page_scrub_schedule_work() \ diff --git a/emul-privop-lock.patch b/emul-privop-lock.patch deleted file mode 100644 index e5564db..0000000 --- a/emul-privop-lock.patch +++ /dev/null @@ -1,76 +0,0 @@ -Index: 2007-01-31/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/traps.c 2007-01-31 09:41:46.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/traps.c 2007-01-31 09:41:54.000000000 +0100 -@@ -1196,7 +1196,7 @@ static int emulate_privileged_op(struct - { - struct vcpu *v = current; - unsigned long *reg, eip = regs->eip, res; -- u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0, rex = 0; -+ u8 opcode, modrm_reg = 0, modrm_rm = 0, rep_prefix = 0, lock = 0, rex = 0; - enum { lm_seg_none, lm_seg_fs, lm_seg_gs } lm_ovr = lm_seg_none; - unsigned int port, i, data_sel, ar, data, rc; - unsigned int op_bytes, op_default, ad_bytes, ad_default; -@@ -1261,6 +1261,7 @@ static int emulate_privileged_op(struct - data_sel = regs->ss; - continue; - case 0xf0: /* LOCK */ -+ lock = 1; - continue; - case 0xf2: /* REPNE/REPNZ */ - case 0xf3: /* REP/REPE/REPZ */ -@@ -1287,6 +1288,9 @@ static int emulate_privileged_op(struct - if ( opcode == 0x0f ) - goto twobyte_opcode; - -+ if ( lock ) -+ goto fail; -+ - /* Input/Output String instructions. */ - if ( (opcode >= 0x6c) && (opcode <= 0x6f) ) - { -@@ -1550,6 +1554,8 @@ static int emulate_privileged_op(struct - - /* Privileged (ring 0) instructions. */ - opcode = insn_fetch(u8, code_base, eip, code_limit); -+ if ( lock && (opcode & ~3) != 0x20 ) -+ goto fail; - switch ( opcode ) - { - case 0x06: /* CLTS */ -@@ -1568,7 +1574,7 @@ static int emulate_privileged_op(struct - - case 0x20: /* MOV CR?, */ - opcode = insn_fetch(u8, code_base, eip, code_limit); -- modrm_reg |= (opcode >> 3) & 7; -+ modrm_reg += ((opcode >> 3) & 7) + (lock << 3); - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); - switch ( modrm_reg ) -@@ -1608,7 +1614,7 @@ static int emulate_privileged_op(struct - - case 0x21: /* MOV DR?, */ - opcode = insn_fetch(u8, code_base, eip, code_limit); -- modrm_reg |= (opcode >> 3) & 7; -+ modrm_reg += ((opcode >> 3) & 7) + (lock << 3); - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); - if ( (res = do_get_debugreg(modrm_reg)) > (unsigned long)-256 ) -@@ -1618,7 +1624,7 @@ static int emulate_privileged_op(struct - - case 0x22: /* MOV ,CR? */ - opcode = insn_fetch(u8, code_base, eip, code_limit); -- modrm_reg |= (opcode >> 3) & 7; -+ modrm_reg += ((opcode >> 3) & 7) + (lock << 3); - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); - switch ( modrm_reg ) -@@ -1666,7 +1672,7 @@ static int emulate_privileged_op(struct - - case 0x23: /* MOV ,DR? */ - opcode = insn_fetch(u8, code_base, eip, code_limit); -- modrm_reg |= (opcode >> 3) & 7; -+ modrm_reg += ((opcode >> 3) & 7) + (lock << 3); - modrm_rm |= (opcode >> 0) & 7; - reg = decode_register(modrm_rm, regs, 0); - if ( do_set_debugreg(modrm_reg, *reg) != 0 ) diff --git a/fbback-bimodal.diff b/fbback-bimodal.diff deleted file mode 100644 index 5496936..0000000 --- a/fbback-bimodal.diff +++ /dev/null @@ -1,158 +0,0 @@ -bimodal: pvfb backend - -Teach pvfb backend to deal with bith 32 and 64 bit frontends. - -Signed-off-by: Gerd Hoffmann ---- - tools/xenfb/xenfb.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 87 insertions(+), 11 deletions(-) - -Index: build-32-release304-13133/tools/xenfb/xenfb.c -=================================================================== ---- build-32-release304-13133.orig/tools/xenfb/xenfb.c -+++ build-32-release304-13133/tools/xenfb/xenfb.c -@@ -7,6 +7,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -40,6 +41,7 @@ struct xenfb_private { - struct xs_handle *xsh; /* xs daemon handle */ - struct xenfb_device fb, kbd; - size_t fb_len; /* size of framebuffer */ -+ char protocol[64]; /* frontend protocol */ - }; - - static void xenfb_detach_dom(struct xenfb_private *); -@@ -324,36 +326,107 @@ static int xenfb_wait_for_frontend_initi - return 0; - } - -+static void xenfb_copy_mfns(int mode, int count, unsigned long *dst, void *src) -+{ -+ uint32_t *src32 = src; -+ uint64_t *src64 = src; -+ int i; -+ -+ for (i = 0; i < count; i++) -+ dst[i] = (mode == 32) ? src32[i] : src64[i]; -+} -+ - static int xenfb_map_fb(struct xenfb_private *xenfb, int domid) - { - struct xenfb_page *page = xenfb->fb.page; - int n_fbmfns; - int n_fbdirs; -- unsigned long *fbmfns; -+ unsigned long *pgmfns = NULL; -+ unsigned long *fbmfns = NULL; -+ void *map, *pd; -+ int mode, ret = -1; -+ -+ /* default to native */ -+ pd = page->pd; -+ mode = sizeof(unsigned long) * 8; -+ -+ if (0 == strlen(xenfb->protocol)) { -+ /* -+ * Undefined protocol, some guesswork needed. -+ * -+ * Old frontends which don't set the protocol use -+ * one page directory only, thus pd[1] must be zero. -+ * pd[1] of the 32bit struct layout and the lower -+ * 32 bits of pd[0] of the 64bit struct layout have -+ * the same location, so we can check that ... -+ */ -+ uint32_t *ptr32 = NULL; -+ uint32_t *ptr64 = NULL; -+#if defined(__i386__) -+ ptr32 = (void*)page->pd; -+ ptr64 = ((void*)page->pd) + 4; -+#elif defined(__x86_64__) -+ ptr32 = ((void*)page->pd) - 4; -+ ptr64 = (void*)page->pd; -+#endif -+ if (ptr32) { -+ if (0 == ptr32[1]) { -+ mode = 32; -+ pd = ptr32; -+ } else { -+ mode = 64; -+ pd = ptr64; -+ } -+ } -+#if defined(__x86_64__) -+ } else if (0 == strcmp(xenfb->protocol, XEN_IO_PROTO_ABI_X86_32)) { -+ /* 64bit dom0, 32bit domU */ -+ mode = 32; -+ pd = ((void*)page->pd) - 4; -+#elif defined(__i386__) -+ } else if (0 == strcmp(xenfb->protocol, XEN_IO_PROTO_ABI_X86_64)) { -+ /* 32bit dom0, 64bit domU */ -+ mode = 64; -+ pd = ((void*)page->pd) + 4; -+#endif -+ } - - n_fbmfns = (xenfb->fb_len + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; -- n_fbdirs = n_fbmfns * sizeof(unsigned long); -+ n_fbdirs = n_fbmfns * mode / 8; - n_fbdirs = (n_fbdirs + (XC_PAGE_SIZE - 1)) / XC_PAGE_SIZE; - -+ pgmfns = malloc(sizeof(unsigned long) * n_fbdirs); -+ fbmfns = malloc(sizeof(unsigned long) * n_fbmfns); -+ if (!pgmfns || !fbmfns) -+ goto out; -+ - /* - * Bug alert: xc_map_foreign_batch() can fail partly and - * return a non-null value. This is a design flaw. When it - * happens, we happily continue here, and later crash on - * access. - */ -- fbmfns = xc_map_foreign_batch(xenfb->xc, domid, -- PROT_READ, page->pd, n_fbdirs); -- if (fbmfns == NULL) -- return -1; -+ xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd); -+ map = xc_map_foreign_batch(xenfb->xc, domid, -+ PROT_READ, pgmfns, n_fbdirs); -+ if (map == NULL) -+ goto out; -+ xenfb_copy_mfns(mode, n_fbmfns, fbmfns, map); -+ munmap(map, n_fbdirs * XC_PAGE_SIZE); - - xenfb->pub.pixels = xc_map_foreign_batch(xenfb->xc, domid, - PROT_READ | PROT_WRITE, fbmfns, n_fbmfns); -- if (xenfb->pub.pixels == NULL) { -- munmap(fbmfns, n_fbdirs * XC_PAGE_SIZE); -- return -1; -- } -+ if (xenfb->pub.pixels == NULL) -+ goto out; - -- return munmap(fbmfns, n_fbdirs * XC_PAGE_SIZE); -+ ret = 0; /* all is fine */ -+ -+ out: -+ if (pgmfns) -+ free(pgmfns); -+ if (fbmfns) -+ free(fbmfns); -+ return ret; - } - - static int xenfb_bind(struct xenfb_device *dev) -@@ -491,6 +564,9 @@ int xenfb_attach_dom(struct xenfb *xenfb - errno = ENOTSUP; - goto error; - } -+ if (xenfb_xs_scanf1(xsh, xenfb->fb.otherend, "protocol", "%63s", -+ xenfb->protocol) < 0) -+ xenfb->protocol[0] = '\0'; - xenfb_xs_printf(xsh, xenfb->fb.nodename, "request-update", "1"); - - /* TODO check for permitted ranges */ diff --git a/hide-asm-labels.patch b/hide-asm-labels.patch deleted file mode 100644 index ac168a3..0000000 --- a/hide-asm-labels.patch +++ /dev/null @@ -1,505 +0,0 @@ -Index: 2006-12-11/xen/arch/x86/x86_32/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_32/entry.S 2006-12-15 15:21:44.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_32/entry.S 2006-12-15 15:39:13.000000000 +0100 -@@ -84,10 +84,10 @@ restore_all_guest: - jmp restore_all_vm86 - 1: - #endif --FLT1: mov UREGS_ds(%esp),%ds --FLT2: mov UREGS_es(%esp),%es --FLT3: mov UREGS_fs(%esp),%fs --FLT4: mov UREGS_gs(%esp),%gs -+.LFT1: mov UREGS_ds(%esp),%ds -+.LFT2: mov UREGS_es(%esp),%es -+.LFT3: mov UREGS_fs(%esp),%fs -+.LFT4: mov UREGS_gs(%esp),%gs - restore_all_vm86: - popl %ebx - popl %ecx -@@ -97,9 +97,9 @@ restore_all_vm86: - popl %ebp - popl %eax - addl $4,%esp --FLT5: iret -+.LFT5: iret - .section .fixup,"ax" --FIX5: subl $28,%esp -+.LFX5: subl $28,%esp - pushl 28(%esp) # error_code/entry_vector - movl %eax,UREGS_eax+4(%esp) - movl %ebp,UREGS_ebp+4(%esp) -@@ -108,7 +108,7 @@ FIX5: subl $28,%esp - movl %edx,UREGS_edx+4(%esp) - movl %ecx,UREGS_ecx+4(%esp) - movl %ebx,UREGS_ebx+4(%esp) --FIX1: SET_XEN_SEGMENTS(a) -+.LFX1: SET_XEN_SEGMENTS(a) - movl %eax,%fs - movl %eax,%gs - sti -@@ -116,11 +116,11 @@ FIX1: SET_XEN_SEGMENTS(a) - pushfl # EFLAGS - movl $__HYPERVISOR_CS,%eax - pushl %eax # CS -- movl $DBLFLT1,%eax -+ movl $.LDF1,%eax - pushl %eax # EIP - pushl %esi # error_code/entry_vector - jmp handle_exception --DBLFLT1:GET_CURRENT(%ebx) -+.LDF1: GET_CURRENT(%ebx) - jmp test_all_events - failsafe_callback: - GET_CURRENT(%ebx) -@@ -142,14 +142,14 @@ failsafe_callback: - jmp test_all_events - .previous - .section __pre_ex_table,"a" -- .long FLT1,FIX1 -- .long FLT2,FIX1 -- .long FLT3,FIX1 -- .long FLT4,FIX1 -- .long FLT5,FIX5 -+ .long .LFT1,.LFX1 -+ .long .LFT2,.LFX1 -+ .long .LFT3,.LFX1 -+ .long .LFT4,.LFX1 -+ .long .LFT5,.LFX5 - .previous - .section __ex_table,"a" -- .long DBLFLT1,failsafe_callback -+ .long .LDF1,failsafe_callback - .previous - - ALIGN -@@ -288,32 +288,33 @@ create_bounce_frame: - testl $(2|X86_EFLAGS_VM),%ecx - jz ring1 /* jump if returning to an existing ring-1 activation */ - movl VCPU_kernel_sp(%ebx),%esi --FLT6: mov VCPU_kernel_ss(%ebx),%gs -+.LFT6: mov VCPU_kernel_ss(%ebx),%gs - testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) -- jz nvm86_1 -+ jz .Lnvm86_1 - subl $16,%esi /* push ES/DS/FS/GS (VM86 stack frame) */ - movl UREGS_es+4(%esp),%eax --FLT7: movl %eax,%gs:(%esi) -+.LFT7: movl %eax,%gs:(%esi) - movl UREGS_ds+4(%esp),%eax --FLT8: movl %eax,%gs:4(%esi) -+.LFT8: movl %eax,%gs:4(%esi) - movl UREGS_fs+4(%esp),%eax --FLT9: movl %eax,%gs:8(%esi) -+.LFT9: movl %eax,%gs:8(%esi) - movl UREGS_gs+4(%esp),%eax --FLT10: movl %eax,%gs:12(%esi) --nvm86_1:subl $8,%esi /* push SS/ESP (inter-priv iret) */ -+.LFT10: movl %eax,%gs:12(%esi) -+.Lnvm86_1: -+ subl $8,%esi /* push SS/ESP (inter-priv iret) */ - movl UREGS_esp+4(%esp),%eax --FLT11: movl %eax,%gs:(%esi) -+.LFT11: movl %eax,%gs:(%esi) - movl UREGS_ss+4(%esp),%eax --FLT12: movl %eax,%gs:4(%esi) -+.LFT12: movl %eax,%gs:4(%esi) - jmp 1f - ring1: /* obtain ss/esp from oldss/oldesp -- a ring-1 activation exists */ - movl UREGS_esp+4(%esp),%esi --FLT13: mov UREGS_ss+4(%esp),%gs -+.LFT13: mov UREGS_ss+4(%esp),%gs - 1: /* Construct a stack frame: EFLAGS, CS/EIP */ - movb TRAPBOUNCE_flags(%edx),%cl - subl $12,%esi - movl UREGS_eip+4(%esp),%eax --FLT14: movl %eax,%gs:(%esi) -+.LFT14: movl %eax,%gs:(%esi) - movl VCPU_vcpu_info(%ebx),%eax - pushl VCPUINFO_upcall_mask(%eax) - testb $TBF_INTERRUPT,%cl -@@ -324,49 +325,51 @@ FLT14: movl %eax,%gs:(%esi) - movw UREGS_cs+4(%esp),%ax # Bits 0-15: CS - #ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL - testw $2,%ax -- jnz FLT15 -+ jnz .LFT15 - and $~3,%ax # RPL 1 -> RPL 0 - #endif --FLT15: movl %eax,%gs:4(%esi) -+.LFT15: movl %eax,%gs:4(%esi) - test $0x00FF0000,%eax # Bits 16-23: saved_upcall_mask - setz %ch # %ch == !saved_upcall_mask - movl UREGS_eflags+4(%esp),%eax - andl $~X86_EFLAGS_IF,%eax - shlb $1,%ch # Bit 9 (EFLAGS.IF) - orb %ch,%ah # Fold EFLAGS.IF into %eax --FLT16: movl %eax,%gs:8(%esi) -+.LFT16: movl %eax,%gs:8(%esi) - test $TBF_EXCEPTION_ERRCODE,%cl - jz 1f - subl $4,%esi # push error_code onto guest frame - movl TRAPBOUNCE_error_code(%edx),%eax --FLT17: movl %eax,%gs:(%esi) -+.LFT17: movl %eax,%gs:(%esi) - 1: testb $TBF_FAILSAFE,%cl - jz 2f - subl $16,%esi # add DS/ES/FS/GS to failsafe stack frame - testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) -- jz nvm86_2 -+ jz .Lnvm86_2 - xorl %eax,%eax # VM86: we write zero selector values --FLT18: movl %eax,%gs:(%esi) --FLT19: movl %eax,%gs:4(%esi) --FLT20: movl %eax,%gs:8(%esi) --FLT21: movl %eax,%gs:12(%esi) -+.LFT18: movl %eax,%gs:(%esi) -+.LFT19: movl %eax,%gs:4(%esi) -+.LFT20: movl %eax,%gs:8(%esi) -+.LFT21: movl %eax,%gs:12(%esi) - jmp 2f --nvm86_2:movl UREGS_ds+4(%esp),%eax # non-VM86: write real selector values --FLT22: movl %eax,%gs:(%esi) -+.Lnvm86_2: -+ movl UREGS_ds+4(%esp),%eax # non-VM86: write real selector values -+.LFT22: movl %eax,%gs:(%esi) - movl UREGS_es+4(%esp),%eax --FLT23: movl %eax,%gs:4(%esi) -+.LFT23: movl %eax,%gs:4(%esi) - movl UREGS_fs+4(%esp),%eax --FLT24: movl %eax,%gs:8(%esi) -+.LFT24: movl %eax,%gs:8(%esi) - movl UREGS_gs+4(%esp),%eax --FLT25: movl %eax,%gs:12(%esi) -+.LFT25: movl %eax,%gs:12(%esi) - 2: testl $X86_EFLAGS_VM,UREGS_eflags+4(%esp) -- jz nvm86_3 -+ jz .Lnvm86_3 - xorl %eax,%eax /* zero DS-GS, just as a real CPU would */ - movl %eax,UREGS_ds+4(%esp) - movl %eax,UREGS_es+4(%esp) - movl %eax,UREGS_fs+4(%esp) - movl %eax,UREGS_gs+4(%esp) --nvm86_3:/* Rewrite our stack frame and return to ring 1. */ -+.Lnvm86_3: -+ /* Rewrite our stack frame and return to ring 1. */ - /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */ - andl $~(X86_EFLAGS_VM|X86_EFLAGS_RF|\ - X86_EFLAGS_NT|X86_EFLAGS_TF),UREGS_eflags+4(%esp) -@@ -382,16 +385,16 @@ nvm86_3:/* Rewrite our stack frame and r - movb $0,TRAPBOUNCE_flags(%edx) - ret - .section __ex_table,"a" -- .long FLT6,domain_crash_synchronous , FLT7,domain_crash_page_fault -- .long FLT8,domain_crash_page_fault_4 , FLT9,domain_crash_page_fault_8 -- .long FLT10,domain_crash_page_fault_12, FLT11,domain_crash_page_fault -- .long FLT12,domain_crash_page_fault_4 , FLT13,domain_crash_synchronous -- .long FLT14,domain_crash_page_fault , FLT15,domain_crash_page_fault_4 -- .long FLT16,domain_crash_page_fault_8 , FLT17,domain_crash_page_fault -- .long FLT18,domain_crash_page_fault , FLT19,domain_crash_page_fault_4 -- .long FLT20,domain_crash_page_fault_8 , FLT21,domain_crash_page_fault_12 -- .long FLT22,domain_crash_page_fault , FLT23,domain_crash_page_fault_4 -- .long FLT24,domain_crash_page_fault_8 , FLT25,domain_crash_page_fault_12 -+ .long .LFT6,domain_crash_synchronous , .LFT7,domain_crash_page_fault -+ .long .LFT8,domain_crash_page_fault_4 , .LFT9,domain_crash_page_fault_8 -+ .long .LFT10,domain_crash_page_fault_12, .LFT11,domain_crash_page_fault -+ .long .LFT12,domain_crash_page_fault_4 , .LFT13,domain_crash_synchronous -+ .long .LFT14,domain_crash_page_fault , .LFT15,domain_crash_page_fault_4 -+ .long .LFT16,domain_crash_page_fault_8 , .LFT17,domain_crash_page_fault -+ .long .LFT18,domain_crash_page_fault , .LFT19,domain_crash_page_fault_4 -+ .long .LFT20,domain_crash_page_fault_8 , .LFT21,domain_crash_page_fault_12 -+ .long .LFT22,domain_crash_page_fault , .LFT23,domain_crash_page_fault_4 -+ .long .LFT24,domain_crash_page_fault_8 , .LFT25,domain_crash_page_fault_12 - .previous - - .section .rodata,"a" -Index: 2006-12-11/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:39:03.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/compat/entry.S 2006-12-15 15:39:13.000000000 +0100 -@@ -118,10 +118,10 @@ compat_bad_hypercall: - compat_restore_all_guest: - RESTORE_ALL - addq $8,%rsp --CFLT0: iretq -+.Lft0: iretq - - .section .fixup,"ax" --CFIX0: popq -15*8-8(%rsp) # error_code/entry_vector -+.Lfx0: popq -15*8-8(%rsp) # error_code/entry_vector - SAVE_ALL # 15*8 bytes pushed - movq -8(%rsp),%rsi # error_code/entry_vector - sti # after stack abuse (-1024(%rsp)) -@@ -130,11 +130,11 @@ CFIX0: popq -15*8-8(%rsp) # - pushq %rax # RSP - pushfq # RFLAGS - pushq $__HYPERVISOR_CS # CS -- leaq CDBLFLT0(%rip),%rax -+ leaq .Ldf0(%rip),%rax - pushq %rax # RIP - pushq %rsi # error_code/entry_vector - jmp handle_exception --CDBLFLT0:GET_CURRENT(%rbx) -+.Ldf0: GET_CURRENT(%rbx) - jmp compat_test_all_events - compat_failsafe_callback: - GET_CURRENT(%rbx) -@@ -152,10 +152,10 @@ compat_failsafe_callback: - jmp compat_test_all_events - .previous - .section __pre_ex_table,"a" -- .quad CFLT0,CFIX0 -+ .quad .Lft0,.Lfx0 - .previous - .section __ex_table,"a" -- .quad CDBLFLT0,compat_failsafe_callback -+ .quad .Ldf0,compat_failsafe_callback - .previous - - /* %rdx: trap_bounce, %rbx: struct vcpu */ -@@ -175,16 +175,16 @@ compat_create_bounce_frame: - jz 1f - /* Push new frame at registered guest-OS stack base. */ - movl VCPU_kernel_sp(%rbx),%esi --CFLT1: mov VCPU_kernel_ss(%rbx),%fs -+.Lft1: mov VCPU_kernel_ss(%rbx),%fs - subl $2*4,%esi - movl UREGS_rsp+8(%rsp),%eax --CFLT2: movl %eax,%fs:(%rsi) -+.Lft2: movl %eax,%fs:(%rsi) - movl UREGS_ss+8(%rsp),%eax --CFLT3: movl %eax,%fs:4(%rsi) -+.Lft3: movl %eax,%fs:4(%rsi) - jmp 2f - 1: /* In kernel context already: push new frame at existing %rsp. */ - movl UREGS_rsp+8(%rsp),%esi --CFLT4: mov UREGS_ss+8(%rsp),%fs -+.Lft4: mov UREGS_ss+8(%rsp),%fs - 2: - movb TRAPBOUNCE_flags(%rdx),%cl - subl $3*4,%esi -@@ -196,7 +196,7 @@ CFLT4: mov UREGS_ss+8(%rsp),%fs - popq %rax - shll $16,%eax # Bits 16-23: saved_upcall_mask - movw UREGS_cs+8(%rsp),%ax # Bits 0-15: CS --CFLT5: movl %eax,%fs:4(%rsi) # CS / saved_upcall_mask -+.Lft5: movl %eax,%fs:4(%rsi) # CS / saved_upcall_mask - shrl $16,%eax - testb %al,%al # Bits 0-7: saved_upcall_mask - setz %ch # %ch == !saved_upcall_mask -@@ -204,25 +204,25 @@ CFLT5: movl %eax,%fs:4(%rsi) - andl $~X86_EFLAGS_IF,%eax - shlb $1,%ch # Bit 9 (EFLAGS.IF) - orb %ch,%ah # Fold EFLAGS.IF into %eax --CFLT6: movl %eax,%fs:2*4(%rsi) # EFLAGS -+.Lft6: movl %eax,%fs:2*4(%rsi) # EFLAGS - movl UREGS_rip+8(%rsp),%eax --CFLT7: movl %eax,%fs:(%rsi) # EIP -+.Lft7: movl %eax,%fs:(%rsi) # EIP - testb $TBF_EXCEPTION_ERRCODE,%cl - jz 1f - subl $4,%esi - movl TRAPBOUNCE_error_code(%rdx),%eax --CFLT8: movl %eax,%fs:(%rsi) # ERROR CODE -+.Lft8: movl %eax,%fs:(%rsi) # ERROR CODE - 1: - testb $TBF_FAILSAFE,%cl - jz 2f - subl $4*4,%esi - movl %gs,%eax --CFLT9: movl %eax,%fs:3*4(%rsi) # GS --CFLT10: movl %edi,%fs:2*4(%rsi) # FS -+.Lft9: movl %eax,%fs:3*4(%rsi) # GS -+.Lft10: movl %edi,%fs:2*4(%rsi) # FS - movl %es,%eax --CFLT11: movl %eax,%fs:1*4(%rsi) # ES -+.Lft11: movl %eax,%fs:1*4(%rsi) # ES - movl %ds,%eax --CFLT12: movl %eax,%fs:0*4(%rsi) # DS -+.Lft12: movl %eax,%fs:0*4(%rsi) # DS - 2: - /* Rewrite our stack frame and return to guest-OS mode. */ - /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */ -@@ -231,7 +231,7 @@ CFLT12: movl %eax,%fs:0*4(%rsi) - X86_EFLAGS_NT|X86_EFLAGS_TF),UREGS_eflags+8(%rsp) - mov %fs,UREGS_ss+8(%rsp) - movl %esi,UREGS_rsp+8(%rsp) --CFLT13: mov %edi,%fs -+.Lft13: mov %edi,%fs - movzwl TRAPBOUNCE_cs(%rdx),%eax - /* Null selectors (0-3) are not allowed. */ - testl $~3,%eax -@@ -242,18 +242,18 @@ CFLT13: mov %edi,%fs - movb $0,TRAPBOUNCE_flags(%rdx) - ret - .section .fixup,"ax" --CFIX13: -+.Lfx13: - xorl %edi,%edi -- jmp CFLT13 -+ jmp .Lft13 - .previous - .section __ex_table,"a" -- .quad CFLT1,domain_crash_synchronous , CFLT2,compat_crash_page_fault -- .quad CFLT3,compat_crash_page_fault_4 , CFLT4,domain_crash_synchronous -- .quad CFLT5,compat_crash_page_fault_4 , CFLT6,compat_crash_page_fault_8 -- .quad CFLT7,compat_crash_page_fault , CFLT8,compat_crash_page_fault -- .quad CFLT9,compat_crash_page_fault_12, CFLT10,compat_crash_page_fault_8 -- .quad CFLT11,compat_crash_page_fault_4 , CFLT12,compat_crash_page_fault -- .quad CFLT13,CFIX13 -+ .quad .Lft1,domain_crash_synchronous , .Lft2,compat_crash_page_fault -+ .quad .Lft3,compat_crash_page_fault_4 , .Lft4,domain_crash_synchronous -+ .quad .Lft5,compat_crash_page_fault_4 , .Lft6,compat_crash_page_fault_8 -+ .quad .Lft7,compat_crash_page_fault , .Lft8,compat_crash_page_fault -+ .quad .Lft9,compat_crash_page_fault_12, .Lft10,compat_crash_page_fault_8 -+ .quad .Lft11,compat_crash_page_fault_4 , .Lft12,compat_crash_page_fault -+ .quad .Lft13,.Lfx13 - .previous - - compat_crash_page_fault_12: -@@ -263,17 +263,17 @@ compat_crash_page_fault_8: - compat_crash_page_fault_4: - addl $4,%esi - compat_crash_page_fault: --CFLT14: mov %edi,%fs -+.Lft14: mov %edi,%fs - movl %esi,%edi - call show_page_walk - jmp domain_crash_synchronous - .section .fixup,"ax" --CFIX14: -+.Lfx14: - xorl %edi,%edi -- jmp CFLT14 -+ jmp .Lft14 - .previous - .section __ex_table,"a" -- .quad CFLT14,CFIX14 -+ .quad .Lft14,.Lfx14 - .previous - - .section .rodata, "a", @progbits -Index: 2006-12-11/xen/arch/x86/x86_64/entry.S -=================================================================== ---- 2006-12-11.orig/xen/arch/x86/x86_64/entry.S 2006-12-15 15:23:16.000000000 +0100 -+++ 2006-12-11/xen/arch/x86/x86_64/entry.S 2006-12-15 15:39:13.000000000 +0100 -@@ -56,10 +56,10 @@ restore_all_guest: - /* No special register assumptions. */ - iret_exit_to_guest: - addq $8,%rsp --FLT1: iretq -+.LFT1: iretq - - .section .fixup,"ax" --FIX1: popq -15*8-8(%rsp) # error_code/entry_vector -+.LFX1: popq -15*8-8(%rsp) # error_code/entry_vector - SAVE_ALL # 15*8 bytes pushed - movq -8(%rsp),%rsi # error_code/entry_vector - sti # after stack abuse (-1024(%rsp)) -@@ -68,11 +68,11 @@ FIX1: popq -15*8-8(%rsp) # - pushq %rax # RSP - pushf # RFLAGS - pushq $__HYPERVISOR_CS # CS -- leaq DBLFLT1(%rip),%rax -+ leaq .LDF1(%rip),%rax - pushq %rax # RIP - pushq %rsi # error_code/entry_vector - jmp handle_exception --DBLFLT1:GET_CURRENT(%rbx) -+.LDF1: GET_CURRENT(%rbx) - jmp test_all_events - failsafe_callback: - GET_CURRENT(%rbx) -@@ -87,10 +87,10 @@ failsafe_callback: - jmp test_all_events - .previous - .section __pre_ex_table,"a" -- .quad FLT1,FIX1 -+ .quad .LFT1,.LFX1 - .previous - .section __ex_table,"a" -- .quad DBLFLT1,failsafe_callback -+ .quad .LDF1,failsafe_callback - .previous - - ALIGN -@@ -249,9 +249,9 @@ create_bounce_frame: - 1: movb TRAPBOUNCE_flags(%rdx),%cl - subq $40,%rsi - movq UREGS_ss+8(%rsp),%rax --FLT2: movq %rax,32(%rsi) # SS -+.LFT2: movq %rax,32(%rsi) # SS - movq UREGS_rsp+8(%rsp),%rax --FLT3: movq %rax,24(%rsi) # RSP -+.LFT3: movq %rax,24(%rsi) # RSP - movq VCPU_vcpu_info(%rbx),%rax - pushq VCPUINFO_upcall_mask(%rax) - testb $TBF_INTERRUPT,%cl -@@ -260,7 +260,7 @@ FLT3: movq %rax,24(%rsi) - popq %rax - shlq $32,%rax # Bits 32-39: saved_upcall_mask - movw UREGS_cs+8(%rsp),%ax # Bits 0-15: CS --FLT4: movq %rax,8(%rsi) # CS / saved_upcall_mask -+.LFT4: movq %rax,8(%rsi) # CS / saved_upcall_mask - shrq $32,%rax - testb $0xFF,%al # Bits 0-7: saved_upcall_mask - setz %ch # %ch == !saved_upcall_mask -@@ -268,30 +268,30 @@ FLT4: movq %rax,8(%rsi) - andq $~X86_EFLAGS_IF,%rax - shlb $1,%ch # Bit 9 (EFLAGS.IF) - orb %ch,%ah # Fold EFLAGS.IF into %eax --FLT5: movq %rax,16(%rsi) # RFLAGS -+.LFT5: movq %rax,16(%rsi) # RFLAGS - movq UREGS_rip+8(%rsp),%rax --FLT6: movq %rax,(%rsi) # RIP -+.LFT6: movq %rax,(%rsi) # RIP - testb $TBF_EXCEPTION_ERRCODE,%cl - jz 1f - subq $8,%rsi - movl TRAPBOUNCE_error_code(%rdx),%eax --FLT7: movq %rax,(%rsi) # ERROR CODE -+.LFT7: movq %rax,(%rsi) # ERROR CODE - 1: testb $TBF_FAILSAFE,%cl - jz 2f - subq $32,%rsi - movl %gs,%eax --FLT8: movq %rax,24(%rsi) # GS -+.LFT8: movq %rax,24(%rsi) # GS - movl %fs,%eax --FLT9: movq %rax,16(%rsi) # FS -+.LFT9: movq %rax,16(%rsi) # FS - movl %es,%eax --FLT10: movq %rax,8(%rsi) # ES -+.LFT10: movq %rax,8(%rsi) # ES - movl %ds,%eax --FLT11: movq %rax,(%rsi) # DS -+.LFT11: movq %rax,(%rsi) # DS - 2: subq $16,%rsi - movq UREGS_r11+8(%rsp),%rax --FLT12: movq %rax,8(%rsi) # R11 -+.LFT12: movq %rax,8(%rsi) # R11 - movq UREGS_rcx+8(%rsp),%rax --FLT13: movq %rax,(%rsi) # RCX -+.LFT13: movq %rax,(%rsi) # RCX - /* Rewrite our stack frame and return to guest-OS mode. */ - /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */ - /* Also clear AC: alignment checks shouldn't trigger in kernel mode. */ -@@ -308,12 +308,12 @@ FLT13: movq %rax,(%rsi) - movb $0,TRAPBOUNCE_flags(%rdx) - ret - .section __ex_table,"a" -- .quad FLT2,domain_crash_page_fault_32, FLT3,domain_crash_page_fault_24 -- .quad FLT4,domain_crash_page_fault_8 , FLT5,domain_crash_page_fault_16 -- .quad FLT6,domain_crash_page_fault , FLT7,domain_crash_page_fault -- .quad FLT8,domain_crash_page_fault_24, FLT9,domain_crash_page_fault_16 -- .quad FLT10,domain_crash_page_fault_8 , FLT11,domain_crash_page_fault -- .quad FLT12,domain_crash_page_fault_8 , FLT13,domain_crash_page_fault -+ .quad .LFT2,domain_crash_page_fault_32, .LFT3,domain_crash_page_fault_24 -+ .quad .LFT4,domain_crash_page_fault_8 , .LFT5,domain_crash_page_fault_16 -+ .quad .LFT6,domain_crash_page_fault , .LFT7,domain_crash_page_fault -+ .quad .LFT8,domain_crash_page_fault_24, .LFT9,domain_crash_page_fault_16 -+ .quad .LFT10,domain_crash_page_fault_8 , .LFT11,domain_crash_page_fault -+ .quad .LFT12,domain_crash_page_fault_8 , .LFT13,domain_crash_page_fault - .previous - - .section .rodata,"a" diff --git a/libelf-add-to-xenkernel.diff b/libelf-add-to-xenkernel.diff deleted file mode 100644 index 5de12b1..0000000 --- a/libelf-add-to-xenkernel.diff +++ /dev/null @@ -1,3100 +0,0 @@ -add libelf: an ELF binary parser library. - -This patch adds a library with a small collection of helper functions -to parse and load elf binaries. The library handles endianess and -elfsize at runtime. - -The patch also shuffles around the include files a bit. Now there is -*one* include file holding all the elf structures -(xen/include/public/elfstructs.h) which is included by everyone who -needs them. - -It's dead code with this patch only, putting the code into use happens -in followup patches. - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/xc_elf.h | 525 ----------------------------------- - xen/arch/x86/boot/mkelf32.c | 2 - xen/common/Makefile | 2 - xen/common/libelf/Makefile | 4 - xen/common/libelf/README | 1 - xen/common/libelf/libelf-dominfo.c | 420 ++++++++++++++++++++++++++++ - xen/common/libelf/libelf-loader.c | 156 ++++++++++ - xen/common/libelf/libelf-private.h | 51 +++ - xen/common/libelf/libelf-relocate.c | 345 +++++++++++++++++++++++ - xen/common/libelf/libelf-tools.c | 225 +++++++++++++++ - xen/include/public/elfstructs.h | 527 ++++++++++++++++++++++++++++++++++++ - xen/include/public/libelf.h | 238 ++++++++++++++++ - xen/include/xen/elf.h | 490 --------------------------------- - 13 files changed, 1972 insertions(+), 1014 deletions(-) - -Index: build-32-release304-13132/xen/common/Makefile -=================================================================== ---- build-32-release304-13132.orig/xen/common/Makefile -+++ build-32-release304-13132/xen/common/Makefile -@@ -37,6 +37,8 @@ obj-$(CONFIG_XENCOMM) += xencomm.o - - subdir-$(CONFIG_COMPAT) += compat - -+subdir-y += libelf -+ - # Object file contains changeset and compiler information. - version.o: $(BASEDIR)/include/xen/compile.h - -Index: build-32-release304-13132/xen/common/libelf/Makefile -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/Makefile -@@ -0,0 +1,4 @@ -+obj-y += libelf-tools.o -+obj-y += libelf-loader.o -+obj-y += libelf-dominfo.o -+#obj-y += libelf-relocate.o -Index: build-32-release304-13132/xen/common/libelf/README -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/README -@@ -0,0 +1 @@ -+Take care, this code is used by both xen and tools ... -Index: build-32-release304-13132/xen/common/libelf/libelf-dominfo.c -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/libelf-dominfo.c -@@ -0,0 +1,420 @@ -+/* -+ * parse xen-specific informations out of elf kernel binaries. -+ */ -+ -+#include "libelf-private.h" -+ -+/* ------------------------------------------------------------------------ */ -+/* xen features */ -+ -+const char *elf_xen_feature_names[] = { -+ [XENFEAT_writable_page_tables] = "writable_page_tables", -+ [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables", -+ [XENFEAT_auto_translated_physmap] = "auto_translated_physmap", -+ [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel", -+ [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb" -+}; -+const int elf_xen_features = -+ sizeof(elf_xen_feature_names) / sizeof(elf_xen_feature_names[0]); -+ -+int elf_xen_parse_features(const char *features, -+ uint32_t *supported, -+ uint32_t *required) -+{ -+ char feature[64]; -+ int pos, len, i; -+ -+ if (NULL == features) -+ return 0; -+ for (pos = 0; features[pos] != '\0'; pos += len) -+ { -+ memset(feature, 0, sizeof(feature)); -+ for (len = 0;; len++) -+ { -+ if (len >= sizeof(feature)-1) -+ break; -+ if (features[pos + len] == '\0') -+ break; -+ if (features[pos + len] == '|') -+ { -+ len++; -+ break; -+ } -+ feature[len] = features[pos + len]; -+ } -+ -+ for (i = 0; i < elf_xen_features; i++) -+ { -+ if (!elf_xen_feature_names[i]) -+ continue; -+ if (NULL != required && feature[0] == '!') -+ { -+ /* required */ -+ if (0 == strcmp(feature + 1, elf_xen_feature_names[i])) -+ { -+ elf_xen_feature_set(i, supported); -+ elf_xen_feature_set(i, required); -+ break; -+ } -+ } -+ else -+ { -+ /* supported */ -+ if (0 == strcmp(feature, elf_xen_feature_names[i])) -+ { -+ elf_xen_feature_set(i, supported); -+ break; -+ } -+ } -+ } -+ if (i == elf_xen_features) -+ return -1; -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* xen elf notes */ -+ -+int elf_xen_parse_note(struct elf_binary *elf, -+ struct elf_dom_parms *parms, -+ const elf_note *note) -+{ -+/* *INDENT-OFF* */ -+ static const struct { -+ char *name; -+ int str; -+ } note_desc[] = { -+ [XEN_ELFNOTE_ENTRY] = { "ENTRY", 0}, -+ [XEN_ELFNOTE_HYPERCALL_PAGE] = { "HYPERCALL_PAGE", 0}, -+ [XEN_ELFNOTE_VIRT_BASE] = { "VIRT_BASE", 0}, -+ [XEN_ELFNOTE_PADDR_OFFSET] = { "PADDR_OFFSET", 0}, -+ [XEN_ELFNOTE_HV_START_LOW] = { "HV_START_LOW", 0}, -+ [XEN_ELFNOTE_XEN_VERSION] = { "XEN_VERSION", 1}, -+ [XEN_ELFNOTE_GUEST_OS] = { "GUEST_OS", 1}, -+ [XEN_ELFNOTE_GUEST_VERSION] = { "GUEST_VERSION", 1}, -+ [XEN_ELFNOTE_LOADER] = { "LOADER", 1}, -+ [XEN_ELFNOTE_PAE_MODE] = { "PAE_MODE", 1}, -+ [XEN_ELFNOTE_FEATURES] = { "FEATURES", 1}, -+ [XEN_ELFNOTE_BSD_SYMTAB] = { "BSD_SYMTAB", 1}, -+ }; -+/* *INDENT-ON* */ -+ -+ const char *str = NULL; -+ uint64_t val = 0; -+ int type = elf_uval(elf, note, type); -+ -+ if ((type >= sizeof(note_desc) / sizeof(note_desc[0])) || -+ (NULL == note_desc[type].name)) -+ { -+ elf_err(elf, "%s: unknown xen elf note (0x%x)\n", -+ __FUNCTION__, type); -+ return -1; -+ } -+ -+ if (note_desc[type].str) -+ { -+ str = elf_note_desc(elf, note); -+ elf_msg(elf, "%s: %s = \"%s\"\n", __FUNCTION__, -+ note_desc[type].name, str); -+ } -+ else -+ { -+ val = elf_note_numeric(elf, note); -+ elf_msg(elf, "%s: %s = 0x%" PRIx64 "\n", __FUNCTION__, -+ note_desc[type].name, val); -+ } -+ -+ switch (type) -+ { -+ case XEN_ELFNOTE_LOADER: -+ strncpy(parms->loader, str, sizeof(parms->loader)); -+ break; -+ case XEN_ELFNOTE_GUEST_OS: -+ strncpy(parms->guest_os, str, sizeof(parms->guest_os)); -+ break; -+ case XEN_ELFNOTE_GUEST_VERSION: -+ strncpy(parms->guest_ver, str, sizeof(parms->guest_ver)); -+ break; -+ case XEN_ELFNOTE_XEN_VERSION: -+ strncpy(parms->xen_ver, str, sizeof(parms->xen_ver)); -+ break; -+ case XEN_ELFNOTE_PAE_MODE: -+ if (0 == strcmp(str, "yes")) -+ parms->pae = 2 /* extended_cr3 */; -+ if (strstr(str, "bimodal")) -+ parms->pae = 3 /* bimodal */; -+ break; -+ case XEN_ELFNOTE_BSD_SYMTAB: -+ if (0 == strcmp(str, "yes")) -+ parms->bsd_symtab = 1; -+ break; -+ -+ case XEN_ELFNOTE_VIRT_BASE: -+ parms->virt_base = val; -+ break; -+ case XEN_ELFNOTE_ENTRY: -+ parms->virt_entry = val; -+ break; -+ case XEN_ELFNOTE_PADDR_OFFSET: -+ parms->elf_paddr_offset = val; -+ break; -+ case XEN_ELFNOTE_HYPERCALL_PAGE: -+ parms->virt_hypercall = val; -+ break; -+ case XEN_ELFNOTE_HV_START_LOW: -+ parms->virt_hv_start_low = val; -+ break; -+ -+ case XEN_ELFNOTE_FEATURES: -+ if (0 != elf_xen_parse_features(str, parms->f_supported, -+ parms->f_required)) -+ return -1; -+ break; -+ -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* __xen_guest section */ -+ -+int elf_xen_parse_guest_info(struct elf_binary *elf, -+ struct elf_dom_parms *parms) -+{ -+ const char *h; -+ char name[32], value[128]; -+ int len; -+ -+ h = parms->guest_info; -+ while (*h) -+ { -+ memset(name, 0, sizeof(name)); -+ memset(value, 0, sizeof(value)); -+ for (len = 0;; len++, h++) { -+ if (len >= sizeof(name)-1) -+ break; -+ if (*h == '\0') -+ break; -+ if (*h == ',') -+ { -+ h++; -+ break; -+ } -+ if (*h == '=') -+ { -+ h++; -+ for (len = 0;; len++, h++) { -+ if (len >= sizeof(value)-1) -+ break; -+ if (*h == '\0') -+ break; -+ if (*h == ',') -+ { -+ h++; -+ break; -+ } -+ value[len] = *h; -+ } -+ break; -+ } -+ name[len] = *h; -+ } -+ elf_msg(elf, "%s: %s=\"%s\"\n", __FUNCTION__, name, value); -+ -+ /* strings */ -+ if (0 == strcmp(name, "LOADER")) -+ strncpy(parms->loader, value, sizeof(parms->loader)); -+ if (0 == strcmp(name, "GUEST_OS")) -+ strncpy(parms->guest_os, value, sizeof(parms->guest_os)); -+ if (0 == strcmp(name, "GUEST_VER")) -+ strncpy(parms->guest_ver, value, sizeof(parms->guest_ver)); -+ if (0 == strcmp(name, "XEN_VER")) -+ strncpy(parms->xen_ver, value, sizeof(parms->xen_ver)); -+ if (0 == strcmp(name, "PAE")) -+ { -+ if (0 == strcmp(value, "yes[extended-cr3]")) -+ parms->pae = 2 /* extended_cr3 */; -+ else if (0 == strncmp(value, "yes", 3)) -+ parms->pae = 1 /* yes */; -+ } -+ if (0 == strcmp(name, "BSD_SYMTAB")) -+ parms->bsd_symtab = 1; -+ -+ /* longs */ -+ if (0 == strcmp(name, "VIRT_BASE")) -+ parms->virt_base = strtoull(value, NULL, 0); -+ if (0 == strcmp(name, "VIRT_ENTRY")) -+ parms->virt_entry = strtoull(value, NULL, 0); -+ if (0 == strcmp(name, "ELF_PADDR_OFFSET")) -+ parms->elf_paddr_offset = strtoull(value, NULL, 0); -+ if (0 == strcmp(name, "HYPERCALL_PAGE")) -+ parms->virt_hypercall = (strtoull(value, NULL, 0) << 12) + -+ parms->virt_base; -+ -+ /* other */ -+ if (0 == strcmp(name, "FEATURES")) -+ if (0 != elf_xen_parse_features(value, parms->f_supported, -+ parms->f_required)) -+ return -1; -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* sanity checks */ -+ -+static int elf_xen_note_check(struct elf_binary *elf, -+ struct elf_dom_parms *parms) -+{ -+ if (NULL == parms->elf_note_start && NULL == parms->guest_info) { -+ int machine = elf_uval(elf, elf->ehdr, e_machine); -+ if (EM_386 == machine || EM_X86_64 == machine) { -+ elf_err(elf, "%s: ERROR: Not a Xen-ELF image: " -+ "No ELF notes or '__xen_guest' section found.\n", -+ __FUNCTION__); -+ return -1; -+ } -+ return 0; -+ } -+ -+ /* Check the contents of the Xen notes or guest string. */ -+ if ( ( 0 == strlen(parms->loader) || strncmp(parms->loader, "generic", 7) ) && -+ ( 0 == strlen(parms->guest_os) || strncmp(parms->guest_os, "linux", 5) ) ) -+ { -+ elf_err(elf, "%s: ERROR: Will only load images built for the generic " -+ "loader or Linux images", __FUNCTION__); -+ return -1; -+ } -+ -+ if ( 0 == strlen(parms->xen_ver) || strncmp(parms->xen_ver, "xen-3.0", 7) ) -+ { -+ elf_err(elf, "%s: ERROR: Xen will only load images built for Xen v3.0\n", -+ __FUNCTION__); -+ return -1; -+ } -+ return 0; -+} -+ -+static int elf_xen_addr_calc_check(struct elf_binary *elf, -+ struct elf_dom_parms *parms) -+{ -+ if (UNSET_ADDR != parms->elf_paddr_offset && -+ UNSET_ADDR == parms->virt_base ) -+ { -+ elf_err(elf, "%s: ERROR: ELF_PADDR_OFFSET set, VIRT_BASE unset\n", -+ __FUNCTION__); -+ return -1; -+ } -+ -+ /* Initial guess for virt_base is 0 if it is not explicitly defined. */ -+ if (UNSET_ADDR == parms->virt_base) -+ { -+ parms->virt_base = 0; -+ elf_msg(elf, "%s: VIRT_BASE unset, using 0x%" PRIx64 "\n", -+ __FUNCTION__, parms->virt_base); -+ } -+ -+ /* -+ * If we are using the legacy __xen_guest section then elf_pa_off -+ * defaults to v_start in order to maintain compatibility with -+ * older hypervisors which set padd in the ELF header to -+ * virt_base. -+ * -+ * If we are using the modern ELF notes interface then the default -+ * is 0. -+ */ -+ if (UNSET_ADDR == parms->elf_paddr_offset) -+ { -+ if (parms->elf_note_start) -+ parms->elf_paddr_offset = 0; -+ else -+ parms->elf_paddr_offset = parms->virt_base; -+ elf_msg(elf, "%s: ELF_PADDR_OFFSET unset, using 0x%" PRIx64 "\n", -+ __FUNCTION__, parms->elf_paddr_offset); -+ } -+ -+ parms->virt_offset = parms->virt_base - parms->elf_paddr_offset; -+ parms->virt_kstart = elf->pstart + parms->virt_offset; -+ parms->virt_kend = elf->pend + parms->virt_offset; -+ -+ if (UNSET_ADDR == parms->virt_entry) -+ parms->virt_entry = elf_uval(elf, elf->ehdr, e_entry); -+ -+ elf_msg(elf, "%s: addresses:\n", __FUNCTION__); -+ elf_msg(elf, " virt_base = 0x%" PRIx64 "\n", parms->virt_base); -+ elf_msg(elf, " elf_paddr_offset = 0x%" PRIx64 "\n", parms->elf_paddr_offset); -+ elf_msg(elf, " virt_offset = 0x%" PRIx64 "\n", parms->virt_offset); -+ elf_msg(elf, " virt_kstart = 0x%" PRIx64 "\n", parms->virt_kstart); -+ elf_msg(elf, " virt_kend = 0x%" PRIx64 "\n", parms->virt_kend); -+ elf_msg(elf, " virt_entry = 0x%" PRIx64 "\n", parms->virt_entry); -+ -+ if ( (parms->virt_kstart > parms->virt_kend) || -+ (parms->virt_entry < parms->virt_kstart) || -+ (parms->virt_entry > parms->virt_kend) || -+ (parms->virt_base > parms->virt_kstart) ) -+ { -+ elf_err(elf, "%s: ERROR: ELF start or entries are out of bounds.\n", -+ __FUNCTION__); -+ return -1; -+ } -+ -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* glue it all together ... */ -+ -+int elf_xen_parse(struct elf_binary *elf, -+ struct elf_dom_parms *parms) -+{ -+ const elf_note *note; -+ const elf_shdr *shdr; -+ int xen_elfnotes = 0; -+ int i, count; -+ -+ memset(parms, 0, sizeof(*parms)); -+ parms->virt_base = UNSET_ADDR; -+ parms->virt_entry = UNSET_ADDR; -+ parms->virt_hypercall = UNSET_ADDR; -+ parms->virt_hv_start_low = UNSET_ADDR; -+ parms->elf_paddr_offset = UNSET_ADDR; -+ -+ /* find and parse elf notes */ -+ count = elf_shdr_count(elf); -+ for (i = 0; i < count; i++) -+ { -+ shdr = elf_shdr_by_index(elf, i); -+ if (0 == strcmp(elf_section_name(elf, shdr), "__xen_guest")) -+ parms->guest_info = elf_section_start(elf, shdr); -+ if (elf_uval(elf, shdr, sh_type) != SHT_NOTE) -+ continue; -+ parms->elf_note_start = elf_section_start(elf, shdr); -+ parms->elf_note_end = elf_section_end(elf, shdr); -+ for (note = parms->elf_note_start; -+ (void *)note < parms->elf_note_end; -+ note = elf_note_next(elf, note)) -+ { -+ if (0 != strcmp(elf_note_name(elf, note), "Xen")) -+ continue; -+ if (0 != elf_xen_parse_note(elf, parms, note)) -+ return -1; -+ xen_elfnotes++; -+ } -+ } -+ -+ if (!xen_elfnotes && parms->guest_info) -+ { -+ parms->elf_note_start = NULL; -+ parms->elf_note_end = NULL; -+ elf_msg(elf, "%s: __xen_guest: \"%s\"\n", __FUNCTION__, -+ parms->guest_info); -+ elf_xen_parse_guest_info(elf, parms); -+ } -+ -+ if (0 != elf_xen_note_check(elf, parms)) -+ return -1; -+ if (0 != elf_xen_addr_calc_check(elf, parms)) -+ return -1; -+ return 0; -+} -Index: build-32-release304-13132/xen/common/libelf/libelf-loader.c -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/libelf-loader.c -@@ -0,0 +1,156 @@ -+/* -+ * parse and load elf binaries -+ */ -+ -+#include "libelf-private.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+int elf_init(struct elf_binary *elf, const char *image, size_t size) -+{ -+ const elf_shdr *shdr; -+ uint64_t i, count, section, offset; -+ -+ if (!elf_is_elfbinary(image)) -+ { -+ elf_err(elf, "%s: not an ELF binary\n", __FUNCTION__); -+ return -1; -+ } -+ -+ memset(elf, 0, sizeof(*elf)); -+ elf->image = image; -+ elf->size = size; -+ elf->ehdr = (elf_ehdr *) image; -+ elf->class = elf->ehdr->e32.e_ident[EI_CLASS]; -+ elf->data = elf->ehdr->e32.e_ident[EI_DATA]; -+ -+ /* sanity check phdr */ -+ offset = elf_uval(elf, elf->ehdr, e_phoff) + -+ elf_uval(elf, elf->ehdr, e_phentsize) * elf_phdr_count(elf); -+ if (offset > elf->size) -+ { -+ elf_err(elf, "%s: phdr overflow (off %" PRIx64 " > size %lx)\n", -+ __FUNCTION__, offset, (unsigned long)elf->size); -+ return -1; -+ } -+ -+ /* sanity check shdr */ -+ offset = elf_uval(elf, elf->ehdr, e_shoff) + -+ elf_uval(elf, elf->ehdr, e_shentsize) * elf_shdr_count(elf); -+ if (offset > elf->size) -+ { -+ elf_err(elf, "%s: shdr overflow (off %" PRIx64 " > size %lx)\n", -+ __FUNCTION__, offset, (unsigned long)elf->size); -+ return -1; -+ } -+ -+ /* find section string table */ -+ section = elf_uval(elf, elf->ehdr, e_shstrndx); -+ shdr = elf_shdr_by_index(elf, section); -+ if (NULL != shdr) -+ elf->sec_strtab = elf_section_start(elf, shdr); -+ -+ /* find symbol table, symbol string table */ -+ count = elf_shdr_count(elf); -+ for (i = 0; i < count; i++) -+ { -+ shdr = elf_shdr_by_index(elf, i); -+ if (elf_uval(elf, shdr, sh_type) != SHT_SYMTAB) -+ continue; -+ elf->sym_tab = shdr; -+ shdr = elf_shdr_by_index(elf, elf_uval(elf, shdr, sh_link)); -+ if (NULL == shdr) -+ { -+ elf->sym_tab = NULL; -+ continue; -+ } -+ elf->sym_strtab = elf_section_start(elf, shdr); -+ break; -+ } -+ return 0; -+} -+ -+#ifndef __XEN__ -+void elf_set_logfile(struct elf_binary *elf, FILE * log, int verbose) -+{ -+ elf->log = log; -+ elf->verbose = verbose; -+} -+#else -+void elf_set_verbose(struct elf_binary *elf) -+{ -+ elf->verbose = 1; -+} -+#endif -+ -+void elf_parse_binary(struct elf_binary *elf) -+{ -+ const elf_phdr *phdr; -+ uint64_t low = -1; -+ uint64_t high = 0; -+ uint64_t i, count, paddr, memsz; -+ -+ count = elf_uval(elf, elf->ehdr, e_phnum); -+ for (i = 0; i < count; i++) -+ { -+ phdr = elf_phdr_by_index(elf, i); -+ if (!elf_phdr_is_loadable(elf, phdr)) -+ continue; -+ paddr = elf_uval(elf, phdr, p_paddr); -+ memsz = elf_uval(elf, phdr, p_memsz); -+ elf_msg(elf, "%s: phdr: paddr=0x%" PRIx64 -+ " memsz=0x%" PRIx64 "\n", __FUNCTION__, paddr, memsz); -+ if (low > paddr) -+ low = paddr; -+ if (high < paddr + memsz) -+ high = paddr + memsz; -+ } -+ elf->pstart = low; -+ elf->pend = high; -+ elf_msg(elf, "%s: memory: 0x%" PRIx64 " -> 0x%" PRIx64 "\n", -+ __FUNCTION__, elf->pstart, elf->pend); -+} -+ -+void elf_load_binary(struct elf_binary *elf) -+{ -+ const elf_phdr *phdr; -+ uint64_t i, count, paddr, offset, filesz, memsz; -+ char *dest; -+ -+ count = elf_uval(elf, elf->ehdr, e_phnum); -+ for (i = 0; i < count; i++) -+ { -+ phdr = elf_phdr_by_index(elf, i); -+ if (!elf_phdr_is_loadable(elf, phdr)) -+ continue; -+ paddr = elf_uval(elf, phdr, p_paddr); -+ offset = elf_uval(elf, phdr, p_offset); -+ filesz = elf_uval(elf, phdr, p_filesz); -+ memsz = elf_uval(elf, phdr, p_memsz); -+ dest = elf_get_ptr(elf, paddr); -+ memcpy(dest, elf->image + offset, filesz); -+ memset(dest + filesz, 0, memsz - filesz); -+ } -+} -+ -+void *elf_get_ptr(struct elf_binary *elf, unsigned long addr) -+{ -+ return elf->dest + addr - elf->pstart; -+} -+ -+uint64_t elf_lookup_addr(struct elf_binary * elf, const char *symbol) -+{ -+ const elf_sym *sym; -+ uint64_t value; -+ -+ sym = elf_sym_by_name(elf, symbol); -+ if (NULL == sym) -+ { -+ elf_err(elf, "%s: not found: %s\n", __FUNCTION__, symbol); -+ return -1; -+ } -+ value = elf_uval(elf, sym, st_value); -+ elf_msg(elf, "%s: symbol \"%s\" at 0x%" PRIx64 "\n", __FUNCTION__, -+ symbol, value); -+ return value; -+} -Index: build-32-release304-13132/xen/common/libelf/libelf-private.h -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/libelf-private.h -@@ -0,0 +1,51 @@ -+#ifdef __XEN__ -+ -+#include -+#include -+#include -+#include -+ -+#define elf_msg(elf, fmt, args ... ) \ -+ if (elf->verbose) printk(fmt, ## args ) -+#define elf_err(elf, fmt, args ... ) \ -+ printk(fmt, ## args ) -+ -+#define strtoull(str, end, base) simple_strtoull(str, end, base) -+#define bswap_16(x) \ -+ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) -+#define bswap_32(x) \ -+ ( (((x) & 0xff000000) >> 24) \ -+ | (((x) & 0x00ff0000) >> 8) \ -+ | (((x) & 0x0000ff00) << 8) \ -+ | (((x) & 0x000000ff) << 24)) -+#define bswap_64(x) \ -+ ( (((x) & 0xff00000000000000ull) >> 56) \ -+ | (((x) & 0x00ff000000000000ull) >> 40) \ -+ | (((x) & 0x0000ff0000000000ull) >> 24) \ -+ | (((x) & 0x000000ff00000000ull) >> 8) \ -+ | (((x) & 0x00000000ff000000ull) << 8) \ -+ | (((x) & 0x0000000000ff0000ull) << 24) \ -+ | (((x) & 0x000000000000ff00ull) << 40) \ -+ | (((x) & 0x00000000000000ffull) << 56)) -+ -+#else /* !__XEN__ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "xenctrl.h" -+#include "xc_private.h" -+ -+#define elf_msg(elf, fmt, args ... ) \ -+ if (elf->log && elf->verbose) fprintf(elf->log, fmt , ## args ) -+#define elf_err(elf, fmt, args ... ) do { \ -+ if (elf->log) \ -+ fprintf(elf->log, fmt , ## args ); \ -+ xc_set_error(XC_INVALID_KERNEL, fmt , ## args ); \ -+ } while (0) -+ -+#endif -Index: build-32-release304-13132/xen/common/libelf/libelf-relocate.c -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/libelf-relocate.c -@@ -0,0 +1,345 @@ -+/* -+ * ELF relocation code (not used by xen kernel right now). -+ */ -+ -+#include "libelf-private.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+static const char *rel_names_i386[] = { -+ "R_386_NONE", -+ "R_386_32", -+ "R_386_PC32", -+ "R_386_GOT32", -+ "R_386_PLT32", -+ "R_386_COPY", -+ "R_386_GLOB_DAT", -+ "R_386_JMP_SLOT", -+ "R_386_RELATIVE", -+ "R_386_GOTOFF", -+ "R_386_GOTPC", -+ "R_386_32PLT", -+ "R_386_TLS_TPOFF", -+ "R_386_TLS_IE", -+ "R_386_TLS_GOTIE", -+ "R_386_TLS_LE", -+ "R_386_TLS_GD", -+ "R_386_TLS_LDM", -+ "R_386_16", -+ "R_386_PC16", -+ "R_386_8", -+ "R_386_PC8", -+ "R_386_TLS_GD_32", -+ "R_386_TLS_GD_PUSH", -+ "R_386_TLS_GD_CALL", -+ "R_386_TLS_GD_POP", -+ "R_386_TLS_LDM_32", -+ "R_386_TLS_LDM_PUSH", -+ "R_386_TLS_LDM_CALL", -+ "R_386_TLS_LDM_POP", -+ "R_386_TLS_LDO_32", -+ "R_386_TLS_IE_32", -+ "R_386_TLS_LE_32", -+ "R_386_TLS_DTPMOD32", -+ "R_386_TLS_DTPOFF32", -+ "R_386_TLS_TPOFF32", -+}; -+ -+static int elf_reloc_i386(struct elf_binary *elf, int type, -+ uint64_t addr, uint64_t value) -+{ -+ void *ptr = elf_get_ptr(elf, addr); -+ uint32_t *u32; -+ -+ switch (type) -+ { -+ case 1 /* R_386_32 */ : -+ u32 = ptr; -+ *u32 += elf->reloc_offset; -+ break; -+ case 2 /* R_386_PC32 */ : -+ /* nothing */ -+ break; -+ default: -+ return -1; -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static const char *rel_names_x86_64[] = { -+ "R_X86_64_NONE", -+ "R_X86_64_64", -+ "R_X86_64_PC32", -+ "R_X86_64_GOT32", -+ "R_X86_64_PLT32", -+ "R_X86_64_COPY", -+ "R_X86_64_GLOB_DAT", -+ "R_X86_64_JUMP_SLOT", -+ "R_X86_64_RELATIVE", -+ "R_X86_64_GOTPCREL", -+ "R_X86_64_32", -+ "R_X86_64_32S", -+ "R_X86_64_16", -+ "R_X86_64_PC16", -+ "R_X86_64_8", -+ "R_X86_64_PC8", -+ "R_X86_64_DTPMOD64", -+ "R_X86_64_DTPOFF64", -+ "R_X86_64_TPOFF64", -+ "R_X86_64_TLSGD", -+ "R_X86_64_TLSLD", -+ "R_X86_64_DTPOFF32", -+ "R_X86_64_GOTTPOFF", -+ "R_X86_64_TPOFF32", -+}; -+ -+static int elf_reloc_x86_64(struct elf_binary *elf, int type, -+ uint64_t addr, uint64_t value) -+{ -+ void *ptr = elf_get_ptr(elf, addr); -+ uint64_t *u64; -+ uint32_t *u32; -+ int32_t *s32; -+ -+ switch (type) -+ { -+ case 1 /* R_X86_64_64 */ : -+ u64 = ptr; -+ value += elf->reloc_offset; -+ *u64 = value; -+ break; -+ case 2 /* R_X86_64_PC32 */ : -+ u32 = ptr; -+ *u32 = value - addr; -+ if (*u32 != (uint32_t) (value - addr)) -+ { -+ elf_err(elf, "R_X86_64_PC32 overflow: 0x%" PRIx32 " != 0x%" PRIx32 "\n", -+ *u32, (uint32_t) (value - addr)); -+ return -1; -+ } -+ break; -+ case 10 /* R_X86_64_32 */ : -+ u32 = ptr; -+ value += elf->reloc_offset; -+ *u32 = value; -+ if (*u32 != value) -+ { -+ elf_err(elf, "R_X86_64_32 overflow: 0x%" PRIx32 " != 0x%" PRIx64 "\n", -+ *u32, value); -+ return -1; -+ } -+ break; -+ case 11 /* R_X86_64_32S */ : -+ s32 = ptr; -+ value += elf->reloc_offset; -+ *s32 = value; -+ if (*s32 != (int64_t) value) -+ { -+ elf_err(elf, "R_X86_64_32S overflow: 0x%" PRIx32 " != 0x%" PRIx64 "\n", -+ *s32, (int64_t) value); -+ return -1; -+ } -+ break; -+ default: -+ return -1; -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct relocs { -+ const char **names; -+ int count; -+ int (*func) (struct elf_binary * elf, int type, uint64_t addr, -+ uint64_t value); -+} relocs[] = -+/* *INDENT-OFF* */ -+{ -+ [EM_386] = { -+ .names = rel_names_i386, -+ .count = sizeof(rel_names_i386) / sizeof(rel_names_i386[0]), -+ .func = elf_reloc_i386, -+ }, -+ [EM_X86_64] = { -+ .names = rel_names_x86_64, -+ .count = sizeof(rel_names_x86_64) / sizeof(rel_names_x86_64[0]), -+ .func = elf_reloc_x86_64, -+ } -+}; -+/* *INDENT-ON* */ -+ -+/* ------------------------------------------------------------------------ */ -+ -+static const char *rela_name(int machine, int type) -+{ -+ if (machine > sizeof(relocs) / sizeof(relocs[0])) -+ return "unknown mach"; -+ if (!relocs[machine].names) -+ return "unknown mach"; -+ if (type > relocs[machine].count) -+ return "unknown rela"; -+ return relocs[machine].names[type]; -+} -+ -+static int elf_reloc_section(struct elf_binary *elf, -+ const elf_shdr * rels, -+ const elf_shdr * sect, const elf_shdr * syms) -+{ -+ const void *ptr, *end; -+ const elf_shdr *shdr; -+ const elf_rela *rela; -+ const elf_rel *rel; -+ const elf_sym *sym; -+ uint64_t s_type; -+ uint64_t r_offset; -+ uint64_t r_info; -+ uint64_t r_addend; -+ int r_type, r_sym; -+ size_t rsize; -+ uint64_t shndx, sbase, addr, value; -+ const char *sname; -+ int machine; -+ -+ machine = elf_uval(elf, elf->ehdr, e_machine); -+ if (machine >= sizeof(relocs) / sizeof(relocs[0]) || -+ NULL == relocs[machine].func) -+ { -+ elf_err(elf, "%s: can't handle machine %d\n", -+ __FUNCTION__, machine); -+ return -1; -+ } -+ if (elf_swap(elf)) -+ { -+ elf_err(elf, "%s: non-native byte order, relocation not supported\n", -+ __FUNCTION__); -+ return -1; -+ } -+ -+ s_type = elf_uval(elf, rels, sh_type); -+ rsize = (SHT_REL == s_type) ? elf_size(elf, rel) : elf_size(elf, rela); -+ ptr = elf_section_start(elf, rels); -+ end = elf_section_end(elf, rels); -+ -+ for (; ptr < end; ptr += rsize) -+ { -+ switch (s_type) -+ { -+ case SHT_REL: -+ rel = ptr; -+ r_offset = elf_uval(elf, rel, r_offset); -+ r_info = elf_uval(elf, rel, r_info); -+ r_addend = 0; -+ break; -+ case SHT_RELA: -+ rela = ptr; -+ r_offset = elf_uval(elf, rela, r_offset); -+ r_info = elf_uval(elf, rela, r_info); -+ r_addend = elf_uval(elf, rela, r_addend); -+ break; -+ default: -+ /* can't happen */ -+ return -1; -+ } -+ if (elf_64bit(elf)) -+ { -+ r_type = ELF64_R_TYPE(r_info); -+ r_sym = ELF64_R_SYM(r_info); -+ } -+ else -+ { -+ r_type = ELF32_R_TYPE(r_info); -+ r_sym = ELF32_R_SYM(r_info); -+ } -+ -+ sym = elf_sym_by_index(elf, r_sym); -+ shndx = elf_uval(elf, sym, st_shndx); -+ switch (shndx) -+ { -+ case SHN_UNDEF: -+ sname = "*UNDEF*"; -+ sbase = 0; -+ break; -+ case SHN_COMMON: -+ elf_err(elf, "%s: invalid section: %" PRId64 "\n", -+ __FUNCTION__, shndx); -+ return -1; -+ case SHN_ABS: -+ sname = "*ABS*"; -+ sbase = 0; -+ break; -+ default: -+ shdr = elf_shdr_by_index(elf, shndx); -+ if (NULL == shdr) -+ { -+ elf_err(elf, "%s: invalid section: %" PRId64 "\n", -+ __FUNCTION__, shndx); -+ return -1; -+ } -+ sname = elf_section_name(elf, shdr); -+ sbase = elf_uval(elf, shdr, sh_addr); -+ } -+ -+ addr = r_offset; -+ value = elf_uval(elf, sym, st_value); -+ value += r_addend; -+ -+ if (elf->log && elf->verbose > 1) -+ { -+ uint64_t st_name = elf_uval(elf, sym, st_name); -+ const char *name = st_name ? elf->sym_strtab + st_name : "*NONE*"; -+ -+ elf_msg(elf, -+ "%s: type %s [%d], off 0x%" PRIx64 ", add 0x%" PRIx64 "," -+ " sym %s [0x%" PRIx64 "], sec %s [0x%" PRIx64 "]" -+ " -> addr 0x%" PRIx64 " value 0x%" PRIx64 "\n", -+ __FUNCTION__, rela_name(machine, r_type), r_type, r_offset, -+ r_addend, name, elf_uval(elf, sym, st_value), sname, sbase, -+ addr, value); -+ } -+ -+ if (-1 == relocs[machine].func(elf, r_type, addr, value)) -+ { -+ elf_err(elf, "%s: unknown/unsupported reloc type %s [%d]\n", -+ __FUNCTION__, rela_name(machine, r_type), r_type); -+ return -1; -+ } -+ } -+ return 0; -+} -+ -+int elf_reloc(struct elf_binary *elf) -+{ -+ const elf_shdr *rels, *sect, *syms; -+ uint64_t i, count, type; -+ -+ count = elf_shdr_count(elf); -+ for (i = 0; i < count; i++) -+ { -+ rels = elf_shdr_by_index(elf, i); -+ type = elf_uval(elf, rels, sh_type); -+ if (type != SHT_REL && type != SHT_RELA) -+ continue; -+ -+ sect = elf_shdr_by_index(elf, elf_uval(elf, rels, sh_info)); -+ syms = elf_shdr_by_index(elf, elf_uval(elf, rels, sh_link)); -+ if (NULL == sect || NULL == syms) -+ continue; -+ -+ if (!(elf_uval(elf, sect, sh_flags) & SHF_ALLOC)) -+ { -+ elf_msg(elf, "%s: relocations for %s, skipping\n", -+ __FUNCTION__, elf_section_name(elf, sect)); -+ continue; -+ } -+ -+ elf_msg(elf, "%s: relocations for %s @ 0x%" PRIx64 "\n", -+ __FUNCTION__, elf_section_name(elf, sect), -+ elf_uval(elf, sect, sh_addr)); -+ if (0 != elf_reloc_section(elf, rels, sect, syms)) -+ return -1; -+ } -+ return 0; -+} -Index: build-32-release304-13132/xen/common/libelf/libelf-tools.c -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/common/libelf/libelf-tools.c -@@ -0,0 +1,225 @@ -+/* -+ * various helper functions to access elf structures -+ */ -+ -+#include "libelf-private.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+uint64_t elf_access_unsigned(struct elf_binary * elf, const void *ptr, -+ off_t offset, size_t size) -+{ -+ int need_swap = elf_swap(elf); -+ const uint8_t *u8; -+ const uint16_t *u16; -+ const uint32_t *u32; -+ const uint64_t *u64; -+ -+ switch (size) -+ { -+ case 1: -+ u8 = ptr + offset; -+ return *u8; -+ case 2: -+ u16 = ptr + offset; -+ return need_swap ? bswap_16(*u16) : *u16; -+ case 4: -+ u32 = ptr + offset; -+ return need_swap ? bswap_32(*u32) : *u32; -+ case 8: -+ u64 = ptr + offset; -+ return need_swap ? bswap_64(*u64) : *u64; -+ default: -+ return 0; -+ } -+} -+ -+int64_t elf_access_signed(struct elf_binary *elf, const void *ptr, -+ off_t offset, size_t size) -+{ -+ int need_swap = elf_swap(elf); -+ const int8_t *s8; -+ const int16_t *s16; -+ const int32_t *s32; -+ const int64_t *s64; -+ -+ switch (size) -+ { -+ case 1: -+ s8 = ptr + offset; -+ return *s8; -+ case 2: -+ s16 = ptr + offset; -+ return need_swap ? bswap_16(*s16) : *s16; -+ case 4: -+ s32 = ptr + offset; -+ return need_swap ? bswap_32(*s32) : *s32; -+ case 8: -+ s64 = ptr + offset; -+ return need_swap ? bswap_64(*s64) : *s64; -+ default: -+ return 0; -+ } -+} -+ -+uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr) -+{ -+ int elf_round = (elf_64bit(elf) ? 8 : 4) - 1; -+ -+ return (addr + elf_round) & ~elf_round; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+int elf_shdr_count(struct elf_binary *elf) -+{ -+ return elf_uval(elf, elf->ehdr, e_shnum); -+} -+ -+int elf_phdr_count(struct elf_binary *elf) -+{ -+ return elf_uval(elf, elf->ehdr, e_phnum); -+} -+ -+const elf_shdr *elf_shdr_by_name(struct elf_binary *elf, const char *name) -+{ -+ uint64_t count = elf_shdr_count(elf); -+ const elf_shdr *shdr; -+ const char *sname; -+ int i; -+ -+ for (i = 0; i < count; i++) { -+ shdr = elf_shdr_by_index(elf, i); -+ sname = elf_section_name(elf, shdr); -+ if (sname && 0 == strcmp(sname, name)) -+ return shdr; -+ } -+ return NULL; -+} -+ -+const elf_shdr *elf_shdr_by_index(struct elf_binary *elf, int index) -+{ -+ uint64_t count = elf_shdr_count(elf); -+ const void *ptr = NULL; -+ -+ if (index < count) -+ ptr = elf->image -+ + elf_uval(elf, elf->ehdr, e_shoff) -+ + elf_uval(elf, elf->ehdr, e_shentsize) * index; -+ return ptr; -+} -+ -+const elf_phdr *elf_phdr_by_index(struct elf_binary *elf, int index) -+{ -+ uint64_t count = elf_uval(elf, elf->ehdr, e_phnum); -+ const void *ptr = NULL; -+ -+ if (index < count) -+ ptr = elf->image -+ + elf_uval(elf, elf->ehdr, e_phoff) -+ + elf_uval(elf, elf->ehdr, e_phentsize) * index; -+ return ptr; -+} -+ -+const char *elf_section_name(struct elf_binary *elf, const elf_shdr * shdr) -+{ -+ if (NULL == elf->sec_strtab) -+ return "unknown"; -+ return elf->sec_strtab + elf_uval(elf, shdr, sh_name); -+} -+ -+const void *elf_section_start(struct elf_binary *elf, const elf_shdr * shdr) -+{ -+ return elf->image + elf_uval(elf, shdr, sh_offset); -+} -+ -+const void *elf_section_end(struct elf_binary *elf, const elf_shdr * shdr) -+{ -+ return elf->image -+ + elf_uval(elf, shdr, sh_offset) + elf_uval(elf, shdr, sh_size); -+} -+ -+const elf_sym *elf_sym_by_name(struct elf_binary *elf, const char *symbol) -+{ -+ const void *ptr = elf_section_start(elf, elf->sym_tab); -+ const void *end = elf_section_end(elf, elf->sym_tab); -+ const elf_sym *sym; -+ uint64_t info, name; -+ -+ for (; ptr < end; ptr += elf_size(elf, sym)) -+ { -+ sym = ptr; -+ info = elf_uval(elf, sym, st_info); -+ name = elf_uval(elf, sym, st_name); -+ if (ELF32_ST_BIND(info) != STB_GLOBAL) -+ continue; -+ if (strcmp(elf->sym_strtab + name, symbol) != 0) -+ continue; -+ return sym; -+ } -+ return NULL; -+} -+ -+const elf_sym *elf_sym_by_index(struct elf_binary *elf, int index) -+{ -+ const void *ptr = elf_section_start(elf, elf->sym_tab); -+ const elf_sym *sym; -+ -+ sym = ptr + index * elf_size(elf, sym); -+ return sym; -+} -+ -+const char *elf_note_name(struct elf_binary *elf, const elf_note * note) -+{ -+ return (void *)note + elf_size(elf, note); -+} -+ -+const void *elf_note_desc(struct elf_binary *elf, const elf_note * note) -+{ -+ int namesz = (elf_uval(elf, note, namesz) + 3) & ~3; -+ -+ return (void *)note + elf_size(elf, note) + namesz; -+} -+ -+uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note) -+{ -+ const void *desc = elf_note_desc(elf, note); -+ int descsz = elf_uval(elf, note, descsz); -+ -+ switch (descsz) -+ { -+ case 1: -+ case 2: -+ case 4: -+ case 8: -+ return elf_access_unsigned(elf, desc, 0, descsz); -+ default: -+ return 0; -+ } -+} -+const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note) -+{ -+ int namesz = (elf_uval(elf, note, namesz) + 3) & ~3; -+ int descsz = (elf_uval(elf, note, descsz) + 3) & ~3; -+ -+ return (void *)note + elf_size(elf, note) + namesz + descsz; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+int elf_is_elfbinary(const void *image) -+{ -+ const Elf32_Ehdr *ehdr = image; -+ -+ if (IS_ELF(*ehdr)) -+ return 1; -+ return 0; -+} -+ -+int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr) -+{ -+ uint64_t p_type = elf_uval(elf, phdr, p_type); -+ uint64_t p_flags = elf_uval(elf, phdr, p_flags); -+ -+ return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0); -+} -Index: build-32-release304-13132/xen/include/public/elfstructs.h -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/include/public/elfstructs.h -@@ -0,0 +1,527 @@ -+#ifndef __XEN_PUBLIC_ELFSTRUCTS_H__ -+#define __XEN_PUBLIC_ELFSTRUCTS_H__ 1 -+/* -+ * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * 3. The name of the author may not be used to endorse or promote products -+ * derived from this software without specific prior written permission -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ */ -+ -+typedef uint8_t Elf_Byte; -+ -+typedef uint32_t Elf32_Addr; /* Unsigned program address */ -+typedef uint32_t Elf32_Off; /* Unsigned file offset */ -+typedef int32_t Elf32_Sword; /* Signed large integer */ -+typedef uint32_t Elf32_Word; /* Unsigned large integer */ -+typedef uint16_t Elf32_Half; /* Unsigned medium integer */ -+ -+typedef uint64_t Elf64_Addr; -+typedef uint64_t Elf64_Off; -+typedef int32_t Elf64_Shalf; -+ -+typedef int32_t Elf64_Sword; -+typedef uint32_t Elf64_Word; -+ -+typedef int64_t Elf64_Sxword; -+typedef uint64_t Elf64_Xword; -+ -+typedef uint32_t Elf64_Half; -+typedef uint16_t Elf64_Quarter; -+ -+/* -+ * e_ident[] identification indexes -+ * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html -+ */ -+#define EI_MAG0 0 /* file ID */ -+#define EI_MAG1 1 /* file ID */ -+#define EI_MAG2 2 /* file ID */ -+#define EI_MAG3 3 /* file ID */ -+#define EI_CLASS 4 /* file class */ -+#define EI_DATA 5 /* data encoding */ -+#define EI_VERSION 6 /* ELF header version */ -+#define EI_OSABI 7 /* OS/ABI ID */ -+#define EI_ABIVERSION 8 /* ABI version */ -+#define EI_PAD 9 /* start of pad bytes */ -+#define EI_NIDENT 16 /* Size of e_ident[] */ -+ -+/* e_ident[] magic number */ -+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ -+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ -+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ -+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ -+#define ELFMAG "\177ELF" /* magic */ -+#define SELFMAG 4 /* size of magic */ -+ -+/* e_ident[] file class */ -+#define ELFCLASSNONE 0 /* invalid */ -+#define ELFCLASS32 1 /* 32-bit objs */ -+#define ELFCLASS64 2 /* 64-bit objs */ -+#define ELFCLASSNUM 3 /* number of classes */ -+ -+/* e_ident[] data encoding */ -+#define ELFDATANONE 0 /* invalid */ -+#define ELFDATA2LSB 1 /* Little-Endian */ -+#define ELFDATA2MSB 2 /* Big-Endian */ -+#define ELFDATANUM 3 /* number of data encode defines */ -+ -+/* e_ident[] Operating System/ABI */ -+#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ -+#define ELFOSABI_HPUX 1 /* HP-UX operating system */ -+#define ELFOSABI_NETBSD 2 /* NetBSD */ -+#define ELFOSABI_LINUX 3 /* GNU/Linux */ -+#define ELFOSABI_HURD 4 /* GNU/Hurd */ -+#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ -+#define ELFOSABI_SOLARIS 6 /* Solaris */ -+#define ELFOSABI_MONTEREY 7 /* Monterey */ -+#define ELFOSABI_IRIX 8 /* IRIX */ -+#define ELFOSABI_FREEBSD 9 /* FreeBSD */ -+#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ -+#define ELFOSABI_MODESTO 11 /* Novell Modesto */ -+#define ELFOSABI_OPENBSD 12 /* OpenBSD */ -+#define ELFOSABI_ARM 97 /* ARM */ -+#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ -+ -+/* e_ident */ -+#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ -+ (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ -+ (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ -+ (ehdr).e_ident[EI_MAG3] == ELFMAG3) -+ -+/* ELF Header */ -+typedef struct elfhdr { -+ unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ -+ Elf32_Half e_type; /* object file type */ -+ Elf32_Half e_machine; /* machine */ -+ Elf32_Word e_version; /* object file version */ -+ Elf32_Addr e_entry; /* virtual entry point */ -+ Elf32_Off e_phoff; /* program header table offset */ -+ Elf32_Off e_shoff; /* section header table offset */ -+ Elf32_Word e_flags; /* processor-specific flags */ -+ Elf32_Half e_ehsize; /* ELF header size */ -+ Elf32_Half e_phentsize; /* program header entry size */ -+ Elf32_Half e_phnum; /* number of program header entries */ -+ Elf32_Half e_shentsize; /* section header entry size */ -+ Elf32_Half e_shnum; /* number of section header entries */ -+ Elf32_Half e_shstrndx; /* section header table's "section -+ header string table" entry offset */ -+} Elf32_Ehdr; -+ -+typedef struct { -+ unsigned char e_ident[EI_NIDENT]; /* Id bytes */ -+ Elf64_Quarter e_type; /* file type */ -+ Elf64_Quarter e_machine; /* machine type */ -+ Elf64_Half e_version; /* version number */ -+ Elf64_Addr e_entry; /* entry point */ -+ Elf64_Off e_phoff; /* Program hdr offset */ -+ Elf64_Off e_shoff; /* Section hdr offset */ -+ Elf64_Half e_flags; /* Processor flags */ -+ Elf64_Quarter e_ehsize; /* sizeof ehdr */ -+ Elf64_Quarter e_phentsize; /* Program header entry size */ -+ Elf64_Quarter e_phnum; /* Number of program headers */ -+ Elf64_Quarter e_shentsize; /* Section header entry size */ -+ Elf64_Quarter e_shnum; /* Number of section headers */ -+ Elf64_Quarter e_shstrndx; /* String table index */ -+} Elf64_Ehdr; -+ -+/* e_type */ -+#define ET_NONE 0 /* No file type */ -+#define ET_REL 1 /* relocatable file */ -+#define ET_EXEC 2 /* executable file */ -+#define ET_DYN 3 /* shared object file */ -+#define ET_CORE 4 /* core file */ -+#define ET_NUM 5 /* number of types */ -+#define ET_LOPROC 0xff00 /* reserved range for processor */ -+#define ET_HIPROC 0xffff /* specific e_type */ -+ -+/* e_machine */ -+#define EM_NONE 0 /* No Machine */ -+#define EM_M32 1 /* AT&T WE 32100 */ -+#define EM_SPARC 2 /* SPARC */ -+#define EM_386 3 /* Intel 80386 */ -+#define EM_68K 4 /* Motorola 68000 */ -+#define EM_88K 5 /* Motorola 88000 */ -+#define EM_486 6 /* Intel 80486 - unused? */ -+#define EM_860 7 /* Intel 80860 */ -+#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ -+/* -+ * Don't know if EM_MIPS_RS4_BE, -+ * EM_SPARC64, EM_PARISC, -+ * or EM_PPC are ABI compliant -+ */ -+#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ -+#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */ -+#define EM_PARISC 15 /* HPPA */ -+#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ -+#define EM_PPC 20 /* PowerPC */ -+#define EM_PPC64 21 /* PowerPC 64-bit */ -+#define EM_ARM 40 /* Advanced RISC Machines ARM */ -+#define EM_ALPHA 41 /* DEC ALPHA */ -+#define EM_SPARCV9 43 /* SPARC version 9 */ -+#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */ -+#define EM_IA_64 50 /* Intel Merced */ -+#define EM_X86_64 62 /* AMD x86-64 architecture */ -+#define EM_VAX 75 /* DEC VAX */ -+ -+/* Version */ -+#define EV_NONE 0 /* Invalid */ -+#define EV_CURRENT 1 /* Current */ -+#define EV_NUM 2 /* number of versions */ -+ -+/* Section Header */ -+typedef struct { -+ Elf32_Word sh_name; /* name - index into section header -+ string table section */ -+ Elf32_Word sh_type; /* type */ -+ Elf32_Word sh_flags; /* flags */ -+ Elf32_Addr sh_addr; /* address */ -+ Elf32_Off sh_offset; /* file offset */ -+ Elf32_Word sh_size; /* section size */ -+ Elf32_Word sh_link; /* section header table index link */ -+ Elf32_Word sh_info; /* extra information */ -+ Elf32_Word sh_addralign; /* address alignment */ -+ Elf32_Word sh_entsize; /* section entry size */ -+} Elf32_Shdr; -+ -+typedef struct { -+ Elf64_Half sh_name; /* section name */ -+ Elf64_Half sh_type; /* section type */ -+ Elf64_Xword sh_flags; /* section flags */ -+ Elf64_Addr sh_addr; /* virtual address */ -+ Elf64_Off sh_offset; /* file offset */ -+ Elf64_Xword sh_size; /* section size */ -+ Elf64_Half sh_link; /* link to another */ -+ Elf64_Half sh_info; /* misc info */ -+ Elf64_Xword sh_addralign; /* memory alignment */ -+ Elf64_Xword sh_entsize; /* table entry size */ -+} Elf64_Shdr; -+ -+/* Special Section Indexes */ -+#define SHN_UNDEF 0 /* undefined */ -+#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ -+#define SHN_LOPROC 0xff00 /* reserved range for processor */ -+#define SHN_HIPROC 0xff1f /* specific section indexes */ -+#define SHN_ABS 0xfff1 /* absolute value */ -+#define SHN_COMMON 0xfff2 /* common symbol */ -+#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ -+ -+/* sh_type */ -+#define SHT_NULL 0 /* inactive */ -+#define SHT_PROGBITS 1 /* program defined information */ -+#define SHT_SYMTAB 2 /* symbol table section */ -+#define SHT_STRTAB 3 /* string table section */ -+#define SHT_RELA 4 /* relocation section with addends*/ -+#define SHT_HASH 5 /* symbol hash table section */ -+#define SHT_DYNAMIC 6 /* dynamic section */ -+#define SHT_NOTE 7 /* note section */ -+#define SHT_NOBITS 8 /* no space section */ -+#define SHT_REL 9 /* relation section without addends */ -+#define SHT_SHLIB 10 /* reserved - purpose unknown */ -+#define SHT_DYNSYM 11 /* dynamic symbol table section */ -+#define SHT_NUM 12 /* number of section types */ -+#define SHT_LOPROC 0x70000000 /* reserved range for processor */ -+#define SHT_HIPROC 0x7fffffff /* specific section header types */ -+#define SHT_LOUSER 0x80000000 /* reserved range for application */ -+#define SHT_HIUSER 0xffffffff /* specific indexes */ -+ -+/* Section names */ -+#define ELF_BSS ".bss" /* uninitialized data */ -+#define ELF_DATA ".data" /* initialized data */ -+#define ELF_DEBUG ".debug" /* debug */ -+#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ -+#define ELF_DYNSTR ".dynstr" /* dynamic string table */ -+#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ -+#define ELF_FINI ".fini" /* termination code */ -+#define ELF_GOT ".got" /* global offset table */ -+#define ELF_HASH ".hash" /* symbol hash table */ -+#define ELF_INIT ".init" /* initialization code */ -+#define ELF_REL_DATA ".rel.data" /* relocation data */ -+#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ -+#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ -+#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ -+#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ -+#define ELF_REL_TEXT ".rel.text" /* relocation code */ -+#define ELF_RODATA ".rodata" /* read-only data */ -+#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ -+#define ELF_STRTAB ".strtab" /* string table */ -+#define ELF_SYMTAB ".symtab" /* symbol table */ -+#define ELF_TEXT ".text" /* code */ -+ -+ -+/* Section Attribute Flags - sh_flags */ -+#define SHF_WRITE 0x1 /* Writable */ -+#define SHF_ALLOC 0x2 /* occupies memory */ -+#define SHF_EXECINSTR 0x4 /* executable */ -+#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ -+ /* specific section attributes */ -+ -+/* Symbol Table Entry */ -+typedef struct elf32_sym { -+ Elf32_Word st_name; /* name - index into string table */ -+ Elf32_Addr st_value; /* symbol value */ -+ Elf32_Word st_size; /* symbol size */ -+ unsigned char st_info; /* type and binding */ -+ unsigned char st_other; /* 0 - no defined meaning */ -+ Elf32_Half st_shndx; /* section header index */ -+} Elf32_Sym; -+ -+typedef struct { -+ Elf64_Half st_name; /* Symbol name index in str table */ -+ Elf_Byte st_info; /* type / binding attrs */ -+ Elf_Byte st_other; /* unused */ -+ Elf64_Quarter st_shndx; /* section index of symbol */ -+ Elf64_Xword st_value; /* value of symbol */ -+ Elf64_Xword st_size; /* size of symbol */ -+} Elf64_Sym; -+ -+/* Symbol table index */ -+#define STN_UNDEF 0 /* undefined */ -+ -+/* Extract symbol info - st_info */ -+#define ELF32_ST_BIND(x) ((x) >> 4) -+#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) -+#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -+ -+#define ELF64_ST_BIND(x) ((x) >> 4) -+#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf) -+#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -+ -+/* Symbol Binding - ELF32_ST_BIND - st_info */ -+#define STB_LOCAL 0 /* Local symbol */ -+#define STB_GLOBAL 1 /* Global symbol */ -+#define STB_WEAK 2 /* like global - lower precedence */ -+#define STB_NUM 3 /* number of symbol bindings */ -+#define STB_LOPROC 13 /* reserved range for processor */ -+#define STB_HIPROC 15 /* specific symbol bindings */ -+ -+/* Symbol type - ELF32_ST_TYPE - st_info */ -+#define STT_NOTYPE 0 /* not specified */ -+#define STT_OBJECT 1 /* data object */ -+#define STT_FUNC 2 /* function */ -+#define STT_SECTION 3 /* section */ -+#define STT_FILE 4 /* file */ -+#define STT_NUM 5 /* number of symbol types */ -+#define STT_LOPROC 13 /* reserved range for processor */ -+#define STT_HIPROC 15 /* specific symbol types */ -+ -+/* Relocation entry with implicit addend */ -+typedef struct { -+ Elf32_Addr r_offset; /* offset of relocation */ -+ Elf32_Word r_info; /* symbol table index and type */ -+} Elf32_Rel; -+ -+/* Relocation entry with explicit addend */ -+typedef struct { -+ Elf32_Addr r_offset; /* offset of relocation */ -+ Elf32_Word r_info; /* symbol table index and type */ -+ Elf32_Sword r_addend; -+} Elf32_Rela; -+ -+/* Extract relocation info - r_info */ -+#define ELF32_R_SYM(i) ((i) >> 8) -+#define ELF32_R_TYPE(i) ((unsigned char) (i)) -+#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) -+ -+typedef struct { -+ Elf64_Xword r_offset; /* where to do it */ -+ Elf64_Xword r_info; /* index & type of relocation */ -+} Elf64_Rel; -+ -+typedef struct { -+ Elf64_Xword r_offset; /* where to do it */ -+ Elf64_Xword r_info; /* index & type of relocation */ -+ Elf64_Sxword r_addend; /* adjustment value */ -+} Elf64_Rela; -+ -+#define ELF64_R_SYM(info) ((info) >> 32) -+#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF) -+#define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t)) -+ -+/* Program Header */ -+typedef struct { -+ Elf32_Word p_type; /* segment type */ -+ Elf32_Off p_offset; /* segment offset */ -+ Elf32_Addr p_vaddr; /* virtual address of segment */ -+ Elf32_Addr p_paddr; /* physical address - ignored? */ -+ Elf32_Word p_filesz; /* number of bytes in file for seg. */ -+ Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ -+ Elf32_Word p_flags; /* flags */ -+ Elf32_Word p_align; /* memory alignment */ -+} Elf32_Phdr; -+ -+typedef struct { -+ Elf64_Half p_type; /* entry type */ -+ Elf64_Half p_flags; /* flags */ -+ Elf64_Off p_offset; /* offset */ -+ Elf64_Addr p_vaddr; /* virtual address */ -+ Elf64_Addr p_paddr; /* physical address */ -+ Elf64_Xword p_filesz; /* file size */ -+ Elf64_Xword p_memsz; /* memory size */ -+ Elf64_Xword p_align; /* memory & file alignment */ -+} Elf64_Phdr; -+ -+/* Segment types - p_type */ -+#define PT_NULL 0 /* unused */ -+#define PT_LOAD 1 /* loadable segment */ -+#define PT_DYNAMIC 2 /* dynamic linking section */ -+#define PT_INTERP 3 /* the RTLD */ -+#define PT_NOTE 4 /* auxiliary information */ -+#define PT_SHLIB 5 /* reserved - purpose undefined */ -+#define PT_PHDR 6 /* program header */ -+#define PT_NUM 7 /* Number of segment types */ -+#define PT_LOPROC 0x70000000 /* reserved range for processor */ -+#define PT_HIPROC 0x7fffffff /* specific segment types */ -+ -+/* Segment flags - p_flags */ -+#define PF_X 0x1 /* Executable */ -+#define PF_W 0x2 /* Writable */ -+#define PF_R 0x4 /* Readable */ -+#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ -+ /* specific segment flags */ -+ -+/* Dynamic structure */ -+typedef struct { -+ Elf32_Sword d_tag; /* controls meaning of d_val */ -+ union { -+ Elf32_Word d_val; /* Multiple meanings - see d_tag */ -+ Elf32_Addr d_ptr; /* program virtual address */ -+ } d_un; -+} Elf32_Dyn; -+ -+typedef struct { -+ Elf64_Xword d_tag; /* controls meaning of d_val */ -+ union { -+ Elf64_Addr d_ptr; -+ Elf64_Xword d_val; -+ } d_un; -+} Elf64_Dyn; -+ -+/* Dynamic Array Tags - d_tag */ -+#define DT_NULL 0 /* marks end of _DYNAMIC array */ -+#define DT_NEEDED 1 /* string table offset of needed lib */ -+#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ -+#define DT_PLTGOT 3 /* address PLT/GOT */ -+#define DT_HASH 4 /* address of symbol hash table */ -+#define DT_STRTAB 5 /* address of string table */ -+#define DT_SYMTAB 6 /* address of symbol table */ -+#define DT_RELA 7 /* address of relocation table */ -+#define DT_RELASZ 8 /* size of relocation table */ -+#define DT_RELAENT 9 /* size of relocation entry */ -+#define DT_STRSZ 10 /* size of string table */ -+#define DT_SYMENT 11 /* size of symbol table entry */ -+#define DT_INIT 12 /* address of initialization func. */ -+#define DT_FINI 13 /* address of termination function */ -+#define DT_SONAME 14 /* string table offset of shared obj */ -+#define DT_RPATH 15 /* string table offset of library -+ search path */ -+#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ -+#define DT_REL 17 /* address of rel. tbl. w addends */ -+#define DT_RELSZ 18 /* size of DT_REL relocation table */ -+#define DT_RELENT 19 /* size of DT_REL relocation entry */ -+#define DT_PLTREL 20 /* PLT referenced relocation entry */ -+#define DT_DEBUG 21 /* bugger */ -+#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ -+#define DT_JMPREL 23 /* add. of PLT's relocation entries */ -+#define DT_BIND_NOW 24 /* Bind now regardless of env setting */ -+#define DT_NUM 25 /* Number used. */ -+#define DT_LOPROC 0x70000000 /* reserved range for processor */ -+#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ -+ -+/* Standard ELF hashing function */ -+unsigned int elf_hash(const unsigned char *name); -+ -+/* -+ * Note Definitions -+ */ -+typedef struct { -+ Elf32_Word namesz; -+ Elf32_Word descsz; -+ Elf32_Word type; -+} Elf32_Note; -+ -+typedef struct { -+ Elf64_Half namesz; -+ Elf64_Half descsz; -+ Elf64_Half type; -+} Elf64_Note; -+ -+ -+#if defined(ELFSIZE) -+#define CONCAT(x,y) __CONCAT(x,y) -+#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) -+#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) -+#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) -+#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) -+#endif -+ -+#if defined(ELFSIZE) && (ELFSIZE == 32) -+#define Elf_Ehdr Elf32_Ehdr -+#define Elf_Phdr Elf32_Phdr -+#define Elf_Shdr Elf32_Shdr -+#define Elf_Sym Elf32_Sym -+#define Elf_Rel Elf32_Rel -+#define Elf_RelA Elf32_Rela -+#define Elf_Dyn Elf32_Dyn -+#define Elf_Word Elf32_Word -+#define Elf_Sword Elf32_Sword -+#define Elf_Addr Elf32_Addr -+#define Elf_Off Elf32_Off -+#define Elf_Nhdr Elf32_Nhdr -+#define Elf_Note Elf32_Note -+ -+#define ELF_R_SYM ELF32_R_SYM -+#define ELF_R_TYPE ELF32_R_TYPE -+#define ELF_R_INFO ELF32_R_INFO -+#define ELFCLASS ELFCLASS32 -+ -+#define ELF_ST_BIND ELF32_ST_BIND -+#define ELF_ST_TYPE ELF32_ST_TYPE -+#define ELF_ST_INFO ELF32_ST_INFO -+ -+#define AuxInfo Aux32Info -+#elif defined(ELFSIZE) && (ELFSIZE == 64) -+#define Elf_Ehdr Elf64_Ehdr -+#define Elf_Phdr Elf64_Phdr -+#define Elf_Shdr Elf64_Shdr -+#define Elf_Sym Elf64_Sym -+#define Elf_Rel Elf64_Rel -+#define Elf_RelA Elf64_Rela -+#define Elf_Dyn Elf64_Dyn -+#define Elf_Word Elf64_Word -+#define Elf_Sword Elf64_Sword -+#define Elf_Addr Elf64_Addr -+#define Elf_Off Elf64_Off -+#define Elf_Nhdr Elf64_Nhdr -+#define Elf_Note Elf64_Note -+ -+#define ELF_R_SYM ELF64_R_SYM -+#define ELF_R_TYPE ELF64_R_TYPE -+#define ELF_R_INFO ELF64_R_INFO -+#define ELFCLASS ELFCLASS64 -+ -+#define ELF_ST_BIND ELF64_ST_BIND -+#define ELF_ST_TYPE ELF64_ST_TYPE -+#define ELF_ST_INFO ELF64_ST_INFO -+ -+#define AuxInfo Aux64Info -+#endif -+ -+#endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */ -Index: build-32-release304-13132/xen/include/public/libelf.h -=================================================================== ---- /dev/null -+++ build-32-release304-13132/xen/include/public/libelf.h -@@ -0,0 +1,238 @@ -+#ifndef __XC_LIBELF__ -+#define __XC_LIBELF__ 1 -+ -+#ifdef __XEN__ -+ -+#include -+#include -+typedef uint64_t off_t; -+ -+#define LITTLE_ENDIAN 1234 -+#define BIG_ENDIAN 4321 -+#if defined(__i386__) || defined(__x86_64) || defined(__ia64__) -+#define BYTE_ORDER LITTLE_ENDIAN -+#elif defined(__powerpc__) -+#define BYTE_ORDER BIG_ENDIAN -+#endif -+ -+#else /* !__XEN__ */ -+ -+#include -+#include -+ -+#endif -+ -+#undef ELFSIZE -+#include "elfstructs.h" -+#include "features.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+typedef union { -+ Elf32_Ehdr e32; -+ Elf64_Ehdr e64; -+} elf_ehdr; -+ -+typedef union { -+ Elf32_Phdr e32; -+ Elf64_Phdr e64; -+} elf_phdr; -+ -+typedef union { -+ Elf32_Shdr e32; -+ Elf64_Shdr e64; -+} elf_shdr; -+ -+typedef union { -+ Elf32_Sym e32; -+ Elf64_Sym e64; -+} elf_sym; -+ -+typedef union { -+ Elf32_Rel e32; -+ Elf64_Rel e64; -+} elf_rel; -+ -+typedef union { -+ Elf32_Rela e32; -+ Elf64_Rela e64; -+} elf_rela; -+ -+typedef union { -+ Elf32_Note e32; -+ Elf64_Note e64; -+} elf_note; -+ -+struct elf_binary { -+ /* elf binary */ -+ const char *image; -+ size_t size; -+ char class; -+ char data; -+ -+ const elf_ehdr *ehdr; -+ const char *sec_strtab; -+ const elf_shdr *sym_tab; -+ const char *sym_strtab; -+ -+ /* loaded to */ -+ char *dest; -+ uint64_t pstart; -+ uint64_t pend; -+ uint64_t reloc_offset; -+ -+#ifndef __XEN__ -+ /* misc */ -+ FILE *log; -+#endif -+ int verbose; -+}; -+ -+/* ------------------------------------------------------------------------ */ -+/* accessing elf header fields */ -+ -+#if !defined(BYTE_ORDER) -+# error BYTE_ORDER not defined -+#elif BYTE_ORDER == BIG_ENDIAN -+# define NATIVE_ELFDATA ELFDATA2MSB -+#elif BYTE_ORDER == LITTLE_ENDIAN -+# define NATIVE_ELFDATA ELFDATA2LSB -+#else -+# error BYTE_ORDER unknown -+#endif -+ -+#define elf_32bit(elf) (ELFCLASS32 == (elf)->class) -+#define elf_64bit(elf) (ELFCLASS64 == (elf)->class) -+#define elf_msb(elf) (ELFDATA2MSB == (elf)->data) -+#define elf_lsb(elf) (ELFDATA2LSB == (elf)->data) -+#define elf_swap(elf) (NATIVE_ELFDATA != (elf)->data) -+ -+#define elf_uval(elf, str, elem) \ -+ ((ELFCLASS64 == (elf)->class) \ -+ ? elf_access_unsigned((elf), (str), \ -+ offsetof(typeof(*(str)),e64.elem), \ -+ sizeof((str)->e64.elem)) \ -+ : elf_access_unsigned((elf), (str), \ -+ offsetof(typeof(*(str)),e32.elem), \ -+ sizeof((str)->e32.elem))) -+ -+#define elf_sval(elf, str, elem) \ -+ ((ELFCLASS64 == (elf)->class) \ -+ ? elf_access_signed((elf), (str), \ -+ offsetof(typeof(*(str)),e64.elem), \ -+ sizeof((str)->e64.elem)) \ -+ : elf_access_signed((elf), (str), \ -+ offsetof(typeof(*(str)),e32.elem), \ -+ sizeof((str)->e32.elem))) -+ -+#define elf_size(elf, str) \ -+ ((ELFCLASS64 == (elf)->class) \ -+ ? sizeof((str)->e64) \ -+ : sizeof((str)->e32)) -+ -+uint64_t elf_access_unsigned(struct elf_binary *elf, const void *ptr, -+ off_t offset, size_t size); -+int64_t elf_access_signed(struct elf_binary *elf, const void *ptr, -+ off_t offset, size_t size); -+ -+uint64_t elf_round_up(struct elf_binary *elf, uint64_t addr); -+ -+/* ------------------------------------------------------------------------ */ -+/* xc_libelf_tools.c */ -+ -+int elf_shdr_count(struct elf_binary *elf); -+int elf_phdr_count(struct elf_binary *elf); -+ -+const elf_shdr *elf_shdr_by_name(struct elf_binary *elf, const char *name); -+const elf_shdr *elf_shdr_by_index(struct elf_binary *elf, int index); -+const elf_phdr *elf_phdr_by_index(struct elf_binary *elf, int index); -+ -+const char *elf_section_name(struct elf_binary *elf, const elf_shdr * shdr); -+const void *elf_section_start(struct elf_binary *elf, const elf_shdr * shdr); -+const void *elf_section_end(struct elf_binary *elf, const elf_shdr * shdr); -+ -+const elf_sym *elf_sym_by_name(struct elf_binary *elf, const char *symbol); -+const elf_sym *elf_sym_by_index(struct elf_binary *elf, int index); -+ -+const char *elf_note_name(struct elf_binary *elf, const elf_note * note); -+const void *elf_note_desc(struct elf_binary *elf, const elf_note * note); -+uint64_t elf_note_numeric(struct elf_binary *elf, const elf_note * note); -+const elf_note *elf_note_next(struct elf_binary *elf, const elf_note * note); -+ -+int elf_is_elfbinary(const void *image); -+int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr); -+ -+/* ------------------------------------------------------------------------ */ -+/* xc_libelf_loader.c */ -+ -+int elf_init(struct elf_binary *elf, const char *image, size_t size); -+#ifdef __XEN__ -+void elf_set_verbose(struct elf_binary *elf); -+#else -+void elf_set_logfile(struct elf_binary *elf, FILE * log, int verbose); -+#endif -+ -+void elf_parse_binary(struct elf_binary *elf); -+void elf_load_binary(struct elf_binary *elf); -+ -+void *elf_get_ptr(struct elf_binary *elf, unsigned long addr); -+uint64_t elf_lookup_addr(struct elf_binary *elf, const char *symbol); -+ -+/* ------------------------------------------------------------------------ */ -+/* xc_libelf_relocate.c */ -+ -+int elf_reloc(struct elf_binary *elf); -+ -+/* ------------------------------------------------------------------------ */ -+/* xc_libelf_dominfo.c */ -+ -+#define UNSET_ADDR ((uint64_t)-1) -+ -+struct elf_dom_parms { -+ /* raw */ -+ const char *guest_info; -+ const void *elf_note_start; -+ const void *elf_note_end; -+ -+ /* parsed */ -+ char guest_os[16]; -+ char guest_ver[16]; -+ char xen_ver[16]; -+ char loader[16]; -+ int pae; -+ int bsd_symtab; -+ uint64_t virt_base; -+ uint64_t virt_entry; -+ uint64_t virt_hypercall; -+ uint64_t virt_hv_start_low; -+ uint64_t elf_paddr_offset; -+ uint32_t f_supported[XENFEAT_NR_SUBMAPS]; -+ uint32_t f_required[XENFEAT_NR_SUBMAPS]; -+ -+ /* calculated */ -+ uint64_t virt_offset; -+ uint64_t virt_kstart; -+ uint64_t virt_kend; -+}; -+ -+static inline void elf_xen_feature_set(int nr, uint32_t * addr) -+{ -+ addr[nr >> 5] |= 1 << (nr & 31); -+} -+static inline int elf_xen_feature_get(int nr, uint32_t * addr) -+{ -+ return !!(addr[nr >> 5] & (1 << (nr & 31))); -+} -+ -+int elf_xen_parse_features(const char *features, -+ uint32_t *supported, -+ uint32_t *required); -+int elf_xen_parse_note(struct elf_binary *elf, -+ struct elf_dom_parms *parms, -+ const elf_note *note); -+int elf_xen_parse_guest_info(struct elf_binary *elf, -+ struct elf_dom_parms *parms); -+int elf_xen_parse(struct elf_binary *elf, -+ struct elf_dom_parms *parms); -+ -+#endif /* __XC_LIBELF__ */ -Index: build-32-release304-13132/tools/libxc/xc_elf.h -=================================================================== ---- build-32-release304-13132.orig/tools/libxc/xc_elf.h -+++ build-32-release304-13132/tools/libxc/xc_elf.h -@@ -1,524 +1 @@ --/* -- * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. -- * -- * Redistribution and use in source and binary forms, with or without -- * modification, are permitted provided that the following conditions -- * are met: -- * 1. Redistributions of source code must retain the above copyright -- * notice, this list of conditions and the following disclaimer. -- * 2. Redistributions in binary form must reproduce the above copyright -- * notice, this list of conditions and the following disclaimer in the -- * documentation and/or other materials provided with the distribution. -- * 3. The name of the author may not be used to endorse or promote products -- * derived from this software without specific prior written permission -- * -- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- */ -- --typedef uint8_t Elf_Byte; -- --typedef uint32_t Elf32_Addr; /* Unsigned program address */ --typedef uint32_t Elf32_Off; /* Unsigned file offset */ --typedef int32_t Elf32_Sword; /* Signed large integer */ --typedef uint32_t Elf32_Word; /* Unsigned large integer */ --typedef uint16_t Elf32_Half; /* Unsigned medium integer */ -- --typedef uint64_t Elf64_Addr; --typedef uint64_t Elf64_Off; --typedef int32_t Elf64_Shalf; -- --typedef int32_t Elf64_Sword; --typedef uint32_t Elf64_Word; -- --typedef int64_t Elf64_Sxword; --typedef uint64_t Elf64_Xword; -- --typedef uint32_t Elf64_Half; --typedef uint16_t Elf64_Quarter; -- --/* -- * e_ident[] identification indexes -- * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html -- */ --#define EI_MAG0 0 /* file ID */ --#define EI_MAG1 1 /* file ID */ --#define EI_MAG2 2 /* file ID */ --#define EI_MAG3 3 /* file ID */ --#define EI_CLASS 4 /* file class */ --#define EI_DATA 5 /* data encoding */ --#define EI_VERSION 6 /* ELF header version */ --#define EI_OSABI 7 /* OS/ABI ID */ --#define EI_ABIVERSION 8 /* ABI version */ --#define EI_PAD 9 /* start of pad bytes */ --#define EI_NIDENT 16 /* Size of e_ident[] */ -- --/* e_ident[] magic number */ --#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ --#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ --#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ --#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ --#define ELFMAG "\177ELF" /* magic */ --#define SELFMAG 4 /* size of magic */ -- --/* e_ident[] file class */ --#define ELFCLASSNONE 0 /* invalid */ --#define ELFCLASS32 1 /* 32-bit objs */ --#define ELFCLASS64 2 /* 64-bit objs */ --#define ELFCLASSNUM 3 /* number of classes */ -- --/* e_ident[] data encoding */ --#define ELFDATANONE 0 /* invalid */ --#define ELFDATA2LSB 1 /* Little-Endian */ --#define ELFDATA2MSB 2 /* Big-Endian */ --#define ELFDATANUM 3 /* number of data encode defines */ -- --/* e_ident[] Operating System/ABI */ --#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ --#define ELFOSABI_HPUX 1 /* HP-UX operating system */ --#define ELFOSABI_NETBSD 2 /* NetBSD */ --#define ELFOSABI_LINUX 3 /* GNU/Linux */ --#define ELFOSABI_HURD 4 /* GNU/Hurd */ --#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ --#define ELFOSABI_SOLARIS 6 /* Solaris */ --#define ELFOSABI_MONTEREY 7 /* Monterey */ --#define ELFOSABI_IRIX 8 /* IRIX */ --#define ELFOSABI_FREEBSD 9 /* FreeBSD */ --#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ --#define ELFOSABI_MODESTO 11 /* Novell Modesto */ --#define ELFOSABI_OPENBSD 12 /* OpenBSD */ --#define ELFOSABI_ARM 97 /* ARM */ --#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ -- --/* e_ident */ --#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ -- (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ -- (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ -- (ehdr).e_ident[EI_MAG3] == ELFMAG3) -- --/* ELF Header */ --typedef struct elfhdr { -- unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ -- Elf32_Half e_type; /* object file type */ -- Elf32_Half e_machine; /* machine */ -- Elf32_Word e_version; /* object file version */ -- Elf32_Addr e_entry; /* virtual entry point */ -- Elf32_Off e_phoff; /* program header table offset */ -- Elf32_Off e_shoff; /* section header table offset */ -- Elf32_Word e_flags; /* processor-specific flags */ -- Elf32_Half e_ehsize; /* ELF header size */ -- Elf32_Half e_phentsize; /* program header entry size */ -- Elf32_Half e_phnum; /* number of program header entries */ -- Elf32_Half e_shentsize; /* section header entry size */ -- Elf32_Half e_shnum; /* number of section header entries */ -- Elf32_Half e_shstrndx; /* section header table's "section -- header string table" entry offset */ --} Elf32_Ehdr; -- --typedef struct { -- unsigned char e_ident[EI_NIDENT]; /* Id bytes */ -- Elf64_Quarter e_type; /* file type */ -- Elf64_Quarter e_machine; /* machine type */ -- Elf64_Half e_version; /* version number */ -- Elf64_Addr e_entry; /* entry point */ -- Elf64_Off e_phoff; /* Program hdr offset */ -- Elf64_Off e_shoff; /* Section hdr offset */ -- Elf64_Half e_flags; /* Processor flags */ -- Elf64_Quarter e_ehsize; /* sizeof ehdr */ -- Elf64_Quarter e_phentsize; /* Program header entry size */ -- Elf64_Quarter e_phnum; /* Number of program headers */ -- Elf64_Quarter e_shentsize; /* Section header entry size */ -- Elf64_Quarter e_shnum; /* Number of section headers */ -- Elf64_Quarter e_shstrndx; /* String table index */ --} Elf64_Ehdr; -- --/* e_type */ --#define ET_NONE 0 /* No file type */ --#define ET_REL 1 /* relocatable file */ --#define ET_EXEC 2 /* executable file */ --#define ET_DYN 3 /* shared object file */ --#define ET_CORE 4 /* core file */ --#define ET_NUM 5 /* number of types */ --#define ET_LOPROC 0xff00 /* reserved range for processor */ --#define ET_HIPROC 0xffff /* specific e_type */ -- --/* e_machine */ --#define EM_NONE 0 /* No Machine */ --#define EM_M32 1 /* AT&T WE 32100 */ --#define EM_SPARC 2 /* SPARC */ --#define EM_386 3 /* Intel 80386 */ --#define EM_68K 4 /* Motorola 68000 */ --#define EM_88K 5 /* Motorola 88000 */ --#define EM_486 6 /* Intel 80486 - unused? */ --#define EM_860 7 /* Intel 80860 */ --#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ --/* -- * Don't know if EM_MIPS_RS4_BE, -- * EM_SPARC64, EM_PARISC, -- * or EM_PPC are ABI compliant -- */ --#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ --#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */ --#define EM_PARISC 15 /* HPPA */ --#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ --#define EM_PPC 20 /* PowerPC */ --#define EM_PPC64 21 /* PowerPC 64-bit */ --#define EM_ARM 40 /* Advanced RISC Machines ARM */ --#define EM_ALPHA 41 /* DEC ALPHA */ --#define EM_SPARCV9 43 /* SPARC version 9 */ --#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */ --#define EM_IA_64 50 /* Intel Merced */ --#define EM_X86_64 62 /* AMD x86-64 architecture */ --#define EM_VAX 75 /* DEC VAX */ -- --/* Version */ --#define EV_NONE 0 /* Invalid */ --#define EV_CURRENT 1 /* Current */ --#define EV_NUM 2 /* number of versions */ -- --/* Section Header */ --typedef struct { -- Elf32_Word sh_name; /* name - index into section header -- string table section */ -- Elf32_Word sh_type; /* type */ -- Elf32_Word sh_flags; /* flags */ -- Elf32_Addr sh_addr; /* address */ -- Elf32_Off sh_offset; /* file offset */ -- Elf32_Word sh_size; /* section size */ -- Elf32_Word sh_link; /* section header table index link */ -- Elf32_Word sh_info; /* extra information */ -- Elf32_Word sh_addralign; /* address alignment */ -- Elf32_Word sh_entsize; /* section entry size */ --} Elf32_Shdr; -- --typedef struct { -- Elf64_Half sh_name; /* section name */ -- Elf64_Half sh_type; /* section type */ -- Elf64_Xword sh_flags; /* section flags */ -- Elf64_Addr sh_addr; /* virtual address */ -- Elf64_Off sh_offset; /* file offset */ -- Elf64_Xword sh_size; /* section size */ -- Elf64_Half sh_link; /* link to another */ -- Elf64_Half sh_info; /* misc info */ -- Elf64_Xword sh_addralign; /* memory alignment */ -- Elf64_Xword sh_entsize; /* table entry size */ --} Elf64_Shdr; -- --/* Special Section Indexes */ --#define SHN_UNDEF 0 /* undefined */ --#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ --#define SHN_LOPROC 0xff00 /* reserved range for processor */ --#define SHN_HIPROC 0xff1f /* specific section indexes */ --#define SHN_ABS 0xfff1 /* absolute value */ --#define SHN_COMMON 0xfff2 /* common symbol */ --#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ -- --/* sh_type */ --#define SHT_NULL 0 /* inactive */ --#define SHT_PROGBITS 1 /* program defined information */ --#define SHT_SYMTAB 2 /* symbol table section */ --#define SHT_STRTAB 3 /* string table section */ --#define SHT_RELA 4 /* relocation section with addends*/ --#define SHT_HASH 5 /* symbol hash table section */ --#define SHT_DYNAMIC 6 /* dynamic section */ --#define SHT_NOTE 7 /* note section */ --#define SHT_NOBITS 8 /* no space section */ --#define SHT_REL 9 /* relation section without addends */ --#define SHT_SHLIB 10 /* reserved - purpose unknown */ --#define SHT_DYNSYM 11 /* dynamic symbol table section */ --#define SHT_NUM 12 /* number of section types */ --#define SHT_LOPROC 0x70000000 /* reserved range for processor */ --#define SHT_HIPROC 0x7fffffff /* specific section header types */ --#define SHT_LOUSER 0x80000000 /* reserved range for application */ --#define SHT_HIUSER 0xffffffff /* specific indexes */ -- --/* Section names */ --#define ELF_BSS ".bss" /* uninitialized data */ --#define ELF_DATA ".data" /* initialized data */ --#define ELF_DEBUG ".debug" /* debug */ --#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ --#define ELF_DYNSTR ".dynstr" /* dynamic string table */ --#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ --#define ELF_FINI ".fini" /* termination code */ --#define ELF_GOT ".got" /* global offset table */ --#define ELF_HASH ".hash" /* symbol hash table */ --#define ELF_INIT ".init" /* initialization code */ --#define ELF_REL_DATA ".rel.data" /* relocation data */ --#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ --#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ --#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ --#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ --#define ELF_REL_TEXT ".rel.text" /* relocation code */ --#define ELF_RODATA ".rodata" /* read-only data */ --#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ --#define ELF_STRTAB ".strtab" /* string table */ --#define ELF_SYMTAB ".symtab" /* symbol table */ --#define ELF_TEXT ".text" /* code */ -- -- --/* Section Attribute Flags - sh_flags */ --#define SHF_WRITE 0x1 /* Writable */ --#define SHF_ALLOC 0x2 /* occupies memory */ --#define SHF_EXECINSTR 0x4 /* executable */ --#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ -- /* specific section attributes */ -- --/* Symbol Table Entry */ --typedef struct elf32_sym { -- Elf32_Word st_name; /* name - index into string table */ -- Elf32_Addr st_value; /* symbol value */ -- Elf32_Word st_size; /* symbol size */ -- unsigned char st_info; /* type and binding */ -- unsigned char st_other; /* 0 - no defined meaning */ -- Elf32_Half st_shndx; /* section header index */ --} Elf32_Sym; -- --typedef struct { -- Elf64_Half st_name; /* Symbol name index in str table */ -- Elf_Byte st_info; /* type / binding attrs */ -- Elf_Byte st_other; /* unused */ -- Elf64_Quarter st_shndx; /* section index of symbol */ -- Elf64_Xword st_value; /* value of symbol */ -- Elf64_Xword st_size; /* size of symbol */ --} Elf64_Sym; -- --/* Symbol table index */ --#define STN_UNDEF 0 /* undefined */ -- --/* Extract symbol info - st_info */ --#define ELF32_ST_BIND(x) ((x) >> 4) --#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) --#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -- --#define ELF64_ST_BIND(x) ((x) >> 4) --#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf) --#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -- --/* Symbol Binding - ELF32_ST_BIND - st_info */ --#define STB_LOCAL 0 /* Local symbol */ --#define STB_GLOBAL 1 /* Global symbol */ --#define STB_WEAK 2 /* like global - lower precedence */ --#define STB_NUM 3 /* number of symbol bindings */ --#define STB_LOPROC 13 /* reserved range for processor */ --#define STB_HIPROC 15 /* specific symbol bindings */ -- --/* Symbol type - ELF32_ST_TYPE - st_info */ --#define STT_NOTYPE 0 /* not specified */ --#define STT_OBJECT 1 /* data object */ --#define STT_FUNC 2 /* function */ --#define STT_SECTION 3 /* section */ --#define STT_FILE 4 /* file */ --#define STT_NUM 5 /* number of symbol types */ --#define STT_LOPROC 13 /* reserved range for processor */ --#define STT_HIPROC 15 /* specific symbol types */ -- --/* Relocation entry with implicit addend */ --typedef struct { -- Elf32_Addr r_offset; /* offset of relocation */ -- Elf32_Word r_info; /* symbol table index and type */ --} Elf32_Rel; -- --/* Relocation entry with explicit addend */ --typedef struct { -- Elf32_Addr r_offset; /* offset of relocation */ -- Elf32_Word r_info; /* symbol table index and type */ -- Elf32_Sword r_addend; --} Elf32_Rela; -- --/* Extract relocation info - r_info */ --#define ELF32_R_SYM(i) ((i) >> 8) --#define ELF32_R_TYPE(i) ((unsigned char) (i)) --#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) -- --typedef struct { -- Elf64_Xword r_offset; /* where to do it */ -- Elf64_Xword r_info; /* index & type of relocation */ --} Elf64_Rel; -- --typedef struct { -- Elf64_Xword r_offset; /* where to do it */ -- Elf64_Xword r_info; /* index & type of relocation */ -- Elf64_Sxword r_addend; /* adjustment value */ --} Elf64_Rela; -- --#define ELF64_R_SYM(info) ((info) >> 32) --#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF) --#define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t)) -- --/* Program Header */ --typedef struct { -- Elf32_Word p_type; /* segment type */ -- Elf32_Off p_offset; /* segment offset */ -- Elf32_Addr p_vaddr; /* virtual address of segment */ -- Elf32_Addr p_paddr; /* physical address - ignored? */ -- Elf32_Word p_filesz; /* number of bytes in file for seg. */ -- Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ -- Elf32_Word p_flags; /* flags */ -- Elf32_Word p_align; /* memory alignment */ --} Elf32_Phdr; -- --typedef struct { -- Elf64_Half p_type; /* entry type */ -- Elf64_Half p_flags; /* flags */ -- Elf64_Off p_offset; /* offset */ -- Elf64_Addr p_vaddr; /* virtual address */ -- Elf64_Addr p_paddr; /* physical address */ -- Elf64_Xword p_filesz; /* file size */ -- Elf64_Xword p_memsz; /* memory size */ -- Elf64_Xword p_align; /* memory & file alignment */ --} Elf64_Phdr; -- --/* Segment types - p_type */ --#define PT_NULL 0 /* unused */ --#define PT_LOAD 1 /* loadable segment */ --#define PT_DYNAMIC 2 /* dynamic linking section */ --#define PT_INTERP 3 /* the RTLD */ --#define PT_NOTE 4 /* auxiliary information */ --#define PT_SHLIB 5 /* reserved - purpose undefined */ --#define PT_PHDR 6 /* program header */ --#define PT_NUM 7 /* Number of segment types */ --#define PT_LOPROC 0x70000000 /* reserved range for processor */ --#define PT_HIPROC 0x7fffffff /* specific segment types */ -- --/* Segment flags - p_flags */ --#define PF_X 0x1 /* Executable */ --#define PF_W 0x2 /* Writable */ --#define PF_R 0x4 /* Readable */ --#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ -- /* specific segment flags */ -- --/* Dynamic structure */ --typedef struct { -- Elf32_Sword d_tag; /* controls meaning of d_val */ -- union { -- Elf32_Word d_val; /* Multiple meanings - see d_tag */ -- Elf32_Addr d_ptr; /* program virtual address */ -- } d_un; --} Elf32_Dyn; -- --typedef struct { -- Elf64_Xword d_tag; /* controls meaning of d_val */ -- union { -- Elf64_Addr d_ptr; -- Elf64_Xword d_val; -- } d_un; --} Elf64_Dyn; -- --/* Dynamic Array Tags - d_tag */ --#define DT_NULL 0 /* marks end of _DYNAMIC array */ --#define DT_NEEDED 1 /* string table offset of needed lib */ --#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ --#define DT_PLTGOT 3 /* address PLT/GOT */ --#define DT_HASH 4 /* address of symbol hash table */ --#define DT_STRTAB 5 /* address of string table */ --#define DT_SYMTAB 6 /* address of symbol table */ --#define DT_RELA 7 /* address of relocation table */ --#define DT_RELASZ 8 /* size of relocation table */ --#define DT_RELAENT 9 /* size of relocation entry */ --#define DT_STRSZ 10 /* size of string table */ --#define DT_SYMENT 11 /* size of symbol table entry */ --#define DT_INIT 12 /* address of initialization func. */ --#define DT_FINI 13 /* address of termination function */ --#define DT_SONAME 14 /* string table offset of shared obj */ --#define DT_RPATH 15 /* string table offset of library -- search path */ --#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ --#define DT_REL 17 /* address of rel. tbl. w addends */ --#define DT_RELSZ 18 /* size of DT_REL relocation table */ --#define DT_RELENT 19 /* size of DT_REL relocation entry */ --#define DT_PLTREL 20 /* PLT referenced relocation entry */ --#define DT_DEBUG 21 /* bugger */ --#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ --#define DT_JMPREL 23 /* add. of PLT's relocation entries */ --#define DT_BIND_NOW 24 /* Bind now regardless of env setting */ --#define DT_NUM 25 /* Number used. */ --#define DT_LOPROC 0x70000000 /* reserved range for processor */ --#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ -- --/* Standard ELF hashing function */ --unsigned int elf_hash(const unsigned char *name); -- --/* -- * Note Definitions -- */ --typedef struct { -- Elf32_Word namesz; -- Elf32_Word descsz; -- Elf32_Word type; --} Elf32_Note; -- --typedef struct { -- Elf64_Half namesz; -- Elf64_Half descsz; -- Elf64_Half type; --} Elf64_Note; -- -- --#if defined(ELFSIZE) --#define CONCAT(x,y) __CONCAT(x,y) --#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) --#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) --#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) --#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) --#endif -- --#if defined(ELFSIZE) && (ELFSIZE == 32) --#define Elf_Ehdr Elf32_Ehdr --#define Elf_Phdr Elf32_Phdr --#define Elf_Shdr Elf32_Shdr --#define Elf_Sym Elf32_Sym --#define Elf_Rel Elf32_Rel --#define Elf_RelA Elf32_Rela --#define Elf_Dyn Elf32_Dyn --#define Elf_Word Elf32_Word --#define Elf_Sword Elf32_Sword --#define Elf_Addr Elf32_Addr --#define Elf_Off Elf32_Off --#define Elf_Nhdr Elf32_Nhdr --#define Elf_Note Elf32_Note -- --#define ELF_R_SYM ELF32_R_SYM --#define ELF_R_TYPE ELF32_R_TYPE --#define ELF_R_INFO ELF32_R_INFO --#define ELFCLASS ELFCLASS32 -- --#define ELF_ST_BIND ELF32_ST_BIND --#define ELF_ST_TYPE ELF32_ST_TYPE --#define ELF_ST_INFO ELF32_ST_INFO -- --#define AuxInfo Aux32Info --#elif defined(ELFSIZE) && (ELFSIZE == 64) --#define Elf_Ehdr Elf64_Ehdr --#define Elf_Phdr Elf64_Phdr --#define Elf_Shdr Elf64_Shdr --#define Elf_Sym Elf64_Sym --#define Elf_Rel Elf64_Rel --#define Elf_RelA Elf64_Rela --#define Elf_Dyn Elf64_Dyn --#define Elf_Word Elf64_Word --#define Elf_Sword Elf64_Sword --#define Elf_Addr Elf64_Addr --#define Elf_Off Elf64_Off --#define Elf_Nhdr Elf64_Nhdr --#define Elf_Note Elf64_Note -- --#define ELF_R_SYM ELF64_R_SYM --#define ELF_R_TYPE ELF64_R_TYPE --#define ELF_R_INFO ELF64_R_INFO --#define ELFCLASS ELFCLASS64 -- --#define ELF_ST_BIND ELF64_ST_BIND --#define ELF_ST_TYPE ELF64_ST_TYPE --#define ELF_ST_INFO ELF64_ST_INFO -- --#define AuxInfo Aux64Info --#endif -- -+#include -Index: build-32-release304-13132/xen/include/xen/elf.h -=================================================================== ---- build-32-release304-13132.orig/xen/include/xen/elf.h -+++ build-32-release304-13132/xen/include/xen/elf.h -@@ -27,495 +27,7 @@ - #ifndef __XEN_ELF_H__ - #define __XEN_ELF_H__ - --typedef u8 Elf_Byte; -- --typedef u32 Elf32_Addr; /* Unsigned program address */ --typedef u32 Elf32_Off; /* Unsigned file offset */ --typedef s32 Elf32_Sword; /* Signed large integer */ --typedef u32 Elf32_Word; /* Unsigned large integer */ --typedef u16 Elf32_Half; /* Unsigned medium integer */ -- --typedef u64 Elf64_Addr; --typedef u64 Elf64_Off; --typedef s32 Elf64_Shalf; -- --typedef s32 Elf64_Sword; --typedef u32 Elf64_Word; -- --typedef s64 Elf64_Sxword; --typedef u64 Elf64_Xword; -- --typedef u32 Elf64_Half; --typedef u16 Elf64_Quarter; -- --/* -- * e_ident[] identification indexes -- * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html -- */ --#define EI_MAG0 0 /* file ID */ --#define EI_MAG1 1 /* file ID */ --#define EI_MAG2 2 /* file ID */ --#define EI_MAG3 3 /* file ID */ --#define EI_CLASS 4 /* file class */ --#define EI_DATA 5 /* data encoding */ --#define EI_VERSION 6 /* ELF header version */ --#define EI_OSABI 7 /* OS/ABI ID */ --#define EI_ABIVERSION 8 /* ABI version */ --#define EI_PAD 9 /* start of pad bytes */ --#define EI_NIDENT 16 /* Size of e_ident[] */ -- --/* e_ident[] magic number */ --#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */ --#define ELFMAG1 'E' /* e_ident[EI_MAG1] */ --#define ELFMAG2 'L' /* e_ident[EI_MAG2] */ --#define ELFMAG3 'F' /* e_ident[EI_MAG3] */ --#define ELFMAG "\177ELF" /* magic */ --#define SELFMAG 4 /* size of magic */ -- --/* e_ident[] file class */ --#define ELFCLASSNONE 0 /* invalid */ --#define ELFCLASS32 1 /* 32-bit objs */ --#define ELFCLASS64 2 /* 64-bit objs */ --#define ELFCLASSNUM 3 /* number of classes */ -- --/* e_ident[] data encoding */ --#define ELFDATANONE 0 /* invalid */ --#define ELFDATA2LSB 1 /* Little-Endian */ --#define ELFDATA2MSB 2 /* Big-Endian */ --#define ELFDATANUM 3 /* number of data encode defines */ -- --/* e_ident[] Operating System/ABI */ --#define ELFOSABI_SYSV 0 /* UNIX System V ABI */ --#define ELFOSABI_HPUX 1 /* HP-UX operating system */ --#define ELFOSABI_NETBSD 2 /* NetBSD */ --#define ELFOSABI_LINUX 3 /* GNU/Linux */ --#define ELFOSABI_HURD 4 /* GNU/Hurd */ --#define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */ --#define ELFOSABI_SOLARIS 6 /* Solaris */ --#define ELFOSABI_MONTEREY 7 /* Monterey */ --#define ELFOSABI_IRIX 8 /* IRIX */ --#define ELFOSABI_FREEBSD 9 /* FreeBSD */ --#define ELFOSABI_TRU64 10 /* TRU64 UNIX */ --#define ELFOSABI_MODESTO 11 /* Novell Modesto */ --#define ELFOSABI_OPENBSD 12 /* OpenBSD */ --#define ELFOSABI_ARM 97 /* ARM */ --#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */ -- --/* e_ident */ --#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ -- (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ -- (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ -- (ehdr).e_ident[EI_MAG3] == ELFMAG3) -- --/* ELF Header */ --typedef struct elfhdr { -- unsigned char e_ident[EI_NIDENT]; /* ELF Identification */ -- Elf32_Half e_type; /* object file type */ -- Elf32_Half e_machine; /* machine */ -- Elf32_Word e_version; /* object file version */ -- Elf32_Addr e_entry; /* virtual entry point */ -- Elf32_Off e_phoff; /* program header table offset */ -- Elf32_Off e_shoff; /* section header table offset */ -- Elf32_Word e_flags; /* processor-specific flags */ -- Elf32_Half e_ehsize; /* ELF header size */ -- Elf32_Half e_phentsize; /* program header entry size */ -- Elf32_Half e_phnum; /* number of program header entries */ -- Elf32_Half e_shentsize; /* section header entry size */ -- Elf32_Half e_shnum; /* number of section header entries */ -- Elf32_Half e_shstrndx; /* section header table's "section -- header string table" entry offset */ --} Elf32_Ehdr; -- --typedef struct { -- unsigned char e_ident[EI_NIDENT]; /* Id bytes */ -- Elf64_Quarter e_type; /* file type */ -- Elf64_Quarter e_machine; /* machine type */ -- Elf64_Half e_version; /* version number */ -- Elf64_Addr e_entry; /* entry point */ -- Elf64_Off e_phoff; /* Program hdr offset */ -- Elf64_Off e_shoff; /* Section hdr offset */ -- Elf64_Half e_flags; /* Processor flags */ -- Elf64_Quarter e_ehsize; /* sizeof ehdr */ -- Elf64_Quarter e_phentsize; /* Program header entry size */ -- Elf64_Quarter e_phnum; /* Number of program headers */ -- Elf64_Quarter e_shentsize; /* Section header entry size */ -- Elf64_Quarter e_shnum; /* Number of section headers */ -- Elf64_Quarter e_shstrndx; /* String table index */ --} Elf64_Ehdr; -- --/* e_type */ --#define ET_NONE 0 /* No file type */ --#define ET_REL 1 /* relocatable file */ --#define ET_EXEC 2 /* executable file */ --#define ET_DYN 3 /* shared object file */ --#define ET_CORE 4 /* core file */ --#define ET_NUM 5 /* number of types */ --#define ET_LOPROC 0xff00 /* reserved range for processor */ --#define ET_HIPROC 0xffff /* specific e_type */ -- --/* e_machine */ --#define EM_NONE 0 /* No Machine */ --#define EM_M32 1 /* AT&T WE 32100 */ --#define EM_SPARC 2 /* SPARC */ --#define EM_386 3 /* Intel 80386 */ --#define EM_68K 4 /* Motorola 68000 */ --#define EM_88K 5 /* Motorola 88000 */ --#define EM_486 6 /* Intel 80486 - unused? */ --#define EM_860 7 /* Intel 80860 */ --#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */ --/* -- * Don't know if EM_MIPS_RS4_BE, -- * EM_SPARC64, EM_PARISC, -- * or EM_PPC are ABI compliant -- */ --#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */ --#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */ --#define EM_PARISC 15 /* HPPA */ --#define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */ --#define EM_PPC 20 /* PowerPC */ --#define EM_PPC64 21 /* PowerPC 64-bit */ --#define EM_ARM 40 /* Advanced RISC Machines ARM */ --#define EM_ALPHA 41 /* DEC ALPHA */ --#define EM_SPARCV9 43 /* SPARC version 9 */ --#define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */ --#define EM_IA_64 50 /* Intel Merced */ --#define EM_X86_64 62 /* AMD x86-64 architecture */ --#define EM_VAX 75 /* DEC VAX */ -- --/* Version */ --#define EV_NONE 0 /* Invalid */ --#define EV_CURRENT 1 /* Current */ --#define EV_NUM 2 /* number of versions */ -- --/* Section Header */ --typedef struct { -- Elf32_Word sh_name; /* name - index into section header -- string table section */ -- Elf32_Word sh_type; /* type */ -- Elf32_Word sh_flags; /* flags */ -- Elf32_Addr sh_addr; /* address */ -- Elf32_Off sh_offset; /* file offset */ -- Elf32_Word sh_size; /* section size */ -- Elf32_Word sh_link; /* section header table index link */ -- Elf32_Word sh_info; /* extra information */ -- Elf32_Word sh_addralign; /* address alignment */ -- Elf32_Word sh_entsize; /* section entry size */ --} Elf32_Shdr; -- --typedef struct { -- Elf64_Half sh_name; /* section name */ -- Elf64_Half sh_type; /* section type */ -- Elf64_Xword sh_flags; /* section flags */ -- Elf64_Addr sh_addr; /* virtual address */ -- Elf64_Off sh_offset; /* file offset */ -- Elf64_Xword sh_size; /* section size */ -- Elf64_Half sh_link; /* link to another */ -- Elf64_Half sh_info; /* misc info */ -- Elf64_Xword sh_addralign; /* memory alignment */ -- Elf64_Xword sh_entsize; /* table entry size */ --} Elf64_Shdr; -- --/* Special Section Indexes */ --#define SHN_UNDEF 0 /* undefined */ --#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */ --#define SHN_LOPROC 0xff00 /* reserved range for processor */ --#define SHN_HIPROC 0xff1f /* specific section indexes */ --#define SHN_ABS 0xfff1 /* absolute value */ --#define SHN_COMMON 0xfff2 /* common symbol */ --#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */ -- --/* sh_type */ --#define SHT_NULL 0 /* inactive */ --#define SHT_PROGBITS 1 /* program defined information */ --#define SHT_SYMTAB 2 /* symbol table section */ --#define SHT_STRTAB 3 /* string table section */ --#define SHT_RELA 4 /* relocation section with addends*/ --#define SHT_HASH 5 /* symbol hash table section */ --#define SHT_DYNAMIC 6 /* dynamic section */ --#define SHT_NOTE 7 /* note section */ --#define SHT_NOBITS 8 /* no space section */ --#define SHT_REL 9 /* relation section without addends */ --#define SHT_SHLIB 10 /* reserved - purpose unknown */ --#define SHT_DYNSYM 11 /* dynamic symbol table section */ --#define SHT_NUM 12 /* number of section types */ --#define SHT_LOPROC 0x70000000 /* reserved range for processor */ --#define SHT_HIPROC 0x7fffffff /* specific section header types */ --#define SHT_LOUSER 0x80000000 /* reserved range for application */ --#define SHT_HIUSER 0xffffffff /* specific indexes */ -- --/* Section names */ --#define ELF_BSS ".bss" /* uninitialized data */ --#define ELF_DATA ".data" /* initialized data */ --#define ELF_DEBUG ".debug" /* debug */ --#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */ --#define ELF_DYNSTR ".dynstr" /* dynamic string table */ --#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */ --#define ELF_FINI ".fini" /* termination code */ --#define ELF_GOT ".got" /* global offset table */ --#define ELF_HASH ".hash" /* symbol hash table */ --#define ELF_INIT ".init" /* initialization code */ --#define ELF_REL_DATA ".rel.data" /* relocation data */ --#define ELF_REL_FINI ".rel.fini" /* relocation termination code */ --#define ELF_REL_INIT ".rel.init" /* relocation initialization code */ --#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */ --#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */ --#define ELF_REL_TEXT ".rel.text" /* relocation code */ --#define ELF_RODATA ".rodata" /* read-only data */ --#define ELF_SHSTRTAB ".shstrtab" /* section header string table */ --#define ELF_STRTAB ".strtab" /* string table */ --#define ELF_SYMTAB ".symtab" /* symbol table */ --#define ELF_TEXT ".text" /* code */ -- -- --/* Section Attribute Flags - sh_flags */ --#define SHF_WRITE 0x1 /* Writable */ --#define SHF_ALLOC 0x2 /* occupies memory */ --#define SHF_EXECINSTR 0x4 /* executable */ --#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ -- /* specific section attributes */ -- --/* Symbol Table Entry */ --typedef struct elf32_sym { -- Elf32_Word st_name; /* name - index into string table */ -- Elf32_Addr st_value; /* symbol value */ -- Elf32_Word st_size; /* symbol size */ -- unsigned char st_info; /* type and binding */ -- unsigned char st_other; /* 0 - no defined meaning */ -- Elf32_Half st_shndx; /* section header index */ --} Elf32_Sym; -- --typedef struct { -- Elf64_Half st_name; /* Symbol name index in str table */ -- Elf_Byte st_info; /* type / binding attrs */ -- Elf_Byte st_other; /* unused */ -- Elf64_Quarter st_shndx; /* section index of symbol */ -- Elf64_Xword st_value; /* value of symbol */ -- Elf64_Xword st_size; /* size of symbol */ --} Elf64_Sym; -- --/* Symbol table index */ --#define STN_UNDEF 0 /* undefined */ -- --/* Extract symbol info - st_info */ --#define ELF32_ST_BIND(x) ((x) >> 4) --#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) --#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -- --#define ELF64_ST_BIND(x) ((x) >> 4) --#define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf) --#define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf)) -- --/* Symbol Binding - ELF32_ST_BIND - st_info */ --#define STB_LOCAL 0 /* Local symbol */ --#define STB_GLOBAL 1 /* Global symbol */ --#define STB_WEAK 2 /* like global - lower precedence */ --#define STB_NUM 3 /* number of symbol bindings */ --#define STB_LOPROC 13 /* reserved range for processor */ --#define STB_HIPROC 15 /* specific symbol bindings */ -- --/* Symbol type - ELF32_ST_TYPE - st_info */ --#define STT_NOTYPE 0 /* not specified */ --#define STT_OBJECT 1 /* data object */ --#define STT_FUNC 2 /* function */ --#define STT_SECTION 3 /* section */ --#define STT_FILE 4 /* file */ --#define STT_NUM 5 /* number of symbol types */ --#define STT_LOPROC 13 /* reserved range for processor */ --#define STT_HIPROC 15 /* specific symbol types */ -- --/* Relocation entry with implicit addend */ --typedef struct { -- Elf32_Addr r_offset; /* offset of relocation */ -- Elf32_Word r_info; /* symbol table index and type */ --} Elf32_Rel; -- --/* Relocation entry with explicit addend */ --typedef struct { -- Elf32_Addr r_offset; /* offset of relocation */ -- Elf32_Word r_info; /* symbol table index and type */ -- Elf32_Sword r_addend; --} Elf32_Rela; -- --/* Extract relocation info - r_info */ --#define ELF32_R_SYM(i) ((i) >> 8) --#define ELF32_R_TYPE(i) ((unsigned char) (i)) --#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t)) -- --typedef struct { -- Elf64_Xword r_offset; /* where to do it */ -- Elf64_Xword r_info; /* index & type of relocation */ --} Elf64_Rel; -- --typedef struct { -- Elf64_Xword r_offset; /* where to do it */ -- Elf64_Xword r_info; /* index & type of relocation */ -- Elf64_Sxword r_addend; /* adjustment value */ --} Elf64_Rela; -- --#define ELF64_R_SYM(info) ((info) >> 32) --#define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF) --#define ELF64_R_INFO(s,t) (((s) << 32) + (u32)(t)) -- --/* Program Header */ --typedef struct { -- Elf32_Word p_type; /* segment type */ -- Elf32_Off p_offset; /* segment offset */ -- Elf32_Addr p_vaddr; /* virtual address of segment */ -- Elf32_Addr p_paddr; /* physical address - ignored? */ -- Elf32_Word p_filesz; /* number of bytes in file for seg. */ -- Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ -- Elf32_Word p_flags; /* flags */ -- Elf32_Word p_align; /* memory alignment */ --} Elf32_Phdr; -- --typedef struct { -- Elf64_Half p_type; /* entry type */ -- Elf64_Half p_flags; /* flags */ -- Elf64_Off p_offset; /* offset */ -- Elf64_Addr p_vaddr; /* virtual address */ -- Elf64_Addr p_paddr; /* physical address */ -- Elf64_Xword p_filesz; /* file size */ -- Elf64_Xword p_memsz; /* memory size */ -- Elf64_Xword p_align; /* memory & file alignment */ --} Elf64_Phdr; -- --/* Segment types - p_type */ --#define PT_NULL 0 /* unused */ --#define PT_LOAD 1 /* loadable segment */ --#define PT_DYNAMIC 2 /* dynamic linking section */ --#define PT_INTERP 3 /* the RTLD */ --#define PT_NOTE 4 /* auxiliary information */ --#define PT_SHLIB 5 /* reserved - purpose undefined */ --#define PT_PHDR 6 /* program header */ --#define PT_NUM 7 /* Number of segment types */ --#define PT_LOPROC 0x70000000 /* reserved range for processor */ --#define PT_HIPROC 0x7fffffff /* specific segment types */ -- --/* Segment flags - p_flags */ --#define PF_X 0x1 /* Executable */ --#define PF_W 0x2 /* Writable */ --#define PF_R 0x4 /* Readable */ --#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ -- /* specific segment flags */ -- --/* Dynamic structure */ --typedef struct { -- Elf32_Sword d_tag; /* controls meaning of d_val */ -- union { -- Elf32_Word d_val; /* Multiple meanings - see d_tag */ -- Elf32_Addr d_ptr; /* program virtual address */ -- } d_un; --} Elf32_Dyn; -- --typedef struct { -- Elf64_Xword d_tag; /* controls meaning of d_val */ -- union { -- Elf64_Addr d_ptr; -- Elf64_Xword d_val; -- } d_un; --} Elf64_Dyn; -- --/* Dynamic Array Tags - d_tag */ --#define DT_NULL 0 /* marks end of _DYNAMIC array */ --#define DT_NEEDED 1 /* string table offset of needed lib */ --#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */ --#define DT_PLTGOT 3 /* address PLT/GOT */ --#define DT_HASH 4 /* address of symbol hash table */ --#define DT_STRTAB 5 /* address of string table */ --#define DT_SYMTAB 6 /* address of symbol table */ --#define DT_RELA 7 /* address of relocation table */ --#define DT_RELASZ 8 /* size of relocation table */ --#define DT_RELAENT 9 /* size of relocation entry */ --#define DT_STRSZ 10 /* size of string table */ --#define DT_SYMENT 11 /* size of symbol table entry */ --#define DT_INIT 12 /* address of initialization func. */ --#define DT_FINI 13 /* address of termination function */ --#define DT_SONAME 14 /* string table offset of shared obj */ --#define DT_RPATH 15 /* string table offset of library -- search path */ --#define DT_SYMBOLIC 16 /* start sym search in shared obj. */ --#define DT_REL 17 /* address of rel. tbl. w addends */ --#define DT_RELSZ 18 /* size of DT_REL relocation table */ --#define DT_RELENT 19 /* size of DT_REL relocation entry */ --#define DT_PLTREL 20 /* PLT referenced relocation entry */ --#define DT_DEBUG 21 /* bugger */ --#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */ --#define DT_JMPREL 23 /* add. of PLT's relocation entries */ --#define DT_BIND_NOW 24 /* Bind now regardless of env setting */ --#define DT_NUM 25 /* Number used. */ --#define DT_LOPROC 0x70000000 /* reserved range for processor */ --#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */ -- --/* Standard ELF hashing function */ --unsigned int elf_hash(const unsigned char *name); -- --/* -- * Note Definitions -- */ -- --typedef struct { -- u32 namesz; -- u32 descsz; -- u32 type; --} Elf_Note; /* same format for both 32-bit and 64-bit ELF */ -- --#if defined(ELFSIZE) --#define CONCAT(x,y) __CONCAT(x,y) --#define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) --#define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) --#define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) --#define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) --#endif -- --#if defined(ELFSIZE) && (ELFSIZE == 32) --#define Elf_Ehdr Elf32_Ehdr --#define Elf_Phdr Elf32_Phdr --#define Elf_Shdr Elf32_Shdr --#define Elf_Sym Elf32_Sym --#define Elf_Rel Elf32_Rel --#define Elf_RelA Elf32_Rela --#define Elf_Dyn Elf32_Dyn --#define Elf_Word Elf32_Word --#define Elf_Sword Elf32_Sword --#define Elf_Addr Elf32_Addr --#define Elf_Off Elf32_Off --#define Elf_Nhdr Elf32_Nhdr -- --#define ELF_R_SYM ELF32_R_SYM --#define ELF_R_TYPE ELF32_R_TYPE --#define ELF_R_INFO ELF32_R_INFO --#define ELFCLASS ELFCLASS32 -- --#define ELF_ST_BIND ELF32_ST_BIND --#define ELF_ST_TYPE ELF32_ST_TYPE --#define ELF_ST_INFO ELF32_ST_INFO -- --#define AuxInfo Aux32Info --#elif defined(ELFSIZE) && (ELFSIZE == 64) --#define Elf_Ehdr Elf64_Ehdr --#define Elf_Phdr Elf64_Phdr --#define Elf_Shdr Elf64_Shdr --#define Elf_Sym Elf64_Sym --#define Elf_Rel Elf64_Rel --#define Elf_RelA Elf64_Rela --#define Elf_Dyn Elf64_Dyn --#define Elf_Word Elf64_Word --#define Elf_Sword Elf64_Sword --#define Elf_Addr Elf64_Addr --#define Elf_Off Elf64_Off --#define Elf_Nhdr Elf64_Nhdr -- --#define ELF_R_SYM ELF64_R_SYM --#define ELF_R_TYPE ELF64_R_TYPE --#define ELF_R_INFO ELF64_R_INFO --#define ELFCLASS ELFCLASS64 -- --#define ELF_ST_BIND ELF64_ST_BIND --#define ELF_ST_TYPE ELF64_ST_TYPE --#define ELF_ST_INFO ELF64_ST_INFO -- --#define AuxInfo Aux64Info --#endif -+#include - - struct domain_setup_info; - extern int loadelfimage(struct domain_setup_info *); -Index: build-32-release304-13132/xen/arch/x86/boot/mkelf32.c -=================================================================== ---- build-32-release304-13132.orig/xen/arch/x86/boot/mkelf32.c -+++ build-32-release304-13132/xen/arch/x86/boot/mkelf32.c -@@ -25,7 +25,7 @@ - #define s16 int16_t - #define s32 int32_t - #define s64 int64_t --#include "../../../include/xen/elf.h" -+#include "../../../include/public/elfstructs.h" - - #define DYNAMICALLY_FILLED 0 - #define RAW_OFFSET 128 diff --git a/libelf-dominfo.diff b/libelf-dominfo.diff deleted file mode 100644 index 718b21f..0000000 --- a/libelf-dominfo.diff +++ /dev/null @@ -1,15 +0,0 @@ -diff -r ad9bbd103034 xen/common/libelf/libelf-dominfo.c ---- a/xen/common/libelf/libelf-dominfo.c Fri Feb 09 18:19:24 2007 +0000 -+++ b/xen/common/libelf/libelf-dominfo.c Mon Feb 12 15:05:11 2007 +0100 -@@ -107,9 +107,9 @@ int elf_xen_parse_note(struct elf_binary - if ((type >= sizeof(note_desc) / sizeof(note_desc[0])) || - (NULL == note_desc[type].name)) - { -- elf_err(elf, "%s: unknown xen elf note (0x%x)\n", -+ elf_msg(elf, "%s: unknown xen elf note (0x%x)\n", - __FUNCTION__, type); -- return -1; -+ return 0; - } - - if (note_desc[type].str) diff --git a/libelf-symlink-to-libxc.diff b/libelf-symlink-to-libxc.diff deleted file mode 100644 index 0ccc5a8..0000000 --- a/libelf-symlink-to-libxc.diff +++ /dev/null @@ -1,36 +0,0 @@ -libelf: add to libxc - -This patch makes libelf available to the tools, by symlinking the source -files and compiling them into libxc. - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/Makefile | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -Index: build-32-unstable-12621/tools/libxc/Makefile -=================================================================== ---- build-32-unstable-12621.orig/tools/libxc/Makefile -+++ build-32-unstable-12621/tools/libxc/Makefile -@@ -29,6 +29,21 @@ GUEST_SRCS-$(CONFIG_IA64) += xc_linux_bu - GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c - GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c - -+# symlink libelf from xen/common/libelf/ -+LIBELF_SRCS := libelf-tools.c libelf-loader.c -+LIBELF_SRCS += libelf-dominfo.c libelf-relocate.c -+ -+libelf-tools.o: libelf-tools.c libelf-private.h -+libelf-loader.o: libelf-loader.c libelf-private.h -+libelf-dominfo.o: libelf-dominfo.c libelf-private.h -+libelf-relocate.o: libelf-relocate.c libelf-private.h -+ -+$(LIBELF_SRCS) libelf-private.h: -+ ln -s ../../xen/common/libelf/$@ $@ -+ -+# add libelf bits to libxc -+GUEST_SRCS-y += $(LIBELF_SRCS) -+ - -include $(XEN_TARGET_ARCH)/Makefile - - CFLAGS += -Werror -Wmissing-prototypes diff --git a/libelf-use-hvm-build.diff b/libelf-use-hvm-build.diff deleted file mode 100644 index a47a177..0000000 --- a/libelf-use-hvm-build.diff +++ /dev/null @@ -1,300 +0,0 @@ -libelf: use for hvm builder. - -This patch switches over the hvm domain builder to libelf -(for loading hvmloader). - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/xc_hvm_build.c | 220 +++++++++++++-------------------------------- - 1 file changed, 65 insertions(+), 155 deletions(-) - -Index: build-32-unstable-12802/tools/libxc/xc_hvm_build.c -=================================================================== ---- build-32-unstable-12802.orig/tools/libxc/xc_hvm_build.c -+++ build-32-unstable-12802/tools/libxc/xc_hvm_build.c -@@ -2,29 +2,22 @@ - * xc_hvm_build.c - */ - --#define ELFSIZE 32 - #include - #include --#include "xg_private.h" --#include "xc_private.h" --#include "xc_elf.h" - #include - #include - #include -+ -+#include "xg_private.h" -+#include "xc_private.h" -+ - #include - #include - #include - --#define SCRATCH_PFN 0xFFFFF -+#include - --#define HVM_LOADER_ENTR_ADDR 0x00100000 --static int --parseelfimage( -- char *elfbase, unsigned long elfsize, struct domain_setup_info *dsi); --static int --loadelfimage( -- char *elfbase, int xch, uint32_t dom, unsigned long *parray, -- struct domain_setup_info *dsi); -+#define SCRATCH_PFN 0xFFFFF - - int xc_set_hvm_param( - int handle, domid_t dom, int param, unsigned long value) -@@ -144,6 +137,48 @@ static void build_e820map(void *e820_pag - *(((unsigned char *)e820_page) + E820_MAP_NR_OFFSET) = nr_map; - } - -+static int -+loadelfimage(struct elf_binary *elf, int xch, uint32_t dom, unsigned long *parray) -+{ -+ privcmd_mmap_entry_t *entries = NULL; -+ int pages = (elf->pend - elf->pstart + PAGE_SIZE - 1) >> PAGE_SHIFT; -+ int i, rc = -1; -+ -+ /* map hvmloader address space */ -+ entries = malloc(pages * sizeof(privcmd_mmap_entry_t)); -+ if (NULL == entries) -+ goto err; -+ elf->dest = mmap(NULL, pages << PAGE_SHIFT, PROT_READ | PROT_WRITE, -+ MAP_SHARED, xch, 0); -+ if (MAP_FAILED == elf->dest) -+ goto err; -+ -+ for (i = 0; i < pages; i++) -+ { -+ entries[i].va = (uintptr_t)elf->dest + (i << PAGE_SHIFT); -+ entries[i].mfn = parray[(elf->pstart >> PAGE_SHIFT) + i]; -+ entries[i].npages = 1; -+ } -+ rc = xc_map_foreign_ranges(xch, dom, entries, pages); -+ if (rc < 0) -+ goto err; -+ -+ /* load hvmloader */ -+ elf_load_binary(elf); -+ rc = 0; -+ -+ err: -+ /* cleanup */ -+ if (elf->dest) { -+ munmap(elf->dest, pages << PAGE_SHIFT); -+ elf->dest = NULL; -+ } -+ if (entries) -+ free(entries); -+ -+ return rc; -+} -+ - static int setup_guest(int xc_handle, - uint32_t dom, int memsize, - char *image, unsigned long image_size, -@@ -155,35 +190,35 @@ static int setup_guest(int xc_handle, - struct xen_add_to_physmap xatp; - struct shared_info *shared_info; - void *e820_page; -- struct domain_setup_info dsi; -- uint64_t v_end; -+ struct elf_binary elf; -+ uint64_t v_start, v_end; - int rc; - -- memset(&dsi, 0, sizeof(struct domain_setup_info)); -- -- if ( (parseelfimage(image, image_size, &dsi)) != 0 ) -+ if (0 != elf_init(&elf, image, image_size)) - goto error_out; -+ elf_parse_binary(&elf); -+ v_start = 0; -+ v_end = (unsigned long long)memsize << 20; - -- if ( (dsi.v_kernstart & (PAGE_SIZE - 1)) != 0 ) -+ if ( (elf.pstart & (PAGE_SIZE - 1)) != 0 ) - { - PERROR("Guest OS must load to a page boundary.\n"); - goto error_out; - } - -- v_end = (unsigned long long)memsize << 20; -- - IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n" -- " Loaded HVM loader: %016"PRIx64"->%016"PRIx64"\n" -- " TOTAL: %016"PRIx64"->%016"PRIx64"\n", -- dsi.v_kernstart, dsi.v_kernend, -- dsi.v_start, v_end); -- IPRINTF(" ENTRY ADDRESS: %016"PRIx64"\n", dsi.v_kernentry); -+ " Loaded HVM loader: %016"PRIx64"->%016"PRIx64"\n" -+ " TOTAL: %016"PRIx64"->%016"PRIx64"\n" -+ " ENTRY ADDRESS: %016"PRIx64"\n", -+ elf.pstart, elf.pend, -+ v_start, v_end, -+ elf_uval(&elf, elf.ehdr, e_entry)); - -- if ( (v_end - dsi.v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) ) -+ if ( (v_end - v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) ) - { - PERROR("Initial guest OS requires too much space: " - "(%lluMB is greater than %lluMB limit)\n", -- (unsigned long long)(v_end - dsi.v_start) >> 20, -+ (unsigned long long)(v_end - v_start) >> 20, - ((unsigned long long)nr_pages << PAGE_SHIFT) >> 20); - goto error_out; - } -@@ -212,7 +247,7 @@ static int setup_guest(int xc_handle, - goto error_out; - } - -- loadelfimage(image, xc_handle, dom, page_array, &dsi); -+ loadelfimage(&elf, xc_handle, dom, page_array); - - if ( (e820_page = xc_map_foreign_range( - xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, -@@ -256,7 +291,7 @@ static int setup_guest(int xc_handle, - - free(page_array); - -- ctxt->user_regs.eip = dsi.v_kernentry; -+ ctxt->user_regs.eip = elf_uval(&elf, elf.ehdr, e_entry); - - return 0; - -@@ -315,131 +350,6 @@ static inline int is_loadable_phdr(Elf32 - ((phdr->p_flags & (PF_W|PF_X)) != 0)); - } - --static int parseelfimage(char *elfbase, -- unsigned long elfsize, -- struct domain_setup_info *dsi) --{ -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfbase; -- Elf32_Phdr *phdr; -- Elf32_Shdr *shdr; -- unsigned long kernstart = ~0UL, kernend=0UL; -- char *shstrtab; -- int h; -- -- if ( !IS_ELF(*ehdr) ) -- { -- xc_set_error(XC_INVALID_KERNEL, -- "Kernel image does not have an ELF header."); -- return -EINVAL; -- } -- -- if ( (ehdr->e_phoff + (ehdr->e_phnum * ehdr->e_phentsize)) > elfsize ) -- { -- xc_set_error(XC_INVALID_KERNEL, -- "ELF program headers extend beyond end of image."); -- return -EINVAL; -- } -- -- if ( (ehdr->e_shoff + (ehdr->e_shnum * ehdr->e_shentsize)) > elfsize ) -- { -- xc_set_error(XC_INVALID_KERNEL, -- "ELF section headers extend beyond end of image."); -- return -EINVAL; -- } -- -- /* Find the section-header strings table. */ -- if ( ehdr->e_shstrndx == SHN_UNDEF ) -- { -- xc_set_error(XC_INVALID_KERNEL, -- "ELF image has no section-header strings table (shstrtab)."); -- return -EINVAL; -- } -- shdr = (Elf32_Shdr *)(elfbase + ehdr->e_shoff + -- (ehdr->e_shstrndx*ehdr->e_shentsize)); -- shstrtab = elfbase + shdr->sh_offset; -- -- for ( h = 0; h < ehdr->e_phnum; h++ ) -- { -- phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize)); -- if ( !is_loadable_phdr(phdr) ) -- continue; -- if ( phdr->p_paddr < kernstart ) -- kernstart = phdr->p_paddr; -- if ( (phdr->p_paddr + phdr->p_memsz) > kernend ) -- kernend = phdr->p_paddr + phdr->p_memsz; -- } -- -- if ( (kernstart > kernend) || -- (ehdr->e_entry < kernstart) || -- (ehdr->e_entry > kernend) ) -- { -- xc_set_error(XC_INVALID_KERNEL, -- "Malformed ELF image."); -- return -EINVAL; -- } -- -- dsi->v_start = 0x00000000; -- -- dsi->v_kernstart = kernstart; -- dsi->v_kernend = kernend; -- dsi->v_kernentry = HVM_LOADER_ENTR_ADDR; -- -- dsi->v_end = dsi->v_kernend; -- -- return 0; --} -- --static int --loadelfimage( -- char *elfbase, int xch, uint32_t dom, unsigned long *parray, -- struct domain_setup_info *dsi) --{ -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)elfbase; -- Elf32_Phdr *phdr; -- int h; -- -- char *va; -- unsigned long pa, done, chunksz; -- -- for ( h = 0; h < ehdr->e_phnum; h++ ) -- { -- phdr = (Elf32_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize)); -- if ( !is_loadable_phdr(phdr) ) -- continue; -- -- for ( done = 0; done < phdr->p_filesz; done += chunksz ) -- { -- pa = (phdr->p_paddr + done) - dsi->v_start; -- if ((va = xc_map_foreign_range( -- xch, dom, PAGE_SIZE, PROT_WRITE, -- parray[pa >> PAGE_SHIFT])) == 0) -- return -1; -- chunksz = phdr->p_filesz - done; -- if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) ) -- chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1)); -- memcpy(va + (pa & (PAGE_SIZE-1)), -- elfbase + phdr->p_offset + done, chunksz); -- munmap(va, PAGE_SIZE); -- } -- -- for ( ; done < phdr->p_memsz; done += chunksz ) -- { -- pa = (phdr->p_paddr + done) - dsi->v_start; -- if ((va = xc_map_foreign_range( -- xch, dom, PAGE_SIZE, PROT_WRITE, -- parray[pa >> PAGE_SHIFT])) == 0) -- return -1; -- chunksz = phdr->p_memsz - done; -- if ( chunksz > (PAGE_SIZE - (pa & (PAGE_SIZE-1))) ) -- chunksz = PAGE_SIZE - (pa & (PAGE_SIZE-1)); -- memset(va + (pa & (PAGE_SIZE-1)), 0, chunksz); -- munmap(va, PAGE_SIZE); -- } -- } -- -- return 0; --} -- - /* xc_hvm_build - * - * Create a domain for a virtualized Linux, using files/filenames diff --git a/libelf-use-readnotes.diff b/libelf-use-readnotes.diff deleted file mode 100644 index 35c2715..0000000 --- a/libelf-use-readnotes.diff +++ /dev/null @@ -1,360 +0,0 @@ -libelf: use for readnotes utility. - -This patch makes the readnotes utility use libelf. - -Signed-off-by: Gerd Hoffmann ---- - tools/xcutils/readnotes.c | 277 +++++++--------------------------------------- - 1 file changed, 45 insertions(+), 232 deletions(-) - -Index: build-32-unstable-12621/tools/xcutils/readnotes.c -=================================================================== ---- build-32-unstable-12621.orig/tools/xcutils/readnotes.c -+++ build-32-unstable-12621/tools/xcutils/readnotes.c -@@ -1,4 +1,3 @@ --#include - #include - #include - #include -@@ -11,219 +10,35 @@ - #include - #include - --#include -- --#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_))) --#define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->n_namesz+3)&~3)) --#define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->n_descsz+3)&~3)) -- --#ifndef ELFSIZE --#include --#if UINT_MAX == ULONG_MAX --#define ELFSIZE 32 --#else --#define ELFSIZE 64 --#endif --#endif -- --#if (ELFSIZE == 32) --typedef Elf32_Nhdr Elf_Nhdr; --typedef Elf32_Half Elf_Half; --typedef Elf32_Word Elf_Word; --#elif (ELFSIZE == 64) --typedef Elf64_Nhdr Elf_Nhdr; --typedef Elf64_Half Elf_Half; --typedef Elf64_Word Elf_Word; --#else --#error "Unknown ELFSIZE" --#endif -- --static void print_string_note(const char *prefix, Elf_Nhdr *note) --{ -- printf("%s: %s\n", prefix, (const char *)ELFNOTE_DESC(note)); --} -- --static void print_numeric_note(const char *prefix,Elf_Nhdr *note) --{ -- switch (note->n_descsz) -- { -- case 4: -- printf("%s: %#010" PRIx32 " (4 bytes)\n", -- prefix, *(uint32_t *)ELFNOTE_DESC(note)); -- break; -- case 8: -- printf("%s: %#018" PRIx64 " (8 bytes)\n", -- prefix, *(uint64_t *)ELFNOTE_DESC(note)); -- break; -- default: -- printf("%s: unknown data size %#lx\n", prefix, -- (unsigned long)note->n_descsz); -- break; -- } --} -- --static inline int is_elf(void *image) --{ -- /* -- * Since we are only accessing the e_ident field we can -- * acccess the bytes directly without needing to figure out -- * which version of Elf*_Ehdr structure to use. -- */ -- const unsigned char *hdr = image; -- return ( hdr[EI_MAG0] == ELFMAG0 && -- hdr[EI_MAG1] == ELFMAG1 && -- hdr[EI_MAG2] == ELFMAG2 && -- hdr[EI_MAG3] == ELFMAG3 ); --} -- --static inline unsigned char ehdr_class(void *image) --{ -- /* -- * Since we are only accessing the e_ident field we can -- * acccess the bytes directly without needing to figure out -- * which version of Elf*_Ehdr structure to use. -- */ -- const unsigned char *hdr = image; -- switch (hdr[EI_CLASS]) -- { -- case ELFCLASS32: -- case ELFCLASS64: -- return hdr[EI_CLASS]; -- default: -- fprintf(stderr, "Unknown ELF class %d\n", hdr[EI_CLASS]); -- exit(1); -- } --} -+#include - --static inline Elf_Half ehdr_shnum(void *image) --{ -- switch (ehdr_class(image)) -- { -- case ELFCLASS32: -- return ((Elf32_Ehdr *)image)->e_shnum; -- case ELFCLASS64: -- return ((Elf64_Ehdr *)image)->e_shnum; -- default: -- exit(1); -- } --} -+#include - --static inline Elf_Word shdr_type(void *image, int shnum) -+static void print_string_note(const char *prefix, struct elf_binary *elf, -+ const elf_note *note) - { -- switch (ehdr_class(image)) -- { -- case ELFCLASS32: -- { -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image; -- Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return shdr->sh_type; -- } -- case ELFCLASS64: -- { -- Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image; -- Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return shdr->sh_type; -- } -- default: -- exit(1); -- } -+ printf("%s: %s\n", prefix, (char*)elf_note_desc(elf, note)); - } - --static inline const char *shdr_name(void *image, int shnum) --{ -- const char *shstrtab; -- -- switch (ehdr_class(image)) -- { -- case ELFCLASS32: -- { -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image; -- Elf32_Shdr *shdr; -- /* Find the section-header strings table. */ -- if ( ehdr->e_shstrndx == SHN_UNDEF ) -- return NULL; -- shdr = (Elf32_Shdr *)(image + ehdr->e_shoff + -- (ehdr->e_shstrndx*ehdr->e_shentsize)); -- shstrtab = image + shdr->sh_offset; -- -- shdr= (Elf32_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return &shstrtab[shdr->sh_name]; -- } -- case ELFCLASS64: -- { -- Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image; -- Elf64_Shdr *shdr; -- /* Find the section-header strings table. */ -- if ( ehdr->e_shstrndx == SHN_UNDEF ) -- return NULL; -- shdr = (Elf64_Shdr *)(image + ehdr->e_shoff + -- (ehdr->e_shstrndx*ehdr->e_shentsize)); -- shstrtab = image + shdr->sh_offset; -- -- shdr= (Elf64_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return &shstrtab[shdr->sh_name]; -- } -- default: -- exit(1); -- } --} --static inline void *shdr_start(void *image, int shnum) -+static void print_numeric_note(const char *prefix, struct elf_binary *elf, -+ const elf_note *note) - { -- switch (ehdr_class(image)) -- { -- case ELFCLASS32: -- { -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image; -- Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return image + shdr->sh_offset; -- } -- case ELFCLASS64: -- { -- Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image; -- Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return image + shdr->sh_offset; -- } -- default: -- exit(1); -- } --} -+ uint64_t value = elf_note_numeric(elf, note); -+ int descsz = elf_uval(elf, note, descsz); - --static inline void *shdr_end(void *image, int shnum) --{ -- switch (ehdr_class(image)) -- { -- case ELFCLASS32: -- { -- Elf32_Ehdr *ehdr = (Elf32_Ehdr *)image; -- Elf32_Shdr *shdr = (Elf32_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return image + shdr->sh_offset + shdr->sh_size; -- } -- case ELFCLASS64: -- { -- Elf64_Ehdr *ehdr = (Elf64_Ehdr *)image; -- Elf64_Shdr *shdr = (Elf64_Shdr*)(image + ehdr->e_shoff + -- (shnum*ehdr->e_shentsize)); -- return image + shdr->sh_offset + shdr->sh_size; -- } -- default: -- exit(1); -- } -+ printf("%s: %#*" PRIx64 " (%d bytes)\n", -+ prefix, 2+2*descsz, value, descsz); - } - - int main(int argc, char **argv) - { - const char *f; -- int fd,h; -+ int fd,h,size,count; - void *image; - struct stat st; -- Elf_Nhdr *note; -+ struct elf_binary elf; -+ const elf_shdr *shdr; -+ const elf_note *note, *end; - - if (argc != 2) - { -@@ -251,76 +66,74 @@ int main(int argc, char **argv) - fprintf(stderr, "Unable to map %s: %s\n", f, strerror(errno)); - return 1; - } -+ size = st.st_size; - -- if ( !is_elf(image) ) -+ if (0 != elf_init(&elf, image, size)) - { - fprintf(stderr, "File %s is not an ELF image\n", f); - return 1; - } -+ elf_set_logfile(&elf, stderr, 0); - -- for ( h=0; h < ehdr_shnum(image); h++) -+ count = elf_shdr_count(&elf); -+ for ( h=0; h < count; h++) - { -- if (shdr_type(image,h) != SHT_NOTE) -+ shdr = elf_shdr_by_index(&elf, h); -+ if (elf_uval(&elf, shdr, sh_type) != SHT_NOTE) - continue; -- for (note = (Elf_Nhdr*)shdr_start(image,h); -- note < (Elf_Nhdr*)shdr_end(image,h); -- note = (Elf_Nhdr*)(ELFNOTE_NEXT(note))) -+ end = elf_section_end(&elf, shdr); -+ for (note = elf_section_start(&elf, shdr); -+ note < end; -+ note = elf_note_next(&elf, note)) - { -- switch(note->n_type) -+ if (0 != strcmp(elf_note_name(&elf, note), "Xen")) -+ continue; -+ switch(elf_uval(&elf, note, type)) - { - case XEN_ELFNOTE_INFO: -- print_string_note("INFO", note); -+ print_string_note("INFO", &elf , note); - break; - case XEN_ELFNOTE_ENTRY: -- print_numeric_note("ENTRY", note); -+ print_numeric_note("ENTRY", &elf , note); - break; - case XEN_ELFNOTE_HYPERCALL_PAGE: -- print_numeric_note("HYPERCALL_PAGE", note); -+ print_numeric_note("HYPERCALL_PAGE", &elf , note); - break; - case XEN_ELFNOTE_VIRT_BASE: -- print_numeric_note("VIRT_BASE", note); -+ print_numeric_note("VIRT_BASE", &elf , note); - break; - case XEN_ELFNOTE_PADDR_OFFSET: -- print_numeric_note("PADDR_OFFSET", note); -+ print_numeric_note("PADDR_OFFSET", &elf , note); - break; - case XEN_ELFNOTE_XEN_VERSION: -- print_string_note("XEN_VERSION", note); -+ print_string_note("XEN_VERSION", &elf , note); - break; - case XEN_ELFNOTE_GUEST_OS: -- print_string_note("GUEST_OS", note); -+ print_string_note("GUEST_OS", &elf , note); - break; - case XEN_ELFNOTE_GUEST_VERSION: -- print_string_note("GUEST_VERSION", note); -+ print_string_note("GUEST_VERSION", &elf , note); - break; - case XEN_ELFNOTE_LOADER: -- print_string_note("LOADER", note); -+ print_string_note("LOADER", &elf , note); - break; - case XEN_ELFNOTE_PAE_MODE: -- print_string_note("PAE_MODE", note); -+ print_string_note("PAE_MODE", &elf , note); - break; - case XEN_ELFNOTE_FEATURES: -- print_string_note("FEATURES", note); -+ print_string_note("FEATURES", &elf , note); - break; - default: -- printf("unknown note type %#lx\n", -- (unsigned long)note->n_type); -+ printf("unknown note type %#x\n", -+ (int)elf_uval(&elf, note, type)); - break; - } - } - } - -- for ( h=0; h < ehdr_shnum(image); h++) -- { -- const char *name = shdr_name(image,h); -- -- if ( name == NULL ) -- continue; -- if ( strcmp(name, "__xen_guest") != 0 ) -- continue; -- -- printf("__xen_guest: %s\n", (const char *)shdr_start(image, h)); -- break; -- } -+ shdr = elf_shdr_by_name(&elf, "__xen_guest"); -+ if (shdr) -+ printf("__xen_guest: %s\n", (char*)elf_section_start(&elf, shdr)); - - return 0; - } diff --git a/libelf-use-xen-dom0.diff b/libelf-use-xen-dom0.diff deleted file mode 100644 index 48c3c91..0000000 --- a/libelf-use-xen-dom0.diff +++ /dev/null @@ -1,722 +0,0 @@ -libelf: use for x86 dom0 builder. - -This patch switches the x86 dom0 builder over to libelf. - -Signed-off-by: Gerd Hoffmann ---- - xen/arch/ia64/xen/domain.c | 79 +++++------ - xen/arch/x86/domain_build.c | 305 +++++++++++++++----------------------------- - xen/common/Makefile | 4 - 3 files changed, 149 insertions(+), 239 deletions(-) - -Index: build-32-release304-13131/xen/common/Makefile -=================================================================== ---- build-32-release304-13131.orig/xen/common/Makefile -+++ build-32-release304-13131/xen/common/Makefile -@@ -2,8 +2,8 @@ obj-y += acm_ops.o - obj-y += bitmap.o - obj-y += domctl.o - obj-y += domain.o --obj-y += elf.o --obj-$(CONFIG_COMPAT) += elf32.o -+#obj-y += elf.o -+#obj-$(CONFIG_COMPAT) += elf32.o - obj-y += event_channel.o - obj-y += grant_table.o - obj-y += kernel.o -Index: build-32-release304-13131/xen/arch/x86/domain_build.c -=================================================================== ---- build-32-release304-13131.orig/xen/arch/x86/domain_build.c -+++ build-32-release304-13131/xen/arch/x86/domain_build.c -@@ -13,7 +13,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -29,7 +28,7 @@ - #include - - #include --#include -+#include - - extern unsigned long initial_images_nrpages(void); - extern void discard_initial_images(void); -@@ -190,69 +189,12 @@ static void process_dom0_ioports_disable - } - } - --static const char *feature_names[XENFEAT_NR_SUBMAPS*32] = { -- [XENFEAT_writable_page_tables] = "writable_page_tables", -- [XENFEAT_writable_descriptor_tables] = "writable_descriptor_tables", -- [XENFEAT_auto_translated_physmap] = "auto_translated_physmap", -- [XENFEAT_supervisor_mode_kernel] = "supervisor_mode_kernel", -- [XENFEAT_pae_pgdir_above_4gb] = "pae_pgdir_above_4gb" --}; -- --static void parse_features( -- const char *feats, -- uint32_t supported[XENFEAT_NR_SUBMAPS], -- uint32_t required[XENFEAT_NR_SUBMAPS]) --{ -- const char *end, *p; -- int i, req; -- -- if ( (end = strchr(feats, ',')) == NULL ) -- end = feats + strlen(feats); -- -- while ( feats < end ) -- { -- p = strchr(feats, '|'); -- if ( (p == NULL) || (p > end) ) -- p = end; -- -- req = (*feats == '!'); -- if ( req ) -- feats++; -- -- for ( i = 0; i < XENFEAT_NR_SUBMAPS*32; i++ ) -- { -- if ( feature_names[i] == NULL ) -- continue; -- -- if ( strncmp(feature_names[i], feats, p-feats) == 0 ) -- { -- set_bit(i, supported); -- if ( req ) -- set_bit(i, required); -- break; -- } -- } -- -- if ( i == XENFEAT_NR_SUBMAPS*32 ) -- { -- printk("Unknown kernel feature \"%.*s\".\n", -- (int)(p-feats), feats); -- if ( req ) -- panic("Domain 0 requires an unknown hypervisor feature.\n"); -- } -- -- feats = p; -- if ( *feats == '|' ) -- feats++; -- } --} -- - int construct_dom0(struct domain *d, - unsigned long _image_start, unsigned long image_len, - unsigned long _initrd_start, unsigned long initrd_len, - char *cmdline) - { -- int i, rc, dom0_pae, xen_pae, order; -+ int i, rc, compatible, compat32, order, machine; - struct cpu_user_regs *regs; - unsigned long pfn, mfn; - unsigned long nr_pages; -@@ -263,9 +205,7 @@ int construct_dom0(struct domain *d, - struct page_info *page = NULL; - start_info_t *si; - struct vcpu *v = d->vcpu[0]; -- const char *p; - unsigned long long value; -- int value_defined; - #if defined(__i386__) - char *image_start = (char *)_image_start; /* use lowmem mappings */ - char *initrd_start = (char *)_initrd_start; /* use lowmem mappings */ -@@ -287,7 +227,10 @@ int construct_dom0(struct domain *d, - * *_start address are page-aligned, except v_start (and v_end) which are - * superpage-aligned. - */ -- struct domain_setup_info dsi; -+ struct elf_binary elf; -+ struct elf_dom_parms parms; -+ unsigned long vkern_start; -+ unsigned long vkern_end; - unsigned long vinitrd_start; - unsigned long vinitrd_end; - unsigned long vphysmap_start; -@@ -298,6 +241,7 @@ int construct_dom0(struct domain *d, - unsigned long vstack_end; - unsigned long vpt_start; - unsigned long vpt_end; -+ unsigned long v_start; - unsigned long v_end; - - /* Machine address of next candidate page-table page. */ -@@ -312,21 +256,71 @@ int construct_dom0(struct domain *d, - BUG_ON(d->vcpu[0] == NULL); - BUG_ON(test_bit(_VCPUF_initialised, &v->vcpu_flags)); - -- memset(&dsi, 0, sizeof(struct domain_setup_info)); -- dsi.image_addr = (unsigned long)image_start; -- dsi.image_len = image_len; -- - printk("*** LOADING DOMAIN 0 ***\n"); - - d->max_pages = ~0U; - - nr_pages = compute_dom0_nr_pages(); - -- rc = parseelfimage(&dsi); -+ if (0 != (rc = elf_init(&elf, image_start, image_len))) -+ return rc; -+#ifdef VERBOSE -+ elf_set_verbose(&elf); -+#endif -+ elf_parse_binary(&elf); -+ if (0 != (elf_xen_parse(&elf, &parms))) -+ return rc; -+ -+ /* compatibility check */ -+ compatible = 0; -+ compat32 = 0; -+ machine = elf_uval(&elf, elf.ehdr, e_machine); -+ switch (CONFIG_PAGING_LEVELS) { -+ case 2: /* x86_32 */ -+ if (parms.pae == PAEKERN_bimodal) -+ parms.pae = PAEKERN_no; -+ printk(" Xen kernel: 32-bit, lsb\n"); -+ if (elf_32bit(&elf) && !parms.pae && machine == EM_386) -+ compatible = 1; -+ break; -+ case 3: /* x86_32p */ -+ if (parms.pae == PAEKERN_bimodal) -+ parms.pae = PAEKERN_extended_cr3; -+ printk(" Xen kernel: 32-bit, PAE, lsb\n"); -+ if (elf_32bit(&elf) && parms.pae && machine == EM_386) -+ compatible = 1; -+ break; -+ case 4: /* x86_64 */ -+#ifndef CONFIG_COMPAT -+ printk(" Xen kernel: 64-bit, lsb\n"); -+#else -+ printk(" Xen kernel: 64-bit, lsb, compat32\n"); -+ if (elf_32bit(&elf) && parms.pae == PAEKERN_bimodal) -+ parms.pae = PAEKERN_extended_cr3; -+ if (elf_32bit(&elf) && parms.pae && machine == EM_386) -+ { -+ compat32 = 1; -+ compatible = 1; -+ } -+#endif -+ if (elf_64bit(&elf) && machine == EM_X86_64) -+ compatible = 1; -+ break; -+ } -+ printk(" Dom0 kernel: %s%s, %s, paddr 0x%" PRIx64 " -> 0x%" PRIx64 "\n", -+ elf_64bit(&elf) ? "64-bit" : "32-bit", -+ parms.pae ? ", PAE" : "", -+ elf_msb(&elf) ? "msb" : "lsb", -+ elf.pstart, elf.pend); -+ -+ if ( !compatible ) -+ { -+ printk("Mismatch between Xen and DOM0 kernel\n"); -+ return -EINVAL; -+ } -+ - #ifdef CONFIG_COMPAT -- if ( rc == -ENOSYS -- && !compat_disabled -- && (rc = parseelf32image(&dsi)) == 0 ) -+ if (compat32) - { - l1_pgentry_t gdt_l1e; - -@@ -348,42 +342,10 @@ int construct_dom0(struct domain *d, - local_flush_tlb_one(GDT_LDT_VIRT_START + FIRST_RESERVED_GDT_BYTE); - } - #endif -- if ( rc != 0) -- { -- if ( rc == -ENOSYS ) -- printk("DOM0 image is not a Xen-compatible Elf image.\n"); -- return rc; -- } -- -- xen_pae = (CONFIG_PAGING_LEVELS == 3) || IS_COMPAT(d); -- if (dsi.pae_kernel == PAEKERN_bimodal) -- dom0_pae = xen_pae; -- else -- dom0_pae = (dsi.pae_kernel != PAEKERN_no); -- if ( dom0_pae != xen_pae ) -- { -- printk("PAE mode mismatch between Xen and DOM0 (xen=%s, dom0=%s)\n", -- xen_pae ? "yes" : "no", dom0_pae ? "yes" : "no"); -- return -EINVAL; -- } -- -- if ( xen_pae && (dsi.pae_kernel == PAEKERN_extended_cr3 || -- dsi.pae_kernel == PAEKERN_bimodal) ) -+ if ( parms.pae == PAEKERN_extended_cr3 ) - set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist); - --#ifdef CONFIG_COMPAT -- if ( IS_COMPAT(d) ) -- { -- value = xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HV_START_LOW, &value_defined); -- p = xen_elf32note_string(&dsi, XEN_ELFNOTE_FEATURES); -- } -- else --#endif -- { -- value = xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HV_START_LOW, &value_defined); -- p = xen_elfnote_string(&dsi, XEN_ELFNOTE_FEATURES); -- } -- if ( value_defined ) -+ if ( UNSET_ADDR != parms.virt_hv_start_low && elf_32bit(&elf) ) - { - #if CONFIG_PAGING_LEVELS < 4 - unsigned long mask = (1UL << L2_PAGETABLE_SHIFT) - 1; -@@ -393,7 +355,7 @@ int construct_dom0(struct domain *d, - : (1UL << L2_PAGETABLE_SHIFT) - 1; - #endif - -- value = (value + mask) & ~mask; -+ value = (parms.virt_hv_start_low + mask) & ~mask; - #ifdef CONFIG_COMPAT - HYPERVISOR_COMPAT_VIRT_START(d) = max_t(unsigned int, m2p_compat_vstart, value); - d->pa_bitsize = fls((1UL << 32) - HYPERVISOR_COMPAT_VIRT_START(d)) - 1 -@@ -406,21 +368,12 @@ int construct_dom0(struct domain *d, - #endif - panic("Domain 0 expects too high a hypervisor start address.\n"); - } -- if ( p != NULL ) -- { -- parse_features(p, -- dom0_features_supported, -- dom0_features_required); -- printk("Domain 0 kernel supports features = { %08x }.\n", -- dom0_features_supported[0]); -- printk("Domain 0 kernel requires features = { %08x }.\n", -- dom0_features_required[0]); -- if ( dom0_features_required[0] ) -+ -+ if ( parms.f_required[0] /* Huh? -- kraxel */ ) - panic("Domain 0 requires an unsupported hypervisor feature.\n"); -- } - - /* Align load address to 4MB boundary. */ -- dsi.v_start &= ~((1UL<<22)-1); -+ v_start = parms.virt_base & ~((1UL<<22)-1); - - /* - * Why do we need this? The number of page-table frames depends on the -@@ -429,7 +382,9 @@ int construct_dom0(struct domain *d, - * read-only). We have a pair of simultaneous equations in two unknowns, - * which we solve by exhaustive search. - */ -- vinitrd_start = round_pgup(dsi.v_end); -+ vkern_start = parms.virt_kstart; -+ vkern_end = parms.virt_kend; -+ vinitrd_start = round_pgup(vkern_end); - vinitrd_end = vinitrd_start + initrd_len; - vphysmap_start = round_pgup(vinitrd_end); - vphysmap_end = vphysmap_start + (nr_pages * (!IS_COMPAT(d) ? -@@ -449,12 +404,12 @@ int construct_dom0(struct domain *d, - if ( (v_end - vstack_end) < (512UL << 10) ) - v_end += 1UL << 22; /* Add extra 4MB to get >= 512kB padding. */ - #if defined(__i386__) && !defined(CONFIG_X86_PAE) -- if ( (((v_end - dsi.v_start + ((1UL<> -+ if ( (((v_end - v_start + ((1UL<> - L2_PAGETABLE_SHIFT) + 1) <= nr_pt_pages ) - break; - #elif defined(__i386__) && defined(CONFIG_X86_PAE) - /* 5 pages: 1x 3rd + 4x 2nd level */ -- if ( (((v_end - dsi.v_start + ((1UL<> -+ if ( (((v_end - v_start + ((1UL<> - L2_PAGETABLE_SHIFT) + 5) <= nr_pt_pages ) - break; - #elif defined(__x86_64__) -@@ -462,24 +417,24 @@ int construct_dom0(struct domain *d, - (((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \ - ((_l) & ~((1UL<<(_s))-1))) >> (_s)) - if ( (1 + /* # L4 */ -- NR(dsi.v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */ -+ NR(v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */ - (!IS_COMPAT(d) ? -- NR(dsi.v_start, v_end, L3_PAGETABLE_SHIFT) : /* # L2 */ -+ NR(v_start, v_end, L3_PAGETABLE_SHIFT) : /* # L2 */ - 4) + /* # compat L2 */ -- NR(dsi.v_start, v_end, L2_PAGETABLE_SHIFT)) /* # L1 */ -+ NR(v_start, v_end, L2_PAGETABLE_SHIFT)) /* # L1 */ - <= nr_pt_pages ) - break; - #endif - } - -- order = get_order_from_bytes(v_end - dsi.v_start); -+ order = get_order_from_bytes(v_end - v_start); - if ( (1UL << order) > nr_pages ) - panic("Domain 0 allocation is too small for kernel image.\n"); - - #ifdef __i386__ - /* Ensure that our low-memory 1:1 mapping covers the allocation. */ - page = alloc_domheap_pages(d, order, -- MEMF_bits(30 + (dsi.v_start >> 31))); -+ MEMF_bits(30 + (v_start >> 31))); - #else - page = alloc_domheap_pages(d, order, 0); - #endif -@@ -502,24 +457,24 @@ int construct_dom0(struct domain *d, - " Page tables: %p->%p\n" - " Boot stack: %p->%p\n" - " TOTAL: %p->%p\n", -- _p(dsi.v_kernstart), _p(dsi.v_kernend), -+ _p(vkern_start), _p(vkern_end), - _p(vinitrd_start), _p(vinitrd_end), - _p(vphysmap_start), _p(vphysmap_end), - _p(vstartinfo_start), _p(vstartinfo_end), - _p(vpt_start), _p(vpt_end), - _p(vstack_start), _p(vstack_end), -- _p(dsi.v_start), _p(v_end)); -- printk(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry)); -+ _p(v_start), _p(v_end)); -+ printk(" ENTRY ADDRESS: %p\n", _p(parms.virt_entry)); - -- if ( ((v_end - dsi.v_start)>>PAGE_SHIFT) > nr_pages ) -+ if ( ((v_end - v_start)>>PAGE_SHIFT) > nr_pages ) - { - printk("Initial guest OS requires too much space\n" - "(%luMB is greater than %luMB limit)\n", -- (v_end-dsi.v_start)>>20, nr_pages>>(20-PAGE_SHIFT)); -+ (v_end-v_start)>>20, nr_pages>>(20-PAGE_SHIFT)); - return -ENOMEM; - } - -- mpt_alloc = (vpt_start - dsi.v_start) + -+ mpt_alloc = (vpt_start - v_start) + - (unsigned long)pfn_to_paddr(alloc_spfn); - - #if defined(__i386__) -@@ -527,7 +482,7 @@ int construct_dom0(struct domain *d, - * Protect the lowest 1GB of memory. We use a temporary mapping there - * from which we copy the kernel and ramdisk images. - */ -- if ( dsi.v_start < (1UL<<30) ) -+ if ( v_start < (1UL<<30) ) - { - printk("Initial loading isn't allowed to lowest 1GB of memory.\n"); - return -EINVAL; -@@ -557,9 +512,9 @@ int construct_dom0(struct domain *d, - l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt) + i, - __PAGE_HYPERVISOR); - -- l2tab += l2_linear_offset(dsi.v_start); -+ l2tab += l2_linear_offset(v_start); - mfn = alloc_spfn; -- for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ ) -+ for ( count = 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ ) - { - if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) - { -@@ -569,7 +524,7 @@ int construct_dom0(struct domain *d, - l2tab++; - clear_page(l1tab); - if ( count == 0 ) -- l1tab += l1_table_offset(dsi.v_start); -+ l1tab += l1_table_offset(v_start); - } - *l1tab = l1e_from_pfn(mfn, L1_PROT); - l1tab++; -@@ -659,7 +614,7 @@ int construct_dom0(struct domain *d, - - /* Overlap with Xen protected area? */ - if ( !IS_COMPAT(d) ? -- ((dsi.v_start < HYPERVISOR_VIRT_END) && -+ ((v_start < HYPERVISOR_VIRT_END) && - (v_end > HYPERVISOR_VIRT_START)) : - (v_end > HYPERVISOR_COMPAT_VIRT_START(d)) ) - { -@@ -699,9 +654,9 @@ int construct_dom0(struct domain *d, - panic("Not enough RAM for domain 0 hypercall argument translation.\n"); - } - -- l4tab += l4_table_offset(dsi.v_start); -+ l4tab += l4_table_offset(v_start); - mfn = alloc_spfn; -- for ( count = 0; count < ((v_end-dsi.v_start)>>PAGE_SHIFT); count++ ) -+ for ( count = 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ ) - { - if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) - { -@@ -709,14 +664,14 @@ int construct_dom0(struct domain *d, - l1start = l1tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; - clear_page(l1tab); - if ( count == 0 ) -- l1tab += l1_table_offset(dsi.v_start); -+ l1tab += l1_table_offset(v_start); - if ( !((unsigned long)l2tab & (PAGE_SIZE-1)) ) - { - maddr_to_page(mpt_alloc)->u.inuse.type_info = PGT_l2_page_table; - l2start = l2tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; - clear_page(l2tab); - if ( count == 0 ) -- l2tab += l2_table_offset(dsi.v_start); -+ l2tab += l2_table_offset(v_start); - if ( !((unsigned long)l3tab & (PAGE_SIZE-1)) ) - { - maddr_to_page(mpt_alloc)->u.inuse.type_info = -@@ -724,7 +679,7 @@ int construct_dom0(struct domain *d, - l3start = l3tab = __va(mpt_alloc); mpt_alloc += PAGE_SIZE; - clear_page(l3tab); - if ( count == 0 ) -- l3tab += l3_table_offset(dsi.v_start); -+ l3tab += l3_table_offset(v_start); - *l4tab = l4e_from_paddr(__pa(l3start), L4_PROT); - l4tab++; - } -@@ -837,30 +792,20 @@ int construct_dom0(struct domain *d, - write_ptbase(v); - - /* Copy the OS image and free temporary buffer. */ --#ifdef CONFIG_COMPAT -- if ( IS_COMPAT(d) ) -- { -- (void)loadelf32image(&dsi); -- value = -- xen_elf32note_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &value_defined); -- } -- else --#endif -- { -- (void)loadelfimage(&dsi); -- value = -- xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE, &value_defined); -- } -- if ( value_defined ) -+ elf.dest = (void*)vkern_start; -+ elf_load_binary(&elf); -+ -+ if ( UNSET_ADDR != parms.virt_hypercall ) - { -- if ( (value < dsi.v_start) || (value >= v_end) ) -+ if ( (parms.virt_hypercall < v_start) || -+ (parms.virt_hypercall >= v_end) ) - { - write_ptbase(current); - local_irq_enable(); - printk("Invalid HYPERCALL_PAGE field in ELF notes.\n"); - return -1; - } -- hypercall_page_initialise(d, (void *)(unsigned long)value); -+ hypercall_page_initialise(d, (void *)(unsigned long)parms.virt_hypercall); - } - - /* Copy the initial ramdisk. */ -@@ -883,14 +828,15 @@ int construct_dom0(struct domain *d, - si->mfn_list = vphysmap_start; - sprintf(si->magic, "xen-%i.%i-x86_%d%s", - xen_major_version(), xen_minor_version(), -- !IS_COMPAT(d) ? BITS_PER_LONG : 32, xen_pae ? "p" : ""); -+ elf_64bit(&elf) ? 64 : 32, -+ parms.pae ? "p" : ""); - - /* Write the phys->machine and machine->phys table entries. */ - for ( pfn = 0; pfn < d->tot_pages; pfn++ ) - { - mfn = pfn + alloc_spfn; - #ifndef NDEBUG --#define REVERSE_START ((v_end - dsi.v_start) >> PAGE_SHIFT) -+#define REVERSE_START ((v_end - v_start) >> PAGE_SHIFT) - if ( pfn > REVERSE_START ) - mfn = alloc_epfn - (pfn - REVERSE_START); - #endif -@@ -971,7 +917,7 @@ int construct_dom0(struct domain *d, - : FLAT_COMPAT_KERNEL_DS; - regs->ss = !IS_COMPAT(d) ? FLAT_KERNEL_SS : FLAT_COMPAT_KERNEL_SS; - regs->cs = !IS_COMPAT(d) ? FLAT_KERNEL_CS : FLAT_COMPAT_KERNEL_CS; -- regs->eip = dsi.v_kernentry; -+ regs->eip = parms.virt_entry; - regs->esp = vstack_end; - regs->esi = vstartinfo_start; - regs->eflags = X86_EFLAGS_IF; -@@ -1042,41 +988,6 @@ int construct_dom0(struct domain *d, - return 0; - } - --int elf_sanity_check(const Elf_Ehdr *ehdr) --{ -- if ( !IS_ELF(*ehdr) || --#if defined(__i386__) -- (ehdr->e_ident[EI_CLASS] != ELFCLASS32) || -- (ehdr->e_machine != EM_386) || --#elif defined(__x86_64__) -- (ehdr->e_ident[EI_CLASS] != ELFCLASS64) || -- (ehdr->e_machine != EM_X86_64) || --#endif -- (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) || -- (ehdr->e_type != ET_EXEC) ) -- { -- return 0; -- } -- -- return 1; --} -- --#ifdef CONFIG_COMPAT --int elf32_sanity_check(const Elf32_Ehdr *ehdr) --{ -- if ( !IS_ELF(*ehdr) || -- (ehdr->e_ident[EI_CLASS] != ELFCLASS32) || -- (ehdr->e_machine != EM_386) || -- (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) || -- (ehdr->e_type != ET_EXEC) ) -- { -- return 0; -- } -- -- return 1; --} --#endif -- - /* - * Local variables: - * mode: C -Index: build-32-release304-13131/xen/arch/ia64/xen/domain.c -=================================================================== ---- build-32-release304-13131.orig/xen/arch/ia64/xen/domain.c -+++ build-32-release304-13131/xen/arch/ia64/xen/domain.c -@@ -31,7 +31,7 @@ - #include - #include - #include --#include -+#include - #include - #include /* for IA64_THREAD_INFO_SIZE */ - #include /* for function declarations */ -@@ -866,38 +866,23 @@ int shadow_mode_control(struct domain *d - #define privify_memory(x,y) do {} while(0) - #endif - --// see arch/x86/xxx/domain_build.c --int elf_sanity_check(Elf_Ehdr *ehdr) --{ -- if (!(IS_ELF(*ehdr))) -- { -- printk("DOM0 image is not a Xen-compatible Elf image.\n"); -- return 0; -- } -- return 1; --} -- --static void loaddomainelfimage(struct domain *d, unsigned long image_start) -+static void loaddomainelfimage(struct domain *d, struct elf_binary *elf) - { -- char *elfbase = (char *) image_start; -- Elf_Ehdr ehdr; -- Elf_Phdr phdr; -- int h, filesz, memsz; -+ const elf_phdr *phdr; -+ int h, phnum, filesz, memsz; - unsigned long elfaddr, dom_mpaddr, dom_imva; - struct page_info *p; -- -- memcpy(&ehdr, (void *) image_start, sizeof(Elf_Ehdr)); -- for ( h = 0; h < ehdr.e_phnum; h++ ) { -- memcpy(&phdr, -- elfbase + ehdr.e_phoff + (h*ehdr.e_phentsize), -- sizeof(Elf_Phdr)); -- if ((phdr.p_type != PT_LOAD)) -+ -+ phnum = elf_uval(elf, elf->ehdr, e_phnum); -+ for ( h = 0; h < phnum; h++ ) { -+ phdr = elf_phdr_by_index(elf, h); -+ if (!elf_phdr_is_loadable(elf, phdr)) - continue; - -- filesz = phdr.p_filesz; -- memsz = phdr.p_memsz; -- elfaddr = (unsigned long) elfbase + phdr.p_offset; -- dom_mpaddr = phdr.p_paddr; -+ filesz = elf_uval(elf, phdr, p_filesz); -+ memsz = elf_uval(elf, phdr, p_memsz); -+ elfaddr = (unsigned long) elf->image + elf_uval(elf, phdr, p_offset); -+ dom_mpaddr = elf_uval(elf, phdr, p_paddr); - - while (memsz > 0) { - p = assign_new_domain_page(d,dom_mpaddr); -@@ -917,7 +902,7 @@ static void loaddomainelfimage(struct do - PAGE_SIZE-filesz); - } - //FIXME: This test for code seems to find a lot more than objdump -x does -- if (phdr.p_flags & PF_X) { -+ if (elf_uval(elf, phdr, p_flags) & PF_X) { - privify_memory(dom_imva,PAGE_SIZE); - flush_icache_range(dom_imva, - dom_imva+PAGE_SIZE); -@@ -980,7 +965,8 @@ int construct_dom0(struct domain *d, - struct vcpu *v = d->vcpu[0]; - unsigned long max_pages; - -- struct domain_setup_info dsi; -+ struct elf_binary elf; -+ struct elf_dom_parms parms; - unsigned long p_start; - unsigned long pkern_start; - unsigned long pkern_entry; -@@ -1004,18 +990,31 @@ int construct_dom0(struct domain *d, - BUG_ON(d->vcpu[0] == NULL); - BUG_ON(test_bit(_VCPUF_initialised, &v->vcpu_flags)); - -- memset(&dsi, 0, sizeof(struct domain_setup_info)); -- - printk("*** LOADING DOMAIN 0 ***\n"); - - max_pages = dom0_size / PAGE_SIZE; - d->max_pages = max_pages; - d->tot_pages = 0; -- dsi.image_addr = (unsigned long)image_start; -- dsi.image_len = image_len; -- rc = parseelfimage(&dsi); -+ -+ rc = elf_init(&elf, (void*)image_start, image_len); - if ( rc != 0 ) - return rc; -+#ifdef VERBOSE -+ elf_set_verbose(&elf); -+#endif -+ elf_parse_binary(&elf); -+ if (0 != (elf_xen_parse(&elf, &parms))) -+ return rc; -+ -+ printk(" Dom0 kernel: %s, %s, paddr 0x%" PRIx64 " -> 0x%" PRIx64 "\n", -+ elf_64bit(&elf) ? "64-bit" : "32-bit", -+ elf_msb(&elf) ? "msb" : "lsb", -+ elf.pstart, elf.pend); -+ if (!elf_64bit(&elf) || -+ elf_uval(&elf, elf.ehdr, e_machine) != EM_IA_64) { -+ printk("Incompatible kernel binary\n"); -+ return -1; -+ } - - #ifdef VALIDATE_VT - /* Temp workaround */ -@@ -1034,10 +1033,10 @@ int construct_dom0(struct domain *d, - } - #endif - -- p_start = dsi.v_start; -- pkern_start = dsi.v_kernstart; -- pkern_end = dsi.v_kernend; -- pkern_entry = dsi.v_kernentry; -+ p_start = parms.virt_base; -+ pkern_start = parms.virt_kstart; -+ pkern_end = parms.virt_kend; -+ pkern_entry = parms.virt_entry; - - //printk("p_start=%lx, pkern_start=%lx, pkern_end=%lx, pkern_entry=%lx\n",p_start,pkern_start,pkern_end,pkern_entry); - -@@ -1107,7 +1106,7 @@ int construct_dom0(struct domain *d, - printk ("Cannot allocate dom0 vcpu %d\n", i); - - /* Copy the OS image. */ -- loaddomainelfimage(d,image_start); -+ loaddomainelfimage(d,&elf); - - /* Copy the initial ramdisk. */ - //if ( initrd_len != 0 ) diff --git a/libxen_permissive.patch b/libxen_permissive.patch index 2b14ae7..d8cb151 100644 --- a/libxen_permissive.patch +++ b/libxen_permissive.patch @@ -1,7 +1,8 @@ -diff -ru xen-3.0.4-testing-orig/tools/libxen/src/xen_common.c xen-3.0.4-testing/tools/libxen/src/xen_common.c ---- xen-3.0.4-testing-orig/tools/libxen/src/xen_common.c 2007-02-07 16:15:33.000000000 -0700 -+++ xen-3.0.4-testing/tools/libxen/src/xen_common.c 2007-02-09 11:08:37.000000000 -0700 -@@ -634,8 +634,15 @@ +Index: xen-3.0.5-testing/tools/libxen/src/xen_common.c +=================================================================== +--- xen-3.0.5-testing.orig/tools/libxen/src/xen_common.c ++++ xen-3.0.5-testing/tools/libxen/src/xen_common.c +@@ -899,8 +899,15 @@ static void parse_into(xen_session *s, x 0 != strcmp((char *)value_node->children->name, "struct") || value_node->children->children == NULL) { @@ -17,4 +18,3 @@ diff -ru xen-3.0.4-testing-orig/tools/libxen/src/xen_common.c xen-3.0.4-testing/ } else { -Only in xen-3.0.4-testing/tools/libxen/src: xen_common.c~ diff --git a/mem-zones.patch b/mem-zones.patch deleted file mode 100644 index 69b39cc..0000000 --- a/mem-zones.patch +++ /dev/null @@ -1,244 +0,0 @@ -Index: xen-3.0.4-testing/xen/common/page_alloc.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/common/page_alloc.c -+++ xen-3.0.4-testing/xen/common/page_alloc.c -@@ -67,16 +67,18 @@ unsigned long max_dma_mfn = (1UL << (CON - static void parse_dma_bits(char *s) - { - unsigned int v = simple_strtol(s, NULL, 0); -- if ( v >= (sizeof(long)*8 + PAGE_SHIFT) ) -+ if ( v >= (BITS_PER_LONG + PAGE_SHIFT) ) - { -- dma_bitsize = sizeof(long)*8 + PAGE_SHIFT; -+ dma_bitsize = BITS_PER_LONG + PAGE_SHIFT; - max_dma_mfn = ~0UL; - } -- else -+ else if ( v > PAGE_SHIFT ) - { - dma_bitsize = v; - max_dma_mfn = (1UL << (dma_bitsize - PAGE_SHIFT)) - 1; - } -+ else -+ printk("Invalid dma_bits value of %u ignored.\n", v); - } - custom_param("dma_bits", parse_dma_bits); - -@@ -293,12 +295,13 @@ unsigned long alloc_boot_pages(unsigned - */ - - #define MEMZONE_XEN 0 --#define MEMZONE_DOM 1 --#define MEMZONE_DMADOM 2 --#define NR_ZONES 3 -+#ifdef PADDR_BITS -+#define NR_ZONES (PADDR_BITS - PAGE_SHIFT) -+#else -+#define NR_ZONES (BITS_PER_LONG - PAGE_SHIFT) -+#endif - --#define pfn_dom_zone_type(_pfn) \ -- (((_pfn) <= max_dma_mfn) ? MEMZONE_DMADOM : MEMZONE_DOM) -+#define pfn_dom_zone_type(_pfn) (fls(_pfn) - 1) - - static struct list_head heap[NR_ZONES][MAX_NUMNODES][MAX_ORDER+1]; - -@@ -308,15 +311,17 @@ static DEFINE_SPINLOCK(heap_lock); - - /* Allocate 2^@order contiguous pages. */ - static struct page_info *alloc_heap_pages( -- unsigned int zone, unsigned int cpu, unsigned int order) -+ unsigned int zone_lo, unsigned zone_hi, -+ unsigned int cpu, unsigned int order) - { - unsigned int i, j, node = cpu_to_node(cpu), num_nodes = num_online_nodes(); -- unsigned int request = (1UL << order); -+ unsigned int zone, request = (1UL << order); - struct page_info *pg; - - ASSERT(node >= 0); - ASSERT(node < num_nodes); -- ASSERT(zone < NR_ZONES); -+ ASSERT(zone_lo <= zone_hi); -+ ASSERT(zone_hi < NR_ZONES); - - if ( unlikely(order > MAX_ORDER) ) - return NULL; -@@ -329,14 +334,17 @@ static struct page_info *alloc_heap_page - * needless computation on fast-path */ - for ( i = 0; i < num_nodes; i++ ) - { -- /* check if target node can support the allocation */ -- if ( avail[zone][node] >= request ) -+ for ( zone = zone_hi; zone >= zone_lo; --zone ) - { -- /* Find smallest order which can satisfy the request. */ -- for ( j = order; j <= MAX_ORDER; j++ ) -+ /* check if target node can support the allocation */ -+ if ( avail[zone][node] >= request ) - { -- if ( !list_empty(&heap[zone][node][j]) ) -- goto found; -+ /* Find smallest order which can satisfy the request. */ -+ for ( j = order; j <= MAX_ORDER; j++ ) -+ { -+ if ( !list_empty(&heap[zone][node][j]) ) -+ goto found; -+ } - } - } - /* pick next node, wrapping around if needed */ -@@ -461,16 +469,17 @@ void init_heap_pages( - } - - static unsigned long avail_heap_pages( -- int zone, int node) -+ unsigned int zone_lo, unsigned int zone_hi, unsigned int node) - { -- unsigned int i, j, num_nodes = num_online_nodes(); -+ unsigned int i, zone, num_nodes = num_online_nodes(); - unsigned long free_pages = 0; - -- for (i=0; i= NR_ZONES ) -+ zone_hi = NR_ZONES - 1; -+ for ( zone = zone_lo; zone <= zone_hi; zone++ ) -+ for ( i = 0; i < num_nodes; i++ ) -+ if ( (node == -1) || (node == i) ) -+ free_pages += avail[zone][i]; - - return free_pages; - } -@@ -590,7 +599,7 @@ void *alloc_xenheap_pages(unsigned int o - int i; - - local_irq_save(flags); -- pg = alloc_heap_pages(MEMZONE_XEN, smp_processor_id(), order); -+ pg = alloc_heap_pages(MEMZONE_XEN, MEMZONE_XEN, smp_processor_id(), order); - local_irq_restore(flags); - - if ( unlikely(pg == NULL) ) -@@ -635,22 +644,26 @@ void free_xenheap_pages(void *v, unsigne - - void init_domheap_pages(paddr_t ps, paddr_t pe) - { -- unsigned long s_tot, e_tot, s_dma, e_dma, s_nrm, e_nrm; -+ unsigned long s_tot, e_tot; -+ unsigned int zone; - - ASSERT(!in_irq()); - - s_tot = round_pgup(ps) >> PAGE_SHIFT; - e_tot = round_pgdown(pe) >> PAGE_SHIFT; - -- s_dma = min(s_tot, max_dma_mfn + 1); -- e_dma = min(e_tot, max_dma_mfn + 1); -- if ( s_dma < e_dma ) -- init_heap_pages(MEMZONE_DMADOM, mfn_to_page(s_dma), e_dma - s_dma); -- -- s_nrm = max(s_tot, max_dma_mfn + 1); -- e_nrm = max(e_tot, max_dma_mfn + 1); -- if ( s_nrm < e_nrm ) -- init_heap_pages(MEMZONE_DOM, mfn_to_page(s_nrm), e_nrm - s_nrm); -+ zone = fls(s_tot); -+ BUG_ON(zone <= MEMZONE_XEN + 1); -+ for ( --zone; s_tot < e_tot; ++zone ) -+ { -+ unsigned long end = e_tot; -+ -+ BUILD_BUG_ON(NR_ZONES > BITS_PER_LONG); -+ if ( zone < BITS_PER_LONG - 1 && end > 1UL << (zone + 1) ) -+ end = 1UL << (zone + 1); -+ init_heap_pages(zone, mfn_to_page(s_tot), end - s_tot); -+ s_tot = end; -+ } - } - - -@@ -717,17 +730,21 @@ struct page_info *__alloc_domheap_pages( - - if ( !(memflags & MEMF_dma) ) - { -- pg = alloc_heap_pages(MEMZONE_DOM, cpu, order); -+ pg = alloc_heap_pages(dma_bitsize - PAGE_SHIFT, NR_ZONES - 1, cpu, order); - /* Failure? Then check if we can fall back to the DMA pool. */ - if ( unlikely(pg == NULL) && - ((order > MAX_ORDER) || -- (avail_heap_pages(MEMZONE_DMADOM,-1) < -+ (avail_heap_pages(MEMZONE_XEN + 1, -+ dma_bitsize - PAGE_SHIFT - 1, -+ -1) < - (dma_emergency_pool_pages + (1UL << order)))) ) - return NULL; - } - - if ( pg == NULL ) -- if ( (pg = alloc_heap_pages(MEMZONE_DMADOM, cpu, order)) == NULL ) -+ if ( (pg = alloc_heap_pages(MEMZONE_XEN + 1, -+ dma_bitsize - PAGE_SHIFT - 1, -+ cpu, order)) == NULL ) - return NULL; - - mask = pg->u.free.cpumask; -@@ -849,9 +866,14 @@ unsigned long avail_domheap_pages(void) - { - unsigned long avail_nrm, avail_dma; - -- avail_nrm = avail_heap_pages(MEMZONE_DOM,-1); -+ avail_nrm = avail_heap_pages(dma_bitsize - PAGE_SHIFT, -+ NR_ZONES - 1, -+ -1); -+ -+ avail_dma = avail_heap_pages(MEMZONE_XEN + 1, -+ dma_bitsize - PAGE_SHIFT - 1, -+ -1); - -- avail_dma = avail_heap_pages(MEMZONE_DMADOM,-1); - if ( avail_dma > dma_emergency_pool_pages ) - avail_dma -= dma_emergency_pool_pages; - else -@@ -862,18 +884,33 @@ unsigned long avail_domheap_pages(void) - - unsigned long avail_nodeheap_pages(int node) - { -- return avail_heap_pages(-1, node); -+ return avail_heap_pages(0, NR_ZONES - 1, node); - } - - static void pagealloc_keyhandler(unsigned char key) - { -+ unsigned int zone = MEMZONE_XEN; -+ unsigned long total = 0; -+ - printk("Physical memory information:\n"); -- printk(" Xen heap: %lukB free\n" -- " DMA heap: %lukB free\n" -- " Dom heap: %lukB free\n", -- avail_heap_pages(MEMZONE_XEN, -1) << (PAGE_SHIFT-10), -- avail_heap_pages(MEMZONE_DMADOM, -1) <<(PAGE_SHIFT-10), -- avail_heap_pages(MEMZONE_DOM, -1) <<(PAGE_SHIFT-10)); -+ printk(" Xen heap: %lukB free\n", -+ avail_heap_pages(zone, zone, -1) << (PAGE_SHIFT-10)); -+ -+ while ( ++zone < NR_ZONES ) -+ { -+ unsigned long n; -+ -+ if ( zone == dma_bitsize - PAGE_SHIFT ) -+ { -+ printk(" DMA heap: %lukB free\n", total << (PAGE_SHIFT-10)); -+ total = 0; -+ } -+ n = avail_heap_pages(zone, zone, -1); -+ total += n; -+ if ( n ) -+ printk(" heap[%02u]: %lukB free\n", zone, n << (PAGE_SHIFT-10)); -+ } -+ printk(" Dom heap: %lukB free\n", total << (PAGE_SHIFT-10)); - } - - diff --git a/microcode-xen-13079.diff b/microcode-xen-13079.diff deleted file mode 100644 index dabc285..0000000 --- a/microcode-xen-13079.diff +++ /dev/null @@ -1,61 +0,0 @@ -# HG changeset patch -# User Kurt Garloff -# Node ID b1752c878a7845d812c9b15e721f401d786394b2 -# Parent 469478194aef6e987f9281efbc0756749be6eb80 -Microcode does not need to have the default size of 2000+48 bytes. -A corresponding patch has gone into Linux 2.6.19; this is the -port to Xen. - -Signed-off-by: Kurt Garloff - -Reference: Patch to linux kernel from Sep 27 2006 -> # User Shaohua Li -> # Node ID 45898b908138b5d93c2cc7353f061ce54af145dc -> # Parent f962eab7b82c9bf1a6da69571046e764f5128395 -> [PATCH] x86 microcode: don't check the size -> -> IA32 manual says if micorcode update's size is 0, then the size is -> default size (2048 bytes). But this doesn't suggest all microcode -> update's size should be above 2048 bytes to me. We actually had a -> microcode update whose size is 1024 bytes. The patch just removed the -> check. -> -> Signed-off-by: Shaohua Li -> Cc: Tigran Aivazian -> Signed-off-by: Andrew Morton -> Signed-off-by: Linus Torvalds -> -> committer: Linus Torvalds 1159370778 -0700 - -diff -r 469478194aef -r b1752c878a78 xen/arch/x86/microcode.c ---- a/xen/arch/x86/microcode.c Mon Dec 18 00:14:40 2006 +0000 -+++ b/xen/arch/x86/microcode.c Sun Dec 24 17:06:23 2006 +0100 -@@ -249,14 +249,14 @@ static int find_matching_ucodes (void) - } - - total_size = get_totalsize(&mc_header); -- if ((cursor + total_size > user_buffer_size) || (total_size < DEFAULT_UCODE_TOTALSIZE)) { -+ if (cursor + total_size > user_buffer_size) { - printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); - error = -EINVAL; - goto out; - } - - data_size = get_datasize(&mc_header); -- if ((data_size + MC_HEADER_SIZE > total_size) || (data_size < DEFAULT_UCODE_DATASIZE)) { -+ if (data_size + MC_HEADER_SIZE > total_size) { - printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); - error = -EINVAL; - goto out; -@@ -459,11 +459,6 @@ int microcode_update(XEN_GUEST_HANDLE(vo - { - int ret; - -- if (len < DEFAULT_UCODE_TOTALSIZE) { -- printk(KERN_ERR "microcode: not enough data\n"); -- return -EINVAL; -- } -- - if (len != (typeof(user_buffer_size))len) { - printk(KERN_ERR "microcode: too much data\n"); - return -E2BIG; diff --git a/network-multi_bridge b/network-multi_bridge new file mode 100644 index 0000000..a248c79 --- /dev/null +++ b/network-multi_bridge @@ -0,0 +1,337 @@ +#!/bin/bash +#============================================================================ +# network-multi_bridge +# +# Version = 2.0.1 +# Date = 2007-03-09 +# +# Maintainer(s) = Ron Terry - ron (at) pronetworkconsulting (dot) com +# +# The latest version can be found at: +# +# http://pronetworkconsulting.com/linux/scripts/network-multi_bridge.html +# +# Description: +# +# Extension to and wrapper for the xen network-bridge script that allows for +# the creation of multiple bridges. +# +# This script can create 3 types of bridges: +# +# traditional bridges: -Bridges that contain both a physical network +# device (ethX) and a virtual network device (vethX) +# from Dom0. +# -This is the traditional type of network bridge +# created in xen by the network-bridge script. +# +# host bridges: -Bridgees that contain only a virtual network +# device (vethX) from Dom0. +# -This is similar to a VMware "Host Only" network. +# +# empty bridges: -Bridges that do not contain any physical or +# virtual network devices from Dom0. +# -These can be used to allow VMs in DomUs to +# communicate only with other DomUs and not Dom0. +# +# This script accepts the (start|stop|status) parameters and passes +# them to the network-bridge script for each physical interface +# specified in the NETDEV_LIST variable. This will allow the user +# to disassemble the traditional bridges containg physical network +# devices so that they may change the network configuration of the +# Physical network interfaces. If not specified it sends the start +# parameter. +# +# Host bridges do not need to be disassembled to change the IP address +# of the virtual interfaces because they do not contain interfaces that +# have been renamed like the traditional briges created by the +# network-bridge script do. The stop parameter does however cause them +# to be disassembled and removed. +# +# The Empty bridges do not contain interfaces from Dom0 so are not +# affected by IP address changes. The stop parameter does cause them +# to be removed as well. +# +# This script will test for the presence of the physical interfaces +# configured to be connected to traditional bridges and only attempt to +# create bridges on the ones that are present and up. It will also test +# for the presence of virtual interfaces configured to be connected to +# host bridges and only create bridges for the ones that exist and +# are not already connected to an existing bridge. +# +# Edit the NETDEV_LIST variable to define which physical interfaces +# you wish to create bridges on. The default is the first 3 network +# interfaces (eth0 eth1 eth2). +# +# Edit the HOST_BRIDGE_LIST variable to define which virtual interfaces +# you wish to create host bridges on. The defaule is the 3rd virtual +# interface (veth3) +# +# Edit the EMPTY_BRIDGE_LIST variable to define which empty bridges to +# create. This list should contain the numbers of the bridges to +# create (4 5 6 7) +# +# To enable this script edit the network-script field in the +# /etc/xen/xen-config.sxp file. +# +# Example: (network-script network-multi_bridge) +# +# Depends on: /etc/xen/scripts/xen-network-common.sh +# /etc/xen/scripts/network-bridge +# +# Can use: /etc/sysconfig/dom0config +# +# Usage: network-multi_bridge (start|stop|status) +# +# Vars: +# +# NETDEV_LIST -Space delimited list of physical network devices to +# create traditional bridges on +# +# HOST_BRIDGE_LIST -Space delimited list of virtual network devices to +# create host bridges on using the following format: +# +# ,, +# +# Example with 2 virtual devices: +# +# "veth1,00:16:3E:01:00:01,172.16.0.1/16 veth2,00:16:3E:01:00:02,172.17.0.1/16" +# +# EMPTY_BRIDGE_LIST -Space delimited list of bridge numbers to create as +# empty bridges. +# +# BRIDGE_NAME -Name of bridge to create (example: xenbr) +# +# SCRIPT_PATH -Path to the directory conaining the xen network-bridge +# script (typically /etc/xen/scripts) +# +#============================================================================ + +#### Read config files and set variables ################################## + +. /etc/xen/scripts/xen-network-common.sh + +# If you source the /etc/sysconfig/dom0config file comment out the variables +# being set in this script. + +#. /etc/sysconfig/dom0config + +NETDEV_LIST="eth0 eth1 eth2" +HOST_BRIDGE_LIST="veth3,00:16:3E:01:00:03,172.16.0.1/16" +EMPTY_BRIDGE_LIST="4 5 6 7" +BRIDGE_NAME="xenbr" +SCRIPT_PATH="/etc/xen/scripts" + +#### Script Fuinctions #################################################### + +get_option() { +# Determine which option was passed from the command line. +# If nothing is passed it defaults to start + if [ -z "$1" ] + then + CMD_OPT="start" + else + case "$1" in + start|stop|status) + CMD_OPT="$1" + ;; + *) + CMD_OPT="start" + ;; + esac + fi +} + +setup_host_interface() { +# Configure the MAC and IP address of a virtual device. +# +# This function is called by other fuctions. +# +# usage: setup_host_interface + + local DEV="$1" + local MAC="$2" + local IPADDR="$3" + + case $CMD_OPT in + start) + # take the interface down + ip link set $DEV down + + # ... and configure it + ip link set $DEV addr $MAC + ip addr flush $DEV + ip addr add $IPADDR brd + dev $DEV + + # bring it back up + ip link set $DEV up + ;; + stop) + # take the interface down + ip link set $DEV down + + # unconfigure it + ip link set $DEV addr fe:ff:ff:ff:ff:ff + ip addr flush $DEV + ;; + status) + ip addr show $DEV + ;; + esac +} + +create_bridges() { +# Uses the network-bridge script to create bridges on physical devices in Dom0. +# +# This fuction passes the start,stop,status parameters on to the network-bridge +# script. + + for NETDEVICE in $NETDEV_LIST + do + local BRIDGE_NUM=${NETDEVICE##${NETDEVICE%%[0-9]*}} + + if /sbin/ip address show $NETDEVICE | grep -q UP + then + echo "" + echo "============================================================" + echo "Configuring Virtual Bridge: $BRIDGE_NAME$BRIDGE_NUM" + echo "using- Physical Interface: $NETDEVICE" + echo " Virtual Interface: vif$BRIDGE_NUM" + echo "============================================================" + echo "" + $SCRIPT_PATH/network-bridge $CMD_OPT netdev=$NETDEVICE bridge=$BRIDGE_NAME$BRIDGE_NUM vifnum=$BRIDGE_NUM + echo "" + echo "------------------------------------------------------------" + else + echo " Physical Interface $NETDEVICE is not up. Skipping $BRIDGE_NAME$BRIDGE_NUM" + echo "------------------------------------------------------------" + fi + done +} + + +create_host_bridges() { +# Creates bridges attached to virtual devices in Dom0. +# +# This fuction reads the start,stop,status parameter from the $CMD_OPT variable +# and responds respectively. + + for HOSTDEVICE in $HOST_BRIDGE_LIST + do + + local DEV=`echo $HOSTDEVICE|cut -d "," -f 1` + local MAC=`echo $HOSTDEVICE|cut -d "," -f 2` + local IPADDR=`echo $HOSTDEVICE|cut -d "," -f 3` + local BRIDGE_NUM=`echo $DEV|cut -c 5` + local VIF=vif0.$BRIDGE_NUM + local BR_NAME=$BRIDGE_NAME$BRIDGE_NUM + + case $CMD_OPT in + start) + if ! brctl show | grep -q $DEV && /sbin/ip address show $DEV + then + echo "" + echo "============================================================" + echo "Configuring Virtual Host Bridge: $BR_NAME" + echo " using- Virtual Interface: $VIF" + echo " Virtual Device: $DEV" + echo "============================================================" + + create_bridge $BR_NAME + setup_bridge_port $VIF + add_to_bridge $BR_NAME $VIF + setup_host_interface $DEV $MAC $IPADDR + + echo "------------------------------------------------------------" + else + echo " Virtual Interface $DEV is already attached to a bridge or it does not exist." + echo " Skipping $BR_NAME" + echo "------------------------------------------------------------" + fi + ;; + stop) + echo "" + echo "============================================================" + echo "Unconfiguring Virtual Host Bridge: $BR_NAME" + echo " using- Virtual Interface: $VIF" + echo " Virtual Device: $DEV" + echo "============================================================" + + # unconfigure the veth + setup_host_interface $DEV $MAC $IPADDR + + # remove vif from the bridge + brctl delif $BR_NAME $VIF + + # unconfigure the vif + ip link set $VIF down + ip link set $VIF addr fe:ff:ff:ff:ff:ff + ip link set $VIF multicast on + ip link set $VIF arp on + ip addr flush $VIF + + # unconfigure the bridge + ip link set $BR_NAME down + brctl delbr $BR_NAME + + echo "------------------------------------------------------------" + ;; + status) + echo "" + echo "============================================================" + echo "Status of Virtual Host Bridge: $BR_NAME" + echo " using- Virtual Interface: $VIF" + echo " Virtual Device: $DEV" + echo "============================================================" + brctl show | grep -w "^$BR_NAME" + echo "" + ip addr show $DEV + echo "============================================================" + ;; + esac + done +} + +create_empty_bridges() { +# Creates bridges attached to no devices in Dom0. +# +# This function reads the start,stop,status parameter from the $CMD_OPT +# variable and respondes respectively. + + echo "" + echo "============================================================" + for BRIDGE in $EMPTY_BRIDGE_LIST + do + + local BRIDGE_NUM=$BRIDGE + local BR_NAME=$BRIDGE_NAME$BRIDGE_NUM + + case $CMD_OPT in + start) + if ! brctl show | grep -qw "^$BR_NAME" + then + echo "Configuring Virtual Empty Bridge: $BR_NAME" + create_bridge $BR_NAME + fi + ;; + stop) + if brctl show | grep -qw "^$BR_NAME" + then + echo "Unconfiguring Virtual Empty Bridge: $BR_NAME" + ip link set $BR_NAME down + brctl delbr $BR_NAME + fi + ;; + status) + brctl show $BR_NAME | grep -w "^$BR_NAME" + ;; + esac + done + echo "============================================================" +} + +#### Call Functions ####################################################### + +get_option "$1" +create_bridges +create_host_bridges +create_empty_bridges diff --git a/npt-fpu-bug.patch b/npt-fpu-bug.patch deleted file mode 100644 index b877320..0000000 --- a/npt-fpu-bug.patch +++ /dev/null @@ -1,28 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/svm/svm.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -@@ -1745,6 +1745,13 @@ int npt_mov_to_cr(int gpreg, int cr, str - case 0: - vmcb->cr0 = value; - v->arch.hvm_svm.cpu_shadow_cr0 = value; -+ -+ /* TS cleared? Then initialise FPU now. */ -+ if ( !(value & X86_CR0_TS) ) { -+ setup_fpu(v); -+ vmcb->exception_intercepts &= ~EXCEPTION_BITMAP_NM; -+ } -+ - npt_update_guest_paging_mode(v); - break; - case 3: -@@ -1755,8 +1762,8 @@ int npt_mov_to_cr(int gpreg, int cr, str - case 4: /* CR4 */ - vmcb->cr4 = value; - v->arch.hvm_svm.cpu_shadow_cr4 = value; -- npt_update_guest_paging_mode(v); - set_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags); -+ npt_update_guest_paging_mode(v); - break; - case 8: - vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4)); diff --git a/npt-windows-bug.patch b/npt-windows-bug.patch deleted file mode 100644 index dc3c872..0000000 --- a/npt-windows-bug.patch +++ /dev/null @@ -1,302 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domain.c -+++ xen-3.0.4-testing/xen/arch/x86/domain.c -@@ -41,6 +41,7 @@ - #include - #include - #include -+#include - #ifdef CONFIG_COMPAT - #include - #endif -@@ -334,6 +335,8 @@ int vcpu_initialise(struct vcpu *v) - - pae_l3_cache_init(&v->arch.pae_l3_cache); - -+ hap_vcpu_init(v); -+ - /* This should move to arch_domain_create(). */ - if ( !is_idle_domain(d) && (v->vcpu_id == 0) ) - pit_init(v, cpu_khz); -@@ -470,6 +473,9 @@ void arch_domain_destroy(struct domain * - hvm_domain_destroy(d); - } - -+ for_each_vcpu ( d, v ) -+ hap_vcpu_destroy(v); -+ - shadow_final_teardown(d); - - free_xenheap_pages( -Index: xen-3.0.4-testing/xen/arch/x86/hvm/hvm.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/hvm.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/hvm.c -@@ -49,6 +49,7 @@ - #include - #include - #include -+#include - - int hvm_enabled = 0; - -@@ -339,7 +340,7 @@ static int __hvm_copy(void *buf, paddr_t - count = min_t(int, PAGE_SIZE - (addr & ~PAGE_MASK), todo); - - if ( virt ) -- mfn = get_mfn_from_gpfn(shadow_gva_to_gfn(current, addr)); -+ mfn = get_mfn_from_gpfn(hap_gva_to_gfn(current, addr)); - else - mfn = get_mfn_from_gpfn(addr >> PAGE_SHIFT); - -Index: xen-3.0.4-testing/xen/arch/x86/hvm/platform.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/platform.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/platform.c -@@ -37,6 +37,7 @@ - #include - #include - #include -+#include - - #define DECODE_success 1 - #define DECODE_failure 0 -@@ -793,7 +794,7 @@ void send_pio_req(unsigned long port, un - if ( value_is_ptr ) /* get physical address of data */ - { - if ( hvm_paging_enabled(current) ) -- p->data = shadow_gva_to_gpa(current, value); -+ p->data = hap_gva_to_gpa(current, value); - else - p->data = value; /* guest VA == guest PA */ - } -@@ -849,7 +850,7 @@ static void send_mmio_req(unsigned char - if ( value_is_ptr ) - { - if ( hvm_paging_enabled(v) ) -- p->data = shadow_gva_to_gpa(v, value); -+ p->data = hap_gva_to_gpa(v, value); - else - p->data = value; /* guest VA == guest PA */ - } -@@ -965,7 +966,7 @@ void handle_mmio(unsigned long gpa) - if ( ad_size == WORD ) - addr &= 0xFFFF; - addr += hvm_get_segment_base(v, x86_seg_es); -- if ( shadow_gva_to_gpa(v, addr) == gpa ) -+ if ( hap_gva_to_gpa(v, addr) == gpa ) - { - enum x86_segment seg; - -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/hap.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/mm/hap/hap.c -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/hap.c -@@ -18,7 +18,21 @@ - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - --#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include - - /* initialize hardware assisted paging. It checks whether hap option is enabled - * in Xen boot option. -@@ -26,6 +40,20 @@ - int opt_hap_enabled = 0; - boolean_param("hap", opt_hap_enabled); - -+/*************************************************/ -+/* hap functions */ -+/*************************************************/ -+void hap_vcpu_init(struct vcpu *v) -+{ -+ v->arch.hap_activated = 0; /* not activated at the beginning */ -+} -+ -+void hap_vcpu_destroy(struct vcpu *v) -+{ -+ /* nothing to do */ -+} -+ -+ - /* - * Local variables: - * mode: C -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/npt.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/mm/hap/npt/npt.c -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/npt.c -@@ -34,6 +34,49 @@ - #include "page-guest32.h" - - extern int opt_hap_enabled; -+ -+/* Forward Declaration */ -+static paddr_t npt_gva_to_gpa_real_mode(struct vcpu *v, unsigned long gva); -+static paddr_t npt_gva_to_gpa_protected_mode(struct vcpu *v, -+ unsigned long gva); -+static paddr_t npt_gva_to_gpa_pae_mode(struct vcpu *v, unsigned long gva); -+static paddr_t npt_gva_to_gpa_long_mode(struct vcpu *v, unsigned long gva); -+static unsigned long npt_gva_to_gfn_real_mode(struct vcpu *v, -+ unsigned long gva); -+static unsigned long npt_gva_to_gfn_protected_mode(struct vcpu *v, -+ unsigned long gva); -+static unsigned long npt_gva_to_gfn_pae_mode(struct vcpu *v, -+ unsigned long gva); -+static unsigned long npt_gva_to_gfn_long_mode(struct vcpu *v, -+ unsigned long gva); -+ -+/*******************************************/ -+/* global variables */ -+/*******************************************/ -+struct hap_vcpu NPT_REAL_MODE_HANDLER = { -+ .guest_page_level = 1, -+ .gva_to_gfn = npt_gva_to_gfn_real_mode, -+ .gva_to_gpa = npt_gva_to_gpa_real_mode -+}; -+ -+struct hap_vcpu NPT_PROTECTED_MODE_HANDLER = { -+ .guest_page_level = 2, -+ .gva_to_gfn = npt_gva_to_gfn_protected_mode, -+ .gva_to_gpa = npt_gva_to_gpa_protected_mode -+}; -+ -+struct hap_vcpu NPT_PAE_MODE_HANDLER = { -+ .guest_page_level = 3, -+ .gva_to_gfn = npt_gva_to_gfn_pae_mode, -+ .gva_to_gpa = npt_gva_to_gpa_pae_mode -+}; -+ -+struct hap_vcpu NPT_LONG_MODE_HANDLER = { -+ .guest_page_level = 4, -+ .gva_to_gfn = npt_gva_to_gfn_long_mode, -+ .gva_to_gpa = npt_gva_to_gpa_long_mode -+}; -+ - /*******************************************/ - /* Platform Specific Functions */ - /*******************************************/ -@@ -350,7 +393,9 @@ void npt_detect(void) - - /* check CPUID for nested paging support */ - cpuid(0x8000000A, &eax, &ebx, &ecx, &edx); -- if ( !(edx & 0x01) && opt_hap_enabled ) { -+ if ( edx & 0x01 ) { -+ } -+ else if ( opt_hap_enabled ) { - printk(" nested paging is not supported by this CPU.\n"); - opt_hap_enabled = 0; /* no nested paging, we disable op_hap_enabled */ - } -@@ -366,23 +411,19 @@ void npt_set_guest_paging_levels(struct - switch(levels) { - case 1: - NPT_PRINTK("Install real mode guest with ID = %d\n", v->vcpu_id); -- v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_real_mode; -- v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_real_mode; -+ v->arch.hap_mode = &NPT_REAL_MODE_HANDLER; - break; - case 2: - NPT_PRINTK("Install 32-bit non-PAE guest with ID = %d\n", v->vcpu_id); -- v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_protected_mode; -- v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_protected_mode; -+ v->arch.hap_mode = &NPT_PROTECTED_MODE_HANDLER; - break; - case 3: - NPT_PRINTK("Install 32-bit PAE guest with ID = %d\n", v->vcpu_id); -- v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_pae_mode; -- v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_pae_mode; -+ v->arch.hap_mode = &NPT_PAE_MODE_HANDLER; - break; - case 4: - NPT_PRINTK("Install 64-bit guest with ID = %d\n", v->vcpu_id); -- v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_long_mode; -- v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_long_mode; -+ v->arch.hap_mode = &NPT_LONG_MODE_HANDLER; - break; - default: - printk("Un-supported guest paging level: %d\n", levels); -Index: xen-3.0.4-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/domain.h -+++ xen-3.0.4-testing/xen/include/asm-x86/domain.h -@@ -208,8 +208,8 @@ struct arch_vcpu - unsigned long shadow_ldt_mapcnt; - - struct shadow_vcpu shadow; -- -- unsigned int hap_activated:1; /* hardware assisted paging */ -+ struct hap_vcpu *hap_mode; /* hardware assisted paging support */ -+ unsigned int hap_activated:1; - } __cacheline_aligned; - - /* shorthands to improve code legibility */ -Index: xen-3.0.4-testing/xen/include/asm-x86/hap.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/hap.h -+++ xen-3.0.4-testing/xen/include/asm-x86/hap.h -@@ -26,6 +26,25 @@ - #include - #include - -+/************************************************/ -+/* HAP data structure */ -+/************************************************/ -+struct hap_vcpu { -+ int guest_page_level; -+ -+ /* function pointers */ -+ int (*host_pgfault )(struct vcpu *v, unsigned long va, -+ struct cpu_user_regs *regs); -+ unsigned long (*gva_to_gfn )(struct vcpu *v, unsigned long gva); -+ paddr_t (*gva_to_gpa )(struct vcpu *v, unsigned long gva); -+}; -+ -+/************************************************/ -+/* HAP interface to Xen */ -+/************************************************/ -+void hap_vcpu_init(struct vcpu *v); -+void hap_vcpu_destroy(struct vcpu *v); -+ - static inline unsigned int hap_is_activated(struct vcpu *v) - { - return v->arch.hap_activated; -@@ -41,6 +60,24 @@ static inline void hap_deactivate(struct - v->arch.hap_activated = 0; - } - -+static inline paddr_t hap_gva_to_gpa(struct vcpu *v, unsigned long gva) -+{ -+ if ( v->arch.hap_activated ) -+ return v->arch.hap_mode->gva_to_gpa(v, gva); -+ else -+ return shadow_gva_to_gpa(v, gva); -+} -+ -+static inline unsigned long hap_gva_to_gfn(struct vcpu *v, unsigned long gva) -+{ -+ if ( v->arch.hap_activated ) -+ return v->arch.hap_mode->gva_to_gfn(v, gva); -+ else -+ return shadow_gva_to_gfn(v, gva); -+} -+/************************************************/ -+/* nested paging interface */ -+/************************************************/ - void npt_update_guest_paging_mode(struct vcpu *v); - void npt_detect(void); - #endif diff --git a/npt_part1.patch b/npt_part1.patch deleted file mode 100644 index e59ac12..0000000 --- a/npt_part1.patch +++ /dev/null @@ -1,1096 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/svm/svm.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -@@ -30,6 +30,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -53,7 +54,7 @@ - __asm__ __volatile__ ( "movw %%ax ,%%" STR(name) "" : : "a" (value) ) - - /* External functions. We should move these to some suitable header file(s) */ -- -+extern int opt_hap_enabled; - extern int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip, - int inst_len); - extern asmlinkage void do_IRQ(struct cpu_user_regs *); -@@ -800,6 +801,8 @@ static int svm_vcpu_initialise(struct vc - - v->arch.hvm_svm.saved_irq_vector = -1; - -+ hap_deactivate(v); -+ - if ( (rc = svm_create_vmcb(v)) != 0 ) - { - dprintk(XENLOG_WARNING, -@@ -814,6 +817,7 @@ static int svm_vcpu_initialise(struct vc - static void svm_vcpu_destroy(struct vcpu *v) - { - svm_destroy_vmcb(v); -+ hap_deactivate(v); - } - - static void svm_hvm_inject_exception( -@@ -856,6 +860,7 @@ int start_svm(void) - asidpool_init( cpu ); - printk("AMD SVM Extension is enabled for cpu %d.\n", cpu ); - -+ npt_detect(); - /* Initialize the HSA for this core */ - phys_hsa = (u64) virt_to_maddr(hsa[cpu]); - phys_hsa_lo = (u32) phys_hsa; -@@ -1705,6 +1710,120 @@ static inline int svm_pgbit_test(struct - return v->arch.hvm_svm.cpu_shadow_cr0 & X86_CR0_PG; - } - -+/************************************************/ -+/* nested paging functions */ -+/************************************************/ -+void npt_activate(struct vcpu *v) -+{ -+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -+ struct domain *d = v->domain; -+ -+ vmcb->h_cr3 = pagetable_get_paddr(d->arch.phys_table); -+ /* use guest's CR register values */ -+ vmcb->cr0 = v->arch.hvm_svm.cpu_shadow_cr0; -+ vmcb->cr3 = v->arch.hvm_svm.cpu_cr3; -+ vmcb->cr4 = v->arch.hvm_svm.cpu_shadow_cr4; -+ vmcb->np_enable = 1; /* enable nested paging */ -+ vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */ -+ vmcb->exception_intercepts &= ~EXCEPTION_BITMAP_PG; -+ npt_update_guest_paging_mode(v); -+ hap_activate(v); -+} -+ -+int npt_mov_to_cr(int gpreg, int cr, struct cpu_user_regs *regs) -+{ -+ unsigned long value; -+ struct vcpu *v = current; -+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -+ struct vlapic *vlapic = vcpu_vlapic(v); -+ -+ ASSERT(vmcb); -+ -+ value = get_reg(gpreg, regs, vmcb); -+ -+ switch (cr) { -+ case 0: -+ vmcb->cr0 = value; -+ v->arch.hvm_svm.cpu_shadow_cr0 = value; -+ npt_update_guest_paging_mode(v); -+ break; -+ case 3: -+ vmcb->cr3 = value; -+ v->arch.hvm_svm.cpu_cr3 = value; -+ set_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags); -+ break; -+ case 4: /* CR4 */ -+ vmcb->cr4 = value; -+ v->arch.hvm_svm.cpu_shadow_cr4 = value; -+ npt_update_guest_paging_mode(v); -+ set_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags); -+ break; -+ case 8: -+ vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4)); -+ break; -+ default: -+ gdprintk(XENLOG_ERR, "invalid cr: %d\n", cr); -+ domain_crash(v->domain); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+void npt_mov_from_cr(int cr, int gp, struct cpu_user_regs *regs) -+{ -+ unsigned long value = 0; -+ struct vcpu *v = current; -+ struct vmcb_struct *vmcb; -+ struct vlapic *vlapic = vcpu_vlapic(v); -+ -+ vmcb = v->arch.hvm_svm.vmcb; -+ ASSERT(vmcb); -+ -+ switch(cr) -+ { -+ case 0: -+ value = vmcb->cr0; -+ break; -+ case 2: -+ value = vmcb->cr2; -+ break; -+ case 3: -+ value = vmcb->cr3; -+ break; -+ case 4: -+ value = vmcb->cr4; -+ break; -+ case 8: -+ value = (unsigned long)vlapic_get_reg(vlapic, APIC_TASKPRI); -+ value = (value & 0xF0) >> 4; -+ break; -+ default: -+ domain_crash(v->domain); -+ return; -+ } -+ -+ set_reg(gp, value, regs, vmcb); -+} -+ -+int npt_do_nested_page_fault(unsigned long va, struct cpu_user_regs *regs) -+{ -+ struct vcpu *v = current; -+ unsigned long gpa = va; -+ int result = 1; -+ -+ if (mmio_space(gpa)) { -+ handle_mmio(gpa); -+ return 1; -+ } -+ -+ /* P2M table should have been constructed at the beginning */ -+ domain_crash(v->domain); -+ return result; -+} -+/*************************************************/ -+/* end of nested paging functions */ -+/*************************************************/ - - /* - * Write to control registers -@@ -1905,12 +2024,21 @@ static int svm_cr_access(struct vcpu *v, - { - case INSTR_MOV2CR: - gpreg = decode_src_reg(prefix, buffer[index+2]); -- result = mov_to_cr(gpreg, cr, regs); -+ if ( hap_is_activated(v) ) -+ result = npt_mov_to_cr(gpreg, cr, regs); -+ else { -+ result = mov_to_cr(gpreg, cr, regs); -+ if ( opt_hap_enabled && svm_paging_enabled(v) ) -+ npt_activate(v); -+ } - break; - - case INSTR_MOVCR2: - gpreg = decode_src_reg(prefix, buffer[index+2]); -- mov_from_cr(cr, gpreg, regs); -+ if ( hap_is_activated(v) ) -+ npt_mov_from_cr(cr, gpreg, regs); -+ else -+ mov_from_cr(cr, gpreg, regs); - break; - - case INSTR_CLTS: -@@ -2897,6 +3025,19 @@ asmlinkage void svm_vmexit_handler(struc - svm_do_msr_access(v, regs); - break; - -+ case VMEXIT_NPF: -+ { -+ unsigned long gpa; -+ -+ gpa = vmcb->exitinfo2; -+ regs->error_code = vmcb->exitinfo1; -+ -+ if (!(error = npt_do_nested_page_fault(gpa, regs))) -+ domain_crash(v->domain); -+ -+ break; -+ } -+ - case VMEXIT_SHUTDOWN: - gdprintk(XENLOG_ERR, "Guest shutdown exit\n"); - goto exit_and_crash; -Index: xen-3.0.4-testing/xen/arch/x86/mm/Makefile -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/mm/Makefile -+++ xen-3.0.4-testing/xen/arch/x86/mm/Makefile -@@ -1 +1,2 @@ - subdir-y += shadow -+subdir-y += hap -Index: xen-3.0.4-testing/xen/include/asm-x86/domain.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/domain.h -+++ xen-3.0.4-testing/xen/include/asm-x86/domain.h -@@ -206,6 +206,8 @@ struct arch_vcpu - unsigned long shadow_ldt_mapcnt; - - struct shadow_vcpu shadow; -+ -+ unsigned int hap_activated:1; /* hardware assisted paging */ - } __cacheline_aligned; - - /* shorthands to improve code legibility */ -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/Makefile -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/Makefile -@@ -0,0 +1,3 @@ -+subdir-y += npt -+ -+obj-y += hap.o -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/hap.c -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/hap.c -@@ -0,0 +1,36 @@ -+/****************************************************************************** -+ * arch/x86/mm/hap/hap.c -+ * -+ * hardware assisted paging support -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#include -+ -+/* initialize hardware assisted paging. It checks whether hap option is enabled -+ * in Xen boot option. -+ */ -+int opt_hap_enabled = 0; -+boolean_param("hap", opt_hap_enabled); -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/Makefile -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/Makefile -@@ -0,0 +1 @@ -+obj-y += npt.o -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/npt.c -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/npt.c -@@ -0,0 +1,464 @@ -+/* -+ * npt.c: AMD SVM nested paging implementation for Xen -+ * -+ * Copyright (c) 2006, AMD Corporation (Wei Huang) -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms and conditions of the GNU General Public License, -+ * version 2, as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ * You should have received a copy of the GNU General Public License along with -+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple -+ * Place - Suite 330, Boston, MA 02111-1307 USA. -+ * -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "private.h" -+#include "page-guest32.h" -+ -+extern int opt_hap_enabled; -+/*******************************************/ -+/* Platform Specific Functions */ -+/*******************************************/ -+ -+/* Translate guest virtual address to guest physical address. Specifically -+ * for real mode guest. -+ */ -+ -+static paddr_t npt_gva_to_gpa_real_mode(struct vcpu *v, unsigned long gva) -+{ -+ HERE_I_AM; -+ return (paddr_t)gva; -+} -+ -+/* Translate guest virtual address to guest physical address. Specifically -+ * for 2-level guest. -+ */ -+static paddr_t npt_gva_to_gpa_protected_mode(struct vcpu *v, unsigned long gva) -+{ -+ unsigned long gcr3 = hvm_get_guest_ctrl_reg(v, 3); -+ int mode = 2; /* two-level guest */ -+ int lev, index; -+ paddr_t gpa = 0; -+ unsigned long gpfn, mfn; -+ int result = 1; -+ l2_pgentry_32_t *l2e; /* guest page entry size is 32-bit */ -+ l1_pgentry_32_t *l1e; -+ -+ HERE_I_AM; -+ -+ gpfn = (gcr3 >> PAGE_SHIFT); -+ for ( lev = mode; lev >= 1; lev-- ) { -+ mfn = get_mfn_from_gpfn( gpfn ); -+ if ( mfn == INVALID_MFN ) { -+ NPT_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, -+ lev); -+ result = 0; -+ break; -+ } -+ index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1); -+ -+ if ( lev == 2 ) { -+ l2e = map_domain_page( mfn ); -+ NPT_PRINTK("l2 page table entry is %ulx at index = %d\n", -+ l2e[index].l2, index); -+ if ( !(l2e_get_flags_32(l2e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 2 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ -+ if ( l2e_get_flags_32(l2e[index]) & _PAGE_PSE ) { /* handle PSE */ -+ NPT_PRINTK("guest page table is PSE\n"); -+ if ( l2e_get_intpte(l2e[index]) & 0x001FE000UL ) { /*[13:20] */ -+ printk("guest physical memory size is too large!\n"); -+ domain_crash(v->domain); -+ } -+ gpa = (l2e_get_intpte(l2e[index]) & PHYSICAL_PAGE_4M_MASK) + -+ (gva & ~PHYSICAL_PAGE_4M_MASK); -+ unmap_domain_page(l2e); -+ break; /* last level page table, return from here */ -+ } -+ else { -+ gpfn = l2e_get_pfn( l2e[index] ); -+ } -+ unmap_domain_page(l2e); -+ } -+ -+ if ( lev == 1 ) { -+ l1e = map_domain_page( mfn ); -+ NPT_PRINTK("l1 page table entry is %ulx at index = %d\n", -+ l1e[index].l1, index); -+ if ( !(l1e_get_flags_32(l1e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 1 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l1e_get_pfn( l1e[index] ); -+ gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_PAGE_4K_MASK) + -+ (gva & ~PHYSICAL_PAGE_4K_MASK); -+ unmap_domain_page(l1e); -+ } -+ -+ if ( result != 1 ) /* error happened, jump out */ -+ break; -+ } -+ -+ NPT_PRINTK("result = %d, gva = %lx, gpa = %lx\n", result, gva, gpa); -+ return (paddr_t)gpa; -+} -+ -+/* Translate guest virtual address to guest physical address. Specifically -+ * for 3-level guest. -+ */ -+#if CONFIG_PAGING_LEVELS >= 3 -+static paddr_t npt_gva_to_gpa_pae_mode(struct vcpu *v, unsigned long gva) -+{ -+ unsigned long gcr3 = hvm_get_guest_ctrl_reg(v, 3); -+ int mode = 3; /* three-level guest */ -+ int lev, index; -+ paddr_t gpa = 0; -+ unsigned long gpfn, mfn; -+ int result = 1; -+ l1_pgentry_t *l1e; -+ l2_pgentry_t *l2e; -+ l3_pgentry_t *l3e; -+ -+ HERE_I_AM; -+ -+ NPT_PRINTK("npt_gva_to_gpa:mode = %d, gcr3 = 0x%lx, gva = 0x%lx, " -+ "entry size = %ld\n", mode, gcr3, gva, sizeof(*l3e)); -+ gpfn = (gcr3 >> PAGE_SHIFT); -+ for ( lev = mode; lev >= 1; lev-- ) { -+ mfn = get_mfn_from_gpfn( gpfn ); -+ if ( mfn == INVALID_MFN ) { -+ NPT_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, -+ lev); -+ result = 0; -+ break; -+ } -+ index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1); -+ -+ if ( lev == 3 ) { -+ l3e = map_domain_page( mfn ); -+ index += ( ((gcr3 >> 5 ) & 127 ) * 4 ); -+ if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 3 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l3e_get_pfn( l3e[index] ); -+ unmap_domain_page(l3e); -+ } -+ -+ if ( lev == 2 ) { -+ l2e = map_domain_page( mfn ); -+ if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 2 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ -+ if ( l2e_get_flags(l2e[index]) & _PAGE_PSE ) { /* handle PSE */ -+ NPT_PRINTK("guest page table is PSE\n"); -+ gpa = (l2e_get_intpte(l2e[index]) & PHYSICAL_PAGE_2M_MASK) + -+ (gva & ~PHYSICAL_PAGE_2M_MASK); -+ unmap_domain_page(l2e); -+ break; /* last level page table, jump out from here */ -+ } -+ else { -+ gpfn = l2e_get_pfn(l2e[index]); -+ } -+ unmap_domain_page(l2e); -+ } -+ -+ if ( lev == 1 ) { -+ l1e = map_domain_page( mfn ); -+ if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 1 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l1e_get_pfn( l1e[index] ); -+ gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_PAGE_4K_MASK) + -+ (gva & ~PHYSICAL_PAGE_4K_MASK); -+ unmap_domain_page(l1e); -+ } -+ -+ if ( result != 1 ) /* error happened, jump out */ -+ break; -+ } -+ -+ gpa &= ~PAGE_NX_BIT; /* clear NX bit of guest physical address */ -+ NPT_PRINTK("result = %d, gva = %lx, gpa = %lx\n", result, gva, gpa); -+ return (paddr_t)gpa; -+} -+#else -+static paddr_t npt_gva_to_gpa_pae_mode(struct vcpu *v, unsigned long gva) -+{ -+ HERE_I_AM; -+ printk("guest paging level (3) is greater than host paging level!\n"); -+ domain_crash(v->domain); -+ return 0UL; -+} -+#endif -+ -+/* Translate guest virtual address to guest physical address. Specifically -+ * for 4-level guest. -+ */ -+#if CONFIG_PAGING_LEVELS == 4 -+static paddr_t npt_gva_to_gpa_long_mode(struct vcpu *v, unsigned long gva) -+{ -+ unsigned long gcr3 = hvm_get_guest_ctrl_reg(v, 3); -+ int mode = 4; /* four-level guest */ -+ int lev, index; -+ paddr_t gpa = 0; -+ unsigned long gpfn, mfn; -+ int result = 1; -+ l4_pgentry_t *l4e; -+ l3_pgentry_t *l3e; -+ l2_pgentry_t *l2e; -+ l1_pgentry_t *l1e; -+ -+ HERE_I_AM; -+ -+ NPT_PRINTK("npt_gva_to_gpa:mode = %d, gcr3 = 0x%lx, gva = 0x%lx, " -+ "entry size is = %ld\n", mode, gcr3, gva, sizeof(*l4e)); -+ gpfn = (gcr3 >> PAGE_SHIFT); -+ for ( lev = mode; lev >= 1; lev-- ) { -+ mfn = get_mfn_from_gpfn( gpfn ); -+ if ( mfn == INVALID_MFN ) { -+ NPT_PRINTK("bad pfn=0x%lx from gva=0x%lx at lev%d\n", gpfn, gva, -+ lev); -+ result = 0; -+ break; -+ } -+ index = (gva >> PT_SHIFT[mode][lev]) & (PT_ENTRIES[mode][lev]-1); -+ -+ if ( lev == 4 ) { -+ l4e = map_domain_page( mfn ); -+ if ( !(l4e_get_flags(l4e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 4 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l4e_get_pfn( l4e[index] ); -+ unmap_domain_page(l4e); -+ } -+ -+ if ( lev == 3 ) { -+ l3e = map_domain_page( mfn ); -+ if ( !(l3e_get_flags(l3e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 3 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l3e_get_pfn( l3e[index] ); -+ unmap_domain_page(l3e); -+ } -+ -+ if ( lev == 2 ) { -+ l2e = map_domain_page( mfn ); -+ if ( !(l2e_get_flags(l2e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 2 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ -+ if ( l2e_get_flags(l2e[index]) & _PAGE_PSE ) { /* handle PSE */ -+ NPT_PRINTK("guest page table is PSE\n"); -+ gpa = (l2e_get_intpte(l2e[index]) & PHYSICAL_PAGE_2M_MASK) + -+ (gva & ~PHYSICAL_PAGE_2M_MASK); -+ unmap_domain_page(l2e); -+ break; /* last level page table, jump out from here */ -+ } -+ else { -+ gpfn = l2e_get_pfn(l2e[index]); -+ } -+ unmap_domain_page(l2e); -+ } -+ -+ if ( lev == 1 ) { -+ l1e = map_domain_page( mfn ); -+ if ( !(l1e_get_flags(l1e[index]) & _PAGE_PRESENT) ) { -+ NPT_PRINTK("Level 1 entry not present at index = %d\n", index); -+ result = 0; -+ } -+ gpfn = l1e_get_pfn( l1e[index] ); -+ gpa = (l1e_get_intpte(l1e[index]) & PHYSICAL_PAGE_4K_MASK) + -+ (gva & ~PHYSICAL_PAGE_4K_MASK); -+ unmap_domain_page(l1e); -+ } -+ -+ if ( result != 1 ) /* error happened, jump out */ -+ break; -+ } -+ -+ gpa &= ~PAGE_NX_BIT; /* clear NX bit of guest physical address */ -+ NPT_PRINTK("result = %d, gva = %lx, gpa = %lx\n", result, gva, gpa); -+ return (paddr_t)gpa; -+} -+#else -+static paddr_t npt_gva_to_gpa_long_mode(struct vcpu *v, unsigned long gva) -+{ -+ HERE_I_AM; -+ printk("guest paging level (4) is greater than host paging level!\n"); -+ domain_crash(v->domain); -+ return 0UL; -+} -+#endif -+ -+static unsigned long -+npt_gva_to_gfn_real_mode(struct vcpu *v, unsigned long gva) -+{ -+ return (npt_gva_to_gpa_real_mode(v, gva) >> PAGE_SHIFT); -+} -+ -+static unsigned long -+npt_gva_to_gfn_protected_mode(struct vcpu *v, unsigned long gva) -+{ -+ return (npt_gva_to_gpa_protected_mode(v, gva) >> PAGE_SHIFT); -+} -+ -+static unsigned long -+npt_gva_to_gfn_pae_mode(struct vcpu *v, unsigned long gva) -+{ -+ return (npt_gva_to_gpa_pae_mode(v, gva) >> PAGE_SHIFT); -+} -+ -+static unsigned long -+npt_gva_to_gfn_long_mode(struct vcpu *v, unsigned long gva) -+{ -+ return (npt_gva_to_gpa_long_mode(v, gva) >> PAGE_SHIFT); -+} -+ -+/********************************************/ -+/* AMD NPT Platform Specific Functions */ -+/********************************************/ -+void npt_detect(void) -+{ -+ u32 eax, ebx, ecx, edx; -+ -+ /* check CPUID for nested paging support */ -+ cpuid(0x8000000A, &eax, &ebx, &ecx, &edx); -+ if ( !(edx & 0x01) && opt_hap_enabled ) { -+ printk(" nested paging is not supported by this CPU.\n"); -+ opt_hap_enabled = 0; /* no nested paging, we disable op_hap_enabled */ -+ } -+} -+ -+/*******************************************/ -+/* Public Interface to Xen */ -+/*******************************************/ -+ -+void npt_set_guest_paging_levels(struct vcpu *v, int levels) -+{ -+ HERE_I_AM; -+ switch(levels) { -+ case 1: -+ NPT_PRINTK("Install real mode guest with ID = %d\n", v->vcpu_id); -+ v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_real_mode; -+ v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_real_mode; -+ break; -+ case 2: -+ NPT_PRINTK("Install 32-bit non-PAE guest with ID = %d\n", v->vcpu_id); -+ v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_protected_mode; -+ v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_protected_mode; -+ break; -+ case 3: -+ NPT_PRINTK("Install 32-bit PAE guest with ID = %d\n", v->vcpu_id); -+ v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_pae_mode; -+ v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_pae_mode; -+ break; -+ case 4: -+ NPT_PRINTK("Install 64-bit guest with ID = %d\n", v->vcpu_id); -+ v->arch.shadow.mode->gva_to_gpa = &npt_gva_to_gpa_long_mode; -+ v->arch.shadow.mode->gva_to_gfn = &npt_gva_to_gfn_long_mode; -+ break; -+ default: -+ printk("Un-supported guest paging level: %d\n", levels); -+ domain_crash(v->domain); -+ break; -+ } -+} -+ -+/* dom_init_npt: initialize the resources of nested paging support -+ * return 1 when successful, return 0 when fail -+ */ -+ -+int dom_init_npt(struct domain *d) -+{ -+ u32 eax, ebx, ecx, edx; -+ -+ HERE_I_AM; -+ -+ /* check CPUID for nested paging support first */ -+ cpuid(0x8000000A, &eax, &ebx, &ecx, &edx); -+ if ( !(edx & 0x01) ) { -+ printk("AMD nested paging is not supported ..."); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+/* reclaim the resource */ -+void dom_destroy_npt(struct domain *d) -+{ -+ HERE_I_AM; -+ NPT_PRINTK("dom_destroy_npt() done!\n"); -+} -+ -+/* This method update the guest paging mode based on guest's accesses (both -+ * read and write) to CR registers, as well as to EFER registers. It also -+ * installs corresponding guest handler based on guest' paging levels. -+ */ -+void npt_update_guest_paging_mode(struct vcpu *v) -+{ -+ struct domain *d = v->domain; -+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -+ u64 cr0_value = vmcb->cr0; -+ u64 cr4_value = vmcb->cr4; -+ u64 efer_value = vmcb->efer; -+ -+ HERE_I_AM; -+ -+ npt_lock(d); -+ -+ if ( (cr0_value & X86_CR0_PE) && (cr0_value & X86_CR0_PG)) { -+ if ( (efer_value & EFER_LME) && (cr4_value & X86_CR4_PAE) ) -+ npt_set_guest_paging_levels(v, PAGING_L4); -+ else if ( cr4_value & X86_CR4_PAE) -+ npt_set_guest_paging_levels(v, PAGING_L3); -+ else -+ npt_set_guest_paging_levels(v, PAGING_L2); -+ } -+ else { -+ NPT_PRINTK("paging is turned off by guests\n"); -+ npt_set_guest_paging_levels(v, PAGING_REAL_MODE); -+ } -+ -+ v->arch.shadow.translate_enabled = !!hvm_paging_enabled(v); -+ -+ npt_unlock(d); -+} -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -+ -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/page-guest32.h -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/page-guest32.h -@@ -0,0 +1,105 @@ -+ -+#ifndef __X86_PAGE_GUEST_H__ -+#define __X86_PAGE_GUEST_H__ -+ -+#ifndef __ASSEMBLY__ -+# include -+#endif -+ -+#define PAGETABLE_ORDER_32 10 -+#define L1_PAGETABLE_ENTRIES_32 (1<> L1_PAGETABLE_SHIFT_32) & (L1_PAGETABLE_ENTRIES_32 - 1)) -+#define l2_table_offset_32(a) \ -+ (((a) >> L2_PAGETABLE_SHIFT_32) & (L2_PAGETABLE_ENTRIES_32 - 1)) -+ -+#define linear_l1_table_32 \ -+ ((l1_pgentry_32_t *)(LINEAR_PT_VIRT_START)) -+ -+#define linear_pg_table_32 linear_l1_table_32 -+ -+#endif /* __X86_PAGE_GUEST_H__ */ -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * tab-width: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ -Index: xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/private.h -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/arch/x86/mm/hap/npt/private.h -@@ -0,0 +1,165 @@ -+/* -+ * private.h: SVM Nested Paging Related Defintion -+ * Copyright (c) 2006, Wei Huang, AMD Corporation. -+ * -+ * This program is free software; you can redistribute it and/or modify it -+ * under the terms and conditions of the GNU General Public License, -+ * version 2, as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope it will be useful, but WITHOUT -+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ * more details. -+ * -+ * You should have received a copy of the GNU General Public License along with -+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple -+ * Place - Suite 330, Boston, MA 02111-1307 USA. -+ * -+ */ -+#ifndef __NPT_PRIVATE_H__ -+#define __NPT_PRIVATE_H__ -+ -+#include -+#include -+ -+/********************************************/ -+/* NPT Debugging Utilities */ -+/********************************************/ -+#define HERE_I_AM \ -+ debugtrace_printk("HERE I AM: %s %s %d\n", __func__, __FILE__, __LINE__) -+#define NPT_PRINTK(_f, _a...) \ -+ debugtrace_printk("npt: %s(): " _f, __func__, ##_a) -+#define NPT_ERROR(_f, _a...) \ -+ printk("npt error: %s(): " _f, __func__, ##_a) -+#define NPT_DEBUG(flag, _f, _a...) \ -+ do { \ -+ debugtrace_printk("npt debug: %s(): " _f, __func__, ##_a); \ -+ } while (0) -+/********************************************/ -+/* NPT Inline Functions and Tools */ -+/********************************************/ -+#define npt_lock(_d) \ -+ do { \ -+ if ( unlikely((_d)->arch.shadow.locker == current->processor) ) \ -+ { \ -+ printk("Error: shadow lock held by %s\n", \ -+ (_d)->arch.shadow.locker_function); \ -+ BUG(); \ -+ } \ -+ spin_lock(&(_d)->arch.shadow.lock); \ -+ ASSERT((_d)->arch.shadow.locker == -1); \ -+ (_d)->arch.shadow.locker = current->processor; \ -+ (_d)->arch.shadow.locker_function = __func__; \ -+ } while (0) -+ -+#define npt_unlock(_d) \ -+ do { \ -+ ASSERT((_d)->arch.shadow.locker == current->processor); \ -+ (_d)->arch.shadow.locker = -1; \ -+ (_d)->arch.shadow.locker_function = "nobody"; \ -+ spin_unlock(&(_d)->arch.shadow.lock); \ -+ } while (0) -+/********************************************/ -+/* Variable Definition */ -+/********************************************/ -+#define NPT_HOST_PAGE_TABLE_FLAGS (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER) & ~_PAGE_DIRTY & ~_PAGE_ACCESSED -+#define NPT_HOST_PAGE_TABLE_MMIO_FLAGS ( _PAGE_PRESENT ) & ~_PAGE_DIRTY & ~_PAGE_ACCESSED -+#if CONFIG_PAGING_LEVELS == 3 -+#define NPT_HOST_PAGE_TABLE_PDPE_FLAGS _PAGE_PRESENT -+#else -+#define NPT_HOST_PAGE_TABLE_PDPE_FLAGS (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER) & ~_PAGE_DIRTY & ~_PAGE_ACCESSED -+#endif -+ -+#if CONFIG_PAGING_LEVELS == 2 -+#define INIT_NUM_OF_NPT_PAGES 1 -+#elif CONFIG_PAGING_LEVELS == 3 -+#define INIT_NUM_OF_NPT_PAGES 1 + L3_PAGETABLE_ENTRIES -+#elif CONFIG_PAGING_LEVELS == 4 -+#define INIT_NUM_OF_NPT_PAGES 1 -+#endif -+ -+/* The following is the max number of host page table pages required. For most -+ * time, we don't use so much. -+ */ -+#if CONFIG_PAGING_LEVELS == 2 -+#define MAX_NUM_OF_NPT_PAGES 1 + L2_PAGETABLE_ENTRIES -+#elif CONFIG_PAGING_LEVELS == 3 -+#define MAX_NUM_OF_NPT_PAGES 1 + L3_PAGETABLE_ENTRIES * (1 + L2_PAGETABLE_ENTRIES) -+#elif CONFIG_PAGING_LEVELS == 4 -+#define MAX_NUM_OF_NPT_PAGES 1 + L4_PAGETABLE_ENTRIES * (1 + L3_PAGETABLE_ENTRIES * (1 + L2_PAGETABLE_ENTRIES)) -+#endif -+ -+ -+ -+/********************************************/ -+/* MISC DEFINITIONS */ -+/********************************************/ -+ -+/* PT_SHIFT describes the amount by which a virtual address is shifted right -+ * to right justify the portion to be used for indexing into a page -+ * table, given the guest memory model (i.e. number of levels) and the level -+ * of the page table being accessed. The idea is from Virtual Iron's code. -+ */ -+static const int PT_SHIFT[][5] = -+ { /* ------ level ------ nr_levels */ -+ /* 1 2 3 4 */ -+ { 0, 0, 0, 0, 0}, /* 0 not used */ -+ { 0, 0, 0, 0, 0}, /* 1 not used */ -+ { 0, 12, 22, 0, 0}, /* 2 */ -+ { 0, 12, 21, 30, 0}, /* 3 */ -+ { 0, 12, 21, 30, 39} /* 4 */ -+ }; -+ -+/* PT_ENTRIES describes the number of entries in a page table, given the -+ * memory model (i.e. number of levels) and the level of the page table -+ * being considered. This idea from Virtual Iron's shadow code*/ -+static const int PT_ENTRIES[][5] = -+ { /* ------ level ------ nr_levels */ -+ /* 1 2 3 4 */ -+ { 0, 0, 0, 0, 0}, /* 0 not used */ -+ { 0, 0, 0, 0, 0}, /* 1 not used */ -+ { 0, 1024, 1024, 0, 0}, /* 2 */ -+ { 0, 512, 512, 4, 0}, /* 3 */ -+ { 0, 512, 512, 512, 512} /* 4 */ -+ }; -+ -+/********************************************/ -+/* PAGING DEFINITION FOR GUEST */ -+/********************************************/ -+#define PHYSICAL_PAGE_4K_SIZE (1UL << 12) -+#define PHYSICAL_PAGE_2M_SIZE (1UL << 21) -+#define PHYSICAL_PAGE_4M_SIZE (1UL << 22) -+#define PHYSICAL_PAGE_4K_MASK ( ~(PHYSICAL_PAGE_4K_SIZE - 1) ) -+#define PHYSICAL_PAGE_2M_MASK ( ~(PHYSICAL_PAGE_2M_SIZE - 1) ) -+#define PHYSICAL_PAGE_4M_MASK ( ~(PHYSICAL_PAGE_4M_SIZE - 1) ) -+#define NPT_GUEST_CR3_SHIFT_NON_PAE 12 /* both legacy mode and long mode */ -+#define NPT_GUEST_CR3_SHIFT_PAE 5 /* PAE mode */ -+ -+#define PAGING_REAL_MODE 1 -+#define PAGING_L2 2 -+#define PAGING_L3 3 -+#define PAGING_L4 4 -+ -+#define PAGE_NX_BIT (1ULL << 63) -+/********************************************/ -+/* MISC. DDFINITIONS */ -+/********************************************/ -+#if CONFIG_PAGING_LEVELS == 2 -+#define NPT_PRI_LONG "08x" -+#define NPT_PRI_ULONG "08ux" -+#else /* CONFIG_PAGING_LEVELS >= 3 */ -+#ifndef __x86_64__ -+#define SH_PRI_LONG "016llx" -+#define NPT_PRI_ULONG "016llux" -+#else -+#define SH_PRI_LONG "016lx" -+#define NPT_PRI_ULONG "016lux" -+#endif -+#endif -+ -+#if CONFIG_PAGING_LEVELS == 2 -+#define NPT_MAX_ORDER 0 /* Only ever need 4k allocations */ -+#else -+#define NPT_MAX_ORDER 2 /* Need up to 16k allocs for 32-bit on PAE/64 */ -+#endif -+#endif /* __SVM_NPT_H__ */ -Index: xen-3.0.4-testing/xen/include/asm-x86/hap.h -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/asm-x86/hap.h -@@ -0,0 +1,56 @@ -+/****************************************************************************** -+ * include/asm-x86/hap.h -+ * hardware assisted paging support -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -+ */ -+ -+#ifndef _HAP_H_ -+#define _HAP_H_ -+ -+#include -+#include -+#include -+#include -+#include -+ -+static inline unsigned int hap_is_activated(struct vcpu *v) -+{ -+ return v->arch.hap_activated; -+} -+ -+static inline void hap_activate(struct vcpu *v) -+{ -+ v->arch.hap_activated = 1; -+} -+ -+static inline void hap_deactivate(struct vcpu *v) -+{ -+ v->arch.hap_activated = 0; -+} -+ -+void npt_update_guest_paging_mode(struct vcpu *v); -+void npt_detect(void); -+#endif -+ -+ -+/* -+ * Local variables: -+ * mode: C -+ * c-set-style: "BSD" -+ * c-basic-offset: 4 -+ * indent-tabs-mode: nil -+ * End: -+ */ diff --git a/npt_part2.patch b/npt_part2.patch deleted file mode 100644 index 9222727..0000000 --- a/npt_part2.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/mm/shadow/common.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/mm/shadow/common.c -+++ xen-3.0.4-testing/xen/arch/x86/mm/shadow/common.c -@@ -1163,6 +1163,8 @@ p2m_next_level(struct domain *d, mfn_t * - if (type == PGT_l2_page_table) - { - struct vcpu *v; -+ /* for PAE mode, PDPE only have PCD/PWT/P bits available */ -+ *p2m_entry = l1e_from_pfn(mfn_x(mfn), _PAGE_PRESENT); - /* We have written to the p2m l3: need to sync the per-vcpu - * copies of it in the monitor tables */ - p2m_install_entry_in_monitors(d, (l3_pgentry_t *)p2m_entry); diff --git a/pae-guest-linear-pgtable.patch b/pae-guest-linear-pgtable.patch deleted file mode 100644 index 75055fb..0000000 --- a/pae-guest-linear-pgtable.patch +++ /dev/null @@ -1,147 +0,0 @@ -Index: 2007-01-31/xen/arch/x86/domain.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/domain.c 2007-01-31 09:39:18.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/domain.c 2007-02-15 15:10:02.000000000 +0100 -@@ -1337,7 +1337,8 @@ int hypercall_xlat_continuation(unsigned - } - #endif - --static void relinquish_memory(struct domain *d, struct list_head *list) -+static void relinquish_memory(struct domain *d, struct list_head *list, -+ unsigned long type) - { - struct list_head *ent; - struct page_info *page; -@@ -1366,23 +1367,24 @@ static void relinquish_memory(struct dom - put_page(page); - - /* -- * Forcibly invalidate base page tables at this point to break circular -- * 'linear page table' references. This is okay because MMU structures -- * are not shared across domains and this domain is now dead. Thus base -- * tables are not in use so a non-zero count means circular reference. -+ * Forcibly invalidate top-most, still valid page tables at this point -+ * to break circular 'linear page table' references. This is okay -+ * because MMU structures are not shared across domains and this domain -+ * is now dead. Thus top-most valid tables are not in use so a non-zero -+ * count means circular reference. - */ - y = page->u.inuse.type_info; - for ( ; ; ) - { - x = y; - if ( likely((x & (PGT_type_mask|PGT_validated)) != -- (PGT_base_page_table|PGT_validated)) ) -+ (type|PGT_validated)) ) - break; - - y = cmpxchg(&page->u.inuse.type_info, x, x & ~PGT_validated); - if ( likely(y == x) ) - { -- free_page_type(page, PGT_base_page_table); -+ free_page_type(page, type); - break; - } - } -@@ -1464,8 +1466,16 @@ void domain_relinquish_resources(struct - destroy_gdt(v); - - /* Relinquish every page of memory. */ -- relinquish_memory(d, &d->xenpage_list); -- relinquish_memory(d, &d->page_list); -+#if CONFIG_PAGING_LEVELS >= 4 -+ relinquish_memory(d, &d->xenpage_list, PGT_l4_page_table); -+ relinquish_memory(d, &d->page_list, PGT_l4_page_table); -+#endif -+#if CONFIG_PAGING_LEVELS >= 3 -+ relinquish_memory(d, &d->xenpage_list, PGT_l3_page_table); -+ relinquish_memory(d, &d->page_list, PGT_l3_page_table); -+#endif -+ relinquish_memory(d, &d->xenpage_list, PGT_l2_page_table); -+ relinquish_memory(d, &d->page_list, PGT_l2_page_table); - - /* Free page used by xen oprofile buffer */ - free_xenoprof_pages(d); -Index: 2007-01-31/xen/arch/x86/mm.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/mm.c 2007-02-15 15:02:01.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/mm.c 2007-02-02 16:34:03.000000000 +0100 -@@ -509,7 +509,7 @@ get_linear_pagetable( - return 0; - - /* -- * Make sure that the mapped frame is an already-validated L2 table. -+ * Make sure that the mapped frame is an already-validated root table. - * If so, atomically increment the count (checking for overflow). - */ - page = mfn_to_page(pfn); -@@ -531,6 +531,51 @@ get_linear_pagetable( - } - #endif /* !CONFIG_X86_PAE */ - -+#if defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64) -+static int -+get_l2_linear_pagetable( -+ l2_pgentry_t l2e, unsigned long l2e_pfn, struct domain *d) -+{ -+ unsigned long pfn; -+ -+ if ( (l2e_get_flags(l2e) & _PAGE_RW) ) -+ { -+ MEM_LOG("Attempt to create linear p.t. with write perms"); -+ return 0; -+ } -+ -+ if ( (pfn = l2e_get_pfn(l2e)) != l2e_pfn ) -+ { -+ unsigned long x, y; -+ struct page_info *page; -+ -+ /* Make sure the mapped frame belongs to the correct domain. */ -+ if ( unlikely(!get_page_from_pagenr(pfn, d)) ) -+ return 0; -+ -+ /* -+ * Make sure that the mapped frame is an already-validated L2 table. -+ * If so, atomically increment the count (checking for overflow). -+ */ -+ page = mfn_to_page(pfn); -+ y = page->u.inuse.type_info; -+ do { -+ x = y; -+ if ( unlikely((x & PGT_count_mask) == PGT_count_mask) || -+ unlikely((x & (PGT_type_mask|PGT_validated)) != -+ (PGT_l2_page_table|PGT_validated)) ) -+ { -+ put_page(page); -+ return 0; -+ } -+ } -+ while ( (y = cmpxchg(&page->u.inuse.type_info, x, x + 1)) != x ); -+ } -+ -+ return 1; -+} -+#endif /* !CONFIG_X86_PAE */ -+ - int - get_page_from_l1e( - l1_pgentry_t l1e, struct domain *d) -@@ -607,10 +652,16 @@ get_page_from_l2e( - } - - rc = get_page_and_type_from_pagenr(l2e_get_pfn(l2e), PGT_l1_page_table, d); --#if CONFIG_PAGING_LEVELS == 2 - if ( unlikely(!rc) ) -+ { -+#if CONFIG_PAGING_LEVELS == 2 - rc = get_linear_pagetable(l2e, pfn, d); -+#else -+ if ( (CONFIG_PAGING_LEVELS == 3 || IS_COMPAT(d)) ) -+ rc = get_l2_linear_pagetable(l2e, pfn, d); - #endif -+ } -+ - return rc; - } - diff --git a/protocol-bimodal.diff b/protocol-bimodal.diff deleted file mode 100644 index 411a9de..0000000 --- a/protocol-bimodal.diff +++ /dev/null @@ -1,35 +0,0 @@ -bimodal: header file with protocol names. - -This patch adds a header file with the protocol names. - -Signed-off-by: Gerd Hoffmann ---- - xen/include/public/io/protocols.h | 21 +++++++++++++++++++++ - 1 file changed, 21 insertions(+) - -Index: build-32-unstable-13495/xen/include/public/io/protocols.h -=================================================================== ---- /dev/null -+++ build-32-unstable-13495/xen/include/public/io/protocols.h -@@ -0,0 +1,21 @@ -+#ifndef __XEN_PROTOCOLS_H__ -+#define __XEN_PROTOCOLS_H__ -+ -+#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" -+#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" -+#define XEN_IO_PROTO_ABI_IA64 "ia64-abi" -+#define XEN_IO_PROTO_ABI_POWERPC64 "powerpc64-abi" -+ -+#if defined(__i386__) -+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 -+#elif defined(__x86_64__) -+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 -+#elif defined(__ia64__) -+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_IA64 -+#elif defined(__powerpc64__) -+# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_POWERPC64 -+#else -+# error arch fixup needed here -+#endif -+ -+#endif diff --git a/pv-driver-build.patch b/pv-driver-build.patch deleted file mode 100644 index b38a96d..0000000 --- a/pv-driver-build.patch +++ /dev/null @@ -1,101 +0,0 @@ -Index: 2007-01-19/unmodified_drivers/linux-2.6/mkbuildtree -=================================================================== ---- 2007-01-19.orig/unmodified_drivers/linux-2.6/mkbuildtree 2006-12-14 22:49:58.000000000 +0100 -+++ 2007-01-19/unmodified_drivers/linux-2.6/mkbuildtree 2007-01-24 14:48:33.000000000 +0100 -@@ -8,10 +8,12 @@ else - echo "This may be overridden on the command line (i386,x86_64,ia64)." - fi - --C=$PWD -- --XEN=$C/../../xen --XL=$C/../../linux-2.6-xen-sparse -+if [ -n "$XL" -a -d "$XL" ]; then -+ XL=$(cd $XL && pwd) -+else -+ XL=/usr/src/linux -+fi -+cd "$(dirname "$0")" - - for d in $(find ${XL}/drivers/xen/ -maxdepth 1 -type d | sed -e 1d); do - if ! echo $d | egrep -q back; then -@@ -24,14 +26,9 @@ ln -sf ${XL}/drivers/xen/core/features.c - ln -sf ${XL}/drivers/xen/core/xen_proc.c xenbus - ln -sf ${XL}/drivers/xen/core/reboot.c util - --mkdir -p include --mkdir -p include/xen --mkdir -p include/public --mkdir -p include/asm --mkdir -p include/asm/xen -+mkdir -p include/asm include/xen - - lndir -silent ${XL}/include/xen include/xen --ln -nsf ${XEN}/include/public include/xen/interface - - # Need to be quite careful here: we don't want the files we link in to - # risk overriding the native Linux ones (in particular, system.h must -@@ -43,7 +40,8 @@ in - ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/hypercall.h include/asm - ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/synch_bitops.h include/asm - ln -sf ${XL}/include/asm-x86_64/mach-xen/asm/maddr.h include/asm -- ln -sf ${XL}/include/asm-i386 include/asm-i386 -+ mkdir include/asm-i386 -+ lndir -silent ${XL}/include/asm-i386 include/asm-i386 - ;; - i[34567]86) - ln -sf ${XL}/include/asm-i386/mach-xen/asm/hypervisor.h include/asm -@@ -56,6 +54,7 @@ i[34567]86) - ln -sf ${XL}/include/asm-ia64/hypercall.h include/asm - ln -sf ${XL}/include/asm-ia64/synch_bitops.h include/asm - ln -sf ${XL}/include/asm-ia64/maddr.h include/asm -+ mkdir include/asm/xen - ln -sf ${XL}/include/asm-ia64/xen/xcom_hcall.h include/asm/xen - ln -sf ${XL}/include/asm-ia64/xen/xencomm.h include/asm/xen - ln -sf ${XL}/arch/ia64/xen/xcom_mini.c platform-pci -Index: 2007-01-19/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h -=================================================================== ---- 2007-01-19.orig/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h 2006-12-14 22:49:58.000000000 +0100 -+++ 2007-01-19/unmodified_drivers/linux-2.6/compat-include/xen/platform-compat.h 2007-01-26 10:44:53.000000000 +0100 -@@ -69,4 +69,12 @@ extern char *kasprintf(gfp_t gfp, const - __attribute__ ((format (printf, 2, 3))); - #endif - -+/* -+ * This variable at present is referenced by netfront, but only in code that -+ * is dead when running in hvm guests. To detect potential active uses of it -+ * in the future, don't try to supply a 'valid' value here, so that any -+ * mappings created with it will fault when accessed. -+ */ -+#define __supported_pte_mask ((maddr_t)0) -+ - #endif -Index: 2007-01-19/unmodified_drivers/linux-2.6/overrides.mk -=================================================================== ---- 2007-01-19.orig/unmodified_drivers/linux-2.6/overrides.mk 2006-12-14 22:49:58.000000000 +0100 -+++ 2007-01-19/unmodified_drivers/linux-2.6/overrides.mk 2007-01-23 13:19:27.000000000 +0100 -@@ -4,9 +4,5 @@ - # - # (i.e. we need the native config for things like -mregparm, but - # a Xen kernel to find the right headers) --EXTRA_CFLAGS += -DCONFIG_VMX -DCONFIG_VMX_GUEST -DCONFIG_X86_XEN --EXTRA_CFLAGS += -DCONFIG_XEN_SHADOW_MODE -DCONFIG_XEN_SHADOW_TRANSLATE --EXTRA_CFLAGS += -DCONFIG_XEN_BLKDEV_GRANT -DXEN_EVTCHN_MASK_OPS --EXTRA_CFLAGS += -DCONFIG_XEN_NETDEV_GRANT_RX -DCONFIG_XEN_NETDEV_GRANT_TX - EXTRA_CFLAGS += -D__XEN_INTERFACE_VERSION__=0x00030202 - EXTRA_CFLAGS += -I$(M)/include -I$(M)/compat-include -DHAVE_XEN_PLATFORM_COMPAT_H -Index: 2007-01-19/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c -=================================================================== ---- 2007-01-19.orig/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c 2006-12-14 22:49:58.000000000 +0100 -+++ 2007-01-19/unmodified_drivers/linux-2.6/platform-pci/platform-compat.c 2007-01-23 12:54:45.000000000 +0100 -@@ -115,7 +115,9 @@ void *kzalloc(size_t size, int flags) - EXPORT_SYMBOL(kzalloc); - #endif - --#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) -+#if defined(CONFIG_SUSE_KERNEL) \ -+ ? LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) \ -+ : LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) - /* Simplified asprintf. */ - char *kasprintf(gfp_t gfp, const char *fmt, ...) - { diff --git a/serial-split.patch b/serial-split.patch index 27fc341..a4dd074 100644 --- a/serial-split.patch +++ b/serial-split.patch @@ -1,7 +1,7 @@ -Index: xen-3.0.4-testing/tools/misc/serial-split/Makefile +Index: xen-unstable/tools/misc/serial-split/Makefile =================================================================== --- /dev/null -+++ xen-3.0.4-testing/tools/misc/serial-split/Makefile ++++ xen-unstable/tools/misc/serial-split/Makefile @@ -0,0 +1,20 @@ +CC ?= gcc +CFLAGS ?= -Wall -Os @@ -23,10 +23,10 @@ Index: xen-3.0.4-testing/tools/misc/serial-split/Makefile + +%.o: %.c Makefile + $(CC) $(CFLAGS) -c -o $@ $< -Index: xen-3.0.4-testing/tools/misc/serial-split/serial-split.c +Index: xen-unstable/tools/misc/serial-split/serial-split.c =================================================================== --- /dev/null -+++ xen-3.0.4-testing/tools/misc/serial-split/serial-split.c ++++ xen-unstable/tools/misc/serial-split/serial-split.c @@ -0,0 +1,422 @@ +/* + * serial-split.c diff --git a/supported_module.diff b/supported_module.diff new file mode 100644 index 0000000..ab4e37c --- /dev/null +++ b/supported_module.diff @@ -0,0 +1,13 @@ +Make our PV drivers "Novell supported modules" + +Signed-off-by: K. Y. Srinivasan + +Index: xen-3.0.4-testing/unmodified_drivers/linux-2.6/Module.supported +=================================================================== +--- /dev/null ++++ xen-3.0.4-testing/unmodified_drivers/linux-2.6/Module.supported +@@ -0,0 +1,4 @@ ++xen-vbd ++xen-platform-pci ++xen-vnif ++xenbus diff --git a/suppress-rdtscp.patch b/suppress-rdtscp.patch deleted file mode 100644 index 3ffea38..0000000 --- a/suppress-rdtscp.patch +++ /dev/null @@ -1,28 +0,0 @@ -Index: 2007-01-31/xen/arch/x86/traps.c -=================================================================== ---- 2007-01-31.orig/xen/arch/x86/traps.c 2007-01-31 09:42:07.000000000 +0100 -+++ 2007-01-31/xen/arch/x86/traps.c 2007-02-07 17:03:20.000000000 +0100 -@@ -613,6 +613,11 @@ static int emulate_forced_invalid_op(str - if ( !IS_PRIV(current->domain) ) - clear_bit(X86_FEATURE_MTRR, &d); - } -+ else if ( regs->eax == 0x80000001 ) -+ { -+ /* Modify Feature Information. */ -+ clear_bit(X86_FEATURE_RDTSCP % 32, &d); -+ } - else - { - (void)cpuid_hypervisor_leaves(regs->eax, &a, &b, &c, &d); -Index: 2007-01-31/xen/include/asm-x86/cpufeature.h -=================================================================== ---- 2007-01-31.orig/xen/include/asm-x86/cpufeature.h 2007-01-31 09:28:56.000000000 +0100 -+++ 2007-01-31/xen/include/asm-x86/cpufeature.h 2007-02-07 17:03:20.000000000 +0100 -@@ -49,6 +49,7 @@ - #define X86_FEATURE_MP (1*32+19) /* MP Capable. */ - #define X86_FEATURE_NX (1*32+20) /* Execute Disable */ - #define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ -+#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */ - #define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */ - #define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */ - #define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */ diff --git a/svm-update-v_tpr-on-mmio.patch b/svm-update-v_tpr-on-mmio.patch deleted file mode 100644 index 4a27524..0000000 --- a/svm-update-v_tpr-on-mmio.patch +++ /dev/null @@ -1,116 +0,0 @@ -# HG changeset patch -# User Travis Betak -# Date 1168370530 21600 -# Node ID e822926dd62492282e51c5847a8d85a3d22dda1d -# Parent d401cb96d8a0da5febe737b86f453a88f1f45bb7 -[HVM][SVM] Updated the SVM V_TPR register on MMIO writes to the VLAPIC TPR - -The SVM architecture includes a virtual TPR register. This patch -updates this register on MMIO writes to the HVM Virtual APIC. - -VT does not have this register as far as I know so a stub is added in -the VT code. - -Signed-off-by: Travis Betak - -Index: xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/svm/svm.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -@@ -503,6 +503,13 @@ void svm_update_guest_cr3(struct vcpu *v - v->arch.hvm_svm.vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3; - } - -+static void svm_update_vtpr(struct vcpu *v, unsigned long value) -+{ -+ struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; -+ -+ vmcb->vintr.fields.tpr = value & 0x0f; -+} -+ - unsigned long svm_get_ctrl_reg(struct vcpu *v, unsigned int num) - { - switch ( num ) -@@ -894,6 +901,8 @@ int start_svm(void) - hvm_funcs.update_host_cr3 = svm_update_host_cr3; - hvm_funcs.update_guest_cr3 = svm_update_guest_cr3; - -+ hvm_funcs.update_vtpr = svm_update_vtpr; -+ - hvm_funcs.stts = svm_stts; - hvm_funcs.set_tsc_offset = svm_set_tsc_offset; - -@@ -1956,6 +1965,7 @@ static int mov_to_cr(int gpreg, int cr, - - case 8: - vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4)); -+ vmcb->vintr.fields.tpr = value & 0x0F; - break; - - default: -Index: xen-3.0.4-testing/xen/arch/x86/hvm/vlapic.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/vlapic.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/vlapic.c -@@ -631,6 +631,7 @@ static void vlapic_write(struct vcpu *v, - { - case APIC_TASKPRI: - vlapic_set_reg(vlapic, APIC_TASKPRI, val & 0xff); -+ hvm_update_vtpr(v, (val >> 4) & 0x0f); - break; - - case APIC_EOI: -Index: xen-3.0.4-testing/xen/arch/x86/hvm/vmx/vmx.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/vmx/vmx.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/vmx/vmx.c -@@ -738,6 +738,11 @@ static void vmx_inject_exception( - v->arch.hvm_vmx.cpu_cr2 = cr2; - } - -+static void vmx_update_vtpr(struct vcpu *v, unsigned long value) -+{ -+ /* VMX doesn't have a V_TPR field */ -+} -+ - /* Setup HVM interfaces */ - static void vmx_setup_hvm_funcs(void) - { -@@ -763,6 +768,8 @@ static void vmx_setup_hvm_funcs(void) - hvm_funcs.update_host_cr3 = vmx_update_host_cr3; - hvm_funcs.update_guest_cr3 = vmx_update_guest_cr3; - -+ hvm_funcs.update_vtpr = vmx_update_vtpr; -+ - hvm_funcs.stts = vmx_stts; - hvm_funcs.set_tsc_offset = vmx_set_tsc_offset; - -Index: xen-3.0.4-testing/xen/include/asm-x86/hvm/hvm.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/hvm/hvm.h -+++ xen-3.0.4-testing/xen/include/asm-x86/hvm/hvm.h -@@ -108,6 +108,11 @@ struct hvm_function_table { - void (*update_guest_cr3)(struct vcpu *v); - - /* -+ * Reflect the virtual APIC's value in the guest's V_TPR register -+ */ -+ void (*update_vtpr)(struct vcpu *v, unsigned long value); -+ -+ /* - * Update specifics of the guest state: - * 1) TS bit in guest cr0 - * 2) TSC offset in guest -@@ -193,6 +198,12 @@ hvm_update_host_cr3(struct vcpu *v) - hvm_funcs.update_host_cr3(v); - } - -+static inline void -+hvm_update_vtpr(struct vcpu *v, unsigned long value) -+{ -+ hvm_funcs.update_vtpr(v, value); -+} -+ - void hvm_update_guest_cr3(struct vcpu *v, unsigned long guest_cr3); - - void hvm_hypercall_page_initialise(struct domain *d, diff --git a/svm_cpuid_ffxsr_13743.patch b/svm_cpuid_ffxsr_13743.patch deleted file mode 100644 index efac3e4..0000000 --- a/svm_cpuid_ffxsr_13743.patch +++ /dev/null @@ -1,25 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/hvm/svm/svm.c -+++ xen-3.0.4-testing/xen/arch/x86/hvm/svm/svm.c -@@ -1085,6 +1085,8 @@ static void svm_vmexit_do_cpuid(struct v - /* So far, we do not support 3DNow for the guest. */ - clear_bit(X86_FEATURE_3DNOW & 31, &edx); - clear_bit(X86_FEATURE_3DNOWEXT & 31, &edx); -+ /* no FFXSR instructions feature. */ -+ clear_bit(X86_FEATURE_FFXSR & 31, &edx); - } - } - else if ( ( input == 0x80000007 ) || ( input == 0x8000000A ) ) -Index: xen-3.0.4-testing/xen/include/asm-x86/cpufeature.h -=================================================================== ---- xen-3.0.4-testing.orig/xen/include/asm-x86/cpufeature.h -+++ xen-3.0.4-testing/xen/include/asm-x86/cpufeature.h -@@ -92,6 +92,7 @@ - #define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */ - #define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */ - #define X86_FEATURE_SVME (6*32+ 2) /* Secure Virtual Machine */ -+#define X86_FEATURE_FFXSR (6*32+25) /* FFXSR instruction optimizations */ - - #define cpu_has(c, bit) test_bit(bit, (c)->x86_capability) - #define boot_cpu_has(bit) test_bit(bit, boot_cpu_data.x86_capability) diff --git a/tools-add-errors.diff b/tools-add-errors.diff deleted file mode 100644 index c6f9bd1..0000000 --- a/tools-add-errors.diff +++ /dev/null @@ -1,41 +0,0 @@ -Add more xc_error_code values. - -XC_INVALID_PARAM - such as asking for features unsupported by either xen or guest kernel. -XC_OUT_OF_MEMORY - no comment ;) - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/xc_private.c | 4 ++++ - tools/libxc/xenctrl.h | 2 ++ - 2 files changed, 6 insertions(+) - -Index: build-32-unstable-12809/tools/libxc/xenctrl.h -=================================================================== ---- build-32-unstable-12809.orig/tools/libxc/xenctrl.h -+++ build-32-unstable-12809/tools/libxc/xenctrl.h -@@ -691,6 +691,8 @@ typedef enum { - XC_ERROR_NONE = 0, - XC_INTERNAL_ERROR = 1, - XC_INVALID_KERNEL = 2, -+ XC_INVALID_PARAM = 3, -+ XC_OUT_OF_MEMORY = 4, - } xc_error_code; - - #define XC_MAX_ERROR_MSG_LEN 1024 -Index: build-32-unstable-12809/tools/libxc/xc_private.c -=================================================================== ---- build-32-unstable-12809.orig/tools/libxc/xc_private.c -+++ build-32-unstable-12809/tools/libxc/xc_private.c -@@ -45,6 +45,10 @@ const char *xc_error_code_to_desc(int co - return "Internal error"; - case XC_INVALID_KERNEL: - return "Invalid kernel"; -+ case XC_INVALID_PARAM: -+ return "Invalid configuration"; -+ case XC_OUT_OF_MEMORY: -+ return "Out of memory"; - } - - return "Unknown error code"; diff --git a/tools-debug-oldbuilder.diff b/tools-debug-oldbuilder.diff deleted file mode 100644 index 176376c..0000000 --- a/tools-debug-oldbuilder.diff +++ /dev/null @@ -1,238 +0,0 @@ -debug: compile old domain builder too. - -Compile both old and new domain builder into the tools, so both -are available and can be selected at runtime. Nice for a quick -check when things go wrong, to see if the new domain builder is -incompatible with the old one or whenever something else broke. - -Activate with "builder=old" in the config file or as option for -the "xm create" command - ---- - tools/libxc/Makefile | 4 +-- - tools/libxc/xc_linux_build.c | 4 +-- - tools/libxc/xenguest.h | 28 +++++++++++++++++++++ - tools/python/xen/lowlevel/xc/xc.c | 50 +++++++++++++++++++++++++++++++++++++- - tools/python/xen/xend/image.py | 40 ++++++++++++++++++++++++++++++ - 5 files changed, 121 insertions(+), 5 deletions(-) - -Index: build-32-release304-13087/tools/libxc/Makefile -=================================================================== ---- build-32-release304-13087.orig/tools/libxc/Makefile -+++ build-32-release304-13087/tools/libxc/Makefile -@@ -24,8 +24,8 @@ GUEST_SRCS-y := - GUEST_SRCS-y += xc_load_bin.c - GUEST_SRCS-y += xc_load_elf.c - GUEST_SRCS-y += xg_private.c --#GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c --#GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c -+GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c -+GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c - GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c - GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c - -Index: build-32-release304-13087/tools/libxc/xc_linux_build.c -=================================================================== ---- build-32-release304-13087.orig/tools/libxc/xc_linux_build.c -+++ build-32-release304-13087/tools/libxc/xc_linux_build.c -@@ -1185,7 +1185,7 @@ static int xc_linux_build_internal(int x - return -1; - } - --int xc_linux_build_mem(int xc_handle, -+int old_xc_linux_build_mem(int xc_handle, - uint32_t domid, - unsigned int mem_mb, - const char *image_buffer, -@@ -1254,7 +1254,7 @@ int xc_linux_build_mem(int xc_handle, - return sts; - } - --int xc_linux_build(int xc_handle, -+int old_xc_linux_build(int xc_handle, - uint32_t domid, - unsigned int mem_mb, - const char *image_name, -Index: build-32-release304-13087/tools/libxc/xenguest.h -=================================================================== ---- build-32-release304-13087.orig/tools/libxc/xenguest.h -+++ build-32-release304-13087/tools/libxc/xenguest.h -@@ -59,6 +59,19 @@ int xc_linux_restore(int xc_handle, int - * @parm conole_mfn returned with the mfn of the console page - * @return 0 on success, -1 on failure - */ -+int old_xc_linux_build(int xc_handle, -+ uint32_t domid, -+ unsigned int mem_mb, -+ const char *image_name, -+ const char *ramdisk_name, -+ const char *cmdline, -+ const char *features, -+ unsigned long flags, -+ unsigned int store_evtchn, -+ unsigned long *store_mfn, -+ unsigned int console_evtchn, -+ unsigned long *console_mfn); -+ - int xc_linux_build(int xc_handle, - uint32_t domid, - unsigned int mem_mb, -@@ -91,6 +104,21 @@ int xc_linux_build(int xc_handle, - * @parm conole_mfn returned with the mfn of the console page - * @return 0 on success, -1 on failure - */ -+int old_xc_linux_build_mem(int xc_handle, -+ uint32_t domid, -+ unsigned int mem_mb, -+ const char *image_buffer, -+ unsigned long image_size, -+ const char *initrd_buffer, -+ unsigned long initrd_size, -+ const char *cmdline, -+ const char *features, -+ unsigned long flags, -+ unsigned int store_evtchn, -+ unsigned long *store_mfn, -+ unsigned int console_evtchn, -+ unsigned long *console_mfn); -+ - int xc_linux_build_mem(int xc_handle, - uint32_t domid, - unsigned int mem_mb, -Index: build-32-release304-13087/tools/python/xen/lowlevel/xc/xc.c -=================================================================== ---- build-32-release304-13087.orig/tools/python/xen/lowlevel/xc/xc.c -+++ build-32-release304-13087/tools/python/xen/lowlevel/xc/xc.c -@@ -349,6 +349,43 @@ static PyObject *pyxc_vcpu_getinfo(XcObj - return info_dict; - } - -+static PyObject *pyxc_old_linux_build(XcObject *self, -+ PyObject *args, -+ PyObject *kwds) -+{ -+ uint32_t dom; -+ char *image, *ramdisk = NULL, *cmdline = "", *features = NULL; -+ int flags = 0; -+ int store_evtchn, console_evtchn; -+ unsigned int mem_mb; -+ unsigned long store_mfn = 0; -+ unsigned long console_mfn = 0; -+ -+ static char *kwd_list[] = { "domid", "store_evtchn", "memsize", -+ "console_evtchn", "image", -+ /* optional */ -+ "ramdisk", "cmdline", "flags", -+ "features", NULL }; -+ -+ if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list, -+ &dom, &store_evtchn, &mem_mb, -+ &console_evtchn, &image, -+ /* optional */ -+ &ramdisk, &cmdline, &flags, -+ &features) ) -+ return NULL; -+ -+ if ( old_xc_linux_build(self->xc_handle, dom, mem_mb, image, -+ ramdisk, cmdline, features, flags, -+ store_evtchn, &store_mfn, -+ console_evtchn, &console_mfn) != 0 ) { -+ return pyxc_error_to_exception(); -+ } -+ return Py_BuildValue("{s:i,s:i}", -+ "store_mfn", store_mfn, -+ "console_mfn", console_mfn); -+} -+ - static PyObject *pyxc_linux_build(XcObject *self, - PyObject *args, - PyObject *kwds) -@@ -1093,7 +1130,18 @@ static PyMethodDef pyxc_methods[] = { - " cpumap [int]: Bitmap of CPUs this VCPU can run on\n" - " cpu [int]: CPU that this VCPU is currently bound to\n" }, - -- { "linux_build", -+ { "old_linux_build", -+ (PyCFunction)pyxc_old_linux_build, -+ METH_VARARGS | METH_KEYWORDS, "\n" -+ "Build a new Linux guest OS.\n" -+ " dom [int]: Identifier of domain to build into.\n" -+ " image [str]: Name of kernel image file. May be gzipped.\n" -+ " ramdisk [str, n/a]: Name of ramdisk file, if any.\n" -+ " cmdline [str, n/a]: Kernel parameters, if any.\n\n" -+ " vcpus [int, 1]: Number of Virtual CPUS in domain.\n\n" -+ "Returns: [int] 0 on success; -1 on error.\n" }, -+ -+ { "linux_build", - (PyCFunction)pyxc_linux_build, - METH_VARARGS | METH_KEYWORDS, "\n" - "Build a new Linux guest OS.\n" -Index: build-32-release304-13087/tools/python/xen/xend/image.py -=================================================================== ---- build-32-release304-13087.orig/tools/python/xen/xend/image.py -+++ build-32-release304-13087/tools/python/xen/xend/image.py -@@ -181,6 +181,35 @@ class ImageHandler: - pass - - -+class OldLinuxImageHandler(ImageHandler): -+ -+ ostype = "linux" -+ -+ def buildDomain(self): -+ store_evtchn = self.vm.getStorePort() -+ console_evtchn = self.vm.getConsolePort() -+ -+ mem_mb = self.getRequiredInitialReservation() / 1024 -+ -+ log.debug("domid = %d", self.vm.getDomid()) -+ log.debug("memsize = %d", mem_mb) -+ log.debug("image = %s", self.kernel) -+ log.debug("store_evtchn = %d", store_evtchn) -+ log.debug("console_evtchn = %d", console_evtchn) -+ log.debug("cmdline = %s", self.cmdline) -+ log.debug("ramdisk = %s", self.ramdisk) -+ log.debug("vcpus = %d", self.vm.getVCpuCount()) -+ log.debug("features = %s", self.vm.getFeatures()) -+ -+ return xc.old_linux_build(domid = self.vm.getDomid(), -+ memsize = mem_mb, -+ image = self.kernel, -+ store_evtchn = store_evtchn, -+ console_evtchn = console_evtchn, -+ cmdline = self.cmdline, -+ ramdisk = self.ramdisk, -+ features = self.vm.getFeatures()) -+ - class LinuxImageHandler(ImageHandler): - - ostype = "linux" -@@ -625,6 +654,15 @@ class X86_Linux_ImageHandler(LinuxImageH - xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) - return LinuxImageHandler.buildDomain(self) - -+class X86_OldLinux_ImageHandler(OldLinuxImageHandler): -+ -+ def buildDomain(self): -+ # set physical mapping limit -+ # add an 8MB slack to balance backend allocations. -+ mem_kb = self.getRequiredInitialReservation() + (8 * 1024) -+ xc.domain_set_memmap_limit(self.vm.getDomid(), mem_kb) -+ return OldLinuxImageHandler.buildDomain(self) -+ - _handlers = { - "powerpc": { - "linux": PPC_LinuxImageHandler, -@@ -632,10 +670,12 @@ _handlers = { - }, - "ia64": { - "linux": LinuxImageHandler, -+ "old": OldLinuxImageHandler, - "hvm": IA64_HVM_ImageHandler, - }, - "x86": { - "linux": X86_Linux_ImageHandler, -+ "old": X86_OldLinux_ImageHandler, - "hvm": X86_HVM_ImageHandler, - }, - } diff --git a/tools-domain-builder-core.diff b/tools-domain-builder-core.diff deleted file mode 100644 index 0fe9235..0000000 --- a/tools-domain-builder-core.diff +++ /dev/null @@ -1,3066 +0,0 @@ -libxc domain builder rewrite, core bits. - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/Makefile | 14 - tools/libxc/xc_dom.h | 261 +++++++++++++ - tools/libxc/xc_dom_binloader.c | 294 +++++++++++++++ - tools/libxc/xc_dom_boot.c | 592 +++++++++++++++++++++++++++++++ - tools/libxc/xc_dom_core.c | 776 +++++++++++++++++++++++++++++++++++++++++ - tools/libxc/xc_dom_elfloader.c | 283 ++++++++++++++ - tools/libxc/xc_dom_ia64.c | 119 ++++++ - tools/libxc/xc_dom_powerpc64.c | 100 +++++ - tools/libxc/xc_dom_x86.c | 561 +++++++++++++++++++++++++++++ - 9 files changed, 3000 insertions(+) - -Index: build-32-release304-13138/tools/libxc/Makefile -=================================================================== ---- build-32-release304-13138.orig/tools/libxc/Makefile -+++ build-32-release304-13138/tools/libxc/Makefile -@@ -44,6 +44,20 @@ $(LIBELF_SRCS) libelf-private.h: - # add libelf bits to libxc - GUEST_SRCS-y += $(LIBELF_SRCS) - -+# new domain builder -+GUEST_SRCS-y += xc_dom_core.c xc_dom_boot.c -+GUEST_SRCS-y += xc_dom_elfloader.c -+GUEST_SRCS-y += xc_dom_binloader.c -+ -+ifeq ($(CONFIG_POWERPC),y) -+# big endian boxes -+GUEST_SRCS-y += xc_dom_powerpc64.c -+else -+# little endian boxes -+GUEST_SRCS-y += xc_dom_x86.c -+GUEST_SRCS-y += xc_dom_ia64.c -+endif -+ - -include $(XEN_TARGET_ARCH)/Makefile - - CFLAGS += -Werror -Wmissing-prototypes -Index: build-32-release304-13138/tools/libxc/xc_dom.h -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom.h -@@ -0,0 +1,261 @@ -+#include -+ -+#define INVALID_P2M_ENTRY ((xen_pfn_t)-1) -+ -+/* --- typedefs and structs ---------------------------------------- */ -+ -+typedef uint64_t xen_vaddr_t; -+typedef uint64_t xen_paddr_t; -+ -+/* FIXME: temporary hack ... */ -+#ifndef PRIpfn -+#define PRIpfn "lx" -+#endif -+ -+struct xc_dom_seg { -+ xen_vaddr_t vstart; -+ xen_vaddr_t vend; -+ xen_pfn_t pfn; -+}; -+ -+struct xc_dom_mem { -+ struct xc_dom_mem *next; -+ void *mmap_ptr; -+ size_t mmap_len; -+ unsigned char memory[0]; -+}; -+ -+struct xc_dom_phys { -+ struct xc_dom_phys *next; -+ void *ptr; -+ xen_pfn_t first; -+ xen_pfn_t count; -+}; -+ -+struct xc_dom_image { -+ /* files */ -+ void *kernel_blob; -+ size_t kernel_size; -+ void *ramdisk_blob; -+ size_t ramdisk_size; -+ -+ /* arguments and parameters */ -+ char *cmdline; -+ uint32_t f_requested[XENFEAT_NR_SUBMAPS]; -+ -+ /* info from (elf) kernel image */ -+ struct elf_dom_parms parms; -+ char *guest_type; -+ -+ /* memory layout */ -+ struct xc_dom_seg kernel_seg; -+ struct xc_dom_seg ramdisk_seg; -+ struct xc_dom_seg p2m_seg; -+ struct xc_dom_seg pgtables_seg; -+ xen_pfn_t start_info_pfn; -+ xen_pfn_t console_pfn; -+ xen_pfn_t xenstore_pfn; -+ xen_pfn_t shared_info_pfn; -+ xen_pfn_t bootstack_pfn; -+ xen_vaddr_t virt_alloc_end; -+ xen_vaddr_t bsd_symtab_start; -+ -+ /* initial page tables */ -+ unsigned int pgtables; -+ unsigned int pg_l4; -+ unsigned int pg_l3; -+ unsigned int pg_l2; -+ unsigned int pg_l1; -+ unsigned int alloc_bootstack; -+ unsigned int extra_pages; -+ xen_vaddr_t virt_pgtab_end; -+ -+ /* other state info */ -+ uint32_t f_active[XENFEAT_NR_SUBMAPS]; -+ xen_pfn_t *p2m_host; -+ void *p2m_guest; -+ -+ /* physical memory */ -+ xen_pfn_t total_pages; -+ struct xc_dom_phys *phys_pages; -+ -+ /* malloc memory pool */ -+ struct xc_dom_mem *memblocks; -+ -+ /* memory footprint stats */ -+ size_t alloc_malloc; -+ size_t alloc_mem_map; -+ size_t alloc_file_map; -+ size_t alloc_domU_map; -+ -+ /* misc xen domain config stuff */ -+ unsigned long flags; -+ unsigned int console_evtchn; -+ unsigned int xenstore_evtchn; -+ xen_pfn_t shared_info_mfn; -+ -+ int guest_xc; -+ domid_t guest_domid; -+ int shadow_enabled; -+ -+ int xen_version; -+ xen_capabilities_info_t xen_caps; -+ -+ /* kernel loader, arch hooks */ -+ struct xc_dom_loader *kernel_loader; -+ void *private_loader; -+ -+ /* kernel loader */ -+ struct xc_dom_arch *arch_hooks; -+}; -+ -+/* --- pluggable kernel loader ------------------------------------- */ -+ -+struct xc_dom_loader { -+ char *name; -+ int (*probe) (struct xc_dom_image * dom); -+ int (*parser) (struct xc_dom_image * dom); -+ int (*loader) (struct xc_dom_image * dom); -+ -+ struct xc_dom_loader *next; -+}; -+ -+#define __init __attribute__ ((constructor)) -+void xc_dom_register_loader(struct xc_dom_loader *loader); -+ -+/* --- arch specific hooks ----------------------------------------- */ -+ -+struct xc_dom_arch { -+ /* pagetable setup */ -+ int (*alloc_magic_pages) (struct xc_dom_image * dom); -+ int (*count_pgtables) (struct xc_dom_image * dom); -+ int (*setup_pgtables) (struct xc_dom_image * dom); -+ -+ /* arch-specific data structs setup */ -+ int (*start_info) (struct xc_dom_image * dom); -+ int (*shared_info) (struct xc_dom_image * dom, void *shared_info); -+ int (*vcpu) (struct xc_dom_image * dom, void *vcpu_ctxt); -+ -+ char *guest_type; -+ int page_shift; -+ int sizeof_pfn; -+ -+ struct xc_dom_arch *next; -+}; -+void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks); -+ -+#define XC_DOM_PAGE_SHIFT(dom) ((dom)->arch_hooks->page_shift) -+#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks->page_shift) -+ -+/* --- main functions ---------------------------------------------- */ -+ -+struct xc_dom_image *xc_dom_allocate(const char *cmdline, const char *features); -+void xc_dom_release_phys(struct xc_dom_image *dom); -+void xc_dom_release(struct xc_dom_image *dom); -+int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb); -+ -+size_t xc_dom_check_gzip(void *blob, size_t ziplen); -+int xc_dom_do_gunzip(void *src, size_t srclen, void *dst, size_t dstlen); -+int xc_dom_try_gunzip(struct xc_dom_image *dom, void **blob, size_t * size); -+ -+int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename); -+int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename); -+int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem, -+ size_t memsize); -+int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem, -+ size_t memsize); -+ -+int xc_dom_parse_image(struct xc_dom_image *dom); -+int xc_dom_build_image(struct xc_dom_image *dom); -+int xc_dom_update_guest_p2m(struct xc_dom_image *dom); -+ -+int xc_dom_boot_xen_init(struct xc_dom_image *dom, int xc, domid_t domid); -+int xc_dom_boot_mem_init(struct xc_dom_image *dom); -+void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn, -+ xen_pfn_t count); -+int xc_dom_boot_image(struct xc_dom_image *dom); -+int xc_dom_compat_check(struct xc_dom_image *dom); -+ -+/* --- debugging bits ---------------------------------------------- */ -+ -+extern FILE *xc_dom_logfile; -+ -+void xc_dom_loginit(void); -+int xc_dom_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); -+int xc_dom_panic_func(const char *file, int line, xc_error_code err, -+ const char *fmt, ...) -+ __attribute__ ((format(printf, 4, 5))); -+#define xc_dom_panic(err, fmt, args...) \ -+ xc_dom_panic_func(__FILE__, __LINE__, err, fmt, ## args) -+#define xc_dom_trace(mark) \ -+ xc_dom_printf("%s:%d: trace %s\n", __FILE__, __LINE__, mark) -+ -+void xc_dom_log_memory_footprint(struct xc_dom_image *dom); -+ -+/* --- simple memory pool ------------------------------------------ */ -+ -+void *xc_dom_malloc(struct xc_dom_image *dom, size_t size); -+void *xc_dom_malloc_page_aligned(struct xc_dom_image *dom, size_t size); -+void *xc_dom_malloc_filemap(struct xc_dom_image *dom, -+ const char *filename, size_t * size); -+char *xc_dom_strdup(struct xc_dom_image *dom, const char *str); -+ -+/* --- alloc memory pool ------------------------------------------- */ -+ -+int xc_dom_alloc_page(struct xc_dom_image *dom, char *name); -+int xc_dom_alloc_segment(struct xc_dom_image *dom, -+ struct xc_dom_seg *seg, char *name, -+ xen_vaddr_t start, xen_vaddr_t size); -+ -+/* --- misc bits --------------------------------------------------- */ -+ -+void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t first, -+ xen_pfn_t count); -+void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn); -+void xc_dom_unmap_all(struct xc_dom_image *dom); -+ -+static inline void *xc_dom_seg_to_ptr(struct xc_dom_image *dom, -+ struct xc_dom_seg *seg) -+{ -+ xen_vaddr_t segsize = seg->vend - seg->vstart; -+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom); -+ xen_pfn_t pages = (segsize + page_size - 1) / page_size; -+ -+ return xc_dom_pfn_to_ptr(dom, seg->pfn, pages); -+} -+ -+static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom, -+ xen_vaddr_t vaddr) -+{ -+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom); -+ xen_pfn_t page = (vaddr - dom->parms.virt_base) / page_size; -+ unsigned int offset = (vaddr - dom->parms.virt_base) % page_size; -+ void *ptr = xc_dom_pfn_to_ptr(dom, page, 0); -+ -+ if (!ptr) -+ return NULL; -+ return ptr + offset; -+} -+ -+static inline int xc_dom_feature_translated(struct xc_dom_image *dom) -+{ -+ return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active); -+} -+ -+static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn) -+{ -+ if (dom->shadow_enabled) -+ return pfn; -+ return dom->p2m_host[pfn]; -+} -+ -+static inline xen_pfn_t xc_dom_p2m_guest(struct xc_dom_image *dom, -+ xen_pfn_t pfn) -+{ -+ if (xc_dom_feature_translated(dom)) -+ return pfn; -+ return dom->p2m_host[pfn]; -+} -+ -+/* --- arch bits --------------------------------------------------- */ -+ -Index: build-32-release304-13138/tools/libxc/xc_dom_boot.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_boot.c -@@ -0,0 +1,592 @@ -+/* -+ * Xen domain builder -- xen booter. -+ * -+ * This is the code which actually boots a fresh -+ * prepared domain image as xen guest domain. -+ * -+ * ==> this is the only domain bilder code piece -+ * where xen hypercalls are allowed <== -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+#include -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int setup_hypercall_page(struct xc_dom_image *dom) -+{ -+ DECLARE_DOMCTL; -+ xen_pfn_t pfn; -+ int rc; -+ -+ if (-1 == dom->parms.virt_hypercall) -+ return 0; -+ pfn = (dom->parms.virt_hypercall - dom->parms.virt_base) -+ >> XC_DOM_PAGE_SHIFT(dom); -+ -+ xc_dom_printf("%s: vaddr=0x%" PRIx64 " pfn=0x%" PRIpfn "\n", __FUNCTION__, -+ dom->parms.virt_hypercall, pfn); -+ domctl.cmd = XEN_DOMCTL_hypercall_init; -+ domctl.domain = dom->guest_domid; -+ domctl.u.hypercall_init.gmfn = xc_dom_p2m_guest(dom, pfn); -+ rc = do_domctl(dom->guest_xc, &domctl); -+ if (0 != rc) -+ xc_dom_panic(XC_INTERNAL_ERROR, "%s: HYPERCALL_INIT failed (rc=%d)\n", -+ __FUNCTION__, rc); -+ return rc; -+} -+ -+static int launch_vm(int xc, domid_t domid, void *ctxt) -+{ -+ DECLARE_DOMCTL; -+ int rc; -+ -+ xc_dom_printf("%s: called, ctxt=%p\n", __FUNCTION__, ctxt); -+ memset(&domctl, 0, sizeof(domctl)); -+ domctl.cmd = XEN_DOMCTL_setvcpucontext; -+ domctl.domain = domid; -+ domctl.u.vcpucontext.vcpu = 0; -+ set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); -+ rc = do_domctl(xc, &domctl); -+ if (0 != rc) -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: SETVCPUCONTEXT failed (rc=%d)\n", __FUNCTION__, rc); -+ return rc; -+} -+ -+static int clear_page(struct xc_dom_image *dom, xen_pfn_t pfn) -+{ -+ xen_pfn_t dst; -+ int rc; -+ -+ if (0 == pfn) -+ return 0; -+ -+ dst = xc_dom_p2m_host(dom, pfn); -+ xc_dom_printf("%s: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "\n", -+ __FUNCTION__, pfn, dst); -+ rc = xc_clear_domain_page(dom->guest_xc, dom->guest_domid, dst); -+ if (0 != rc) -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: xc_clear_domain_page failed (pfn 0x%" PRIpfn -+ ", rc=%d)\n", __FUNCTION__, pfn, rc); -+ return rc; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* arch stuff: x86 bits */ -+ -+#if defined(__i386__) || defined(__x86_64__) -+ -+static int x86_compat(int xc, domid_t domid, char *guest_type) -+{ -+#if defined(XEN_DOMCTL_set_address_size) -+ -+ /* stable api, 3.0.5 final */ -+ static const struct { -+ char *guest; -+ uint32_t size; -+ } types[] = { -+ { "xen-3.0-x86_32p", 32 }, -+ { "xen-3.0-x86_64", 64 }, -+ }; -+ DECLARE_DOMCTL; -+ int i,rc; -+ -+ memset(&domctl, 0, sizeof(domctl)); -+ domctl.domain = domid; -+ domctl.cmd = XEN_DOMCTL_set_address_size; -+ for (i = 0; i < sizeof(types)/sizeof(types[0]); i++) -+ if (0 == strcmp(types[i].guest, guest_type)) -+ domctl.u.address_size.size = types[i].size; -+ if (0 == domctl.u.address_size.size) -+ /* nothing to do */ -+ return 0; -+ -+ xc_dom_printf("%s: guest %s, address size %" PRId32 "\n", __FUNCTION__, -+ guest_type, domctl.u.address_size.size); -+ rc = do_domctl(xc, &domctl); -+ if (0 != rc) -+ xc_dom_printf("%s: warning: failed (rc=%d)\n", -+ __FUNCTION__, rc); -+ return rc; -+ -+#elif defined(XEN_DOMCTL_set_compat) -+ -+ /* temporary, 3.0.4 patches and 3.0.5 initial merge */ -+ static const struct { -+ char *guest; -+ unsigned long cmd; -+ } types[] = { -+ { "xen-3.0-x86_32p", XEN_DOMCTL_set_compat }, -+ { "xen-3.0-x86_64", XEN_DOMCTL_set_native }, -+ }; -+ DECLARE_DOMCTL; -+ int i,rc; -+ -+ memset(&domctl, 0, sizeof(domctl)); -+ domctl.domain = domid; -+ for (i = 0; i < sizeof(types)/sizeof(types[0]); i++) -+ if (0 == strcmp(types[i].guest, guest_type)) -+ domctl.cmd = types[i].cmd; -+ if (0 == domctl.cmd) -+ /* nothing to do */ -+ return 0; -+ -+ xc_dom_printf("%s: guest %s, cmd %d\n", __FUNCTION__, -+ guest_type, domctl.cmd); -+ rc = do_domctl(xc, &domctl); -+ if (0 != rc) -+ xc_dom_printf("%s: warning: failed (rc=%d)\n", -+ __FUNCTION__, rc); -+ return rc; -+ -+#else -+#warn compiling without compat/native switching -+ xc_dom_printf("%s: compiled without compat/native switching\n", __FUNCTION__); -+ return 0; -+#endif -+} -+ -+ -+static int x86_shadow(int xc, domid_t domid) -+{ -+ int rc, mode; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ mode = XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT | -+ XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE; -+ -+ rc = xc_shadow_control(xc, domid, -+ XEN_DOMCTL_SHADOW_OP_ENABLE, -+ NULL, 0, NULL, mode, NULL); -+ if (0 != rc) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: SHADOW_OP_ENABLE (mode=0x%x) failed (rc=%d)\n", -+ __FUNCTION__, mode, rc); -+ return rc; -+ } -+ xc_dom_printf("%s: shadow enabled (mode=0x%x)\n", __FUNCTION__, mode); -+ return rc; -+} -+ -+static int arch_setup_meminit(struct xc_dom_image *dom) -+{ -+ int rc = 0; -+ -+ x86_compat(dom->guest_xc, dom->guest_domid, dom->guest_type); -+ if (xc_dom_feature_translated(dom)) -+ { -+ dom->shadow_enabled = 1; -+ rc = x86_shadow(dom->guest_xc, dom->guest_domid); -+ } -+ return rc; -+} -+ -+static int arch_setup_bootearly(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootlate(struct xc_dom_image *dom) -+{ -+ static const struct { -+ char *guest; -+ unsigned long pgd_type; -+ } types[] = { -+ { "xen-3.0-x86_32", MMUEXT_PIN_L2_TABLE}, -+ { "xen-3.0-x86_32p", MMUEXT_PIN_L3_TABLE}, -+ { "xen-3.0-x86_64", MMUEXT_PIN_L4_TABLE}, -+ }; -+ unsigned long pgd_type = 0; -+ shared_info_t *shared_info; -+ xen_pfn_t shinfo; -+ int i, rc; -+ -+ for (i = 0; i < sizeof(types) / sizeof(types[0]); i++) -+ if (0 == strcmp(types[i].guest, dom->guest_type)) -+ pgd_type = types[i].pgd_type; -+ -+ if (!xc_dom_feature_translated(dom)) -+ { -+ /* paravirtualized guest */ -+ xc_dom_unmap_one(dom, dom->pgtables_seg.pfn); -+ rc = pin_table(dom->guest_xc, pgd_type, -+ xc_dom_p2m_host(dom, dom->pgtables_seg.pfn), -+ dom->guest_domid); -+ if (0 != rc) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: pin_table failed (pfn 0x%" PRIpfn ", rc=%d)\n", -+ __FUNCTION__, dom->pgtables_seg.pfn, rc); -+ return rc; -+ } -+ shinfo = dom->shared_info_mfn; -+ } -+ else -+ { -+ /* paravirtualized guest with auto-translation */ -+ struct xen_add_to_physmap xatp; -+ int i; -+ -+ /* Map shared info frame into guest physmap. */ -+ xatp.domid = dom->guest_domid; -+ xatp.space = XENMAPSPACE_shared_info; -+ xatp.idx = 0; -+ xatp.gpfn = dom->shared_info_pfn; -+ rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp); -+ if (rc != 0) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, "%s: mapping shared_info failed " -+ "(pfn=0x%" PRIpfn ", rc=%d)\n", -+ __FUNCTION__, xatp.gpfn, rc); -+ return rc; -+ } -+ -+ /* Map grant table frames into guest physmap. */ -+ for (i = 0;; i++) -+ { -+ xatp.domid = dom->guest_domid; -+ xatp.space = XENMAPSPACE_grant_table; -+ xatp.idx = i; -+ xatp.gpfn = dom->total_pages + i; -+ rc = xc_memory_op(dom->guest_xc, XENMEM_add_to_physmap, &xatp); -+ if (rc != 0) -+ { -+ if (i > 0 && errno == EINVAL) -+ { -+ xc_dom_printf("%s: %d grant tables mapped\n", __FUNCTION__, -+ i); -+ break; -+ } -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: mapping grant tables failed " "(pfn=0x%" -+ PRIpfn ", rc=%d)\n", __FUNCTION__, xatp.gpfn, rc); -+ return rc; -+ } -+ } -+ shinfo = dom->shared_info_pfn; -+ } -+ -+ /* setup shared_info page */ -+ xc_dom_printf("%s: shared_info: pfn 0x%" PRIpfn ", mfn 0x%" PRIpfn "\n", -+ __FUNCTION__, dom->shared_info_pfn, dom->shared_info_mfn); -+ shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid, -+ PAGE_SIZE_X86, -+ PROT_READ | PROT_WRITE, -+ shinfo); -+ if (NULL == shared_info) -+ return -1; -+ dom->arch_hooks->shared_info(dom, shared_info); -+ munmap(shared_info, PAGE_SIZE_X86); -+ -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* arch stuff: ia64 */ -+ -+#elif defined(__ia64__) -+ -+static int arch_setup_meminit(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootearly(struct xc_dom_image *dom) -+{ -+ DECLARE_DOMCTL; -+ int rc; -+ -+ xc_dom_printf("%s: setup firmware\n", __FUNCTION__); -+ -+ memset(&domctl, 0, sizeof(domctl)); -+ domctl.cmd = XEN_DOMCTL_arch_setup; -+ domctl.domain = dom->guest_domid; -+ domctl.u.arch_setup.flags = 0; -+ -+ domctl.u.arch_setup.bp = (dom->start_info_pfn << PAGE_SHIFT) -+ + sizeof(start_info_t); -+ /* 3 = start info page, xenstore page and console page */ -+ domctl.u.arch_setup.maxmem = (dom->total_pages - 3) << PAGE_SHIFT; -+ rc = do_domctl(dom->guest_xc, &domctl); -+ return rc; -+} -+ -+static int arch_setup_bootlate(struct xc_dom_image *dom) -+{ -+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom); -+ shared_info_t *shared_info; -+ -+ /* setup shared_info page */ -+ xc_dom_printf("%s: shared_info: mfn 0x%" PRIpfn "\n", -+ __FUNCTION__, dom->shared_info_mfn); -+ shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid, -+ page_size, -+ PROT_READ | PROT_WRITE, -+ dom->shared_info_mfn); -+ if (NULL == shared_info) -+ return -1; -+ dom->arch_hooks->shared_info(dom, shared_info); -+ munmap(shared_info, page_size); -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* arch stuff: powerpc */ -+ -+#elif defined(__powerpc64__) -+ -+static int arch_setup_meminit(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootearly(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootlate(struct xc_dom_image *dom) -+{ -+ start_info_t *si = -+ xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); -+ -+ xc_dom_printf("%s: TODO: setup devtree\n", __FUNCTION__); -+ -+#if 0 -+ load_devtree(dom->guest_xc, -+ dom->guest_domid, -+ dom->p2m_host, -+ devtree, // FIXME -+ devtree_addr, // FIXME -+ dom->ramdisk_seg.vstart, -+ dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart, -+ si, -+ dom->start_info_pfn << PAGE_SHIFT); -+#endif -+ return rc; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* arch stuff: other */ -+ -+#else -+ -+static int arch_setup_meminit(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootearly(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+static int arch_setup_bootlate(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__); -+ return 0; -+} -+ -+#endif /* arch stuff */ -+ -+/* ------------------------------------------------------------------------ */ -+ -+int xc_dom_compat_check(struct xc_dom_image *dom) -+{ -+ xen_capabilities_info_t xen_caps; -+ char *item, *ptr; -+ int match, found = 0; -+ -+ strcpy(xen_caps, dom->xen_caps); -+ for (item = strtok_r(xen_caps, " ", &ptr); -+ NULL != item; item = strtok_r(NULL, " ", &ptr)) -+ { -+ match = (0 == strcmp(dom->guest_type, item)); -+ xc_dom_printf("%s: supported guest type: %s%s\n", __FUNCTION__, -+ item, match ? " <= matches" : ""); -+ if (match) -+ found++; -+ } -+ if (!found) -+ xc_dom_panic(XC_INVALID_KERNEL, -+ "%s: guest type %s not supported by xen kernel, sorry\n", -+ __FUNCTION__, dom->guest_type); -+ -+ return found; -+} -+ -+int xc_dom_boot_xen_init(struct xc_dom_image *dom, int xc, domid_t domid) -+{ -+ dom->guest_xc = xc; -+ dom->guest_domid = domid; -+ -+ dom->xen_version = xc_version(dom->guest_xc, XENVER_version, NULL); -+ if (xc_version(xc, XENVER_capabilities, &dom->xen_caps) < 0) { -+ xc_dom_panic(XC_INTERNAL_ERROR, "can't get xen capabilities"); -+ return -1; -+ } -+ xc_dom_printf("%s: ver %d.%d, caps %s\n", __FUNCTION__, -+ dom->xen_version >> 16, dom->xen_version & 0xff, -+ dom->xen_caps); -+ return 0; -+} -+ -+int xc_dom_boot_mem_init(struct xc_dom_image *dom) -+{ -+ long rc; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ if (0 != (rc = arch_setup_meminit(dom))) -+ return rc; -+ -+ /* allocate guest memory */ -+ rc = xc_domain_memory_populate_physmap(dom->guest_xc, dom->guest_domid, -+ dom->total_pages, 0, 0, -+ dom->p2m_host); -+ if (0 != rc) -+ { -+ xc_dom_panic(XC_OUT_OF_MEMORY, -+ "%s: can't allocate low memory for domain\n", -+ __FUNCTION__); -+ return rc; -+ } -+ -+ return 0; -+} -+ -+void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn, -+ xen_pfn_t count) -+{ -+ int page_shift = XC_DOM_PAGE_SHIFT(dom); -+ privcmd_mmap_entry_t *entries; -+ void *ptr; -+ int i, rc; -+ -+ entries = xc_dom_malloc(dom, count * sizeof(privcmd_mmap_entry_t)); -+ if (NULL == entries) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn -+ " [malloc]\n", __FUNCTION__, pfn, count); -+ return NULL; -+ } -+ -+ ptr = mmap(NULL, count << page_shift, PROT_READ | PROT_WRITE, -+ MAP_SHARED, dom->guest_xc, 0); -+ if (MAP_FAILED == ptr) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn -+ " [mmap]\n", __FUNCTION__, pfn, count); -+ return NULL; -+ } -+ -+ for (i = 0; i < count; i++) -+ { -+ entries[i].va = (uintptr_t) ptr + (i << page_shift); -+ entries[i].mfn = xc_dom_p2m_host(dom, pfn + i); -+ entries[i].npages = 1; -+ } -+ -+ rc = xc_map_foreign_ranges(dom->guest_xc, dom->guest_domid, entries, count); -+ if (rc < 0) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn -+ " [xenctl, rc=%d]\n", __FUNCTION__, pfn, count, rc); -+ return NULL; -+ } -+ return ptr; -+} -+ -+int xc_dom_boot_image(struct xc_dom_image *dom) -+{ -+ DECLARE_DOMCTL; -+ void *ctxt; -+ int rc; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* misc ia64 stuff*/ -+ if (0 != (rc = arch_setup_bootearly(dom))) -+ return rc; -+ -+ /* collect some info */ -+ domctl.cmd = XEN_DOMCTL_getdomaininfo; -+ domctl.domain = dom->guest_domid; -+ rc = do_domctl(dom->guest_xc, &domctl); -+ if (0 != rc) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: getdomaininfo failed (rc=%d)\n", __FUNCTION__, rc); -+ return rc; -+ } -+ if (domctl.domain != dom->guest_domid) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: Huh? domid mismatch (%d != %d)\n", __FUNCTION__, -+ domctl.domain, dom->guest_domid); -+ return -1; -+ } -+ dom->shared_info_mfn = domctl.u.getdomaininfo.shared_info_frame; -+ -+ /* sanity checks */ -+ if (!xc_dom_compat_check(dom)) -+ return -1; -+ -+ /* initial mm setup */ -+ if (0 != (rc = xc_dom_update_guest_p2m(dom))) -+ return rc; -+ if (dom->arch_hooks->setup_pgtables) -+ if (0 != (rc = dom->arch_hooks->setup_pgtables(dom))) -+ return rc; -+ -+ if (0 != (rc = clear_page(dom, dom->console_pfn))) -+ return rc; -+ if (0 != (rc = clear_page(dom, dom->xenstore_pfn))) -+ return rc; -+ -+ /* start info page */ -+ if (dom->arch_hooks->start_info) -+ dom->arch_hooks->start_info(dom); -+ -+ /* hypercall page */ -+ if (0 != (rc = setup_hypercall_page(dom))) -+ return rc; -+ xc_dom_log_memory_footprint(dom); -+ -+ /* misc x86 stuff */ -+ if (0 != (rc = arch_setup_bootlate(dom))) -+ return rc; -+ -+ /* let the vm run */ -+ ctxt = xc_dom_malloc(dom, PAGE_SIZE * 2 /* FIXME */ ); -+ memset(ctxt, 0, PAGE_SIZE * 2); -+ if (0 != (rc = dom->arch_hooks->vcpu(dom, ctxt))) -+ return rc; -+ xc_dom_unmap_all(dom); -+ rc = launch_vm(dom->guest_xc, dom->guest_domid, ctxt); -+ -+ return rc; -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_core.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_core.c -@@ -0,0 +1,776 @@ -+/* -+ * Xen domain builder -- core bits. -+ * -+ * The core code goes here: -+ * - allocate and release domain structs. -+ * - memory management functions. -+ * - misc helper functions. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+/* ------------------------------------------------------------------------ */ -+/* debugging */ -+ -+FILE *xc_dom_logfile = NULL; -+ -+void xc_dom_loginit(void) -+{ -+ if (xc_dom_logfile) -+ return; -+ xc_dom_logfile = fopen("/var/log/xen/domain-builder-ng.log", "a"); -+ setvbuf(xc_dom_logfile, NULL, _IONBF, 0); -+ xc_dom_printf("### ----- xc domain builder logfile opened -----\n"); -+} -+ -+int xc_dom_printf(const char *fmt, ...) -+{ -+ va_list args; -+ char buf[1024]; -+ int rc; -+ -+ if (!xc_dom_logfile) -+ return 0; -+ -+ va_start(args, fmt); -+ rc = vsnprintf(buf, sizeof(buf), fmt, args); -+ va_end(args); -+ rc = fwrite(buf, rc, 1, xc_dom_logfile); -+ -+ return rc; -+} -+ -+int xc_dom_panic_func(const char *file, int line, xc_error_code err, -+ const char *fmt, ...) -+{ -+ va_list args; -+ FILE *fp = stderr; -+ int rc = 0; -+ char pos[256]; -+ char msg[XC_MAX_ERROR_MSG_LEN]; -+ -+ if (xc_dom_logfile) -+ fp = xc_dom_logfile; -+ -+ snprintf(pos, sizeof(pos), "%s:%d: panic: ", file, line); -+ va_start(args, fmt); -+ vsnprintf(msg, sizeof(msg), fmt, args); -+ va_end(args); -+ xc_set_error(err, "%s", msg); -+ rc = fprintf(fp, "%s%s", pos, msg); -+ return rc; -+} -+ -+static void print_mem(const char *name, size_t mem) -+{ -+ if (mem > 32 * 1024 * 1024) -+ xc_dom_printf("%-24s : %zd MB\n", name, mem / (1024 * 1024)); -+ else if (mem > 32 * 1024) -+ xc_dom_printf("%-24s : %zd kB\n", name, mem / 1024); -+ else -+ xc_dom_printf("%-24s : %zd bytes\n", name, mem); -+} -+ -+void xc_dom_log_memory_footprint(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("domain builder memory footprint\n"); -+ xc_dom_printf(" allocated\n"); -+ print_mem(" malloc", dom->alloc_malloc); -+ print_mem(" anon mmap", dom->alloc_mem_map); -+ xc_dom_printf(" mapped\n"); -+ print_mem(" file mmap", dom->alloc_file_map); -+ print_mem(" domU mmap", dom->alloc_domU_map); -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* simple memory pool */ -+ -+void *xc_dom_malloc(struct xc_dom_image *dom, size_t size) -+{ -+ struct xc_dom_mem *block; -+ -+ block = malloc(sizeof(*block) + size); -+ if (NULL == block) -+ return NULL; -+ memset(block, 0, sizeof(*block) + size); -+ block->next = dom->memblocks; -+ dom->memblocks = block; -+ dom->alloc_malloc += sizeof(*block) + size; -+ if (size > 100 * 1024) -+ print_mem(__FUNCTION__, size); -+ return block->memory; -+} -+ -+void *xc_dom_malloc_page_aligned(struct xc_dom_image *dom, size_t size) -+{ -+ struct xc_dom_mem *block; -+ -+ block = malloc(sizeof(*block)); -+ if (NULL == block) -+ return NULL; -+ memset(block, 0, sizeof(*block)); -+ block->mmap_len = size; -+ block->mmap_ptr = mmap(NULL, block->mmap_len, -+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -+ -1, 0); -+ if (MAP_FAILED == block->mmap_ptr) -+ { -+ free(block); -+ return NULL; -+ } -+ block->next = dom->memblocks; -+ dom->memblocks = block; -+ dom->alloc_malloc += sizeof(*block); -+ dom->alloc_mem_map += block->mmap_len; -+ if (size > 100 * 1024) -+ print_mem(__FUNCTION__, size); -+ return block->mmap_ptr; -+} -+ -+void *xc_dom_malloc_filemap(struct xc_dom_image *dom, -+ const char *filename, size_t * size) -+{ -+ struct xc_dom_mem *block = NULL; -+ int fd = -1; -+ -+ fd = open(filename, O_RDONLY); -+ if (-1 == fd) -+ goto err; -+ -+ lseek(fd, 0, SEEK_SET); -+ *size = lseek(fd, 0, SEEK_END); -+ -+ block = malloc(sizeof(*block)); -+ if (NULL == block) -+ goto err; -+ memset(block, 0, sizeof(*block)); -+ block->mmap_len = *size; -+ block->mmap_ptr = mmap(NULL, block->mmap_len, PROT_READ, MAP_SHARED, fd, 0); -+ if (MAP_FAILED == block->mmap_ptr) -+ goto err; -+ block->next = dom->memblocks; -+ dom->memblocks = block; -+ dom->alloc_malloc += sizeof(*block); -+ dom->alloc_file_map += block->mmap_len; -+ close(fd); -+ if (*size > 100 * 1024) -+ print_mem(__FUNCTION__, *size); -+ return block->mmap_ptr; -+ -+ err: -+ if (-1 != fd) -+ close(fd); -+ if (block) -+ free(block); -+ return NULL; -+} -+ -+static void xc_dom_free_all(struct xc_dom_image *dom) -+{ -+ struct xc_dom_mem *block; -+ -+ while (NULL != (block = dom->memblocks)) -+ { -+ dom->memblocks = block->next; -+ if (block->mmap_ptr) -+ munmap(block->mmap_ptr, block->mmap_len); -+ free(block); -+ } -+} -+ -+char *xc_dom_strdup(struct xc_dom_image *dom, const char *str) -+{ -+ size_t len = strlen(str) + 1; -+ char *nstr = xc_dom_malloc(dom, len); -+ -+ if (NULL == nstr) -+ return NULL; -+ memcpy(nstr, str, len); -+ return nstr; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* read files, copy memory blocks, with transparent gunzip */ -+ -+size_t xc_dom_check_gzip(void *blob, size_t ziplen) -+{ -+ unsigned char *gzlen; -+ size_t unziplen; -+ -+ if (0 != strncmp(blob, "\037\213", 2)) -+ /* not gzipped */ -+ return 0; -+ -+ gzlen = blob + ziplen - 4; -+ unziplen = gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0]; -+ if (unziplen < ziplen || unziplen > ziplen * 8) -+ { -+ xc_dom_printf -+ ("%s: size (zip %zd, unzip %zd) looks insane, skip gunzip\n", -+ __FUNCTION__, ziplen, unziplen); -+ return 0; -+ } -+ -+ return unziplen + 16; -+} -+ -+int xc_dom_do_gunzip(void *src, size_t srclen, void *dst, size_t dstlen) -+{ -+ z_stream zStream; -+ int rc; -+ -+ memset(&zStream, 0, sizeof(zStream)); -+ zStream.next_in = src; -+ zStream.avail_in = srclen; -+ zStream.next_out = dst; -+ zStream.avail_out = dstlen; -+ rc = inflateInit2(&zStream, (MAX_WBITS + 32)); /* +32 means "handle gzip" */ -+ if (rc != Z_OK) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: inflateInit2 failed (rc=%d)\n", __FUNCTION__, rc); -+ return -1; -+ } -+ rc = inflate(&zStream, Z_FINISH); -+ if (rc != Z_STREAM_END) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: inflate failed (rc=%d)\n", __FUNCTION__, rc); -+ return -1; -+ } -+ -+ xc_dom_printf("%s: unzip ok, 0x%zx -> 0x%zx\n", -+ __FUNCTION__, srclen, dstlen); -+ return 0; -+} -+ -+int xc_dom_try_gunzip(struct xc_dom_image *dom, void **blob, size_t * size) -+{ -+ void *unzip; -+ size_t unziplen; -+ -+ unziplen = xc_dom_check_gzip(*blob, *size); -+ if (0 == unziplen) -+ return 0; -+ -+ unzip = xc_dom_malloc(dom, unziplen); -+ if (NULL == unzip) -+ return -1; -+ -+ if (-1 == xc_dom_do_gunzip(*blob, *size, unzip, unziplen)) -+ return -1; -+ -+ *blob = unzip; -+ *size = unziplen; -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* domain memory */ -+ -+void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, -+ xen_pfn_t count) -+{ -+ struct xc_dom_phys *phys; -+ unsigned int page_shift = XC_DOM_PAGE_SHIFT(dom); -+ char *mode = "unset"; -+ -+ if (pfn > dom->total_pages) -+ { -+ xc_dom_printf("%s: pfn out of range (0x%" PRIpfn " > 0x%" PRIpfn ")\n", -+ __FUNCTION__, pfn, dom->total_pages); -+ return NULL; -+ } -+ -+ /* already allocated? */ -+ for (phys = dom->phys_pages; NULL != phys; phys = phys->next) -+ { -+ if (pfn >= phys->first + phys->count) -+ continue; -+ if (count) -+ { -+ /* size given: must be completely within the already allocated block */ -+ if (pfn + count <= phys->first) -+ continue; -+ if (pfn < phys->first || pfn + count > phys->first + phys->count) -+ { -+ xc_dom_printf("%s: request overlaps allocated block" -+ " (req 0x%" PRIpfn "+0x%" PRIpfn "," -+ " blk 0x%" PRIpfn "+0x%" PRIpfn ")\n", -+ __FUNCTION__, pfn, count, phys->first, -+ phys->count); -+ return NULL; -+ } -+ } -+ else -+ { -+ /* no size given: block must be allocated already, -+ just hand out a pointer to it */ -+ if (pfn < phys->first) -+ continue; -+ } -+ return phys->ptr + ((pfn - phys->first) << page_shift); -+ } -+ -+ /* allocating is allowed with size specified only */ -+ if (0 == count) -+ { -+ xc_dom_printf("%s: no block found, no size given," -+ " can't malloc (pfn 0x%" PRIpfn ")\n", __FUNCTION__, pfn); -+ return NULL; -+ } -+ -+ /* not found, no overlap => allocate */ -+ phys = xc_dom_malloc(dom, sizeof(*phys)); -+ if (NULL == phys) -+ return NULL; -+ memset(phys, 0, sizeof(*phys)); -+ phys->first = pfn; -+ phys->count = count; -+ -+ if (dom->guest_domid) -+ { -+ mode = "domU mapping"; -+ phys->ptr = xc_dom_boot_domU_map(dom, phys->first, phys->count); -+ if (NULL == phys->ptr) -+ return NULL; -+ dom->alloc_domU_map += phys->count << page_shift; -+ } -+ else -+ { -+ mode = "anonymous memory"; -+ phys->ptr = mmap(NULL, phys->count << page_shift, -+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -+ -1, 0); -+ if (MAP_FAILED == phys->ptr) -+ { -+ xc_dom_panic(XC_OUT_OF_MEMORY, -+ "%s: oom: can't allocate 0x%" PRIpfn " pages\n", -+ __FUNCTION__, count); -+ return NULL; -+ } -+ dom->alloc_mem_map += phys->count << page_shift; -+ } -+ -+#if 1 -+ xc_dom_printf("%s: %s: pfn 0x%" PRIpfn "+0x%" PRIpfn " at %p\n", -+ __FUNCTION__, mode, phys->first, phys->count, phys->ptr); -+#endif -+ phys->next = dom->phys_pages; -+ dom->phys_pages = phys; -+ return phys->ptr; -+} -+ -+int xc_dom_alloc_segment(struct xc_dom_image *dom, -+ struct xc_dom_seg *seg, char *name, -+ xen_vaddr_t start, xen_vaddr_t size) -+{ -+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom); -+ xen_pfn_t pages = (size + page_size - 1) / page_size; -+ void *ptr; -+ -+ if (0 == start) -+ start = dom->virt_alloc_end; -+ -+ if (start & (page_size - 1)) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: segment start isn't page aligned (0x%" PRIx64 ")\n", -+ __FUNCTION__, start); -+ return -1; -+ } -+ if (start < dom->virt_alloc_end) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: segment start too low (0x%" PRIx64 " < 0x%" PRIx64 -+ ")\n", __FUNCTION__, start, dom->virt_alloc_end); -+ return -1; -+ } -+ -+ seg->vstart = start; -+ seg->vend = start + pages * page_size; -+ seg->pfn = (seg->vstart - dom->parms.virt_base) / page_size; -+ dom->virt_alloc_end = seg->vend; -+ -+ xc_dom_printf("%-20s: %-12s : 0x%" PRIx64 " -> 0x%" PRIx64 -+ " (pfn 0x%" PRIpfn " + 0x%" PRIpfn " pages)\n", -+ __FUNCTION__, name, seg->vstart, seg->vend, seg->pfn, pages); -+ -+ /* map and clear pages */ -+ ptr = xc_dom_seg_to_ptr(dom, seg); -+ if (NULL == ptr) -+ return -1; -+ memset(ptr, 0, pages * page_size); -+ -+ return 0; -+} -+ -+int xc_dom_alloc_page(struct xc_dom_image *dom, char *name) -+{ -+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom); -+ xen_vaddr_t start; -+ xen_pfn_t pfn; -+ -+ start = dom->virt_alloc_end; -+ dom->virt_alloc_end += page_size; -+ pfn = (start - dom->parms.virt_base) / page_size; -+ -+ xc_dom_printf("%-20s: %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")\n", -+ __FUNCTION__, name, start, pfn); -+ return pfn; -+} -+ -+void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn) -+{ -+ unsigned int page_shift = XC_DOM_PAGE_SHIFT(dom); -+ struct xc_dom_phys *phys, *prev = NULL; -+ -+ for (phys = dom->phys_pages; NULL != phys; phys = phys->next) -+ { -+ if (pfn >= phys->first && pfn < phys->first + phys->count) -+ break; -+ prev = phys; -+ } -+ if (!phys) -+ { -+ xc_dom_printf("%s: Huh? no mapping with pfn 0x%" PRIpfn "\n", -+ __FUNCTION__, pfn); -+ return; -+ } -+ -+ munmap(phys->ptr, phys->count << page_shift); -+ if (prev) -+ prev->next = phys->next; -+ else -+ dom->phys_pages = phys->next; -+} -+ -+void xc_dom_unmap_all(struct xc_dom_image *dom) -+{ -+ while (dom->phys_pages) -+ xc_dom_unmap_one(dom, dom->phys_pages->first); -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* pluggable kernel loaders */ -+ -+static struct xc_dom_loader *first_loader = NULL; -+static struct xc_dom_arch *first_hook = NULL; -+ -+void xc_dom_register_loader(struct xc_dom_loader *loader) -+{ -+ loader->next = first_loader; -+ first_loader = loader; -+} -+ -+static struct xc_dom_loader *xc_dom_find_loader(struct xc_dom_image *dom) -+{ -+ struct xc_dom_loader *loader = first_loader; -+ -+ while (NULL != loader) -+ { -+ xc_dom_printf("%s: trying %s loader ... ", __FUNCTION__, loader->name); -+ if (0 == loader->probe(dom)) -+ { -+ xc_dom_printf("OK\n"); -+ return loader; -+ } -+ xc_dom_printf("failed\n"); -+ loader = loader->next; -+ } -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: no loader found\n", __FUNCTION__); -+ return NULL; -+} -+ -+void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks) -+{ -+ hooks->next = first_hook; -+ first_hook = hooks; -+} -+ -+static struct xc_dom_arch *xc_dom_find_arch_hooks(char *guest_type) -+{ -+ struct xc_dom_arch *hooks = first_hook; -+ -+ while (NULL != hooks) -+ { -+ if (0 == strcmp(hooks->guest_type, guest_type)) -+ return hooks; -+ hooks = hooks->next; -+ } -+ xc_dom_panic(XC_INVALID_KERNEL, -+ "%s: not found (type %s)\n", __FUNCTION__, guest_type); -+ return NULL; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* public interface */ -+ -+void xc_dom_release(struct xc_dom_image *dom) -+{ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ if (dom->phys_pages) -+ xc_dom_unmap_all(dom); -+ xc_dom_free_all(dom); -+ free(dom); -+} -+ -+struct xc_dom_image *xc_dom_allocate(const char *cmdline, const char *features) -+{ -+ struct xc_dom_image *dom; -+ -+ xc_dom_printf("%s: cmdline=\"%s\", features=\"%s\"\n", -+ __FUNCTION__, cmdline, features); -+ dom = malloc(sizeof(*dom)); -+ if (!dom) -+ goto err; -+ -+ memset(dom, 0, sizeof(*dom)); -+ if (cmdline) -+ dom->cmdline = xc_dom_strdup(dom, cmdline); -+ if (features) -+ elf_xen_parse_features(features, dom->f_requested, NULL); -+ -+ dom->parms.virt_base = UNSET_ADDR; -+ dom->parms.virt_entry = UNSET_ADDR; -+ dom->parms.virt_hypercall = UNSET_ADDR; -+ dom->parms.virt_hv_start_low = UNSET_ADDR; -+ dom->parms.elf_paddr_offset = UNSET_ADDR; -+ -+ dom->alloc_malloc += sizeof(*dom); -+ return dom; -+ -+ err: -+ if (dom) -+ xc_dom_release(dom); -+ return NULL; -+} -+ -+int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename) -+{ -+ xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename); -+ dom->kernel_blob = xc_dom_malloc_filemap(dom, filename, &dom->kernel_size); -+ if (NULL == dom->kernel_blob) -+ return -1; -+ return xc_dom_try_gunzip(dom, &dom->kernel_blob, &dom->kernel_size); -+} -+ -+int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename) -+{ -+ xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename); -+ dom->ramdisk_blob = -+ xc_dom_malloc_filemap(dom, filename, &dom->ramdisk_size); -+ if (NULL == dom->ramdisk_blob) -+ return -1; -+// return xc_dom_try_gunzip(dom, &dom->ramdisk_blob, &dom->ramdisk_size); -+ return 0; -+} -+ -+int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem, size_t memsize) -+{ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ dom->kernel_blob = (void *)mem; -+ dom->kernel_size = memsize; -+ return xc_dom_try_gunzip(dom, &dom->kernel_blob, &dom->kernel_size); -+} -+ -+int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem, -+ size_t memsize) -+{ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ dom->ramdisk_blob = (void *)mem; -+ dom->ramdisk_size = memsize; -+// return xc_dom_try_gunzip(dom, &dom->ramdisk_blob, &dom->ramdisk_size); -+ return 0; -+} -+ -+int xc_dom_parse_image(struct xc_dom_image *dom) -+{ -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* parse kernel image */ -+ dom->kernel_loader = xc_dom_find_loader(dom); -+ if (NULL == dom->kernel_loader) -+ goto err; -+ if (0 != dom->kernel_loader->parser(dom)) -+ goto err; -+ if (NULL == dom->guest_type) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "%s: guest_type not set\n", __FUNCTION__); -+ goto err; -+ } -+ -+ /* check features */ -+ for (i = 0; i < XENFEAT_NR_SUBMAPS; i++) -+ { -+ dom->f_active[i] |= dom->f_requested[i]; /* cmd line */ -+ dom->f_active[i] |= dom->parms.f_required[i]; /* kernel */ -+ if ((dom->f_active[i] & dom->parms.f_supported[i]) != dom->f_active[i]) -+ { -+ xc_dom_panic(XC_INVALID_PARAM, -+ "%s: unsupported feature requested\n", __FUNCTION__); -+ goto err; -+ } -+ } -+ return 0; -+ -+ err: -+ return -1; -+} -+ -+int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb) -+{ -+ unsigned int page_shift; -+ xen_pfn_t nr_pages, pfn; -+ -+ dom->arch_hooks = xc_dom_find_arch_hooks(dom->guest_type); -+ if (NULL == dom->arch_hooks) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n", -+ __FUNCTION__); -+ return -1; -+ } -+ -+ page_shift = XC_DOM_PAGE_SHIFT(dom); -+ nr_pages = mem_mb << (20 - page_shift); -+ -+ xc_dom_printf("%s: mem %d MB, pages 0x%" PRIpfn " pages, %dk each\n", -+ __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10)); -+ dom->total_pages = nr_pages; -+ -+ xc_dom_printf("%s: 0x%" PRIpfn " pages\n", -+ __FUNCTION__, dom->total_pages); -+ -+ /* setup initial p2m */ -+ dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * dom->total_pages); -+ for (pfn = 0; pfn < dom->total_pages; pfn++) -+ dom->p2m_host[pfn] = pfn; -+ return 0; -+} -+ -+int xc_dom_update_guest_p2m(struct xc_dom_image *dom) -+{ -+ uint32_t *p2m_32; -+ uint64_t *p2m_64; -+ xen_pfn_t i; -+ -+ if (!dom->p2m_guest) -+ return 0; -+ -+ switch (dom->arch_hooks->sizeof_pfn) -+ { -+ case 4: -+ xc_dom_printf("%s: dst 32bit, pages 0x%" PRIpfn " \n", -+ __FUNCTION__, dom->total_pages); -+ p2m_32 = dom->p2m_guest; -+ for (i = 0; i < dom->total_pages; i++) -+ if (INVALID_P2M_ENTRY != dom->p2m_host[i]) -+ p2m_32[i] = dom->p2m_host[i]; -+ else -+ p2m_32[i] = (uint32_t) - 1; -+ break; -+ case 8: -+ xc_dom_printf("%s: dst 64bit, pages 0x%" PRIpfn " \n", -+ __FUNCTION__, dom->total_pages); -+ p2m_64 = dom->p2m_guest; -+ for (i = 0; i < dom->total_pages; i++) -+ if (INVALID_P2M_ENTRY != dom->p2m_host[i]) -+ p2m_64[i] = dom->p2m_host[i]; -+ else -+ p2m_64[i] = (uint64_t) - 1; -+ break; -+ default: -+ xc_dom_panic(XC_INTERNAL_ERROR, -+ "sizeof_pfn is invalid (is %d, can be 4 or 8)", -+ dom->arch_hooks->sizeof_pfn); -+ return -1; -+ } -+ return 0; -+} -+ -+int xc_dom_build_image(struct xc_dom_image *dom) -+{ -+ unsigned int page_size; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* check for arch hooks */ -+ if (NULL == dom->arch_hooks) -+ { -+ xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n", -+ __FUNCTION__); -+ goto err; -+ } -+ page_size = XC_DOM_PAGE_SIZE(dom); -+ -+ /* 4MB align virtual base address */ -+ dom->parms.virt_base &= ~(((uint64_t)1<<22)-1); -+ -+ /* load kernel */ -+ if (0 != xc_dom_alloc_segment(dom, &dom->kernel_seg, "kernel", -+ dom->kernel_seg.vstart, -+ dom->kernel_seg.vend - -+ dom->kernel_seg.vstart)) -+ goto err; -+ if (0 != dom->kernel_loader->loader(dom)) -+ goto err; -+ -+ /* load ramdisk */ -+ if (dom->ramdisk_blob) -+ { -+ size_t unziplen, ramdisklen; -+ void *ramdiskmap; -+ -+ unziplen = xc_dom_check_gzip(dom->ramdisk_blob, dom->ramdisk_size); -+ ramdisklen = unziplen ? unziplen : dom->ramdisk_size; -+ if (0 != xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk", 0, -+ ramdisklen)) -+ goto err; -+ ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg); -+ if (unziplen) -+ { -+ if (-1 == xc_dom_do_gunzip(dom->ramdisk_blob, dom->ramdisk_size, -+ ramdiskmap, ramdisklen)) -+ goto err; -+ } -+ else -+ memcpy(ramdiskmap, dom->ramdisk_blob, dom->ramdisk_size); -+ } -+ -+ /* allocate other pages */ -+ if (0 != dom->arch_hooks->alloc_magic_pages(dom)) -+ goto err; -+ if (dom->arch_hooks->count_pgtables) -+ { -+ dom->arch_hooks->count_pgtables(dom); -+ if (dom->pgtables > 0) -+ if (0 != -+ xc_dom_alloc_segment(dom, &dom->pgtables_seg, "page tables", 0, -+ dom->pgtables * page_size)) -+ goto err; -+ } -+ if (dom->alloc_bootstack) -+ dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack"); -+ xc_dom_printf("%-20s: virt_alloc_end : 0x%" PRIx64 "\n", -+ __FUNCTION__, dom->virt_alloc_end); -+ xc_dom_printf("%-20s: virt_pgtab_end : 0x%" PRIx64 "\n", -+ __FUNCTION__, dom->virt_pgtab_end); -+ return 0; -+ -+ err: -+ return -1; -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_ia64.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_ia64.c -@@ -0,0 +1,119 @@ -+/* -+ * Xen domain builder -- ia64 bits. -+ * -+ * Most architecture-specific code for ia64 goes here. -+ * - fill architecture-specific structs. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int alloc_magic_pages(struct xc_dom_image *dom) -+{ -+ /* allocate special pages */ -+ dom->console_pfn = dom->total_pages -1; -+ dom->xenstore_pfn = dom->total_pages -2; -+ dom->start_info_pfn = dom->total_pages -3; -+ return 0; -+} -+ -+static int start_info_ia64(struct xc_dom_image *dom) -+{ -+ start_info_ia64_t *start_info = -+ xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); -+ struct xen_ia64_boot_param_ia64 *bp = -+ (struct xen_ia64_boot_param_ia64 *)(start_info + 1); -+ -+ xc_dom_printf("%s\n", __FUNCTION__); -+ -+ memset(start_info, 0, sizeof(*start_info)); -+ sprintf(start_info->magic, dom->guest_type); -+ start_info->flags = dom->flags; -+ start_info->nr_pages = dom->total_pages; -+ start_info->store_mfn = dom->xenstore_pfn; -+ start_info->store_evtchn = dom->xenstore_evtchn; -+ start_info->console.domU.mfn = dom->console_pfn; -+ start_info->console.domU.evtchn = dom->console_evtchn; -+ -+ if (dom->ramdisk_blob) -+ { -+ start_info->mod_start = dom->ramdisk_seg.vstart; -+ start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart; -+ bp->initrd_start = start_info->mod_start; -+ bp->initrd_size = start_info->mod_len; -+ } -+ bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64) -+ + offsetof(start_info_t, cmd_line); -+ if (dom->cmdline) -+ { -+ strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE); -+ start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0'; -+ } -+ return 0; -+} -+ -+static int shared_info_ia64(struct xc_dom_image *dom, void *ptr) -+{ -+ shared_info_ia64_t *shared_info = ptr; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ memset(shared_info, 0, sizeof(*shared_info)); -+ for (i = 0; i < MAX_VIRT_CPUS; i++) -+ shared_info->vcpu_info[i].evtchn_upcall_mask = 1; -+ shared_info->arch.start_info_pfn = dom->start_info_pfn; -+ return 0; -+} -+ -+extern unsigned long xc_ia64_fpsr_default(void); -+ -+static int vcpu_ia64(struct xc_dom_image *dom, void *ptr) -+{ -+ vcpu_guest_context_ia64_t *ctxt = ptr; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* clear everything */ -+ memset(ctxt, 0, sizeof(*ctxt)); -+ -+ ctxt->flags = 0; -+ ctxt->user_regs.cr_ipsr = 0; /* all necessary bits filled by hypervisor */ -+ ctxt->user_regs.cr_iip = dom->parms.virt_entry; -+ ctxt->user_regs.cr_ifs = (uint64_t) 1 << 63; -+#ifdef __ia64__ /* FIXME */ -+ ctxt->user_regs.ar_fpsr = xc_ia64_fpsr_default(); -+#endif -+ ctxt->user_regs.r28 = (dom->start_info_pfn << PAGE_SHIFT_IA64) -+ + sizeof(start_info_ia64_t); -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct xc_dom_arch xc_dom_arch = { -+ .guest_type = "xen-3.0-ia64", -+ .page_shift = PAGE_SHIFT_IA64, -+ .alloc_magic_pages = alloc_magic_pages, -+ .start_info = start_info_ia64, -+ .shared_info = shared_info_ia64, -+ .vcpu = vcpu_ia64, -+}; -+ -+static void __init register_arch_hooks(void) -+{ -+ xc_dom_register_arch_hooks(&xc_dom_arch); -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_x86.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_x86.c -@@ -0,0 +1,561 @@ -+/* -+ * Xen domain builder -- i386 and x86_64 bits. -+ * -+ * Most architecture-specific code for x86 goes here. -+ * - prepare page tables. -+ * - fill architecture-specific structs. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+#define bits_to_mask(bits) (((xen_vaddr_t)1 << (bits))-1) -+#define round_down(addr, mask) ((addr) & ~(mask)) -+#define round_up(addr, mask) ((addr) | (mask)) -+ -+static inline unsigned long -+nr_page_tables(xen_vaddr_t start, xen_vaddr_t end, unsigned long bits) -+{ -+ xen_vaddr_t mask = bits_to_mask(bits); -+ int tables; -+ -+ if (0 == bits) -+ return 0; /* unused */ -+ -+ if (8 * sizeof(unsigned long) == bits) -+ { -+ /* must be pgd, need one */ -+ start = 0; -+ end = -1; -+ tables = 1; -+ } -+ else -+ { -+ start = round_down(start, mask); -+ end = round_up(end, mask); -+ tables = ((end - start) >> bits) + 1; -+ } -+ -+ xc_dom_printf("%s: 0x%016" PRIx64 "/%ld: 0x%016" PRIx64 -+ " -> 0x%016" PRIx64 ", %d table(s)\n", -+ __FUNCTION__, mask, bits, start, end, tables); -+ return tables; -+} -+ -+static int count_pgtables(struct xc_dom_image *dom, int pae, -+ int l4_bits, int l3_bits, int l2_bits, int l1_bits) -+{ -+ int pages, extra_pages; -+ xen_vaddr_t try_virt_end; -+ -+ extra_pages = dom->alloc_bootstack ? 1 : 0; -+ extra_pages += dom->extra_pages; -+ extra_pages += 128; /* 512kB padding */ -+ pages = extra_pages; -+ for (;;) -+ { -+ try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86, -+ bits_to_mask(22)); /* 4MB alignment */ -+ dom->pg_l4 = -+ nr_page_tables(dom->parms.virt_base, try_virt_end, l4_bits); -+ dom->pg_l3 = -+ nr_page_tables(dom->parms.virt_base, try_virt_end, l3_bits); -+ dom->pg_l2 = -+ nr_page_tables(dom->parms.virt_base, try_virt_end, l2_bits); -+ dom->pg_l1 = -+ nr_page_tables(dom->parms.virt_base, try_virt_end, l1_bits); -+ if (pae && try_virt_end < 0xc0000000) -+ { -+ xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n", __FUNCTION__); -+ dom->pg_l2++; -+ } -+ dom->pgtables = dom->pg_l4 + dom->pg_l3 + dom->pg_l2 + dom->pg_l1; -+ pages = dom->pgtables + extra_pages; -+ if (dom->virt_alloc_end + pages * PAGE_SIZE_X86 <= try_virt_end + 1) -+ break; -+ } -+ dom->virt_pgtab_end = try_virt_end + 1; -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* i386 pagetables */ -+ -+#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) -+#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) -+#define L3_PROT (_PAGE_PRESENT) -+ -+static int count_pgtables_x86_32(struct xc_dom_image *dom) -+{ -+ return count_pgtables(dom, 0, 0, 0, 32, L2_PAGETABLE_SHIFT_I386); -+} -+ -+static int count_pgtables_x86_32_pae(struct xc_dom_image *dom) -+{ -+ return count_pgtables(dom, 1, 0, 32, -+ L3_PAGETABLE_SHIFT_PAE, L2_PAGETABLE_SHIFT_PAE); -+} -+ -+#define pfn_to_paddr(pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86) -+ -+static int setup_pgtables_x86_32(struct xc_dom_image *dom) -+{ -+ xen_pfn_t l2pfn = dom->pgtables_seg.pfn; -+ xen_pfn_t l1pfn = dom->pgtables_seg.pfn + dom->pg_l2; -+ l2_pgentry_32_t *l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1); -+ l1_pgentry_32_t *l1tab = NULL; -+ unsigned long l2off, l1off; -+ xen_vaddr_t addr; -+ xen_pfn_t pgpfn; -+ -+ for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end; -+ addr += PAGE_SIZE_X86) -+ { -+ if (NULL == l1tab) -+ { -+ /* get L1 tab, make L2 entry */ -+ l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1); -+ l2off = l2_table_offset_i386(addr); -+ l2tab[l2off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; -+ l1pfn++; -+ } -+ -+ /* make L1 entry */ -+ l1off = l1_table_offset_i386(addr); -+ pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86; -+ l1tab[l1off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT; -+ if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend) -+ l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ -+ if (L1_PAGETABLE_ENTRIES_I386 - 1 == l1off) -+ l1tab = NULL; -+ } -+ return 0; -+} -+ -+static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) -+{ -+ xen_pfn_t l3pfn = dom->pgtables_seg.pfn; -+ xen_pfn_t l2pfn = dom->pgtables_seg.pfn + dom->pg_l3; -+ xen_pfn_t l1pfn = dom->pgtables_seg.pfn + dom->pg_l3 + dom->pg_l2; -+ l3_pgentry_64_t *l3tab = xc_dom_pfn_to_ptr(dom, l3pfn, 1); -+ l2_pgentry_64_t *l2tab = NULL; -+ l1_pgentry_64_t *l1tab = NULL; -+ unsigned long l3off, l2off, l1off; -+ xen_vaddr_t addr; -+ xen_pfn_t pgpfn; -+ -+ for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end; -+ addr += PAGE_SIZE_X86) -+ { -+ if (NULL == l2tab) -+ { -+ /* get L2 tab, make L3 entry */ -+ l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1); -+ l3off = l3_table_offset_pae(addr); -+ l3tab[l3off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; -+ l2pfn++; -+ } -+ -+ if (NULL == l1tab) -+ { -+ /* get L1 tab, make L2 entry */ -+ l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1); -+ l2off = l2_table_offset_pae(addr); -+ l2tab[l2off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; -+ if (L2_PAGETABLE_ENTRIES_PAE - 1 == l2off) -+ l2tab = NULL; -+ l1pfn++; -+ } -+ -+ /* make L1 entry */ -+ l1off = l1_table_offset_pae(addr); -+ pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86; -+ l1tab[l1off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT; -+ if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend) -+ l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ -+ if (L1_PAGETABLE_ENTRIES_PAE - 1 == l1off) -+ l1tab = NULL; -+ } -+ -+ if (dom->virt_pgtab_end <= 0xc0000000) -+ { -+ xc_dom_printf("%s: PAE: extra l2 page table for l3#3\n", __FUNCTION__); -+ l3tab[3] = pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; -+ } -+ return 0; -+} -+ -+#undef L1_PROT -+#undef L2_PROT -+#undef L3_PROT -+ -+/* ------------------------------------------------------------------------ */ -+/* x86_64 pagetables */ -+ -+static int count_pgtables_x86_64(struct xc_dom_image *dom) -+{ -+ return count_pgtables(dom, 0, -+ L4_PAGETABLE_SHIFT_X86_64 + 9, -+ L4_PAGETABLE_SHIFT_X86_64, -+ L3_PAGETABLE_SHIFT_X86_64, L2_PAGETABLE_SHIFT_X86_64); -+} -+ -+#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) -+#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) -+#define L3_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) -+#define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) -+ -+static int setup_pgtables_x86_64(struct xc_dom_image *dom) -+{ -+ xen_pfn_t l4pfn = dom->pgtables_seg.pfn; -+ xen_pfn_t l3pfn = dom->pgtables_seg.pfn + dom->pg_l4; -+ xen_pfn_t l2pfn = dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3; -+ xen_pfn_t l1pfn = -+ dom->pgtables_seg.pfn + dom->pg_l4 + dom->pg_l3 + dom->pg_l2; -+ l4_pgentry_64_t *l4tab = xc_dom_pfn_to_ptr(dom, l4pfn, 1); -+ l3_pgentry_64_t *l3tab = NULL; -+ l2_pgentry_64_t *l2tab = NULL; -+ l1_pgentry_64_t *l1tab = NULL; -+ uint64_t l4off, l3off, l2off, l1off; -+ uint64_t addr; -+ xen_pfn_t pgpfn; -+ -+ for (addr = dom->parms.virt_base; addr < dom->virt_pgtab_end; -+ addr += PAGE_SIZE_X86) -+ { -+ if (NULL == l3tab) -+ { -+ /* get L3 tab, make L4 entry */ -+ l3tab = xc_dom_pfn_to_ptr(dom, l3pfn, 1); -+ l4off = l4_table_offset_x86_64(addr); -+ l4tab[l4off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l3pfn)) | L4_PROT; -+ l3pfn++; -+ } -+ -+ if (NULL == l2tab) -+ { -+ /* get L2 tab, make L3 entry */ -+ l2tab = xc_dom_pfn_to_ptr(dom, l2pfn, 1); -+ l3off = l3_table_offset_x86_64(addr); -+ l3tab[l3off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; -+ if (L3_PAGETABLE_ENTRIES_X86_64 - 1 == l3off) -+ l3tab = NULL; -+ l2pfn++; -+ } -+ -+ if (NULL == l1tab) -+ { -+ /* get L1 tab, make L2 entry */ -+ l1tab = xc_dom_pfn_to_ptr(dom, l1pfn, 1); -+ l2off = l2_table_offset_x86_64(addr); -+ l2tab[l2off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; -+ if (L2_PAGETABLE_ENTRIES_X86_64 - 1 == l2off) -+ l2tab = NULL; -+ l1pfn++; -+ } -+ -+ /* make L1 entry */ -+ l1off = l1_table_offset_x86_64(addr); -+ pgpfn = (addr - dom->parms.virt_base) >> PAGE_SHIFT_X86; -+ l1tab[l1off] = -+ pfn_to_paddr(xc_dom_p2m_guest(dom, pgpfn)) | L1_PROT; -+ if (addr >= dom->pgtables_seg.vstart && addr < dom->pgtables_seg.vend) -+ l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ -+ if (L1_PAGETABLE_ENTRIES_X86_64 - 1 == l1off) -+ l1tab = NULL; -+ } -+ return 0; -+} -+ -+#undef L1_PROT -+#undef L2_PROT -+#undef L3_PROT -+#undef L4_PROT -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int alloc_magic_pages(struct xc_dom_image *dom) -+{ -+ size_t p2m_size = dom->total_pages * dom->arch_hooks->sizeof_pfn; -+ -+ /* allocate phys2mach table */ -+ if (0 != xc_dom_alloc_segment(dom, &dom->p2m_seg, "phys2mach", 0, p2m_size)) -+ return -1; -+ dom->p2m_guest = xc_dom_seg_to_ptr(dom, &dom->p2m_seg); -+ -+ /* allocate special pages */ -+ dom->start_info_pfn = xc_dom_alloc_page(dom, "start info"); -+ dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore"); -+ dom->console_pfn = xc_dom_alloc_page(dom, "console"); -+ if (xc_dom_feature_translated(dom)) -+ dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info"); -+ dom->alloc_bootstack = 1; -+ -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int start_info_x86_32(struct xc_dom_image *dom) -+{ -+ start_info_x86_32_t *start_info = -+ xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); -+ xen_pfn_t shinfo = -+ xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom-> -+ shared_info_mfn; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ sprintf(start_info->magic, dom->guest_type); -+ start_info->nr_pages = dom->total_pages; -+ start_info->shared_info = shinfo << PAGE_SHIFT_X86; -+ start_info->pt_base = dom->pgtables_seg.vstart; -+ start_info->nr_pt_frames = dom->pgtables; -+ start_info->mfn_list = dom->p2m_seg.vstart; -+ -+ start_info->flags = dom->flags; -+ start_info->store_mfn = xc_dom_p2m_guest(dom, dom->xenstore_pfn); -+ start_info->store_evtchn = dom->xenstore_evtchn; -+ start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn); -+ start_info->console.domU.evtchn = dom->console_evtchn; -+ -+ if (dom->ramdisk_blob) -+ { -+ start_info->mod_start = dom->ramdisk_seg.vstart; -+ start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart; -+ } -+ if (dom->cmdline) -+ { -+ strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE); -+ start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0'; -+ } -+ return 0; -+} -+ -+static int start_info_x86_64(struct xc_dom_image *dom) -+{ -+ start_info_x86_64_t *start_info = -+ xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); -+ xen_pfn_t shinfo = -+ xc_dom_feature_translated(dom) ? dom->shared_info_pfn : dom-> -+ shared_info_mfn; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ sprintf(start_info->magic, dom->guest_type); -+ start_info->nr_pages = dom->total_pages; -+ start_info->shared_info = shinfo << PAGE_SHIFT_X86; -+ start_info->pt_base = dom->pgtables_seg.vstart; -+ start_info->nr_pt_frames = dom->pgtables; -+ start_info->mfn_list = dom->p2m_seg.vstart; -+ -+ start_info->flags = dom->flags; -+ start_info->store_mfn = xc_dom_p2m_guest(dom, dom->xenstore_pfn); -+ start_info->store_evtchn = dom->xenstore_evtchn; -+ start_info->console.domU.mfn = xc_dom_p2m_guest(dom, dom->console_pfn); -+ start_info->console.domU.evtchn = dom->console_evtchn; -+ -+ if (dom->ramdisk_blob) -+ { -+ start_info->mod_start = dom->ramdisk_seg.vstart; -+ start_info->mod_len = dom->ramdisk_seg.vend - dom->ramdisk_seg.vstart; -+ } -+ if (dom->cmdline) -+ { -+ strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE); -+ start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0'; -+ } -+ return 0; -+} -+ -+static int shared_info_x86_32(struct xc_dom_image *dom, void *ptr) -+{ -+ shared_info_x86_32_t *shared_info = ptr; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ memset(shared_info, 0, sizeof(*shared_info)); -+ for (i = 0; i < MAX_VIRT_CPUS; i++) -+ shared_info->vcpu_info[i].evtchn_upcall_mask = 1; -+ return 0; -+} -+ -+static int shared_info_x86_64(struct xc_dom_image *dom, void *ptr) -+{ -+ shared_info_x86_64_t *shared_info = ptr; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ memset(shared_info, 0, sizeof(*shared_info)); -+ for (i = 0; i < MAX_VIRT_CPUS; i++) -+ shared_info->vcpu_info[i].evtchn_upcall_mask = 1; -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr) -+{ -+ vcpu_guest_context_x86_32_t *ctxt = ptr; -+ xen_pfn_t cr3_pfn; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* clear everything */ -+ memset(ctxt, 0, sizeof(*ctxt)); -+ -+ /* Virtual IDT is empty at start-of-day. */ -+ for (i = 0; i < 256; i++) -+ { -+ ctxt->trap_ctxt[i].vector = i; -+ ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_32; -+ } -+ -+ /* No callback handlers. */ -+ ctxt->event_callback_cs = FLAT_KERNEL_CS_X86_32; -+ ctxt->failsafe_callback_cs = FLAT_KERNEL_CS_X86_32; -+ -+ ctxt->user_regs.ds = FLAT_KERNEL_DS_X86_32; -+ ctxt->user_regs.es = FLAT_KERNEL_DS_X86_32; -+ ctxt->user_regs.fs = FLAT_KERNEL_DS_X86_32; -+ ctxt->user_regs.gs = FLAT_KERNEL_DS_X86_32; -+ ctxt->user_regs.ss = FLAT_KERNEL_SS_X86_32; -+ ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_32; -+ ctxt->user_regs.eip = dom->parms.virt_entry; -+ ctxt->user_regs.esp = -+ dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86; -+ ctxt->user_regs.esi = -+ dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86; -+ ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */ -+ -+ ctxt->kernel_ss = FLAT_KERNEL_SS_X86_32; -+ ctxt->kernel_sp = -+ dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86; -+ -+ ctxt->flags = VGCF_in_kernel_X86_32; -+ if (dom->parms.pae == 2 /* extended_cr3 */ || -+ dom->parms.pae == 3 /* bimodal */) -+ ctxt->vm_assist |= (1UL << VMASST_TYPE_pae_extended_cr3); -+ -+ cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn); -+ ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_32(cr3_pfn); -+ xc_dom_printf("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "\n", -+ __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn); -+ -+ return 0; -+} -+ -+static int vcpu_x86_64(struct xc_dom_image *dom, void *ptr) -+{ -+ vcpu_guest_context_x86_64_t *ctxt = ptr; -+ xen_pfn_t cr3_pfn; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* clear everything */ -+ memset(ctxt, 0, sizeof(*ctxt)); -+ -+ /* Virtual IDT is empty at start-of-day. */ -+ for (i = 0; i < 256; i++) -+ { -+ ctxt->trap_ctxt[i].vector = i; -+ ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_64; -+ } -+ -+ ctxt->user_regs.ds = FLAT_KERNEL_DS_X86_64; -+ ctxt->user_regs.es = FLAT_KERNEL_DS_X86_64; -+ ctxt->user_regs.fs = FLAT_KERNEL_DS_X86_64; -+ ctxt->user_regs.gs = FLAT_KERNEL_DS_X86_64; -+ ctxt->user_regs.ss = FLAT_KERNEL_SS_X86_64; -+ ctxt->user_regs.cs = FLAT_KERNEL_CS_X86_64; -+ ctxt->user_regs.rip = dom->parms.virt_entry; -+ ctxt->user_regs.rsp = -+ dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86; -+ ctxt->user_regs.rsi = -+ dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86; -+ ctxt->user_regs.rflags = 1 << 9; /* Interrupt Enable */ -+ -+ ctxt->kernel_ss = FLAT_KERNEL_SS_X86_64; -+ ctxt->kernel_sp = -+ dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86; -+ -+ ctxt->flags = VGCF_in_kernel_X86_64; -+ cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn); -+ ctxt->ctrlreg[3] = xen_pfn_to_cr3_x86_64(cr3_pfn); -+ xc_dom_printf("%s: cr3: pfn 0x%" PRIpfn " mfn 0x%" PRIpfn "\n", -+ __FUNCTION__, dom->pgtables_seg.pfn, cr3_pfn); -+ -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct xc_dom_arch xc_dom_32 = { -+ .guest_type = "xen-3.0-x86_32", -+ .page_shift = PAGE_SHIFT_X86, -+ .sizeof_pfn = 4, -+ .alloc_magic_pages = alloc_magic_pages, -+ .count_pgtables = count_pgtables_x86_32, -+ .setup_pgtables = setup_pgtables_x86_32, -+ .start_info = start_info_x86_32, -+ .shared_info = shared_info_x86_32, -+ .vcpu = vcpu_x86_32, -+}; -+static struct xc_dom_arch xc_dom_32_pae = { -+ .guest_type = "xen-3.0-x86_32p", -+ .page_shift = PAGE_SHIFT_X86, -+ .sizeof_pfn = 4, -+ .alloc_magic_pages = alloc_magic_pages, -+ .count_pgtables = count_pgtables_x86_32_pae, -+ .setup_pgtables = setup_pgtables_x86_32_pae, -+ .start_info = start_info_x86_32, -+ .shared_info = shared_info_x86_32, -+ .vcpu = vcpu_x86_32, -+}; -+ -+static struct xc_dom_arch xc_dom_64 = { -+ .guest_type = "xen-3.0-x86_64", -+ .page_shift = PAGE_SHIFT_X86, -+ .sizeof_pfn = 8, -+ .alloc_magic_pages = alloc_magic_pages, -+ .count_pgtables = count_pgtables_x86_64, -+ .setup_pgtables = setup_pgtables_x86_64, -+ .start_info = start_info_x86_64, -+ .shared_info = shared_info_x86_64, -+ .vcpu = vcpu_x86_64, -+}; -+ -+static void __init register_arch_hooks(void) -+{ -+ xc_dom_register_arch_hooks(&xc_dom_32); -+ xc_dom_register_arch_hooks(&xc_dom_32_pae); -+ xc_dom_register_arch_hooks(&xc_dom_64); -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_powerpc64.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_powerpc64.c -@@ -0,0 +1,100 @@ -+/* -+ * Xen domain builder -- ia64 bits. -+ * -+ * Most architecture-specific code for ia64 goes here. -+ * - fill architecture-specific structs. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int alloc_magic_pages(struct xc_dom_image *dom) -+{ -+ /* allocate special pages */ -+ dom->low_top--; /* shared_info */ -+ dom->xenstore_pfn = --dom->low_top; -+ dom->console_pfn = --dom->low_top; -+ dom->start_info_pfn = --dom->low_top; -+ return 0; -+} -+ -+static int start_info(struct xc_dom_image *dom) -+{ -+ start_info_t *si = -+ xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); -+ -+ xc_dom_printf("%s\n", __FUNCTION__); -+ -+ snprintf(si->magic, sizeof(si->magic), "xen-%d.%d-powerpc64HV", 3, 0); -+ -+ si->nr_pages = dom->total_pages; -+ si->shared_info = (dom->total_pages - 1) << PAGE_SHIFT; -+ si->store_mfn = dom->xenstore_pfn; -+ si->store_evtchn = dom->store_evtchn; -+ si->console.domU.mfn = dom->console_pfn; -+ si->console.domU.evtchn = dom->console_evtchn; -+ return 0; -+} -+ -+static int shared_info(struct xc_dom_image *dom, void *ptr) -+{ -+ shared_info_t *shared_info = ptr; -+ int i; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ memset(shared_info, 0, sizeof(*shared_info)); -+ return 0; -+} -+ -+static int vcpu(struct xc_dom_image *dom, void *ptr) -+{ -+ vcpu_guest_context_t *ctxt = ptr; -+ -+ xc_dom_printf("%s: called\n", __FUNCTION__); -+ -+ /* clear everything */ -+ memset(ctxt, 0, sizeof(*ctxt)); -+ -+ memset(&ctxt->user_regs, 0x55, sizeof(ctxt.user_regs)); -+ ctxt->user_regs.pc = dsi->v_kernentry; -+ ctxt->user_regs.msr = 0; -+ ctxt->user_regs.gprs[1] = 0; /* Linux uses its own stack */ -+ ctxt->user_regs.gprs[3] = devtree_addr; -+ ctxt->user_regs.gprs[4] = kern_addr; -+ ctxt->user_regs.gprs[5] = 0; -+ -+ /* There is a buggy kernel that does not zero the "local_paca", so -+ * we must make sure this register is 0 */ -+ ctxt->user_regs.gprs[13] = 0; -+ -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct xc_dom_arch xc_dom_arch = { -+ .guest_type = "xen-3.0-powerpc64", -+ .page_shift = FIXME, -+ .alloc_magic_pages = alloc_magic_pages, -+ .start_info = start_info, -+ .shared_info = shared_info, -+ .vcpu = vcpu, -+}; -+ -+static void __init register_arch_hooks(void) -+{ -+ xc_dom_register_arch_hooks(&xc_dom_arch); -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_elfloader.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_elfloader.c -@@ -0,0 +1,283 @@ -+/* -+ * Xen domain builder -- ELF bits. -+ * -+ * Parse and load ELF kernel images. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+#define XEN_VER "xen-3.0" -+ -+/* ------------------------------------------------------------------------ */ -+ -+static char *xc_dom_guest_type(struct xc_dom_image *dom, -+ struct elf_binary *elf) -+{ -+ uint64_t machine = elf_uval(elf, elf->ehdr, e_machine); -+ -+ switch (machine) { -+ case EM_386: -+ switch (dom->parms.pae) { -+ case 3 /* PAEKERN_bimodal */: -+ if (strstr(dom->xen_caps, "xen-3.0-x86_32p")) -+ return "xen-3.0-x86_32p"; -+ return "xen-3.0-x86_32"; -+ case PAEKERN_extended_cr3: -+ case PAEKERN_yes: -+ return "xen-3.0-x86_32p"; -+ break; -+ case PAEKERN_no: -+ default: -+ return "xen-3.0-x86_32"; -+ } -+ case EM_X86_64: -+ return "xen-3.0-x86_64"; -+ case EM_IA_64: -+ return elf_msb(elf) ? "xen-3.0-ia64be" : "xen-3.0-ia64"; -+ case EM_PPC64: -+ return "xen-3.0-powerpc64"; -+ default: -+ return "xen-3.0-unknown"; -+ } -+} -+ -+/* ------------------------------------------------------------------------ */ -+/* parse elf binary */ -+ -+static int check_elf_kernel(struct xc_dom_image *dom, int verbose) -+{ -+ if (NULL == dom->kernel_blob) -+ { -+ if (verbose) -+ xc_dom_panic(XC_INTERNAL_ERROR, "%s: no kernel image loaded\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ -+ if (!elf_is_elfbinary(dom->kernel_blob)) -+ { -+ if (verbose) -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: kernel is not an ELF image\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static int xc_dom_probe_elf_kernel(struct xc_dom_image *dom) -+{ -+ return check_elf_kernel(dom, 0); -+} -+ -+static int xc_dom_load_elf_symtab(struct xc_dom_image *dom, -+ struct elf_binary *elf, int load) -+{ -+ struct elf_binary syms; -+ const elf_shdr *shdr, *shdr2; -+ xen_vaddr_t symtab, maxaddr; -+ char *hdr; -+ size_t size; -+ int h, count, type, i, tables = 0; -+ -+ if (elf_swap(elf)) { -+ xc_dom_printf("%s: non-native byte order, bsd symtab not supported\n", -+ __FUNCTION__); -+ return 0; -+ } -+ -+ if (load) { -+ if (!dom->bsd_symtab_start) -+ return 0; -+ size = dom->kernel_seg.vend - dom->bsd_symtab_start; -+ hdr = xc_dom_vaddr_to_ptr(dom, dom->bsd_symtab_start); -+ *(int *)hdr = size - sizeof(int); -+ } else { -+ size = sizeof(int) + elf_size(elf, elf->ehdr) + -+ elf_shdr_count(elf) * elf_size(elf, shdr); -+ hdr = xc_dom_malloc(dom, size); -+ if (hdr == NULL) -+ return 0; -+ dom->bsd_symtab_start = elf_round_up(&syms, dom->kernel_seg.vend); -+ } -+ -+ memcpy(hdr + sizeof(int), -+ elf->image, -+ elf_size(elf, elf->ehdr)); -+ memcpy(hdr + sizeof(int) + elf_size(elf, elf->ehdr), -+ elf->image + elf_uval(elf, elf->ehdr, e_shoff), -+ elf_shdr_count(elf) * elf_size(elf, shdr)); -+ if (elf_64bit(elf)) { -+ Elf64_Ehdr *ehdr = (Elf64_Ehdr *)(hdr + sizeof(int)); -+ ehdr->e_phoff = 0; -+ ehdr->e_phentsize = 0; -+ ehdr->e_phnum = 0; -+ ehdr->e_shoff = elf_size(elf, elf->ehdr); -+ ehdr->e_shstrndx = SHN_UNDEF; -+ } else { -+ Elf32_Ehdr *ehdr = (Elf32_Ehdr *)(hdr + sizeof(int)); -+ ehdr->e_phoff = 0; -+ ehdr->e_phentsize = 0; -+ ehdr->e_phnum = 0; -+ ehdr->e_shoff = elf_size(elf, elf->ehdr); -+ ehdr->e_shstrndx = SHN_UNDEF; -+ } -+ if (0 != elf_init(&syms, hdr + sizeof(int), size - sizeof(int))) -+ return -1; -+ if (xc_dom_logfile) -+ elf_set_logfile(&syms, xc_dom_logfile, 1); -+ -+ symtab = dom->bsd_symtab_start + sizeof(int); -+ maxaddr = elf_round_up(&syms, symtab + elf_size(&syms, syms.ehdr) + -+ elf_shdr_count(&syms) * elf_size(&syms, shdr)); -+ -+ xc_dom_printf("%s/%s: bsd_symtab_start=%" PRIx64 ", kernel.end=0x%" PRIx64 -+ " -- symtab=0x%" PRIx64 ", maxaddr=0x%" PRIx64 "\n", -+ __FUNCTION__, load ? "load" : "parse", -+ dom->bsd_symtab_start, dom->kernel_seg.vend, symtab, maxaddr); -+ -+ count = elf_shdr_count(&syms); -+ for (h = 0; h < count; h++) -+ { -+ shdr = elf_shdr_by_index(&syms, h); -+ type = elf_uval(&syms, shdr, sh_type); -+ if (type == SHT_STRTAB) -+ { -+ /* Look for a strtab @i linked to symtab @h. */ -+ for (i = 0; i < count; i++) { -+ shdr2 = elf_shdr_by_index(&syms, i); -+ if ((elf_uval(&syms, shdr2, sh_type) == SHT_SYMTAB) && -+ (elf_uval(&syms, shdr2, sh_link) == h)) -+ break; -+ } -+ /* Skip symtab @h if we found no corresponding strtab @i. */ -+ if (i == count) -+ { -+ if (elf_64bit(&syms)) -+ *(Elf64_Off*)(&shdr->e64.sh_offset) = 0; -+ else -+ *(Elf32_Off*)(&shdr->e32.sh_offset) = 0; -+ continue; -+ } -+ } -+ -+ if ((type == SHT_STRTAB) || (type == SHT_SYMTAB)) -+ { -+ /* Mangled to be based on ELF header location. */ -+ if (elf_64bit(&syms)) -+ *(Elf64_Off*)(&shdr->e64.sh_offset) = maxaddr - symtab; -+ else -+ *(Elf32_Off*)(&shdr->e32.sh_offset) = maxaddr - symtab; -+ size = elf_uval(&syms, shdr, sh_size); -+ maxaddr = elf_round_up(&syms, maxaddr + size); -+ tables++; -+ xc_dom_printf("%s: h=%d %s, size=0x%zx, maxaddr=0x%" PRIx64 "\n", -+ __FUNCTION__, h, -+ type == SHT_SYMTAB ? "symtab" : "strtab", -+ size, maxaddr); -+ -+ if (load) { -+ shdr2 = elf_shdr_by_index(elf, h); -+ memcpy((void*)elf_section_start(&syms, shdr), -+ elf_section_start(elf, shdr2), -+ size); -+ } -+ } -+ -+ /* Name is NULL. */ -+ if (elf_64bit(&syms)) -+ *(Elf64_Half*)(&shdr->e64.sh_name) = 0; -+ else -+ *(Elf32_Word*)(&shdr->e32.sh_name) = 0; -+ } -+ -+ if (0 == tables) -+ { -+ xc_dom_printf("%s: no symbol table present\n", __FUNCTION__); -+ dom->bsd_symtab_start = 0; -+ return 0; -+ } -+ if (!load) -+ dom->kernel_seg.vend = maxaddr; -+ return 0; -+} -+ -+static int xc_dom_parse_elf_kernel(struct xc_dom_image *dom) -+{ -+ struct elf_binary *elf; -+ int rc; -+ -+ rc = check_elf_kernel(dom, 1); -+ if (0 != rc) -+ return rc; -+ -+ elf = xc_dom_malloc(dom, sizeof(*elf)); -+ dom->private_loader = elf; -+ rc = elf_init(elf, dom->kernel_blob, dom->kernel_size); -+ if (xc_dom_logfile) -+ elf_set_logfile(elf, xc_dom_logfile, 1); -+ if (0 != rc) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: corrupted ELF image\n", -+ __FUNCTION__); -+ return rc; -+ } -+ -+ /* Find the section-header strings table. */ -+ if (NULL == elf->sec_strtab) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: ELF image has no shstrtab\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ -+ /* parse binary and get xen meta info */ -+ elf_parse_binary(elf); -+ if (0 != (rc = elf_xen_parse(elf, &dom->parms))) -+ return rc; -+ -+ /* find kernel segment */ -+ dom->kernel_seg.vstart = dom->parms.virt_kstart; -+ dom->kernel_seg.vend = dom->parms.virt_kend; -+ -+ if (dom->parms.bsd_symtab) -+ xc_dom_load_elf_symtab(dom, elf, 0); -+ -+ dom->guest_type = xc_dom_guest_type(dom, elf); -+ xc_dom_printf("%s: %s: 0x%" PRIx64 " -> 0x%" PRIx64 "\n", -+ __FUNCTION__, dom->guest_type, -+ dom->kernel_seg.vstart, dom->kernel_seg.vend); -+ return 0; -+} -+ -+static int xc_dom_load_elf_kernel(struct xc_dom_image *dom) -+{ -+ struct elf_binary *elf = dom->private_loader; -+ -+ elf->dest = xc_dom_seg_to_ptr(dom, &dom->kernel_seg); -+ elf_load_binary(elf); -+ if (dom->parms.bsd_symtab) -+ xc_dom_load_elf_symtab(dom, elf, 1); -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct xc_dom_loader elf_loader = { -+ .name = "ELF-generic", -+ .probe = xc_dom_probe_elf_kernel, -+ .parser = xc_dom_parse_elf_kernel, -+ .loader = xc_dom_load_elf_kernel, -+}; -+ -+static void __init register_loader(void) -+{ -+ xc_dom_register_loader(&elf_loader); -+} -Index: build-32-release304-13138/tools/libxc/xc_dom_binloader.c -=================================================================== ---- /dev/null -+++ build-32-release304-13138/tools/libxc/xc_dom_binloader.c -@@ -0,0 +1,294 @@ -+/****************************************************************************** -+ * -+ * Loads simple binary images. It's like a .COM file in MS-DOS. No headers are -+ * present. The only requirement is that it must have a xen_bin_image table -+ * somewhere in the first 8192 bytes, starting on a 32-bit aligned address. -+ * Those familiar with the multiboot specification should recognize this, it's -+ * (almost) the same as the multiboot header. -+ * The layout of the xen_bin_image table is: -+ * -+ * Offset Type Name Note -+ * 0 uint32_t magic required -+ * 4 uint32_t flags required -+ * 8 uint32_t checksum required -+ * 12 uint32_t header_addr required -+ * 16 uint32_t load_addr required -+ * 20 uint32_t load_end_addr required -+ * 24 uint32_t bss_end_addr required -+ * 28 uint32_t entry_addr required -+ * -+ * - magic -+ * Magic number identifying the table. For images to be loaded by Xen 3, the -+ * magic value is 0x336ec578 ("xEn3" with the 0x80 bit of the "E" set). -+ * - flags -+ * bit 0: indicates whether the image needs to be loaded on a page boundary -+ * bit 1: reserved, must be 0 (the multiboot spec uses this bit to indicate -+ * that memory info should be passed to the image) -+ * bit 2: reserved, must be 0 (the multiboot spec uses this bit to indicate -+ * that the bootloader should pass video mode info to the image) -+ * bit 16: reserved, must be 1 (the multiboot spec uses this bit to indicate -+ * that the values in the fields header_addr - entry_addr are -+ * valid) -+ * All other bits should be set to 0. -+ * - checksum -+ * When added to "magic" and "flags", the resulting value should be 0. -+ * - header_addr -+ * Contains the virtual address corresponding to the beginning of the -+ * table - the memory location at which the magic value is supposed to be -+ * loaded. This field serves to synchronize the mapping between OS image -+ * offsets and virtual memory addresses. -+ * - load_addr -+ * Contains the virtual address of the beginning of the text segment. The -+ * offset in the OS image file at which to start loading is defined by the -+ * offset at which the table was found, minus (header addr - load addr). -+ * load addr must be less than or equal to header addr. -+ * - load_end_addr -+ * Contains the virtual address of the end of the data segment. -+ * (load_end_addr - load_addr) specifies how much data to load. This implies -+ * that the text and data segments must be consecutive in the OS image. If -+ * this field is zero, the domain builder assumes that the text and data -+ * segments occupy the whole OS image file. -+ * - bss_end_addr -+ * Contains the virtual address of the end of the bss segment. The domain -+ * builder initializes this area to zero, and reserves the memory it occupies -+ * to avoid placing boot modules and other data relevant to the loaded image -+ * in that area. If this field is zero, the domain builder assumes that no bss -+ * segment is present. -+ * - entry_addr -+ * The virtual address at which to start execution of the loaded image. -+ * -+ * Some of the field descriptions were copied from "The Multiboot -+ * Specification", Copyright 1995, 96 Bryan Ford , -+ * Erich Stefan Boleyn Copyright 1999, 2000, 2001, 2002 -+ * Free Software Foundation, Inc. -+ */ -+ -+#include -+#include -+ -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+#define round_pgup(_p) (((_p)+(PAGE_SIZE_X86-1))&PAGE_MASK_X86) -+#define round_pgdown(_p) ((_p)&PAGE_MASK_X86) -+ -+struct xen_bin_image_table -+{ -+ uint32_t magic; -+ uint32_t flags; -+ uint32_t checksum; -+ uint32_t header_addr; -+ uint32_t load_addr; -+ uint32_t load_end_addr; -+ uint32_t bss_end_addr; -+ uint32_t entry_addr; -+}; -+ -+#define XEN_MULTIBOOT_MAGIC3 0x336ec578 -+ -+#define XEN_MULTIBOOT_FLAG_ALIGN4K 0x00000001 -+#define XEN_MULTIBOOT_FLAG_NEEDMEMINFO 0x00000002 -+#define XEN_MULTIBOOT_FLAG_NEEDVIDINFO 0x00000004 -+#define XEN_MULTIBOOT_FLAG_ADDRSVALID 0x00010000 -+#define XEN_MULTIBOOT_FLAG_PAE_SHIFT 14 -+#define XEN_MULTIBOOT_FLAG_PAE_MASK (3 << XEN_MULTIBOOT_FLAG_PAE_SHIFT) -+ -+/* Flags we test for */ -+#define FLAGS_MASK ((~ 0) & (~ XEN_MULTIBOOT_FLAG_ALIGN4K) & \ -+ (~ XEN_MULTIBOOT_FLAG_PAE_MASK)) -+#define FLAGS_REQUIRED XEN_MULTIBOOT_FLAG_ADDRSVALID -+ -+/* --------------------------------------------------------------------- */ -+ -+static struct xen_bin_image_table *find_table(struct xc_dom_image *dom) -+{ -+ struct xen_bin_image_table *table; -+ uint32_t *probe_ptr; -+ uint32_t *probe_end; -+ -+ probe_ptr = dom->kernel_blob; -+ probe_end = dom->kernel_blob + dom->kernel_size - sizeof(*table); -+ if ((void*)probe_end > dom->kernel_blob + 8192) -+ probe_end = dom->kernel_blob + 8192; -+ -+ for (table = NULL; probe_ptr < probe_end; probe_ptr++) -+ { -+ if (XEN_MULTIBOOT_MAGIC3 == *probe_ptr) -+ { -+ table = (struct xen_bin_image_table *) probe_ptr; -+ /* Checksum correct? */ -+ if (0 == table->magic + table->flags + table->checksum) -+ { -+ return table; -+ } -+ } -+ } -+ return NULL; -+} -+ -+static int xc_dom_probe_bin_kernel(struct xc_dom_image *dom) -+{ -+ struct xen_bin_image_table *table; -+ -+ table = find_table(dom); -+ if (!table) -+ return -EINVAL; -+ return 0; -+} -+ -+static int xc_dom_parse_bin_kernel(struct xc_dom_image *dom) -+{ -+ struct xen_bin_image_table *image_info; -+ char *image = dom->kernel_blob; -+ size_t image_size = dom->kernel_size; -+ uint32_t start_addr; -+ uint32_t load_end_addr; -+ uint32_t bss_end_addr; -+ uint32_t pae_flags; -+ -+ image_info = find_table(dom); -+ if (!image_info) -+ return -EINVAL; -+ -+ xc_dom_printf("%s: multiboot header fields\n", __FUNCTION__); -+ xc_dom_printf(" flags: 0x%" PRIx32 "\n", image_info->flags); -+ xc_dom_printf(" header_addr: 0x%" PRIx32 "\n", image_info->header_addr); -+ xc_dom_printf(" load_addr: 0x%" PRIx32 "\n", image_info->load_addr); -+ xc_dom_printf(" load_end_addr: 0x%" PRIx32 "\n", image_info->load_end_addr); -+ xc_dom_printf(" bss_end_addr: 0x%" PRIx32 "\n", image_info->bss_end_addr); -+ xc_dom_printf(" entry_addr: 0x%" PRIx32 "\n", image_info->entry_addr); -+ -+ /* Check the flags */ -+ if ( FLAGS_REQUIRED != (image_info->flags & FLAGS_MASK) ) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, -+ "%s: xen_bin_image_table flags required " -+ "0x%08" PRIx32 " found 0x%08" PRIx32 "\n", -+ __FUNCTION__, FLAGS_REQUIRED, image_info->flags & FLAGS_MASK); -+ return -EINVAL; -+ } -+ -+ /* Sanity check on the addresses */ -+ if ( image_info->header_addr < image_info->load_addr || -+ ((char *) image_info - image) < -+ (image_info->header_addr - image_info->load_addr) ) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: Invalid header_addr.", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ -+ start_addr = image_info->header_addr - ((char *)image_info - image); -+ load_end_addr = image_info->load_end_addr ?: start_addr + image_size; -+ bss_end_addr = image_info->bss_end_addr ?: load_end_addr; -+ -+ xc_dom_printf("%s: calculated addresses\n", __FUNCTION__); -+ xc_dom_printf(" start_addr: 0x%" PRIx32 "\n", start_addr); -+ xc_dom_printf(" load_end_addr: 0x%" PRIx32 "\n", load_end_addr); -+ xc_dom_printf(" bss_end_addr: 0x%" PRIx32 "\n", bss_end_addr); -+ -+ if ( start_addr + image_size < load_end_addr ) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: Invalid load_end_addr.\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ -+ if ( bss_end_addr < load_end_addr) -+ { -+ xc_dom_panic(XC_INVALID_KERNEL, "%s: Invalid bss_end_addr.\n", -+ __FUNCTION__); -+ return -EINVAL; -+ } -+ -+ dom->kernel_seg.vstart = image_info->load_addr; -+ dom->kernel_seg.vend = bss_end_addr; -+ dom->parms.virt_base = start_addr; -+ dom->parms.virt_entry = image_info->entry_addr; -+ -+ pae_flags = image_info->flags & XEN_MULTIBOOT_FLAG_PAE_MASK; -+ switch (pae_flags >> XEN_MULTIBOOT_FLAG_PAE_SHIFT) { -+ case 0: -+ dom->guest_type = "xen-3.0-x86_32"; -+ break; -+ case 1: -+ dom->guest_type = "xen-3.0-x86_32p"; -+ break; -+ case 2: -+ dom->guest_type = "xen-3.0-x86_64"; -+ break; -+ case 3: -+ /* Kernel detects PAE at runtime. So try to figure whenever -+ * xen supports PAE and advertise a PAE-capable kernel in case -+ * it does. */ -+ dom->guest_type = "xen-3.0-x86_32"; -+ if (strstr(dom->xen_caps, "xen-3.0-x86_32p")) { -+ xc_dom_printf("%s: PAE fixup\n", __FUNCTION__); -+ dom->guest_type = "xen-3.0-x86_32p"; -+ dom->parms.pae = 2; -+ } -+ break; -+ } -+ return 0; -+} -+ -+static int xc_dom_load_bin_kernel(struct xc_dom_image *dom) -+{ -+ struct xen_bin_image_table *image_info; -+ char *image = dom->kernel_blob; -+ char *dest; -+ size_t image_size = dom->kernel_size; -+ uint32_t start_addr; -+ uint32_t load_end_addr; -+ uint32_t bss_end_addr; -+ uint32_t skip, text_size, bss_size; -+ uint32_t pae_flags; -+ -+ image_info = find_table(dom); -+ if (!image_info) -+ return -EINVAL; -+ -+ start_addr = image_info->header_addr - ((char *)image_info - image); -+ load_end_addr = image_info->load_end_addr ?: start_addr + image_size; -+ bss_end_addr = image_info->bss_end_addr ?: load_end_addr; -+ -+ /* It's possible that we need to skip the first part of the image */ -+ skip = image_info->load_addr - start_addr; -+ text_size = load_end_addr - image_info->load_addr; -+ bss_size = bss_end_addr - load_end_addr; -+ -+ xc_dom_printf("%s: calculated sizes\n", __FUNCTION__); -+ xc_dom_printf(" skip: 0x%" PRIx32 "\n", skip); -+ xc_dom_printf(" text_size: 0x%" PRIx32 "\n", text_size); -+ xc_dom_printf(" bss_size: 0x%" PRIx32 "\n", bss_size); -+ -+ dest = xc_dom_vaddr_to_ptr(dom, dom->kernel_seg.vstart); -+ memcpy(dest, image + skip, text_size); -+ memset(dest + text_size, 0, bss_size); -+ -+ pae_flags = image_info->flags & XEN_MULTIBOOT_FLAG_PAE_MASK; -+ if (3 == (pae_flags >> XEN_MULTIBOOT_FLAG_PAE_SHIFT) && dom->guest_xc > 0) -+ { -+ } -+ return 0; -+} -+ -+/* ------------------------------------------------------------------------ */ -+ -+static struct xc_dom_loader bin_loader = { -+ .name = "multiboot-binary", -+ .probe = xc_dom_probe_bin_kernel, -+ .parser = xc_dom_parse_bin_kernel, -+ .loader = xc_dom_load_bin_kernel, -+}; -+ -+static void __init register_loader(void) -+{ -+ xc_dom_register_loader(&bin_loader); -+} -+ -+/* -+ * Local variables: -+ * c-basic-offset: 4 -+ * End: -+ */ diff --git a/tools-domain-builder-header-libxc.diff b/tools-domain-builder-header-libxc.diff deleted file mode 100644 index ac24536..0000000 --- a/tools-domain-builder-header-libxc.diff +++ /dev/null @@ -1,165 +0,0 @@ -libxc header fixups. - -Make some arch-specific #defines for page table handling -available unconditionally, add a suffix to avoid name clashes. - -The versions without suffix are defined depending on the -architecture like they used to, so code using them continues -to work. - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/xg_private.h | 114 +++++++++++++++++++++++++++-------------------- - 1 file changed, 67 insertions(+), 47 deletions(-) - -Index: build-32-unstable-11822/tools/libxc/xg_private.h -=================================================================== ---- build-32-unstable-11822.orig/tools/libxc/xg_private.h -+++ build-32-unstable-11822/tools/libxc/xg_private.h -@@ -46,37 +46,41 @@ unsigned long csum_page (void * page); - #define _PAGE_PSE 0x080 - #define _PAGE_GLOBAL 0x100 - --#define L1_PAGETABLE_SHIFT_PAE 12 --#define L2_PAGETABLE_SHIFT_PAE 21 --#define L3_PAGETABLE_SHIFT_PAE 30 -- --#define L2_PAGETABLE_SHIFT_I386 22 -- --#if defined(__i386__) --#define L1_PAGETABLE_SHIFT 12 --#define L2_PAGETABLE_SHIFT 22 --#elif defined(__x86_64__) --#define L1_PAGETABLE_SHIFT 12 --#define L2_PAGETABLE_SHIFT 21 --#define L3_PAGETABLE_SHIFT 30 --#define L4_PAGETABLE_SHIFT 39 --#endif -+#define L1_PAGETABLE_SHIFT_I386 12 -+#define L2_PAGETABLE_SHIFT_I386 22 -+#define L1_PAGETABLE_ENTRIES_I386 1024 -+#define L2_PAGETABLE_ENTRIES_I386 1024 - --#define L1_PAGETABLE_ENTRIES_PAE 512 --#define L2_PAGETABLE_ENTRIES_PAE 512 --#define L3_PAGETABLE_ENTRIES_PAE 4 -+#define L1_PAGETABLE_SHIFT_PAE 12 -+#define L2_PAGETABLE_SHIFT_PAE 21 -+#define L3_PAGETABLE_SHIFT_PAE 30 -+#define L1_PAGETABLE_ENTRIES_PAE 512 -+#define L2_PAGETABLE_ENTRIES_PAE 512 -+#define L3_PAGETABLE_ENTRIES_PAE 4 - --#define L1_PAGETABLE_ENTRIES_I386 1024 --#define L2_PAGETABLE_ENTRIES_I386 1024 -+#define L1_PAGETABLE_SHIFT_X86_64 12 -+#define L2_PAGETABLE_SHIFT_X86_64 21 -+#define L3_PAGETABLE_SHIFT_X86_64 30 -+#define L4_PAGETABLE_SHIFT_X86_64 39 -+#define L1_PAGETABLE_ENTRIES_X86_64 512 -+#define L2_PAGETABLE_ENTRIES_X86_64 512 -+#define L3_PAGETABLE_ENTRIES_X86_64 512 -+#define L4_PAGETABLE_ENTRIES_X86_64 512 - - #if defined(__i386__) --#define L1_PAGETABLE_ENTRIES 1024 --#define L2_PAGETABLE_ENTRIES 1024 -+#define L1_PAGETABLE_SHIFT L1_PAGETABLE_SHIFT_I386 -+#define L2_PAGETABLE_SHIFT L2_PAGETABLE_SHIFT_I386 -+#define L1_PAGETABLE_ENTRIES L1_PAGETABLE_ENTRIES_I386 -+#define L2_PAGETABLE_ENTRIES L2_PAGETABLE_ENTRIES_I386 - #elif defined(__x86_64__) --#define L1_PAGETABLE_ENTRIES 512 --#define L2_PAGETABLE_ENTRIES 512 --#define L3_PAGETABLE_ENTRIES 512 --#define L4_PAGETABLE_ENTRIES 512 -+#define L1_PAGETABLE_SHIFT L1_PAGETABLE_SHIFT_X86_64 -+#define L2_PAGETABLE_SHIFT L2_PAGETABLE_SHIFT_X86_64 -+#define L3_PAGETABLE_SHIFT L3_PAGETABLE_SHIFT_X86_64 -+#define L4_PAGETABLE_SHIFT L4_PAGETABLE_SHIFT_X86_64 -+#define L1_PAGETABLE_ENTRIES L1_PAGETABLE_ENTRIES_X86_64 -+#define L2_PAGETABLE_ENTRIES L2_PAGETABLE_ENTRIES_X86_64 -+#define L3_PAGETABLE_ENTRIES L3_PAGETABLE_ENTRIES_X86_64 -+#define L4_PAGETABLE_ENTRIES L4_PAGETABLE_ENTRIES_X86_64 - #endif - - typedef uint32_t l1_pgentry_32_t; -@@ -84,13 +88,23 @@ typedef uint32_t l2_pgentry_32_t; - typedef uint64_t l1_pgentry_64_t; - typedef uint64_t l2_pgentry_64_t; - typedef uint64_t l3_pgentry_64_t; --typedef unsigned long l1_pgentry_t; --typedef unsigned long l2_pgentry_t; --#if defined(__x86_64__) --typedef unsigned long l3_pgentry_t; --typedef unsigned long l4_pgentry_t; -+typedef uint64_t l4_pgentry_64_t; -+ -+#if defined(__i386__) -+typedef l1_pgentry_32_t l1_pgentry_t; -+typedef l2_pgentry_32_t l2_pgentry_t; -+#elif defined(__x86_64__) -+typedef l1_pgentry_64_t l1_pgentry_t; -+typedef l2_pgentry_64_t l2_pgentry_t; -+typedef l3_pgentry_64_t l3_pgentry_t; -+typedef l4_pgentry_64_t l4_pgentry_t; - #endif - -+#define l1_table_offset_i386(_a) \ -+ (((_a) >> L1_PAGETABLE_SHIFT_I386) & (L1_PAGETABLE_ENTRIES_I386 - 1)) -+#define l2_table_offset_i386(_a) \ -+ (((_a) >> L2_PAGETABLE_SHIFT_I386) & (L2_PAGETABLE_ENTRIES_I386 - 1)) -+ - #define l1_table_offset_pae(_a) \ - (((_a) >> L1_PAGETABLE_SHIFT_PAE) & (L1_PAGETABLE_ENTRIES_PAE - 1)) - #define l2_table_offset_pae(_a) \ -@@ -98,27 +112,33 @@ typedef unsigned long l4_pgentry_t; - #define l3_table_offset_pae(_a) \ - (((_a) >> L3_PAGETABLE_SHIFT_PAE) & (L3_PAGETABLE_ENTRIES_PAE - 1)) - --#define l1_table_offset_i386(_a) \ -- (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES_I386 - 1)) --#define l2_table_offset_i386(_a) \ -- (((_a) >> L2_PAGETABLE_SHIFT_I386) & (L2_PAGETABLE_ENTRIES_I386 - 1)) -+#define l1_table_offset_x86_64(_a) \ -+ (((_a) >> L1_PAGETABLE_SHIFT_X86_64) & (L1_PAGETABLE_ENTRIES_X86_64 - 1)) -+#define l2_table_offset_x86_64(_a) \ -+ (((_a) >> L2_PAGETABLE_SHIFT_X86_64) & (L2_PAGETABLE_ENTRIES_X86_64 - 1)) -+#define l3_table_offset_x86_64(_a) \ -+ (((_a) >> L3_PAGETABLE_SHIFT_X86_64) & (L3_PAGETABLE_ENTRIES_X86_64 - 1)) -+#define l4_table_offset_x86_64(_a) \ -+ (((_a) >> L4_PAGETABLE_SHIFT_X86_64) & (L4_PAGETABLE_ENTRIES_X86_64 - 1)) - - #if defined(__i386__) --#define l1_table_offset(_a) \ -- (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1)) --#define l2_table_offset(_a) \ -- ((_a) >> L2_PAGETABLE_SHIFT) -+#define l1_table_offset(_a) l1_table_offset_i386(_a) -+#define l2_table_offset(_a) l2_table_offset_i386(_a) - #elif defined(__x86_64__) --#define l1_table_offset(_a) \ -- (((_a) >> L1_PAGETABLE_SHIFT) & (L1_PAGETABLE_ENTRIES - 1)) --#define l2_table_offset(_a) \ -- (((_a) >> L2_PAGETABLE_SHIFT) & (L2_PAGETABLE_ENTRIES - 1)) --#define l3_table_offset(_a) \ -- (((_a) >> L3_PAGETABLE_SHIFT) & (L3_PAGETABLE_ENTRIES - 1)) --#define l4_table_offset(_a) \ -- (((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1)) -+#define l1_table_offset(_a) l1_table_offset_x86_64(_a) -+#define l2_table_offset(_a) l2_table_offset_x86_64(_a) -+#define l3_table_offset(_a) l3_table_offset_x86_64(_a) -+#define l4_table_offset(_a) l4_table_offset_x86_64(_a) - #endif - -+#define PAGE_SHIFT_X86 12 -+#define PAGE_SIZE_X86 (1UL << PAGE_SHIFT_X86) -+#define PAGE_MASK_X86 (~(PAGE_SIZE_X86-1)) -+ -+#define PAGE_SHIFT_IA64 14 -+#define PAGE_SIZE_IA64 (1UL << PAGE_SHIFT_IA64) -+#define PAGE_MASK_IA64 (~(PAGE_SIZE_IA64-1)) -+ - struct domain_setup_info - { - uint64_t v_start; diff --git a/tools-domain-builder-linux.diff b/tools-domain-builder-linux.diff deleted file mode 100644 index 51f0513..0000000 --- a/tools-domain-builder-linux.diff +++ /dev/null @@ -1,164 +0,0 @@ -libxc domain builder rewrite, linux builder - -use new domain builder for the linux (aka generic elf) loader. - -Signed-off-by: Gerd Hoffmann ---- - tools/libxc/Makefile | 7 +- - tools/libxc/xc_dom_compat_linux.c | 124 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 129 insertions(+), 2 deletions(-) - -Index: build-32-release304-12901/tools/libxc/xc_dom_compat_linux.c -=================================================================== ---- /dev/null -+++ build-32-release304-12901/tools/libxc/xc_dom_compat_linux.c -@@ -0,0 +1,124 @@ -+/* -+ * Xen domain builder -- compatibility code. -+ * -+ * Replacements for xc_linux_build & friends, -+ * as example code and to make the new builder -+ * usable as drop-in replacement. -+ * -+ * This code is licenced under the GPL. -+ * written 2006 by Gerd Hoffmann . -+ * -+ */ -+#include -+#include -+#include -+#include -+#include -+ -+#include "xenctrl.h" -+#include "xg_private.h" -+#include "xc_dom.h" -+ -+/* ------------------------------------------------------------------------ */ -+ -+static int xc_linux_build_internal(struct xc_dom_image *dom, -+ int xc_handle, uint32_t domid, -+ unsigned int mem_mb, -+ unsigned long flags, -+ unsigned int store_evtchn, -+ unsigned long *store_mfn, -+ unsigned int console_evtchn, -+ unsigned long *console_mfn) -+{ -+ int rc; -+ -+ if (0 != (rc = xc_dom_boot_xen_init(dom, xc_handle, domid))) -+ goto out; -+ if (0 != (rc = xc_dom_parse_image(dom))) -+ goto out; -+ if (0 != (rc = xc_dom_mem_init(dom, mem_mb))) -+ goto out; -+ if (0 != (rc = xc_dom_boot_mem_init(dom))) -+ goto out; -+ if (0 != (rc = xc_dom_build_image(dom))) -+ goto out; -+ -+ dom->flags = flags; -+ dom->console_evtchn = console_evtchn; -+ dom->xenstore_evtchn = store_evtchn; -+ rc = xc_dom_boot_image(dom); -+ if (0 != rc) -+ goto out; -+ -+ *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn); -+ *store_mfn = xc_dom_p2m_host(dom, dom->xenstore_pfn); -+ -+ out: -+ return rc; -+} -+ -+int xc_linux_build_mem(int xc_handle, uint32_t domid, -+ unsigned int mem_mb, -+ const char *image_buffer, -+ unsigned long image_size, -+ const char *initrd, -+ unsigned long initrd_len, -+ const char *cmdline, -+ const char *features, -+ unsigned long flags, -+ unsigned int store_evtchn, -+ unsigned long *store_mfn, -+ unsigned int console_evtchn, unsigned long *console_mfn) -+{ -+ struct xc_dom_image *dom; -+ int rc; -+ -+ xc_dom_loginit(); -+ dom = xc_dom_allocate(cmdline, features); -+ if (0 != (rc = xc_dom_kernel_mem(dom, image_buffer, image_size))) -+ goto out; -+ if (initrd) -+ if (0 != (rc = xc_dom_ramdisk_mem(dom, initrd, initrd_len))) -+ goto out; -+ -+ rc = xc_linux_build_internal(dom, xc_handle, domid, -+ mem_mb, flags, -+ store_evtchn, store_mfn, -+ console_evtchn, console_mfn); -+ -+ out: -+ xc_dom_release(dom); -+ return rc; -+} -+ -+int xc_linux_build(int xc_handle, uint32_t domid, -+ unsigned int mem_mb, -+ const char *image_name, -+ const char *initrd_name, -+ const char *cmdline, -+ const char *features, -+ unsigned long flags, -+ unsigned int store_evtchn, -+ unsigned long *store_mfn, -+ unsigned int console_evtchn, unsigned long *console_mfn) -+{ -+ struct xc_dom_image *dom; -+ int rc; -+ -+ xc_dom_loginit(); -+ dom = xc_dom_allocate(cmdline, features); -+ if (0 != (rc = xc_dom_kernel_file(dom, image_name))) -+ goto out; -+ if (initrd_name && strlen(initrd_name)) -+ if (0 != (rc = xc_dom_ramdisk_file(dom, initrd_name))) -+ goto out; -+ -+ rc = xc_linux_build_internal(dom, xc_handle, domid, -+ mem_mb, flags, -+ store_evtchn, store_mfn, -+ console_evtchn, console_mfn); -+ -+ out: -+ xc_dom_release(dom); -+ return rc; -+} -Index: build-32-release304-12901/tools/libxc/Makefile -=================================================================== ---- build-32-release304-12901.orig/tools/libxc/Makefile -+++ build-32-release304-12901/tools/libxc/Makefile -@@ -24,8 +24,8 @@ GUEST_SRCS-y := - GUEST_SRCS-y += xc_load_bin.c - GUEST_SRCS-y += xc_load_elf.c - GUEST_SRCS-y += xg_private.c --GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c --GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c -+#GUEST_SRCS-$(CONFIG_X86) += xc_linux_build.c -+#GUEST_SRCS-$(CONFIG_IA64) += xc_linux_build.c - GUEST_SRCS-$(CONFIG_MIGRATE) += xc_linux_restore.c xc_linux_save.c - GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c - -@@ -58,6 +58,9 @@ GUEST_SRCS-y += xc_dom_x86.c - GUEST_SRCS-y += xc_dom_ia64.c - endif - -+GUEST_SRCS-$(CONFIG_X86) += xc_dom_compat_linux.c -+GUEST_SRCS-$(CONFIG_IA64) += xc_dom_compat_linux.c -+ - -include $(XEN_TARGET_ARCH)/Makefile - - CFLAGS += -Werror -Wmissing-prototypes diff --git a/tools-kboot.diff b/tools-kboot.diff index f7200e7..b860817 100644 --- a/tools-kboot.diff +++ b/tools-kboot.diff @@ -13,10 +13,10 @@ Signed-off-by: Gerd Hoffmann tools/kboot/select-kernel | 59 + 9 files changed, 2111 insertions(+) -Index: build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_32 +Index: xen-unstable/buildconfigs/linux-defconfig_xenUboot_x86_32 =================================================================== --- /dev/null -+++ build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_32 ++++ xen-unstable/buildconfigs/linux-defconfig_xenUboot_x86_32 @@ -0,0 +1,874 @@ +# +# Automatically generated make config: don't edit @@ -892,10 +892,10 @@ Index: build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_32 +CONFIG_X86_NO_TSS=y +CONFIG_X86_NO_IDT=y +CONFIG_KTIME_SCALAR=y -Index: build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_64 +Index: xen-unstable/buildconfigs/linux-defconfig_xenUboot_x86_64 =================================================================== --- /dev/null -+++ build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_64 ++++ xen-unstable/buildconfigs/linux-defconfig_xenUboot_x86_64 @@ -0,0 +1,653 @@ +# +# Automatically generated make config: don't edit @@ -1550,17 +1550,17 @@ Index: build-32-unstable-12542/buildconfigs/linux-defconfig_xenUboot_x86_64 +# CONFIG_CRC32 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y -Index: build-32-unstable-12542/buildconfigs/mk.linux-2.6-xenUboot +Index: xen-unstable/buildconfigs/mk.linux-2.6-xenUboot =================================================================== --- /dev/null -+++ build-32-unstable-12542/buildconfigs/mk.linux-2.6-xenUboot ++++ xen-unstable/buildconfigs/mk.linux-2.6-xenUboot @@ -0,0 +1,2 @@ +EXTRAVERSION = xenUboot +include buildconfigs/mk.linux-2.6-xen -Index: build-32-unstable-12542/tools/kboot/Makefile +Index: xen-unstable/tools/kboot/Makefile =================================================================== --- /dev/null -+++ build-32-unstable-12542/tools/kboot/Makefile ++++ xen-unstable/tools/kboot/Makefile @@ -0,0 +1,23 @@ +# +# tools/kboot/Makefile @@ -1585,10 +1585,10 @@ Index: build-32-unstable-12542/tools/kboot/Makefile +kboot.initramfs: mkinitramfs init select-kernel ../xcutils/xc_kexec + sh ./mkinitramfs | tee $@ + -Index: build-32-unstable-12542/tools/kboot/README +Index: xen-unstable/tools/kboot/README =================================================================== --- /dev/null -+++ build-32-unstable-12542/tools/kboot/README ++++ xen-unstable/tools/kboot/README @@ -0,0 +1,43 @@ + +This is a simple kexec-based boot loader @@ -1633,10 +1633,10 @@ Index: build-32-unstable-12542/tools/kboot/README + +-- +Gerd Hoffmann -Index: build-32-unstable-12542/tools/kboot/init +Index: xen-unstable/tools/kboot/init =================================================================== --- /dev/null -+++ build-32-unstable-12542/tools/kboot/init ++++ xen-unstable/tools/kboot/init @@ -0,0 +1,309 @@ +#!/bin/sh + @@ -1947,10 +1947,10 @@ Index: build-32-unstable-12542/tools/kboot/init +msg "bye ..." +banner "boot $guestos" +xc_kexec -e -Index: build-32-unstable-12542/tools/kboot/mkinitramfs +Index: xen-unstable/tools/kboot/mkinitramfs =================================================================== --- /dev/null -+++ build-32-unstable-12542/tools/kboot/mkinitramfs ++++ xen-unstable/tools/kboot/mkinitramfs @@ -0,0 +1,111 @@ +#!/bin/sh + @@ -2063,10 +2063,10 @@ Index: build-32-unstable-12542/tools/kboot/mkinitramfs + echo "file $LIB/$(basename $lib) $lib 0755 0 0" +done +echo -Index: build-32-unstable-12542/tools/kboot/select-kernel +Index: xen-unstable/tools/kboot/select-kernel =================================================================== --- /dev/null -+++ build-32-unstable-12542/tools/kboot/select-kernel ++++ xen-unstable/tools/kboot/select-kernel @@ -0,0 +1,59 @@ +#!/bin/sh + @@ -2127,10 +2127,10 @@ Index: build-32-unstable-12542/tools/kboot/select-kernel +msg "using $kernelname" +echo "$kernelname" + -Index: build-32-unstable-12542/make-kboot +Index: xen-unstable/make-kboot =================================================================== --- /dev/null -+++ build-32-unstable-12542/make-kboot ++++ xen-unstable/make-kboot @@ -0,0 +1,37 @@ +#!/bin/sh + diff --git a/tools-readnotes-gunzip.diff b/tools-readnotes-gunzip.diff deleted file mode 100644 index 0912ede..0000000 --- a/tools-readnotes-gunzip.diff +++ /dev/null @@ -1,46 +0,0 @@ -Support transparant gunzipping in the readnotes utility. - -Signed-off-by: Gerd Hoffmann ---- - tools/xcutils/readnotes.c | 14 ++++++++++++-- - 1 file changed, 12 insertions(+), 2 deletions(-) - -Index: build-32-release304-13138/tools/xcutils/readnotes.c -=================================================================== ---- build-32-release304-13138.orig/tools/xcutils/readnotes.c -+++ build-32-release304-13138/tools/xcutils/readnotes.c -@@ -11,6 +11,7 @@ - #include - - #include -+#include /* gunzip bits */ - - #include - -@@ -33,8 +34,8 @@ static void print_numeric_note(const cha - int main(int argc, char **argv) - { - const char *f; -- int fd,h,size,count; -- void *image; -+ int fd,h,size,usize,count; -+ void *image,*tmp; - struct stat st; - struct elf_binary elf; - const elf_shdr *shdr; -@@ -68,6 +69,15 @@ int main(int argc, char **argv) - } - size = st.st_size; - -+ usize = xc_dom_check_gzip(image, st.st_size); -+ if (usize) -+ { -+ tmp = malloc(usize); -+ xc_dom_do_gunzip(image, st.st_size, tmp, usize); -+ image = tmp; -+ size = usize; -+ } -+ - if (0 != elf_init(&elf, image, size)) - { - fprintf(stderr, "File %s is not an ELF image\n", f); diff --git a/tools-xc_kexec.diff b/tools-xc_kexec.diff index 8cbaa89..ca1495b 100644 --- a/tools-xc_kexec.diff +++ b/tools-xc_kexec.diff @@ -23,13 +23,13 @@ Signed-off-by: Gerd Hoffmann tools/xcutils/xc_kexec.c | 503 +++++++++++++++ 19 files changed, 4988 insertions(+), 2 deletions(-) -Index: build-32-release304-12901/tools/xcutils/Makefile +Index: xen-unstable/tools/xcutils/Makefile =================================================================== ---- build-32-release304-12901.orig/tools/xcutils/Makefile -+++ build-32-release304-12901/tools/xcutils/Makefile +--- xen-unstable.orig/tools/xcutils/Makefile ++++ xen-unstable/tools/xcutils/Makefile @@ -15,14 +15,14 @@ PROGRAMS_INSTALL_DIR = /usr/$(LIBDIR)/xe - INCLUDES += -I $(XEN_LIBXC) + INCLUDES += -I $(XEN_LIBXC) -I $(XEN_XENSTORE) -CFLAGS += -Werror -fno-strict-aliasing +CFLAGS += -g -O0 -Werror -fno-strict-aliasing @@ -39,10 +39,10 @@ Index: build-32-release304-12901/tools/xcutils/Makefile CFLAGS += -Wp,-MD,.$(@F).d PROG_DEP = .*.d --PROGRAMS = xc_restore xc_save readnotes +-PROGRAMS = xc_restore xc_save readnotes +PROGRAMS = xc_restore xc_save readnotes xc_kexec - LDLIBS = -L$(XEN_LIBXC) -lxenguest -lxenctrl + LDLIBS = -L$(XEN_LIBXC) -L$(XEN_XENSTORE) -lxenguest -lxenctrl -lxenstore @@ -35,6 +35,11 @@ build: $(PROGRAMS) $(PROGRAMS): %: %.o @@ -63,10 +63,10 @@ Index: build-32-release304-12901/tools/xcutils/Makefile + make -C helper clean -include $(PROG_DEP) -Index: build-32-release304-12901/tools/xcutils/helper/Makefile +Index: xen-unstable/tools/xcutils/helper/Makefile =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/Makefile ++++ xen-unstable/tools/xcutils/helper/Makefile @@ -0,0 +1,39 @@ + +XEN_ROOT = ../../.. @@ -107,10 +107,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/Makefile +# dependencies + +$(XEN_TARGET_ARCH)/entry.o: $(XEN_TARGET_ARCH)/entry.S $(XEN_TARGET_ARCH)/offsets.h -Index: build-32-release304-12901/tools/xcutils/helper/console.c +Index: xen-unstable/tools/xcutils/helper/console.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/console.c ++++ xen-unstable/tools/xcutils/helper/console.c @@ -0,0 +1,69 @@ +#include + @@ -181,10 +181,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/console.c + + return printed_len; +} -Index: build-32-release304-12901/tools/xcutils/helper/ctype.c +Index: xen-unstable/tools/xcutils/helper/ctype.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/ctype.c ++++ xen-unstable/tools/xcutils/helper/ctype.c @@ -0,0 +1,35 @@ +/* + * linux/lib/ctype.c @@ -221,10 +221,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/ctype.c +_L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ + +EXPORT_SYMBOL(_ctype); -Index: build-32-release304-12901/tools/xcutils/helper/ctype.h +Index: xen-unstable/tools/xcutils/helper/ctype.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/ctype.h ++++ xen-unstable/tools/xcutils/helper/ctype.h @@ -0,0 +1,54 @@ +#ifndef _LINUX_CTYPE_H +#define _LINUX_CTYPE_H @@ -280,10 +280,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/ctype.h +#define toupper(c) __toupper(c) + +#endif -Index: build-32-release304-12901/tools/xcutils/helper/helper.h +Index: xen-unstable/tools/xcutils/helper/helper.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/helper.h ++++ xen-unstable/tools/xcutils/helper/helper.h @@ -0,0 +1,107 @@ +#include +#include @@ -392,10 +392,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/helper.h +int sprintf(char * buf, const char *fmt, ...); +int vsscanf(const char * buf, const char * fmt, va_list args); +int sscanf(const char * buf, const char * fmt, ...); -Index: build-32-release304-12901/tools/xcutils/helper/main.c +Index: xen-unstable/tools/xcutils/helper/main.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/main.c ++++ xen-unstable/tools/xcutils/helper/main.c @@ -0,0 +1,651 @@ +#include +#include "hypercall.h" @@ -1048,10 +1048,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/main.c + printk("\r\n"); + start_kernel(); +} -Index: build-32-release304-12901/tools/xcutils/helper/make-offsets.c +Index: xen-unstable/tools/xcutils/helper/make-offsets.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/make-offsets.c ++++ xen-unstable/tools/xcutils/helper/make-offsets.c @@ -0,0 +1,28 @@ +#include +#include @@ -1081,10 +1081,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/make-offsets.c + vcpu_off("cr3", ctrlreg[3]); + return 0; +} -Index: build-32-release304-12901/tools/xcutils/helper/printk.c +Index: xen-unstable/tools/xcutils/helper/printk.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/printk.c ++++ xen-unstable/tools/xcutils/helper/printk.c @@ -0,0 +1,1051 @@ +/* + * linux/kernel/printk.c @@ -2137,10 +2137,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/printk.c + printk_ratelimit_burst); +} +EXPORT_SYMBOL(printk_ratelimit); -Index: build-32-release304-12901/tools/xcutils/helper/string.c +Index: xen-unstable/tools/xcutils/helper/string.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/string.c ++++ xen-unstable/tools/xcutils/helper/string.c @@ -0,0 +1,601 @@ +/* + * linux/lib/string.c @@ -2743,10 +2743,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/string.c +} +EXPORT_SYMBOL(memchr); +#endif -Index: build-32-release304-12901/tools/xcutils/helper/vsprintf.c +Index: xen-unstable/tools/xcutils/helper/vsprintf.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/vsprintf.c ++++ xen-unstable/tools/xcutils/helper/vsprintf.c @@ -0,0 +1,842 @@ +/* + * linux/lib/vsprintf.c @@ -3590,10 +3590,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/vsprintf.c +} + +EXPORT_SYMBOL(sscanf); -Index: build-32-release304-12901/tools/xcutils/helper/x86_32/div64.h +Index: xen-unstable/tools/xcutils/helper/x86_32/div64.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_32/div64.h ++++ xen-unstable/tools/xcutils/helper/x86_32/div64.h @@ -0,0 +1,48 @@ +#ifndef __I386_DIV64 +#define __I386_DIV64 @@ -3643,10 +3643,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_32/div64.h + +} +#endif -Index: build-32-release304-12901/tools/xcutils/helper/x86_32/entry.S +Index: xen-unstable/tools/xcutils/helper/x86_32/entry.S =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_32/entry.S ++++ xen-unstable/tools/xcutils/helper/x86_32/entry.S @@ -0,0 +1,49 @@ +#include "offsets.h" + @@ -3697,10 +3697,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_32/entry.S + nop + .align 4096 +hypercall_end: -Index: build-32-release304-12901/tools/xcutils/helper/x86_32/hypercall.h +Index: xen-unstable/tools/xcutils/helper/x86_32/hypercall.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_32/hypercall.h ++++ xen-unstable/tools/xcutils/helper/x86_32/hypercall.h @@ -0,0 +1,360 @@ +/****************************************************************************** + * hypercall.h @@ -4062,10 +4062,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_32/hypercall.h + + +#endif /* __HYPERCALL_H__ */ -Index: build-32-release304-12901/tools/xcutils/helper/x86_64/div64.h +Index: xen-unstable/tools/xcutils/helper/x86_64/div64.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_64/div64.h ++++ xen-unstable/tools/xcutils/helper/x86_64/div64.h @@ -0,0 +1,58 @@ +#ifndef _ASM_GENERIC_DIV64_H +#define _ASM_GENERIC_DIV64_H @@ -4125,10 +4125,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_64/div64.h +#endif /* BITS_PER_LONG */ + +#endif /* _ASM_GENERIC_DIV64_H */ -Index: build-32-release304-12901/tools/xcutils/helper/x86_64/entry.S +Index: xen-unstable/tools/xcutils/helper/x86_64/entry.S =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_64/entry.S ++++ xen-unstable/tools/xcutils/helper/x86_64/entry.S @@ -0,0 +1,50 @@ +#include "offsets.h" + @@ -4180,10 +4180,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_64/entry.S + nop + .align 4096 +hypercall_end: -Index: build-32-release304-12901/tools/xcutils/helper/x86_64/hypercall.h +Index: xen-unstable/tools/xcutils/helper/x86_64/hypercall.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/helper/x86_64/hypercall.h ++++ xen-unstable/tools/xcutils/helper/x86_64/hypercall.h @@ -0,0 +1,355 @@ +/****************************************************************************** + * hypercall.h @@ -4540,10 +4540,10 @@ Index: build-32-release304-12901/tools/xcutils/helper/x86_64/hypercall.h +} + +#endif /* __HYPERCALL_H__ */ -Index: build-32-release304-12901/tools/xcutils/kexec-syscall.h +Index: xen-unstable/tools/xcutils/kexec-syscall.h =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/kexec-syscall.h ++++ xen-unstable/tools/xcutils/kexec-syscall.h @@ -0,0 +1,80 @@ +#ifndef KEXEC_SYSCALL_H +#define KEXEC_SYSCALL_H @@ -4625,10 +4625,10 @@ Index: build-32-release304-12901/tools/xcutils/kexec-syscall.h +#define KEXEC_MAX_SEGMENTS 16 + +#endif /* KEXEC_SYSCALL_H */ -Index: build-32-release304-12901/tools/xcutils/xc_kexec.c +Index: xen-unstable/tools/xcutils/xc_kexec.c =================================================================== --- /dev/null -+++ build-32-release304-12901/tools/xcutils/xc_kexec.c ++++ xen-unstable/tools/xcutils/xc_kexec.c @@ -0,0 +1,503 @@ +#include +#include diff --git a/vgacon-50-lines.patch b/vgacon-50-lines.patch index 698eaa4..5e4e54d 100644 --- a/vgacon-50-lines.patch +++ b/vgacon-50-lines.patch @@ -1,17 +1,8 @@ -Index: xen-3.0.4-testing/xen/drivers/video/vga.c +Index: xen-unstable/xen/drivers/video/vga.c =================================================================== ---- xen-3.0.4-testing.orig/xen/drivers/video/vga.c -+++ xen-3.0.4-testing/xen/drivers/video/vga.c -@@ -557,7 +557,7 @@ static int vga_load_font(const struct fo - - static int vgacon_enabled = 0; - static int vgacon_keep = 0; --static int vgacon_lines = 25; -+static int vgacon_lines = 50; - static const struct font_desc *font; - - static int xpos, ypos; -@@ -609,6 +609,8 @@ void vga_init(void) +--- xen-unstable.orig/xen/drivers/video/vga.c ++++ xen-unstable/xen/drivers/video/vga.c +@@ -585,6 +585,8 @@ void vga_init(void) vgacon_keep = 1; else if ( strncmp(p, "text-80x", 8) == 0 ) vgacon_lines = simple_strtoul(p + 8, NULL, 10); @@ -20,25 +11,3 @@ Index: xen-3.0.4-testing/xen/drivers/video/vga.c } video = setup_vga(); -@@ -625,17 +627,18 @@ void vga_init(void) - case 34: - font = &font_vga_8x14; - break; -+ default: -+ vgacon_lines = 50; - case 43: - case 50: - case 60: - font = &font_vga_8x8; - break; -- default: -- vgacon_lines = 25; -+ case 0: - break; - } - -- if ( (font != NULL) && (vga_load_font(font, vgacon_lines) < 0) ) -+ if ( (font == NULL) || (vga_load_font(font, vgacon_lines) < 0) ) - { - vgacon_lines = 25; - font = NULL; diff --git a/vgacon-keep.patch b/vgacon-keep.patch index 2aa6bad..16405bb 100644 --- a/vgacon-keep.patch +++ b/vgacon-keep.patch @@ -1,7 +1,7 @@ -Index: 2007-01-08/xen/drivers/video/vga.c +Index: xen-unstable/xen/drivers/video/vga.c =================================================================== ---- 2007-01-08.orig/xen/drivers/video/vga.c 2007-01-11 17:41:46.000000000 +0100 -+++ 2007-01-08/xen/drivers/video/vga.c 2007-01-11 17:42:35.000000000 +0100 +--- xen-unstable.orig/xen/drivers/video/vga.c ++++ xen-unstable/xen/drivers/video/vga.c @@ -556,7 +556,6 @@ static int vga_load_font(const struct fo */ @@ -28,7 +28,7 @@ Index: 2007-01-08/xen/drivers/video/vga.c else if ( strncmp(p, "text-80x", 8) == 0 ) vgacon_lines = simple_strtoul(p + 8, NULL, 10); else if ( strncmp(p, "text", 4) == 0 && p[4] != '-' ) -@@ -627,21 +629,48 @@ void vga_init(void) +@@ -623,21 +625,48 @@ void vga_init(void) /* Disable cursor. */ vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20); @@ -82,7 +82,7 @@ Index: 2007-01-08/xen/drivers/video/vga.c static void put_newline(void) { -@@ -659,14 +688,25 @@ static void put_newline(void) +@@ -655,14 +684,25 @@ static void put_newline(void) void vga_putchar(int c) { diff --git a/x86-extra-trap-info.patch b/x86-extra-trap-info.patch index 553baf9..4ff99f7 100644 --- a/x86-extra-trap-info.patch +++ b/x86-extra-trap-info.patch @@ -1,31 +1,31 @@ -Index: 2006-12-05/xen/arch/x86/x86_32/entry.S +Index: xen-unstable/xen/arch/x86/x86_32/entry.S =================================================================== ---- 2006-12-05.orig/xen/arch/x86/x86_32/entry.S 2006-12-01 10:44:36.000000000 +0100 -+++ 2006-12-05/xen/arch/x86/x86_32/entry.S 2006-12-08 14:24:54.000000000 +0100 -@@ -382,21 +382,33 @@ nvm86_3:/* Rewrite our stack frame and r +--- xen-unstable.orig/xen/arch/x86/x86_32/entry.S ++++ xen-unstable/xen/arch/x86/x86_32/entry.S +@@ -386,21 +386,33 @@ ring1: /* obtain ss/esp from oldss/olde movb $0,TRAPBOUNCE_flags(%edx) ret .section __ex_table,"a" -- .long FLT6,domain_crash_synchronous , FLT7,domain_crash_synchronous -- .long FLT8,domain_crash_synchronous , FLT9,domain_crash_synchronous -- .long FLT10,domain_crash_synchronous , FLT11,domain_crash_synchronous -- .long FLT12,domain_crash_synchronous , FLT13,domain_crash_synchronous -- .long FLT14,domain_crash_synchronous , FLT15,domain_crash_synchronous -- .long FLT16,domain_crash_synchronous , FLT17,domain_crash_synchronous -- .long FLT18,domain_crash_synchronous , FLT19,domain_crash_synchronous -- .long FLT20,domain_crash_synchronous , FLT21,domain_crash_synchronous -- .long FLT22,domain_crash_synchronous , FLT23,domain_crash_synchronous -- .long FLT24,domain_crash_synchronous , FLT25,domain_crash_synchronous -+ .long FLT6,domain_crash_synchronous , FLT7,domain_crash_page_fault -+ .long FLT8,domain_crash_page_fault_4 , FLT9,domain_crash_page_fault_8 -+ .long FLT10,domain_crash_page_fault_12, FLT11,domain_crash_page_fault -+ .long FLT12,domain_crash_page_fault_4 , FLT13,domain_crash_synchronous -+ .long FLT14,domain_crash_page_fault , FLT15,domain_crash_page_fault_4 -+ .long FLT16,domain_crash_page_fault_8 , FLT17,domain_crash_page_fault -+ .long FLT18,domain_crash_page_fault , FLT19,domain_crash_page_fault_4 -+ .long FLT20,domain_crash_page_fault_8 , FLT21,domain_crash_page_fault_12 -+ .long FLT22,domain_crash_page_fault , FLT23,domain_crash_page_fault_4 -+ .long FLT24,domain_crash_page_fault_8 , FLT25,domain_crash_page_fault_12 +- .long .Lft6,domain_crash_synchronous , .Lft7,domain_crash_synchronous +- .long .Lft8,domain_crash_synchronous , .Lft9,domain_crash_synchronous +- .long .Lft10,domain_crash_synchronous , .Lft11,domain_crash_synchronous +- .long .Lft12,domain_crash_synchronous , .Lft13,domain_crash_synchronous +- .long .Lft14,domain_crash_synchronous , .Lft15,domain_crash_synchronous +- .long .Lft16,domain_crash_synchronous , .Lft17,domain_crash_synchronous +- .long .Lft18,domain_crash_synchronous , .Lft19,domain_crash_synchronous +- .long .Lft20,domain_crash_synchronous , .Lft21,domain_crash_synchronous +- .long .Lft22,domain_crash_synchronous , .Lft23,domain_crash_synchronous +- .long .Lft24,domain_crash_synchronous , .Lft25,domain_crash_synchronous ++ .long .Lft6,domain_crash_synchronous , .Lft7,domain_crash_page_fault ++ .long .Lft8,domain_crash_page_fault_4 , .Lft9,domain_crash_page_fault_8 ++ .long .Lft10,domain_crash_page_fault_12, .Lft11,domain_crash_page_fault ++ .long .Lft12,domain_crash_page_fault_4 , .Lft13,domain_crash_synchronous ++ .long .Lft14,domain_crash_page_fault , .Lft15,domain_crash_page_fault_4 ++ .long .Lft16,domain_crash_page_fault_8 , .Lft17,domain_crash_page_fault ++ .long .Lft18,domain_crash_page_fault , .Lft19,domain_crash_page_fault_4 ++ .long .Lft20,domain_crash_page_fault_8 , .Lft21,domain_crash_page_fault_12 ++ .long .Lft22,domain_crash_page_fault , .Lft23,domain_crash_page_fault_4 ++ .long .Lft24,domain_crash_page_fault_8 , .Lft25,domain_crash_page_fault_12 .previous +.section .rodata,"a" @@ -46,26 +46,26 @@ Index: 2006-12-05/xen/arch/x86/x86_32/entry.S domain_crash_synchronous: pushl $domain_crash_synchronous_string call printk -Index: 2006-12-05/xen/arch/x86/x86_64/entry.S +Index: xen-unstable/xen/arch/x86/x86_64/entry.S =================================================================== ---- 2006-12-05.orig/xen/arch/x86/x86_64/entry.S 2006-12-01 10:44:36.000000000 +0100 -+++ 2006-12-05/xen/arch/x86/x86_64/entry.S 2006-12-08 14:24:54.000000000 +0100 -@@ -308,17 +308,30 @@ FLT13: movq %rax,(%rsi) +--- xen-unstable.orig/xen/arch/x86/x86_64/entry.S ++++ xen-unstable/xen/arch/x86/x86_64/entry.S +@@ -339,17 +339,30 @@ create_bounce_frame: movb $0,TRAPBOUNCE_flags(%rdx) ret .section __ex_table,"a" -- .quad FLT2,domain_crash_synchronous , FLT3,domain_crash_synchronous -- .quad FLT4,domain_crash_synchronous , FLT5,domain_crash_synchronous -- .quad FLT6,domain_crash_synchronous , FLT7,domain_crash_synchronous -- .quad FLT8,domain_crash_synchronous , FLT9,domain_crash_synchronous -- .quad FLT10,domain_crash_synchronous , FLT11,domain_crash_synchronous -- .quad FLT12,domain_crash_synchronous , FLT13,domain_crash_synchronous -+ .quad FLT2,domain_crash_page_fault_32, FLT3,domain_crash_page_fault_24 -+ .quad FLT4,domain_crash_page_fault_8 , FLT5,domain_crash_page_fault_16 -+ .quad FLT6,domain_crash_page_fault , FLT7,domain_crash_page_fault -+ .quad FLT8,domain_crash_page_fault_24, FLT9,domain_crash_page_fault_16 -+ .quad FLT10,domain_crash_page_fault_8 , FLT11,domain_crash_page_fault -+ .quad FLT12,domain_crash_page_fault_8 , FLT13,domain_crash_page_fault +- .quad .Lft2,domain_crash_synchronous , .Lft3,domain_crash_synchronous +- .quad .Lft4,domain_crash_synchronous , .Lft5,domain_crash_synchronous +- .quad .Lft6,domain_crash_synchronous , .Lft7,domain_crash_synchronous +- .quad .Lft8,domain_crash_synchronous , .Lft9,domain_crash_synchronous +- .quad .Lft10,domain_crash_synchronous , .Lft11,domain_crash_synchronous +- .quad .Lft12,domain_crash_synchronous , .Lft13,domain_crash_synchronous ++ .quad .Lft2,domain_crash_page_fault_32, .Lft3,domain_crash_page_fault_24 ++ .quad .Lft4,domain_crash_page_fault_8 , .Lft5,domain_crash_page_fault_16 ++ .quad .Lft6,domain_crash_page_fault , .Lft7,domain_crash_page_fault ++ .quad .Lft8,domain_crash_page_fault_24, .Lft9,domain_crash_page_fault_16 ++ .quad .Lft10,domain_crash_page_fault_8 , .Lft11,domain_crash_page_fault ++ .quad .Lft12,domain_crash_page_fault_8 , .Lft13,domain_crash_page_fault .previous +.section .rodata,"a" @@ -84,6 +84,6 @@ Index: 2006-12-05/xen/arch/x86/x86_64/entry.S +domain_crash_page_fault: + movq %rsi,%rdi + call show_page_walk - domain_crash_synchronous: + ENTRY(domain_crash_synchronous) # Get out of the guest-save area of the stack. GET_GUEST_REGS(%rax) diff --git a/x86-mm-simplify.patch b/x86-mm-simplify.patch deleted file mode 100644 index 5304097..0000000 --- a/x86-mm-simplify.patch +++ /dev/null @@ -1,56 +0,0 @@ -Replace mfn_to_page(lXe_get_pfn()) by lXe_get_page(). - -However, what I got surprised by while looking for all of these is that -ptwr_emulated_update() uses gmfn_to_mfn() on the pte loaded from the -emulation context, while ptwr_do_page_fault() doesn't on the pte stored -into that context. Shouldn't these two be symmetric? - -Index: 2007-02-20/xen/arch/x86/mm.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm.c 2007-02-20 10:55:57.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm.c 2007-02-20 10:56:12.000000000 +0100 -@@ -794,7 +794,7 @@ static void put_page_from_l2e(l2_pgentry - { - if ( (l2e_get_flags(l2e) & _PAGE_PRESENT) && - (l2e_get_pfn(l2e) != pfn) ) -- put_page_and_type(mfn_to_page(l2e_get_pfn(l2e))); -+ put_page_and_type(l2e_get_page(l2e)); - } - - -@@ -803,7 +803,7 @@ static void put_page_from_l3e(l3_pgentry - { - if ( (l3e_get_flags(l3e) & _PAGE_PRESENT) && - (l3e_get_pfn(l3e) != pfn) ) -- put_page_and_type(mfn_to_page(l3e_get_pfn(l3e))); -+ put_page_and_type(l3e_get_page(l3e)); - } - #endif - -@@ -812,7 +812,7 @@ static void put_page_from_l4e(l4_pgentry - { - if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && - (l4e_get_pfn(l4e) != pfn) ) -- put_page_and_type(mfn_to_page(l4e_get_pfn(l4e))); -+ put_page_and_type(l4e_get_page(l4e)); - } - #endif - -@@ -3369,7 +3369,6 @@ int ptwr_do_page_fault(struct vcpu *v, u - struct cpu_user_regs *regs) - { - struct domain *d = v->domain; -- unsigned long pfn; - struct page_info *page; - l1_pgentry_t pte; - struct ptwr_emulate_ctxt ptwr_ctxt; -@@ -3383,8 +3382,7 @@ int ptwr_do_page_fault(struct vcpu *v, u - guest_get_eff_l1e(v, addr, &pte); - if ( !(l1e_get_flags(pte) & _PAGE_PRESENT) ) - goto bail; -- pfn = l1e_get_pfn(pte); -- page = mfn_to_page(pfn); -+ page = l1e_get_page(pte); - - /* We are looking only for read-only mappings of p.t. pages. */ - if ( ((l1e_get_flags(pte) & (_PAGE_PRESENT|_PAGE_RW)) != _PAGE_PRESENT) || diff --git a/x86-nmi-inject.patch b/x86-nmi-inject.patch deleted file mode 100644 index 0e02b24..0000000 --- a/x86-nmi-inject.patch +++ /dev/null @@ -1,359 +0,0 @@ -Index: 2007-02-20/xen/arch/x86/physdev.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/physdev.c 2007-02-20 10:41:50.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/physdev.c 2007-02-20 10:56:30.000000000 +0100 -@@ -143,6 +143,57 @@ ret_t do_physdev_op(int cmd, XEN_GUEST_H - break; - } - -+ case PHYSDEVOP_send_nmi: { -+ struct physdev_send_nmi send_nmi; -+ struct domain *d; -+ -+ ret = -EFAULT; -+ if ( copy_from_guest(&send_nmi, arg, 1) != 0 ) -+ break; -+ -+ ret = -EPERM; -+ if ( send_nmi.domain == DOMID_SELF ) -+ d = current->domain; -+ else if ( !IS_PRIV(current->domain) ) -+ break; -+ else -+ d = find_domain_by_id(send_nmi.domain); -+ ret = -ESRCH; -+ if ( !d ) -+ break; -+ -+ switch ( send_nmi.vcpu ) -+ { -+ struct vcpu *v; -+ -+ case XEN_SEND_NMI_ALL: -+ case XEN_SEND_NMI_ALL_BUT_SELF: -+ for_each_vcpu(d, v) -+ { -+ if ( (send_nmi.vcpu == XEN_SEND_NMI_ALL || v != current) && -+ !test_and_set_bit(_VCPUF_nmi_pending, &v->vcpu_flags) ) -+ vcpu_kick(v); -+ } -+ ret = 0; -+ break; -+ case 0 ... MAX_VIRT_CPUS - 1: -+ if ( (v = d->vcpu[send_nmi.vcpu]) != NULL ) -+ { -+ if ( !test_and_set_bit(_VCPUF_nmi_pending, &v->vcpu_flags) ) -+ vcpu_kick(v); -+ ret = 0; -+ } -+ break; -+ default: -+ ret = EINVAL; -+ break; -+ } -+ -+ if ( send_nmi.domain != DOMID_SELF ) -+ put_domain(d); -+ break; -+ } -+ - default: - ret = -ENOSYS; - break; -Index: 2007-02-20/xen/arch/x86/traps.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/traps.c 2007-02-20 10:56:27.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/traps.c 2007-02-20 10:56:30.000000000 +0100 -@@ -2516,6 +2516,12 @@ long do_set_trap_table(XEN_GUEST_HANDLE( - if ( cur.address == 0 ) - break; - -+ if ( cur.vector == 2 && !TI_GET_IF(&cur) ) -+ { -+ rc = -EINVAL; -+ break; -+ } -+ - fixup_guest_code_selector(current->domain, cur.cs); - - memcpy(&dst[cur.vector], &cur, sizeof(cur)); -Index: 2007-02-20/xen/arch/x86/x86_32/asm-offsets.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_32/asm-offsets.c 2006-12-13 11:15:54.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_32/asm-offsets.c 2007-02-20 10:56:30.000000000 +0100 -@@ -68,6 +68,7 @@ void __dummy__(void) - OFFSET(VCPU_arch_guest_fpu_ctxt, struct vcpu, arch.guest_context.fpu_ctxt); - OFFSET(VCPU_flags, struct vcpu, vcpu_flags); - OFFSET(VCPU_nmi_addr, struct vcpu, nmi_addr); -+ OFFSET(VCPU_nmi_cs, struct vcpu, arch.guest_context.trap_ctxt[2].cs); - DEFINE(_VCPUF_nmi_pending, _VCPUF_nmi_pending); - DEFINE(_VCPUF_nmi_masked, _VCPUF_nmi_masked); - DEFINE(_VGCF_failsafe_disables_events, _VGCF_failsafe_disables_events); -Index: 2007-02-20/xen/arch/x86/x86_32/entry.S -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_32/entry.S 2007-02-20 10:56:03.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_32/entry.S 2007-02-20 10:56:30.000000000 +0100 -@@ -232,7 +232,7 @@ test_all_events: - shl $IRQSTAT_shift,%eax - test %ecx,irq_stat(%eax,1) - jnz process_softirqs -- btr $_VCPUF_nmi_pending,VCPU_flags(%ebx) -+ lock btrl $_VCPUF_nmi_pending,VCPU_flags(%ebx) - jc process_nmi - test_guest_events: - movl VCPU_vcpu_info(%ebx),%eax -@@ -259,19 +259,20 @@ process_softirqs: - - ALIGN - process_nmi: -- movl VCPU_nmi_addr(%ebx),%eax -+ movzwl VCPU_nmi_cs(%ebx),%eax -+ movl VCPU_nmi_addr(%ebx),%ecx - test %eax,%eax - jz test_all_events -- bts $_VCPUF_nmi_masked,VCPU_flags(%ebx) -+ lock btsl $_VCPUF_nmi_masked,VCPU_flags(%ebx) - jc 1f - sti - leal VCPU_trap_bounce(%ebx),%edx -- movl %eax,TRAPBOUNCE_eip(%edx) -- movw $FLAT_KERNEL_CS,TRAPBOUNCE_cs(%edx) -+ movl %ecx,TRAPBOUNCE_eip(%edx) -+ movw %ax,TRAPBOUNCE_cs(%edx) - movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%edx) - call create_bounce_frame - jmp test_all_events --1: bts $_VCPUF_nmi_pending,VCPU_flags(%ebx) -+1: lock btsl $_VCPUF_nmi_pending,VCPU_flags(%ebx) - jmp test_guest_events - - bad_hypercall: -Index: 2007-02-20/xen/arch/x86/x86_64/asm-offsets.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_64/asm-offsets.c 2007-02-20 10:41:52.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_64/asm-offsets.c 2007-02-20 10:56:30.000000000 +0100 -@@ -76,6 +76,7 @@ void __dummy__(void) - OFFSET(VCPU_arch_guest_fpu_ctxt, struct vcpu, arch.guest_context.fpu_ctxt); - OFFSET(VCPU_flags, struct vcpu, vcpu_flags); - OFFSET(VCPU_nmi_addr, struct vcpu, nmi_addr); -+ OFFSET(VCPU_nmi_cs, struct vcpu, arch.guest_context.trap_ctxt[2].cs); - DEFINE(_VCPUF_nmi_pending, _VCPUF_nmi_pending); - DEFINE(_VCPUF_nmi_masked, _VCPUF_nmi_masked); - DEFINE(_VGCF_failsafe_disables_events, _VGCF_failsafe_disables_events); -Index: 2007-02-20/xen/arch/x86/x86_64/compat/entry.S -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_64/compat/entry.S 2007-02-20 10:56:03.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_64/compat/entry.S 2007-02-20 10:56:30.000000000 +0100 -@@ -68,7 +68,7 @@ compat_test_all_events: - leaq irq_stat(%rip),%rcx - testl $~0,(%rcx,%rax,1) - jnz compat_process_softirqs -- btrq $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+ lock btrl $_VCPUF_nmi_pending,VCPU_flags(%rbx) - jc compat_process_nmi - compat_test_guest_events: - movq VCPU_vcpu_info(%rbx),%rax -@@ -82,7 +82,7 @@ compat_test_guest_events: - movl VCPU_event_addr(%rbx),%eax - movl %eax,TRAPBOUNCE_eip(%rdx) - movl VCPU_event_sel(%rbx),%eax -- movl %eax,TRAPBOUNCE_cs(%rdx) -+ movw %ax,TRAPBOUNCE_cs(%rdx) - movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) - call compat_create_bounce_frame - jmp compat_test_all_events -@@ -97,20 +97,21 @@ compat_process_softirqs: - ALIGN - /* %rbx: struct vcpu */ - compat_process_nmi: -- movl VCPU_nmi_addr(%rbx),%eax -+ movzwl VCPU_nmi_cs(%rbx),%eax -+ movl VCPU_nmi_addr(%rbx),%ecx - testl %eax,%eax - jz compat_test_all_events -- btsq $_VCPUF_nmi_masked,VCPU_flags(%rbx) -+ lock btsl $_VCPUF_nmi_masked,VCPU_flags(%rbx) - jc 1f - sti - leaq VCPU_trap_bounce(%rbx),%rdx -- movl %eax,TRAPBOUNCE_eip(%rdx) -- movl $FLAT_COMPAT_KERNEL_CS,TRAPBOUNCE_cs(%rdx) -+ movl %ecx,TRAPBOUNCE_eip(%rdx) -+ movw %ax,TRAPBOUNCE_cs(%rdx) - movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) - call compat_create_bounce_frame - jmp compat_test_all_events - 1: -- btsq $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+ lock btsl $_VCPUF_nmi_pending,VCPU_flags(%rbx) - jmp compat_test_guest_events - - compat_bad_hypercall: -@@ -145,7 +146,7 @@ compat_failsafe_callback: - movl VCPU_failsafe_addr(%rbx),%eax - movl %eax,TRAPBOUNCE_eip(%rdx) - movl VCPU_failsafe_sel(%rbx),%eax -- movl %eax,TRAPBOUNCE_cs(%rdx) -+ movw %ax,TRAPBOUNCE_cs(%rdx) - movw $TBF_FAILSAFE,TRAPBOUNCE_flags(%rdx) - btq $_VGCF_failsafe_disables_events,VCPU_guest_context_flags(%rbx) - jnc 1f -Index: 2007-02-20/xen/arch/x86/x86_64/compat/traps.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_64/compat/traps.c 2007-02-20 10:41:57.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_64/compat/traps.c 2007-02-20 10:56:30.000000000 +0100 -@@ -287,6 +287,12 @@ int compat_set_trap_table(XEN_GUEST_HAND - if ( cur.address == 0 ) - break; - -+ if ( cur.vector == 2 && !TI_GET_IF(&cur) ) -+ { -+ rc = -EINVAL; -+ break; -+ } -+ - fixup_guest_code_selector(current->domain, cur.cs); - - XLAT_trap_info(dst + cur.vector, &cur); -Index: 2007-02-20/xen/arch/x86/x86_64/entry.S -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_64/entry.S 2007-02-20 10:56:03.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_64/entry.S 2007-02-20 10:56:30.000000000 +0100 -@@ -177,7 +177,7 @@ test_all_events: - leaq irq_stat(%rip),%rcx - testl $~0,(%rcx,%rax,1) - jnz process_softirqs -- btr $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+ lock btrl $_VCPUF_nmi_pending,VCPU_flags(%rbx) - jc process_nmi - test_guest_events: - movq VCPU_vcpu_info(%rbx),%rax -@@ -207,7 +207,7 @@ process_nmi: - movq VCPU_nmi_addr(%rbx),%rax - test %rax,%rax - jz test_all_events -- bts $_VCPUF_nmi_masked,VCPU_flags(%rbx) -+ lock btsl $_VCPUF_nmi_masked,VCPU_flags(%rbx) - jc 1f - sti - leaq VCPU_trap_bounce(%rbx),%rdx -@@ -215,7 +215,7 @@ process_nmi: - movw $TBF_INTERRUPT,TRAPBOUNCE_flags(%rdx) - call create_bounce_frame - jmp test_all_events --1: bts $_VCPUF_nmi_pending,VCPU_flags(%rbx) -+1: lock btsl $_VCPUF_nmi_pending,VCPU_flags(%rbx) - jmp test_guest_events - - bad_hypercall: -Index: 2007-02-20/xen/arch/x86/x86_64/physdev.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/x86_64/physdev.c 2007-02-20 10:41:50.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/x86_64/physdev.c 2007-02-20 10:56:30.000000000 +0100 -@@ -30,6 +30,10 @@ - #define physdev_irq_status_query compat_physdev_irq_status_query - #define physdev_irq_status_query_t physdev_irq_status_query_compat_t - -+#define xen_physdev_send_nmi physdev_send_nmi -+CHECK_physdev_send_nmi; -+#undef xen_physdev_send_nmi -+ - #define COMPAT - #undef guest_handle_okay - #define guest_handle_okay compat_handle_okay -Index: 2007-02-20/xen/common/kernel.c -=================================================================== ---- 2007-02-20.orig/xen/common/kernel.c 2007-02-20 10:41:46.000000000 +0100 -+++ 2007-02-20/xen/common/kernel.c 2007-02-20 10:56:30.000000000 +0100 -@@ -247,16 +247,20 @@ long register_guest_nmi_callback(unsigne - struct vcpu *v = current; - struct domain *d = current->domain; - -- if ( (d->domain_id != 0) || (v->vcpu_id != 0) ) -- return -EINVAL; -- - v->nmi_addr = address; - #ifdef CONFIG_X86 -+ v->arch.guest_context.trap_ctxt[2].vector = 2; -+ v->arch.guest_context.trap_ctxt[2].flags = 0; -+ TI_SET_IF(v->arch.guest_context.trap_ctxt + 2, 1); -+ v->arch.guest_context.trap_ctxt[2].cs = -+ !IS_COMPAT(d) ? FLAT_KERNEL_CS : FLAT_COMPAT_KERNEL_CS; -+ - /* - * If no handler was registered we can 'lose the NMI edge'. Re-assert it - * now. - */ -- if ( arch_get_nmi_reason(d) != 0 ) -+ if ( d->domain_id == 0 && v->vcpu_id == 0 && -+ arch_get_nmi_reason(d) != 0 ) - set_bit(_VCPUF_nmi_pending, &v->vcpu_flags); - #endif - -@@ -267,6 +271,11 @@ long unregister_guest_nmi_callback(void) - { - struct vcpu *v = current; - -+#ifdef CONFIG_X86 -+ v->arch.guest_context.trap_ctxt[2].cs = 0; -+ v->arch.guest_context.trap_ctxt[2].vector = 0; -+ v->arch.guest_context.trap_ctxt[2].flags = 0; -+#endif - v->nmi_addr = 0; - - return 0; -Index: 2007-02-20/xen/include/public/physdev.h -=================================================================== ---- 2007-02-20.orig/xen/include/public/physdev.h 2006-12-13 11:15:56.000000000 +0100 -+++ 2007-02-20/xen/include/public/physdev.h 2007-02-20 10:56:30.000000000 +0100 -@@ -119,6 +119,22 @@ typedef struct physdev_irq physdev_irq_t - DEFINE_XEN_GUEST_HANDLE(physdev_irq_t); - - /* -+ * Allocate or free a physical upcall vector for the specified IRQ line. -+ * @arg == pointer to physdev_irq structure. -+ */ -+#define PHYSDEVOP_send_nmi 13 -+struct physdev_send_nmi { -+ /* IN */ -+ domid_t domain; -+ uint32_t vcpu; -+}; -+typedef struct physdev_send_nmi physdev_send_nmi_t; -+DEFINE_XEN_GUEST_HANDLE(physdev_send_nmi_t); -+ -+#define XEN_SEND_NMI_ALL (~(uint32_t)0) -+#define XEN_SEND_NMI_ALL_BUT_SELF (~(uint32_t)1) -+ -+/* - * Argument to physdev_op_compat() hypercall. Superceded by new physdev_op() - * hypercall since 0x00030202. - */ -Index: 2007-02-20/xen/include/xen/sched.h -=================================================================== ---- 2007-02-20.orig/xen/include/xen/sched.h 2007-02-20 10:42:03.000000000 +0100 -+++ 2007-02-20/xen/include/xen/sched.h 2007-02-20 10:56:30.000000000 +0100 -@@ -108,7 +108,11 @@ struct vcpu - /* Bitmask of CPUs on which this VCPU may run. */ - cpumask_t cpu_affinity; - -+#ifndef CONFIG_X86 - unsigned long nmi_addr; /* NMI callback address. */ -+#else -+# define nmi_addr arch.guest_context.trap_ctxt[2].address -+#endif - - /* Bitmask of CPUs which are holding onto this VCPU's state. */ - cpumask_t vcpu_dirty_cpumask; -Index: 2007-02-20/xen/include/xlat.lst -=================================================================== ---- 2007-02-20.orig/xen/include/xlat.lst 2007-02-20 10:41:58.000000000 +0100 -+++ 2007-02-20/xen/include/xlat.lst 2007-02-20 10:56:30.000000000 +0100 -@@ -40,6 +40,7 @@ - ! memory_map memory.h - ! memory_reservation memory.h - ! translate_gpfn_list memory.h -+? physdev_send_nmi physdev.h - ! sched_poll sched.h - ? sched_remote_shutdown sched.h - ? sched_shutdown sched.h diff --git a/x86-ptwr_emulate.patch b/x86-ptwr_emulate.patch deleted file mode 100644 index bac6a76..0000000 --- a/x86-ptwr_emulate.patch +++ /dev/null @@ -1,33 +0,0 @@ -Index: 2007-02-20/xen/arch/x86/mm.c -=================================================================== ---- 2007-02-20.orig/xen/arch/x86/mm.c 2007-02-20 10:56:12.000000000 +0100 -+++ 2007-02-20/xen/arch/x86/mm.c 2007-02-20 10:56:25.000000000 +0100 -@@ -3252,14 +3252,15 @@ static int ptwr_emulated_update( - { - if ( (CONFIG_PAGING_LEVELS == 3 || IS_COMPAT(d)) && - (bytes == 4) && -+ (addr & 4) && - !do_cmpxchg && - (l1e_get_flags(nl1e) & _PAGE_PRESENT) ) - { - /* -- * If this is a half-write to a PAE PTE then we assume that the -- * guest has simply got the two writes the wrong way round. We -- * zap the PRESENT bit on the assumption the bottom half will be -- * written immediately after we return to the guest. -+ * If this is an upper half write to a PAE PTE then we assume -+ * that the guest has simply got the two writes the wrong way -+ * round. We zap the PRESENT bit on the assumption the bottom -+ * half will be written immediately after we return to the guest. - */ - MEM_LOG("ptwr_emulate: fixing up invalid PAE PTE %"PRIpte, - l1e_get_intpte(nl1e)); -@@ -3391,7 +3392,7 @@ int ptwr_do_page_fault(struct vcpu *v, u - (page_get_owner(page) != d) ) - goto bail; - -- ptwr_ctxt.ctxt.regs = guest_cpu_user_regs(); -+ ptwr_ctxt.ctxt.regs = regs; - ptwr_ctxt.ctxt.mode = !IS_COMPAT(d) ? X86EMUL_MODE_HOST : X86EMUL_MODE_PROT32; - ptwr_ctxt.cr2 = addr; - ptwr_ctxt.pte = pte; diff --git a/xen-3.0.4-testing-src.tar.bz2 b/xen-3.0.4-testing-src.tar.bz2 deleted file mode 100644 index 12b629f..0000000 --- a/xen-3.0.4-testing-src.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ed27830300bd6d68d35737d3e8deefe815115f2d165574c8a1f527ee8ec6a606 -size 5383589 diff --git a/xen-3.0.5-testing-src.tar.bz2 b/xen-3.0.5-testing-src.tar.bz2 new file mode 100644 index 0000000..6832bba --- /dev/null +++ b/xen-3.0.5-testing-src.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e8a7b00a1dbc6d63ffb4b8080dbf94ed264d2cef9a5b79ecaa18e21f1ef1366e +size 5773489 diff --git a/xen-bonding.diff b/xen-bonding.diff index 945fb6b..dbd52ea 100644 --- a/xen-bonding.diff +++ b/xen-bonding.diff @@ -1,7 +1,7 @@ -Index: xen-3.0.4-testing/tools/examples/network-bridge +Index: xen-unstable/tools/examples/network-bridge =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/network-bridge -+++ xen-3.0.4-testing/tools/examples/network-bridge +--- xen-unstable.orig/tools/examples/network-bridge ++++ xen-unstable/tools/examples/network-bridge @@ -143,6 +143,21 @@ antispoofing () { iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT } @@ -24,7 +24,7 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge # Usage: show_status dev bridge # Print ifconfig and routes. show_status () { -@@ -185,10 +200,11 @@ using loopback.nloopbacks= on the dom +@@ -184,10 +199,11 @@ using netloop.nloopbacks= on the doma create_bridge ${bridge} @@ -38,7 +38,7 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge transfer_addrs ${netdev} ${vdev} ifdown ${netdev} ip link set ${netdev} name ${pdev} -@@ -203,6 +219,13 @@ using loopback.nloopbacks= on the dom +@@ -202,6 +218,13 @@ using netloop.nloopbacks= on the doma add_to_bridge2 ${bridge} ${pdev} ip link set ${netdev} up ifup ${hwddev} @@ -50,9 +50,9 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge + transfer_addrs ${netdev} ${bridge} + transfer_routes ${netdev} ${bridge} else - # old style without ${vdev} - transfer_addrs ${netdev} ${bridge} -@@ -241,6 +264,10 @@ op_stop () { + ip link set ${bridge} arp on + ip link set ${bridge} multicast on +@@ -244,6 +267,10 @@ op_stop () { ip link set ${pdev} name ${netdev} ifup ${netdev} else diff --git a/xen-bootloader-dryrun.diff b/xen-bootloader-dryrun.diff index 373f14e..987e09a 100644 --- a/xen-bootloader-dryrun.diff +++ b/xen-bootloader-dryrun.diff @@ -1,18 +1,18 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py +Index: xen-unstable/tools/python/xen/xend/XendBootloader.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendBootloader.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py -@@ -22,7 +22,7 @@ from XendLogging import log - from XendError import VmError +--- xen-unstable.orig/tools/python/xen/xend/XendBootloader.py ++++ xen-unstable/tools/python/xen/xend/XendBootloader.py +@@ -25,7 +25,7 @@ import pty, termios, fcntl + from xen.lowlevel import ptsname - def bootloader(blexec, disk, quiet = False, blargs = '', kernel = '', + def bootloader(blexec, disk, dom, quiet = False, blargs = '', kernel = '', - ramdisk = '', kernel_args = ''): + ramdisk = '', kernel_args = '', dryrun = False): """Run the boot loader executable on the given disk and return a config image. @param blexec Binary to use as the boot loader -@@ -55,6 +55,8 @@ def bootloader(blexec, disk, quiet = Fal - args = [ blexec ] +@@ -91,6 +91,8 @@ def bootloader(blexec, disk, dom, quiet + args.append("--args=%s" % kernel_args) if quiet: args.append("-q") + if dryrun: diff --git a/xen-bootloader-nohang.diff b/xen-bootloader-nohang.diff deleted file mode 100644 index 88e4940..0000000 --- a/xen-bootloader-nohang.diff +++ /dev/null @@ -1,32 +0,0 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendBootloader.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendBootloader.py -@@ -70,20 +70,18 @@ def bootloader(blexec, disk, quiet = Fal - - while True: - try: -- r = os.open(fifo, os.O_RDONLY) -+ r = os.open(fifo, os.O_RDONLY, os.O_NONBLOCK) - except OSError, e: - if e.errno == errno.EINTR: - continue - break - ret = "" -- while True: -- select.select([r], [], []) -- s = os.read(r, 1024) -- ret = ret + s -- if len(s) == 0: -- break -- -- os.waitpid(child, 0) -+ while os.waitpid(child, os.WNOHANG) == (0, 0): -+ # Large timeout, because crashed bootloader is a corner case -+ if select.select([r], [], [], 5.0)[0]: -+ s = os.read(r, 1024) -+ ret = ret + s -+ - os.close(r) - os.unlink(fifo) - diff --git a/xen-bootloader-tidy.diff b/xen-bootloader-tidy.diff index d3363aa..8fef16a 100644 --- a/xen-bootloader-tidy.diff +++ b/xen-bootloader-tidy.diff @@ -1,13 +1,13 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -1589,7 +1589,7 @@ class XendDomainInfo: - log.info("Unmounting %s from %s." % - (fn, BOOTLOADER_LOOPBACK_DEVICE)) +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -1820,7 +1820,7 @@ class XendDomainInfo: + log.info("Unmounting %s from %s." % + (fn, BOOTLOADER_LOOPBACK_DEVICE)) -- dom0.destroyDevice('tap', '/dev/xvdp') -+ dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE) - - break +- dom0.destroyDevice('tap', '/dev/xvdp') ++ dom0.destroyDevice('tap', BOOTLOADER_LOOPBACK_DEVICE) + if blcfg is None: + msg = "Had a bootloader specified, but can't find disk" diff --git a/xen-changeset.diff b/xen-changeset.diff index 41b26ba..47bf6b5 100644 --- a/xen-changeset.diff +++ b/xen-changeset.diff @@ -1,13 +1,13 @@ -Index: xen-3.0.4-testing/xen/Makefile +Index: xen-unstable/xen/Makefile =================================================================== ---- xen-3.0.4-testing.orig/xen/Makefile -+++ xen-3.0.4-testing/xen/Makefile +--- xen-unstable.orig/xen/Makefile ++++ xen-unstable/xen/Makefile @@ -1,3 +1,4 @@ +export XEN_CHANGESET = unavailable # This is the correct place to edit the build version. # All other places this is stored (eg. compile.h) should be autogenerated. export XEN_VERSION = 3 -@@ -103,7 +104,7 @@ include/xen/compile.h: include/xen/compi +@@ -112,7 +113,7 @@ include/xen/compile.h: include/xen/compi -e 's/@@version@@/$(XEN_VERSION)/g' \ -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \ -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \ diff --git a/xen-config.diff b/xen-config.diff index b24fae5..b10535e 100644 --- a/xen-config.diff +++ b/xen-config.diff @@ -1,14 +1,15 @@ -Index: xen-unstable/Config.mk +Index: xen-3.0.5-testing/Config.mk =================================================================== ---- xen-unstable.orig/Config.mk -+++ xen-unstable/Config.mk -@@ -70,7 +70,7 @@ ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_ +--- xen-3.0.5-testing.orig/Config.mk ++++ xen-3.0.5-testing/Config.mk +@@ -89,8 +89,8 @@ ACM_DEFAULT_SECURITY_POLICY ?= ACM_NULL_ # Optional components - XENSTAT_XENTOP ?= y - VTPM_TOOLS ?= n + XENSTAT_XENTOP ?= y + VTPM_TOOLS ?= n -LIBXENAPI_BINDINGS ?= n --XENFB_TOOLS ?= n +-XENFB_TOOLS ?= n +LIBXENAPI_BINDINGS ?= y -+XENFB_TOOLS ?= y ++XENFB_TOOLS ?= y + PYTHON_TOOLS ?= y -include $(XEN_ROOT)/.config diff --git a/xen-destdir.diff b/xen-destdir.diff index a70280c..5cfc614 100644 --- a/xen-destdir.diff +++ b/xen-destdir.diff @@ -1,35 +1,18 @@ -Index: xen-3.0.4-testing/docs/Makefile +Index: xen-3.0.5-testing/docs/Makefile =================================================================== ---- xen-3.0.4-testing.orig/docs/Makefile -+++ xen-3.0.4-testing/docs/Makefile -@@ -13,8 +13,8 @@ LATEX2HTML := latex2html - DOXYGEN := doxygen - POD2MAN := pod2man - --pkgdocdir := /usr/share/doc/xen --mandir := /usr/share/man -+pkgdocdir := $(DOCDIR) -+mandir := $(MANDIR) - - DOC_MAN5SRC := $(wildcard man/*.pod.5) - DOC_MAN1SRC := $(wildcard man/*.pod.1) -@@ -87,13 +87,13 @@ distclean: clean - .PHONY: install - install: all - rm -rf $(DESTDIR)$(pkgdocdir) -- $(INSTALL_DIR) $(DESTDIR)$(pkgdocdir) -+ $(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)/html - cp -dR ps $(DESTDIR)$(pkgdocdir) - cp -dR pdf $(DESTDIR)$(pkgdocdir) -+ cp -dR html.done/* $(DESTDIR)$(pkgdocdir)/html +--- xen-3.0.5-testing.orig/docs/Makefile ++++ xen-3.0.5-testing/docs/Makefile +@@ -90,7 +90,8 @@ install: all $(INSTALL_DIR) $(DESTDIR)$(mandir) cp -dR man1 $(DESTDIR)$(mandir) cp -dR man5 $(DESTDIR)$(mandir) - [ ! -d html ] || cp -dR html $(DESTDIR)$(pkgdocdir) ++ $(INSTALL_DIR) $(DESTDIR)$(pkgdocdir)/html ++ cp -dR html.done/* $(DESTDIR)$(pkgdocdir)/html pdf/%.pdf: ps/%.ps $(INSTALL_DIR) $(@D) -@@ -117,3 +117,9 @@ html/%/index.html: src/%.tex +@@ -114,3 +115,9 @@ html/%/index.html: src/%.tex $(LATEX2HTML) -split 0 -show_section_numbers -toc_depth 3 -nonavigation \ -numbered_footnotes -local_icons -noinfo -math -dir $(@D) \ $< 1>/dev/null 2>/dev/null @@ -39,10 +22,10 @@ Index: xen-3.0.4-testing/docs/Makefile + ln -sf $*.html html.done/$*/index.html + rm -rf html/ + -Index: xen-3.0.4-testing/tools/xentrace/Makefile +Index: xen-3.0.5-testing/tools/xentrace/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/xentrace/Makefile -+++ xen-3.0.4-testing/tools/xentrace/Makefile +--- xen-3.0.5-testing.orig/tools/xentrace/Makefile ++++ xen-3.0.5-testing/tools/xentrace/Makefile @@ -38,14 +38,14 @@ install: build [ -d $(DESTDIR)/usr/bin ] || $(INSTALL_DIR) $(DESTDIR)/usr/bin [ -z "$(LIBBIN)" ] || [ -d $(DESTDIR)/usr/$(LIBDIR)/xen/bin ] || \ @@ -64,11 +47,11 @@ Index: xen-3.0.4-testing/tools/xentrace/Makefile .PHONY: clean clean: -Index: xen-3.0.4-testing/tools/examples/Makefile +Index: xen-3.0.5-testing/tools/examples/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/Makefile -+++ xen-3.0.4-testing/tools/examples/Makefile -@@ -38,18 +38,6 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent +--- xen-3.0.5-testing.orig/tools/examples/Makefile ++++ xen-3.0.5-testing/tools/examples/Makefile +@@ -41,18 +41,6 @@ XEN_HOTPLUG_SCRIPTS = xen-backend.agent UDEV_RULES_DIR = /etc/udev UDEV_RULES = xen-backend.rules @@ -87,7 +70,7 @@ Index: xen-3.0.4-testing/tools/examples/Makefile .PHONY: all all: -@@ -57,15 +45,15 @@ all: +@@ -60,15 +48,15 @@ all: build: .PHONY: install @@ -106,7 +89,7 @@ Index: xen-3.0.4-testing/tools/examples/Makefile .PHONY: install-configs install-configs: $(XEN_CONFIGS) -@@ -106,9 +94,7 @@ install-udev: +@@ -109,9 +97,7 @@ install-udev: $(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d for i in $(UDEV_RULES); \ do \ @@ -117,57 +100,140 @@ Index: xen-3.0.4-testing/tools/examples/Makefile done .PHONY: clean -Index: xen-3.0.4-testing/tools/security/Makefile +Index: xen-3.0.5-testing/tools/security/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/security/Makefile -+++ xen-3.0.4-testing/tools/security/Makefile -@@ -73,9 +73,9 @@ install: all $(ACM_CONFIG_FILE) - $(INSTALL_DIR) -p $(DESTDIR)$(ACM_SECGEN_CGIDIR) - $(INSTALL_PROG) -p $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR) +--- xen-3.0.5-testing.orig/tools/security/Makefile ++++ xen-3.0.5-testing/tools/security/Makefile +@@ -69,9 +69,9 @@ install: all $(ACM_CONFIG_FILE) + $(INSTALL_DIR) $(DESTDIR)$(ACM_SECGEN_CGIDIR) + $(INSTALL_PROG) $(ACM_INST_CGI) $(DESTDIR)$(ACM_SECGEN_CGIDIR) ifndef XEN_PYTHON_NATIVE_INSTALL -- python python/setup.py install --home="$(DESTDIR)/usr" -+ python python/setup.py install --home="$(DESTDIR)/usr" --prefix="" +- python python/setup.py install --home="$(DESTDIR)/usr" --install-lib="$(DESTDIR)$(LIBPATH)/python" ++ python python/setup.py install --home="$(DESTDIR)/usr" --install-lib="$(DESTDIR)$(LIBPATH)/python" --prefix="" else - python python/setup.py install --root="$(DESTDIR)" + python python/setup.py install --root="$(DESTDIR)" --prefix="/usr" endif else .PHONY: all -Index: xen-3.0.4-testing/tools/pygrub/Makefile +Index: xen-3.0.5-testing/tools/pygrub/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/pygrub/Makefile -+++ xen-3.0.4-testing/tools/pygrub/Makefile -@@ -15,7 +15,7 @@ install: all - $(INSTALL_DIR) -p $(DESTDIR)/var/run/xend/boot +--- xen-3.0.5-testing.orig/tools/pygrub/Makefile ++++ xen-3.0.5-testing/tools/pygrub/Makefile +@@ -16,7 +16,7 @@ install: all + $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot else install: all - CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr" - $(INSTALL_DIR) -p $(DESTDIR)/var/run/xend/boot + $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot endif -Index: xen-3.0.4-testing/tools/python/Makefile +Index: xen-3.0.5-testing/tools/python/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/python/Makefile -+++ xen-3.0.4-testing/tools/python/Makefile -@@ -14,7 +14,7 @@ install: all - CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force +--- xen-3.0.5-testing.orig/tools/python/Makefile ++++ xen-3.0.5-testing/tools/python/Makefile +@@ -60,7 +60,7 @@ install: install-messages install-dtd + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force --install-lib="$(DESTDIR)$(LIBPATH)/python" else - install: all + install: install-messages install-dtd - CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force + CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --prefix="/usr" --force endif - .PHONY: test -Index: xen-3.0.4-testing/tools/Makefile + install-dtd: all +Index: xen-3.0.5-testing/tools/Makefile =================================================================== ---- xen-3.0.4-testing.orig/tools/Makefile -+++ xen-3.0.4-testing/tools/Makefile +--- xen-3.0.5-testing.orig/tools/Makefile ++++ xen-3.0.5-testing/tools/Makefile @@ -25,7 +25,6 @@ SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen # These don't cross-compile ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) - SUBDIRS-y += python --SUBDIRS-y += pygrub + SUBDIRS-$(PYTHON_TOOLS) += python +-SUBDIRS-$(PYTHON_TOOLS) += pygrub endif .PHONY: all +Index: xen-3.0.5-testing/docs/Docs.mk +=================================================================== +--- xen-3.0.5-testing.orig/docs/Docs.mk ++++ xen-3.0.5-testing/docs/Docs.mk +@@ -8,6 +8,6 @@ POD2MAN := pod2man + DOT := dot + NEATO := neato + +-pkgdocdir := /usr/share/doc/xen +-mandir := /usr/share/man ++pkgdocdir := $(DOCDIR) ++mandir := $(MANDIR) + +Index: xen-3.0.5-testing/tools/misc/xen-python-path +=================================================================== +--- xen-3.0.5-testing.orig/tools/misc/xen-python-path ++++ xen-3.0.5-testing/tools/misc/xen-python-path +@@ -30,7 +30,8 @@ import sys + + for p in ['python%s' % sys.version[:3], 'python']: + for l in ['/usr/lib64', '/usr/lib']: +- d = os.path.join(l, p) ++ for s in ['site-packages', '']: ++ d = os.path.join(l, p, s) + if os.path.exists(os.path.join(d, AUXBIN)): + sys.path.append(d) + import xen.util.auxbin +Index: xen-3.0.5-testing/tools/xenstore/Makefile +=================================================================== +--- xen-3.0.5-testing.orig/tools/xenstore/Makefile ++++ xen-3.0.5-testing/tools/xenstore/Makefile +@@ -24,6 +24,7 @@ TESTENV = XENSTORED_ROOTDIR=$(TESTDIR) + CLIENTS := xenstore-exists xenstore-list xenstore-read xenstore-rm xenstore-chmod + CLIENTS += xenstore-write + CLIENTS_OBJS := $(patsubst xenstore-%,xenstore_%.o,$(CLIENTS)) ++CLIENTS_DOMU := $(patsubst xenstore-%,domu-xenstore-%,$(CLIENTS)) + + XENSTORED_OBJS = xenstored_core.o xenstored_watch.o xenstored_domain.o xenstored_transaction.o xs_lib.o talloc.o utils.o tdb.o hashtable.o + +@@ -33,7 +34,7 @@ XENSTORED_OBJS_$(CONFIG_SunOS) = xenstor + XENSTORED_OBJS += $(XENSTORED_OBJS_y) + + .PHONY: all +-all: libxenstore.so libxenstore.a xenstored $(CLIENTS) xs_tdb_dump xenstore-control xenstore-ls ++all: libxenstore.so libxenstore.a xenstored $(CLIENTS) $(CLIENTS_DOMU) xs_tdb_dump xenstore-control xenstore-ls + + test_interleaved_transactions: test_interleaved_transactions.o + $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -L. -lxenstore -o $@ +@@ -47,6 +48,9 @@ xenstored: $(XENSTORED_OBJS) + $(CLIENTS): xenstore-%: xenstore_%.o libxenstore.so + $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lxenstore $(SOCKET_LIBS) -o $@ + ++$(CLIENTS_DOMU): domu-xenstore-%: xenstore_%.o libxenstore.a ++ $(CC) $(CFLAGS) $(LDFLAGS) $< $(LOADLIBES) $(LDLIBS) -L. -lpthread libxenstore.a $(SOCKET_LIBS) -o $@ ++ + $(CLIENTS_OBJS): xenstore_%.o: xenstore_client.c + $(COMPILE.c) -DCLIENT_$(*F) -o $@ $< + +@@ -101,7 +105,7 @@ clean: testsuite-clean + rm -f *.a *.o *.opic *.so* + rm -f xenstored xs_random xs_stress xs_crashme + rm -f xs_test xenstored_test xs_tdb_dump xenstore-control xenstore-ls +- rm -f $(CLIENTS) ++ rm -f $(CLIENTS) $(CLIENTS_DOMU) + $(RM) $(PROG_DEP) + + .PHONY: print-dir +@@ -170,11 +174,15 @@ tarball: clean + install: all + $(INSTALL_DIR) $(DESTDIR)/var/run/xenstored + $(INSTALL_DIR) $(DESTDIR)/var/lib/xenstored ++ $(INSTALL_DIR) $(DESTDIR)/bin + $(INSTALL_DIR) $(DESTDIR)/usr/bin + $(INSTALL_DIR) $(DESTDIR)/usr/sbin + $(INSTALL_DIR) $(DESTDIR)/usr/include + $(INSTALL_PROG) xenstored $(DESTDIR)/usr/sbin + $(INSTALL_PROG) $(CLIENTS) $(DESTDIR)/usr/bin ++ for client in $(CLIENTS_DOMU); do \ ++ $(INSTALL_PROG) $$client $(DESTDIR)/bin/$${client/domu-}; \ ++ done + $(INSTALL_PROG) xenstore-control $(DESTDIR)/usr/bin + $(INSTALL_PROG) xenstore-ls $(DESTDIR)/usr/bin + $(INSTALL_DIR) $(DESTDIR)/usr/$(LIBDIR) diff --git a/xen-disable-qemu-monitor.diff b/xen-disable-qemu-monitor.diff new file mode 100644 index 0000000..c84fc94 --- /dev/null +++ b/xen-disable-qemu-monitor.diff @@ -0,0 +1,74 @@ +CVE-2007-0998 - remote compromise of dom0 + +Rather than completely disabling QEMU's console (which would remove +the "sendkey" command, among other useful things), remove all console +commands that can read/write dom0's state. + + +Index: xen-unstable/tools/ioemu/monitor.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/monitor.c ++++ xen-unstable/tools/ioemu/monitor.c +@@ -1158,6 +1158,7 @@ static term_cmd_t term_cmds[] = { + "", "commit changes to the disk images (if -snapshot is used)" }, + { "info", "s?", do_info, + "subcommand", "show various information about the system state" }, ++#ifdef CONFIG_TRUSTED_CLIENT + { "q|quit", "", do_quit, + "", "quit the emulator" }, + { "eject", "-fB", do_eject, +@@ -1168,6 +1169,7 @@ static term_cmd_t term_cmds[] = { + "filename", "save screen into PPM image 'filename'" }, + { "log", "s", do_log, + "item1[,...]", "activate logging of the specified items to '/tmp/qemu.log'" }, ++#endif + #ifndef CONFIG_DM + { "savevm", "F", do_savevm, + "filename", "save the whole virtual machine state to 'filename'" }, +@@ -1199,12 +1201,14 @@ static term_cmd_t term_cmds[] = { + { "system_powerdown", "", do_system_powerdown, + "", "send system power down event" }, + #endif /* !CONFIG_DM */ ++#ifdef CONFIG_TRUSTED_CLIENT + { "sum", "ii", do_sum, + "addr size", "compute the checksum of a memory region" }, + { "usb_add", "s", do_usb_add, + "device", "add USB device (e.g. 'host:bus.addr' or 'host:vendor_id:product_id')" }, + { "usb_del", "s", do_usb_del, + "device", "remove USB device 'bus.addr'" }, ++#endif + #ifndef CONFIG_DM + { "cpu", "i", do_cpu_set, + "index", "set the default CPU" }, +@@ -1213,6 +1217,7 @@ static term_cmd_t term_cmds[] = { + "dx dy [dz]", "send mouse move events" }, + { "mouse_button", "i", do_mouse_button, + "state", "change mouse button state (1=L, 2=M, 4=R)" }, ++#ifdef CONFIG_TRUSTED_CLIENT + #ifdef HAS_AUDIO + { "wavcapture", "si?i?i?", do_wav_capture, + "path [frequency bits channels]", +@@ -1220,6 +1225,7 @@ static term_cmd_t term_cmds[] = { + #endif + { "stopcapture", "i", do_stop_capture, + "capture index", "stop capture" }, ++#endif + { NULL, NULL, }, + }; + +@@ -1258,6 +1264,7 @@ static term_cmd_t info_cmds[] = { + #endif /* !CONFIG_DM */ + { "usb", "", usb_info, + "", "show guest USB devices", }, ++#ifdef CONFIG_TRUSTED_CLIENT + { "usbhost", "", usb_host_info, + "", "show host USB devices", }, + { "profile", "", do_info_profile, +@@ -1268,6 +1275,7 @@ static term_cmd_t info_cmds[] = { + { "hvmiopage", "", sp_info, + "", "show HVM device model shared page info", }, + #endif /* CONFIG_DM */ ++#endif + { NULL, NULL, }, + }; + diff --git a/xen-generate-foreign-headers.diff b/xen-generate-foreign-headers.diff index 4fd8d76..3479e44 100644 --- a/xen-generate-foreign-headers.diff +++ b/xen-generate-foreign-headers.diff @@ -1,406 +1,22 @@ -Generate headers with arch-specific structs. - -This patch adds a script to generate headers with arch-specific -structs which can be included on any architecture. Can be used -to deal with structs of "foreign" architectures, needed for -32-on-64 support for example. - -Signed-off-by: Gerd Hoffmann ---- - tools/Rules.mk | 2 - xen/Makefile | 5 - xen/include/public/foreign/Makefile | 30 +++++ - xen/include/public/foreign/mkchecker.py | 58 +++++++++++ - xen/include/public/foreign/mkheader.py | 153 ++++++++++++++++++++++++++++++ - xen/include/public/foreign/reference.size | 17 +++ - xen/include/public/foreign/structs.py | 49 +++++++++ - 7 files changed, 314 insertions(+) - -Index: xen-3.0.4-testing/xen/include/public/foreign/Makefile +Index: xen-unstable/xen/include/public/foreign/Makefile =================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/public/foreign/Makefile -@@ -0,0 +1,37 @@ -+XEN_ROOT := ../../../.. -+include $(XEN_ROOT)/tools/Rules.mk -+ -+architectures := x86_32 x86_64 ia64 -+headers := $(patsubst %, %.h, $(architectures)) -+scripts := $(wildcard *.py) -+ -+.PHONY: all clean check-headers -+all: $(headers) check-headers -+ -+clean: -+ rm -f $(headers) -+ rm -f checker checker.c $(XEN_TARGET_ARCH).size -+ rm -f *.pyc *.o *~ -+ -+check-headers: checker -+ifeq ($(CROSS_COMPILE),) -+ ./checker > $(XEN_TARGET_ARCH).size -+ diff -u reference.size $(XEN_TARGET_ARCH).size -+else -+ @echo "cross build: skipping check" -+endif -+ -+x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts) -+ python mkheader.py $* $@ $(filter %.h,$^) -+ -+x86_64.h: ../arch-x86/xen-x86_64.h ../arch-x86/xen.h ../xen.h $(scripts) -+ python mkheader.py $* $@ $(filter %.h,$^) -+ -+ia64.h: ../arch-ia64.h ../xen.h $(scripts) -+ python mkheader.py $* $@ $(filter %.h,$^) -+ +--- xen-unstable.orig/xen/include/public/foreign/Makefile ++++ xen-unstable/xen/include/public/foreign/Makefile +@@ -17,8 +17,6 @@ ifeq ($(CROSS_COMPILE),) + check-headers: checker + ./checker > $(XEN_TARGET_ARCH).size + diff -u reference.size $(XEN_TARGET_ARCH).size +-checker: checker.c $(headers) +- $(HOSTCC) $(HOSTCFLAGS) -o $@ $< + else + check-headers: + @echo "cross build: skipping check" +@@ -33,5 +31,8 @@ x86_64.h: ../arch-x86/xen-x86_64.h ../ar + ia64.h: ../arch-ia64.h ../xen.h $(scripts) + python mkheader.py $* $@ $(filter %.h,$^) + +checker: checker.c $(headers) -+ $(HOSTCC) -o $@ $< ++ $(HOSTCC) $(HOSTCFLAGS) -o $@ $< + -+checker.c: $(scripts) -+ python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures) -Index: xen-3.0.4-testing/xen/include/public/foreign/mkheader.py -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/public/foreign/mkheader.py -@@ -0,0 +1,153 @@ -+#!/usr/bin/python -+ -+import sys, re; -+from structs import structs, defines; -+ -+# command line arguments -+arch = sys.argv[1]; -+outfile = sys.argv[2]; -+infiles = sys.argv[3:]; -+ -+ -+########################################################################### -+# configuration #2: architecture information -+ -+inttypes = {}; -+header = {}; -+footer = {}; -+ -+# x86_32 -+inttypes["x86_32"] = { -+ "unsigned long" : "uint32_t", -+ "long" : "uint32_t", -+ "xen_pfn_t" : "uint32_t", -+}; -+header["x86_32"] = """ -+#define __i386___X86_32 1 -+#pragma pack(push, 4) -+"""; -+footer["x86_32"] = """ -+#pragma pack(pop) -+"""; -+ -+# x86_64 -+inttypes["x86_64"] = { -+ "unsigned long" : "__align8__ uint64_t", -+ "long" : "__align8__ uint64_t", -+ "xen_pfn_t" : "__align8__ uint64_t", -+}; -+header["x86_64"] = """ -+#ifdef __GNUC__ -+# define __DECL_REG(name) union { uint64_t r ## name, e ## name; } -+# define __align8__ __attribute__((aligned (8))) -+#else -+# define __DECL_REG(name) uint64_t r ## name -+# define __align8__ FIXME -+#endif -+#define __x86_64___X86_64 1 -+"""; -+ -+# ia64 -+inttypes["ia64"] = { -+ "unsigned long" : "__align8__ uint64_t", -+ "long" : "__align8__ uint64_t", -+ "xen_pfn_t" : "__align8__ uint64_t", -+ "long double" : "__align16__ ldouble_t", -+}; -+header["ia64"] = """ -+#define __align8__ __attribute__((aligned (8))) -+#define __align16__ __attribute__((aligned (16))) -+typedef unsigned char ldouble_t[16]; -+"""; -+ -+ -+########################################################################### -+# main -+ -+input = ""; -+output = ""; -+fileid = re.sub("[-.]", "_", "__FOREIGN_%s__" % outfile.upper()); -+ -+# read input header files -+for name in infiles: -+ f = open(name, "r"); -+ input += f.read(); -+ f.close(); -+ -+# add header -+output += """ -+/* -+ * public xen defines and struct for %s -+ * generated by %s -- DO NOT EDIT -+ */ -+ -+#ifndef %s -+#define %s 1 -+ -+""" % (arch, sys.argv[0], fileid, fileid) -+ -+if arch in header: -+ output += header[arch]; -+ output += "\n"; -+ -+# add defines to output -+for line in re.findall("#define[^\n]+", input): -+ for define in defines: -+ regex = "#define\s+%s\\b" % define; -+ match = re.search(regex, line); -+ if None == match: -+ continue; -+ if define.upper()[0] == define[0]: -+ replace = define + "_" + arch.upper(); -+ else: -+ replace = define + "_" + arch; -+ regex = "\\b%s\\b" % define; -+ output += re.sub(regex, replace, line) + "\n"; -+output += "\n"; -+ -+# delete defines, comments, empty lines -+input = re.sub("#define[^\n]+\n", "", input); -+input = re.compile("/\*(.*?)\*/", re.S).sub("", input) -+input = re.compile("\n\s*\n", re.S).sub("\n", input); -+ -+# add structs to output -+for struct in structs: -+ regex = "struct\s+%s\s*\{(.*?)\n\};" % struct; -+ match = re.search(regex, input, re.S) -+ if None == match: -+ output += "#define %s_has_no_%s 1\n" % (arch, struct); -+ else: -+ output += "struct %s_%s {%s\n};\n" % (struct, arch, match.group(1)); -+ output += "typedef struct %s_%s %s_%s_t;\n" % (struct, arch, struct, arch); -+ output += "\n"; -+ -+# add footer -+if arch in footer: -+ output += footer[arch]; -+ output += "\n"; -+output += "#endif /* %s */\n" % fileid; -+ -+# replace: defines -+for define in defines: -+ if define.upper()[0] == define[0]: -+ replace = define + "_" + arch.upper(); -+ else: -+ replace = define + "_" + arch; -+ output = re.sub("\\b%s\\b" % define, replace, output); -+ -+# replace: structs + struct typedefs -+for struct in structs: -+ output = re.sub("\\b(struct\s+%s)\\b" % struct, "\\1_%s" % arch, output); -+ output = re.sub("\\b(%s)_t\\b" % struct, "\\1_%s_t" % arch, output); -+ -+# replace: integer types -+integers = inttypes[arch].keys(); -+integers.sort(lambda a, b: cmp(len(b),len(a))); -+for type in integers: -+ output = re.sub("\\b%s\\b" % type, inttypes[arch][type], output); -+ -+# print results -+f = open(outfile, "w"); -+f.write(output); -+f.close; -+ -Index: xen-3.0.4-testing/xen/include/public/foreign/structs.py -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/public/foreign/structs.py -@@ -0,0 +1,52 @@ -+# configuration: what needs translation -+ -+structs = [ "start_info", -+ "trap_info", -+ "pt_fpreg", -+ "cpu_user_regs", -+ "xen_ia64_boot_param", -+ "ia64_tr_entry", -+ "vcpu_extra_regs", -+ "vcpu_guest_context", -+ "arch_vcpu_info", -+ "vcpu_time_info", -+ "vcpu_info", -+ "arch_shared_info", -+ "shared_info" ]; -+ -+defines = [ "__i386__", -+ "__x86_64__", -+ -+ "FLAT_RING1_CS", -+ "FLAT_RING1_DS", -+ "FLAT_RING1_SS", -+ -+ "FLAT_RING3_CS64", -+ "FLAT_RING3_DS64", -+ "FLAT_RING3_SS64", -+ "FLAT_KERNEL_CS64", -+ "FLAT_KERNEL_DS64", -+ "FLAT_KERNEL_SS64", -+ -+ "FLAT_KERNEL_CS", -+ "FLAT_KERNEL_DS", -+ "FLAT_KERNEL_SS", -+ -+ # x86_{32,64} -+ "_VGCF_i387_valid", -+ "VGCF_i387_valid", -+ "_VGCF_in_kernel", -+ "VGCF_in_kernel", -+ "_VGCF_failsafe_disables_events", -+ "VGCF_failsafe_disables_events", -+ "_VGCF_syscall_disables_events", -+ "VGCF_syscall_disables_events", -+ -+ # ia64 -+ "VGCF_EXTRA_REGS", -+ -+ # all archs -+ "xen_pfn_to_cr3", -+ "MAX_VIRT_CPUS", -+ "MAX_GUEST_CMDLINE" ]; -+ -Index: xen-3.0.4-testing/xen/include/public/foreign/reference.size -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/public/foreign/reference.size -@@ -0,0 +1,17 @@ -+ -+structs | x86_32 x86_64 ia64 -+ -+start_info | 1104 1152 1152 -+trap_info | 8 16 - -+pt_fpreg | - - 16 -+cpu_user_regs | 68 200 496 -+xen_ia64_boot_param | - - 96 -+ia64_tr_entry | - - 32 -+vcpu_extra_regs | - - 536 -+vcpu_guest_context | 2800 5168 1056 -+arch_vcpu_info | 24 16 0 -+vcpu_time_info | 32 32 32 -+vcpu_info | 64 64 48 -+arch_shared_info | 268 280 272 -+shared_info | 2584 3368 4384 -+ -Index: xen-3.0.4-testing/xen/Makefile -=================================================================== ---- xen-3.0.4-testing.orig/xen/Makefile -+++ xen-3.0.4-testing/xen/Makefile -@@ -36,10 +36,13 @@ _install: $(TARGET).gz - $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/hvm - [ -d $(DESTDIR)/usr/include/xen/io ] || \ - $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/io -+ [ -d $(DESTDIR)/usr/include/xen/foreign ] || \ -+ $(INSTALL_DIR) $(DESTDIR)/usr/include/xen/foreign - $(INSTALL_DATA) include/public/*.h $(DESTDIR)/usr/include/xen - $(INSTALL_DATA) include/public/arch-x86/*.h $(DESTDIR)/usr/include/xen/arch-x86 - $(INSTALL_DATA) include/public/hvm/*.h $(DESTDIR)/usr/include/xen/hvm - $(INSTALL_DATA) include/public/io/*.h $(DESTDIR)/usr/include/xen/io -+ $(INSTALL_DATA) include/public/foreign/*.h $(DESTDIR)/usr/include/xen/foreign - $(INSTALL_DATA) include/public/COPYING $(DESTDIR)/usr/include/xen - - .PHONY: _debug -@@ -49,6 +52,7 @@ _debug: - .PHONY: _clean - _clean: delete-unfresh-files - $(MAKE) -C tools clean -+ $(MAKE) -C include/public/foreign clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean -@@ -68,6 +72,7 @@ $(TARGET).gz: $(TARGET) - - $(TARGET): delete-unfresh-files - $(MAKE) -C tools -+ $(MAKE) -C include/public/foreign - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/acm_policy.h - [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm -Index: xen-3.0.4-testing/xen/include/public/foreign/mkchecker.py -=================================================================== ---- /dev/null -+++ xen-3.0.4-testing/xen/include/public/foreign/mkchecker.py -@@ -0,0 +1,58 @@ -+#!/usr/bin/python -+ -+import sys; -+from structs import structs; -+ -+# command line arguments -+arch = sys.argv[1]; -+outfile = sys.argv[2]; -+archs = sys.argv[3:]; -+ -+f = open(outfile, "w"); -+f.write(''' -+/* -+ * sanity checks for generated foreign headers: -+ * - verify struct sizes -+ * -+ * generated by %s -- DO NOT EDIT -+ */ -+#include -+#include -+#include -+#include -+#include "../xen.h" -+'''); -+ -+for a in archs: -+ f.write('#include "%s.h"\n' % a); -+ -+f.write('int main(int argc, char *argv[])\n{\n'); -+ -+f.write('\tprintf("\\n");'); -+f.write('printf("%-20s |", "structs");\n'); -+for a in archs: -+ f.write('\tprintf("%%8s", "%s");\n' % a); -+f.write('\tprintf("\\n");'); -+ -+f.write('\tprintf("\\n");'); -+for struct in structs: -+ f.write('\tprintf("%%-20s |", "%s");\n' % struct); -+ for a in archs: -+ if a == arch: -+ s = struct; # native -+ else: -+ s = struct + "_" + a; -+ f.write('#ifdef %s_has_no_%s\n' % (a, struct)); -+ f.write('\tprintf("%8s", "-");\n'); -+ f.write("#else\n"); -+ f.write('\tprintf("%%8zd", sizeof(struct %s));\n' % s); -+ f.write("#endif\n"); -+ -+ f.write('\tprintf("\\n");\n\n'); -+ -+f.write('\tprintf("\\n");\n'); -+f.write('\texit(0);\n'); -+f.write('}\n'); -+ -+f.close(); -+ -Index: xen-3.0.4-testing/tools/Rules.mk -=================================================================== ---- xen-3.0.4-testing.orig/tools/Rules.mk -+++ xen-3.0.4-testing/tools/Rules.mk -@@ -52,5 +52,7 @@ mk-symlinks-xen: - ( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . ) - mkdir -p xen/arch-x86 - ( cd xen/arch-x86 && ln -sf ../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . ) -+ mkdir -p xen/foreign -+ ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/*.h . ) - - mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS) + checker.c: $(scripts) + python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures) diff --git a/xen-hvm-default-bridge.diff b/xen-hvm-default-bridge.diff index a8cc97a..3be3049 100644 --- a/xen-hvm-default-bridge.diff +++ b/xen-hvm-default-bridge.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/tools/examples/xend-config.sxp +Index: xen-unstable/tools/examples/xend-config.sxp =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xend-config.sxp -+++ xen-3.0.4-testing/tools/examples/xend-config.sxp -@@ -116,7 +116,8 @@ +--- xen-unstable.orig/tools/examples/xend-config.sxp ++++ xen-unstable/tools/examples/xend-config.sxp +@@ -134,7 +134,8 @@ # # (network-script 'network-bridge netdev=eth1') # @@ -12,19 +12,19 @@ Index: xen-3.0.4-testing/tools/examples/xend-config.sxp # # (network-script 'network-bridge bridge=') # -Index: xen-3.0.4-testing/tools/ioemu/vl.c +Index: xen-unstable/tools/ioemu/vl.c =================================================================== ---- xen-3.0.4-testing.orig/tools/ioemu/vl.c -+++ xen-3.0.4-testing/tools/ioemu/vl.c -@@ -89,7 +89,6 @@ - #include "exec-all.h" +--- xen-unstable.orig/tools/ioemu/vl.c ++++ xen-unstable/tools/ioemu/vl.c +@@ -90,7 +90,6 @@ + #include #define DEFAULT_NETWORK_SCRIPT "/etc/xen/qemu-ifup" -#define DEFAULT_BRIDGE "xenbr0" //#define DEBUG_UNUSED_IOPORT //#define DEBUG_IOPORT -@@ -3779,10 +3778,10 @@ int net_client_init(const char *str) +@@ -3843,10 +3842,10 @@ int net_client_init(const char *str) if (get_param_value(setup_script, sizeof(setup_script), "script", p) == 0) { pstrcpy(setup_script, sizeof(setup_script), DEFAULT_NETWORK_SCRIPT); } @@ -39,11 +39,11 @@ Index: xen-3.0.4-testing/tools/ioemu/vl.c } } else #endif -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py +Index: xen-unstable/tools/python/xen/xend/image.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -419,13 +419,16 @@ class HVMImageHandler(ImageHandler): +--- xen-unstable.orig/tools/python/xen/xend/image.py ++++ xen-unstable/tools/python/xen/xend/image.py +@@ -352,13 +352,16 @@ class HVMImageHandler(ImageHandler): mac = devinfo.get('mac') if mac is None: mac = randomMAC() @@ -60,20 +60,19 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/image.py + net += ",bridge=%s" % (bridge,) + ret.append(net) - return ret -Index: xen-3.0.4-testing/tools/ioemu/target-i386-dm/qemu-ifup + # +Index: xen-unstable/tools/ioemu/target-i386-dm/qemu-ifup =================================================================== ---- xen-3.0.4-testing.orig/tools/ioemu/target-i386-dm/qemu-ifup -+++ xen-3.0.4-testing/tools/ioemu/target-i386-dm/qemu-ifup -@@ -1,10 +1,11 @@ +--- xen-unstable.orig/tools/ioemu/target-i386-dm/qemu-ifup ++++ xen-unstable/tools/ioemu/target-i386-dm/qemu-ifup +@@ -1,9 +1,11 @@ #!/bin/sh -#. /etc/rc.d/init.d/functions -#ulimit -c unlimited - --echo -c 'config qemu network with xen bridge for ' --echo $* +-echo 'config qemu network with xen bridge for ' $* +bridge=$2 +if [ -z "$bridge" ]; then + brnum=$(ip route list | awk '/^default / { print $NF }' | sed 's/^[^0-9]*//') diff --git a/xen-hvm-default-pae.diff b/xen-hvm-default-pae.diff index e418583..0b0cb57 100644 --- a/xen-hvm-default-pae.diff +++ b/xen-hvm-default-pae.diff @@ -1,15 +1,15 @@ PAE must be on for 64-on-64 to work at all. -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py +Index: xen-unstable/tools/python/xen/xend/image.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -334,7 +334,7 @@ class HVMImageHandler(ImageHandler): +--- xen-unstable.orig/tools/python/xen/xend/image.py ++++ xen-unstable/tools/python/xen/xend/image.py +@@ -265,7 +265,7 @@ class HVMImageHandler(ImageHandler): - self.dmargs += self.configVNC(imageConfig) + self.pid = None -- self.pae = imageConfig['hvm'].get('pae', 0) -+ self.pae = imageConfig['hvm'].get('pae', 1) - self.apic = imageConfig['hvm'].get('apic', 0) - self.acpi = imageConfig['hvm']['devices'].get('acpi', 0) +- self.pae = int(vmConfig['platform'].get('pae', 0)) ++ self.pae = int(vmConfig['platform'].get('pae', 1)) + self.apic = int(vmConfig['platform'].get('apic', 0)) + self.acpi = int(vmConfig['platform'].get('acpi', 0)) diff --git a/xen-hvm-netfront.diff b/xen-hvm-netfront.diff index 5c525b5..dbcbb7e 100644 --- a/xen-hvm-netfront.diff +++ b/xen-hvm-netfront.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +Index: xen-3.0.5-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c =================================================================== ---- xen-3.0.4-testing.orig/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c -+++ xen-3.0.4-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c -@@ -282,6 +282,13 @@ static int __devinit netfront_probe(stru +--- xen-3.0.5-testing.orig/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c ++++ xen-3.0.5-testing/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +@@ -294,6 +294,13 @@ static int __devinit netfront_probe(stru int err; struct net_device *netdev; struct netfront_info *info; diff --git a/xen-ioapic-ack-default.diff b/xen-ioapic-ack-default.diff index 55d9227..a92fb76 100644 --- a/xen-ioapic-ack-default.diff +++ b/xen-ioapic-ack-default.diff @@ -1,10 +1,10 @@ Change default IO-APIC ack mode for single IO-APIC systems to old-style. Jan -Index: xen-3.0.4-testing/xen/arch/x86/io_apic.c +Index: xen-unstable/xen/arch/x86/io_apic.c =================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/io_apic.c -+++ xen-3.0.4-testing/xen/arch/x86/io_apic.c +--- xen-unstable.orig/xen/arch/x86/io_apic.c ++++ xen-unstable/xen/arch/x86/io_apic.c @@ -1339,7 +1339,7 @@ static unsigned int startup_level_ioapic return 0; /* don't check for pending */ } diff --git a/xen-ioemu-hvm-pv-support.diff b/xen-ioemu-hvm-pv-support.diff index 8d37c42..4755ea2 100644 --- a/xen-ioemu-hvm-pv-support.diff +++ b/xen-ioemu-hvm-pv-support.diff @@ -1,7 +1,8 @@ -diff -Nuar ioemu-orig/hw/ide.c ioemu/hw/ide.c ---- a/tools/ioemu/hw/ide.c 2007-03-01 15:18:35.000000000 -0700 -+++ b/tools/ioemu/hw/ide.c 2007-03-01 15:19:15.000000000 -0700 -@@ -392,6 +392,9 @@ +Index: xen-unstable/tools/ioemu/hw/ide.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/hw/ide.c ++++ xen-unstable/tools/ioemu/hw/ide.c +@@ -392,6 +392,9 @@ typedef struct PCIIDEState { int type; /* see IDE_TYPE_xxx */ } PCIIDEState; @@ -11,7 +12,7 @@ diff -Nuar ioemu-orig/hw/ide.c ioemu/hw/ide.c #define DMA_MULTI_THREAD #ifdef DMA_MULTI_THREAD -@@ -2001,6 +2004,27 @@ +@@ -2165,6 +2168,27 @@ static void ide_reset(IDEState *s) ide_dummy_transfer_stop(s); } @@ -39,7 +40,7 @@ diff -Nuar ioemu-orig/hw/ide.c ioemu/hw/ide.c struct partition { uint8_t boot_ind; /* 0x80 - active */ uint8_t head; /* starting head */ -@@ -2436,6 +2460,9 @@ +@@ -2600,6 +2624,9 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl sizeof(PCIIDEState), -1, NULL, NULL); @@ -49,7 +50,7 @@ diff -Nuar ioemu-orig/hw/ide.c ioemu/hw/ide.c d->type = IDE_TYPE_CMD646; pci_conf = d->dev.config; pci_conf[0x00] = 0x95; // CMD646 -@@ -2493,6 +2520,9 @@ +@@ -2771,6 +2798,9 @@ void pci_piix3_ide_init(PCIBus *bus, Blo NULL, NULL); d->type = IDE_TYPE_PIIX3; @@ -59,10 +60,11 @@ diff -Nuar ioemu-orig/hw/ide.c ioemu/hw/ide.c pci_conf = d->dev.config; pci_conf[0x00] = 0x86; // Intel pci_conf[0x01] = 0x80; -diff -Nuar ioemu-orig/hw/pci.c ioemu/hw/pci.c ---- a/tools/ioemu/hw/pci.c 2007-03-01 15:18:35.000000000 -0700 -+++ b/tools/ioemu/hw/pci.c 2007-03-01 15:19:15.000000000 -0700 -@@ -514,3 +514,24 @@ +Index: xen-unstable/tools/ioemu/hw/pci.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/hw/pci.c ++++ xen-unstable/tools/ioemu/hw/pci.c +@@ -517,3 +517,24 @@ void pci_nic_init(PCIBus *bus, NICInfo * } } @@ -87,10 +89,11 @@ diff -Nuar ioemu-orig/hw/pci.c ioemu/hw/pci.c + } + } +} -diff -Nuar ioemu-orig/hw/xen_platform.c ioemu/hw/xen_platform.c ---- a/tools/ioemu/hw/xen_platform.c 2007-03-01 15:18:35.000000000 -0700 -+++ b/tools/ioemu/hw/xen_platform.c 2007-03-01 15:19:15.000000000 -0700 -@@ -29,9 +29,36 @@ +Index: xen-unstable/tools/ioemu/hw/xen_platform.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/hw/xen_platform.c ++++ xen-unstable/tools/ioemu/hw/xen_platform.c +@@ -29,15 +29,46 @@ extern FILE *logfile; @@ -98,49 +101,50 @@ diff -Nuar ioemu-orig/hw/xen_platform.c ioemu/hw/xen_platform.c + static void platform_ioport_write(void *opaque, uint32_t addr, uint32_t val) { -- return; + DECLARE_DOMCTL; + int rc; ++ + if (val == 0) + qemu_invalidate_map_cache(); + + switch (addr - ioport_base) { + case 0: -+ fprintf(logfile, "Init hypercall page %x, addr %x.\n", val, addr); -+ domctl.domain = (domid_t)domid; -+ domctl.u.hypercall_init.gmfn = val; -+ domctl.cmd = XEN_DOMCTL_hypercall_init; -+ rc = xc_domctl(xc_handle, &domctl); -+ fprintf(logfile, "result -> %d.\n", rc); -+ break; ++ fprintf(logfile, "Init hypercall page %x, addr %x.\n", val, addr); ++ domctl.domain = (domid_t)domid; ++ domctl.u.hypercall_init.gmfn = val; ++ domctl.cmd = XEN_DOMCTL_hypercall_init; ++ rc = xc_domctl(xc_handle, &domctl); ++ fprintf(logfile, "result -> %d.\n", rc); ++ break; + case 4: -+ fprintf(logfile, "Disconnect IDE hard disk...\n"); -+ ide_unplug_harddisks(); -+ fprintf(logfile, "Disconnect netifs...\n"); -+ pci_unplug_netifs(); -+ fprintf(logfile, "Shutdown taps...\n"); -+ net_tap_shutdown_all(); -+ fprintf(logfile, "Done.\n"); -+ break; ++ fprintf(logfile, "Disconnect IDE hard disk...\n"); ++ ide_unplug_harddisks(); ++ fprintf(logfile, "Disconnect netifs...\n"); ++ pci_unplug_netifs(); ++ fprintf(logfile, "Shutdown taps...\n"); ++ net_tap_shutdown_all(); ++ fprintf(logfile, "Done.\n"); ++ break; + default: -+ fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n", -+ addr, ioport_base); -+ break; ++ fprintf(logfile, "Write to bad port %x (base %x) on evtchn device.\n", ++ addr, ioport_base); ++ break; + } } - static uint32_t platform_ioport_read(void *opaque, uint32_t addr) -@@ -42,6 +69,8 @@ static void platform_ioport_map(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { + ioport_base = addr; + - register_ioport_write(addr, 16, 4, platform_ioport_write, NULL); - register_ioport_read(addr, 16, 1, platform_ioport_read, NULL); + register_ioport_write(addr, 1, 1, platform_ioport_write, NULL); } -diff -Nuar ioemu-orig/vl.c ioemu/vl.c ---- a/tools/ioemu/vl.c 2007-03-01 15:18:35.000000000 -0700 -+++ b/tools/ioemu/vl.c 2007-03-01 15:19:15.000000000 -0700 -@@ -170,6 +170,19 @@ + +Index: xen-unstable/tools/ioemu/vl.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/vl.c ++++ xen-unstable/tools/ioemu/vl.c +@@ -170,6 +170,19 @@ time_t timeoffset = 0; char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'}; extern int domid; @@ -160,7 +164,7 @@ diff -Nuar ioemu-orig/vl.c ioemu/vl.c char vncpasswd[64]; unsigned char challenge[AUTHCHALLENGESIZE]; -@@ -3084,6 +3097,7 @@ +@@ -3139,6 +3152,7 @@ void net_slirp_smb(const char *exported_ typedef struct TAPState { VLANClientState *vc; int fd; @@ -168,7 +172,7 @@ diff -Nuar ioemu-orig/vl.c ioemu/vl.c } TAPState; static void tap_receive(void *opaque, const uint8_t *buf, int size) -@@ -3111,6 +3125,36 @@ +@@ -3166,6 +3180,36 @@ static void tap_send(void *opaque) } } @@ -205,7 +209,7 @@ diff -Nuar ioemu-orig/vl.c ioemu/vl.c /* fd support */ static TAPState *net_tap_fd_init(VLANState *vlan, int fd) -@@ -3122,6 +3166,8 @@ +@@ -3177,6 +3221,8 @@ static TAPState *net_tap_fd_init(VLANSta return NULL; s->fd = fd; s->vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s); @@ -214,7 +218,7 @@ diff -Nuar ioemu-orig/vl.c ioemu/vl.c qemu_set_fd_handler(s->fd, tap_send, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "tap: fd=%d", fd); return s; -@@ -4047,19 +4093,6 @@ +@@ -4117,19 +4163,6 @@ void dumb_display_init(DisplayState *ds) #define MAX_IO_HANDLERS 64 @@ -234,18 +238,19 @@ diff -Nuar ioemu-orig/vl.c ioemu/vl.c /* XXX: fd_read_poll should be suppressed, but an API change is necessary in the character devices to suppress fd_can_read(). */ int qemu_set_fd_handler2(int fd, -diff -Nuar ioemu-orig/vl.h ioemu/vl.h ---- a/tools/ioemu/vl.h 2007-03-01 15:18:35.000000000 -0700 -+++ b/tools/ioemu/vl.h 2007-03-01 15:19:15.000000000 -0700 -@@ -826,6 +826,7 @@ - void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn); +Index: xen-unstable/tools/ioemu/vl.h +=================================================================== +--- xen-unstable.orig/tools/ioemu/vl.h ++++ xen-unstable/tools/ioemu/vl.h +@@ -844,6 +844,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo int pmac_ide_init (BlockDriverState **hd_table, SetIRQFunc *set_irq, void *irq_opaque, int irq); + void ide_stop_dma_thread(void); +void ide_unplug_harddisks(void); /* cdrom.c */ int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track); -@@ -1268,6 +1269,8 @@ +@@ -1286,6 +1287,8 @@ void kqemu_record_dump(void); extern char domain_name[]; void destroy_hvm_domain(void); diff --git a/xen-linguas.diff b/xen-linguas.diff new file mode 100644 index 0000000..87d62c9 --- /dev/null +++ b/xen-linguas.diff @@ -0,0 +1,13 @@ +Index: xen-3.0.5-testing/tools/python/Makefile +=================================================================== +--- xen-3.0.5-testing.orig/tools/python/Makefile ++++ xen-3.0.5-testing/tools/python/Makefile +@@ -6,7 +6,7 @@ all: build + + # For each new supported translation, add its name here, eg 'fr_FR' + # to cause the .po file to be built & installed, eg +-LINGUAS := ++LINGUAS := $(shell find xen/xm/messages/ -name '*.po' | sed -e 's,.*/\([^/]*\)/[^/]*$$,\1,') + POPACKAGE := xen-xm + PODIR := xen/xm/messages + POTFILE := $(PODIR)/xen-xm.pot diff --git a/xen-localtime.patch b/xen-localtime.patch deleted file mode 100644 index 4ffab17..0000000 --- a/xen-localtime.patch +++ /dev/null @@ -1,14 +0,0 @@ -Fix usage of localtime parameter in PV guest configuration -Signed-off-by: Bruce Rogers - ---- a/tools/python/xen/xend/XendDomainInfo.py 2007-01-20 08:19:11.877589448 -0700 -+++ b/tools/python/xen/xend/XendDomainInfo.py 2007-01-20 09:20:59.805618252 -0700 -@@ -1361,7 +1361,7 @@ - self.info['image'], - self.info['devices']) - -- localtime = self.info.get('localtime', False) -+ localtime = self.info.get('platform_localtime', False) - if localtime: - xc.domain_set_time_offset(self.domid) - diff --git a/xen-lost-mouse.diff b/xen-lost-mouse.diff index 1baa502..e75b2da 100644 --- a/xen-lost-mouse.diff +++ b/xen-lost-mouse.diff @@ -5,16 +5,16 @@ SIGKILL causes atexit to not be called, so mouse SDL cleanup wasn't performed, so mouse wasn't released. -Index: xen-3.0.4-testing/tools/python/xen/xend/image.py +Index: xen-unstable/tools/python/xen/xend/image.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py -+++ xen-3.0.4-testing/tools/python/xen/xend/image.py -@@ -502,7 +502,7 @@ class HVMImageHandler(ImageHandler): - self.unregister_reboot_feature_watch(); +--- xen-unstable.orig/tools/python/xen/xend/image.py ++++ xen-unstable/tools/python/xen/xend/image.py +@@ -454,7 +454,7 @@ class HVMImageHandler(ImageHandler): + def destroy(self, suspend = False): if self.pid: try: -- os.kill(self.pid, signal.SIGKILL) -+ os.kill(self.pid, signal.SIGTERM) - except OSError, exn: - log.exception(exn) - try: +- sig = signal.SIGKILL ++ sig = signal.SIGTERM + if suspend: + log.info("use sigusr1 to signal qemu %d", self.pid) + sig = signal.SIGUSR1 diff --git a/xen-lowmem-emergency-pool.diff b/xen-lowmem-emergency-pool.diff index 822882e..65ccccd 100644 --- a/xen-lowmem-emergency-pool.diff +++ b/xen-lowmem-emergency-pool.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/xen/arch/x86/x86_32/mm.c +Index: xen-unstable/xen/arch/x86/x86_32/mm.c =================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/x86_32/mm.c -+++ xen-3.0.4-testing/xen/arch/x86/x86_32/mm.c -@@ -62,6 +62,8 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l +--- xen-unstable.orig/xen/arch/x86/x86_32/mm.c ++++ xen-unstable/xen/arch/x86/x86_32/mm.c +@@ -63,6 +63,8 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l return &idle_pg_table_l2[l2_linear_offset(v)]; } @@ -11,7 +11,7 @@ Index: xen-3.0.4-testing/xen/arch/x86/x86_32/mm.c void __init paging_init(void) { void *ioremap_pt; -@@ -130,6 +132,20 @@ void __init setup_idle_pagetable(void) +@@ -131,6 +133,20 @@ void __init setup_idle_pagetable(void) l2e_from_page(virt_to_page(idle_vcpu[0]->domain-> arch.mm_perdomain_pt) + i, __PAGE_HYPERVISOR)); @@ -32,10 +32,10 @@ Index: xen-3.0.4-testing/xen/arch/x86/x86_32/mm.c } void __init zap_low_mappings(l2_pgentry_t *base) -Index: xen-3.0.4-testing/xen/common/page_alloc.c +Index: xen-unstable/xen/common/page_alloc.c =================================================================== ---- xen-3.0.4-testing.orig/xen/common/page_alloc.c -+++ xen-3.0.4-testing/xen/common/page_alloc.c +--- xen-unstable.orig/xen/common/page_alloc.c ++++ xen-unstable/xen/common/page_alloc.c @@ -46,6 +46,20 @@ static char opt_badpage[100] = ""; string_param("badpage", opt_badpage); @@ -56,4 +56,4 @@ Index: xen-3.0.4-testing/xen/common/page_alloc.c +/* * Bit width of the DMA heap. */ - unsigned int dma_bitsize = CONFIG_DMA_BITSIZE; + static unsigned int dma_bitsize = CONFIG_DMA_BITSIZE; diff --git a/xen-man-permissions.patch b/xen-man-permissions.patch deleted file mode 100644 index dc61d30..0000000 --- a/xen-man-permissions.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: xen-3.0.4-testing/tools/ioemu/Makefile -=================================================================== ---- xen-3.0.4-testing.orig/tools/ioemu/Makefile -+++ xen-3.0.4-testing/tools/ioemu/Makefile -@@ -68,7 +68,7 @@ install-doc: $(DOCS) - $(INSTALL) -m 644 qemu-doc.html qemu-tech.html "$(DESTDIR)$(docdir)" - ifndef CONFIG_WIN32 - mkdir -p "$(DESTDIR)$(mandir)/man1" -- $(INSTALL) qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1" -+ $(INSTALL) -m 644 qemu.1 qemu-img.1 "$(DESTDIR)$(mandir)/man1" - endif - - install: all $(if $(BUILD_DOCS),install-doc) diff --git a/xen-man-xm-bad-char.diff b/xen-man-xm-bad-char.diff index be92d1b..8af5561 100644 --- a/xen-man-xm-bad-char.diff +++ b/xen-man-xm-bad-char.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/docs/man/xm.pod.1 +Index: xen-unstable/docs/man/xm.pod.1 =================================================================== ---- xen-3.0.4-testing.orig/docs/man/xm.pod.1 -+++ xen-3.0.4-testing/docs/man/xm.pod.1 -@@ -554,29 +554,29 @@ B +--- xen-unstable.orig/docs/man/xm.pod.1 ++++ xen-unstable/docs/man/xm.pod.1 +@@ -555,29 +555,29 @@ B I xm sched-sedf 20000000 5000000 0 0 0 diff --git a/xen-max-free-mem.diff b/xen-max-free-mem.diff index 65ccb2b..72e400c 100644 --- a/xen-max-free-mem.diff +++ b/xen-max-free-mem.diff @@ -1,16 +1,15 @@ -Index: xen-3.0.4-testing/tools/python/xen/xend/XendNode.py +Index: xen-3.0.5-testing/tools/python/xen/xend/XendNode.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendNode.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendNode.py -@@ -159,9 +159,34 @@ class XendNode: - info['cores_per_socket'] * +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendNode.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendNode.py +@@ -558,9 +558,33 @@ class XendNode: info['threads_per_core']) info['cpu_mhz'] = info['cpu_khz'] / 1000 -- # physinfo is in KiB + +- # physinfo is in KiB, need it in MiB - info['total_memory'] = info['total_memory'] / 1024 - info['free_memory'] = info['free_memory'] / 1024 -+ import XendRoot -+ configured_floor = XendRoot.instance().get_dom0_min_mem() * 1024 ++ configured_floor = xendoptions().get_dom0_min_mem() * 1024 + from xen.xend import balloon + try: + kernel_floor = balloon.get_dom0_min_target() @@ -40,7 +39,7 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/XendNode.py ITEM_ORDER = ['nr_cpus', 'nr_nodes', -@@ -172,6 +197,9 @@ class XendNode: +@@ -571,6 +595,9 @@ class XendNode: 'hw_caps', 'total_memory', 'free_memory', @@ -50,11 +49,11 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/XendNode.py ] return [[k, info[k]] for k in ITEM_ORDER] -Index: xen-3.0.4-testing/tools/python/xen/xend/balloon.py +Index: xen-3.0.5-testing/tools/python/xen/xend/balloon.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/balloon.py -+++ xen-3.0.4-testing/tools/python/xen/xend/balloon.py -@@ -43,6 +43,8 @@ SLEEP_TIME_GROWTH = 0.1 +--- xen-3.0.5-testing.orig/tools/python/xen/xend/balloon.py ++++ xen-3.0.5-testing/tools/python/xen/xend/balloon.py +@@ -41,6 +41,8 @@ SLEEP_TIME_GROWTH = 0.1 # label actually shown in the PROC_XEN_BALLOON file. labels = { 'current' : 'Current allocation', 'target' : 'Requested target', @@ -63,7 +62,7 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/balloon.py 'low-balloon' : 'Low-mem balloon', 'high-balloon' : 'High-mem balloon', 'limit' : 'Xen hard limit' } -@@ -81,6 +83,23 @@ def get_dom0_target_alloc(): +@@ -67,6 +69,23 @@ def get_dom0_target_alloc(): raise VmError('Failed to query target memory allocation of dom0.') return kb @@ -87,11 +86,11 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/balloon.py def free(need_mem): """Balloon out memory from the privileged domain so that there is the specified required amount (in KiB) free. -Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py +Index: xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomainInfo.py -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py -@@ -540,6 +540,27 @@ class XendDomainInfo: +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -573,6 +573,27 @@ class XendDomainInfo: return sxprs @@ -119,10 +118,10 @@ Index: xen-3.0.4-testing/tools/python/xen/xend/XendDomainInfo.py def setMemoryTarget(self, target): """Set the memory target of this domain. @param target: In MiB. -Index: xen-3.0.4-testing/tools/python/xen/xend/server/SrvDomain.py +Index: xen-3.0.5-testing/tools/python/xen/xend/server/SrvDomain.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xend/server/SrvDomain.py -+++ xen-3.0.4-testing/tools/python/xen/xend/server/SrvDomain.py +--- xen-3.0.5-testing.orig/tools/python/xen/xend/server/SrvDomain.py ++++ xen-3.0.5-testing/tools/python/xen/xend/server/SrvDomain.py @@ -169,7 +169,7 @@ class SrvDomain(SrvDir): diff --git a/xen-messages.diff b/xen-messages.diff index 072cd60..bf6a39b 100644 --- a/xen-messages.diff +++ b/xen-messages.diff @@ -1,7 +1,8 @@ -diff -ru xen-3.0.4-testing.orig/tools/misc/xend xen-3.0.4-testing/tools/misc/xend ---- xen-3.0.4-testing.orig/tools/misc/xend 2006-12-14 14:49:56.000000000 -0700 -+++ xen-3.0.4-testing/tools/misc/xend 2007-03-01 18:05:38.000000000 -0700 -@@ -60,22 +60,6 @@ +Index: xen-3.0.5-testing/tools/misc/xend +=================================================================== +--- xen-3.0.5-testing.orig/tools/misc/xend ++++ xen-3.0.5-testing/tools/misc/xend +@@ -50,22 +50,6 @@ def hline(): def msg(message): print >>sys.stderr, "*" * 3, message @@ -24,7 +25,7 @@ diff -ru xen-3.0.4-testing.orig/tools/misc/xend xen-3.0.4-testing/tools/misc/xen def check_user(): """Check that the effective user id is 0 (root). """ -@@ -102,7 +86,6 @@ +@@ -92,7 +76,6 @@ def start_blktapctrl(): def main(): try: @@ -32,24 +33,25 @@ diff -ru xen-3.0.4-testing.orig/tools/misc/xend xen-3.0.4-testing/tools/misc/xen check_user() except CheckError: sys.exit(1) -diff -ru xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomain.py xen-3.0.4-testing/tools/python/xen/xend/XendDomain.py ---- xen-3.0.4-testing.orig/tools/python/xen/xend/XendDomain.py 2006-12-18 14:57:04.000000000 -0700 -+++ xen-3.0.4-testing/tools/python/xen/xend/XendDomain.py 2007-03-01 18:06:31.000000000 -0700 -@@ -780,6 +780,8 @@ +Index: xen-3.0.5-testing/tools/python/xen/xend/XendDomain.py +=================================================================== +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendDomain.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendDomain.py +@@ -825,6 +825,8 @@ class XendDomain: if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot save privileged domain %s" % domname) + if dominfo._readVm('image/ostype') == "hvm": + raise XendError("Cannot save fully virtualized domains") - if dominfo.state != DOM_STATE_RUNNING: - raise XendError("Cannot suspend domain that is not running.") -@@ -1158,6 +1160,8 @@ + if dominfo._stateGet() != DOM_STATE_RUNNING: + raise VMBadState("Domain is not running", +@@ -1243,6 +1245,8 @@ class XendDomain: if dominfo.getDomid() == DOM0_ID: raise XendError("Cannot save privileged domain %i" % domid) + if dominfo._readVm('image/ostype') == "hvm": + raise XendError("Cannot save fully virtualized domains") - fd = os.open(dst, os.O_WRONLY | os.O_CREAT | os.O_TRUNC) - try: + oflags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC + if hasattr(os, "O_LARGEFILE"): diff --git a/xen-network-bridge.diff b/xen-network-bridge.diff index c136f36..f1b8f53 100644 --- a/xen-network-bridge.diff +++ b/xen-network-bridge.diff @@ -1,7 +1,7 @@ -Index: xen-3.0.4-testing/tools/examples/network-bridge +Index: xen-unstable/tools/examples/network-bridge =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/network-bridge -+++ xen-3.0.4-testing/tools/examples/network-bridge +--- xen-unstable.orig/tools/examples/network-bridge ++++ xen-unstable/tools/examples/network-bridge @@ -69,23 +69,6 @@ pdev="p${netdev}" vdev="veth${vifnum}" vif0="vif0.${vifnum}" @@ -26,7 +26,7 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge # Usage: transfer_addrs src dst # Copy all IP addresses (including aliases) from device $src to device $dst. transfer_addrs () { -@@ -204,14 +187,10 @@ using loopback.nloopbacks= on the dom +@@ -203,14 +186,10 @@ using netloop.nloopbacks= on the doma if link_exists "$vdev"; then mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` @@ -44,7 +44,7 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge ip link set ${netdev} name ${pdev} ip link set ${vdev} name ${netdev} -@@ -222,7 +201,8 @@ using loopback.nloopbacks= on the dom +@@ -221,7 +200,8 @@ using netloop.nloopbacks= on the doma ip link set ${bridge} up add_to_bridge ${bridge} ${vif0} add_to_bridge2 ${bridge} ${pdev} @@ -52,9 +52,9 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge + ip link set ${netdev} up + ifup ${hwddev} else - # old style without ${vdev} - transfer_addrs ${netdev} ${bridge} -@@ -246,9 +226,7 @@ op_stop () { + ip link set ${bridge} arp on + ip link set ${bridge} multicast on +@@ -249,9 +229,7 @@ op_stop () { ip link set dev ${vif0} down mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` transfer_addrs ${netdev} ${pdev} @@ -65,7 +65,7 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge ip link set ${netdev} down arp off ip link set ${netdev} addr fe:ff:ff:ff:ff:ff ip link set ${pdev} down -@@ -261,7 +239,7 @@ op_stop () { +@@ -264,7 +242,7 @@ op_stop () { ip link set ${netdev} name ${vdev} ip link set ${pdev} name ${netdev} @@ -74,10 +74,10 @@ Index: xen-3.0.4-testing/tools/examples/network-bridge else transfer_routes ${bridge} ${netdev} ip link set ${bridge} down -Index: xen-3.0.4-testing/tools/examples/xen-network-common.sh +Index: xen-unstable/tools/examples/xen-network-common.sh =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xen-network-common.sh -+++ xen-3.0.4-testing/tools/examples/xen-network-common.sh +--- xen-unstable.orig/tools/examples/xen-network-common.sh ++++ xen-unstable/tools/examples/xen-network-common.sh @@ -16,57 +16,33 @@ # diff --git a/xen-no-dummy-nfs-ip.diff b/xen-no-dummy-nfs-ip.diff index 2c8b3e2..b7c979b 100644 --- a/xen-no-dummy-nfs-ip.diff +++ b/xen-no-dummy-nfs-ip.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/tools/python/xen/xm/create.py +Index: xen-unstable/tools/python/xen/xm/create.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.0.4-testing/tools/python/xen/xm/create.py -@@ -868,9 +868,8 @@ def preprocess_access_control(vals): +--- xen-unstable.orig/tools/python/xen/xm/create.py ++++ xen-unstable/tools/python/xen/xm/create.py +@@ -884,9 +884,8 @@ def preprocess_access_control(vals): def preprocess_ip(vals): if vals.ip or vals.dhcp != 'off': diff --git a/xen-paths.diff b/xen-paths.diff index f886966..47f5c97 100644 --- a/xen-paths.diff +++ b/xen-paths.diff @@ -2,7 +2,7 @@ Index: xen-unstable/tools/python/xen/xm/create.py =================================================================== --- xen-unstable.orig/tools/python/xen/xm/create.py +++ xen-unstable/tools/python/xen/xm/create.py -@@ -64,7 +64,7 @@ gopts.opt('quiet', short='q', +@@ -67,7 +67,7 @@ gopts.opt('quiet', short='q', use="Quiet.") gopts.opt('path', val='PATH', diff --git a/xen-perdomain-free.patch b/xen-perdomain-free.patch deleted file mode 100644 index 8151111..0000000 --- a/xen-perdomain-free.patch +++ /dev/null @@ -1,17 +0,0 @@ -Index: xen-3.0.4-testing/xen/arch/x86/domain.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/arch/x86/domain.c -+++ xen-3.0.4-testing/xen/arch/x86/domain.c -@@ -455,8 +455,10 @@ int arch_domain_create(struct domain *d) - fail: - free_xenheap_page(d->shared_info); - #ifdef __x86_64__ -- free_domheap_page(virt_to_page(d->arch.mm_perdomain_l2)); -- free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3)); -+ if (d->arch.mm_perdomain_l2) -+ free_domheap_page(virt_to_page(d->arch.mm_perdomain_l2)); -+ if (d->arch.mm_perdomain_l3) -+ free_domheap_page(virt_to_page(d->arch.mm_perdomain_l3)); - #endif - free_xenheap_pages(d->arch.mm_perdomain_pt, pdpt_order); - return rc; diff --git a/xen-removable.diff b/xen-removable.diff deleted file mode 100644 index b4e816f..0000000 --- a/xen-removable.diff +++ /dev/null @@ -1,722 +0,0 @@ -Index: xen-unstable/tools/ioemu/block.c -=================================================================== ---- xen-unstable.orig/tools/ioemu/block.c -+++ xen-unstable/tools/ioemu/block.c -@@ -332,6 +332,8 @@ int bdrv_open2(BlockDriverState *bs, con - goto fail; - } - -+ shdev_set_media_instance(bs); -+ - bs->inserted = 1; - - /* call the change callback */ -@@ -356,6 +358,7 @@ void bdrv_close(BlockDriverState *bs) - bs->opaque = NULL; - bs->drv = NULL; - bs->inserted = 0; -+ bs->media_instance = 0; - - /* call the change callback */ - if (bs->change_cb) -@@ -601,6 +604,15 @@ BlockDriverState *bdrv_find(const char * - return NULL; - } - -+BlockDriverState *bdrv_find_bs(int (*it)(BlockDriverState *, void *), void *opaque) -+{ -+ BlockDriverState *bs; -+ -+ for (bs = bdrv_first; bs != NULL && !it(bs, opaque); bs = bs->next); -+ -+ return( bs ); -+} -+ - void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque) - { - BlockDriverState *bs; -Index: xen-unstable/tools/ioemu/block_int.h -=================================================================== ---- xen-unstable.orig/tools/ioemu/block_int.h -+++ xen-unstable/tools/ioemu/block_int.h -@@ -51,6 +51,8 @@ struct BlockDriverState { - int removable; /* if true, the media can be removed */ - int locked; /* if true, the media cannot temporarily be ejected */ - int encrypted; /* if true, the media is encrypted */ -+ int media_instance; -+ int shdev_el; - /* event callback when inserting/removing */ - void (*change_cb)(void *opaque); - void *change_opaque; -Index: xen-unstable/tools/ioemu/hw/ide.c -=================================================================== ---- xen-unstable.orig/tools/ioemu/hw/ide.c -+++ xen-unstable/tools/ioemu/hw/ide.c -@@ -23,6 +23,9 @@ - */ - #include "vl.h" - #include -+#include -+#include -+#include - - /* debug IDE devices */ - //#define DEBUG_IDE -@@ -278,6 +281,7 @@ - #define ASC_ILLEGAL_OPCODE 0x20 - #define ASC_LOGICAL_BLOCK_OOR 0x21 - #define ASC_INV_FIELD_IN_CMD_PACKET 0x24 -+#define ASC_MEDIA_CHANGED 0x28 - #define ASC_MEDIUM_NOT_PRESENT 0x3a - #define ASC_SAVING_PARAMETERS_NOT_SUPPORTED 0x39 - -@@ -294,6 +298,7 @@ typedef void EndTransferFunc(struct IDES - typedef struct IDEState { - /* ide config */ - int is_cdrom; -+ int media_changed; - int cylinders, heads, sectors; - int64_t nb_sectors; - int mult_sectors; -@@ -1141,6 +1146,51 @@ static void ide_atapi_cmd_read(IDEState - } - } - -+static int cd_media_inserted(IDEState *s) -+{ -+ int inserted = 0; -+ -+ if (s->bs->removable) { -+ int h = open(s->bs->filename, O_NONBLOCK, O_RDONLY); -+ -+ if (h >= 0) { -+ struct stat statbuf; -+ if (fstat(h, &statbuf) == 0 && S_ISREG(statbuf.st_mode)) { -+ inserted = 1; -+ } else { -+ int status; -+ sg_io_hdr_t io_hdr; -+ unsigned char test_unit_ready_cmd[6] = {TEST_UNIT_READY, 0, 0, 0, 0, 0}; -+ unsigned char inqBuff[2]; -+ unsigned char sb[32]; -+ -+ memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); -+ io_hdr.interface_id = 'S'; -+ io_hdr.cmd_len = 6; -+ io_hdr.mx_sb_len = sizeof(sb); -+ io_hdr.dxfer_direction = SG_DXFER_NONE; -+ io_hdr.dxfer_len = 0; -+ io_hdr.dxferp = inqBuff; -+ io_hdr.sbp = (unsigned char *) sb; -+ io_hdr.timeout = 2000; -+ io_hdr.cmdp = test_unit_ready_cmd; -+ -+ sb[0] = 0xFF; -+ -+ status = ioctl(h, SG_IO, (void *)&io_hdr); -+ -+ if ( (status == 0) && (sb[0] == 0xFF)) -+ inserted = 1; -+ } -+ -+ close(h); -+ } -+ } else -+ inserted = 1; -+ -+ return inserted; -+} -+ - static void ide_atapi_cmd(IDEState *s) - { - const uint8_t *packet; -@@ -1162,11 +1212,25 @@ static void ide_atapi_cmd(IDEState *s) - switch(s->io_buffer[0]) { - case GPCMD_TEST_UNIT_READY: - if (bdrv_is_inserted(s->bs)) { -- ide_atapi_cmd_ok(s); -+ if (s->media_changed) { -+ s->media_changed = 0; -+ ide_atapi_cmd_error(s, SENSE_UNIT_ATTENTION, ASC_MEDIA_CHANGED); -+ } -+ else { -+ if (!cd_media_inserted(s) || shdev_media_check(s->bs)) { -+ bdrv_close(s->bs); -+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); -+ } -+ else -+ ide_atapi_cmd_ok(s); -+ } - } else { - ide_atapi_cmd_error(s, SENSE_NOT_READY, - ASC_MEDIUM_NOT_PRESENT); -- xenstore_check_new_media_present(1000); -+// xenstore_check_new_media_present(1000); -+ if (cd_media_inserted(s)) { -+ do_insert_request(); -+ } - } - break; - case GPCMD_MODE_SENSE_10: -@@ -1298,6 +1362,13 @@ static void ide_atapi_cmd(IDEState *s) - ASC_MEDIUM_NOT_PRESENT); - break; - } -+ -+ if (shdev_media_check(s->bs)) { -+ bdrv_close(s->bs); -+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); -+ break; -+ } -+ - nb_sectors = (packet[6] << 16) | (packet[7] << 8) | packet[8]; - lba = ube32_to_cpu(packet + 2); - if (nb_sectors == 0) { -@@ -1355,7 +1426,7 @@ static void ide_atapi_cmd(IDEState *s) - - if (eject && !start) { - /* eject the disk */ -- bdrv_close(s->bs); -+ do_eject(1, s->bs->device_name); - } - ide_atapi_cmd_ok(s); - } -@@ -1382,6 +1453,13 @@ static void ide_atapi_cmd(IDEState *s) - ASC_MEDIUM_NOT_PRESENT); - break; - } -+ -+ if (shdev_media_check(s->bs)) { -+ bdrv_close(s->bs); -+ ide_atapi_cmd_error(s, SENSE_NOT_READY, ASC_MEDIUM_NOT_PRESENT); -+ break; -+ } -+ - max_len = ube16_to_cpu(packet + 7); - format = packet[9] >> 6; - msf = (packet[1] >> 1) & 1; -@@ -1454,9 +1532,9 @@ static void cdrom_change_cb(void *opaque - IDEState *s = opaque; - int64_t nb_sectors; - -- /* XXX: send interrupt too */ - bdrv_get_geometry(s->bs, &nb_sectors); - s->nb_sectors = nb_sectors; -+ s->media_changed = 1; - } - - static void ide_cmd_lba48_transform(IDEState *s, int lba48) -@@ -1756,6 +1834,7 @@ static void ide_ioport_write(void *opaqu - ide_set_signature(s); - s->status = 0x00; /* NOTE: READY is _not_ set */ - s->error = 0x01; -+ s->media_changed = 0; - break; - case WIN_PACKETCMD: - if (!s->is_cdrom) -Index: xen-unstable/tools/ioemu/monitor.c -=================================================================== ---- xen-unstable.orig/tools/ioemu/monitor.c -+++ xen-unstable/tools/ioemu/monitor.c -@@ -24,6 +24,7 @@ - #include "vl.h" - #include "disas.h" - #include -+#include - #include "block_int.h" - - //#define DEBUG -@@ -340,7 +341,44 @@ void do_eject(int force, const char *fil - term_printf("device not found\n"); - return; - } -- eject_device(bs, force); -+ -+ if (eject_device(bs, force) == 0) { -+ char cmd[strlen(bs->filename) + 16]; -+ shdev_eject_notice(bs); -+ sprintf(cmd, "eject %s", bs->filename); -+ system(cmd); -+ } -+} -+ -+void do_insert(const char *device) -+{ -+ BlockDriverState *bs; -+ -+ bs = bdrv_find(device); -+ -+ if (!bs) { -+ term_printf("'%s' not found\n", device); -+ return; -+ } -+ -+ if (!bs->removable) { -+ term_printf("'%s' is not removable\n", device); -+ return; -+ } -+ -+ if (bs->inserted) { -+ term_printf("'%s' is already inserted\n", device); -+ return; -+ } -+ -+ bdrv_open(bs, bs->filename, 0); -+} -+ -+static int find_bs_by_type(BlockDriverState *bs, void *opaque) -+{ -+ int *type = (int *)opaque; -+ -+ return( (bs->type == *type) ); - } - - void do_change(const char *device, const char *filename) -@@ -356,7 +394,8 @@ void do_change(const char *device, const - } - if (eject_device(bs, 0) < 0) - return; -- bdrv_open(bs, filename, 0); -+ pstrcpy(bs->filename, sizeof(bs->filename), filename); -+ do_insert(bs->device_name); - if (bdrv_is_encrypted(bs)) { - term_printf("%s is encrypted.\n", device); - for(i = 0; i < 3; i++) { -@@ -368,6 +407,19 @@ void do_change(const char *device, const - } - } - -+void do_insert_request() -+{ -+ BlockDriverState *bs = NULL; -+ int type = BDRV_TYPE_CDROM; -+ -+ bs = bdrv_find_bs(find_bs_by_type, &type); -+ -+ if (bs) -+ do_change(bs->device_name, bs->filename); -+ else -+ term_printf("Did not find cdrom bs.\n"); -+} -+ - static void do_screen_dump(const char *filename) - { - vga_hw_screen_dump(filename); -Index: xen-unstable/tools/ioemu/sdl.c -=================================================================== ---- xen-unstable.orig/tools/ioemu/sdl.c -+++ xen-unstable/tools/ioemu/sdl.c -@@ -544,7 +544,7 @@ void sdl_display_init(DisplayState *ds, - #ifndef _WIN32 - /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */ - signal(SIGINT, SIG_DFL); -- signal(SIGQUIT, SIG_DFL); -+// signal(SIGQUIT, SIG_DFL); - #endif - - ds->dpy_update = sdl_update; -Index: xen-unstable/tools/ioemu/vl.h -=================================================================== ---- xen-unstable.orig/tools/ioemu/vl.h -+++ xen-unstable/tools/ioemu/vl.h -@@ -180,6 +180,8 @@ extern int smp_cpus; - #define BIOS_SIZE ((256 + 64) * 1024) - #endif - -+#define CDROM_DISK_POSITION 2 -+ - /* keyboard/mouse support */ - - #define MOUSE_EVENT_LBUTTON 0x01 -@@ -561,6 +563,7 @@ void bdrv_set_change_cb(BlockDriverState - void (*change_cb)(void *opaque), void *opaque); - void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); - void bdrv_info(void); -+BlockDriverState *bdrv_find_bs(int (*it)(BlockDriverState *bs, void *opaque), void *opaque); - BlockDriverState *bdrv_find(const char *name); - void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); - int bdrv_is_encrypted(BlockDriverState *bs); -@@ -1180,6 +1183,15 @@ pflash_t *pflash_register (target_ulong - - #endif /* defined(QEMU_TOOL) */ - -+/* shdev.h */ -+ -+int shdev_init(void); -+int shdev_report_device(BlockDriverState *bs, const char *name); -+void shdev_set_media_instance(BlockDriverState *bs); -+void shdev_eject_notice(BlockDriverState *bs); -+inline int shdev_media_check(BlockDriverState *bs); -+void do_info_shdev(void); -+ - /* monitor.c */ - void monitor_init(CharDriverState *hd, int show_banner); - void term_puts(const char *str); -@@ -1189,6 +1201,7 @@ void term_flush(void); - void term_print_help(void); - void monitor_readline(const char *prompt, int is_password, - char *buf, int buf_size); -+void do_insert_request(void); - void do_eject(int force, const char *filename); - void do_change(const char *device, const char *filename); - -Index: xen-unstable/tools/ioemu/shdev.c -=================================================================== ---- /dev/null -+++ xen-unstable/tools/ioemu/shdev.c -@@ -0,0 +1,138 @@ -+/* -+ * Managment for Devices Shared Across Guests -+ * -+ * Copyright (c) 2006 Novell, Inc. -+ * -+ * - Author: Ross Maxfield (ross.maxfield@novell.com) -+ * -+ * 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. -+ */ -+ -+#include "vl.h" -+#include "block_int.h" -+#include -+ -+#define MAX_SHARED_DEVS 4 -+#define SHDEV_NAME_LEN 128 -+#define SHARED_DEVS_SIGNATURE "ShRdDeVs" -+#define QEMU_KEY_PATH "/etc/xen" -+ -+typedef struct SharedDevice { -+ char name[SHDEV_NAME_LEN]; -+ int media_instance; -+} SharedDevice; -+ -+typedef struct SharedDevices { -+ char signature[sizeof(SHARED_DEVS_SIGNATURE)]; -+ SharedDevice device[MAX_SHARED_DEVS]; -+} SharedDevices; -+ -+SharedDevices *shdevs; -+ -+int shdev_init() -+{ -+ key_t shm_key; -+ int shm_id; -+ -+ /* Alloc/Get shared device memory */ -+ shm_key = ftok(QEMU_KEY_PATH, 'X'); -+ -+ if (((shm_id = shmget(shm_key, -+ sizeof(SharedDevices), -+ IPC_CREAT|IPC_EXCL|0660)) != -1) -+ && ((shdevs = shmat(shm_id, 0, 0)) != (void *)-1)) { -+ memcpy(&shdevs->signature, SHARED_DEVS_SIGNATURE, -+ sizeof(SHARED_DEVS_SIGNATURE)); -+ } -+ else -+ if (errno == EEXIST) -+ { -+ if (((shm_id = shmget(shm_key, sizeof(SharedDevices), 0)) == -1) -+ || ((shdevs = shmat(shm_id, 0, 0)) == (void *)-1) -+ || (memcmp(shdevs->signature, SHARED_DEVS_SIGNATURE, -+ sizeof(SHARED_DEVS_SIGNATURE)) != 0)) { -+ shdevs = NULL; -+ fprintf(stderr, "Could not setup support for shared devices.\n"); -+ return 1; -+ } -+ } -+ -+ return 0; -+} -+ -+void shdev_set_media_instance(BlockDriverState *bs) -+{ -+ bs->media_instance = shdevs->device[bs->shdev_el].media_instance; -+} -+ -+void shdev_eject_notice(BlockDriverState *bs) -+{ -+ shdevs->device[bs->shdev_el].media_instance++; -+} -+ -+inline int shdev_media_check(BlockDriverState *bs) -+{ -+ return(!(bs->media_instance == shdevs->device[bs->shdev_el].media_instance)); -+} -+ -+int shdev_report_device(BlockDriverState *bs, const char *name) -+{ -+ int i; -+ -+ for (i = 0; -+ (i < MAX_SHARED_DEVS) && strcmp(shdevs->device[i].name, name); -+ i++); -+ -+ if (i == MAX_SHARED_DEVS) { -+ for (i = 0; -+ (i < MAX_SHARED_DEVS) && (shdevs->device[i].name[0] != '\0'); -+ i++); -+ -+ if (i < MAX_SHARED_DEVS) { -+ pstrcpy(shdevs->device[i].name, SHDEV_NAME_LEN, name); -+ shdevs->device[i].media_instance = 0; -+ } -+ else { -+ fprintf(stderr, "%s exceeds maximum of %d shared devices.\n", -+ name, MAX_SHARED_DEVS ); -+ return -1; -+ } -+ } -+ -+ bs->media_instance = shdevs->device[i].media_instance; -+ bs->shdev_el = i; -+ -+ return 0; -+} -+ -+void do_info_shdev(void) -+{ -+ int i; -+ -+ /* Can this device be made availble to this domain? */ -+ for (i = 0; i < MAX_SHARED_DEVS; i++) { -+ if (shdevs->device[i].name[0] != '\0') { -+ term_printf("'%s' [%d]\n", -+ shdevs->device[i].name, -+ shdevs->device[i].media_instance); -+ } -+ } -+} -+ -+ -Index: xen-unstable/tools/ioemu/Makefile.target -=================================================================== ---- xen-unstable.orig/tools/ioemu/Makefile.target -+++ xen-unstable/tools/ioemu/Makefile.target -@@ -307,7 +307,7 @@ ifeq ($(ARCH),alpha) - endif - - # must use static linking to avoid leaving stuff in virtual address space --VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o -+VL_OBJS=vl.o osdep.o block.o shdev.o readline.o monitor.o pci.o console.o - VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o - ifdef CONFIG_WIN32 - VL_OBJS+=tap-win32.o -Index: xen-unstable/tools/ioemu/vl.c -=================================================================== ---- xen-unstable.orig/tools/ioemu/vl.c -+++ xen-unstable/tools/ioemu/vl.c -@@ -5843,6 +5843,8 @@ int main(int argc, char **argv) - int usb_devices_index; - unsigned long nr_pages, tmp_nr_pages, shared_page_nr; - xen_pfn_t *page_array; -+ int dev_type; -+ char buf[64]; - extern void *shared_page; - extern void *buffered_io_page; - -@@ -5073,7 +5073,7 @@ int main(int argc, char **argv) - #ifdef CONFIG_GDBSTUB - int use_gdbstub, gdbstub_port; - #endif -- int i, has_cdrom; -+ int i, has_cdrom = 0; - int snapshot, linux_boot; - CPUState *env; - const char *initrd_filename; -@@ -5094,6 +5094,8 @@ int main(int argc, char **argv) - const char *loadvm = NULL; - unsigned long nr_pages, extra_pages, ram_pages, *page_array; - xc_dominfo_t info; -+ int dev_type; -+ char buf[64]; - extern void *shared_page; - extern void *shared_vram; - extern void *buffered_io_page; -@@ -5122,7 +5124,6 @@ int main(int argc, char **argv) - vncconnect=NULL; - kernel_filename = NULL; - kernel_cmdline = ""; -- has_cdrom = 1; - cyls = heads = secs = 0; - pstrcpy(monitor_device, sizeof(monitor_device), "vc"); - -@@ -5185,12 +5186,6 @@ int main(int argc, char **argv) - case QEMU_OPTION_initrd: - initrd_filename = optarg; - break; -- case QEMU_OPTION_hda: -- hd_filename[0] = optarg; -- break; -- case QEMU_OPTION_hdb: -- hd_filename[1] = optarg; -- break; - case QEMU_OPTION_snapshot: - snapshot = 1; - break; -@@ -5263,15 +5258,56 @@ int main(int argc, char **argv) - } - } - break; -+ case QEMU_OPTION_hda: -+ if (hd_filename[0]) { -+ fprintf(stderr, -+ "qemu: virtual device 'hd%c' already defined as %s\n", -+ 'a', -+ hd_filename[0] ); -+ break; -+ } -+ hd_filename[0] = optarg; -+ break; -+ case QEMU_OPTION_hdb: -+ if (hd_filename[1]) { -+ fprintf(stderr, -+ "qemu: virtual device 'hd%c' already defined as %s\n", -+ 'b', -+ hd_filename[1] ); -+ break; -+ } -+ hd_filename[1] = optarg; -+ break; - case QEMU_OPTION_hdc: -+ if (hd_filename[2]) { -+ fprintf(stderr, -+ "qemu: virtual device 'hd%c' already defined as %s\n", -+ 'c', -+ hd_filename[2] ); -+ break; -+ } - hd_filename[2] = optarg; -- has_cdrom = 0; - break; - case QEMU_OPTION_hdd: -+ if (hd_filename[3]) { -+ fprintf(stderr, -+ "qemu: virtual device 'hd%c' already defined as %s\n", -+ 'd', -+ hd_filename[3] ); -+ break; -+ } - hd_filename[3] = optarg; - break; - case QEMU_OPTION_cdrom: -- hd_filename[2] = optarg; -+ if (hd_filename[CDROM_DISK_POSITION]) { -+ fprintf(stderr, -+ "qemu: virtual device 'hd%c' for cdrom " -+ "is already defined as %s\n", -+ 'a' + CDROM_DISK_POSITION, -+ hd_filename[CDROM_DISK_POSITION] ); -+ break; -+ } -+ hd_filename[CDROM_DISK_POSITION] = optarg; - has_cdrom = 1; - break; - case QEMU_OPTION_boot: -@@ -5487,7 +5523,7 @@ int main(int argc, char **argv) - linux_boot = (kernel_filename != NULL); - - if ( !linux_boot && hd_filename[0] == '\0' && -- hd_filename[2] == '\0' && fd_filename[0] == '\0' ) -+ hd_filename[CDROM_DISK_POSITION] == '\0' && fd_filename[0] == '\0' ) - help(); - - /* boot to cd by default if no hard disk */ -@@ -5668,59 +5704,55 @@ int main(int argc, char **argv) - fprintf(logfile, "shared page at pfn:%lx, mfn: %lx\n", (nr_pages-1), - (page_array[nr_pages - 1])); - -- /* we always create the cdrom drive, even if no disk is there */ - bdrv_init(); -- if (has_cdrom) { -- int fd; -- if ( (fd = open(hd_filename[2], O_RDONLY | O_BINARY)) < 0) { -- hd_filename[2]=NULL; -- bs_table[2]=NULL; -- fprintf(logfile, "Could not open CD %s.\n", hd_filename[i]); -- } -- else { -- close(fd); -- bs_table[2] = bdrv_new("cdrom"); -- bdrv_set_type_hint(bs_table[2], BDRV_TYPE_CDROM); -- } -- } -+ -+ shdev_init(); - - /* open the virtual block devices */ - for(i = 0; i < MAX_DISKS; i++) { - if (hd_filename[i]) { -- if (!bs_table[i]) { -- char buf[64]; -+ if ((i == CDROM_DISK_POSITION) && has_cdrom) { -+ snprintf(buf, sizeof(buf), "cdrom"); -+ dev_type = BDRV_TYPE_CDROM; -+ } -+ else { - snprintf(buf, sizeof(buf), "hd%c", i + 'a'); -- bs_table[i] = bdrv_new(buf); -+ dev_type = BDRV_TYPE_HD; - } -+ -+ bs_table[i] = bdrv_new(buf); -+ -+ bdrv_set_type_hint(bs_table[i], dev_type); -+ -+ if (bs_table[i]->removable) -+ shdev_report_device(bs_table[i], hd_filename[i]); -+ - if (bdrv_open(bs_table[i], hd_filename[i], snapshot) < 0) { -+ if (bs_table[i]->removable) -+ continue; -+ - fprintf(stderr, "qemu: could not open hard disk image '%s'\n", - hd_filename[i]); - exit(1); - } -+ - if (i == 0 && cyls != 0) - bdrv_set_geometry_hint(bs_table[i], cyls, heads, secs); - } - } - -- /* we always create at least one floppy disk */ -- fd_table[0] = bdrv_new("fda"); -- bdrv_set_type_hint(fd_table[0], BDRV_TYPE_FLOPPY); -- - for(i = 0; i < MAX_FD; i++) { - if (fd_filename[i]) { - if (!fd_table[i]) { -- char buf[64]; - snprintf(buf, sizeof(buf), "fd%c", i + 'a'); - fd_table[i] = bdrv_new(buf); - bdrv_set_type_hint(fd_table[i], BDRV_TYPE_FLOPPY); -+ shdev_report_device(fd_table[i], fd_filename[i]); - } -- if (fd_filename[i] != '\0') { -- if (bdrv_open(fd_table[i], fd_filename[i], snapshot) < 0) { -- fprintf(stderr, "qemu: could not open floppy disk image '%s'\n", -+ -+ if (bdrv_open(fd_table[i], fd_filename[i], snapshot) < 0) -+ fprintf(stderr, "qemu: could not open floppy disk '%s'\n", - fd_filename[i]); -- exit(1); -- } -- } - } - } - diff --git a/xen-rpmoptflags.diff b/xen-rpmoptflags.diff index 6972535..189b4d4 100644 --- a/xen-rpmoptflags.diff +++ b/xen-rpmoptflags.diff @@ -3,7 +3,7 @@ Index: xen-unstable/tools/blktap/drivers/Makefile --- xen-unstable.orig/tools/blktap/drivers/Makefile +++ xen-unstable/tools/blktap/drivers/Makefile @@ -8,7 +8,6 @@ QCOW_UTIL = img2qcow qcow2raw qcow-cr - INST_DIR = /usr/sbin + INST_DIR = /usr/sbin LIBAIO_DIR = ../../libaio/src -CFLAGS += -Werror @@ -27,7 +27,7 @@ Index: xen-unstable/Config.mk =================================================================== --- xen-unstable.orig/Config.mk +++ xen-unstable/Config.mk -@@ -13,7 +13,7 @@ CONFIG_$(XEN_OS) := y +@@ -18,7 +18,7 @@ SHELL ?= /bin/sh # Tools to run on system hosting the build HOSTCC = gcc diff --git a/xen-tightvnc-args.diff b/xen-tightvnc-args.diff index 4ce2e1b..c964a15 100644 --- a/xen-tightvnc-args.diff +++ b/xen-tightvnc-args.diff @@ -1,8 +1,8 @@ -Index: xen-3.0.4-testing/tools/python/xen/xm/create.py +Index: xen-unstable/tools/python/xen/xm/create.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xm/create.py -+++ xen-3.0.4-testing/tools/python/xen/xm/create.py -@@ -962,8 +962,7 @@ def spawn_vnc(display): +--- xen-unstable.orig/tools/python/xen/xm/create.py ++++ xen-unstable/tools/python/xen/xm/create.py +@@ -978,8 +978,7 @@ def spawn_vnc(display): returns the port that the vncviewer is listening on and sets the global vncpid. On failure, returns 0. Note that vncviewer is daemonized. """ diff --git a/xen-vm-install.diff b/xen-vm-install.diff index f9b0b0d..39d393b 100644 --- a/xen-vm-install.diff +++ b/xen-vm-install.diff @@ -5,7 +5,7 @@ Index: xen-unstable/tools/Makefile @@ -25,6 +25,7 @@ SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen # These don't cross-compile ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) - SUBDIRS-y += python + SUBDIRS-$(PYTHON_TOOLS) += python +SUBDIRS-y += xen-vm-install endif diff --git a/xen-vm-install.tar.bz2 b/xen-vm-install.tar.bz2 index 5956ef6..4d31771 100644 --- a/xen-vm-install.tar.bz2 +++ b/xen-vm-install.tar.bz2 @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:555986d5b819ceb302b46d7f185b78e21228cfdb4a14fd761c61ae3f9292fd22 -size 138263 +oid sha256:d1b7dd781f0f0a5f29485c7730909176993e5919b94d499972d25580b3c14254 +size 174327 diff --git a/xen-warnings.diff b/xen-warnings.diff index 679c49c..0401527 100644 --- a/xen-warnings.diff +++ b/xen-warnings.diff @@ -2,7 +2,7 @@ Index: xen-unstable/xen/tools/symbols.c =================================================================== --- xen-unstable.orig/xen/tools/symbols.c +++ xen-unstable/xen/tools/symbols.c -@@ -120,7 +120,8 @@ read_symbol(FILE *in, struct sym_entry * +@@ -80,7 +80,8 @@ static int read_symbol(FILE *in, struct if (rc != 3) { if (rc != EOF) { /* skip line */ @@ -49,3 +49,15 @@ Index: xen-unstable/tools/misc/miniterm/miniterm.c break; } +Index: xen-unstable/tools/ioemu/hw/usb-hid.c +=================================================================== +--- xen-unstable.orig/tools/ioemu/hw/usb-hid.c ++++ xen-unstable/tools/ioemu/hw/usb-hid.c +@@ -557,6 +557,7 @@ int usb_mouse_load(QEMUFile *f, void *op + fprintf(logfile, "usb_mouse_load:add usb_mouse_event.\n"); + qemu_add_mouse_event_handler(usb_mouse_event, s, 0); + } ++ return 0; + } + + diff --git a/xen-xm-top-needs-root.diff b/xen-xm-top-needs-root.diff index 03654ae..cb3ef63 100644 --- a/xen-xm-top-needs-root.diff +++ b/xen-xm-top-needs-root.diff @@ -1,11 +1,11 @@ From: Charles Coffing Upstream: no -Index: xen-3.0.4-testing/tools/python/xen/xm/main.py +Index: xen-3.0.5-testing/tools/python/xen/xm/main.py =================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/xm/main.py -+++ xen-3.0.4-testing/tools/python/xen/xm/main.py -@@ -1312,6 +1312,10 @@ def xm_sysrq(args): +--- xen-3.0.5-testing.orig/tools/python/xen/xm/main.py ++++ xen-3.0.5-testing/tools/python/xen/xm/main.py +@@ -1749,6 +1749,10 @@ def xm_debug_keys(args): def xm_top(args): arg_check(args, "top", 0) diff --git a/xen-xmexample-nbd.diff b/xen-xmexample-nbd.diff index ab8af5e..2ea1448 100644 --- a/xen-xmexample-nbd.diff +++ b/xen-xmexample-nbd.diff @@ -2,7 +2,7 @@ Index: xen-unstable/tools/examples/Makefile =================================================================== --- xen-unstable.orig/tools/examples/Makefile +++ xen-unstable/tools/examples/Makefile -@@ -12,7 +12,7 @@ XEN_CONFIGS = xend-config.sxp +@@ -15,7 +15,7 @@ XEN_CONFIGS += xm-config-xenapi.xml XEN_CONFIGS += xmexample1 XEN_CONFIGS += xmexample2 XEN_CONFIGS += xmexample.hvm diff --git a/xen-xmexample.diff b/xen-xmexample.diff index 05a3314..6cbc3a1 100644 --- a/xen-xmexample.diff +++ b/xen-xmexample.diff @@ -1,9 +1,9 @@ Change various example paths in the config files to match SUSE. -Index: xen-3.0.4-testing/tools/examples/xmexample1 +Index: xen-unstable/tools/examples/xmexample1 =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xmexample1 -+++ xen-3.0.4-testing/tools/examples/xmexample1 +--- xen-unstable.orig/tools/examples/xmexample1 ++++ xen-unstable/tools/examples/xmexample1 @@ -7,11 +7,13 @@ #============================================================================ @@ -23,7 +23,7 @@ Index: xen-3.0.4-testing/tools/examples/xmexample1 # The domain build function. Default is 'linux'. #builder='linux' -@@ -96,7 +98,7 @@ disk = [ 'phy:hda1,hda1,w' ] +@@ -130,7 +132,7 @@ disk = [ 'phy:hda1,hda1,w' ] #hostname= "vm%d" % vmid # Set root device. @@ -32,7 +32,7 @@ Index: xen-3.0.4-testing/tools/examples/xmexample1 # Root device for nfs. #root = "/dev/nfs" -@@ -105,8 +107,8 @@ root = "/dev/hda1 ro" +@@ -139,8 +141,8 @@ root = "/dev/hda1 ro" # Root directory on the nfs server. #nfs_root = '/full/path/to/root/directory' @@ -43,10 +43,10 @@ Index: xen-3.0.4-testing/tools/examples/xmexample1 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.0.4-testing/tools/examples/xmexample2 +Index: xen-unstable/tools/examples/xmexample2 =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xmexample2 -+++ xen-3.0.4-testing/tools/examples/xmexample2 +--- xen-unstable.orig/tools/examples/xmexample2 ++++ xen-unstable/tools/examples/xmexample2 @@ -35,11 +35,13 @@ xm_vars.var('vmid', xm_vars.check() @@ -66,7 +66,7 @@ Index: xen-3.0.4-testing/tools/examples/xmexample2 # The domain build function. Default is 'linux'. #builder='linux' -@@ -132,7 +134,7 @@ disk = [ 'phy:sda%d,sda1,w' % (7+vmid), +@@ -166,7 +168,7 @@ disk = [ 'phy:sda%d,sda1,w' % (7+vmid), #hostname= "vm%d" % vmid # Set root device. @@ -75,7 +75,7 @@ Index: xen-3.0.4-testing/tools/examples/xmexample2 # Root device for nfs. #root = "/dev/nfs" -@@ -141,8 +143,8 @@ root = "/dev/sda1 ro" +@@ -175,8 +177,8 @@ root = "/dev/sda1 ro" # Root directory on the nfs server. #nfs_root = '/full/path/to/root/directory' @@ -86,10 +86,10 @@ Index: xen-3.0.4-testing/tools/examples/xmexample2 #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.0.4-testing/tools/examples/xmexample3 +Index: xen-unstable/tools/examples/xmexample3 =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xmexample3 -+++ xen-3.0.4-testing/tools/examples/xmexample3 +--- xen-unstable.orig/tools/examples/xmexample3 ++++ xen-unstable/tools/examples/xmexample3 @@ -35,11 +35,13 @@ xm_vars.var('vmid', xm_vars.check() @@ -109,10 +109,10 @@ Index: xen-3.0.4-testing/tools/examples/xmexample3 # The domain build function. Default is 'linux'. #builder='linux' -Index: xen-3.0.4-testing/tools/examples/xmexample.hvm +Index: xen-unstable/tools/examples/xmexample.hvm =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xmexample.hvm -+++ xen-3.0.4-testing/tools/examples/xmexample.hvm +--- xen-unstable.orig/tools/examples/xmexample.hvm ++++ xen-unstable/tools/examples/xmexample.hvm @@ -71,7 +71,7 @@ vif = [ 'type=ioemu, bridge=xenbr0' ] # and MODE is r for read-only, w for read-write. @@ -122,10 +122,10 @@ Index: xen-3.0.4-testing/tools/examples/xmexample.hvm #---------------------------------------------------------------------------- # Configure the behaviour when a domain exits. There are three 'reasons' -Index: xen-3.0.4-testing/docs/man/xmdomain.cfg.pod.5 +Index: xen-unstable/docs/man/xmdomain.cfg.pod.5 =================================================================== ---- xen-3.0.4-testing.orig/docs/man/xmdomain.cfg.pod.5 -+++ xen-3.0.4-testing/docs/man/xmdomain.cfg.pod.5 +--- xen-unstable.orig/docs/man/xmdomain.cfg.pod.5 ++++ xen-unstable/docs/man/xmdomain.cfg.pod.5 @@ -38,13 +38,13 @@ file. The kernel image for the domain. The format of the parameter is the @@ -142,7 +142,7 @@ Index: xen-3.0.4-testing/docs/man/xmdomain.cfg.pod.5 many Linux distros you will not need a ramdisk if using the default xen kernel. -@@ -258,14 +258,14 @@ configured. They should not be consider +@@ -307,14 +307,14 @@ configured. They should not be consider =item I @@ -161,10 +161,10 @@ Index: xen-3.0.4-testing/docs/man/xmdomain.cfg.pod.5 at hda1, which is the root filesystem. =item I -Index: xen-3.0.4-testing/docs/man/xm.pod.1 +Index: xen-unstable/docs/man/xm.pod.1 =================================================================== ---- xen-3.0.4-testing.orig/docs/man/xm.pod.1 -+++ xen-3.0.4-testing/docs/man/xm.pod.1 +--- xen-unstable.orig/docs/man/xm.pod.1 ++++ xen-unstable/docs/man/xm.pod.1 @@ -102,8 +102,8 @@ soon as it is run. =item I diff --git a/xen.changes b/xen.changes index 9a6b227..9f45e9d 100644 --- a/xen.changes +++ b/xen.changes @@ -1,7 +1,164 @@ ------------------------------------------------------------------- -Sat Apr 21 10:18:45 CEST 2007 - aj@suse.de +Wed Apr 25 13:41:20 MDT 2007 - ccoffing@novell.com -- Use texlive for openSUSE 10.3. +- Update to xen-3.0.5-testing rc3 (changeset 14934). +- Switch BuildRequires to texlive. + +------------------------------------------------------------------- +Fri Apr 20 11:43:06 MDT 2007 - ccoffing@novell.com + +- Updated README. (#250705) +- Fix vm-install's detection of PV RHEL4/5 kernels. (#260983) + +------------------------------------------------------------------- +Thu Apr 19 16:00:12 MDT 2007 - ccoffing@novell.com + +- Place xenstore-* tools in new xen-tools-domU package, to be used + by suse_register. (#249157) + +------------------------------------------------------------------- +Tue Apr 17 08:20:47 MDT 2007 - ccoffing@novell.com + +- Update translations. + +------------------------------------------------------------------- +Thu Apr 12 14:23:15 MDT 2007 - ccoffing@novell.com + +- Combine two xenstore reads into one transaction, which causes + xenstored to not thrash so badly, and makes virt-manager more + responsive and less likely to time out or lock up. Partial fix + for #237406. +- If disk is read-only, pass -r to losetup. (#264158) + +------------------------------------------------------------------- +Thu Apr 5 17:45:45 MDT 2007 - ccoffing@novell.com + +- Update vm-install: + + #260510: do not delete xml settings file + + #260579: write correct vif line for PV NIC in FV VM + + #261288: re-enable add disk buttons after deleting a disk + + #192272, #222765, #250618: Update OS list and their defaults + +------------------------------------------------------------------- +Tue Apr 3 17:07:37 MDT 2007 - ccoffing@novell.com + +- Could not do simultaneous installs via virt-manager. (#259917) + +------------------------------------------------------------------- +Mon Apr 2 17:48:43 MDT 2007 - jfehlig@novell.com + +- Fix improper handling of guest kernel arguments in domUloader. + Bug #259810 + +------------------------------------------------------------------- +Mon Apr 2 17:02:11 MDT 2007 - ccoffing@novell.com + +- Update vm-install: + + #259420: refresh available memory more often + + #259972: cannot enter autoyast url + +------------------------------------------------------------------- +Mon Apr 2 08:46:03 MDT 2007 - ccoffing@novell.com + +- Update translations for RC2. + +------------------------------------------------------------------- +Fri Mar 30 12:54:45 MDT 2007 - ccoffing@novell.com + +- Fix "cannot allocate memory" when starting VMs. (#229849, 258743) + +------------------------------------------------------------------- +Thu Mar 29 10:16:54 MDT 2007 - ccoffing@novell.com + +- Fix quoting of args for child processes during VM install. + (#258376) +- Fix retry logic in block hotplug script. (#257925) + +------------------------------------------------------------------- +Wed Mar 28 11:31:48 MDT 2007 - ccoffing@novell.com + +- Updated vm-install's icon name. +- Updated translations. + +------------------------------------------------------------------- +Fri Mar 23 11:25:01 MDT 2007 - ccoffing@novell.com + +- Disable aspects of qemu's console that can affect domain 0. + (#256135) +- Fix xmclone.sh to work with managed domains. (#253988) +- Update to xen-unstable changeset 14535. + +------------------------------------------------------------------- +Mon Mar 19 09:46:21 MDT 2007 - ccoffing@novell.com + +- Update to xen-unstable changeset 14444. +- Include Ron Terry's network-multi_bridge + +------------------------------------------------------------------- +Fri Mar 9 18:45:33 MST 2007 - jfehlig@novell.com + +- Added lame patch to handle showing suspended state via Xen API. + The patch only affects Xen API and is thus low risk. + Bug #237859 + +------------------------------------------------------------------- +Fri Mar 9 17:00:20 MST 2007 - carnold@novell.com + +- Added AMD support for Vista 64 installation and boot. + +------------------------------------------------------------------- +Fri Mar 9 12:24:12 MST 2007 - ccoffing@novell.com + +- Make vm-install support NFS for SUSE (#241251). + +------------------------------------------------------------------- +Fri Mar 9 10:07:05 MST 2007 - jfehlig@novell.com + +- Fixed bug #250522 + + Upstream c/s 13557 stores model attribute of vif in xenstore. + +------------------------------------------------------------------- +Thu Mar 8 12:35:18 MST 2007 - ccoffing@novell.com + +- Update vm-install: + + Better description on "Virtual Disk" drop-down (not "xvda") + + Proper separation of recording options versus calculating + defaults; fixes corner cases + + #247849, #253013, 253009: Multiple fixes related to how disks + are defined, centered around bug #247849 (handle partitioned + PV installation disk) + + #252437: Allow virtual CDROM to be added (via ISO) even if + physical CDROM doesn't exist + +------------------------------------------------------------------- +Wed Mar 7 19:43:55 MST 2007 - jfehlig@novell.com + +- Fixed bug #252396 + + Added upstream c/s 14021. Applies to Xen API c-bindings - + low risk. + + Added local patch to correctly set Xen API Console.protocol + property + +------------------------------------------------------------------- +Wed Mar 7 14:28:41 MST 2007 - jfehlig@novell.com + +- Added upstream patch that fixes save/restore on 32pae guests. + Upstream c/s 14150. Bug #237859 + +------------------------------------------------------------------- +Tue Mar 6 15:48:13 MST 2007 - carnold@novell.com + +- Remove a debug message which is spamming the logs during live + migration. + +------------------------------------------------------------------- +Mon Mar 5 17:51:17 MST 2007 - jfehlig@novell.com + +- Fixed handling of vbd type in Xen API <-> sexpr integration. + Bug #250351 + + Updated an existing patch (xend_disk_decorate_rm.patch) and + then renamed patch to xend_vbd_type.patch to better reflect + purpose of patch. ------------------------------------------------------------------- Mon Mar 5 09:38:36 MST 2007 - ccoffing@novell.com diff --git a/xen.spec b/xen.spec index 9e55ef3..50d06fa 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen (Version 3.0.4_13138) +# spec file for package xen (Version 3.0.5_14934) # # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany. # This file and all modifications and additions to the pristine @@ -13,8 +13,8 @@ Name: xen %define xvers 3.0 %define xvermaj 3 -%define changeset 13138 -%define xen_build_dir xen-3.0.4-testing +%define changeset 14934 +%define xen_build_dir xen-3.0.5-testing %define with_install 1 %if %sles_version %define with_kmp 1 @@ -22,26 +22,21 @@ Name: xen # openSUSE 10.3 kernel is not yet ready... %define with_kmp 0 %endif -BuildRequires: LibVNCServer SDL-devel autoconf automake bin86 curl-devel dev86 latex2html libjpeg-devel libxml2-devel openssl openssl-devel python-devel texlive-latex transfig -%if %suse_version > 1020 -BuildRequires: texlive-latex -%else -BuildRequires: te_ams te_latex -%endif +BuildRequires: LibVNCServer SDL-devel autoconf automake bin86 curl-devel dev86 graphviz latex2html libjpeg-devel libxml2-devel openssl openssl-devel python-devel texlive texlive-latex transfig %ifarch x86_64 BuildRequires: glibc-32bit glibc-devel-32bit %endif %if %{?with_kmp}0 BuildRequires: kernel-source kernel-syms xorg-x11 %endif -Version: 3.0.4_13138 -Release: 14 +Version: 3.0.5_14934 +Release: 1 License: GNU General Public License (GPL) Group: System/Kernel Autoreqprov: on PreReq: %insserv_prereq %fillup_prereq Summary: Xen Virtualization: Hypervisor (aka VMM aka Microkernel) -Source0: xen-3.0.4-testing-src.tar.bz2 +Source0: xen-3.0.5-testing-src.tar.bz2 Source1: xen-vm-install.tar.bz2 Source2: README.SuSE Source3: boot.xen @@ -56,6 +51,8 @@ Source11: xmexample.nbd Source12: block-iscsi Source13: xmexample.iscsi Source14: xmclone.sh +Source15: dom0config +Source16: network-multi_bridge Patch0: xen-config.diff Patch1: xend-config.diff Patch2: xen-destdir.diff @@ -66,10 +63,10 @@ Patch6: xen-changeset.diff Patch7: xen-paths.diff Patch8: xen-xmexample.diff Patch9: xen-xmexample-nbd.diff -Patch10: xen-bootloader-nohang.diff -Patch11: xen-bootloader-dryrun.diff -Patch12: xen-bootloader-tidy.diff -Patch13: xen-domUloader.diff +Patch10: xen-bootloader-dryrun.diff +Patch11: xen-bootloader-tidy.diff +Patch12: xen-domUloader.diff +Patch13: xen-linguas.diff Patch14: xen-messages.diff Patch15: xen-network-bridge.diff Patch16: xen-no-dummy-nfs-ip.diff @@ -81,142 +78,33 @@ Patch21: xen-bonding.diff Patch22: xen-ioapic-ack-default.diff Patch23: xen-lost-mouse.diff Patch24: xen-lowmem-emergency-pool.diff -Patch26: block-losetup-retry.diff -Patch27: block-sync.diff -Patch29: xen-man-permissions.patch -Patch30: xen-man-xm-bad-char.diff -Patch31: xen-hvm-default-bridge.diff -Patch32: xen-hvm-netfront.diff -Patch33: xend-xmlrpc-large-ints.diff -Patch34: xen-hvm-default-pae.diff -#Patch35: xend-config-devname.patch -Patch36: xend-config-ramdisk.patch -Patch37: xm-test-cleanup.diff -## Jan's patches begin here -Patch100: x86-extra-trap-info.patch -Patch101: x86_emulate.patch -# 32on64 patches -Patch102: 32on64-base.patch -Patch103: 32on64-hypercall.patch -Patch104: 32on64-interface.patch -Patch105: 32on64-startup.patch -Patch106: 32on64-shared.patch -Patch107: 32on64-m2p.patch -Patch108: 32on64-emul.patch -Patch109: 32on64-memop.patch -Patch110: 32on64-mmuop.patch -Patch111: 32on64-physdevop.patch -Patch112: 32on64-vcpuop.patch -Patch113: 32on64-settrap.patch -Patch114: 32on64-multicall.patch -Patch115: 32on64-schedop.patch -Patch116: 32on64-gnttabop.patch -Patch117: 32on64-pltop.patch -Patch118: 32on64-acmop.patch -Patch119: 32on64-xenoprof.patch -Patch120: 32on64-sysctl.patch -Patch121: 32on64-domctl.patch -Patch122: 32on64-trace.patch -Patch123: 32on64-kexec.patch -Patch124: 32on64-hvm.patch -Patch125: 32on64-shadow.patch -# Additional patches -Patch130: xxx_heap_pages-static.patch -Patch131: mem-zones.patch -Patch132: domheap-no-dma.patch -Patch133: 32on64-per-domain-pa-bits.patch -Patch134: 32on64-fixes.patch -Patch135: 32on64-call-gates.patch -Patch136: 32on64-migrate.patch -Patch137: emul-privop-lock.patch -Patch138: hide-asm-labels.patch -Patch139: bug.patch -Patch140: x86-mm-simplify.patch -Patch141: vgacon-50-lines.patch -Patch142: vgacon-keep.patch -Patch143: x86-ptwr_emulate.patch -Patch144: suppress-rdtscp.patch -Patch145: pae-guest-linear-pgtable.patch -Patch146: x86-nmi-inject.patch -## Gerd's patches begin here -# fix cross-build for tools -Patch150: cross-build-fix.diff -# network script fixup -Patch151: bridge-hostonly.diff -# foreign arch headers -Patch152: xen-generate-foreign-headers.diff -# common ELF parser code -Patch153: libelf-add-to-xenkernel.diff -Patch154: libelf-use-xen-dom0.diff -Patch155: libelf-symlink-to-libxc.diff -Patch156: libelf-use-hvm-build.diff -Patch157: libelf-use-readnotes.diff -Patch158: libelf-dominfo.diff -# domain builder rewrite -Patch160: tools-add-errors.diff -Patch161: tools-domain-builder-header-libxc.diff -Patch162: tools-domain-builder-core.diff -Patch163: tools-domain-builder-linux.diff -Patch164: tools-readnotes-gunzip.diff -# bimodal driver bits -Patch165: protocol-bimodal.diff -Patch166: fbback-bimodal.diff -Patch167: blktools-bimodal.diff -# libxc debugging bits -Patch168: tools-debug-oldbuilder.diff -# guest kexec, kboot -Patch170: tools-xc_kexec.diff -Patch171: tools-kboot.diff -# AMD nested page table patches -Patch200: npt_part1.patch -Patch201: npt_part2.patch -Patch202: npt-windows-bug.patch -Patch203: npt-fpu-bug.patch -# Upstream bug fixes -Patch210: microcode-xen-13079.diff -Patch211: xen-localtime.patch -Patch212: svm-update-v_tpr-on-mmio.patch -Patch213: svm_cpuid_ffxsr_13743.patch -Patch214: 13574-win2k-mouse.patch -Patch215: 13630-domctl.patch -Patch216: 13903-domctl.patch -Patch217: 13908-domctl.patch -Patch218: bugfix-246160-domctl.patch -Patch219: xen-perdomain-free.patch -# pv driver building -Patch250: pv-driver-build.patch -# Jim' Xen API patches -Patch270: 13161_xenapi.patch -Patch271: 13201_xenapi.patch -Patch272: 13226_xenapi.patch -Patch273: 13235_xenapi.patch -Patch274: 13236_xenapi.patch -Patch275: 13577_xenapi.patch -Patch276: 13585_xenapi.patch -Patch277: 13615_xenapi.patch -Patch278: 13616_xenapi.patch -Patch279: 13628_xenapi.patch -Patch280: 13655_xenapi.patch -Patch281: 13689_xenapi.patch -Patch282: 13724_xenapi.patch -Patch283: 13745_xenapi.patch -Patch284: 13747_xenapi.patch -Patch285: 13753_xenapi.patch -Patch286: 13775_xenapi.patch -Patch287: 13777_xenapi.patch -Patch288: 13778_xenapi.patch -Patch289: 13784_xenapi.patch -Patch290: 13786_xenapi.patch -Patch291: 13787_xenapi.patch -Patch292: 14022_xenapi.patch -Patch293: libxen_permissive.patch -Patch294: xend_disk_decorate_rm.patch -Patch295: xend_multiple_create.patch -Patch296: xen-ioemu-hvm-pv-support.diff -Patch297: xend-actions-after.patch +Patch25: block-losetup-retry.diff +Patch26: block-flags.diff +Patch27: xen-man-xm-bad-char.diff +Patch28: xen-hvm-default-bridge.diff +Patch29: xen-hvm-netfront.diff +Patch30: xen-hvm-default-pae.diff +Patch31: xm-test-cleanup.diff +Patch32: x86-extra-trap-info.patch +Patch33: x86_emulate.patch +Patch34: vgacon-50-lines.patch +Patch35: vgacon-keep.patch +Patch36: cross-build-fix.diff +Patch37: bridge-hostonly.diff +Patch38: xen-generate-foreign-headers.diff +Patch39: tools-xc_kexec.diff +Patch40: tools-kboot.diff +Patch41: libxen_permissive.patch +Patch42: xend_vbd_type.patch +Patch43: xend_multiple_create.patch +Patch44: xen-ioemu-hvm-pv-support.diff +Patch45: xenapi-console-protocol.patch +Patch46: xen-disable-qemu-monitor.diff +Patch47: supported_module.diff +Patch48: disable_emulated_device.diff +Patch49: balloon-early.patch # Misc unused patches / need to be re-ported: Patch300: xen-enable-hvm-debug.diff -Patch301: xen-removable.diff URL: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ Prefix: /usr BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -283,7 +171,7 @@ Authors: %package libs Summary: Xen Virtualization: Libraries Group: System/Kernel -Requires: xen >= 3.0.4_10000 +Requires: xen >= 3.0.5_14000 AutoReqProv: on %description libs @@ -332,10 +220,10 @@ Authors: %package tools Summary: Xen Virtualization: Control tools for domain 0 Group: System/Kernel -Requires: xen-libs >= 3.0.4_10000 -Requires: bridge-utils multipath-tools python python-xml +Requires: xen-libs >= 3.0.5_14000 +Requires: bridge-utils multipath-tools python python-xml pyxml %if %{?with_install}0 -Requires: python-urlgrabber +Requires: python-urlgrabber libxml2-python %endif AutoReqProv: on @@ -381,6 +269,27 @@ use Xen. +Authors: +-------- + Ian Pratt + +%package tools-domU +Summary: Xen Virtualization: Control tools for domain U +Group: System/Kernel +Conflicts: xen-tools +AutoReqProv: on + + +%description tools-domU +Xen is a virtual machine monitor for x86 that supports execution of +multiple guest operating systems with unprecedented levels of +performance and resource isolation. + +This package contains tools that allow unprivileged domains to query +the virtualized environment. + + + Authors: -------- Ian Pratt @@ -388,7 +297,7 @@ Authors: %package tools-ioemu Summary: Xen Virtualization: BIOS and device emulation for unmodified guests Group: System/Kernel -Requires: xen-tools >= 3.0.4_10000 +Requires: xen-tools >= 3.0.5_14000 AutoReqProv: on %description tools-ioemu @@ -606,8 +515,8 @@ cd .. %patch9 -p1 %patch10 -p1 %patch11 -p1 -%patch12 -p1 -%patch13 -p1 +#%patch12 -p1 # re-port +#%patch13 -p1 # po files are misnamed upstream %patch14 -p1 %patch15 -p1 %patch16 -p1 @@ -619,123 +528,31 @@ cd .. %patch22 -p1 %patch23 -p1 %patch24 -p1 +%patch25 -p1 %patch26 -p1 %patch27 -p1 +%patch28 -p1 %patch29 -p1 %patch30 -p1 %patch31 -p1 %patch32 -p1 -%patch33 -p1 +#%patch33 -p1 # check if upstream %patch34 -p1 -#%patch35 -p1 +%patch35 -p1 %patch36 -p1 %patch37 -p1 -%patch100 -p1 -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -%patch105 -p1 -%patch106 -p1 -%patch107 -p1 -%patch108 -p1 -%patch109 -p1 -%patch110 -p1 -%patch111 -p1 -%patch112 -p1 -%patch113 -p1 -%patch114 -p1 -%patch115 -p1 -%patch116 -p1 -%patch117 -p1 -%patch118 -p1 -%patch119 -p1 -%patch120 -p1 -%patch121 -p1 -%patch122 -p1 -%patch123 -p1 -%patch124 -p1 -%patch125 -p1 -%patch130 -p1 -%patch131 -p1 -%patch132 -p1 -%patch133 -p1 -%patch134 -p1 -%patch135 -p1 -%patch136 -p1 -%patch137 -p1 -%patch138 -p1 -%patch139 -p1 -%patch140 -p1 -%patch141 -p1 -%patch142 -p1 -%patch143 -p1 -%patch144 -p1 -%patch145 -p1 -%patch146 -p1 -%patch150 -p1 -%patch151 -p1 -%patch152 -p1 -%patch153 -p1 -%patch154 -p1 -%patch155 -p1 -%patch156 -p1 -%patch157 -p1 -%patch158 -p1 -%patch160 -p1 -%patch161 -p1 -%patch162 -p1 -%patch163 -p1 -%patch164 -p1 -%patch165 -p1 -%patch166 -p1 -%patch167 -p1 -%patch168 -p1 -%patch170 -p1 -%patch171 -p1 -%patch200 -p1 -%patch201 -p1 -%patch202 -p1 -%patch203 -p1 -%patch210 -p1 -%patch211 -p1 -%patch212 -p1 -%patch213 -p1 -%patch214 -p1 -%patch215 -p1 -%patch216 -p1 -%patch217 -p1 -%patch218 -p1 -%patch219 -p1 -%patch250 -p1 -%patch270 -p1 -%patch271 -p1 -%patch272 -p1 -%patch273 -p1 -%patch274 -p1 -%patch275 -p1 -%patch276 -p1 -%patch277 -p1 -%patch278 -p1 -%patch279 -p1 -%patch280 -p1 -%patch281 -p1 -%patch282 -p1 -%patch283 -p1 -%patch284 -p1 -%patch285 -p1 -%patch286 -p1 -%patch287 -p1 -%patch288 -p1 -%patch289 -p1 -%patch290 -p1 -%patch291 -p1 -%patch292 -p1 -%patch293 -p1 -%patch294 -p1 -%patch295 -p1 -%patch296 -p1 -%patch297 -p1 +%patch38 -p1 +%patch39 -p1 +%patch40 -p1 +%patch41 -p1 +%patch42 -p1 +#%patch43 -p1 # check if bug still exists in 3.0.5 +#%patch44 -p1 # re-port +%patch45 -p1 +%patch46 -p1 +%patch47 -p1 +%patch48 -p1 +%patch49 -p1 XEN_EXTRAVERSION=%version-%release XEN_EXTRAVERSION=${XEN_EXTRAVERSION#%{xvers}} sed -i "s/XEN_EXTRAVERSION[ ]*.=.*\$/XEN_EXTRAVERSION = $XEN_EXTRAVERSION/" xen/Makefile @@ -803,13 +620,8 @@ export RPM_OPT_FLAGS make -C xen/include/public/foreign # tools export XEN_PYTHON_NATIVE_INSTALL=1 -#export PYTHONOPTIMIZE=1 make -C tools install \ DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} -%if %{?with_install}0 -ln -s /usr/bin/vm-install $RPM_BUILD_ROOT/usr/sbin/xen-vm-install -%find_lang xen-vm-install -%endif make -C tools/misc/serial-split install \ DESTDIR=$RPM_BUILD_ROOT MANDIR=%{_mandir} %ifarch x86_64 @@ -849,10 +661,11 @@ mkdir -p $RPM_BUILD_ROOT/etc/xen/{vm,examples} mv $RPM_BUILD_ROOT/etc/xen/xmexample* $RPM_BUILD_ROOT/etc/xen/examples rm $RPM_BUILD_ROOT/etc/xen/examples/*nbd install -m644 %SOURCE9 %SOURCE11 %SOURCE13 $RPM_BUILD_ROOT/etc/xen/examples/ -# sample scripts +install -m644 %SOURCE15 $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.xen +# scripts install -m755 %SOURCE4 %SOURCE14 $RPM_BUILD_ROOT/%{_defaultdocdir}/xen/ rm $RPM_BUILD_ROOT/etc/xen/scripts/block-*nbd -install -m755 %SOURCE10 %SOURCE12 $RPM_BUILD_ROOT/etc/xen/scripts/ +install -m755 %SOURCE10 %SOURCE12 %SOURCE16 $RPM_BUILD_ROOT/etc/xen/scripts/ # logrotate install -m644 -D %SOURCE7 $RPM_BUILD_ROOT/etc/logrotate.d/xend # directories @@ -873,8 +686,11 @@ ln -s /var/lib/xen/images $RPM_BUILD_ROOT/etc/xen/images install -m755 %SOURCE8 $RPM_BUILD_ROOT/usr/lib/xen/boot/ # udev support mv $RPM_BUILD_ROOT/etc/udev/rules.d/xen-backend.rules $RPM_BUILD_ROOT/etc/udev/rules.d/40-xen.rules +%if %{?with_install}0 +%find_lang xen-vm-install xen.lang +%endif +#%find_lang xen-xm xen.lang # po files are misnamed upstream # Clean up unpackaged files -rm $RPM_BUILD_ROOT/usr/bin/xc_shadow rm $RPM_BUILD_ROOT/usr/sbin/netfix rm -rf $RPM_BUILD_ROOT/usr/share/doc/qemu/ rm $RPM_BUILD_ROOT/%{_mandir}/man1/qemu.* @@ -915,15 +731,11 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %{_libdir}/fs/ %{_libdir}/libfsimage* %{_libdir}/libxen*.so.* -%if %{?with_install}0 -%files tools -f ../xen-vm-install.lang -%else - -%files tools -%endif +%files tools -f ../xen.lang %defattr(-,root,root) /usr/bin/lomount +/usr/bin/xen-detect /usr/bin/xencons /usr/bin/xenstore* /usr/bin/xentrace* @@ -938,6 +750,7 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info /usr/sbin/xm %if %{?with_install}0 /usr/bin/vm-install* +%{_datadir}/xen/*.dtd %{_datadir}/xen/install %dir /var/lib/xen/vm-install %dir %{_datadir}/applications/YaST2 @@ -974,7 +787,7 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %config /etc/init.d/xendomains %config /etc/init.d/xend %config /etc/logrotate.d/xend -/var/adm/fillup-templates/sysconfig.xendomains +/var/adm/fillup-templates/* %dir %attr(700,root,root) /etc/xen %config /etc/xen/* %dir /etc/udev @@ -992,6 +805,10 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %pysite/xen/* /usr/lib/xen/boot/domUloader.py +%files tools-domU +%defattr(-,root,root) +/bin/xenstore-* + %files tools-ioemu %defattr(-,root,root) %dir %{_datadir}/xen @@ -1038,8 +855,8 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %{_defaultdocdir}/xen/ps/* %clean -#test ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" && rm -rf $RPM_BUILD_ROOT -#rm -rf $RPM_BUILD_DIR/%xen_build_dir +test ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" && rm -rf $RPM_BUILD_ROOT +rm -rf $RPM_BUILD_DIR/%xen_build_dir %post tools %{fillup_and_insserv -y -f xend} @@ -1053,8 +870,96 @@ rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info %{insserv_cleanup} %changelog -* Sat Apr 21 2007 - aj@suse.de -- Use texlive for openSUSE 10.3. +* Wed Apr 25 2007 - ccoffing@novell.com +- Update to xen-3.0.5-testing rc3 (changeset 14934). +- Switch BuildRequires to texlive. +* Fri Apr 20 2007 - ccoffing@novell.com +- Updated README. (#250705) +- Fix vm-install's detection of PV RHEL4/5 kernels. (#260983) +* Thu Apr 19 2007 - ccoffing@novell.com +- Place xenstore-* tools in new xen-tools-domU package, to be used + by suse_register. (#249157) +* Tue Apr 17 2007 - ccoffing@novell.com +- Update translations. +* Thu Apr 12 2007 - ccoffing@novell.com +- Combine two xenstore reads into one transaction, which causes + xenstored to not thrash so badly, and makes virt-manager more + responsive and less likely to time out or lock up. Partial fix + for #237406. +- If disk is read-only, pass -r to losetup. (#264158) +* Thu Apr 05 2007 - ccoffing@novell.com +- Update vm-install: + + #260510: do not delete xml settings file + + #260579: write correct vif line for PV NIC in FV VM + + #261288: re-enable add disk buttons after deleting a disk + + #192272, #222765, #250618: Update OS list and their defaults +* Tue Apr 03 2007 - ccoffing@novell.com +- Could not do simultaneous installs via virt-manager. (#259917) +* Mon Apr 02 2007 - jfehlig@novell.com +- Fix improper handling of guest kernel arguments in domUloader. + Bug #259810 +* Mon Apr 02 2007 - ccoffing@novell.com +- Update vm-install: + + #259420: refresh available memory more often + + #259972: cannot enter autoyast url +* Mon Apr 02 2007 - ccoffing@novell.com +- Update translations for RC2. +* Fri Mar 30 2007 - ccoffing@novell.com +- Fix "cannot allocate memory" when starting VMs. (#229849, 258743) +* Thu Mar 29 2007 - ccoffing@novell.com +- Fix quoting of args for child processes during VM install. + (#258376) +- Fix retry logic in block hotplug script. (#257925) +* Wed Mar 28 2007 - ccoffing@novell.com +- Updated vm-install's icon name. +- Updated translations. +* Fri Mar 23 2007 - ccoffing@novell.com +- Disable aspects of qemu's console that can affect domain 0. + (#256135) +- Fix xmclone.sh to work with managed domains. (#253988) +- Update to xen-unstable changeset 14535. +* Mon Mar 19 2007 - ccoffing@novell.com +- Update to xen-unstable changeset 14444. +- Include Ron Terry's network-multi_bridge +* Fri Mar 09 2007 - jfehlig@novell.com +- Added lame patch to handle showing suspended state via Xen API. + The patch only affects Xen API and is thus low risk. + Bug #237859 +* Fri Mar 09 2007 - carnold@novell.com +- Added AMD support for Vista 64 installation and boot. +* Fri Mar 09 2007 - ccoffing@novell.com +- Make vm-install support NFS for SUSE (#241251). +* Fri Mar 09 2007 - jfehlig@novell.com +- Fixed bug #250522 + + Upstream c/s 13557 stores model attribute of vif in xenstore. +* Thu Mar 08 2007 - ccoffing@novell.com +- Update vm-install: + + Better description on "Virtual Disk" drop-down (not "xvda") + + Proper separation of recording options versus calculating + defaults; fixes corner cases + + #247849, #253013, 253009: Multiple fixes related to how disks + are defined, centered around bug #247849 (handle partitioned + PV installation disk) + + #252437: Allow virtual CDROM to be added (via ISO) even if + physical CDROM doesn't exist +* Wed Mar 07 2007 - jfehlig@novell.com +- Fixed bug #252396 + + Added upstream c/s 14021. Applies to Xen API c-bindings - + low risk. + + Added local patch to correctly set Xen API Console.protocol + property +* Wed Mar 07 2007 - jfehlig@novell.com +- Added upstream patch that fixes save/restore on 32pae guests. + Upstream c/s 14150. Bug #237859 +* Tue Mar 06 2007 - carnold@novell.com +- Remove a debug message which is spamming the logs during live + migration. +* Mon Mar 05 2007 - jfehlig@novell.com +- Fixed handling of vbd type in Xen API <-> sexpr integration. + Bug #250351 + + Updated an existing patch (xend_disk_decorate_rm.patch) and + then renamed patch to xend_vbd_type.patch to better reflect + purpose of patch. * Mon Mar 05 2007 - ccoffing@novell.com - Default apic=0 for SLES 8 and 9, for performance. (#228133) * Fri Mar 02 2007 - carnold@novell.com diff --git a/xenapi-console-protocol.patch b/xenapi-console-protocol.patch new file mode 100644 index 0000000..72a419c --- /dev/null +++ b/xenapi-console-protocol.patch @@ -0,0 +1,19 @@ +Index: xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +=================================================================== +--- xen-3.0.5-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-3.0.5-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -2325,6 +2325,14 @@ class XendDomainInfo: + if not config.has_key('backend'): + config['backend'] = "00000000-0000-0000-0000-000000000000" + ++ if dev_class == 'console': ++ if not config.has_key('protocol'): ++ con_type = config.get('type', '') ++ if con_type == 'vnc': ++ config['protocol'] = 'rfb' ++ elif con_type == 'sdl': ++ config['protocol'] = 'rdp' ++ + return config + + def get_dev_property(self, dev_class, dev_uuid, field): diff --git a/xend-actions-after.patch b/xend-actions-after.patch deleted file mode 100644 index 7f8da79..0000000 --- a/xend-actions-after.patch +++ /dev/null @@ -1,44 +0,0 @@ -# HG changeset patch -# User Jim Fehlig -# Date 1172864588 25200 -# Node ID 9e87f7af7f21182be5080cac0e4715053529a797 -# Parent 3ac19fda0bc256bac20a4decf7e13bb086162220 -VM.actions_after_[shutdown|reboot|suspend|crash] were not set properly in VM record returned via Xen API. -This patch fixes typos in key name for these fields. - -Signed-off-by: Jim Fehlig - -diff -r 3ac19fda0bc2 -r 9e87f7af7f21 tools/python/xen/xend/XendDomainInfo.py ---- a/tools/python/xen/xend/XendDomainInfo.py Fri Mar 02 12:11:52 2007 +0000 -+++ b/tools/python/xen/xend/XendDomainInfo.py Fri Mar 02 12:43:08 2007 -0700 -@@ -2090,26 +2090,26 @@ class XendDomainInfo: - return self.info.get('tools_version', {}) - - def get_on_shutdown(self): -- after_shutdown = self.info.get('action_after_shutdown') -+ after_shutdown = self.info.get('actions_after_shutdown') - if not after_shutdown or after_shutdown not in XEN_API_ON_NORMAL_EXIT: - return XEN_API_ON_NORMAL_EXIT[-1] - return after_shutdown - - def get_on_reboot(self): -- after_reboot = self.info.get('action_after_reboot') -+ after_reboot = self.info.get('actions_after_reboot') - if not after_reboot or after_reboot not in XEN_API_ON_NORMAL_EXIT: - return XEN_API_ON_NORMAL_EXIT[-1] - return after_reboot - - def get_on_suspend(self): - # TODO: not supported -- after_suspend = self.info.get('action_after_suspend') -+ after_suspend = self.info.get('actions_after_suspend') - if not after_suspend or after_suspend not in XEN_API_ON_NORMAL_EXIT: - return XEN_API_ON_NORMAL_EXIT[-1] - return after_suspend - - def get_on_crash(self): -- after_crash = self.info.get('action_after_crash') -+ after_crash = self.info.get('actions_after_crash') - if not after_crash or after_crash not in XEN_API_ON_CRASH_BEHAVIOUR: - return XEN_API_ON_CRASH_BEHAVIOUR[0] - return after_crash diff --git a/xend-config-ramdisk.patch b/xend-config-ramdisk.patch deleted file mode 100644 index a06945b..0000000 --- a/xend-config-ramdisk.patch +++ /dev/null @@ -1,21 +0,0 @@ -# HG changeset patch -# User jfehlig@jfehlig2.provo.novell.com -# Date 1166572407 25200 -# Node ID d7fd9bc007cd6d4b704a28e24883d63469d30b28 -# Parent 057f7c4dbed1c75a3fbe446d346cee04cff31497 -Recent changes to the grub/cmdline definition in XenAPI introduced PV_bootloader, PV_kernel, PV_ramdisk, etc. This patch fixes one of the kernel_initrc -> PV_ramdisk conversions that was missed in XendConfig.py. - -Signed-off-by: Jim Fehlig - -diff -r 057f7c4dbed1 -r d7fd9bc007cd tools/python/xen/xend/XendConfig.py ---- a/tools/python/xen/xend/XendConfig.py Tue Dec 19 12:00:11 2006 +0000 -+++ b/tools/python/xen/xend/XendConfig.py Tue Dec 19 16:53:27 2006 -0700 -@@ -139,7 +139,7 @@ XENAPI_CFG_TYPES = { - 'tpm_backend': int, - 'PV_bootloader': str, - 'PV_kernel': str, -- 'PV_initrd': str, -+ 'PV_ramdisk': str, - 'PV_args': str, - 'PV_bootloader_args': str, - 'HVM_boot': str, diff --git a/xend-config.diff b/xend-config.diff index 1b7aaed..c180b65 100644 --- a/xend-config.diff +++ b/xend-config.diff @@ -1,7 +1,7 @@ -Index: xen-3.0.4-testing/tools/examples/init.d/sysconfig.xendomains +Index: xen-unstable/tools/examples/init.d/sysconfig.xendomains =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/init.d/sysconfig.xendomains -+++ xen-3.0.4-testing/tools/examples/init.d/sysconfig.xendomains +--- xen-unstable.orig/tools/examples/init.d/sysconfig.xendomains ++++ xen-unstable/tools/examples/init.d/sysconfig.xendomains @@ -98,7 +98,6 @@ XENDOMAINS_RESTORE=true # Note that the script tries to be clever if both RESTORE and AUTO are # set: It will first restore saved domains and then only start domains @@ -21,13 +21,13 @@ Index: xen-3.0.4-testing/tools/examples/init.d/sysconfig.xendomains ## Type: integer ## Default: 300 -Index: xen-3.0.4-testing/tools/examples/xend-config.sxp +Index: xen-unstable/tools/examples/xend-config.sxp =================================================================== ---- xen-3.0.4-testing.orig/tools/examples/xend-config.sxp -+++ xen-3.0.4-testing/tools/examples/xend-config.sxp -@@ -46,16 +46,19 @@ - # (xen-api-server ((9363 pam '^localhost$ example\\.com$') - # (unix none))) +--- xen-unstable.orig/tools/examples/xend-config.sxp ++++ xen-unstable/tools/examples/xend-config.sxp +@@ -51,16 +51,19 @@ + # + # (9367 pam '' /etc/xen/xen-api.key /etc/xen/xen-api.crt) # -# Default: -# (xen-api-server ((unix))) diff --git a/xend-xmlrpc-large-ints.diff b/xend-xmlrpc-large-ints.diff deleted file mode 100644 index 314712b..0000000 --- a/xend-xmlrpc-large-ints.diff +++ /dev/null @@ -1,129 +0,0 @@ -# HG changeset patch -# User anthony@rhesis.austin.ibm.com -# Node ID 8dc8c7bdcbac0e56c606fe5c9205b4d9742e60d7 -# Parent 8b5a752167a17785b998a080a5c1ce1991b9379b -In some cases, Xend can return a very large integer. This so far only happens -on 64bit systems where the sizeof the Python integer is > 32bit. Presumably, -this is occuring because of the fact that we return PFNs as part of the -domain info so on a system with greater than 2G of memory we get into the -invalid integer range. - -For now, the work-around is to overload the xmlrpclib Marshaller and instead -of throwing an exception when we get out-of-range integers, we marshal them -as strings. In the future, we can handle this in a more elegant way by -introducing higher-level types. We also won't have to deal with things like -PFNs once we clean up the XML-RPC interface. - -Signed-off-by: Anthony Liguori - -Index: xen-3.0.4-testing/tools/python/xen/util/xmlrpclib2.py -=================================================================== ---- xen-3.0.4-testing.orig/tools/python/xen/util/xmlrpclib2.py -+++ xen-3.0.4-testing/tools/python/xen/util/xmlrpclib2.py -@@ -29,6 +29,7 @@ from httplib import HTTPConnection, HTTP - from SimpleXMLRPCServer import SimpleXMLRPCServer, SimpleXMLRPCRequestHandler - import SocketServer - import xmlrpclib, socket, os, stat -+from xmlrpclib import Fault - - import mkdir - -@@ -68,6 +69,9 @@ def stringify(value): - # - # It assumes that the RPC handler is /RPC2. This probably needs to be improved - -+MAXINT = 2L**31-1 -+MININT = -2L**31 -+ - # We're forced to subclass the RequestHandler class so that we can work around - # some bugs in Keep-Alive handling and also enabled it by default - class XMLRPCRequestHandler(SimpleXMLRPCRequestHandler): -@@ -157,6 +161,67 @@ class ServerProxy(xmlrpclib.ServerProxy) - return conv_string(response) - - -+class Marshaller(xmlrpclib.Marshaller): -+ def __init__(self, encoding=None, allow_none=0): -+ xmlrpclib.Marshaller.__init__(self, encoding, allow_none) -+ self.dispatch[IntType] = Marshaller.dump_int -+ self.dispatch[LongType] = Marshaller.dump_long -+ -+ def dump_int(self, value, write): -+ if value > MAXINT or value < MININT: -+ self.dispatch[StringType](self, str(value), write) -+ else: -+ xmlrpclib.Marshaller.dump_int(self, value, write) -+ -+ def dump_long(self, value, write): -+ if value > MAXINT or value < MININT: -+ self.dispatch[StringType](self, str(value), write) -+ else: -+ xmlrpclib.Marshaller.dump_long(self, value, write) -+ -+def dumps(params, methodname=None, methodresponse=None, encoding=None, -+ allow_none=0): -+ assert isinstance(params, TupleType) or isinstance(params, Fault),\ -+ "argument must be tuple or Fault instance" -+ -+ if isinstance(params, Fault): -+ methodresponse = 1 -+ elif methodresponse and isinstance(params, TupleType): -+ assert len(params) == 1, "response tuple must be a singleton" -+ -+ if not encoding: -+ encoding = "utf-8" -+ -+ m = Marshaller(encoding, allow_none) -+ -+ data = m.dumps(params) -+ -+ if encoding != "utf-8": -+ xmlheader = "\n" % str(encoding) -+ else: -+ xmlheader = "\n" # utf-8 is default -+ -+ if methodname: -+ if not isinstance(methodname, StringType): -+ methodname = methodname.encode(encoding) -+ data = ( -+ xmlheader, -+ "\n" -+ "", methodname, "\n", -+ data, -+ "\n" -+ ) -+ elif methodresponse: -+ data = ( -+ xmlheader, -+ "\n", -+ data, -+ "\n" -+ ) -+ else: -+ return data -+ return string.join(data, "") -+ - # This is a base XML-RPC server for TCP. It sets allow_reuse_address to - # true, and has an improved marshaller that logs and serializes exceptions. - -@@ -208,15 +273,15 @@ class TCPXMLRPCServer(SocketServer.Threa - response = repr(response)[1:-1] - - response = (response,) -- response = xmlrpclib.dumps(response, -- methodresponse=1, -- allow_none=1) -+ response = dumps(response, -+ methodresponse=1, -+ allow_none=1) - except xmlrpclib.Fault, fault: -- response = xmlrpclib.dumps(fault) -+ response = dumps(fault) - except Exception, exn: - import xen.xend.XendClient - log.exception(exn) -- response = xmlrpclib.dumps( -+ response = dumps( - xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn))) - - return response diff --git a/xend_disk_decorate_rm.patch b/xend_disk_decorate_rm.patch deleted file mode 100644 index 04618e1..0000000 --- a/xend_disk_decorate_rm.patch +++ /dev/null @@ -1,41 +0,0 @@ -diff -ru xen-3.0.4-testing-orig/tools/python/xen/xend/server/blkif.py xen-3.0.4-testing/tools/python/xen/xend/server/blkif.py ---- xen-3.0.4-testing-orig/tools/python/xen/xend/server/blkif.py 2007-02-16 11:16:04.000000000 -0700 -+++ xen-3.0.4-testing/tools/python/xen/xend/server/blkif.py 2007-02-16 11:22:25.000000000 -0700 -@@ -120,10 +120,10 @@ - 'uuid') - dev, typ, params, mode, uuid = devinfo - -+ dev_type = self.readFrontend(devid, 'device-type') -+ if dev_type: -+ config['type'] = dev_type - if dev: -- dev_type = self.readFrontend(devid, 'device-type') -- if dev_type: -- dev += ':' + dev_type - config['dev'] = dev - if typ and params: - config['uname'] = typ +':' + params -diff -ru xen-3.0.4-testing-orig/tools/python/xen/xend/XendConfig.py xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py ---- xen-3.0.4-testing-orig/tools/python/xen/xend/XendConfig.py 2007-02-16 11:16:06.000000000 -0700 -+++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py 2007-02-16 11:25:03.000000000 -0700 -@@ -1036,12 +1036,14 @@ - target['vif_refs'].append(dev_uuid) - - elif dev_type in ('vbd', 'tap'): -- if dev_type == 'vbd': -- dev_info['uname'] = cfg_xenapi.get('image', '') -- dev_info['dev'] = '%s:disk' % cfg_xenapi.get('device') -- elif dev_type == 'tap': -- dev_info['uname'] = 'tap:qcow:%s' % cfg_xenapi.get('image') -- dev_info['dev'] = '%s:disk' % cfg_xenapi.get('device') -+ dev_info['type'] = cfg_xenapi.get('type', 'Disk') -+ if dev_info['type'] == 'CD': -+ dev_info['dev'] = '%s:%s' % (cfg_xenapi.get('device'), -+ 'cdrom') -+ else: -+ dev_info['dev'] = cfg_xenapi.get('device') -+ -+ dev_info['uname'] = cfg_xenapi.get('image', '') - - dev_info['driver'] = cfg_xenapi.get('driver') - dev_info['VDI'] = cfg_xenapi.get('VDI', '') diff --git a/xend_vbd_type.patch b/xend_vbd_type.patch new file mode 100644 index 0000000..17077c3 --- /dev/null +++ b/xend_vbd_type.patch @@ -0,0 +1,12 @@ +Index: xen-unstable/tools/python/xen/xend/server/blkif.py +=================================================================== +--- xen-unstable.orig/tools/python/xen/xend/server/blkif.py ++++ xen-unstable/tools/python/xen/xend/server/blkif.py +@@ -122,6 +122,7 @@ class BlkifController(DevController): + dev_type = self.readFrontend(devid, 'device-type') + if dev_type: + dev += ':' + dev_type ++ config['type'] = dev_type + config['dev'] = dev + if typ and params: + config['uname'] = typ +':' + params diff --git a/xm-test-cleanup.diff b/xm-test-cleanup.diff index 0331d3b..8b4e003 100644 --- a/xm-test-cleanup.diff +++ b/xm-test-cleanup.diff @@ -1,7 +1,7 @@ -Index: xen-3.0.4-testing/tools/xm-test/tests/save/01_save_basic_pos.py +Index: xen-unstable/tools/xm-test/tests/save/01_save_basic_pos.py =================================================================== ---- xen-3.0.4-testing.orig/tools/xm-test/tests/save/01_save_basic_pos.py -+++ xen-3.0.4-testing/tools/xm-test/tests/save/01_save_basic_pos.py +--- xen-unstable.orig/tools/xm-test/tests/save/01_save_basic_pos.py ++++ xen-unstable/tools/xm-test/tests/save/01_save_basic_pos.py @@ -35,3 +35,9 @@ if s != 0: # Make sure it's gone if isDomainRunning(domain.getName()): diff --git a/xmclone.sh b/xmclone.sh index 83b2530..3124f75 100644 --- a/xmclone.sh +++ b/xmclone.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash ################################################################################ # xmclone by Bob Brandt # # based on XenClone by Glen Davis # @@ -8,9 +8,9 @@ ################################################################################ # Defaults # # # -VERSION=0.3 +VERSION=0.3.1 XEN_CONFIGS=/etc/xen/vm/ -XEN_BASE=/xen/ +XEN_BASE=/var/lib/xen/images/ SOURCE= DESTINATION= DUPLICATE=0 @@ -70,17 +70,7 @@ version() # Find/Replace text within a file # replace() { - SearchText=$1 - ReplaceText=$2 - File=$3 - if sed "s/$SearchText/$ReplaceText/g" "$File" > "$File.temporary" && sleep 1 - then - if mv -f "$File.temporary" "$File" && sleep 1 - then - return 0 - fi - fi - return 1 + sed -i -e "s/$1/$2/g" "$3" } ################################################################################ @@ -90,7 +80,7 @@ replace() # # if [ `id -u` -ne 0 ]; then echo -e "You must be root to run this script!\n" - exit 1 + exit 1 fi ################################################################################ @@ -101,11 +91,11 @@ fi # Must look for double -- arguments before getopts if [ "$1" = "--version" ]; then version - exit 0; + exit 0 fi if [ "$1" = "--help" ]; then usage - exit 0; + exit 0 fi while getopts ":hvc:b:dn:i:m:" opt; do case $opt in @@ -157,7 +147,7 @@ fi if [ "$XEN_BASE" != "" ]; then XEN_BASE="${XEN_BASE%/}/" fi -# Verify the validity of each agrument ask the user if there is a problem +# Verify the validity of each argument ask the user if there is a problem while [ ! -d "$XEN_CONFIGS" ]; do echo -e "\nThe $XEN_CONFIGS directory does not exist. Please enter a valid directory." read -p "XEN Configuration Directory? " XEN_CONFIGS @@ -304,7 +294,7 @@ if [ "$DUPLICATE" == "0" ]; then fi fi - while [ "$MAC" != "" ] && [ "${MAC/[0123456789abcdefABCDEF][0123456789abcdefABCDEF]:[0123456789abcdefABCDEF][0123456789abcdefABCDEF]:[0123456789abcdefABCDEF][0123456789abcdefABCDEF]:[0123456789abcdefABCDEF][0123456789abcdefABCDEF]:[0123456789abcdefABCDEF][0123456789abcdefABCDEF]:[0123456789abcdefABCDEF][0123456789abcdefABCDEF]/ok}" != "ok" ]; do + while [ "$MAC" != "" ] && [ "${MAC/[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]/ok}" != "ok" ]; do echo -e "\nThe MAC Address you specified is invalid. If you wish, enter a new one now." read -p "New MAC Address? (format 01:23:45:67:89:AB) " MAC if [ "$MAC" == "" ]; then @@ -322,8 +312,8 @@ fi ################################################################################ # Make sure that the source VM is not running # # # -xmid=`xm list | grep $SOURCE | cut -c34-36` -if [ "$xmid" != "" ]; then +xmid=`xm domid "$SOURCE" 2>/dev/null` +if [ $? -eq 0 ] && [ -n "$xmid" ] && [ -z "${xmid//[[:digit:]]/}" ] ; then echo -e "domU $SOURCE is currently running on Xen, please shutdown before cloning." echo -e "The command \"xm shutdown $xmid -w\" will shutdown the domU" exit 1 @@ -349,7 +339,7 @@ fi # Edit newly copied configuration file # # # echo -e "Editing config file ($DESTCONFIG), correcting the new domU Name." -if ! replace $SOURCE $DESTINATION $DESTCONFIG +if ! replace "$SOURCE" "$DESTINATION" "$DESTCONFIG" then echo -e "Unable to change the domU name in $DESTCONFIG from $SOURCE to $DESTINATION" exit 1 @@ -366,7 +356,7 @@ if [ "$DUPLICATE" == "0" ] && [ "$MAC" != "" ]; then # remove the mac= from the beginning oldMAC=${oldMAC#mac=*} - if ! replace $oldMAC $MAC $DESTCONFIG + if ! replace "$oldMAC" "$MAC" "$DESTCONFIG" then echo -e "Unable to change the MAC address in $DESTCONFIG from ($oldMAC) to ($MAC)" exit 1 @@ -388,7 +378,7 @@ then fi echo -e "Copying complete image. (This may take a few minutes!)" -if ! cp -fv --sparse=never $SOURCEXEN* $DESTXEN +if ! cp -fv $SOURCEXEN* $DESTXEN then echo -e "Unable to copy the images from $SOURCEXEN to $DESTXEN" exit 1 @@ -536,7 +526,7 @@ if [ "$DUPLICATE" == "0" ] && [ "$MAC" != "" ]; then oldHOSTNAME=`cat "$tmpdir/etc/HOSTNAME" | cut -f1 -d\.` sleep 1 - if ! replace $oldHOSTNAME $HOSTNAME HOSTNAME + if ! replace "$oldHOSTNAME" "$HOSTNAME" "HOSTNAME" then echo -e "Unable to change the HOSTNAME from $oldHOSTNAME to $HOSTNAME" exit 1 diff --git a/xxx_heap_pages-static.patch b/xxx_heap_pages-static.patch deleted file mode 100644 index 1a60c9b..0000000 --- a/xxx_heap_pages-static.patch +++ /dev/null @@ -1,244 +0,0 @@ -Index: xen-3.0.4-testing/xen/common/page_alloc.c -=================================================================== ---- xen-3.0.4-testing.orig/xen/common/page_alloc.c -+++ xen-3.0.4-testing/xen/common/page_alloc.c -@@ -306,78 +306,11 @@ static unsigned long avail[NR_ZONES][MAX - - static DEFINE_SPINLOCK(heap_lock); - --void end_boot_allocator(void) --{ -- unsigned long i, j, k; -- int curr_free, next_free; -- -- memset(avail, 0, sizeof(avail)); -- -- for ( i = 0; i < NR_ZONES; i++ ) -- for ( j = 0; j < MAX_NUMNODES; j++ ) -- for ( k = 0; k <= MAX_ORDER; k++ ) -- INIT_LIST_HEAD(&heap[i][j][k]); -- -- /* Pages that are free now go to the domain sub-allocator. */ -- if ( (curr_free = next_free = !allocated_in_map(first_valid_mfn)) ) -- map_alloc(first_valid_mfn, 1); -- for ( i = first_valid_mfn; i < max_page; i++ ) -- { -- curr_free = next_free; -- next_free = !allocated_in_map(i+1); -- if ( next_free ) -- map_alloc(i+1, 1); /* prevent merging in free_heap_pages() */ -- if ( curr_free ) -- init_heap_pages(pfn_dom_zone_type(i), mfn_to_page(i), 1); -- } -- -- printk("Domain heap initialised: DMA width %u bits\n", dma_bitsize); --} -- --/* -- * Hand the specified arbitrary page range to the specified heap zone -- * checking the node_id of the previous page. If they differ and the -- * latter is not on a MAX_ORDER boundary, then we reserve the page by -- * not freeing it to the buddy allocator. -- */ --#define MAX_ORDER_ALIGNED (1UL << (MAX_ORDER)) --void init_heap_pages( -- unsigned int zone, struct page_info *pg, unsigned long nr_pages) --{ -- unsigned int nid_curr, nid_prev; -- unsigned long i; -- -- ASSERT(zone < NR_ZONES); -- -- if ( likely(page_to_mfn(pg) != 0) ) -- nid_prev = phys_to_nid(page_to_maddr(pg-1)); -- else -- nid_prev = phys_to_nid(page_to_maddr(pg)); -- -- for ( i = 0; i < nr_pages; i++ ) -- { -- nid_curr = phys_to_nid(page_to_maddr(pg+i)); -- -- /* -- * free pages of the same node, or if they differ, but are on a -- * MAX_ORDER alignement boundary (which already get reserved) -- */ -- if ( (nid_curr == nid_prev) || (page_to_maddr(pg+i) & -- MAX_ORDER_ALIGNED) ) -- free_heap_pages(zone, pg+i, 0); -- else -- printk("Reserving non-aligned node boundary @ mfn %lu\n", -- page_to_mfn(pg+i)); -- -- nid_prev = nid_curr; -- } --} -- - /* Allocate 2^@order contiguous pages. */ --struct page_info *alloc_heap_pages(unsigned int zone, unsigned int cpu, -- unsigned int order) -+static struct page_info *alloc_heap_pages( -+ unsigned int zone, unsigned int cpu, unsigned int order) - { -- unsigned int i,j, node = cpu_to_node(cpu), num_nodes = num_online_nodes(); -+ unsigned int i, j, node = cpu_to_node(cpu), num_nodes = num_online_nodes(); - unsigned int request = (1UL << order); - struct page_info *pg; - -@@ -436,13 +369,12 @@ struct page_info *alloc_heap_pages(unsig - return pg; - } - -- - /* Free 2^@order set of pages. */ --void free_heap_pages( -+static void free_heap_pages( - unsigned int zone, struct page_info *pg, unsigned int order) - { - unsigned long mask; -- int node = phys_to_nid(page_to_maddr(pg)); -+ unsigned int node = phys_to_nid(page_to_maddr(pg)); - - ASSERT(zone < NR_ZONES); - ASSERT(order <= MAX_ORDER); -@@ -489,6 +421,87 @@ void free_heap_pages( - spin_unlock(&heap_lock); - } - -+/* -+ * Hand the specified arbitrary page range to the specified heap zone -+ * checking the node_id of the previous page. If they differ and the -+ * latter is not on a MAX_ORDER boundary, then we reserve the page by -+ * not freeing it to the buddy allocator. -+ */ -+#define MAX_ORDER_ALIGNED (1UL << (MAX_ORDER)) -+void init_heap_pages( -+ unsigned int zone, struct page_info *pg, unsigned long nr_pages) -+{ -+ unsigned int nid_curr, nid_prev; -+ unsigned long i; -+ -+ ASSERT(zone < NR_ZONES); -+ -+ if ( likely(page_to_mfn(pg) != 0) ) -+ nid_prev = phys_to_nid(page_to_maddr(pg-1)); -+ else -+ nid_prev = phys_to_nid(page_to_maddr(pg)); -+ -+ for ( i = 0; i < nr_pages; i++ ) -+ { -+ nid_curr = phys_to_nid(page_to_maddr(pg+i)); -+ -+ /* -+ * free pages of the same node, or if they differ, but are on a -+ * MAX_ORDER alignement boundary (which already get reserved) -+ */ -+ if ( (nid_curr == nid_prev) || (page_to_maddr(pg+i) & -+ MAX_ORDER_ALIGNED) ) -+ free_heap_pages(zone, pg+i, 0); -+ else -+ printk("Reserving non-aligned node boundary @ mfn %lu\n", -+ page_to_mfn(pg+i)); -+ -+ nid_prev = nid_curr; -+ } -+} -+ -+static unsigned long avail_heap_pages( -+ int zone, int node) -+{ -+ unsigned int i, j, num_nodes = num_online_nodes(); -+ unsigned long free_pages = 0; -+ -+ for (i=0; i