safe/jmp/linux-2.6
15 years agoKVM: MMU: remove redundant check in mmu_set_spte
Joerg Roedel [Wed, 18 Feb 2009 13:08:59 +0000 (14:08 +0100)]
KVM: MMU: remove redundant check in mmu_set_spte

The following code flow is unnecessary:

if (largepage)
was_rmapped = is_large_pte(*shadow_pte);
 else
  was_rmapped = 1;

The is_large_pte() function will always evaluate to one here because the
(largepage && !is_large_pte) case is already handled in the first
if-clause. So we can remove this check and set was_rmapped to one always
here.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: handle compound pages in kvm_is_mmio_pfn
Joerg Roedel [Wed, 18 Feb 2009 13:08:58 +0000 (14:08 +0100)]
KVM: MMU: handle compound pages in kvm_is_mmio_pfn

The function kvm_is_mmio_pfn is called before put_page is called on a
page by KVM. This is a problem when when this function is called on some
struct page which is part of a compund page. It does not test the
reserved flag of the compound page but of the struct page within the
compount page. This is a problem when KVM works with hugepages allocated
at boot time. These pages have the reserved bit set in all tail pages.
Only the flag in the compount head is cleared. KVM would not put such a
page which results in a memory leak.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Fix kvmclock on !constant_tsc boxes
Gerd Hoffmann [Wed, 4 Feb 2009 16:52:04 +0000 (17:52 +0100)]
KVM: Fix kvmclock on !constant_tsc boxes

kvmclock currently falls apart on machines without constant tsc.
This patch fixes it.  Changes:

  * keep tsc frequency in a per-cpu variable.
  * handle kvmclock update using a new request flag, thus checking
    whenever we need an update each time we enter guest context.
  * use a cpufreq notifier to track frequency changes and force
    kvmclock updates.
  * send ipis to kick cpu out of guest context if needed to make
    sure the guest doesn't see stale values.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: Use kvm_mmu_page_fault() handle EPT violation mmio
Sheng Yang [Wed, 11 Feb 2009 05:50:40 +0000 (13:50 +0800)]
KVM: VMX: Use kvm_mmu_page_fault() handle EPT violation mmio

Removed duplicated code.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Use irq routing API for MSI
Sheng Yang [Tue, 10 Feb 2009 05:57:06 +0000 (13:57 +0800)]
KVM: Use irq routing API for MSI

Merge MSI userspace interface with IRQ routing table. Notice the API have been
changed, and using IRQ routing table would be the only interface kvm-userspace
supported.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Drop unused evaluations from string pio handlers
Jan Kiszka [Sun, 8 Feb 2009 12:28:15 +0000 (13:28 +0100)]
KVM: Drop unused evaluations from string pio handlers

Looks like neither the direction nor the rep prefix are used anymore.
Drop related evaluations from SVM's and VMX's I/O exit handlers.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Add FFXSR support
Alexander Graf [Mon, 2 Feb 2009 15:23:51 +0000 (16:23 +0100)]
KVM: Add FFXSR support

AMD K10 CPUs implement the FFXSR feature that gets enabled using
EFER. Let's check if the virtual CPU description includes that
CPUID feature bit and allow enabling it then.

This is required for Windows Server 2008 in Hyper-V mode.

v2 adds CPUID capability exposure

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agox86: Add EFER descriptions for FFXSR
Alexander Graf [Mon, 2 Feb 2009 15:23:50 +0000 (16:23 +0100)]
x86: Add EFER descriptions for FFXSR

AMD k10 includes support for the FFXSR feature, which leaves out
XMM registers on FXSAVE/FXSAVE when the EFER_FFXSR bit is set in
EFER.

The CPUID feature bit exists already, but the EFER bit is missing
currently, so this patch adds it to the list of known EFER bits.

Signed-off-by: Alexander Graf <agraf@suse.de>
CC: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: make irq ack notifications aware of routing table
Marcelo Tosatti [Tue, 27 Jan 2009 17:12:38 +0000 (15:12 -0200)]
KVM: make irq ack notifications aware of routing table

IRQ ack notifications assume an identity mapping between pin->gsi,
which might not be the case with, for example, HPET.

Translate before acking.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Acked-by: Gleb Natapov <gleb@redhat.com>
15 years agoKVM: ia64: dynamic nr online cpus
Jes Sorensen [Wed, 21 Jan 2009 14:16:43 +0000 (15:16 +0100)]
KVM: ia64: dynamic nr online cpus

Account for number of online cpus and use that in loops iterating over
the list of vpus instead of scanning the full array unconditionally.
This patch is a building block to facilitate allowing to bump up
the size of MAX_VCPUS significantly.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Acked-by : Xiantao Zhang  <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: s390: Fix SIGP set prefix ioctl
Christian Borntraeger [Thu, 22 Jan 2009 09:29:08 +0000 (10:29 +0100)]
KVM: s390: Fix SIGP set prefix ioctl

This patch fixes the SET PREFIX interrupt if triggered by userspace.
Until now, it was not necessary, but life migration will need it. In
addition, it helped me creating SMP support for my kvm_crashme tool
(lets kvm execute random guest memory content).

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: s390: Fix problem state check for b2 intercepts
Christian Borntraeger [Thu, 22 Jan 2009 09:28:29 +0000 (10:28 +0100)]
KVM: s390: Fix problem state check for b2 intercepts

