[PATCH] KVM: arm: Use PTR_ERR_OR_ZERO()

2017-11-29 Thread Vasyl Gomonovych
Fix ptr_ret.cocci warnings: virt/kvm/arm/vgic/vgic-its.c:971:1-3: WARNING: PTR_ERR_OR_ZERO can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: scripts/coccinelle/api/ptr_ret.cocci Signed-off-by: Vasyl Gomonovych --- virt/kvm/arm/vgic/vgic-its.c | 4 +--- 1 file

[PATCH] KVM: arm64: handle the translation table walk RAS error

2017-11-29 Thread Dongjiu Geng
For the RAS Synchronous External Abort, there are two types. One is memory access, it will be handled by host APEI driver. Another is translation table walk, in essence, it is hardware memory error on stage1 or stage2 page table. For the guest stage1 translation table error, if host APEI driver ha

Re: [PATCH] KVM: arm64: handle the translation table walk RAS error

2017-11-29 Thread Christoffer Dall
On Thu, Nov 30, 2017 at 04:48:44AM +0800, Dongjiu Geng wrote: > For the RAS Synchronous External Abort, there are two types. > One is memory access, it will be handled by host APEI driver. > Another is translation table walk, in essence, it is hardware > memory error on stage1 or stage2 page table.

Re: [PATCH v5 00/30] ARM Scalable Vector Extension (SVE)

2017-11-29 Thread Alex Bennée
Dave Martin writes: > This series implements Linux kernel support for the ARM Scalable Vector > Extension (SVE). [1] It supersedes the previous v3: see [3] for link > and full cover letter. > > This is a minor update to v4, but does contain a couple of important > fixes. I seem to have run in

Re: [PATCH v5 6/8] KVM: arm/arm64: Support VGIC dist pend/active changes for mapped IRQs

2017-11-29 Thread Andrew Jones
On Mon, Nov 20, 2017 at 08:16:47PM +0100, Christoffer Dall wrote: > For mapped IRQs (with the HW bit set in the LR) we have to follow some > rules of the architecture. One of these rules is that VM must not be > allowed to deactivate a virtual interrupt with the HW bit set unless the > physical in

Re: [PATCH v5 7/8] KVM: arm/arm64: Provide a get_input_level for the arch timer

2017-11-29 Thread Andrew Jones
On Mon, Nov 20, 2017 at 08:16:48PM +0100, Christoffer Dall wrote: > The VGIC can now support the life-cycle of mapped level-triggered > interrupts, and we no longer have to read back the timer state on every > exit from the VM if we had an asserted timer interrupt signal, because > the VGIC already

Re: [virtio-dev] [RFC PATCH v2 4/5] ACPI/IORT: Support paravirtualized IOMMU

2017-11-29 Thread Jean-Philippe Brucker
On 17/11/17 18:52, Jean-Philippe Brucker wrote: > To describe the virtual topology in relation to a virtio-iommu device, > ACPI-based systems use a "paravirtualized IOMMU" IORT node. Add support > for it. > > This is a RFC because the IORT specification doesn't describe the > paravirtualized node

Re: [virtio-dev] [RFC PATCH v2 1/5] iommu: Add virtio-iommu driver

