Commit Graph
20624 Commits
Author SHA1 Message Date
Keir Fraser feb567f210 mini-os: Fix memory leaks in xs_read() and xs_write()
xenbus_read() and xenbus_write() will allocate memory for error
message if any error occurs, this memory should be freed.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-11 09:01:15 +00:00
Keir Fraser 0404e06849 libxenlight: Disable unneeded C++ binding for libconfig
If we want to avoid that a C++ compiler becomes a requirement for a
Xen build, we should disable the (unneeded) C++ library generation for
the embedded libconfig.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
2009-12-11 09:00:40 +00:00
Keir Fraser b501c6cfa8 tools: improve NUMA guest placement when ballooning
the "guest to a single NUMA node" constrain algorithm does not work
well when we do ballooning. Ballooning and NUMA don't play together
anyway, as Dom0 and thus ballooning is not NUMA aware, I am working on
this but it will not be ready for the Xen 4.0 release window.  The
usual ballooning situation will result in an empty candidate list, as
no node has enough free memory to host the guest. In this case the
code will simply pick the first node: again and again, because all
nodes without enough memory will be ultimately penalized with the same
maxint value (regardless of the actual load).  The attached patch will
change this to use a relative penalty in case of not-enough memory, so
that low-load low-memory nodes will be used at one point. A half
loaded node has shown to be a good value, as an unbalanced system is
much worse than non-local memory access for guests.  Regardless of
that you should restrict the Dom0 on a NUMA system to a reasonable
memory size, so that ballooning is not necessary most of the time. In
this case the guest's memory will be NUMA local.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
2009-12-11 08:59:54 +00:00
Keir Fraser e898e6e23e memory hotadd 7/7: hypercall support
The basic work flow to handle the memory hotadd is:
    Update node information
    Map new pages to xen 1:1 mapping
    Setup frametable for new memory range
    Setup m2p table for new memory range
    Put the new pages to domheap

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:58:06 +00:00
Keir Fraser 279dee9582 memory hotadd 6/7: Allocate L3 table for whole direct maping range if
memory hotplug is supported.

Hot-added memory may need a new L4 entry for 1:1 mapping. This patch
setup all L4 entry for 1:1 mapping if memory hotadd is needed, so that
we don't need sync the guest page table in page fault handler.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:57:30 +00:00
Keir Fraser 74168b7082 memory hotadd 5/7: Sync changes to mapping changes caused by memory
hotplug in page fault handler.

In compact guest situation, the compat m2p table is copied, not
directly mapped in L3, so we have to sync it.  Direct mapping range
may changes, and we need sync it with guest's table.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:56:50 +00:00
Keir Fraser 3146829841 memory hotadd 4/7: Setup frametable for hot-added memory
We can't use alloc_boot_pages for memory hot-add, so change it to use
the pages range passed in.

One changes need notice is, when memory hotplug needed, we have to
setup initial frametable as pdx index (i.e. the pdx_gorund_valid)
aligned, to make sure mfn_valid() still works after the max_page is
not maximum anymore.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:56:04 +00:00
Keir Fraser cee463f565 memory hotadd 3/7: Function to share m2p tables with guest.
The m2p tables should be shared by guest as they will be read-only
mapped by guest. This logical is similar to what happens in
subarch_init_memory(). But we need check the mapping is just setup.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:55:08 +00:00
Keir Fraser f988c45631 memory hotadd 2/7: Destroy m2p table for hot-added memory when hot-add failed.
As when we destroy the m2p table, it should not be used, so we don't
need consider clean the head/tail mapping that may exits before hot-add.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:54:37 +00:00
Keir Fraser f17f5479d1 memory hotadd 1/7: Setup m2p table for hot-added memory
When new memory added to the system, we need to update the m2p table
to cover the new memory range.

When memory add, it is difficult to allocate continous pages, so we
allocate the memory from the new added memory range. This also improve
the locality in numa situation.

We don't support 1G mapping for hot memory, because AFAIK currently
hot-plug memory will not be that large.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-11 08:53:57 +00:00
Keir Fraser fc63162a09 PVUSB: xm/xend support
You can see the following slides to understand the usage.
http://www.xen.org/files/xensummit_intel09/PVUSBStatusUpdate.pdf
Limitations:
"xm usb-hc-create" accepts up to 16 ports, but, current usbfront
can work with up to 15 ports. This may be bug and I'm preparing
to fix it.