The kernel handles some priviledged instruction exits. While I was
unable to trigger such an exit from guest userspace, the code should
check for supervisor state before emulating a priviledged instruction.

I also renamed kvm_s390_handle_priv to kvm_s390_handle_b2. After all
there are non priviledged b2 instructions like stck (store clock).

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: s390: Fix printk on SIGP set arch
Christian Borntraeger [Thu, 22 Jan 2009 13:20:27 +0000 (14:20 +0100)]
KVM: s390: Fix printk on SIGP set arch

KVM on s390 does not support the ESA/390 architecture. We refuse to
change the architecture mode and print a warning. This patch removes
the printk for several reasons:

o A malicious guest can flood host dmesg
o The old message had no newline
o there is no connection between the message and the failing guest

This patch simply removes the printk. We already set the condition
code to 3 - the guest knows that something went wrong.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: Implement some pal calls needed for windows 2008
Xiantao Zhang [Wed, 21 Jan 2009 03:21:27 +0000 (11:21 +0800)]
KVM: ia64: Implement some pal calls needed for windows 2008

For windows 2008, it needs more pal calls to implement for booting.
In addition, also changes the name of set_{sal, pal}_call_result to
get_{sal,pal}_call_result for readability.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: Add the support for translating PAL Call's pointer args
Xiantao Zhang [Thu, 15 Jan 2009 10:08:36 +0000 (18:08 +0800)]
KVM: ia64: Add the support for translating PAL Call's pointer args

Add the support to translate PAL Call's pointer args.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: vTLB change for enabling windows 2008 boot
Xiantao Zhang [Thu, 15 Jan 2009 09:58:19 +0000 (17:58 +0800)]
KVM: ia64: vTLB change for enabling windows 2008 boot

Simply the logic of hash vTLB, and export kvm_gpa_to_mpa.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Avoid using CONFIG_ in userspace visible headers
Avi Kivity [Mon, 19 Jan 2009 12:57:52 +0000 (14:57 +0200)]
KVM: Avoid using CONFIG_ in userspace visible headers

Kconfig symbols are not available in userspace, and are not stripped by
headers-install.  Avoid their use by adding #defines in <asm/kvm.h> to
suit each architecture.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Userspace controlled irq routing
Avi Kivity [Wed, 19 Nov 2008 11:58:46 +0000 (13:58 +0200)]
KVM: Userspace controlled irq routing

Currently KVM has a static routing from GSI numbers to interrupts (namely,
0-15 are mapped 1:1 to both PIC and IOAPIC, and 16:23 are mapped 1:1 to
the IOAPIC).  This is insufficient for several reasons:

- HPET requires non 1:1 mapping for the timer interrupt
- MSIs need a new method to assign interrupt numbers and dispatch them
- ACPI APIC mode needs to be able to reassign the PCI LINK interrupts to the
  ioapics

This patch implements an interrupt routing table (as a linked list, but this
can be easily changed) and a userspace interface to replace the table.  The
routing table is initialized according to the current hardwired mapping.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: x86: Fix typos and whitespace errors
Amit Shah [Wed, 14 Jan 2009 16:56:00 +0000 (16:56 +0000)]
KVM: x86: Fix typos and whitespace errors

Some typos, comments, whitespace errors corrected in the cpuid code

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: Move to new TLB invalidate interface
Liu Yu [Wed, 14 Jan 2009 16:47:38 +0000 (10:47 -0600)]
KVM: ppc: Move to new TLB invalidate interface

Commit 2a4aca1144394653269720ffbb5a325a77abd5fa removed old method _tlbia().

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: Fix e500 warnings and some spelling problems
Liu Yu [Wed, 14 Jan 2009 16:47:37 +0000 (10:47 -0600)]
KVM: ppc: Fix e500 warnings and some spelling problems

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agopowerpc/fsl-booke: declare tlbcam_index for use in c
Liu Yu [Wed, 14 Jan 2009 16:47:36 +0000 (10:47 -0600)]
powerpc/fsl-booke: declare tlbcam_index for use in c

So, KVM needs to read tlbcam_index to know exactly
which TLB1 entry is unused by host.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Acked-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Only enable cr4_pge role in shadow mode
Avi Kivity [Sun, 11 Jan 2009 15:19:35 +0000 (17:19 +0200)]
KVM: MMU: Only enable cr4_pge role in shadow mode

Two dimensional paging is only confused by it.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Rename "metaphysical" attribute to "direct"
Avi Kivity [Sun, 11 Jan 2009 11:02:10 +0000 (13:02 +0200)]
KVM: MMU: Rename "metaphysical" attribute to "direct"

This actually describes what is going on, rather than alerting the reader
that something strange is going on.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: drop zeroing on mmu_memory_cache_alloc
Marcelo Tosatti [Thu, 8 Jan 2009 19:44:19 +0000 (17:44 -0200)]
KVM: MMU: drop zeroing on mmu_memory_cache_alloc

Zeroing on mmu_memory_cache_alloc is unnecessary since:

- Smaller areas are pre-allocated with kmem_cache_zalloc.
- Page pointed by ->spt is overwritten with prefetch_page
  and entries in page pointed by ->gfns are initialized
  before reading.

