Keir Fraser [Fri, 31 Oct 2008 14:02:39 +0000 (14:02 +0000)]
Change timer implementation to allow variable 'slop' in how late
timers are fired. The default continues to be 50us, but this can be
configured on Xen's command line.
Signed-off-by: Yu Ke <ke.yu@intel.com> Signed-off-by: Wei Gang <gang.wei@intel.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Keir Fraser [Thu, 30 Oct 2008 15:04:27 +0000 (15:04 +0000)]
x86: Use the right error code when testing for spurious pagefaults
Shadowed PV domains may take pagefaults with PFEC_reserved_bit bit
set, which are then turned into page-not-present faults by the shadow
code. Since that changes the error code in the regs structure, we need
to remember the old error code when we later check for spurious page
faults or we'll get false positives.
Keir Fraser [Thu, 30 Oct 2008 14:53:24 +0000 (14:53 +0000)]
x86: fix preemptable page type handling
- retain a page reference when PGT_partial is set on a page (and drop
it when clearing that flag)
- don't drop a page reference never acquired when freeing the page
type
of a page where the allocation of the type got preempted (and never
completed)
- don't acquire a page reference when allocating the page type of a
page where freeing the type got preempted (and never completed, and
hence didn't drop the respective reference)
Keir Fraser [Wed, 29 Oct 2008 16:58:05 +0000 (16:58 +0000)]
cpufreq.c: shut up compiler about cpufreq_dom
Some versions of GCC are too stupid to figure out that cpufreq_dom is
only used if !!domexist and always set in that case, and complain that
it may be used uninitialised.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Mon, 27 Oct 2008 18:51:52 +0000 (18:51 +0000)]
minios: do not expose #define current to applications
Currently the minios headers do this:
#define current get_current()
Obviously when porting general code to this environment, this can
cause problems !
The attached patch arranges for this only to be done if
#define __MINIOS__
is declared, which is set up by the makefile in extras/mini-os.
Suppressing the namespace pollution is necessary to get recent
upstream qemu's to compile, since they (quite properly) use `current'
as an ordinary identifier.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Keir Fraser [Mon, 27 Oct 2008 13:29:35 +0000 (13:29 +0000)]
x86: highmem handling assistance hypercalls
While looking at the origin of very frequently executed hypercalls I
realized that the high page accessor functions in Linux would be good
candidates to handle in the hypervisor - clearing or copying to/from
a high page is a pretty frequent operation (provided there's enough
memory in the domain). While prior to the first submission I only
measured kernel builds (where the results are not hinting at a
meaningful improvement), I now found time to do a more specific
analysis: page clearing is being improved by about 20%, page copying
doesn't seem to significantly benefit (though that may be an effect of
the simplistic copy_page() implementation Xen currently uses) -
nevertheless I would think that if one function is supported by the
hypervisor, then the other should also be.
Keir Fraser [Mon, 27 Oct 2008 13:22:43 +0000 (13:22 +0000)]
x86: fix domain cleanup
The preemptable page type handling changes modified free_page_type()
behavior without adjusting the call site in relinquish_memory(): Any
type reference left pending when leaving hypercall handlers is
associated with a page reference, and when successful free_page_type()
decrements the type refcount - hence relinquish_memory() must now also
drop the page reference.
Also, the recursion avoidance during domain shutdown somehow (probably
by me when I merged the patch up to a newer snapshot) got screwed up:
The avoidance logic in mm.c should short circuit levels below the top
one currently being processed, rather than the top one itself.
Keir Fraser [Mon, 27 Oct 2008 13:20:52 +0000 (13:20 +0000)]
x86/powernow: fix machine shutdown
cpufreq_del_cpu() calls cpufreq_driver->exit() without checking
whether an exit() handler is present, and by adding an exit() handler
to powernow we can at once close the potential memory leak.
Keir Fraser [Mon, 27 Oct 2008 10:08:48 +0000 (10:08 +0000)]
x86: relax restrictions on reserved bits in L3 for 32on64 x86 guests
A 32on64 guest cannot copy an existing pinned L3 entry to use as a new
L3 because COMPAT_L3_DISALLOW_MASK contains bits which are added to L3
entries by adjust_guest_l3e (U/S & R/W) or by the hardware (A & D).
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Keir Fraser [Thu, 23 Oct 2008 10:40:59 +0000 (11:40 +0100)]
x86, hvm: Move return-to-guest timer and interrupt cranking logic
outside of IRQ-safe context. This allows us to safely take
non-IRQ-safe spinlocks.
The drawback is that {vmx,svm}_intr_assist() now races new event
notifications delivered by IRQ or IPI. We close down this race by
having vcpu_kick() send a dummy softirq -- this gets picked up in
IRQ-sage context and will cause retry of *_intr_assist(). We avoid
delivering the softirq where possible by avoiding it when we are
running in the non-IRQ context of the VCPU to be kicked.
Keir Fraser [Wed, 22 Oct 2008 11:04:32 +0000 (12:04 +0100)]
Port HPET device model to vpt timer subsystem
The current hpet implementation runs a one-shot xen timer for each
hpet timer whenever the main counter is enabled regardless of whether
or not the individual hpet timers are enabled. When the timer fires,
if it is enabled the interrupt is routed to the guest. If the hpet
timer is periodic, a new one-shot timer is set, for NOW()+period.
There are a number of problems with this the most significant is guest
time drift. Windows does not read the hardware clock to verify time,
it depends on timer interrupts firing at the expected interval. The
existing implementation queues a new one-shot timer each time it fires
and does not allow for a difference between NOW() and the time the
timer was expected to fire, causing drift. Also there is
no allowance for lost ticks. This modification changes HPET to use the
Virtual Platform Timer (VPT) and, for periodic timers, to use periodic
timers. The VPT ensures an interrupt is delivered to the guest for
each period that elapses, plus, its use of xen periodic timers ensures
no drift.
Signed-off-by: Peter Johnston <peter.johnston@citrix.com>
Isaku Yamahata [Wed, 22 Oct 2008 02:38:22 +0000 (11:38 +0900)]
[IA64] fix compilation error of xen/common/spinlock.c
This patch fixes the error in the x86 tree.
> spinlock.c: In function _spin_lock_recursive:
> spinlock.c:59: error: dereferencing pointer to incomplete type
Keir Fraser [Tue, 21 Oct 2008 08:48:56 +0000 (09:48 +0100)]
Update cpufreq statistic protection
For struct pm_px, there are 3 pointer: pxpt, pt, trans_pt.
Partly free pointer 'pt' and 'trans_pt' will result in little memory
leak, and what is more, will result in protection issue when user
access px statistic info through libxc.
Keir Fraser [Tue, 21 Oct 2008 08:47:33 +0000 (09:47 +0100)]
x86: Adapt 32b guest os to 64b hypervisor platform_hypercall compatibility
Changeset 18552 (19b0a4f91712) move px transfer logic from
platform_hypercall.c to a common file to support both x86 and
ia64. However, it involves 32b guest os to 64b hypervisor (x86)
compatible issue. This patch fix the compatible issue, and make
set_px_pminfo() re-used by ia64 and x86 (32b guest os to 64b
hypervisor, and 64b guest os to 64b hypervisor).
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
Keir Fraser [Mon, 20 Oct 2008 15:48:17 +0000 (16:48 +0100)]
Clean up spinlock operations and compile as first-class functions.
This follows modern Linux, since apparently outlining spinlock
operations does not slow down execution. The cleanups will also allow
more convenient addition of diagnostic code.
Keir Fraser [Mon, 20 Oct 2008 14:31:54 +0000 (15:31 +0100)]
vmx: avoid taking locks with irqs disabled
Shuffle the bits of the vmexit handler that run with EFLAGS.IF == 0 up
to the top. Otherwise we end up calling spin_lock() with interrupts
disabled, which can deadlock against the time-synchronization
rendezvous code.
Keir Fraser [Mon, 20 Oct 2008 14:22:58 +0000 (15:22 +0100)]
x86: add movnti emulation
Linux added the use of movnti for copying from user to kernel space in
certain cases, and as per reports we got this may happen with the
destination being in MMIO.
Keir Fraser [Mon, 20 Oct 2008 14:19:39 +0000 (15:19 +0100)]
VT-d: correct allocation failure checks
Checking the return value of map_domain_page() (and hence
map_vtd_domain_page()) against NULL is pointless, checking the return
value of alloc_domheap_page() (and thus alloc_pgtable_maddr()) is
mandatory, however.
Keir Fraser [Mon, 20 Oct 2008 14:17:24 +0000 (15:17 +0100)]
xend: fix setting vcpus > VCPUs_max
From reading xend code related to changing number of vcpus it appears
setting the number of vcpus to a value greater than VCPUs_max is not
allowed on a running domain. This restriction is not honored by
setVCpuCount() in XendDomainInfo.py. Attached patch makes
setVCpuCount() fail if vcpus > VCPUs_max and domain is running.
Also, I think the changes should be reflected in managed config of
running domain if in fact the domain is managed - so unconditionally
call managed_config_save().
BTW, the original code is rather confusing. Essentially the same
actions are taken regardless if self.info['VCPUs_max'] > vcpus, just
the order of invocation is changed. But this doesn't seem to matter
since self.info['VCPUs_live'] is not subsequently used.
Keir Fraser [Fri, 17 Oct 2008 11:00:25 +0000 (12:00 +0100)]
Enable PCI serial devices for console messages
The basic issue is that some PCI serial devices use a non-standard
crystal to control the baud rate divisor. This patch enhances the
`com' parameter to enable you to specify the crystal frequency used by
the serial device. Since this parameter already allows you to specify
I/O address and IRQ this is all that is needed to get a PCI serial
device to work. With this patch the `com' parameter is now defined
as:
comN=BBB[/CCC][,NPS[,III[,IRQ]]]
Where `CCC' is the crystal frequency. Note that if you specify 0 for
`IRQ' Xen will run the serial device in polled mode, obviating the
need for interrupts (an advantage since this is the only way I was
able to get my PCI serial device to work).