Rather than debit a full 10ms of credit on a scheduler tick
(probabilistic), debit credits accurately based on time stamps.
The main problem this is meant to address is an attack on the
scheduler that allows a rogue guest to avoid ever being debited
credits. The basic idea is that the rogue process checks time (using
rdtsc) periodically, and yields after 9.5ms. Using this technique, a
guest can "steal" 95% of the cpu. This is particularly an issue in
cloud environments.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
We currently compare the sum of the pages found in the SRAT table to
the address of the highest memory page found via the e820 table to
validate the SRAT. This is completely bogus if there's any kind of
discontiguous memory, where the sum of the pages could be much smaller
than the address of the highest page. I think all that's necessary is
to validate that each usable memory range in the e820 is covered by an
SRAT entry. This might not be the most efficient way to do it, but
there are usually a relatively small number of entries on each side.
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
pygrub currently has a hardcoded path of /usr/bin/python which is not
correct if the version of python at install time is not the same as
that at build time. This patch uses the existing install-wrap and
python/get-path machinery.
(It does not address the currently-existing bug that the get-path
machinery works by assuming that `python' is a symlink, rather than
querying the python interpreter for its version.)
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
and PV/ramdisk
Add support for 'file:' and 'data:' URI schemes for the parameters
'PV/kernel' and 'PV/ramdisk' in the VM.create() call. The 'data:'
scheme handling enables using a file which is stored inside the
management system (from where the XenAPI call is send) as kernel or
ramdisk.
Notes:
o all included: a detailed description can be found in the xenapi
documentation
o bumped up the version of the API document to 1.0.8 (because of
(minimal) interface extension)
o Future enhancements (like http:, ftp: schemes) fit seamlessly into
the current design / classes
o Unittest cases and xm-test case included
Signed-off-by: Andreas Florath <xen@flonatel.org>
- Fix an error message in xc_try_bzip2_decode()
- Check library installation on demand using a Makefile function,
rather than generating a dependency file. Cleaner and avoids a race
on generating the dep file.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
The newer version of the emulator contains several bug fixes, one that
we were seeing in our use of vtpm.
This patch also defines TPM_STRONG_PERSISTENCE for the new emulator.
A couple of important notes about this patch:
-This has only been tested on PVM domU's. In theory it should work for
HVM but I have not tried it at all and can guarantee nothing.
-All the relevant changes in tools/vtpm/vtpm.patch have been ported
to tpm_emulator-0.5.1.
-None of the changes in tpm_emulator.patch have been ported. In
particular this means the BUILD_EMULATOR option, which as I understand
lets you use the tpm_emulator in dom0 for a machine that does
not have a real hardware TPM does not work. This functionality should
be easy to add though because the new emulator already comes with a
kernel module interface.
-No considerations were made for the VTPM_MULTI_VM feature (which is
supposedly unfinished). This patch may or may not break any progress
made on that feature.
Signed-off-by: Matt Fioravante <Matthew.Fioravante@jhuapl.edu>
Right now xen will create a new vtpm instance everytime you start up a
domU, even if you specify the instance parameter in your config file.
Each vtpm instance is then given a uuid and the vtpm.db file maps
instance numbers to uuid numbers.
This patch is a hack that lets you explicitly set the uuid of your
vtpm instance. Everytime you boot up your domU now the vtpm will get
that uuid and thus it will always get the same vtpm instance number
instead of being generated a new one.
So for example, in your config file you would do something like this
vtpm = [ 'backend=0,uuid=dcdb124b-9fed-4040-b149-dd2dfd8d094c' ]
Signed-off-by: Matt Fioravante <Matthew.Fioravante@jhuapl.edu>
There is a bug in the vtpm_manager that has to do with hashing and
saving the NVM memory files (vtpm_dm_%d.data). The file is not
truncated when it is written and this results in the hash becoming
invalid because of the extra bits at the end of the file.
This patch adds O_TRUNC to the flags when opening the file.
More details on this issue are in the bug report on bugzilla=20
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=3D1488
Signed-off-by: Matt Fioravante <Matthew.Fioravante@jhuapl.edu>
When booting Dom0 with huge amounts of memory, and/or memory accesses
being sufficiently slow (due to NUMA effects), and the ACPI PM timer
or a high frequency HPET being used, the time it takes to populate the
M2P table may significantly exceed the overflow time of the platform
timer, screwing up time management to the point where Dom0 boot fails.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Update the XSM Flask documentation to reflect the support for
policy.24, the updated policy and policy build infrastructure, and how
to enable the optional MLS policy.
Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: George S. Coker, II <gscoker@alpha.ncsc.mil>
1. Create an empty dep file if neither lib is installed
2. Forcibly disable support for libs if building minios
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Recent upstream kernels can be compressed using either gzip,
bzip2, or LZMA. However, the PV kernel loader in Xen currently only
understands gzip, and will fail on the other two types. The attached
patch implements kernel decompression for gzip, bzip2, and LZMA so
that kernels compressed with any of these methods can be launched.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
The original xen policy infrastructure was based off of an early
version of refpolicy. Because of this there was a lot of cruft that
does not apply to building a policy for xen. This patch does several
things. First it cleans up the makefile as to remove many unnecessary
build targets. Second it fixes an issue that the policy build process
wasn't handling interface files properly. Third it pulls in the MLS
suppport functions from current ref policy and makes use of
them. Finally it updates the xen policy with new rules to address
changes in xen since the policy was last worked on, and provides
several new abstractions for creating domains.
Signed-off-by: David P. Quigley <dpquigl@tycho.nsa.gov>
The PV limit should not apply as there is no M2P table mapped into an
HVM guest's virtual address space.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
linux kernels
New kernels have ext2 disabled by default. This fix uses ext3 for
testcase 11_block_attach_shared_dom0.
Signed-off-by: Andreas Florath <xen@flonatel.org>
It basically checks for the presence of password line in grub.conf
of the guest image and if this line is present, it supports both clear
text and md5 versions of the password. Editing the grub entries and
command-line are disabled when some password is set in domain's
grub.conf file but the password was not entered yet. Also, new option
to press 'p' in interactive pygrub has been added to allow entering
the grub password. It's been tested on x86_64 with PV guests and was
working fine. Also, the countdown has been stopped after key was
pressed, ie. the user is probably editing the boot configuration.
Signed-off-by: Michal Novotny <minovotn@redhat.com>
shadow_alloc_p2m_page() fails to call shadow_prealloc() before calling
shadow_alloc(). In certain conditions, notably when PoD is being
exercised, this may cause shadow_alloc() to fail, crashing Xen.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
There were a couple of small bugs in the xapi xm-test:
o outdated XenAPI calls were removed from testcase
(02_xapi-vbd_basic)
o minor problem with XendLocalStorageRepository
is fixed (missed list_images() function - which
is moved from the XenQCoWStroageRepo to the common
base class XendStorageRepository)
which was detected running 02_xapi-vbd_basic.
o XenAPI session handling and connecting is fixed.
o 03_xapi-network_pos was rewritten and now uses
XenAPI.
Signed-off-by: Andreas Florath <xen@flonatel.org>
The resport functionality is not removed because there is the hope
that somebody sets up the server side infrastructure.
Signed-off-by: Andreas Florath <xen@flonatel.org>
mm code clearer.
The FOREIGNDOM method was just confusing and pointless. The deferred
TLB flushing is of questionable value now that much automatic flushing has to be
synchronous to avoid guest SMP races.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
teardown_msi_irq logic is covered in destroy_irq,
so remove it to avoid freeing msi resource twice.
Signed-off-by: Xiantao Zhang<xiantao.zhang@intel.com>
Should be a typo, this issue is introduced by Cset20076,
and it may break VT-d device assignment.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
This is a back-port of the latest SELinux code to Xen, adjusted
for Xen coding style and interfaces. Unneeded functionality such
as most object context config data, handle_unknown, MLS field
defaulting, etc has been omitted.
Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: George S. Coker, II <gscoker@alpha.ncsc.mil>
xenpm trace utility gtraceview cleanup
- add gtraceview help info on how to get raw data by xentrace
- make trace_exit_reason compiled in non-debug mode. trace_exit_reason
can be enable/disabled by xentrace at runtime, so no need to disable
it at build time.
Signed-off-by: Yu Ke <ke.yu@intel.com>
Imagine a PCIe switch, which doesn't support ACS (Access Control
Services), has 2 downstream ports: A and B, according to PCIe spec,
the PCIe switch should directly route the transaction that is from A
and to a device under B -- the Root Complex and IOMMU engine are
bypassed -- this doesn't work at all in the case of hvm guest and can
even incur potential security issue, so we should not allow such kind
of device assignment.
If all the intermediate PCIe swiches between a device and Root Complex
support and enable ACS, we can safely asssign the device to guest.
Cc: Allen Kay <allen.m.kay@intel.com>
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
currently the function same_vm in block-common.sh is the one
responsible for detecting if two block devices can be used at the same
time by two VMs. This can be allowed in few specific cases: when the
two VMs are actually the same VM and when the two VMs are the guest
and its stubdomain. We need to expand these exceptions to handle
properly save restore issues: this patch adds to the exceptions the
case when two VMs are the same VM because of save\restore races, and
when two VMs are the guest and the stubdomain of the previous guest,
again during save\restore.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Defer fail_if()-s as much as possible (in favor of possibly generating
exceptions), and avoid generating exceptions when not strictly
necessary.
Avoid fail_if()-s for simple return code checks (making the code that
used them consistent with other, longer existing code).
Eliminate redundant generate_exception_if()-s checking lock_prefix
(which is already covered by the general check prior to decoding
operands).
Also fix the testing code to add PROT_EXEC for the mapping that is
intended to have instruction executed from.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
While Intel and AMD implementations differ in various respects when
it comes to non-default operand sizes of control transfer instructions
and segment register loads (lfs, lgs, lss), it seems to make senss to
(a) match their behavior if they agree and (b) prefer the more
permissive behavior if they don't agree:
- honor operand size overrides on near brances (AMD does, Intel
doesn't)
- honor operand size overrides on far branches (both Intel and AMD do)
- honor REX.W on far branches (Intel does, AMD doesn't except on far
returns)
- honor REX.W on lfs, lgs, and lss (Intel does, AMD doesn't)
Also, do not permit emulation of pushing/popping segment registers
other than fs and gs as well as that of les and lds (the latter are
particularly important due to the re-use of the respective opcodes as
VEX prefixes in AVX).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
In order to give guests a hint at whether their vCPU-s are currently
scheduled (so they can e.g. adapt their behavior in spin loops),
update
the run state area (if registered) also when de-scheduling a vCPU.
Also fix an oversight in the compat mode implementation of
VCPUOP_register_runstate_memory_area.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
Currently, 32 vpids are allocated for each
domain statically, it blocks to support more
vcpus for HVM domain, so remove the limit and
only allocate vpid for intilized vcpus. In this
way, vpid can be non-contiguous for vcpus of one
single domain.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Since Xen and Linux has big differece in code base, it
is very hard to port Linux's patch and apply it to Xen
directly, so this patch only adopts core logic of Linux,
and make it work for Xen.
Key changes:
1. vector allocation algorithm
2. all IRQ chips' set_affinity logic
3. IRQ migration when cpu hot remove.
4. Break assumptions which depend on global vector policy.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
from vector-based to IRQ-based.
In per-cpu vector environment, vector space changes to
multi-demension resource, so vector number is not appropriate
to index irq_desc which stands for unique interrupt source. As
Linux does, irq number is chosen to index irq_desc. This patch
changes vector-based interrupt infrastructure to irq-based one.
Mostly, it follows upstream linux's changes, and some parts are
adapted for Xen.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Currently, nr_irqs is only used for GSI irqs, change
the name to make its meaning more precise. And, also
this is the initial step to support irq allocation for
MSI interrupt source.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Currently the stubdom-dm script doesn't read the bridge of a vif
on xenstore, therefore all the vifs assigned to the stubdom always
belong to default bridge. This patch changes the behavior reading the
bridge from xenstore and adding the bridge to the stubdom config
file.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Add the ability to define VBD QoS policy in the xend layer.
Consider the following vbd entry:
vbd = [
'phy:/dev/server/virtualmachine1-disk,xvda1,w,credit=3D5000/s@50ms',
]
This means that a VM may perform 5000 I/O operations per second, with
credit being replenished every 50 milliseconds.
The 'credit' xenstore value is by the blkback driver to ratelimit I/O
operations for the specific device.
Signed-off-by: William Pitcock <nenolod@dereferenced.org>
Quirk handling is designed to easily add more quirks when needed
w/o messing around in the normal mce code.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Fix formatting of Flask AVC audit messages so that existing
policy tools can parse them. After applying,
'xm dmesg | audit2allow' yields the expected result.
Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: George S. Coker, II <gscoker@alpha.ncsc.mil>
We do not need to use the _irqsave/irqrestore forms of spin locking
within the sidtab in Xen's XSM Flask module, and doing so triggers a
BUG_ON() within check_lock() when we subsequently call xmalloc().
This was preventing Xen from booting with XSM/Flask enabled if built
with debug=y. It appears that this broke upon the changes to xmalloc
in changeset 18379:14a9a1629590.
Signed-off-by: Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: George S. Coker, II <gscoker@alpha.ncsc.mil>
On guest MCE read only print debug code when
a non-zero value has been read. Xen is too
noisy, otherwise.
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
when the VMEXIT code indicates that an NMI has been raised.
Otherwise we might hit a real NMI while in the handler.
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* Correctly handly EFLAGS.TF in the hypervisor
* Register value sent with 'P' command is in native byte order.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
A node's future-hotplug memory range starts from very high end
normally, e.g. 1TB, and is not continuous with its current existing
memory range. It should not be covered by the global variable 'nodes'
as it assumes the node's memory is continuous. Otherwise it can make
nodes' memory ranges become very big and overlapped, and
populate_memnodemap() fails.
We can ignore future-hotplug memory range for now. Physical memory
hotplug support in future will handle it.
Signed-off-by: Yang Xiaowei <xiaowei.yang@intel.com>
Checked builds of Windows will, after every modification of the TPR,
read it back again and assert that the value read back matches with
the value written, including the priority sub-class. Make sure that
we correctly preserve it on vmexit.
As far as I can tell from reading the documentation, the sub-class
doesn't actually do anything, so this should be pretty harmless.
Signed-off-by: Steven Smith <steven.smith@eu.citrix.com>
xentrace_format cannot use "0x016x" format as we expect.
It show only %(N) as "0x016x" format, not as "%(N+1)08x%(N)08x".
So I fixed tools/xentrace/formats by using "%(N+1)08x%(N)08x" format.
Also I added some TRC_PV entries.
Signed-off-by: Akio Takebe <takebe_akio@jp.fujitsu.com>
The headers libelf.h and elfstructs.h were removed from
xen/include/public in 19011:7df072566b8c. But this broke the stubdom
build because parts of libxc depend on them. This patch adds
$(XEN_ROOT)/xen/include/xen to the stubdom -I path.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Expose tmem "freeable" memory for use by management tools.
Management tools looking for a machine with available
memory often look at free_memory to determine if there
is enough physical memory to house a new or migrating
guest. Since tmem absorbs much or all free memory,
and since "ephemeral" tmem memory can be synchronously
freed, management tools need more data -- not only how
much memory is "free" but also how much memory is
"freeable" by tmem if tmem is told (via an already
existing tmem hypercall) to relinquish freeable memory.
This patch provides that extra piece of data (in MB).
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
In changset 19540 a bug was introduced in the fib_iptable function in
vif-common.sh that incorrectly checks the exit status of iptables --
it always believes iptables has failed even when it hasn't.
The attached patch fixes that. It's also bug 1490.
Signed-off-by: John Haxby <john.haxby@oracle.com>
Also remove compile-time limit of 32 for i386. It is no longer
required, since a cpumask was moved out of struct page_info.
Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
We found recently there was an assertion failure when EPT mode is
enabled on 32PAE host when debug=y is used. The patch attached fixes
that. It uses the common p2m ops in the
common p2m code path p2m_remove_page rather than calling
p2m_gfn_to_mfn() for only shadow mode.
Signed-off-by: Xin, Xiaohui <xiaohui.xin@intel.com>
The Xend has a problem that it often fails to restore/migrate
a PV domain whose device backends are partly a driver domain.
Because a checkpoint of the PV domain has device backend value as
domain id, you can restore/migrate the PV domain only when a driver
domain is the same id as device backend value in the checkpoint.
I attached a patch to fix it by renaming device backend value in a
checkpoint from domain id to domain name when xm save/migrate.
This patch doesn't rename device backend value if the value is 0,
which is Domain-0, so the checkpoint format is compatible if you use
only Domain-0 as device backend.
Signed-off-by: Rikiya Ayukawa <ayukawa.rikiya@jp.fujitsu.com>
Attached patch implements save/restore/migration/livemigration
for transcendent memory ("tmem"). Without this patch, domains
using tmem may in some cases lose data when doing save/restore
or migrate/livemigrate. Also included in this patch is
support for a new (privileged) hypercall for authorizing
domains to share pools; this provides the foundation to
accomodate upstream linux requests for security for shared
pools.
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Read/write/execute flags are set to 1 before calling the type_to_flags
function which sets them to their appropriate values depending on the
p2m type. However, in invalid, mmio_dm, and default/unknown cases in
type_to_flags just falls through, unsafely leaving full access to
these pages.
Signed-off-by: Patrick Colp <Patrick.Colp@citrix.com>