Mohammed Gamal [Wed, 27 Aug 2008 02:02:56 +0000 (05:02 +0300)]
KVM: x86 emulator: Add mov r, imm instructions (opcodes 0xb0-0xbf)
The emulator only supported one instance of mov r, imm instruction
(opcode 0xb8), this adds the rest of these instructions.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 26 Aug 2008 14:31:31 +0000 (17:31 +0300)]
KVM: Don't call get_user_pages(.force = 1)
This is esoteric and only needed to break COW on MAP_SHARED mappings. Since
KVM no longer does these sorts of mappings, breaking COW on them is no longer
necessary.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 26 Aug 2008 14:22:47 +0000 (17:22 +0300)]
KVM: Allocate guest memory as MAP_PRIVATE, not MAP_SHARED
There is no reason to share internal memory slots with fork()ed instances.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 22 Aug 2008 16:11:39 +0000 (19:11 +0300)]
KVM: MMU: Convert the paging mode shadow walk to use the generic walker
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 22 Aug 2008 16:28:04 +0000 (19:28 +0300)]
KVM: MMU: Convert direct maps to use the generic shadow walker
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 22 Aug 2008 16:24:38 +0000 (19:24 +0300)]
KVM: MMU: Add generic shadow walker
We currently walk the shadow page tables in two places: direct map (for
real mode and two dimensional paging) and paging mode shadow. Since we
anticipate requiring a third walk (for invlpg), it makes sense to have
a generic facility for shadow walk.
This patch adds such a shadow walker, walks the page tables and calls a
method for every spte encountered. The method can examine the spte,
modify it, or even instantiate it. The walk can be aborted by returning
nonzero from the method.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 26 Aug 2008 13:16:08 +0000 (16:16 +0300)]
KVM: MMU: Infer shadow root level in direct_map()
In all cases the shadow root level is available in mmu.shadow_root_level,
so there is no need to pass it as a parameter.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Xiantao Zhang [Tue, 26 Aug 2008 00:58:53 +0000 (08:58 +0800)]
KVM: ia64: Enable virtio driver for ia64 in Kconfig
kvm/ia64 uses the virtio drivers to optimize its I/O subsytem.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 22 Aug 2008 16:14:17 +0000 (19:14 +0300)]
KVM: MMU: Unify direct map 4K and large page paths
The two paths are equivalent except for one argument, which is already
available. Merge the two codepaths.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 21 Aug 2008 14:49:56 +0000 (17:49 +0300)]
KVM: MMU: Move SHADOW_PT_INDEX to mmu.c
It is not specific to the paging mode, so can be made global (and reusable).
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 21 Aug 2008 14:41:39 +0000 (17:41 +0300)]
KVM: x86 emulator: remove bad ByteOp specifier from NEG descriptor
Signed-off-by: Avi Kivity <avi@qumranet.com>
roel kluin [Tue, 19 Aug 2008 01:25:01 +0000 (21:25 -0400)]
KVM: x86 emulator: remove duplicate SrcImm
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 20 Aug 2008 12:51:42 +0000 (15:51 +0300)]
KVM: Load real mode segments correctly
Real mode segments to not reference the GDT or LDT; they simply compute
base = selector * 16.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 20 Aug 2008 12:48:27 +0000 (15:48 +0300)]
KVM: VMX: Change segment dpl at reset to 3
This is more emulation friendly, if not 100% correct.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 20 Aug 2008 12:07:31 +0000 (15:07 +0300)]
KVM: VMX: Change cs reset state to be a data segment
Real mode cs is a data segment, not a code segment.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Xiantao Zhang [Tue, 19 Aug 2008 12:48:03 +0000 (20:48 +0800)]
KVM: ia64: add a dummy irq ack notification
Before enabling notify_acked_irq for ia64, leave the related APIs as
nop-op first.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Harvey Harrison [Mon, 11 Aug 2008 23:54:20 +0000 (16:54 -0700)]
KVM: make irq ack notifier functions static
sparse says:
arch/x86/kvm/x86.c:107:32: warning: symbol 'kvm_find_assigned_dev' was not declared. Should it be static?
arch/x86/kvm/i8254.c:225:6: warning: symbol 'kvm_pit_ack_irq' was not declared. Should it be static?
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Amit Shah [Mon, 18 Aug 2008 12:07:05 +0000 (15:07 +0300)]
KVM: Use kvm_set_irq to inject interrupts
... instead of using the pic and ioapic variants
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Amit Shah [Mon, 18 Aug 2008 10:11:46 +0000 (13:11 +0300)]
KVM: SVM: Fix typo
Fix typo in as-yet unused macro definition.
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Mohammed Gamal [Sun, 17 Aug 2008 13:42:16 +0000 (16:42 +0300)]
KVM: VMX: Modify mode switching and vmentry functions
This patch modifies mode switching and vmentry function in order to
drive invalid guest state emulation.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Mohammed Gamal [Sun, 17 Aug 2008 13:47:05 +0000 (16:47 +0300)]
KVM: VMX: Add invalid guest state handler
This adds the invalid guest state handler function which invokes the x86
emulator until getting the guest to a VMX-friendly state.
[avi: leave atomic context if scheduling]
[guillaume: return to atomic context correctly]
Signed-off-by: Laurent Vivier <laurent.vivier@bull.net>
Signed-off-by: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Mohammed Gamal [Sun, 17 Aug 2008 13:39:48 +0000 (16:39 +0300)]
KVM: VMX: Add module parameter and emulation flag.
The patch adds the module parameter required to enable emulating invalid
guest state, as well as the emulation_required flag used to drive
emulation whenever needed.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Mohammed Gamal [Sun, 17 Aug 2008 13:38:32 +0000 (16:38 +0300)]
KVM: VMX: Add Guest State Validity Checks
This patch adds functions to check whether guest state is VMX compliant.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Amit Shah [Wed, 13 Aug 2008 13:22:37 +0000 (16:22 +0300)]
KVM: Device assignment: Check for privileges before assigning irq
Even though we don't share irqs at the moment, we should ensure
regular user processes don't try to allocate system resources.
We check for capability to access IO devices (CAP_SYS_RAWIO) before
we request_irq on behalf of the guest.
Noticed by Avi.
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sun, 17 Aug 2008 13:03:46 +0000 (16:03 +0300)]
KVM: Handle spurious acks for PIT interrupts
Spurious acks can be generated, for example if the PIC is being reset.
Handle those acks gracefully rather than flooding the log with warnings.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Thu, 14 Aug 2008 23:53:25 +0000 (20:53 -0300)]
KVM: fix i8259 reset irq acking
The irq ack during pic reset has three problems:
- Ignores slave/master PIC, using gsi 0-8 for both.
- Generates an ACK even if the APIC is in control.
- Depends upon IMR being clear, which is broken if the irq was masked
at the time it was generated.
The last one causes the BIOS to hang after the first reboot of
Windows installation, since PIT interrupts stop.
[avi: fix check whether pic interrupts are seen by cpu]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 14 Aug 2008 18:25:47 +0000 (21:25 +0300)]
KVM: Simplify exception entries by using __ASM_SIZE and _ASM_PTR
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 14 Aug 2008 08:13:16 +0000 (11:13 +0300)]
KVM: VMX: Use interrupt queue for !irqchip_in_kernel
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Fri, 1 Aug 2008 23:09:13 +0000 (20:09 -0300)]
KVM: set debug registers after "schedulable" section
The vcpu thread can be preempted after the guest_debug_pre() callback,
resulting in invalid debug registers on the new vcpu.
Move it inside the non-preemptable section.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Ben-Ami Yassour [Tue, 5 Aug 2008 12:30:13 +0000 (15:30 +0300)]
KVM: remove unused field from the assigned dev struct
Remove unused field: struct kvm_assigned_pci_dev assigned_dev
from struct: struct kvm_assigned_dev_kernel
Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Sheng Yang [Wed, 13 Aug 2008 06:10:33 +0000 (14:10 +0800)]
KVM: VMX: Clean up magic number 0x66 in init_rmode_tss
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Dave Hansen [Mon, 11 Aug 2008 17:01:49 +0000 (10:01 -0700)]
KVM: Reduce stack usage in kvm_pv_mmu_op()
We're in a hot path. We can't use kmalloc() because
it might impact performance. So, we just stick the buffer that
we need into the kvm_vcpu_arch structure. This is used very
often, so it is not really a waste.
We also have to move the buffer structure's definition to the
arch-specific x86 kvm header.
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Dave Hansen [Mon, 11 Aug 2008 17:01:47 +0000 (10:01 -0700)]
KVM: Reduce stack usage in kvm_arch_vcpu_ioctl()
[sheng: fix KVM_GET_LAPIC using wrong size]
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Dave Hansen [Mon, 11 Aug 2008 17:01:46 +0000 (10:01 -0700)]
KVM: Reduce stack usage in kvm_vcpu_ioctl()
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Dave Hansen [Mon, 11 Aug 2008 17:01:45 +0000 (10:01 -0700)]
KVM: Reduce kvm stack usage in kvm_arch_vm_ioctl()
On my machine with gcc 3.4, kvm uses ~2k of stack in a few
select functions. This is mostly because gcc fails to
notice that the different case: statements could have their
stack usage combined. It overflows very nicely if interrupts
happen during one of these large uses.
This patch uses two methods for reducing stack usage.
1. dynamically allocate large objects instead of putting
on the stack.
2. Use a union{} member for all of the case variables. This
tricks gcc into combining them all into a single stack
allocation. (There's also a comment on this)
Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Ben-Ami Yassour [Mon, 28 Jul 2008 16:26:26 +0000 (19:26 +0300)]
KVM: pci device assignment
Based on a patch from: Amit Shah <amit.shah@qumranet.com>
This patch adds support for handling PCI devices that are assigned to
the guest.
The device to be assigned to the guest is registered in the host kernel
and interrupt delivery is handled. If a device is already assigned, or
the device driver for it is still loaded on the host, the device
assignment is failed by conveying a -EBUSY reply to the userspace.
Devices that share their interrupt line are not supported at the moment.
By itself, this patch will not make devices work within the guest.
The VT-d extension is required to enable the device to perform DMA.
Another alternative is PVDMA.
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com>
Signed-off-by: Weidong Han <weidong.han@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Ben-Ami Yassour [Mon, 28 Jul 2008 16:26:24 +0000 (19:26 +0300)]
KVM: direct mmio pfn check
Userspace may specify memory slots that are backed by mmio pages rather than
normal RAM. In some cases it is not enough to identify these mmio pages
by pfn_valid(). This patch adds checking the PageReserved as well.
Signed-off-by: Ben-Ami Yassour <benami@il.ibm.com>
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Glauber Costa [Mon, 28 Jul 2008 14:47:53 +0000 (11:47 -0300)]
x86: KVM guest: use paravirt function to calculate cpu khz
We're currently facing timing problems in guests that do
calibration under heavy load, and then the load vanishes.
This means we'll have a much lower lpj than we actually should,
and delays end up taking less time than they should, which is a
nasty bug.
Solution is to pass on the lpj value from host to guest, and have it
preset.
Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Glauber Costa [Mon, 28 Jul 2008 14:47:52 +0000 (11:47 -0300)]
x86: paravirt: factor out cpu_khz to common code
KVM intends to use paravirt code to calibrate khz. Xen
current code will do just fine. So as a first step, factor out
code to pvclock.c.
Signed-off-by: Glauber Costa <gcosta@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Sat, 26 Jul 2008 20:01:01 +0000 (17:01 -0300)]
KVM: PIT: fix injection logic and count
The PIT injection logic is problematic under the following cases:
1) If there is a higher priority vector to be delivered by the time
kvm_pit_timer_intr_post is invoked ps->inject_pending won't be set.
This opens the possibility for missing many PIT event injections (say if
guest executes hlt at this point).
2) ps->inject_pending is racy with more than two vcpus. Since there's no locking
around read/dec of pt->pending, two vcpu's can inject two interrupts for a single
pt->pending count.
Fix 1 by using an irq ack notifier: only reinject when the previous irq
has been acked. Fix 2 with appropriate locking around manipulation of
pending count and irq_ack by the injection / ack paths.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Sat, 26 Jul 2008 20:01:00 +0000 (17:01 -0300)]
KVM: irq ack notification
Based on a patch from: Ben-Ami Yassour <benami@il.ibm.com>
which was based on a patch from: Amit Shah <amit.shah@qumranet.com>
Notify IRQ acking on PIC/APIC emulation. The previous patch missed two things:
- Edge triggered interrupts on IOAPIC
- PIC reset with IRR/ISR set should be equivalent to ack (LAPIC probably
needs something similar).
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
CC: Amit Shah <amit.shah@qumranet.com>
CC: Ben-Ami Yassour <benami@il.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Sat, 26 Jul 2008 20:00:59 +0000 (17:00 -0300)]
KVM: Add irq ack notifier list
This can be used by kvm subsystems that are interested in when
interrupts are acked, for example time drift compensation.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Fri, 25 Jul 2008 18:54:53 +0000 (13:54 -0500)]
KVM: powerpc: Map guest userspace with TID=0 mappings
When we use TID=N userspace mappings, we must ensure that kernel mappings have
been destroyed when entering userspace. Using TID=1/TID=0 for kernel/user
mappings and running userspace with PID=0 means that userspace can't access the
kernel mappings, but the kernel can directly access userspace.
The net is that we don't need to flush the TLB on privilege switches, but we do
on guest context switches (which are far more infrequent). Guest boot time
performance improvement: about 30%.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Fri, 25 Jul 2008 18:54:52 +0000 (13:54 -0500)]
KVM: ppc: Write only modified shadow entries into the TLB on exit
Track which TLB entries need to be written, instead of overwriting everything
below the high water mark. Typically only a single guest TLB entry will be
modified in a single exit.
Guest boot time performance improvement: about 15%.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Fri, 25 Jul 2008 18:54:51 +0000 (13:54 -0500)]
KVM: ppc: Stop saving host TLB state
We're saving the host TLB state to memory on every exit, but never using it.
Originally I had thought that we'd want to restore host TLB for heavyweight
exits, but that could actually hurt when context switching to an unrelated host
process (i.e. not qemu).
Since this decreases the performance penalty of all exits, this patch improves
guest boot time by about 15%.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Fri, 25 Jul 2008 18:54:49 +0000 (13:54 -0500)]
KVM: ppc: guest breakpoint support
Allow host userspace to program hardware debug registers to set breakpoints
inside guests.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Alexander Graf [Tue, 22 Jul 2008 06:00:45 +0000 (08:00 +0200)]
KVM: Ignore DEBUGCTL MSRs with no effect
Netware writes to DEBUGCTL and reads from the DEBUGCTL and LAST*IP MSRs
without further checks and is really confused to receive a #GP during that.
To make it happy we should just make them stubs, which is exactly what SVM
already does.
Writes to DEBUGCTL that are vendor-specific are resembled to behave as if the
virtual CPU does not know them.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 17 Jul 2008 15:04:30 +0000 (18:04 +0300)]
KVM: VMX: Avoid vmwrite(HOST_RSP) when possible
Usually HOST_RSP retains its value across guest entries. Take advantage
of this and avoid a vmwrite() when this is so.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Christian Ehrhardt [Mon, 14 Jul 2008 12:00:04 +0000 (14:00 +0200)]
KVM: ppc: trace powerpc instruction emulation
This patch adds a trace point for the instruction emulation on embedded powerpc
utilizing the KVM_TRACE interface.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 14 Jul 2008 12:00:03 +0000 (14:00 +0200)]
KVM: ppc: adds trace points for ppc tlb activity
This patch adds trace points to track powerpc TLB activities using the
KVM_TRACE infrastructure.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jerone Young [Mon, 14 Jul 2008 12:00:02 +0000 (14:00 +0200)]
KVM: ppc: enable KVM_TRACE building for powerpc
This patch enables KVM_TRACE to build for PowerPC arch. This means just
adding sections to Kconfig and Makefile.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Christian Ehrhardt [Mon, 14 Jul 2008 12:00:01 +0000 (14:00 +0200)]
KVM: kvmtrace: replace get_cycles with ktime_get v3
The current kvmtrace code uses get_cycles() while the interpretation would be
easier using using nanoseconds. ktime_get() should give at least the same
accuracy as get_cycles on all architectures (even better on 32bit archs) but
at a better unit (e.g. comparable between hosts with different frequencies.
[avi: avoid ktime_t in public header]
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Christian Ehrhardt [Mon, 14 Jul 2008 12:00:00 +0000 (14:00 +0200)]
KVM: kvmtrace: Remove use of bit fields in kvm trace structure
This patch fixes kvmtrace use on big endian systems. When using bit fields the
compiler will lay data out in the wrong order expected when laid down into a
file.
This fixes it by using one variable instead of using bit fields.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Mon, 14 Jul 2008 11:44:59 +0000 (14:44 +0300)]
KVM: SVM: Unify register save/restore across 32 and 64 bit hosts
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Mon, 14 Jul 2008 11:44:59 +0000 (14:44 +0300)]
KVM: VMX: Unify register save/restore across 32 and 64 bit hosts
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jan Kiszka [Mon, 14 Jul 2008 10:28:51 +0000 (12:28 +0200)]
KVM: VMX: Reinject real mode exception
As we execute real mode guests in VM86 mode, exception have to be
reinjected appropriately when the guest triggered them. For this purpose
the patch adopts the real-mode injection pattern used in vmx_inject_irq
to vmx_queue_exception, additionally taking care that the IP is set
correctly for #BP exceptions. Furthermore it extends
handle_rmode_exception to reinject all those exceptions that can be
raised in real mode.
This fixes the execution of himem.exe from FreeDOS and also makes its
debug.com work properly.
Note that guest debugging in real mode is broken now. This has to be
fixed by the scheduled debugging infrastructure rework (will be done
once base patches for QEMU have been accepted).
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Jan Kiszka [Sun, 13 Jul 2008 11:40:55 +0000 (13:40 +0200)]
KVM: Consolidate XX_VECTOR defines
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Mon, 7 Jul 2008 11:45:39 +0000 (14:45 +0300)]
KVM: Consolidate PIC isr clearing into a function
Signed-off-by: Avi Kivity <avi@qumranet.com>
Mohammed Gamal [Sat, 12 Jul 2008 13:02:08 +0000 (16:02 +0300)]
KVM: VMX: Remove redundant check in handle_rmode_exception
Since checking for vcpu->arch.rmode.active is already done whenever we
call handle_rmode_exception(), checking it inside the function is redundant.
Signed-off-by: Mohammed Gamal <m.gamal005@gmail.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 3 Jul 2008 13:14:28 +0000 (16:14 +0300)]
KVM: VMX: Move interrupt post-processing to vmx_complete_interrupts()
Instead of looking at failed injections in the vm entry path, move
processing to the exit path in vmx_complete_interrupts(). This simplifes
the logic and removes any state that is hidden in vmx registers.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 3 Jul 2008 12:17:01 +0000 (15:17 +0300)]
KVM: Add a pending interrupt queue
Similar to the exception queue, this hold interrupts that have been
accepted by the virtual processor core but not yet injected.
Not yet used.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 3 Jul 2008 11:50:12 +0000 (14:50 +0300)]
KVM: VMX: Fix pending exception processing
The vmx code assumes that IDT-Vectoring can only be set when an exception
is injected due to the exception in question. That's not true, however:
if the exception is injected correctly, and later another exception occurs
but its delivery is blocked due to a fault, then we will incorrectly assume
the first exception was not delivered.
Fix by unconditionally dequeuing the pending exception, and requeuing it
(or the second exception) if we see it in the IDT-Vectoring field.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Thu, 3 Jul 2008 11:59:22 +0000 (14:59 +0300)]
KVM: Clear exception queue before emulating an instruction
If we're emulating an instruction, either it will succeed, in which case
any previously queued exception will be spurious, or we will requeue the
same exception.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Wed, 2 Jul 2008 06:28:55 +0000 (09:28 +0300)]
KVM: VMX: Move nmi injection failure processing to vm exit path
Instead of processing nmi injection failure in the vm entry path, move
it to the vm exit path (vm_complete_interrupts()). This separates nmi
injection from nmi post-processing, and moves the nmi state from the VT
state into vcpu state (new variable nmi_injected specifying an injection
in progress).
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Tue, 1 Jul 2008 13:20:21 +0000 (16:20 +0300)]
KVM: Move NMI IRET fault processing to new vmx_complete_interrupts()
Currently most interrupt exit processing is handled on the entry path,
which is confusing. Move the NMI IRET fault processing to a new function,
vmx_complete_interrupts(), which is called on the vmexit path.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 11 Jul 2008 15:07:26 +0000 (18:07 +0300)]
KVM: MMU: Simplify kvm_mmu_zap_page()
The twisty maze of conditionals can be reduced.
[joerg: fix tlb flushing]
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity [Fri, 11 Jul 2008 14:59:46 +0000 (17:59 +0300)]
KVM: MMU: Separate the code for unlinking a shadow page from its parents
Place into own function, in preparation for further cleanups.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Amit Shah [Fri, 27 Jun 2008 12:55:02 +0000 (15:55 +0300)]
KVM: Introduce kvm_set_irq to inject interrupts in guests
This function injects an interrupt into the guest given the kvm struct,
the (guest) irq number and the interrupt level.
Signed-off-by: Amit Shah <amit.shah@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Hollis Blanchard [Tue, 1 Jul 2008 21:23:49 +0000 (16:23 -0500)]
KVM: Move KVM TRACE DEFINITIONS to common header
Move KVM trace definitions from x86 specific kvm headers to common kvm
headers to create a cross-architecture numbering scheme for trace
events. This means the kvmtrace_format userspace tool won't need to know
which architecture produced the log file being processed.
Signed-off-by: Jerone Young <jyoung5@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Marcelo Tosatti [Fri, 27 Jun 2008 17:58:02 +0000 (14:58 -0300)]
KVM: x86: accessors for guest registers
As suggested by Avi, introduce accessors to read/write guest registers.
This simplifies the ->cache_regs/->decache_regs interface, and improves
register caching which is important for VMX, where the cost of
vmcs_read/vmcs_write is significant.
[avi: fix warnings]
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Sheng Yang [Tue, 24 Jun 2008 09:02:38 +0000 (17:02 +0800)]
KVM: VMX: Rename misnamed msr bits
MSR_IA32_FEATURE_LOCKED is just a bit in fact, which shouldn't be prefixed with
MSR_. So is MSR_IA32_FEATURE_VMXON_ENABLED.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Linus Torvalds [Tue, 14 Oct 2008 23:53:02 +0000 (16:53 -0700)]
Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6
* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
i2c-viapro: Add support for SMBus Process Call transactions
i2c: Restore i2c_smbus_process_call function
i2c: Do earlier driver model init
i2c: Only build Tyan SMBus mux drivers on x86
i2c: Guard against oopses from bad init sequences
i2c: Document the implementation details of the /dev interface
i2c: Improve dev-interface documentation
i2c-parport-light: Don't register a platform device resource
hwmon: (dme1737) Convert to a new-style i2c driver
hwmon: (dme1737) Be less i2c-centric
i2c/tps65010: Vibrator hookup to gpiolib
i2c-viapro: Add VX800/VX820 support
i2c: Renesas Highlander FPGA SMBus support
i2c-pca-isa: Don't grab arbitrary resources
i2c/isp1301_omap: Convert to a new-style i2c driver, part 2
i2c/isp1301_omap: Convert to a new-style i2c driver, part 1
Linus Torvalds [Tue, 14 Oct 2008 23:35:43 +0000 (16:35 -0700)]
Merge branch 'for-linus' of git://git./linux/kernel/git/jikos/hid
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (55 commits)
HID: build drivers for all quirky devices by default
HID: add missing blacklist entry for Apple ATV ircontrol
HID: add support for Bright ABNT2 brazilian device
HID: Don't let Avermedia Radio FM800 be handled by usb hid drivers
HID: fix numlock led on Dell device 0x413c/0x2105
HID: remove warn() macro from usb hid drivers
HID: remove info() macro from usb HID drivers
HID: add appletv IR receiver quirk
HID: fix a lockup regression when using force feedback on a PID device
HID: hiddev.h: Fix example code.
HID: hiddev.h: Fix mixed space and tabs in example code.
HID: convert to dev_* prints
HID: remove hid-ff
HID: move zeroplus FF processing
HID: move thrustmaster FF processing
HID: move pantherlord FF processing
HID: fix incorrent length condition in hidraw_write()
HID: fix tty<->hid deadlock
HID: ignore iBuddy devices
HID: report descriptor fix for remaining MacBook JIS keyboards
...
Linus Torvalds [Tue, 14 Oct 2008 23:34:11 +0000 (16:34 -0700)]
Merge branch 'upstream-linus' of git://git./linux/kernel/git/mfasheh/ocfs2
* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfasheh/ocfs2: (56 commits)
ocfs2: Make cached block reads the common case.
ocfs2: Kill the last naked wait_on_buffer() for cached reads.
ocfs2: Move ocfs2_bread() into dir.c
ocfs2: Simplify ocfs2_read_block()
ocfs2: Require an inode for ocfs2_read_block(s)().
ocfs2: Separate out sync reads from ocfs2_read_blocks()
ocfs2: Refactor xattr list and remove ocfs2_xattr_handler().
ocfs2: Calculate EA hash only by its suffix.
ocfs2: Move trusted and user attribute support into xattr.c
ocfs2: Uninline ocfs2_xattr_name_hash()
ocfs2: Don't check for NULL before brelse()
ocfs2: use smaller counters in ocfs2_remove_xattr_clusters_from_cache
ocfs2: Documentation update for user_xattr / nouser_xattr mount options
ocfs2: make la_debug_mutex static
ocfs2: Remove pointless !!
ocfs2: Add empty bucket support in xattr.
ocfs2/xattr.c: Fix a bug when inserting xattr.
ocfs2: Add xattr mount option in ocfs2_show_options()
ocfs2: Switch over to JBD2.
ocfs2: Add the 'inode64' mount option.
...
Bjorn Helgaas [Tue, 14 Oct 2008 23:01:59 +0000 (17:01 -0600)]
rtc-cmos: look for PNP RTC first, then for platform RTC
We shouldn't rely on "pnp_platform_devices" to tell us whether there
is a PNP RTC device.
I introduced "pnp_platform_devices", but I think it was a mistake.
All it tells us is whether we found any PNPBIOS or PNPACPI devices.
Many machines have some PNP devices, but do not describe the RTC
via PNP. On those machines, we need to do the platform driver probe
to find the RTC.
We should just register the PNP driver and see whether it claims anything.
If we don't find a PNP RTC, fall back to the platform driver probe.
This (in conjunction with the arch/x86/kernel/rtc.c patch to add
a platform RTC device when PNP doesn't have one) should resolve
these issues:
http://bugzilla.kernel.org/show_bug.cgi?id=11580
https://bugzilla.redhat.com/show_bug.cgi?id=451188
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Reported-by: Rik Theys <rik.theys@esat.kuleuven.be>
Reported-by: shr_msn@yahoo.com.tw
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bjorn Helgaas [Tue, 14 Oct 2008 23:01:03 +0000 (17:01 -0600)]
x86: register a platform RTC device if PNP doesn't describe it
Most if not all x86 platforms have an RTC device, but sometimes the RTC
is not exposed as a PNP0b00/PNP0b01/PNP0b02 device in PNPBIOS or ACPI:
http://bugzilla.kernel.org/show_bug.cgi?id=11580
https://bugzilla.redhat.com/show_bug.cgi?id=451188
It's best if we can discover the RTC via PNP because then we know
which flavor of device it is, where it lives, and which IRQ it uses.
But if we can't, we should register a platform device using the
compiled-in RTC_PORT/RTC_IRQ resource assumptions.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Reported-by: Rik Theys <rik.theys@esat.kuleuven.be>
Reported-by: shr_msn@yahoo.com.tw
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bjorn Helgaas [Tue, 14 Oct 2008 19:50:21 +0000 (13:50 -0600)]
rtc-cmos: move wake setup from ACPI glue into RTC driver
Move rtc_wake_setup() from drivers/acpi/glue.c into the RTC driver
in drivers/rtc/rtc-cmos.c.
This removes the ordering constraint between the module_init(acpi_rtc_init)
and the cmos_do_probe() code that depends on it.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Jiri Kosina [Tue, 14 Oct 2008 21:37:33 +0000 (23:37 +0200)]
HID: build drivers for all quirky devices by default
Once kernel configuration has CONFIG_HID turned on, let also all the
specialized drivers for quirky devices to be built (unless CONFIG_EMBEDDED is
specified), as usually users don't care that much which driver
gives them the functionality, but when they want generic support, they
probably want to have support for all the quirky devices as well.
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Kosina [Tue, 14 Oct 2008 20:45:40 +0000 (22:45 +0200)]
HID: add missing blacklist entry for Apple ATV ircontrol
This device is already handled by hid-apple driver, but the blacklist entry
was missing in generic driver.
Reported-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Mauro Carvalho Chehab [Tue, 14 Oct 2008 20:41:43 +0000 (22:41 +0200)]
HID: add support for Bright ABNT2 brazilian device
This keyboard needs to reset the LEDS during probe.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Mauro Carvalho Chehab [Tue, 14 Oct 2008 20:34:32 +0000 (22:34 +0200)]
HID: Don't let Avermedia Radio FM800 be handled by usb hid drivers
Based on an original patch from Alexey Klimov <klimov.linux@gmail.com>,
against kernel version 2.6.27.
This device is already handled by radio-mr800 driver, and we therefore
want usbhid not to touch it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Mauro Carvalho Chehab [Tue, 14 Oct 2008 13:08:47 +0000 (11:08 -0200)]
HID: fix numlock led on Dell device 0x413c/0x2105
This keyboard needs to re-sync numlock after probing.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
From: Greg Kroah-Hartman [Sat, 11 Oct 2008 22:25:51 +0000 (00:25 +0200)]
HID: remove warn() macro from usb hid drivers
USB should not be having it's own printk macros, so remove warn() and
use the system-wide standard of dev_warn() wherever possible. In the
few places that will not work out, use a basic printk().
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Greg Kroah-Hartman [Sat, 11 Oct 2008 22:14:23 +0000 (00:14 +0200)]
HID: remove info() macro from usb HID drivers
USB should not be having it's own printk macros, so remove info() and
use the system-wide standard of dev_info() wherever possible.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Peter Korsgaard [Mon, 6 Oct 2008 09:15:34 +0000 (11:15 +0200)]
HID: add appletv IR receiver quirk
Similar to the existing IRCONTROL4 handling
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Anssi Hannula [Sat, 4 Oct 2008 12:44:06 +0000 (14:44 +0200)]
HID: fix a lockup regression when using force feedback on a PID device
Commit
8006479c9b75fb6594a7b746af3d7f1fbb68f18f introduced a spinlock in
input_dev->event_lock, which is locked when handling input events.
However, the hid-pidff driver sleeps when handling events as it waits for
reports being sent to the device before changing the report contents
again.
This causes a system lockup when trying to use force feedback with a PID
device, a regression introduced in 2.6.24 and 2.6.23.15.
Fix it by extracting the raw report data from struct hid_report
immediately when hid_submit_report() is called, therefore allowing
drivers to change the contents of struct hid_report immediately without
affecting the already-queued transfer.
In hid-pidff, re-add the removed usbhid_wait_io() to
pidff_erase_effect() instead, to prevent a full report queue from causing
the submission to fail, thus not freeing up device memory.
pidff_erase_effect() is not called while dev->event_lock is held.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Antonio Ospite [Thu, 2 Oct 2008 20:15:02 +0000 (22:15 +0200)]
HID: hiddev.h: Fix example code.
Fix hiddev.h example code.
To get the correct usage code, you need to set report_type and
report_id.
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Antonio Ospite [Thu, 2 Oct 2008 20:14:54 +0000 (22:14 +0200)]
HID: hiddev.h: Fix mixed space and tabs in example code.
Fix mixed space and tabs in example code.
Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Thu, 18 Sep 2008 10:23:34 +0000 (12:23 +0200)]
HID: convert to dev_* prints
Since we have a real device bound to a driver, we may use struct
device for printing. Use dev_* functions instead of printks in
4 drivers.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Thu, 18 Sep 2008 10:23:33 +0000 (12:23 +0200)]
HID: remove hid-ff
hid-ff.c now calls only pidff (generic driver), the special ones are now
in separate drivers. Invoke pidff on all non-special directly.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Thu, 18 Sep 2008 10:23:32 +0000 (12:23 +0200)]
HID: move zeroplus FF processing
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Thu, 18 Sep 2008 10:23:31 +0000 (12:23 +0200)]
HID: move thrustmaster FF processing
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Thu, 18 Sep 2008 17:43:32 +0000 (19:43 +0200)]
HID: move pantherlord FF processing
Move the force feedback processing into a separate module.
[jkosina@suse.cz: fix Kconfig texts a little bit]
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Kosina [Wed, 17 Sep 2008 17:41:58 +0000 (19:41 +0200)]
HID: fix incorrent length condition in hidraw_write()
The bound check on the buffer length
if (count > HID_MIN_BUFFER_SIZE)
is of course incorrent, the proper check is
if (count > HID_MAX_BUFFER_SIZE)
Fix it.
Reported-by: Jerry Ryle <jerry@mindtribe.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Jiri Slaby [Mon, 8 Sep 2008 23:23:03 +0000 (01:23 +0200)]
HID: fix tty<->hid deadlock
hid_compat_load() runs on the default workqueue, it request_module(), it
execs modprobe, it exits, tty flushes default workqueue, it hangs, because
we are still in it.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Tested-by: <Valdis.Kletnieks@vt.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Remi Cattiau [Mon, 8 Sep 2008 23:39:33 +0000 (01:39 +0200)]
HID: ignore iBuddy devices
iBuddy devices claim to be HID devices, but they are not.
Add them to the blacklist.
Signed-off-by: Remi Cattiau <remi@cattiau.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Tomoya Adachi [Thu, 4 Sep 2008 09:29:27 +0000 (11:29 +0200)]
HID: report descriptor fix for remaining MacBook JIS keyboards
This patch fixes a problem that MacBook JIS keyboard sends wrong report
descriptors. Although it has already been fixed in the first Core 2 Duo model,
it still remains in other models of MacBook.
Signed-off-by: Tomoya Adachi <adachi@il.is.s.u-tokyo.ac.jp>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Randy Dunlap [Thu, 4 Sep 2008 08:55:00 +0000 (10:55 +0200)]
HID: fix gyration build error
Fix config symbol name in ifdef to fix build error:
ERROR: "hid_compat_gyration" [drivers/hid/hid-dummy.ko] undefined!
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Acked-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Sergey Belyashov [Tue, 2 Sep 2008 15:31:16 +0000 (17:31 +0200)]
HID: Autocentering support for Logitech MOMO Racing Wheel
Current kernel has no support for autocentering for Logitech wheels. By
default autocentering enabled in wheel and constant effect does not work
properly. Using USB sniffer I found command which change autocentering
settings: 0xFE, 0x0D, 0x0R, 0x0L, 0x80, 0x00, 0x00, where R - clockwise force,
L - counter-clockwise (0x0-0xF, 0xC = 100%).
Signed-off-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Alex Chiang [Wed, 27 Aug 2008 11:36:18 +0000 (13:36 +0200)]
HID: fix grammo in HID_COMPAT Kconfig help text
The Kconfig option for HID_COMPAT should read "lose", not "loose".
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>