[PATCH 8/8] KVM: PPC: Book3S HV: Fix thinko in try_lock_hpte()

2012-10-15 Thread Paul Mackerras
This fixes an error in the inline asm in try_lock_hpte() where we were erroneously using a register number as an immediate operand. The bug only affects an error path, and in fact the code will still work as long as the compiler chooses some register other than r0 for the bits variable.

[PATCH 0/8] Various Book3s HV fixes that haven't been picked up yet

2012-10-15 Thread Paul Mackerras
This is a set of 8 patches of which the first 7 have been posted previously and have had no comments. The 8th is new, but is quite trivial. They fix a series of issues with HV-style KVM on ppc. They only touch code that is specific to Book3S HV KVM. Please apply. Thanks, Paul. -- To

[PATCH 5/8] KVM: PPC: Book3S HV: Run virtual core whenever any vcpus in it can run

2012-10-15 Thread Paul Mackerras
Currently the Book3S HV code implements a policy on multi-threaded processors (i.e. POWER7) that requires all of the active vcpus in a virtual core to be ready to run before we run the virtual core. However, that causes problems on reset, because reset stops all vcpus except vcpu 0, and can also

[PATCH 6/8] KVM: PPC: Book3S HV: Fix accounting of stolen time

2012-10-15 Thread Paul Mackerras
Currently the code that accounts stolen time tends to overestimate the stolen time, and will sometimes report more stolen time in a DTL (dispatch trace log) entry than has elapsed since the last DTL entry. This can cause guests to underflow the user or system time measured for some tasks, leading

[PATCH 2/8] KVM: PPC: Book3S HV: Fix some races in starting secondary threads

2012-10-15 Thread Paul Mackerras
Subsequent patches implementing in-kernel XICS emulation will make it possible for IPIs to arrive at secondary threads at arbitrary times. This fixes some races in how we start the secondary threads, which if not fixed could lead to occasional crashes of the host kernel. This makes sure that (a)

[PATCH 7/8] KVM: PPC: Book3S HV: Allow DTL to be set to address 0, length 0

2012-10-15 Thread Paul Mackerras
Commit 55b665b026 (KVM: PPC: Book3S HV: Provide a way for userspace to get/set per-vCPU areas) includes a check on the length of the dispatch trace log (DTL) to make sure the buffer is at least one entry long. This is appropriate when registering a buffer, but the interface also allows for any

[PATCH 4/8] KVM: PPC: Book3S HV: Fixes for late-joining threads

2012-10-15 Thread Paul Mackerras
If a thread in a virtual core becomes runnable while other threads in the same virtual core are already running in the guest, it is possible for the latecomer to join the others on the core without first pulling them all out of the guest. Currently this only happens rarely, when a vcpu is first

[PATCH 1/8] KVM: PPC: Book3S HV: Allow KVM guests to stop secondary threads coming online

2012-10-15 Thread Paul Mackerras
When a Book3S HV KVM guest is running, we need the host to be in single-thread mode, that is, all of the cores (or at least all of the cores where the KVM guest could run) to be running only one active hardware thread. This is because of the hardware restriction in POWER processors that all of

[PATCH 3/8] KVM: PPC: Book3s HV: Don't access runnable threads list without vcore lock

2012-10-15 Thread Paul Mackerras
There were a few places where we were traversing the list of runnable threads in a virtual core, i.e. vc-runnable_threads, without holding the vcore spinlock. This extends the places where we hold the vcore spinlock to cover everywhere that we traverse that list. Since we possibly need to sleep

Re: [PATCH 0/8] Various Book3s HV fixes that haven't been picked up yet

2012-10-15 Thread Alexander Graf
On 15.10.2012, at 13:14, Paul Mackerras wrote: This is a set of 8 patches of which the first 7 have been posted previously and have had no comments. The 8th is new, but is quite trivial. They fix a series of issues with HV-style KVM on ppc. They only touch code that is specific to Book3S

[PATCH 0/2] KVM: PPC: Support ioeventfd

2012-10-15 Thread Alexander Graf
In order to support vhost, we need to be able to support ioeventfd. This patch set adds support for ioeventfd to PPC and makes it possible to do so without implementing irqfd along the way, as it requires an in-kernel irqchip which we don't have yet. Alex Alexander Graf (2): KVM: Distangle

[PATCH 2/2] KVM: PPC: Support eventfd

2012-10-15 Thread Alexander Graf
In order to support the generic eventfd infrastructure on PPC, we need to call into the generic KVM in-kernel device mmio code. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/Kconfig |1 + arch/powerpc/kvm/Makefile |4 +++- arch/powerpc/kvm/powerpc.c | 17

