Re: [PATCH kvmtool v1 2/2] vfio-pci: Fallback to INTx mode when disable MSI/MSIX

2019-03-19 Thread Leo Yan
Hi Jean-Philippe, On Fri, Mar 15, 2019 at 02:20:07PM +, Jean-Philippe Brucker wrote: > On 15/03/2019 08:33, Leo Yan wrote: > > Since PCI forbids enabling INTx, MSI or MSIX at the same time, it's by > > default to disable INTx mode when enable MSI/MSIX mode; but this logic is > > easily broken

[kvmarm:5.1-fixes 6/6] arch/arm/kvm/../../../virt/kvm/arm/mmu.c:1154:35: error: 'S2_PUD_MASK' undeclared; did you mean 'S2_PMD_MASK'?

2019-03-19 Thread kbuild test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git 5.1-fixes head: 4c6b77dd0036d42268cc1e6c5ab5a9e9d98cae65 commit: 4c6b77dd0036d42268cc1e6c5ab5a9e9d98cae65 [6/6] KVM: arm/arm64: Fix handling of stage2 huge mappings config: arm-axm55xx_defconfig (attached as .config)

Re: [PATCH v5 00/26] KVM: arm64: SVE guest support

2019-03-19 Thread Dave Martin
On Tue, Mar 19, 2019 at 05:51:51PM +, Dave Martin wrote: [...] Yes, I messed up the subject line in the cover letter :P The prefix should read "[PATCH v6 00/27]" Cheers ---Dave ___ kvmarm mailing list kvmarm@lists.cs.columbia.edu

[PATCH v6 27/27] KVM: arm64/sve: Document KVM API extensions for SVE

2019-03-19 Thread Dave Martin
This patch adds sections to the KVM API documentation describing the extensions for supporting the Scalable Vector Extension (SVE) in guests. Signed-off-by: Dave Martin --- Changes since v5: * Document KVM_ARM_VCPU_FINALIZE and its interactions with SVE. ---

[PATCH v6 23/27] KVM: arm64/sve: Add pseudo-register for the guest's vector lengths

2019-03-19 Thread Dave Martin
This patch adds a new pseudo-register KVM_REG_ARM64_SVE_VLS to allow userspace to set and query the set of vector lengths visible to the guest. In the future, multiple register slices per SVE register may be visible through the ioctl interface. Once the set of slices has been determined we would

[PATCH v6 24/27] KVM: arm64/sve: Allow userspace to enable SVE for vcpus

2019-03-19 Thread Dave Martin
Now that all the pieces are in place, this patch offers a new flag KVM_ARM_VCPU_SVE that userspace can pass to KVM_ARM_VCPU_INIT to turn on SVE for the guest, on a per-vcpu basis. As part of this, support for initialisation and reset of the SVE vector length set and registers is added in the

[PATCH v6 22/27] KVM: arm/arm64: Add KVM_ARM_VCPU_FINALIZE ioctl

2019-03-19 Thread Dave Martin
Some aspects of vcpu configuration may be too complex to be completed inside KVM_ARM_VCPU_INIT. Thus, there may be a requirement for userspace to do some additional configuration before various other ioctls will work in a consistent way. In particular this will be the case for SVE, where

[PATCH v6 25/27] KVM: arm64: Add a capability to advertise SVE support

2019-03-19 Thread Dave Martin
To provide a uniform way to check for KVM SVE support amongst other features, this patch adds a suitable capability KVM_CAP_ARM_SVE, and reports it as present when SVE is available. Signed-off-by: Dave Martin --- Changes since v5: * [Julien Thierry] Strip out has_vhe() sanity-check, which

[PATCH v6 21/27] KVM: arm/arm64: Add hook for arch-specific KVM initialisation

2019-03-19 Thread Dave Martin
This patch adds a kvm_arm_init_arch_resources() hook to perform subarch-specific initialisation when starting up KVM. This will be used in a subsequent patch for global SVE-related setup on arm64. No functional change. Signed-off-by: Dave Martin --- arch/arm/include/asm/kvm_host.h | 2 ++