This xm/xend support requires linux-2.6.18-xen.hg c/s 939 or above.
I recommend latest tip.

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
2009-12-11 08:52:17 +00:00
Keir Fraser 04656384a1 docs: Example usage of pvrdtscp algorithm
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
2009-12-11 08:51:21 +00:00
Keir Fraser 768e0ace27 x86: Allow HPET to set timers more sloppily by seeing each CPU's
acceptable deadline range, rather than just deadline start.

Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-12-11 08:50:13 +00:00
Keir Fraser dcf8b0114d libxenlight: fix cd-insert cli arguments parsing
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-11 08:47:51 +00:00
Keir Fraser de7c9106c1 libxenlight: add a cli option to exit right after domain creation
This patch adds a command line option in xl to exit right after domain
creation and not wait in background for the death of the domain.
Users should be aware that if they use this option, they always have
to destroy the domain manually after the guest shuts down.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-11 08:46:02 +00:00
Keir Fraser 44ed88bd6b libxenlight: fix two memory related issues
- LIBXL_MAXMEM_CONSTANT is 1MB but must be expressed in KB;

- xc_dom_linux_build should take target_memkb instead of max_memkb as
  an argument.

Thanks to Andres for spotting the latter.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-11 08:45:26 +00:00
Keir Fraser b1fc842a27 domain builder: multiboot-like module support
This defines how multiple modules can be passed to a domain by packing
them together into a "multiboot module" in a way very similar to the
multiboot standard.  An SIF_ flag is added to announce such package.
This also adds a packing implementation to PV-GRUB.

Signed-Off-By: Samuel Thibault <samuel.thibault@ens-lyon.org>
2009-12-11 08:44:33 +00:00
Keir Fraser ef9550e2e2 PoD: appropriate BUG_ON when domain is dying
BUG_ON(d->is_dying) in p2m_pod_cache_add() which is introduced in
c/s 20426 is not proper. Since dom->is_dying is set asynchronously.
For example, MMU_UPDATE hypercalls from qemu and the
DOMCTL_destroydomain hypercall from xend can be issued simultaneously.

Also this patch lets p2m_pod_empty_cache() wait by spin_barrier
until another PoD operation ceases.

Signed-off-by: Kouya Shimura <kouya@jp.fujitsu.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
2009-12-11 08:42:28 +00:00
Keir Fraser b6d4a6d487 x86-32/pod: fix map_domain_page() leak
The 'continue' in the if() part of the conditional at the end of
p2m_pod_zero_check() was causing this, but there also really is no
point in retaining the mapping after having checked page contents,
so fix it both ways. Additionally there is no point in updating
map[] at this point anymore.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-12-09 10:59:31 +00:00
Keir Fraser 80b20a2fa0 tools: simplify PYTHON_PATH computation (and fixes for NetBSD)
Doesn't work when build-time python path differs from install-time. Do
we care about this given tools should be packaged/built for the
specific run-time distro?

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2009-12-09 10:58:52 +00:00
Keir Fraser 5f05fba8c1 tmem, xentop: Report a few key per-domain tmem statistics in xentop.
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
2009-12-09 10:46:11 +00:00
Keir Fraser 51010e4de3 tmem: reclaim minimal memory proactively
When a single domain is using most/all of tmem memory
for ephemeral pages belonging to the same object, e.g.
when copying a single huge file larger than ephemeral
memory, long lists are traversed looking for a page to
evict that doesn't belong to this object (as pages in
the object for which a page is currently being inserted
are locked and cannot be evicted).  This is essentially
a livelock.

Avoid this by proactively ensuring there is a margin
of available memory (1MB) before locks are taken on
the object.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
2009-12-09 10:44:56 +00:00
Keir Fraser 9905ac2b90 libxenlight: implement libxl_set_memory_target
This patch adds a target_memkb parameter to libxl_domain_build_info to
set the target memory for the VM at build time and a new function
called libxl_set_memory_target to dynamically modify the memory target
of a VM at run time.  Finally a new command "mem-set" is added to xl
that calls directly libxl_set_memory_target.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-09 10:44:11 +00:00
Keir Fraser 30c666cd1c libxenlight: xenstore data path writable by the guest
Make the data path on xenstore writable by the guest
because Citrix pv drivers requires it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-09 10:43:33 +00:00
Keir Fraser 6369c4faa3 SRAT memory hotplug 2/2: Support overlapped and sparse node memory arrangement.
Currently xen hypervisor use nodes to keep start/end address of
node. It assume memory among nodes has no overlap, this is not always
true, especially if we have memory hotplug support in the system.
This patch backport Linux kernel's memblks to support overlapping
among node. The memblks will be used both for checking conflict, and
caculate memnode_shift.