[avi: zeroing pages is unnecessary]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Fix typo in has_svm()
Joe Perches [Thu, 8 Jan 2009 19:05:17 +0000 (11:05 -0800)]
KVM: SVM: Fix typo in has_svm()

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: expose registers in struct kvm_regs
Jes Sorensen [Thu, 8 Jan 2009 12:58:48 +0000 (13:58 +0100)]
KVM: ia64: expose registers in struct kvm_regs

Provide register layout for struct kvm_regs exposed to userland.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Reset PIT irq injection logic when the PIT IRQ is unmasked
Avi Kivity [Sun, 4 Jan 2009 16:06:06 +0000 (18:06 +0200)]
KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked

While the PIT is masked the guest cannot ack the irq, so the reinject logic
will never allow the interrupt to be injected.

Fix by resetting the reinjection counters on unmask.

Unbreaks Xen.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Interrupt mask notifiers for ioapic
Avi Kivity [Sun, 4 Jan 2009 15:10:50 +0000 (17:10 +0200)]
KVM: Interrupt mask notifiers for ioapic

Allow clients to request notifications when the guest masks or unmasks a
particular irq line.  This complements irq ack notifications, as the guest
will not ack an irq line that is masked.

Currently implemented for the ioapic only.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Add CONFIG_HAVE_KVM_IRQCHIP
Avi Kivity [Sun, 4 Jan 2009 16:04:18 +0000 (18:04 +0200)]
KVM: Add CONFIG_HAVE_KVM_IRQCHIP

Two KVM archs support irqchips and two don't.  Add a Kconfig item to
make selecting between the two models easier.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Optimize page unshadowing
Avi Kivity [Tue, 6 Jan 2009 11:00:27 +0000 (13:00 +0200)]
KVM: MMU: Optimize page unshadowing

Using kvm_mmu_lookup_page() will result in multiple scans of the hash chains;
use hlist_for_each_entry_safe() to achieve a single scan instead.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Add microcode patch level dummy
Alexander Graf [Mon, 5 Jan 2009 15:02:47 +0000 (16:02 +0100)]
KVM: SVM: Add microcode patch level dummy

VMware ESX checks if the microcode level is correct when using a barcelona
CPU, in order to see if it actually can use SVM. Let's tell it we're on the
safe side...

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Add support to disable MSI for assigned device
Sheng Yang [Tue, 6 Jan 2009 08:25:11 +0000 (16:25 +0800)]
KVM: Add support to disable MSI for assigned device

MSI is always enabled by default for msi2intx=1. But if msi2intx=0, we
have to disable MSI if guest require to do so.

The patch also discard unnecessary msi2intx judgment if guest want to update
MSI state.

Notice KVM_DEV_IRQ_ASSIGN_MSI_ACTION is a mask which should cover all MSI
related operations, though we only got one for now.

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Remove duplicated prototype of kvm_arch_destroy_vm
Sheng Yang [Tue, 6 Jan 2009 02:03:01 +0000 (10:03 +0800)]
KVM: Remove duplicated prototype of kvm_arch_destroy_vm

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: remove debug support broken by KVM debug rewrite
Hollis Blanchard [Sun, 4 Jan 2009 19:51:09 +0000 (13:51 -0600)]
KVM: ppc: remove debug support broken by KVM debug rewrite

After the rewrite of KVM's debug support, this code doesn't even build any
more.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Properly lock PIT creation
Avi Kivity [Mon, 5 Jan 2009 13:21:42 +0000 (15:21 +0200)]
KVM: Properly lock PIT creation

Otherwise, two threads can create a PIT in parallel and cause a memory leak.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: x86 emulator: implement 'ret far' instruction (opcode 0xcb)
Avi Kivity [Mon, 5 Jan 2009 11:27:34 +0000 (13:27 +0200)]
KVM: x86 emulator: implement 'ret far' instruction (opcode 0xcb)

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: When emulating on invalid vmx state, don't return to userspace unnecessarily
Avi Kivity [Mon, 5 Jan 2009 10:10:54 +0000 (12:10 +0200)]
KVM: VMX: When emulating on invalid vmx state, don't return to userspace unnecessarily

If we aren't doing mmio there's no need to exit to userspace (which will
just be confused).

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: x86 emulator: Make emulate_pop() a little more generic
Avi Kivity [Mon, 5 Jan 2009 09:12:40 +0000 (11:12 +0200)]
KVM: x86 emulator: Make emulate_pop() a little more generic

Allow emulate_pop() to read into arbitrary memory rather than just the
source operand.  Needed for complicated instructions like far returns.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: Prevent exit handler from running if emulating due to invalid state
Avi Kivity [Sun, 4 Jan 2009 22:53:19 +0000 (00:53 +0200)]
KVM: VMX: Prevent exit handler from running if emulating due to invalid state

If we've just emulated an instruction, we won't have any valid exit
reason and associated information.

Fix by moving the clearing of the emulation_required flag to the exit handler.
This way the exit handler can notice that we've been emulating and abort
early.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: don't clobber segment AR if emulating invalid state
Avi Kivity [Sun, 4 Jan 2009 21:43:42 +0000 (23:43 +0200)]
KVM: VMX: don't clobber segment AR if emulating invalid state