[PATCH v6 26/27] KVM: Document errors for KVM_GET_ONE_REG and KVM_SET_ONE_REG

2019-03-19 Thread Dave Martin
KVM_GET_ONE_REG and KVM_SET_ONE_REG return some error codes that are not documented (but hopefully not surprising either). To give an indication of what these may mean, this patch adds brief documentation. Signed-off-by: Dave Martin --- Documentation/virtual/kvm/api.txt | 6 ++ 1 file

[PATCH v6 20/27] arm64/sve: In-kernel vector length availability query interface

2019-03-19 Thread Dave Martin
KVM will need to interrogate the set of SVE vector lengths available on the system. This patch exposes the relevant bits to the kernel, along with a sve_vq_available() helper to check whether a particular vector length is supported. __vq_to_bit() and __bit_to_vq() are not intended for use

[PATCH v6 17/27] KVM: arm64: Reject ioctl access to FPSIMD V-regs on SVE vcpus

2019-03-19 Thread Dave Martin
In order to avoid the pointless complexity of maintaining two ioctl register access views of the same data, this patch blocks ioctl access to the FPSIMD V-registers on vcpus that support SVE. This will make it more straightforward to add SVE register access support. Since SVE is an opt-in

[PATCH v6 13/27] KVM: arm64/sve: Context switch the SVE registers

2019-03-19 Thread Dave Martin
In order to give each vcpu its own view of the SVE registers, this patch adds context storage via a new sve_state pointer in struct vcpu_arch. An additional member sve_max_vl is also added for each vcpu, to determine the maximum vector length visible to the guest and thus the value to be

[PATCH v6 18/27] KVM: arm64/sve: Add SVE support to register access ioctl interface

2019-03-19 Thread Dave Martin
This patch adds the following registers for access via the KVM_{GET,SET}_ONE_REG interface: * KVM_REG_ARM64_SVE_ZREG(n, i) (n = 0..31) (in 2048-bit slices) * KVM_REG_ARM64_SVE_PREG(n, i) (n = 0..15) (in 256-bit slices) * KVM_REG_ARM64_SVE_FFR(i) (in 256-bit slices) In order to adapt

[PATCH v6 12/27] KVM: arm64/sve: System register context switch and access support

2019-03-19 Thread Dave Martin
This patch adds the necessary support for context switching ZCR_EL1 for each vcpu. ZCR_EL1 is trapped alongside the FPSIMD/SVE registers, so it makes sense for it to be handled as part of the guest FPSIMD/SVE context for context switch purposes instead of handling it as a general system register.

[PATCH v6 16/27] KVM: arm64: Factor out core register ID enumeration