Also, currently if there is no memory populated in a node when system
booting, the node will be unparsed later, and the corresponding CPU's
numa information will be removed also. This patch will keep the CPU
information.

One thing need notice is, currently we caculate memnode_shift with all
memory, including un-populated ones. This should work if the smallest
chuck is not so small. Other option can be flags in the page_info
structure, etc.

The memnodemap is changed from paddr to pdx, both to save space, and
also because currently most access is from pfn.

A flag is mem_hotplug added if there is hotplug memory range.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-09 10:42:53 +00:00
Keir Fraser 4d817e3923 SRAT memory hotplug 1/2: Revert 20053:ebb07c5934c8.
Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-12-09 10:41:37 +00:00
Keir Fraser 7aab6d6523 hvm: Share ASID logic between VMX and SVM.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-12-08 14:14:27 +00:00
Keir Fraser c4a0c89b8c hvm: Pull SVM ASID management into common HVM code where it can be shared.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-12-08 10:33:08 +00:00
Keir Fraser 272c176b86 Track free pages live rather than count pages in all nodes/zones
Trying to fix a livelock condition in tmem that occurs
only when the system is totally out of memory requires
the ability to easily determine if all zones in all
nodes are empty, and this must be checked at a fairly
high frequency.  So to avoid walking all the zones in
all the nodes each time, I'd like a fast way to determine
if "free_pages" is zero.  This patch tracks the sum
of the free pages in all nodes/zones.  Since I think
the value is modified only when heap_lock is held,
it need not be atomic.

I don't know this for sure, but suspect this will be
useful in other future memory utilization code, e.g.
page sharing.

This has had limited testing, though I did drive free
memory down to zero and up and down a few times with
debug on and no asserts were triggered.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
2009-12-08 07:55:21 +00:00
Keir Fraser b9c20c7878 VT-d: per-iommu domain-id
Currently, xen uses shared iommu domain-id across all the VT-d units
in the platform. The number of iommu domain-ids (NR_DID, e.g. 256)
supported by each VT-d unit is reported in Capability register. The
limitation of current implementation is it only can support at most
NR_DID domains with VT-d in the entire platform, even though the
platform can support N * NR_DID (where N is the number of VT-d
units). Imagine a platform with several SR_IOV NICs, and each NIC
supports 128 VFs. It possibly beyond the NR_DID.

This patch implements iommu domain-id management per iommu (VT-d
unit), hence solves above limitation. It removes the global domain-id
bitmap, instead use domain-id bitmap in struct iommu, and also involve
an array to map guest domain-id and iommu domain-id, which is used to
iommu domain-id when flush context cache or IOTLB. When a device is
assigned to a guest, choose an available iommu domain-id from the
device's iommu, and map guest domain id to the domain-id mapping
array. When a device is deassigned from a guest, clear the domain-id
bit in domain-id bitmap and clear the corresponding entry in domain-id
map array if there is no other devices under the same iommu owned by
the guest.

Signed-off-by: Weidong Han <weidong.han@intel.com>
2009-12-08 07:51:30 +00:00
Keir Fraser ef86b9f18b xend: Add keymap to vfb config for existing hvm guests
I submitted a patch a while back to add keymap to vfb config for hvm
guests.  This patch works fine for new config (xm create|new) but not
existing, managed guests.  To cover the latter case I've introduced a
validator method in XendConfig.

Signed-off-by: Jim Fehlig <jfehlig@novell.com>
2009-12-08 07:49:54 +00:00
Keir Fraser 80bae1b6dc Make tsc_mode=3 (pvrdtscp) work correctly.
Initial tsc_mode patch contained a rough cut at pvrdtscp mode.  This
patch gets it working correctly.  For the record, pvrdtscp mode allows
an application to obtain information from Xen to descale/de-offset
a physical tsc value to obtain "nsec since VM start".  Though the
raw tsc value may change across migration due to different Hz rates
and different start times of different physical machines, applying
the pvrdtscp algorithm to a raw tsc value guarantees that the result
will always be both a fixed known rate (nanoseconds) and monotonically
increasing.  BUT, pvrdtscp will only be fast on physical machines that
support the rdtscp instruction AND on which tsc is "safe"; on other
machines both the rdtsc and rdtscp instructions will be emulated.
Also note that when tsc_mode=3 is enabled, tsc-sensitive applications
that do NOT implement the pvrdtscp algorithm will behave incorrectly.
So, tsc_mode=3 should only be used when all apps are either
tsc-resilient
or pvrdtscp-modified, and only has a performance advantage on very
recent generation processors.