The ususable bit is important for determining state validity; don't
clobber it.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: Fix guest state validity checks
Avi Kivity [Sun, 4 Jan 2009 21:26:52 +0000 (23:26 +0200)]
KVM: VMX: Fix guest state validity checks

The vmx guest state validity checks are full of bugs.  Make them
conform to the manual.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: Add extra E500 exceptions
Hollis Blanchard [Sat, 3 Jan 2009 22:23:13 +0000 (16:23 -0600)]
KVM: ppc: Add extra E500 exceptions

e500 has additional interrupt vectors (and corresponding IVORs) for SPE and
performance monitoring interrupts.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: distinguish between interrupts and priorities
Hollis Blanchard [Sat, 3 Jan 2009 22:23:12 +0000 (16:23 -0600)]
KVM: ppc: distinguish between interrupts and priorities

Although BOOKE_MAX_INTERRUPT has the right value, the meaning is not match.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: Add kvmppc_mmu_dtlb/itlb_miss for booke
Hollis Blanchard [Sat, 3 Jan 2009 22:23:11 +0000 (16:23 -0600)]
KVM: ppc: Add kvmppc_mmu_dtlb/itlb_miss for booke

When itlb or dtlb miss happens, E500 needs to update some mmu registers.
So that the auto-load mechanism can work on E500 when write a tlb entry.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: E500 core-specific code
Hollis Blanchard [Sat, 3 Jan 2009 22:23:10 +0000 (16:23 -0600)]
KVM: ppc: E500 core-specific code

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: ifdef iccci with CONFIG_44x
Hollis Blanchard [Sat, 3 Jan 2009 22:23:09 +0000 (16:23 -0600)]
KVM: ppc: ifdef iccci with CONFIG_44x

E500 deosn't support this instruction.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: No need to include core-header for KVM in asm-offsets.c currently
Hollis Blanchard [Sat, 3 Jan 2009 22:23:08 +0000 (16:23 -0600)]
KVM: ppc: No need to include core-header for KVM in asm-offsets.c currently

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: Add dbsr in kvm_vcpu_arch
Hollis Blanchard [Sat, 3 Jan 2009 22:23:07 +0000 (16:23 -0600)]
KVM: ppc: Add dbsr in kvm_vcpu_arch

Kernel for E500 need clear dbsr when startup.
So add dbsr register in kvm_vcpu_arch for BOOKE.

Signed-off-by: Liu Yu <yu.liu@freescale.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: split out common Book E instruction emulation
Hollis Blanchard [Sat, 3 Jan 2009 22:23:06 +0000 (16:23 -0600)]
KVM: ppc: split out common Book E instruction emulation

The Book E code will be shared with e500.

I've left PID in kvmppc_core_emulate_op() just so that we don't need to move
kvmppc_set_pid() right now. Once we have the e500 implementation, we can
probably share that too.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: use macros instead of hardcoded literals for instruction decoding
Hollis Blanchard [Sat, 3 Jan 2009 22:23:05 +0000 (16:23 -0600)]
KVM: ppc: use macros instead of hardcoded literals for instruction decoding

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: remove last 44x-specific bits from booke.c
Hollis Blanchard [Sat, 3 Jan 2009 22:23:04 +0000 (16:23 -0600)]
KVM: ppc: remove last 44x-specific bits from booke.c

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: rename 44x MMU functions used in booke.c
Hollis Blanchard [Sat, 3 Jan 2009 22:23:03 +0000 (16:23 -0600)]
KVM: ppc: rename 44x MMU functions used in booke.c

e500 will provide its own implementation of these.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: turn tlb_xlate() into a per-core hook (and give it a better name)
Hollis Blanchard [Sat, 3 Jan 2009 22:23:02 +0000 (16:23 -0600)]
KVM: ppc: turn tlb_xlate() into a per-core hook (and give it a better name)

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: change kvmppc_mmu_map() parameters
Hollis Blanchard [Sat, 3 Jan 2009 22:23:01 +0000 (16:23 -0600)]
KVM: ppc: change kvmppc_mmu_map() parameters

Passing just the TLB index will ease an e500 implementation.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: small cosmetic changes to Book E DTLB miss handler
Hollis Blanchard [Sat, 3 Jan 2009 22:23:00 +0000 (16:23 -0600)]
KVM: ppc: small cosmetic changes to Book E DTLB miss handler

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: cosmetic changes to mmu hook names
Hollis Blanchard [Sat, 3 Jan 2009 22:22:59 +0000 (16:22 -0600)]
KVM: ppc: cosmetic changes to mmu hook names

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ppc: move struct kvmppc_44x_tlbe into 44x-specific header
Hollis Blanchard [Sat, 3 Jan 2009 22:22:58 +0000 (16:22 -0600)]
KVM: ppc: move struct kvmppc_44x_tlbe into 44x-specific header

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Move struct kvm_pio_request into x86 kvm_host.h
Avi Kivity [Sun, 4 Jan 2009 10:39:07 +0000 (12:39 +0200)]
KVM: Move struct kvm_pio_request into x86 kvm_host.h

This is an x86 specific stucture and has no business living in common code.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: PIT: provide an option to disable interrupt reinjection
Marcelo Tosatti [Tue, 30 Dec 2008 17:55:06 +0000 (15:55 -0200)]
KVM: PIT: provide an option to disable interrupt reinjection