2019-03-19 Thread Dave Martin
In preparation for adding logic to filter out some KVM_REG_ARM_CORE registers from the KVM_GET_REG_LIST output, this patch factors out the core register enumeration into a separate function and rebuilds num_core_regs() on top of it. This may be a little more expensive (depending on how good a job

[PATCH v6 19/27] KVM: arm64: Enumerate SVE register indices for KVM_GET_REG_LIST

2019-03-19 Thread Dave Martin
This patch includes the SVE register IDs in the list returned by KVM_GET_REG_LIST, as appropriate. On a non-SVE-enabled vcpu, no new IDs are added. On an SVE-enabled vcpu, IDs for the FPSIMD V-registers are removed from the list, since userspace is required to access the Z- registers instead in

[PATCH v6 09/27] KVM: arm64: Add a vcpu flag to control SVE visibility for the guest

2019-03-19 Thread Dave Martin
Since SVE will be enabled or disabled on a per-vcpu basis, a flag is needed in order to track which vcpus have it enabled. This patch adds a suitable flag and a helper for checking it. Signed-off-by: Dave Martin Reviewed-by: Alex Bennée --- arch/arm64/include/asm/kvm_host.h | 4 1 file

[PATCH v6 08/27] arm64/sve: Enable SVE state tracking for non-task contexts

2019-03-19 Thread Dave Martin
The current FPSIMD/SVE context handling support for non-task (i.e., KVM vcpu) contexts does not take SVE into account. This means that only task contexts can safely use SVE at present. In preparation for enabling KVM guests to use SVE, it is necessary to keep track of SVE state for non-task

[PATCH v6 14/27] KVM: Allow 2048-bit register access via ioctl interface

2019-03-19 Thread Dave Martin
The Arm SVE architecture defines registers that are up to 2048 bits in size (with some possibility of further future expansion). In order to avoid the need for an excessively large number of ioctls when saving and restoring a vcpu's registers, this patch adds a #define to make support for

[PATCH v6 15/27] KVM: arm64: Add missing #include of in guest.c

2019-03-19 Thread Dave Martin
arch/arm64/kvm/guest.c uses the string functions, but the corresponding header is not included. We seem to get away with this for now, but for completeness this patch adds the #include, in preparation for adding yet more memset() calls. Signed-off-by: Dave Martin --- arch/arm64/kvm/guest.c | 1

[PATCH v6 04/27] KVM: arm64: Refactor kvm_arm_num_regs() for easier maintenance

2019-03-19 Thread Dave Martin
kvm_arm_num_regs() adds together various partial register counts in a freeform sum expression, which makes it harder than necessary to read diffs that add, modify or remove a single term in the sum (which is expected to the common case under maintenance). This patch refactors the code to add the

[PATCH v6 11/27] KVM: arm64: Support runtime sysreg visibility filtering

2019-03-19 Thread Dave Martin
Some optional features of the Arm architecture add new system registers that are not present in the base architecture. Where these features are optional for the guest, the visibility of these registers may need to depend on some runtime configuration, such as a flag passed to KVM_ARM_VCPU_INIT.

[PATCH v6 10/27] KVM: arm64: Propagate vcpu into read_id_reg()

2019-03-19 Thread Dave Martin
Architecture features that are conditionally visible to the guest will require run-time checks in the ID register accessor functions. In particular, read_id_reg() will need to perform checks in order to generate the correct emulated value for certain ID register fields such as ID_AA64PFR0_EL1.SVE

[PATCH v6 07/27] arm64/sve: Check SVE virtualisability

2019-03-19 Thread Dave Martin
Due to the way the effective SVE vector length is controlled and trapped at different exception levels, certain mismatches in the sets of vector lengths supported by different physical CPUs in the system may prevent straightforward virtualisation of SVE at parity with the host. This patch

[PATCH v6 06/27] arm64/sve: Clarify role of the VQ map maintenance functions

2019-03-19 Thread Dave Martin
The roles of sve_init_vq_map(), sve_update_vq_map() and sve_verify_vq_map() are highly non-obvious to anyone who has not dug through cpufeatures.c in detail. Since the way these functions interact with each other is more important here than a full understanding of the cpufeatures code, this patch

[PATCH v6 05/27] KVM: arm64: Add missing #includes to kvm_host.h

2019-03-19 Thread Dave Martin
kvm_host.h uses some declarations from other headers that are currently included by accident, without an explicit #include. This patch adds a few #includes that are clearly missing. Although the header builds without them today, this should help to avoid future surprises. Signed-off-by: Dave

[PATCH v6 02/27] arm64: fpsimd: Always set TIF_FOREIGN_FPSTATE on task state flush

2019-03-19 Thread Dave Martin
This patch updates fpsimd_flush_task_state() to mirror the new semantics of fpsimd_flush_cpu_state() introduced by commit d8ad71fa38a9 ("arm64: fpsimd: Fix TIF_FOREIGN_FPSTATE after invalidating cpu regs"). Both functions now implicitly set TIF_FOREIGN_FPSTATE to indicate that the task's FPSIMD

[PATCH v6 03/27] KVM: arm64: Delete orphaned declaration for __fpsimd_enabled()

2019-03-19 Thread Dave Martin
__fpsimd_enabled() no longer exists, but a dangling declaration has survived in kvm_hyp.h. This patch gets rid of it. Signed-off-by: Dave Martin Reviewed-by: Alex Bennée --- arch/arm64/include/asm/kvm_hyp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_hyp.h

[PATCH v6 01/27] KVM: Documentation: Document arm64 core registers in detail

2019-03-19 Thread Dave Martin
Since the the sizes of individual members of the core arm64 registers vary, the list of register encodings that make sense is not a simple linear sequence. To clarify which encodings to use, this patch adds a brief list to the documentation. Signed-off-by: Dave Martin Reviewed-by: Julien Grall

[PATCH v5 00/26] KVM: arm64: SVE guest support

2019-03-19 Thread Dave Martin
This series implements support for allowing KVM guests to use the Arm Scalable Vector Extension (SVE), superseding the previous v5 series [1]. The patches are also available on a branch for reviewer convenience. [2] The patches are based on v5.1-rc1. The series has been reworked to remove the

Re: [RFC PATCH] KVM: arm/arm64: Enable direct irqfd MSI injection

2019-03-19 Thread Marc Zyngier
On Tue, 19 Mar 2019 15:59:00 +, Zenghui Yu wrote: > > Hi Marc, > > On 2019/3/19 18:01, Marc Zyngier wrote: > > On Tue, 19 Mar 2019 09:09:43 +0800 > > Zenghui Yu wrote: > > > >> Hi all, > >> > >> On 2019/3/18 3:35, Marc Zyngier wrote: > >>> A first approach would be to keep a small cache

Re: [PATCH] kvm: arm: Fix handling of stage2 huge mappings

2019-03-19 Thread Zenghui Yu
Hi Suzuki, On 2019/3/19 22:11, Suzuki K Poulose wrote: We rely on the mmu_notifier call backs to handle the split/merge of huge pages and thus we are guaranteed that, while creating a block mapping, either the entire block is unmapped at stage2 or it is missing permission. However, we miss a

Re: [RFC PATCH] KVM: arm/arm64: Enable direct irqfd MSI injection

2019-03-19 Thread Zenghui Yu
Hi Marc, On 2019/3/19 18:01, Marc Zyngier wrote: On Tue, 19 Mar 2019 09:09:43 +0800 Zenghui Yu wrote: Hi all, On 2019/3/18 3:35, Marc Zyngier wrote: A first approach would be to keep a small cache of the last few successful translations for this ITS, cache that could be looked-up by

Re: [PATCH 1/2] KVM: arm/arm64: vgic-its: Take the srcu lock when writing to guest memory

2019-03-19 Thread Marc Zyngier
Hi Eric, On Tue, 19 Mar 2019 15:16:38 +, Auger Eric wrote: > > Hi Marc, > > On 3/19/19 2:30 PM, Marc Zyngier wrote: > > When halting a guest, QEMU flushes the virtual ITS caches, which > > amounts to writing to the various tables that the guest has allocated. > > > > When doing this, we

Re: [PATCH 2/2] KVM: arm/arm64: vgic-its: Take the srcu lock when parsing the memslots

2019-03-19 Thread Auger Eric
Hi Marc, On 3/19/19 2:30 PM, Marc Zyngier wrote: > Calling kvm_is_visible_gfn() implies that we're parsing the memslots, > and doing this without the srcu lock is frown upon: > > [12704.164532] = > [12704.164544] WARNING: suspicious RCU usage > [12704.164560]

Re: [PATCH 1/2] KVM: arm/arm64: vgic-its: Take the srcu lock when writing to guest memory

2019-03-19 Thread Auger Eric
Hi Marc, On 3/19/19 2:30 PM, Marc Zyngier wrote: > When halting a guest, QEMU flushes the virtual ITS caches, which > amounts to writing to the various tables that the guest has allocated. > > When doing this, we fail to take the srcu lock, and the kernel > shouts loudly if running a lockdep

Re: [RFC] arm/cpu: fix soft lockup panic after resuming from stop

2019-03-19 Thread Heyi Guo
Hi Christoffer and Steve, On 2019/3/15 16:59, Christoffer Dall wrote: Hi Steve, On Wed, Mar 13, 2019 at 10:11:30AM +, Steven Price wrote: Personally I think what we need is: * Either a patch like the one from Heyi Guo (save/restore CNTVCT_EL0) or alternatively hooking up

[PATCH] kvm: arm: Fix handling of stage2 huge mappings

2019-03-19 Thread Suzuki K Poulose
We rely on the mmu_notifier call backs to handle the split/merge of huge pages and thus we are guaranteed that, while creating a block mapping, either the entire block is unmapped at stage2 or it is missing permission. However, we miss a case where the block mapping is split for dirty logging

[PATCH 2/2] KVM: arm/arm64: vgic-its: Take the srcu lock when parsing the memslots

2019-03-19 Thread Marc Zyngier
Calling kvm_is_visible_gfn() implies that we're parsing the memslots, and doing this without the srcu lock is frown upon: [12704.164532] = [12704.164544] WARNING: suspicious RCU usage [12704.164560] 5.1.0-rc1-8-g600025238f51-dirty #16 Tainted: GW

[PATCH 1/2] KVM: arm/arm64: vgic-its: Take the srcu lock when writing to guest memory

2019-03-19 Thread Marc Zyngier
When halting a guest, QEMU flushes the virtual ITS caches, which amounts to writing to the various tables that the guest has allocated. When doing this, we fail to take the srcu lock, and the kernel shouts loudly if running a lockdep kernel: [ 69.680416] = [

[PATCH 0/2] KVM: arm/arm64: vgic-its: Guest memory access fixes

2019-03-19 Thread Marc Zyngier
While messing with something completely different, I managed to trigger a number of RCU warnings, due to the lack of srcu locking in the ITS code. Andre partially addressed those last year[1], but there was some more left. [1]

[RFC] Question about enable doorbell irq and halt_poll process

2019-03-19 Thread Tangnianyao (ICT)
Hi, all Using gicv4, when guest is waiting for irq, it sends wfi and traps to kvm. When vlpi is forwarded to PE after its_vpe_deschedule, before halt_poll in kvm_vcpu_block, halt_poll may increase latency for this vlpi getting to guest. In halt_poll process, it checks if there's pending irq for

Re: [RFC PATCH] KVM: arm/arm64: Enable direct irqfd MSI injection

2019-03-19 Thread Marc Zyngier
On Tue, 19 Mar 2019 09:09:43 +0800 Zenghui Yu wrote: > Hi all, > > On 2019/3/18 3:35, Marc Zyngier wrote: > > On Sun, 17 Mar 2019 14:36:13 +, > > Zenghui Yu wrote: > >> > >> Currently, IRQFD on arm still uses the deferred workqueue mechanism > >> to inject interrupts into guest, which

Re: [RFC] Question about TLB flush while set Stage-2 huge pages

2019-03-19 Thread Zenghui Yu
Hi Suzuki, On 2019/3/19 1:34, Suzuki K Poulose wrote: Hi ! On Sun, Mar 17, 2019 at 09:34:11PM +0800, Zenghui Yu wrote: Hi Suzuki, ---8<--- test: kvm: arm: Maybe two more fixes Applied based on Suzuki's patch. Signed-off-by: Zenghui Yu --- virt/kvm/arm/mmu.c | 8 ++-- 1 file

[PATCH v7 7/10] KVM: arm/arm64: context-switch ptrauth registers

2019-03-19 Thread Amit Daniel Kachhap
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, with a semi-lazy context switch of the pointer auth state. Pointer authentication feature is only enabled when VHE is built in the kernel

[PATCH v7 9/10] KVM: arm64: docs: document KVM support of pointer authentication

2019-03-19 Thread Amit Daniel Kachhap
This adds sections for KVM API extension for pointer authentication. A brief description about usage of pointer authentication for KVM guests is added in the arm64 documentations. Signed-off-by: Amit Daniel Kachhap Cc: Mark Rutland Cc: Christoffer Dall Cc: Marc Zyngier Cc:

[PATCH v7 8/10] KVM: arm64: Add capability to advertise ptrauth for guest

2019-03-19 Thread Amit Daniel Kachhap
This patch advertises the capability of pointer authentication when system supports pointer authentication and VHE mode present. Signed-off-by: Amit Daniel Kachhap Cc: Mark Rutland Cc: Marc Zyngier Cc: Christoffer Dall Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/kvm/reset.c | 4

[kvmtool PATCH v7 10/10] KVM: arm/arm64: Add a vcpu feature for pointer authentication

2019-03-19 Thread Amit Daniel Kachhap
This is a runtime capabality for KVM tool to enable Arm64 8.3 Pointer Authentication in guest kernel. A command line option --ptrauth is required for this. Signed-off-by: Amit Daniel Kachhap --- arm/aarch32/include/kvm/kvm-cpu-arch.h| 1 + arm/aarch64/include/asm/kvm.h | 2 ++

[PATCH v7 2/10] KVM: arm64: Support runtime sysreg visibility filtering

2019-03-19 Thread Amit Daniel Kachhap
From: Dave Martin Some optional features of the Arm architecture add new system registers that are not present in the base architecture. Where these features are optional for the guest, the visibility of these registers may need to depend on some runtime configuration, such as a flag passed to

[PATCH v7 0/10] Add ARMv8.3 pointer authentication for kvm guest

2019-03-19 Thread Amit Daniel Kachhap
Hi, This patch series adds pointer authentication support for KVM guest and is based on top of Linux 5.1-rc1. The basic patches in this series was originally posted by Mark Rutland earlier[1,2] and contains some history of this work. Extension Overview:

[PATCH v7 1/10] KVM: arm64: Propagate vcpu into read_id_reg()

2019-03-19 Thread Amit Daniel Kachhap
From: Dave Martin Architecture features that are conditionally visible to the guest will require run-time checks in the ID register accessor functions. In particular, read_id_reg() will need to perform checks in order to generate the correct emulated value for certain ID register fields such as

[PATCH v7 3/10] KVM: arm64: Move hyp_symbol_addr to fix dependency

2019-03-19 Thread Amit Daniel Kachhap
Currently hyp_symbol_addr is palced in kvm_mmu.h which is mostly used by __hyp_this_cpu_ptr in kvm_asm.h but it cannot include kvm_mmu.h directly as kvm_mmu.h uses kvm_ksym_ref which is defined inside kvm_asm.h. Hence, hyp_symbol_addr is moved inside kvm_asm.h to fix this dependency on each other.

[PATCH v7 6/10] KVM: arm64: Add vcpu feature flags to control ptrauth accessibility

2019-03-19 Thread Amit Daniel Kachhap
Since Pointer authentication will be enabled or disabled on a per-vcpu basis, vcpu feature flags are added in order to know which vcpus have it enabled from userspace. This features will allow the KVM guest to allow the handling of pointer authentication instructions or to treat them as undefined

[PATCH v7 5/10] KVM: arm/arm64: preserve host MDCR_EL2 value

2019-03-19 Thread Amit Daniel Kachhap
Save host MDCR_EL2 value during kvm HYP initialisation and restore after every switch from host to guest. There should not be any change in functionality due to this. The value of mdcr_el2 is now stored in struct kvm_cpu_context as both host and guest can now use this field in a common way.

[PATCH v7 4/10] KVM: arm/arm64: preserve host HCR_EL2 value

2019-03-19 Thread Amit Daniel Kachhap
From: Mark Rutland When restoring HCR_EL2 for the host, KVM uses HCR_HOST_VHE_FLAGS, which is a constant value. This works today, as the host HCR_EL2 value is always the same, but this will get in the way of supporting extensions that require HCR_EL2 bits to be set conditionally for the host.