Re: Unexpected interrupt received in Guest OS when booting after "system_reset"

2019-03-29 Thread Heyi Guo
Hi Marc, The patch works. I tested for 1.5 hour and 52 VM resets. There were 16 times that a virtual LPI left in the ap_list (seen by an additional printk) during reset and we never saw "Unexpected interrupt received" any more. Just a minor comment: how about replacing /vcpu->arch.vgic_cpu./ w

Re: Unexpected interrupt received in Guest OS when booting after "system_reset"

2019-03-29 Thread Marc Zyngier
On 29/03/2019 09:19, Heyi Guo wrote: > Hi Marc, > > The patch works. I tested for 1.5 hour and 52 VM resets. There were > 16 times that a virtual LPI left in the ap_list (seen by an > additional printk) during reset and we never saw "Unexpected > interrupt received" any more. Thanks for testing,

[PATCH v7 00/27] KVM: arm64: SVE guest support

2019-03-29 Thread Dave Martin
This series implements support for allowing KVM guests to use the Arm Scalable Vector Extension (SVE), superseding the previous v6 series [1]. The patches are also available on a branch for reviewer convenience. [2] The patches are based on v5.1-rc2. This series addresses a couple of minor revie

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

2019-03-29 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 t

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

2019-03-29 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 Tested-by: zhang.lei --- arch/arm64/include/asm/kvm_hyp.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm64/inc

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

2019-03-29 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 conte

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

2019-03-29 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 Tested-by: zhang.lei --- arch/arm64/include/asm/kvm_host

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

2019-03-29 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 v7 13/27] KVM: arm64/sve: Context switch the SVE registers

2019-03-29 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 configure

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

2019-03-29 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 individu

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

2019-03-29 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 v7 17/27] KVM: arm64: Reject ioctl access to FPSIMD V-regs on SVE vcpus

2019-03-29 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 feature

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

2019-03-29 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 chang

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

2019-03-29 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 o

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

2019-03-29 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 f

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

2019-03-29 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 appro

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

2019-03-29 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 Reviewed-by: Julien Thierry Tested-by: zhang.lei

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

2019-03-29 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 userspac

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

2019-03-29 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 v7 07/27] arm64/sve: Check SVE virtualisability

2019-03-29 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 analyses

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

2019-03-29 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 outside

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

2019-03-29 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 st

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

2019-03-29 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 Reviewed-by: Julien Thierry Tested-by: zhang.lei --- Changes since v5: * [Julien T

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

2019-03-29 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 v7 11/27] KVM: arm64: Support runtime sysreg visibility filtering

2019-03-29 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. F

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

2019-03-29 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 gracefully

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

2019-03-29 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 Mar

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

2019-03-29 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 v7 15/27] KVM: arm64: Add missing #include of in guest.c

2019-03-29 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 Tested-by: zhang.lei --- arch/

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

2019-03-29 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. --- Documentation/virtual/kvm/api.txt

Re: [PATCH v7 00/27] KVM: arm64: SVE guest support

2019-03-29 Thread Marc Zyngier
Hi Dave, On 29/03/2019 13:00, Dave Martin wrote: > This series implements support for allowing KVM guests to use the Arm > Scalable Vector Extension (SVE), superseding the previous v6 series [1]. > > The patches are also available on a branch for reviewer convenience. [2] > > The patches are bas

Re: [PATCH v7 00/27] KVM: arm64: SVE guest support

2019-03-29 Thread Dave Martin
On Fri, Mar 29, 2019 at 02:56:36PM +, Marc Zyngier wrote: > Hi Dave, > > On 29/03/2019 13:00, Dave Martin wrote: > > This series implements support for allowing KVM guests to use the Arm > > Scalable Vector Extension (SVE), superseding the previous v6 series [1]. > > > > The patches are also

[PATCH 1/1] KVM: arm/arm64: arch_timer: Fix TimerValue TVAL calculation in KVM

2019-03-29 Thread Wei Huang
Recently the generic timer test of kvm-unit-tests failed to complete (stalled) when a physical timer is being used. This issue is caused by incorrect update of CNT_CVAL when TimerValue is being accessed, introduced by 'Commit 84135d3d18da ("KVM: arm/arm64: consolidate arch timer trap handlers")'. A

Re: Unexpected interrupt received in Guest OS when booting after "system_reset"

2019-03-29 Thread Heyi Guo
On 2019/3/29 18:54, Marc Zyngier wrote: On 29/03/2019 09:19, Heyi Guo wrote: Hi Marc, The patch works. I tested for 1.5 hour and 52 VM resets. There were 16 times that a virtual LPI left in the ap_list (seen by an additional printk) during reset and we never saw "Unexpected interrupt receive