Certain clocks (such as TSC) in older 2.6 guests overaccount for lost
ticks, causing severe time drift. Interrupt reinjection magnifies the
problem.

Provide an option to disable it.

[avi: allow room for expansion in case we want to disable reinjection
      of other timers]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Fallback support for MSR_VM_HSAVE_PA
Avi Kivity [Mon, 29 Dec 2008 15:32:28 +0000 (17:32 +0200)]
KVM: Fallback support for MSR_VM_HSAVE_PA

Since we advertise MSR_VM_HSAVE_PA, userspace will attempt to read it
even on Intel.  Implement fake support for this MSR to avoid the
warnings.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: remove the vmap usage
Izik Eidus [Sun, 28 Dec 2008 23:42:20 +0000 (01:42 +0200)]
KVM: remove the vmap usage

vmap() on guest pages hides those pages from the Linux mm for an extended
(userspace determined) amount of time.  Get rid of it.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: introduce kvm_read_guest_virt, kvm_write_guest_virt
Izik Eidus [Sun, 28 Dec 2008 23:42:19 +0000 (01:42 +0200)]
KVM: introduce kvm_read_guest_virt, kvm_write_guest_virt

This commit change the name of emulator_read_std into kvm_read_guest_virt,
and add new function name kvm_write_guest_virt that allow writing into a
guest virtual address.

Signed-off-by: Izik Eidus <ieidus@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: initialize TSC offset relative to vm creation time
Marcelo Tosatti [Thu, 11 Dec 2008 19:45:05 +0000 (20:45 +0100)]
KVM: VMX: initialize TSC offset relative to vm creation time

VMX initializes the TSC offset for each vcpu at different times, and
also reinitializes it for vcpus other than 0 on APIC SIPI message.

This bug causes the TSC's to appear unsynchronized in the guest, even if
the host is good.

Older Linux kernels don't handle the situation very well, so
gettimeofday is likely to go backwards in time:

http://www.mail-archive.com/kvm@vger.kernel.org/msg02955.html
http://sourceforge.net/tracker/index.php?func=detail&aid=2025534&group_id=180599&atid=893831

Fix it by initializating the offset of each vcpu relative to vm creation
time, and moving it from vmx_vcpu_reset to vmx_vcpu_setup, out of the
APIC MP init path.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Drop walk_shadow()
Avi Kivity [Thu, 25 Dec 2008 13:20:07 +0000 (15:20 +0200)]
KVM: MMU: Drop walk_shadow()

No longer used.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Replace walk_shadow() by for_each_shadow_entry() in invlpg()
Avi Kivity [Thu, 25 Dec 2008 13:19:00 +0000 (15:19 +0200)]
KVM: MMU: Replace walk_shadow() by for_each_shadow_entry() in invlpg()

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Replace walk_shadow() by for_each_shadow_entry() in fetch()
Avi Kivity [Thu, 25 Dec 2008 13:10:50 +0000 (15:10 +0200)]
KVM: MMU: Replace walk_shadow() by for_each_shadow_entry() in fetch()

Effectively reverting to the pre walk_shadow() version -- but now
with the reusable for_each().

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Use for_each_shadow_entry() in __direct_map()
Avi Kivity [Thu, 25 Dec 2008 12:54:25 +0000 (14:54 +0200)]
KVM: MMU: Use for_each_shadow_entry() in __direct_map()

Eliminating a callback and a useless structure.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Add for_each_shadow_entry(), a simpler alternative to walk_shadow()
Avi Kivity [Thu, 25 Dec 2008 12:39:47 +0000 (14:39 +0200)]
KVM: MMU: Add for_each_shadow_entry(), a simpler alternative to walk_shadow()

Using a for_each loop style removes the need to write callback and nasty
casts.

Implement the walk_shadow() using the for_each_shadow_entry().

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Advertise guest debug capability per-arch
Jan Kiszka [Fri, 19 Dec 2008 17:13:54 +0000 (18:13 +0100)]
KVM: Advertise guest debug capability per-arch

Limit KVM_CAP_SET_GUEST_DEBUG only to those archs (currently x86) that
support it. This simplifies user space stub implementations.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Fix vmload and friends misinterpreted as lidt
Avi Kivity [Tue, 23 Dec 2008 17:46:01 +0000 (19:46 +0200)]
KVM: Fix vmload and friends misinterpreted as lidt

The AMD SVM instruction family all overload the 0f 01 /3 opcode, further
multiplexing on the three r/m bits.  But the code decided that anything that
isn't a vmmcall must be an lidt (which shares the 0f 01 /3 opcode, for the
case that mod = 3).

Fix by aborting emulation if this isn't a vmmcall.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Initialize a shadow page's global attribute from cr4.pge
Avi Kivity [Sun, 21 Dec 2008 17:36:59 +0000 (19:36 +0200)]
KVM: MMU: Initialize a shadow page's global attribute from cr4.pge

If cr4.pge is cleared, we ought to treat any ptes in the page as non-global.
This allows us to remove the check from set_spte().

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Segregate mmu pages created with different cr4.pge settings
Avi Kivity [Sun, 21 Dec 2008 17:27:36 +0000 (19:27 +0200)]
KVM: MMU: Segregate mmu pages created with different cr4.pge settings