[PATCH 1/2] KVM: Distangle eventfd code from irqchip

2012-10-15 Thread Alexander Graf
The current eventfd code assumes that when we have eventfd, we also have irqfd for in-kernel interrupt delivery. This is not necessarily true. On PPC we don't have an in-kernel irqchip yet, but we can still support easily support eventfd. Signed-off-by: Alexander Graf ag...@suse.de ---

[PATCH] kvm/powerpc: Handle errors in secondary thread grabbing

2012-10-15 Thread Michael Ellerman
In the Book3s HV code, kvmppc_run_core() has logic to grab the secondary threads of the physical core. If for some reason a thread is stuck, kvmppc_grab_hwthread() can fail, but currently we ignore the failure and continue into the guest. If the stuck thread is in the kernel badness ensues.

Re: [PATCH 0/8] Various Book3s HV fixes that haven't been picked up yet

2012-10-15 Thread Paul Mackerras
On Mon, Oct 15, 2012 at 02:00:54PM +0200, Alexander Graf wrote: Sorry, I can't accept patches that haven't shown up on kvm@vger. Please send this patch set again with CC to kvm@vger. Done; I didn't cc kvm-ppc this time since the patches haven't changed. By the way, what is the purpose of

Re: [PATCH] kvm/powerpc: Handle errors in secondary thread grabbing

2012-10-15 Thread Paul Mackerras
Michael, On Tue, Oct 16, 2012 at 11:15:50AM +1100, Michael Ellerman wrote: In the Book3s HV code, kvmppc_run_core() has logic to grab the secondary threads of the physical core. If for some reason a thread is stuck, kvmppc_grab_hwthread() can fail, but currently we ignore the failure and

[PATCH 1/5] KVM: Provide mmu notifier retry test based on struct kvm

2012-10-15 Thread Paul Mackerras
The mmu_notifier_retry() function, used to test whether any page invalidations are in progress, currently takes a vcpu pointer, though the code only needs the VM's struct kvm pointer. Forthcoming patches to the powerpc Book3S HV code will need to test for retry within a VM ioctl, where a struct

[PATCH 3/5] KVM: PPC: Book3S HV: Add a mechanism for recording modified HPTEs

2012-10-15 Thread Paul Mackerras
This uses a bit in our record of the guest view of the HPTE to record when the HPTE gets modified. We use a reserved bit for this, and ensure that this bit is always cleared in HPTE values returned to the guest. The recording of modified HPTEs is only done if other code indicates its interest by

[PATCH 2/5] KVM: PPC: Book3S HV: Restructure HPT entry creation code

2012-10-15 Thread Paul Mackerras
This restructures the code that creates HPT (hashed page table) entries so that it can be called in situations where we don't have a struct vcpu pointer, only a struct kvm pointer. It also fixes a bug where kvmppc_map_vrma() would corrupt the guest R4 value. Now, most of the work of

[PATCH 0/5] KVM: PPC: Book3S HV: HPT read/write functions for userspace

2012-10-15 Thread Paul Mackerras
This series of patches provides an interface by which userspace can read and write the hashed page table (HPT) of a Book3S HV guest. The interface is an ioctl which provides a file descriptor which can be accessed with the read() and write() system calls. The data read and written is the guest

[PATCH 5/5] KVM: PPC: Book3S HV: Provide a method for userspace to read and write the HPT

2012-10-15 Thread Paul Mackerras
A new ioctl, KVM_PPC_GET_HTAB_FD, returns a file descriptor. Reads on this fd return the contents of the HPT (hashed page table), writes create and/or remove entries in the HPT. There is a new capability, KVM_CAP_PPC_HTAB_FD, to indicate the presence of the ioctl. The ioctl takes an argument

[PATCH 4/5] KVM: PPC: Book3S HV: Make a HPTE removal function available

2012-10-15 Thread Paul Mackerras
This makes a HPTE removal function, kvmppc_do_h_remove(), available outside book3s_hv_rm_mmu.c. This will be used by the HPT writing code. Signed-off-by: Paul Mackerras pau...@samba.org --- arch/powerpc/include/asm/kvm_book3s.h |3 +++ arch/powerpc/kvm/book3s_hv_rm_mmu.c | 19

[PATCH] MAINTAINERS: Add git tree link for PPC KVM

2012-10-15 Thread Michael Ellerman
Signed-off-by: Michael Ellerman mich...@ellerman.id.au --- MAINTAINERS |1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index e73060f..32dc107 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -4244,6 +4244,7 @@ KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC M: