[PATCH] KVM: arm/arm64: Fix unintended stage 2 PMD mappings

2018-11-02 Thread Christoffer Dall
There are two things we need to take care of when we create block mappings in the stage 2 page tables: (1) The alignment within a PMD between the host address range and the guest IPA range must be the same, since otherwise we end up mapping pages with the wrong offset. (2) The head and ta

[PATCH] KVM: arm64: Clarify explanation of STAGE2_PGTABLE_LEVELS

2018-11-02 Thread Christoffer Dall
In attempting to re-construct the logic for our stage 2 page table layout I found the reaoning in the comment explaining how we calculate the number of levels used for stage 2 page tables a bit backwards. This commit attempts to clarify the comment, to make it slightly easier to read without havin

Re: [RFC PATCH v2 05/23] KVM: arm: Add arch vcpu uninit hook

2018-11-02 Thread Christoffer Dall
On Fri, Sep 28, 2018 at 02:39:09PM +0100, Dave Martin wrote: > In preparation for adding support for SVE in guests on arm64, a > hook is needed for freeing additional per-vcpu memory when a vcpu > is freed. Can this commit motivate why we can't do the work in kvm_arch_vcpu_free, which we use for f

Re: [RFC PATCH v2 10/23] KVM: arm64: Extend reset_unknown() to handle mixed RES0/UNKNOWN registers

2018-11-02 Thread Christoffer Dall
On Fri, Sep 28, 2018 at 02:39:14PM +0100, Dave Martin wrote: > The reset_unknown() system register helper initialises a guest > register to a distinctive junk value on vcpu reset, to help expose > and debug deficient register initialisation within the guest. > > Some registers such as the SVE cont

Re: [RFC PATCH v2 11/23] KVM: arm64: Support runtime sysreg filtering for KVM_GET_REG_LIST

2018-11-02 Thread Christoffer Dall
On Fri, Sep 28, 2018 at 02:39:15PM +0100, Dave Martin wrote: > KVM_GET_REG_LIST should only enumerate registers that are actually > accessible, so it is necessary to filter out any register that is > not exposed to the guest. For features that are configured at > runtime, this will require a dynam

Re: [RFC PATCH v2 18/23] KVM: arm64: Add arch vcpu ioctl hook

2018-11-02 Thread Christoffer Dall
On Fri, Sep 28, 2018 at 02:39:22PM +0100, Dave Martin wrote: > To enable arm64-specific vcpu ioctls to be added cleanly, this > patch adds a kvm_arm_arch_vcpu_ioctl() hook so that these don't > pollute the common code. > > No functional change: the -EINVAL return for unknown ioctls is > retained,

Re: [RFC PATCH v2 20/23] KVM: arm64: Add arch vm ioctl hook

2018-11-02 Thread Christoffer Dall
On Fri, Sep 28, 2018 at 02:39:24PM +0100, Dave Martin wrote: > To enable arm64-specific vm ioctls to be added cleanly, this patch > adds a kvm_arm_arch_vm_ioctl() hook so that these don't pollute the > common code. Hmmm, I don't really see the strenght of that argument, and have the same concern a

Re: [PATCH v3 2/7] arm64/kvm: context-switch ptrauth registers

2018-11-02 Thread Christoffer Dall
On Wed, Oct 17, 2018 at 04:17:55PM +0530, Amit Daniel Kachhap wrote: > From: Mark Rutland > > When pointer authentication is supported, a guest may wish to use it. > This patch adds the necessary KVM infrastructure for this to work. > > When we schedule a vcpu, we enable guest usage of pointer >

Re: [PATCH v3 6/7] arm64: docs: document KVM support of pointer authentication

2018-11-02 Thread Christoffer Dall
On Wed, Oct 17, 2018 at 04:17:59PM +0530, Amit Daniel Kachhap wrote: > The documentation is updated to help in using pointer authentication > for KVM guests. > > Signed-off-by: Amit Daniel Kachhap > Cc: Mark Rutland > Cc: Christoffer Dall > Cc: Marc Zyngier > Cc: kvmarm@lists.cs.columbia.edu >

Re: [PATCH] KVM: arm/arm64: Fix unintended stage 2 PMD mappings

2018-11-02 Thread Suzuki K Poulose
Hi Christoffer, On 02/11/18 07:53, Christoffer Dall wrote: There are two things we need to take care of when we create block mappings in the stage 2 page tables: (1) The alignment within a PMD between the host address range and the guest IPA range must be the same, since otherwise we end

Re: [PATCH] KVM: arm64: Clarify explanation of STAGE2_PGTABLE_LEVELS

2018-11-02 Thread Suzuki K Poulose
Hi On 02/11/18 07:53, Christoffer Dall wrote: In attempting to re-construct the logic for our stage 2 page table layout I found the reaoning in the comment explaining how we calculate the number of levels used for stage 2 page tables a bit backwards. This commit attempts to clarify the comment,