Don't allow a vcpu with cr4.pge cleared to use a shadow page created with
cr4.pge set; this might cause a cr3 switch not to sync ptes that have the
global bit set (the global bit has no effect if !cr4.pge).

This can only occur on smp with different cr4.pge settings for different
vcpus (since a cr4 change will resync the shadow ptes), but there's no
cost to being correct here.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: MMU: Inherit a shadow page's guest level count from vcpu setup
Avi Kivity [Sun, 21 Dec 2008 17:20:09 +0000 (19:20 +0200)]
KVM: MMU: Inherit a shadow page's guest level count from vcpu setup

Instead of "calculating" it on every shadow page allocation, set it once
when switching modes, and copy it when allocating pages.

This doesn't buy us much, but sets up the stage for inheriting more
information related to the mmu setup.

Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: Code cleanup
Xiantao Zhang [Thu, 18 Dec 2008 02:23:58 +0000 (10:23 +0800)]
KVM: ia64: Code cleanup

Remove some unnecessary blank lines to accord with Kernel's coding style.
Also remove vcpu_get_itir_on_fault due to no reference to it.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: Remove old kvm_guest_debug structs
Jan Kiszka [Thu, 18 Dec 2008 11:33:18 +0000 (12:33 +0100)]
KVM: Remove old kvm_guest_debug structs

Remove the remaining arch fragments of the old guest debug interface
that now break non-x86 builds.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: ia64: stack get/restore patch
Jes Sorensen [Thu, 18 Dec 2008 11:17:51 +0000 (12:17 +0100)]
KVM: ia64: stack get/restore patch

Implement KVM_IA64_VCPU_[GS]ET_STACK ioctl calls. This is required
for live migrations.

Patch is based on previous implementation that was part of old
GET/SET_REGS ioctl calls.

Signed-off-by: Jes Sorensen <jes@sgi.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: x86: Wire-up hardware breakpoints for guest debugging
Jan Kiszka [Mon, 15 Dec 2008 12:52:10 +0000 (13:52 +0100)]
KVM: x86: Wire-up hardware breakpoints for guest debugging

Add the remaining bits to make use of debug registers also for guest
debugging, thus enabling the use of hardware breakpoints and
watchpoints.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: x86: Virtualize debug registers
Jan Kiszka [Mon, 15 Dec 2008 12:52:10 +0000 (13:52 +0100)]
KVM: x86: Virtualize debug registers

So far KVM only had basic x86 debug register support, once introduced to
realize guest debugging that way. The guest itself was not able to use
those registers.

This patch now adds (almost) full support for guest self-debugging via
hardware registers. It refactors the code, moving generic parts out of
SVM (VMX was already cleaned up by the KVM_SET_GUEST_DEBUG patches), and
it ensures that the registers are properly switched between host and
guest.

This patch also prepares debug register usage by the host. The latter
will (once wired-up by the following patch) allow for hardware
breakpoints/watchpoints in guest code. If this is enabled, the guest
will only see faked debug registers without functionality, but with
content reflecting the guest's modifications.

Tested on Intel only, but SVM /should/ work as well, but who knows...

Known limitations: Trapping on tss switch won't work - most probably on
Intel.

Credits also go to Joerg Roedel - I used his once posted debugging
series as platform for this patch.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: Allow single-stepping when uninterruptible
Jan Kiszka [Mon, 15 Dec 2008 12:52:10 +0000 (13:52 +0100)]
KVM: VMX: Allow single-stepping when uninterruptible

When single-stepping over STI and MOV SS, we must clear the
corresponding interruptibility bits in the guest state. Otherwise
vmentry fails as it then expects bit 14 (BS) in pending debug exceptions
being set, but that's not correct for the guest debugging case.

Note that clearing those bits is safe as we check for interruptibility
based on the original state and do not inject interrupts or NMIs if
guest interruptibility was blocked.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: New guest debug interface
Jan Kiszka [Mon, 15 Dec 2008 12:52:10 +0000 (13:52 +0100)]
KVM: New guest debug interface

This rips out the support for KVM_DEBUG_GUEST and introduces a new IOCTL
instead: KVM_SET_GUEST_DEBUG. The IOCTL payload consists of a generic
part, controlling the "main switch" and the single-step feature. The
arch specific part adds an x86 interface for intercepting both types of
debug exceptions separately and re-injecting them when the host was not
interested. Moveover, the foundation for guest debugging via debug
registers is layed.

To signal breakpoint events properly back to userland, an arch-specific
data block is now returned along KVM_EXIT_DEBUG. For x86, the arch block
contains the PC, the debug exception, and relevant debug registers to
tell debug events properly apart.

The availability of this new interface is signaled by
KVM_CAP_SET_GUEST_DEBUG. Empty stubs for not yet supported archs are
provided.

Note that both SVM and VTX are supported, but only the latter was tested
yet. Based on the experience with all those VTX corner case, I would be
fairly surprised if SVM will work out of the box.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: VMX: Support for injecting software exceptions
Jan Kiszka [Mon, 15 Dec 2008 12:52:10 +0000 (13:52 +0100)]
KVM: VMX: Support for injecting software exceptions