Signed-off-by: Dan Magenheiemer <dan.magenheimer@oracle.com>
2009-12-08 07:48:45 +00:00
Keir Fraser 7b4effff89 libxenlight: implement cdrom insert/eject
This patch implements functions in libxenlight to change the cdrom in
a VM at run time and to handle cdrom eject requests from guests.

This patch adds two new commands to xl: cd-insert and cd-eject; it
also modifies xl to handle cdrom eject requests coming from guests
(actually coming from qemu).

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-08 07:47:52 +00:00
Keir Fraser 4baca0b560 fs-backend: add a backend cleanup function
This patch implements a backend cleanup function in fs-backend so that
when the connection to the frontend is closed we don't leak nodes on
xenstore.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-08 07:45:15 +00:00
Keir Fraser d08e561228 libxenlight: minimal vfs support
This patch adds minimal support for fs-backend and minios' fs-front
to libxenlight:

- it creates a vfs directory on the stubdom's xenstore
device path and allows the stubdom to write to it;

- it doesn't try to cleany shutdown the vfs backend.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-12-08 07:44:45 +00:00
Keir Fraser c748ebb04e Update QEMU_TAG to 9297e6402f6aa1b52e5577edc875eb2d2163baeb 2009-12-07 14:10:27 +00:00
Keir Fraser a8af89270c x86_32: Fix build after 20575:0930d17589a6
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-12-05 12:32:34 +00:00
Keir Fraser 1f29decb33 libxenlight: physmap slack for pv domains
Contemplate a memory space slack for PV domains,
since they do ballooning (or flipping network rx)
and need some extra room in their pfn space.

Note that this does not allocate any extra memory
to the domain, it simply extends the physmap with
some extra room for "bounce bufffering back" pfn's
that are yielded to dom0.

The default slack is set at 8MB.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
2009-12-05 12:30:46 +00:00
Keir Fraser a05bf36813 Update QEMU_TAG to 91ae19a7cc445030614bd0ae91548162cf0befbe 2009-12-05 12:29:48 +00:00
Keir Fraser 88cd47fe0f libxenlight: get state for one domain
Simple function to get the dominfo state of a single domain.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:11:44 +00:00
Keir Fraser 6eb9ddda17 libxenlight: domain resume
Added libxenlight implementation for resume domain.
This brings back a cooperative pv domain from the
shutdown state after save, enabling checkpointing.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:11:06 +00:00
Keir Fraser 69535954d1 libxenlight: Destroy device model only for domains that have it
Destroy device model only for domains that have it.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:10:22 +00:00
Keir Fraser 91064f9e07 libxenlight: avoid writing empty values to xenstore
Prevent segmentation fault caused by empty values
in key-value pairs for the /vm/ subdirectory
when restoring a pv domain.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:09:44 +00:00
Keir Fraser 1835885f4f libxenlight: disk and nic destroy calls
Expose disk and nic device destroy calls

Also removes the obsolete device shutdown calls.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:06:47 +00:00
Keir Fraser e7a1488520 libxenlight: refactor libxl destroy code
Refactor libxl device destroy code. Abstract function
waiting for the watch on the state node to fire.
Create a generic device delete function.

Only a single LIBXL_DESTROY_TIMEOUT elapses when
waiting for destruction of all the devices of a
domain.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:03:45 +00:00
Keir Fraser 88de8df0dc libxenlight: fix GC when cloning contexts
Provide a function to clone a context. This is necessary
because simply copying the structs will eventually
corrup the GC: maxsize is updated in the cloned context
but not in the originating, yet they have the same array
of referenced pointers alloc_ptrs.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.com>
2009-12-04 07:02:49 +00:00
Keir Fraser 78eed7d044 xend: Fix parameters to PyArg_ParseTupleAndKeywords()
The kwd_list parameter PyArg_ParseTupleAndKeywords() must be a
NULL-terminated list.

Signed-off-by: KUWAMURA Shin'ya <kuwa@jp.fujitsu.com>
2009-12-04 07:00:25 +00:00
Keir Fraser 25c6a4b616 x86: XENMEM_add_to_physmap should propagate errors from guest_physmap_add_page().
Authored-by: David Lively
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2009-12-04 06:59:33 +00:00
Keir Fraser 42aac3d370 Add keyhandler 'g' to print all active grant table entries.
Authored-By: Robert Phillips
Signed-off-By: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2009-12-04 06:58:08 +00:00
Keir Fraser 8cf96a2728 libxenlight: Get rid of the dependency on the LIBCONFIG_SOURCE directory.
Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
2009-12-04 06:51:53 +00:00