2017-11-29 Thread Jean-Philippe Brucker
On 17/11/17 18:52, Jean-Philippe Brucker wrote: [...] > +struct viommu_domain { > + struct iommu_domain domain; > + struct viommu_dev *viommu; > + struct mutexmutex; > + unsigned intid; > + > + spinlock_t

Re: [PATCH v5 00/30] ARM Scalable Vector Extension (SVE)

2017-11-29 Thread Will Deacon
On Wed, Nov 29, 2017 at 03:04:12PM +, Alex Bennée wrote: > > Dave Martin writes: > > > This series implements Linux kernel support for the ARM Scalable Vector > > Extension (SVE). [1] It supersedes the previous v3: see [3] for link > > and full cover letter. > > > > This is a minor update t

Re: [PATCH v5 00/30] ARM Scalable Vector Extension (SVE)

2017-11-29 Thread Dave Martin
On Wed, Nov 29, 2017 at 03:21:40PM +, Will Deacon wrote: > On Wed, Nov 29, 2017 at 03:04:12PM +, Alex Bennée wrote: > > > > Dave Martin writes: > > > > > This series implements Linux kernel support for the ARM Scalable Vector > > > Extension (SVE). [1] It supersedes the previous v3: see

Re: [PATCH v1 0/2] Additional single-step-cases

2017-11-29 Thread Marc Zyngier
On 23/11/17 12:11, Alex Bennée wrote: > Hi, > > This is now split into two patches as the first case of SError is > separate from behaviour of stepping instructions. > > Alex Bennée (2): > kvm: arm64: handle single-step during SError exceptions > kvm: arm64: handle single-step of hyp emulated

[PATCH] KVM: arm/arm64: Avoid attempting to load timer vgic state without a vgic

2017-11-29 Thread Christoffer Dall
The timer optimization patches inadvertendly changed the logic to always load the timer state as if we have a vgic, even if we don't have a vgic. Fix this by doing the usual irqchip_in_kernel() check and call the appropriate load function. Signed-off-by: Christoffer Dall --- I'm aware that this

[PATCH v2 00/16] Move vcpu_load and vcpu_put calls to arch code

2017-11-29 Thread Christoffer Dall
Some architectures may decide to do different things during kvm_arch_vcpu_load depending on the ioctl being executed. For example, arm64 is about to do significant work in vcpu load/put when running a vcpu, but it's problematic to do this for any other vcpu ioctl than KVM_RUN. Further, while it m

[PATCH v2 06/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_sregs

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_sregs(). Signed-off-by: Christoffer Dall --- arch/powerpc/kvm/book3s.c | 8 +++- arch/powerpc/kvm/booke.c | 9 - arch/s390/kvm/kvm-s390.c | 4 arch/x86/kvm/x86.c|

[PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load

2017-11-29 Thread Christoffer Dall
As we're about to call vcpu_load() from architecture-specific implementations of the KVM vcpu ioctls, but yet we access data structures protected by the vcpu->mutex in the generic code, factor this logic out from vcpu_load(). Signed-off-by: Christoffer Dall --- arch/x86/kvm/vmx.c | 4 +---

[PATCH v2 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_mpstate(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 11 +-- arch/x86/kvm/x86.c | 3 +++ virt/kvm/arm/arm.c | 3 +++ virt/kvm/kvm_main.c | 2

[PATCH v2 09/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_mpstate(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 3 +++ arch/x86/kvm/x86.c | 15 --- virt/kvm/arm/arm.c | 9 +++-- virt/kvm/kvm_main.c

[PATCH v2 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_guest_debug(). Signed-off-by: Christoffer Dall --- arch/arm64/kvm/guest.c| 15 --- arch/powerpc/kvm/book3s.c | 2 ++ arch/powerpc/kvm/booke.c | 19 +-- arch

[PATCH v2 04/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_regs

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_regs(). Signed-off-by: Christoffer Dall --- arch/mips/kvm/mips.c | 3 +++ arch/powerpc/kvm/book3s.c | 3 +++ arch/powerpc/kvm/booke.c | 3 +++ arch/s390/kvm/kvm-s390.c | 2 ++ arch/x8

[PATCH v2 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code

2017-11-29 Thread Christoffer Dall
In preparation for moving calls to vcpu_load() and vcpu_put() into the architecture specific implementations of the KVM vcpu ioctls, move the calls in the main kvm_vcpu_ioctl() dispatcher function to each case of the ioctl select statement. This allows us to move the vcpu_load() and vcpu_put() cal

[PATCH v2 10/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_translate(). Signed-off-by: Christoffer Dall --- arch/powerpc/kvm/booke.c | 2 ++ arch/x86/kvm/x86.c | 3 +++ virt/kvm/kvm_main.c | 2 -- 3 files changed, 5 insertions(+), 2 deletions

[PATCH v2 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_fpu(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 15 --- arch/x86/kvm/x86.c | 8 ++-- virt/kvm/kvm_main.c | 2 -- 3 files changed, 18 insert

[PATCH v2 16/16] KVM: arm/arm64: Move vcpu_load call after kvm_vcpu_first_run_init

2017-11-29 Thread Christoffer Dall
Moving the call to vcpu_load() in kvm_arch_vcpu_ioctl_run() to after we've called kvm_vcpu_first_run_init() simplifies some of the vgic and there is also no need to do vcpu_load() for things such as handling the immediate_exit flag. Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c

[PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN

2017-11-29 Thread Christoffer Dall
Calling vcpu_load() registers preempt notifiers for this vcpu and calls kvm_arch_vcpu_load(). The latter will soon be doing a lot of heavy lifting on arm/arm64 and will try to do things such as enabling the virtual timer and setting us up to handle interrupts from the timer hardware. Loading stat

[PATCH v2 03/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_run

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_run(). Signed-off-by: Christoffer Dall --- arch/mips/kvm/mips.c | 3 +++ arch/powerpc/kvm/powerpc.c | 6 +- arch/s390/kvm/kvm-s390.c | 10 -- arch/x86/kvm/x86.c |

[PATCH v2 05/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_regs

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_regs(). Signed-off-by: Christoffer Dall --- arch/mips/kvm/mips.c | 3 +++ arch/powerpc/kvm/book3s.c | 3 +++ arch/powerpc/kvm/booke.c | 3 +++ arch/s390/kvm/kvm-s390.c | 2 ++ arch/x8

[PATCH v2 07/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_sregs

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_set_sregs(). Signed-off-by: Christoffer Dall --- arch/powerpc/kvm/book3s.c | 8 +++- arch/powerpc/kvm/booke.c | 15 +++ arch/s390/kvm/kvm-s390.c | 4 arch/x86/kvm/x86.c

[PATCH v2 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu

2017-11-29 Thread Christoffer Dall
Move vcpu_load() and vcpu_put() into the architecture specific implementations of kvm_arch_vcpu_ioctl_get_fpu(). Signed-off-by: Christoffer Dall --- arch/s390/kvm/kvm-s390.c | 4 arch/x86/kvm/x86.c | 7 +-- virt/kvm/kvm_main.c | 2 -- 3 files changed, 9 insertions(+), 4 delet

[PATCH v2 14/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl

2017-11-29 Thread Christoffer Dall
Move the calls to vcpu_load() and vcpu_put() in to the architecture specific implementations of kvm_arch_vcpu_ioctl() which dispatches further architecture-specific ioctls on to other functions. Some architectures support asynchronous vcpu ioctls which cannot call vcpu_load() or take the vcpu->mut

Re: [PATCH] kvm: arm: don't treat unavailable HYP mode as an error

2017-11-29 Thread Christoffer Dall
On Tue, Nov 28, 2017 at 03:18:19PM +, Ard Biesheuvel wrote: > Since it is perfectly legal to run the kernel at EL1, it is not > actually an error if HYP mode is not available when attempting to > initialize KVM, given that KVM support cannot be built as a module. > So demote the kvm_err() to kv

Re: [PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > As we're about to call vcpu_load() from architecture-specific > implementations of the KVM vcpu ioctls, but yet we access data > structures protected by the vcpu->mutex in the generic code, factor > this logic out from vcpu_load(). > > Signed-off-by:

Re: [PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load

2017-11-29 Thread Paolo Bonzini
On 29/11/2017 18:17, David Hildenbrand wrote: > On 29.11.2017 17:41, Christoffer Dall wrote: >> As we're about to call vcpu_load() from architecture-specific >> implementations of the KVM vcpu ioctls, but yet we access data >> structures protected by the vcpu->mutex in the generic code, factor >> t

Re: [PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load

2017-11-29 Thread David Hildenbrand
On 29.11.2017 18:20, Paolo Bonzini wrote: > On 29/11/2017 18:17, David Hildenbrand wrote: >> On 29.11.2017 17:41, Christoffer Dall wrote: >>> As we're about to call vcpu_load() from architecture-specific >>> implementations of the KVM vcpu ioctls, but yet we access data >>> structures protected by

Re: [PATCH] arm64: KVM: Hide PMU from guests when disabled

2017-11-29 Thread Christoffer Dall
On Sat, Nov 25, 2017 at 06:40:31PM +0100, Andrew Jones wrote: > Since commit 93390c0a1b20 ("arm64: KVM: Hide unsupported AArch64 CPU > features from guests") we can hide cpu features from guests. Apply > this to a long standing issue where guests see a PMU available, but > it's not, because it was

Re: [PATCH v2 02/16] KVM: Prepare for moving vcpu_load/vcpu_put into arch specific code

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > In preparation for moving calls to vcpu_load() and vcpu_put() into the > architecture specific implementations of the KVM vcpu ioctls, move the > calls in the main kvm_vcpu_ioctl() dispatcher function to each case > of the ioctl select statement. This

Re: [PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN

2017-11-29 Thread David Hildenbrand
> +++ b/virt/kvm/arm/arm.c > @@ -381,14 +381,11 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu) > int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, > struct kvm_mp_state *mp_state) > { > - vcpu_load(vcpu); > - > if (vcpu->arch.power_off)

Re: [PATCH v2 15/16] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN

2017-11-29 Thread Christoffer Dall
On Wed, Nov 29, 2017 at 5:30 PM, David Hildenbrand wrote: > >> +++ b/virt/kvm/arm/arm.c >> @@ -381,14 +381,11 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu) >> int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, >> struct kvm_mp_state *mp_state) >>

Re: [PATCH v2 01/16] KVM: Take vcpu->mutex outside vcpu_load

2017-11-29 Thread Christoffer Dall
On Wed, Nov 29, 2017 at 5:22 PM, David Hildenbrand wrote: > On 29.11.2017 18:20, Paolo Bonzini wrote: >> On 29/11/2017 18:17, David Hildenbrand wrote: >>> On 29.11.2017 17:41, Christoffer Dall wrote: As we're about to call vcpu_load() from architecture-specific implementations of the KVM

Re: [PATCH v2 13/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_fpu

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_set_fpu(). > > Signed-off-by: Christoffer Dall > --- > arch/s390/kvm/kvm-s390.c | 15 --- > arch/x86/kvm/x86.c | 8 ++-- >

Re: [PATCH v5 19/20] KVM: arm/arm64: Get rid of kvm_timer_flush_hwstate

2017-11-29 Thread Christoffer Dall
On Mon, Nov 27, 2017 at 05:50:12PM +0100, Andrew Jones wrote: > On Fri, Oct 27, 2017 at 10:34:40AM +0200, Christoffer Dall wrote: > > diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c > > index 132d39a..14c50d1 100644 > > --- a/virt/kvm/arm/arm.c > > +++ b/virt/kvm/arm/arm.c > > @@ -656,7 +656,6

Re: [PATCH v2 12/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_fpu

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_get_fpu(). > > Signed-off-by: Christoffer Dall > --- > arch/s390/kvm/kvm-s390.c | 4 > arch/x86/kvm/x86.c | 7 +-- > virt/kvm/kvm_

Re: [PATCH v2 11/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_guest_debug

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_set_guest_debug(). > > Signed-off-by: Christoffer Dall > --- > arch/arm64/kvm/guest.c| 15 --- > arch/powerpc/kvm/book3s.c | 2 +

Re: [PATCH v2 10/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_translate

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_translate(). > > Signed-off-by: Christoffer Dall > --- > arch/powerpc/kvm/booke.c | 2 ++ > arch/x86/kvm/x86.c | 3 +++ > virt/kvm/kvm_main

Re: [PATCH v2 09/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_set_mpstate

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_set_mpstate(). > > Signed-off-by: Christoffer Dall > --- > arch/s390/kvm/kvm-s390.c | 3 +++ > arch/x86/kvm/x86.c | 15 --- >

Re: [PATCH v2 08/16] KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl_get_mpstate

2017-11-29 Thread David Hildenbrand
On 29.11.2017 17:41, Christoffer Dall wrote: > Move vcpu_load() and vcpu_put() into the architecture specific > implementations of kvm_arch_vcpu_ioctl_get_mpstate(). > > Signed-off-by: Christoffer Dall > --- > arch/s390/kvm/kvm-s390.c | 11 +-- > arch/x86/kvm/x86.c | 3 +++ > virt

Re: unmap_ptes is not complete

2017-11-29 Thread Christoffer Dall
Hi Raz, On Mon, Nov 27, 2017 at 09:10:56PM +, Raz wrote: > Hey > in mmu.c unmap_ptes() you invalidate *pte but not the pte itself. This > leads to inconsistency in el2 translation tables. ie; the pte entry is > cleared in the cached memory but not in the RAM, so the entry may still be > valid

Re: [PATCH v5 19/20] KVM: arm/arm64: Get rid of kvm_timer_flush_hwstate

2017-11-29 Thread Andrew Jones
On Wed, Nov 29, 2017 at 06:39:00PM +0100, Christoffer Dall wrote: > On Mon, Nov 27, 2017 at 05:50:12PM +0100, Andrew Jones wrote: > > On Fri, Oct 27, 2017 at 10:34:40AM +0200, Christoffer Dall wrote: > > > diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c > > > index 132d39a..14c50d1 100644 > >

Re: [PATCH 01/37] KVM: arm64: Avoid storing the vcpu pointer on the stack

2017-11-29 Thread Christoffer Dall
Hi James, On Mon, Nov 27, 2017 at 11:11:20AM +, James Morse wrote: > On 23/11/17 20:59, Christoffer Dall wrote: > > On Thu, Oct 12, 2017 at 04:49:44PM +0100, Marc Zyngier wrote: > >> On 12/10/17 11:41, Christoffer Dall wrote: > >>> We already have the percpu area for the host cpu state, which