VMX differentiates between processor and software generated exceptions
when injecting them into the guest. Extend vmx_queue_exception
accordingly (and refactor related constants) so that we can use this
service reliably for the new guest debugging framework.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Only allow setting of EFER_SVME when CPUID SVM is set
Alexander Graf [Tue, 25 Nov 2008 19:17:11 +0000 (20:17 +0100)]
KVM: SVM: Only allow setting of EFER_SVME when CPUID SVM is set

Userspace has to tell the kernel module somehow that nested SVM should be used.
The easiest way that doesn't break anything I could think of is to implement

if (cpuid & svm)
    allow write to efer
else
    deny write to efer

Old userspaces mask the SVM capability bit, so they don't break.
In order to find out that the SVM capability is set, I had to split the
kvm_emulate_cpuid into a finding and an emulating part.

(introduced in v6)

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Allow setting the SVME bit
Alexander Graf [Tue, 25 Nov 2008 19:17:10 +0000 (20:17 +0100)]
KVM: SVM: Allow setting the SVME bit

Normally setting the SVME bit in EFER is not allowed, as we did
not support SVM. Not since we do, we should also allow enabling
SVM mode.

v2 comes as last patch, so we don't enable half-ready code
v4 introduces a module option to enable SVM
v6 warns that nesting is enabled

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Allow read access to MSR_VM_VR
Joerg Roedel [Tue, 25 Nov 2008 19:17:09 +0000 (20:17 +0100)]
KVM: SVM: Allow read access to MSR_VM_VR

KVM tries to read the VM_CR MSR to find out if SVM was disabled by
the BIOS. So implement read support for this MSR to make nested
SVM running.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Add VMEXIT handler and intercepts
Alexander Graf [Tue, 25 Nov 2008 19:17:08 +0000 (20:17 +0100)]
KVM: SVM: Add VMEXIT handler and intercepts

This adds the #VMEXIT intercept, so we return to the level 1 guest
when something happens in the level 2 guest that should return to
the level 1 guest.

v2 implements HIF handling and cleans up exception interception
v3 adds support for V_INTR_MASKING_MASK
v4 uses the host page hsave
v5 removes IOPM merging code
v6 moves mmu code out of the atomic section

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Add VMRUN handler
Alexander Graf [Tue, 25 Nov 2008 19:17:07 +0000 (20:17 +0100)]
KVM: SVM: Add VMRUN handler

This patch implements VMRUN. VMRUN enters a virtual CPU and runs that
in the same context as the normal guest CPU would run.
So basically it is implemented the same way, a normal CPU would do it.

We also prepare all intercepts that get OR'ed with the original
intercepts, as we do not allow a level 2 guest to be intercepted less
than the first level guest.

v2 implements the following improvements:

- fixes the CPL check
- does not allocate iopm when not used
- remembers the host's IF in the HIF bit in the hflags

v3:

- make use of the new permission checking
- add support for V_INTR_MASKING_MASK

v4:

- use host page backed hsave

v5:

- remove IOPM merging code

v6:

- save cr4 so PAE l1 guests work

v7:

- return 0 on vmrun so we check the MSRs too
- fix MSR check to use the correct variable

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Add VMLOAD and VMSAVE handlers
Alexander Graf [Tue, 25 Nov 2008 19:17:06 +0000 (20:17 +0100)]
KVM: SVM: Add VMLOAD and VMSAVE handlers

This implements the VMLOAD and VMSAVE instructions, that usually surround
the VMRUN instructions. Both instructions load / restore the same elements,
so we only need to implement them once.

v2 fixes CPL checking and replaces memcpy by assignments
v3 makes use of the new permission checking

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Implement hsave
Alexander Graf [Tue, 25 Nov 2008 19:17:05 +0000 (20:17 +0100)]
KVM: SVM: Implement hsave

Implement the hsave MSR, that gives the VCPU a GPA to save the
old guest state in.

v2 allows userspace to save/restore hsave
v4 dummys out the hsave MSR, so we use a host page
v6 remembers the guest's hsave and exports the MSR

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Implement GIF, clgi and stgi
Alexander Graf [Tue, 25 Nov 2008 19:17:04 +0000 (20:17 +0100)]
KVM: SVM: Implement GIF, clgi and stgi

This patch implements the GIF flag and the clgi and stgi instructions that
set this flag. Only if the flag is set (default), interrupts can be received by
the CPU.

To keep the information about that somewhere, this patch adds a new hidden
flags vector. that is used to store information that does not go into the
vmcb, but is SVM specific.

I tried to write some code to make -no-kvm-irqchip work too, but the first
level guest won't even boot with that atm, so I ditched it.

v2 moves the hflags to x86 generic code
v3 makes use of the new permission helper
v6 only enables interrupt_window if GIF=1

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Add helper functions for nested SVM
Alexander Graf [Tue, 25 Nov 2008 19:17:03 +0000 (20:17 +0100)]
KVM: SVM: Add helper functions for nested SVM

These are helpers for the nested SVM implementation.

- nsvm_printk implements a debug printk variant
- nested_svm_do calls a handler that can accesses gpa-based memory

v3 makes use of the new permission checker
v6 changes:
- streamline nsvm_debug()
- remove printk(KERN_ERR)
- SVME check before CPL check
- give GP error code
- use new EFER constant

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Move EFER and MSR constants to generic x86 code
Alexander Graf [Tue, 25 Nov 2008 19:17:02 +0000 (20:17 +0100)]
KVM: SVM: Move EFER and MSR constants to generic x86 code

