aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_x86.c
Commit message (Collapse)AuthorAgeFilesLines
* libxc: introduce xc_domain_get_guest_width()Dario Faggioli2013-09-131-10/+3
| | | | | | | | | | | | | | As a wrapper to XEN_DOMCTL_get_address_size, and use it wherever the call was being issued directly via do_domctl(), saving quite some line of code. Actually, the function returns the guest width in bytes, rather than directly what XEN_DOMCTL_get_address_size provides (which is a number of bits), since that is what it is useful almost everywhere. Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* libxc/x86: fix page table creation for huge guestsJan Beulich2013-09-121-8/+16
| | | | | | | | | | | The switch-over logic from one page directory to the next was wrong; it needs to be deferred until we actually reach the last page within a given region, instead of being done when the last entry of a page directory gets started with. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: check return values from mallocIan Jackson2013-06-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A sufficiently malformed input to libxc (such as a malformed input ELF or other guest-controlled data) might cause one of libxc's malloc() to fail. In this case we need to make sure we don't dereference or do pointer arithmetic on the result. Search for all occurrences of \b(m|c|re)alloc in libxc, and all functions which call them, and add appropriate error checking where missing. This includes the functions xc_dom_malloc*, which now print a message when they fail so that callers don't have to do so. The function xc_cpuid_to_str wasn't provided with a sane return value and has a pretty strange API, which now becomes a little stranger. There are no in-tree callers. This is part of the fix to a security issue, XSA-55. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> v8: Move a check in xc_exchange_page to the previous patch (ie, remove it from this patch). v7: Add a missing check for a call to alloc_str. Add arithmetic overflow check in xc_dom_malloc. Coding style fix. v6: Fix a missed call `pfn_err = calloc...' in xc_domain_restore.c. Fix a missed call `new_pfn = xc_map_foreign_range...' in xc_offline_page.c v5: This patch is new in this version of the series.
* libxc: check failure of xc_dom_*_to_ptr, xc_map_foreign_rangeIan Jackson2013-06-141-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The return values from xc_dom_*_to_ptr and xc_map_foreign_range are sometimes dereferenced, or subjected to pointer arithmetic, without checking whether the relevant function failed and returned NULL. Add an appropriate error check at every call site. This is part of the fix to a security issue, XSA-55. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> v8: Add a missing check in xc_offline_page.c:xc_exchange_page, which was in the next patch in v7 of the series. Also improve the message. I think in this particular error case it may be that the results are a broken guest, but turning this from a possible host tools crash into a guest problem seems to solve the potential security problem. v7: Simplify an error DOMPRINTF to not use "load ? : ". Make DOMPRINTF allocation error messages consistent. Do not set elf->dest_pages in xc_dom_load_elf_kernel if xc_dom_seg_to_ptr_pages fails. v5: This patch is new in this version of the series.
* libxl: write IO ABI for disk frontendsWei Liu2013-04-261-0/+34
| | | | | | | | | | | | | | | This is a patch to forward-port a Xend behaviour. Xend writes IO ABI used for all frontends. Blkfront before 2.6.26 relies on this behaviour otherwise guest cannot boot when running in 32-on-64 mode. Blkfront after 2.6.26 writes that node itself, in which case it's just an overwrite to an existing node which should be OK. In fact Xend writes the ABI for all frontends including console and vif. But nowadays only old disk frontends rely on that behaviour so that we only write the ABI for disk frontends in libxl, minimizing the impact. Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com>
* xc: use XENMEM_claim_pages hypercall during guest creation.Dan Magenheimer2013-04-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | We add an extra parameter to the structures passed to the PV routine (arch_setup_meminit) and HVM routine (setup_guest) that determines whether the claim hypercall is to be done. The contents of the 'claim_enabled' is defined as an 'int' in case the hypercall expands in the future with extra flags (for example for per-NUMA allocation). For right now the proper values are: 0 to disable it or 1 to enable it. If the hypervisor does not support this function, the xc_domain_claim_pages and xc_domain_get_outstanding_pages will silently return 0 (and set errno to zero). Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> [v2: Updated per Ian's recommendations] [v3: Added support for out-of-sync hypervisor] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* Fix emacs local variable block to use correct C style variable.David Vrabel2013-02-211-1/+1
| | | | | | | The emacs variable to set the C style from a local variable block is c-file-style, not c-set-style. Signed-off-by: David Vrabel <david.vrabel@citrix.com
* libxc: fixes for the ARM platformStefano Stabellini2013-02-151-0/+5
| | | | | | | | | | | | | | | | Make xc_dom_feature_translated an arch-dependent function. alloc_magic_pages: save console and xenstore pfn's in xc_dom_image. alloc_magic_pages: set HVM_PARAM_CONSOLE_EVTCHN and HVM_PARAM_STORE_EVTCHN hvm_params using the event channels allocated by the toolstack. Call xc_dom_gnttab_hvm_seed instead of xc_dom_gnttab_seed in xc_dom_gnttab_init for autotranslated guests. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxc: drop relics of running on non-PAE 32-bit hostsJan Beulich2013-01-241-61/+5
| | | | | | | | | Additionally drop unused (and dangerous) defines and typedefs, plus a minor legibility improvement to setup_pgtables_x86_{32_pae,64}(). Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org> Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
* libxc: x86: ensure that the initial mapping fits into the guest's memoryIan Campbell2013-01-111-0/+12
| | | | | | | | | | | | | | In particular we need to check that adding 512KB of slack and rounding up to a 4MB boundary do not overflow the guest's memory allocation. Otherwise we run off the end of the p2m when building the guest's initial page tables and populate them with garbage. Wei noticed this when build tiny (2MB) mini-os domains. Reported-by: Wei Liu <Wei.Liu2@citrix.com> Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxc: add xc_domain_add_to_physmap to wrap XENMEM_add_to_physmapIan Campbell2010-10-181-13/+8
| | | | | Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: wrappers for XENMEM {increase,decrease}_reservation and populate_physmapIan Campbell2010-10-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the wrappers for these hypercalls swallow partial success and return failure to the caller. In order to use these functions more widely instead of open-coding uses of XENMEM_* and xc_memory_op add variants which return the actual hypercall result. Therefore add the following functions: xc_domain_increase_reservation xc_domain_decrease_reservation xc_domain_populate_physmap and implement the existing semantics using these new functions as xc_domain_increase_reservation_exact xc_domain_decrease_reservation_exact xc_domain_populate_physmap_exact replacing the existing xc_domain_memory_* functions. Use these new functions to replace all open coded uses of XENMEM_increase_reservation, XENMEM_decrease_reservation and XENMEM_populate_physmap. Also rename xc_domain_memory_*_pod_target to xc_domain_*_pod_target for consistency. Temporarily add a compatibility macro for xc_domain_memory_populate_physmap to allow time for qemu to catch up. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* # HG changeset patchIan Campbell2010-08-241-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | # User Ian Campbell <ian.campbell@citrix.com> # Date 1282671421 -3600 # Node ID d1dd29a470ef1b9d2c77478a123326036dfe90bb # Parent d7a4adad9c328decbd384d87b23001aea8951b86 tools/libxc, tools/libelf: Relicense under LGPL v2.1 Relicense these two libraries under LGPL v2.1 only except where individual files already included the "or later" provision. Copyright holders have been contacted by Stephen Spector and have all agreed this change. Removed tools/libxc/ia64/aclinux.h since it appeared to be unused. There is a separate, more up to date, copy in xen/include/acpi/platform/aclinux.h which does appear to be used. Clarify the license of MiniOS privcmd.h under the same terms as other tools/include/xen-sys headers. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Stephen Spector <stephen.spector@citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxc: eliminate static variables, use xentoollog; API changeKeir Fraser2010-05-281-63/+62
| | | | | | | | | | | | | | | | | | | | This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxenguest: Revert domain builder interface changes for 'superpages'Keir Fraser2009-07-201-21/+20
| | | | | | | parameter, and place the flag in a pad byte of 'struct xc_dom_image' instead. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86_64: allow more vCPU-s per guestKeir Fraser2009-06-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Since the shared info layout is fixed, guests are required to use VCPUOP_register_vcpu_info prior to booting any vCPU beyond the traditional limit of 32. MAX_VIRT_CPUS, being an implemetation detail of the hypervisor, is no longer being exposed in the public headers. The tools changes are clearly incomplete (and done only so things would build again), and the current state of the tools (using scalar variables all over the place to represent vCPU bitmaps) very likely doesn't permit booting DomU-s with more than the traditional number of vCPU-s. Testing of the extended functionality was done with Dom0 (96 vCPU-s, as well as 128 vCPU-s out of which the kernel elected - by way of a simple kernel side patch - to use only some, resulting in a sparse bitmap). ia64 changes only to make things build, and build-tested only (and the tools part only as far as the build would go without encountering unrelated problems in the blktap code). Signed-off-by: Jan Beulich <jbeulich@novell.com>
* Add support for superpages (hugepages) in PV domainKeir Fraser2009-05-261-11/+44
| | | | | | | | | | | | | | | | | | This patch adds the option "superpages" to the domain configuration file. If it is set, the domain is populated using 2M pages. This code does not support fallback to small pages. If the domain can not be created with 2M pages, the create will fail. The patch also includes support for saving and restoring domains with the superpage flag set. However, if a domain has freed small pages within its physical page array and then extended the array, the restore will fill in those freed pages. It will then attempt to allocate more than its memory limit and will fail. This is significant because apparently Linux does this during boot, thus a freshly booted Linux image can not be saved and restored successfully. Signed-off-by: Dave McCracken <dcm@mccr.org>
* x86 dom builder: Allocate domU pages in batches.Keir Fraser2009-03-191-4/+10
| | | | | | | Allows a 32-bit dom0 to create very large guests. Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* libxc: Fix gcc 4.3 build failureKeir Fraser2008-12-091-2/+4
| | | | Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
* tools: replace sprintf with snprintf where applicableKeir Fraser2008-06-121-2/+2
| | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* x86 domain builder: Propagate x86_compat return code.Keir Fraser2007-12-051-1/+3
| | | | Signed-off-by: Elizabeth Kon <eak@us.ibm.com>
* domain builder: Zero start_info struct.kfraser@localhost.localdomain2007-08-031-0/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* hvm: e820 public header cleanup.Keir Fraser2007-06-101-1/+0
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [BUILDER] Propagate the native protocol ABI for a guest out of theIan Campbell2007-05-151-0/+4
| | | | | | | | | | domain builder and in to python code. This knowledge will be useful to allow us to pre-seed the protocol field in a VBD entry in xenstore which will allow us to run older kernels in a 32on64 mixed environment. Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [BUILDER] Ensure that the L3 page table page for a PAE guest which does notIan Campbell2007-05-091-1/+82
| | | | | | support the extended-cr3 format is below the 4G boundary. Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [TOOLS] libxc: Fix x86 build.Ian Campbell2007-03-221-0/+1
| | | | Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* Merge with xen-unstable.hg.Hollis Blanchard2007-03-211-28/+6
|\ | | | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
| * x86: Add VGCF_onlien flag to vcpu_guest_context.kfraser@localhost.localdomain2007-03-121-2/+2
| | | | | | | | | | | | Change common Xen code to start all VCPUs (except idle ones) offline. Change arch code to deal with this. Signed-off-by: Keir Fraser <keir@xensource.com>
| * [BUILDER]: Initialize code segment selectors in virtual IDT to 0.Ian Campbell2007-03-081-26/+4
| | | | | | | | | | | | | | | | | | | | These should not be set until the guest kernel kernel configures an entry point otherwise the null_trap_bounce() check gets confused. This change was made to the old domain builder in 12455:3fa6635d04b9 but was lost in the transition to the new builder. Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* | [LIBXC] Allocate memory and populate p2m in arch-specific code.Hollis Blanchard2007-03-211-1/+14
| | | | | | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
* | [LIBXC] Move domain builder hooks into arch-specific files and remove ifdefs.Hollis Blanchard2007-03-211-0/+169
|/ | | | Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
* libxc: Code format cleanups.Keir Fraser2007-02-241-186/+205
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* libxc: Domain builder must align initial virtual mapping to 4MBkfraser@localhost.localdomain2007-02-021-1/+3
| | | | | | boundaries. From: Gerd Hoffmann <kraxel@suse.de> Signed-off-by: Keir Fraser <keir@xensource.com>
* libxc domain builder rewrite, core bits.Emmanuel Ackaouy2007-01-251-0/+559
Signed-off-by: Gerd Hoffmann <kraxel@suse.de> --- tools/libxc/Makefile | 14 tools/libxc/xc_dom.h | 261 +++++++++++++ tools/libxc/xc_dom_binloader.c | 294 +++++++++++++++ tools/libxc/xc_dom_boot.c | 515 +++++++++++++++++++++++++++ tools/libxc/xc_dom_core.c | 773 +++++++++++++++++++++++++++++++++++++++++ tools/libxc/xc_dom_elfloader.c | 283 +++++++++++++++ tools/libxc/xc_dom_ia64.c | 118 ++++++ tools/libxc/xc_dom_powerpc64.c | 100 +++++ tools/libxc/xc_dom_x86.c | 559 +++++++++++++++++++++++++++++ 9 files changed, 2917 insertions(+)