Re: [PATCH v5 11/17] arm64: docs: document pointer authentication

2018-11-02 Thread Ramana Radhakrishnan
>> + >> +When CONFIG_ARM64_PTR_AUTH is selected, and relevant HW support is >> +present, the kernel will assign a random APIAKey value to each process >> +at exec*() time. This key is shared by all threads within the process, >> +and the key is preserved across fork(). Presence of functionality u

Re: [PATCH] KVM: arm/arm64: Fix unintended stage 2 PMD mappings

2018-11-02 Thread Christoffer Dall
On Fri, Nov 02, 2018 at 10:26:37AM +, Suzuki K Poulose wrote: > Hi Christoffer, > > On 02/11/18 07:53, Christoffer Dall wrote: > >There are two things we need to take care of when we create block > >mappings in the stage 2 page tables: > > > > (1) The alignment within a PMD between the host

Re: [PATCH] KVM: arm/arm64: Fix unintended stage 2 PMD mappings

2018-11-02 Thread Suzuki K Poulose
Hi Christoffer, On 02/11/18 13:43, Christoffer Dall wrote: On Fri, Nov 02, 2018 at 10:26:37AM +, Suzuki K Poulose wrote: Hi Christoffer, On 02/11/18 07:53, Christoffer Dall wrote: There are two things we need to take care of when we create block mappings in the stage 2 page tables: (1

Re: [PATCH] KVM: arm64: Clarify explanation of STAGE2_PGTABLE_LEVELS

2018-11-02 Thread Christoffer Dall
On Fri, Nov 02, 2018 at 11:02:38AM +, Suzuki K Poulose wrote: > Hi > > On 02/11/18 07:53, Christoffer Dall wrote: > >In attempting to re-construct the logic for our stage 2 page table > >layout I found the reaoning in the comment explaining how we calculate > >the number of levels used for sta

Re: Timekeeping on ARM guests/hosts

2018-11-02 Thread Christoffer Dall
On Wed, Oct 31, 2018 at 11:49:05AM -0700, Miriam Zimmerman wrote: [...] > > > CONFIG_KVM_GUEST fixes this by providing the guest with information on > > the host time and informs it when the guest is paused (see > > MSR_KVM_SYSTEM_TIME_NEW). Arm doesn't (yet) have para-virtualised time. > > > >

Re: Timekeeping on ARM guests/hosts

2018-11-02 Thread Miriam Zimmerman
On Fri, Nov 2, 2018 at 7:34 AM Christoffer Dall wrote: > > On Wed, Oct 31, 2018 at 11:49:05AM -0700, Miriam Zimmerman wrote: > > [...] > > > > > > CONFIG_KVM_GUEST fixes this by providing the guest with information on > > > the host time and informs it when the guest is paused (see > > > MSR_KVM_S

Re: [PATCH 16/16] KVM: arm/arm64: vgic: Replace spin_is_locked() with lockdep

2018-11-02 Thread Christoffer Dall
On Tue, Oct 02, 2018 at 10:39:02PM -0700, Lance Roy wrote: > lockdep_assert_held() is better suited to checking locking requirements, > since it won't get confused when someone else holds the lock. This is > also a step towards possibly removing spin_is_locked(). > > Signed-off-by: Lance Roy > Cc

Re: [PATCH 16/16] KVM: arm/arm64: vgic: Replace spin_is_locked() with lockdep

2018-11-02 Thread Paul E. McKenney
On Fri, Nov 02, 2018 at 07:45:33PM +0100, Christoffer Dall wrote: > On Tue, Oct 02, 2018 at 10:39:02PM -0700, Lance Roy wrote: > > lockdep_assert_held() is better suited to checking locking requirements, > > since it won't get confused when someone else holds the lock. This is > > also a step towar

Re: Timekeeping on ARM guests/hosts

2018-11-02 Thread Miriam Zimmerman
In researching KVM_REG_ARM_TIMER_CNT, I discovered your commit 4b7a6bf ("target-arm: kvm: Differentiate registers based on write-back levels"), which seems to limit when the KVM_REG_ARM_TIMER_CNT is used to save time. Under what circumstances should this be saved in order to provide a consistent vi

Re: Timekeeping on ARM guests/hosts

2018-11-02 Thread Bijan Mottahedeh
On 11/2/2018 7:34 AM, Christoffer Dall wrote: The key is whether the userspace program that controls the KVM VM (kvmtool, QEMU, crosvm) uses the KVM_REG_ARM_TIMER_CNT ioctl to save the VM view of virtual time, and to retore that at a later time. KVM adjusts the CNTVOFF_EL2 for the VM on which th