MSR_EFER_SVME_MASK, MSR_VM_CR and MSR_VM_HSAVE_PA are set in KVM
specific headers. Linux does have nice header files to collect
EFER bits and MSR IDs, so IMHO we should put them there.

While at it, I also changed the naming scheme to match that
of the other defines.

(introduced in v6)

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoKVM: SVM: Clean up VINTR setting
Alexander Graf [Tue, 25 Nov 2008 19:17:01 +0000 (20:17 +0100)]
KVM: SVM: Clean up VINTR setting

The current VINTR intercept setters don't look clean to me. To make
the code easier to read and enable the possibilty to trap on a VINTR
set, this uses a helper function to set the VINTR intercept.

v2 uses two distinct functions for setting and clearing the bit

Acked-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
15 years agoLinux 2.6.29 v2.6.29
Linus Torvalds [Mon, 23 Mar 2009 23:12:14 +0000 (16:12 -0700)]
Linux 2.6.29

15 years agoBuild with -fno-dwarf2-cfi-asm
Kyle McMartin [Mon, 23 Mar 2009 19:25:49 +0000 (15:25 -0400)]
Build with -fno-dwarf2-cfi-asm

With a sufficiently new compiler and binutils, code which wasn't
previously generating .eh_frame sections has begun to.  Certain
architectures (powerpc, in this case) may generate unexpected relocation
formats in response to this, preventing modules from loading.

While the new relocation types should probably be handled, revert to the
previous behaviour with regards to generation of .eh_frame sections.

(This was reported against Fedora, which appears to be the only distro
doing any building against gcc-4.4 at present: RH bz#486545.)

Signed-off-by: Kyle McMartin <kyle@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Cc: Alexandre Oliva <aoliva@redhat.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agotrivial: fix orphan dates in ext2 documentation
Jody McIntyre [Mon, 23 Mar 2009 17:13:34 +0000 (13:13 -0400)]
trivial: fix orphan dates in ext2 documentation

Revert the change to the orphan dates of Windows 95, DOS, compression.
Add a new orphan date for OS/2.

Signed-off-by: Jody McIntyre <scjody@sun.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Linus Torvalds [Mon, 23 Mar 2009 16:25:58 +0000 (09:25 -0700)]
Merge git://git./linux/kernel/git/davem/net-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (32 commits)
  ucc_geth: Fix oops when using fixed-link support
  dm9000: locking bugfix
  net: update dnet.c for bus_id removal
  dnet: DNET should depend on HAS_IOMEM
  dca: add missing copyright/license headers
  nl80211: Check that function pointer != NULL before using it
  sungem: missing net_device_ops
  be2net: fix to restore vlan ids into BE2 during a IF DOWN->UP cycle
  be2net: replenish when posting to rx-queue is starved in out of mem conditions
  bas_gigaset: correctly allocate USB interrupt transfer buffer
  smsc911x: reset last known duplex and carrier on open
  sh_eth: Fix mistake of the address of SH7763
  sh_eth: Change handling of IRQ
  netns: oops in ip[6]_frag_reasm incrementing stats
  net: kfree(napi->skb) => kfree_skb
  net: fix sctp breakage
  ipv6: fix display of local and remote sit endpoints
  net: Document /proc/sys/net/core/netdev_budget
  tulip: fix crash on iface up with shirq debug
  virtio_net: Make virtio_net support carrier detection
  ...

15 years agoMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
Linus Torvalds [Mon, 23 Mar 2009 16:25:24 +0000 (09:25 -0700)]
Merge git://git./linux/kernel/git/davem/sparc-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc64: Fix crash with /proc/iomem
  sparc64: Reschedule KGDB capture to a software interrupt.
  sbus: Auto-load openprom module when device opened.

15 years agofix ptrace slowness
Miklos Szeredi [Mon, 23 Mar 2009 15:07:24 +0000 (16:07 +0100)]
fix ptrace slowness

This patch fixes bug #12208:

  Bug-Entry       : http://bugzilla.kernel.org/show_bug.cgi?id=12208
  Subject         : uml is very slow on 2.6.28 host

This turned out to be not a scheduler regression, but an already
existing problem in ptrace being triggered by subtle scheduler
changes.

The problem is this:

 - task A is ptracing task B
 - task B stops on a trace event
 - task A is woken up and preempts task B
 - task A calls ptrace on task B, which does ptrace_check_attach()
 - this calls wait_task_inactive(), which sees that task B is still on the runq
 - task A goes to sleep for a jiffy
 - ...

Since UML does lots of the above sequences, those jiffies quickly add
up to make it slow as hell.

This patch solves this by not rescheduling in read_unlock() after
ptrace_stop() has woken up the tracer.

Thanks to Oleg Nesterov and Ingo Molnar for the feedback.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
CC: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
15 years agoMerge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/galak/powerpc
Linus Torvalds [Mon, 23 Mar 2009 15:03:09 +0000 (08:03 -0700)]
Merge branch 'merge' of git://git./linux/kernel/git/galak/powerpc

* 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/galak/powerpc:
  powerpc/mm: Fix Respect _PAGE_COHERENT on classic ppc32 SW TLB load machines