[PATCH 3/4] KVM: arm64: Fix address check for memory slot

2021-03-14 Thread Gavin Shan
ill usable. struct kvm_userspace_memory_region { __u32 slot; /* 1*/ __u32 flags; /* 0*/ __u64 guest_phys_addr;/* 0xfff000 */ __u64 memory_size;/* 0x1000 */ __u64 userspace_addr; }; Signed-off

[PATCH 0/4] KVM: arm64: Minor page fault handler improvement

2021-03-14 Thread Gavin Shan
The series includes several minior improvements to stage-2 page fault handler: PATCH[1/2] are cleaning up the code. PATCH[3] fixes the address range check on adding new memory slot. PATCH[4] don't retrieve the memory slot again in the page fault handler to save a bit CPU cycles. Gavin Sh

[PATCH 4/4] KVM: arm64: Don't retrieve memory slot again in page fault handler

2021-03-14 Thread Gavin Shan
from 928ms to 864ms. Signed-off-by: Gavin Shan --- arch/arm64/kvm/mmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index a5a8ade9fde4..4a4abcccfafb 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -846,7 +

[PATCH 1/4] KVM: arm64: Hide kvm_mmu_wp_memory_region()

2021-03-14 Thread Gavin Shan
We needn't expose the function as it's only used by mmu.c. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/mmu.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/i

[PATCH 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-14 Thread Gavin Shan
find_vma_intersection() has been existing to search the intersected vma. This uses the function where it's applicable, to simplify the code. Signed-off-by: Gavin Shan --- arch/arm64/kvm/mmu.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/mm

Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Gavin Shan
Hi Marc, On 3/15/21 7:52 PM, Marc Zyngier wrote: On Mon, 15 Mar 2021 04:18:42 +, Gavin Shan wrote: find_vma_intersection() has been existing to search the intersected vma. This uses the function where it's applicable, to simplify the code. Signed-off-by: Gavin Shan --- arch/arm6

Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Gavin Shan
Hi Keqian, On 3/15/21 7:04 PM, Keqian Zhu wrote: On 2021/3/15 12:18, Gavin Shan wrote: find_vma_intersection() has been existing to search the intersected vma. This uses the function where it's applicable, to simplify the code. Signed-off-by: Gavin Shan --- arch/arm64/kvm/mmu.c

Re: [PATCH 3/4] KVM: arm64: Fix address check for memory slot

2021-03-15 Thread Gavin Shan
Hi Keqian, On 3/15/21 6:33 PM, Keqian Zhu wrote: FYI, this has been fixed by Marc in commit 262b003d059c. Yeah, I didn't check 5.12.rc3 code where the issue has been fixed. So please ignore this one and sorry for the noise. Thanks, Gavin On 2021/3/15 12:18, Gavin Shan wrote: The

Re: [PATCH 4/4] KVM: arm64: Don't retrieve memory slot again in page fault handler

2021-03-15 Thread Gavin Shan
Hi Keqian, On 3/15/21 7:25 PM, Keqian Zhu wrote: On 2021/3/15 12:18, Gavin Shan wrote: We needn't retrieve the memory slot again in user_mem_abort() because the corresponding memory slot has been passed from the caller. This I think you are right, though fault_ipa will be adjusted when w

Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Gavin Shan
Hi Keqian, On 3/15/21 8:42 PM, Gavin Shan wrote: On 3/15/21 7:04 PM, Keqian Zhu wrote: On 2021/3/15 12:18, Gavin Shan wrote: find_vma_intersection() has been existing to search the intersected vma. This uses the function where it's applicable, to simplify the code. Signed-off-by: Gavin

[PATCH v2 0/3] KVM: arm64: Minor page fault handler improvement

2021-03-15 Thread Gavin Shan
eqian (Gavin) * Drop patch to fix IPA limit boundary issue(Keqian) * Comments on why we use __gfn_to_pfn_memslot() (Keqian) Gavin Shan (3): KVM: arm64: Hide kvm_mmu_wp_memory_region() KVM: arm64: Use find_vma_intersection() KVM: arm64: Don't retrieve memory slot again in

[PATCH v2 1/3] KVM: arm64: Hide kvm_mmu_wp_memory_region()

2021-03-15 Thread Gavin Shan
We needn't expose the function as it's only used by mmu.c since it was introduced by commit c64735554c0a ("KVM: arm: Add initial dirty page locking support"). Signed-off-by: Gavin Shan Reviewed-by: Keqian Zhu --- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/mm

[PATCH v2 3/3] KVM: arm64: Don't retrieve memory slot again in page fault handler

2021-03-15 Thread Gavin Shan
from 928ms to 864ms. Signed-off-by: Gavin Shan Reviewed-by: Keqian Zhu --- arch/arm64/kvm/mmu.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 192e0df2fc8e..2491b40a294a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/

[PATCH v2 2/3] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Gavin Shan
find_vma_intersection() has been existing to search the intersected vma. This uses the function where it's applicable, to simplify the code. Signed-off-by: Gavin Shan Reviewed-by: Keqian Zhu --- arch/arm64/kvm/mmu.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --

Re: [PATCH] KVM: arm64: Correctly handle the mmio faulting

2021-04-20 Thread Gavin Shan
Hi Keqian and Santosh, On 4/21/21 12:59 PM, Keqian Zhu wrote: On 2020/10/22 0:16, Santosh Shukla wrote: The Commit:6d674e28 introduces a notion to detect and handle the device mapping. The commit checks for the VM_PFNMAP flag is set in vma->flags and if set then marks force_pte to true such tha

Re: [PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-20 Thread Gavin Shan
Hi Keqian, On 4/16/21 12:03 AM, Keqian Zhu wrote: The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes these two mapping path hard to sync. Remove the mapping code while keep the usef

Re: [PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-20 Thread Gavin Shan
Hi Keqian, On 4/16/21 12:03 AM, Keqian Zhu wrote: The MMIO region of a device maybe huge (GB level), try to use block mapping in stage2 to speedup both map and unmap. Compared to normal memory mapping, we should consider two more points when try block mapping for MMIO region: 1. For normal mem

Re: [PATCH] KVM: arm64: Correctly handle the mmio faulting

2021-04-21 Thread Gavin Shan
Hi Marc, On 4/21/21 9:59 PM, Marc Zyngier wrote: On Wed, 21 Apr 2021 07:17:44 +0100, Keqian Zhu wrote: On 2021/4/21 14:20, Gavin Shan wrote: On 4/21/21 12:59 PM, Keqian Zhu wrote: On 2020/10/22 0:16, Santosh Shukla wrote: The Commit:6d674e28 introduces a notion to detect and handle the

Re: [PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-21 Thread Gavin Shan
Hi Keqian, On 4/21/21 4:28 PM, Keqian Zhu wrote: On 2021/4/21 14:38, Gavin Shan wrote: On 4/16/21 12:03 AM, Keqian Zhu wrote: The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes

Re: [PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-21 Thread Gavin Shan
Hi Keqian, On 4/21/21 4:36 PM, Keqian Zhu wrote: On 2021/4/21 15:52, Gavin Shan wrote: On 4/16/21 12:03 AM, Keqian Zhu wrote: The MMIO region of a device maybe huge (GB level), try to use block mapping in stage2 to speedup both map and unmap. Compared to normal memory mapping, we should

Re: [PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-22 Thread Gavin Shan
check. Signed-off-by: Keqian Zhu --- arch/arm64/kvm/mmu.c | 38 +++--- 1 file changed, 3 insertions(+), 35 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 8711894db8c2..c59af5ca01b0 100644 --- a/arch

Re: [PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-22 Thread Gavin Shan
and check these two points when selecting block mapping size for MMIO region. Signed-off-by: Keqian Zhu --- arch/arm64/kvm/mmu.c | 61 1 file changed, 51 insertions(+), 10 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/

Re: [PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-22 Thread Gavin Shan
Hi Marc, On 4/22/21 4:51 PM, Marc Zyngier wrote: On Thu, 22 Apr 2021 03:25:23 +0100, Gavin Shan wrote: On 4/21/21 4:36 PM, Keqian Zhu wrote: On 2021/4/21 15:52, Gavin Shan wrote: On 4/16/21 12:03 AM, Keqian Zhu wrote: The MMIO region of a device maybe huge (GB level), try to use block

Re: [PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-22 Thread Gavin Shan
Hi Keqian, On 4/22/21 5:41 PM, Keqian Zhu wrote: On 2021/4/22 10:12, Gavin Shan wrote: On 4/21/21 4:28 PM, Keqian Zhu wrote: On 2021/4/21 14:38, Gavin Shan wrote: On 4/16/21 12:03 AM, Keqian Zhu wrote: [...] Yeah, Sorry that I missed that part. Something associated with Santosh's

Re: [PATCH] KVM: arm64: Correctly handle the mmio faulting

2021-04-22 Thread Gavin Shan
Hi Marc, On 4/22/21 4:50 PM, Marc Zyngier wrote: On Thu, 22 Apr 2021 03:02:00 +0100, Gavin Shan wrote: On 4/21/21 9:59 PM, Marc Zyngier wrote: On Wed, 21 Apr 2021 07:17:44 +0100, Keqian Zhu wrote: On 2021/4/21 14:20, Gavin Shan wrote: On 4/21/21 12:59 PM, Keqian Zhu wrote: On 2020/10/22

[PATCH v3 00/21] Support SDEI Virtualization

2021-05-06 Thread Gavin Shan
re totally changed (Gavin) * Added ioctl commands to support migration(Gavin) Gavin Shan (21): KVM: arm64: Introduce template for inline functions KVM: arm64: Add SDEI virtualization infrastructure KVM: arm64: Support SDEI_VERSION h

[PATCH v3 01/21] KVM: arm64: Introduce template for inline functions

2021-05-06 Thread Gavin Shan
by SDEI virtualization support. Signed-off-by: Gavin Shan --- include/kvm/arm_hypercalls.h | 34 +++--- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h index 0e2509d27910..1120eff7aa28 100644

[PATCH v3 02/21] KVM: arm64: Add SDEI virtualization infrastructure

2021-05-06 Thread Gavin Shan
ect to save the preempted context during SDEI event delivery. The error is returned for all SDEI hypercalls for now. They will be implemented by the subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 4 + arch/arm64/include/asm/kvm_sd

[PATCH v3 04/21] KVM: arm64: Support SDEI_EVENT_REGISTER hypercall

2021-05-06 Thread Gavin Shan
registered successfully, the KVM SDEI event (object) is created or updated because the same KVM SDEI event is shared by multiple vCPUs if it's a private event. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 122 ++ 1 file changed, 122 insertions

[PATCH v3 03/21] KVM: arm64: Support SDEI_VERSION hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_VERSION hypercall by returning v1.0.0 simply when the functionality is supported on the VM and vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index

[PATCH v3 05/21] KVM: arm64: Support SDEI_EVENT_{ENABLE, DISABLE} hypercall

2021-05-06 Thread Gavin Shan
ic vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 68 +++ 1 file changed, 68 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index d3ea3eee154b..b022ce0a202b 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei

[PATCH v3 06/21] KVM: arm64: Support SDEI_EVENT_CONTEXT hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_EVENT_CONTEXT hypercall. It's used by the guest to retrieved the original registers (R0 - R17) in its SDEI event handler. Those registers can be corrupted during the SDEI event delivery. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v3 07/21] KVM: arm64: Support SDEI_EVENT_UNREGISTER hypercall

2021-05-06 Thread Gavin Shan
cific vCPU once it's unregistered successfully. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 61 +++ 1 file changed, 61 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index b4162efda470..a3ba69dc91cb 100644 --- a/arch/arm64/kv

[PATCH v3 08/21] KVM: arm64: Support SDEI_EVENT_STATUS hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_EVENT_STATUS hypercall. It's used by the guest to retrieve a bitmap to indicate the SDEI event states, including registration, enablement and delivery state. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 50 +++ 1 file ch

[PATCH v3 09/21] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_EVENT_GET_INFO hypercall. It's used by the guest to retrieve various information about the supported (exported) events, including type, signaled, route mode and affinity for the shared events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v3 10/21] KVM: arm64: Support SDEI_EVENT_ROUTING_SET hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_EVENT_ROUTING_SET hypercall. It's used by the guest to set route mode and affinity for the registered KVM event. It's only valid for the shared events. It's not allowed to do so when the corresponding event has been raised to the guest. Signed-off-by: Gavin

[PATCH v3 11/21] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_PE_{MASK, UNMASK} hypercall. They are used by the guest to stop the specific vCPU from receiving SDEI events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b

[PATCH v3 12/21] KVM: arm64: Support SDEI_{PRIVATE, SHARED}_RESET hypercall

2021-05-06 Thread Gavin Shan
This supports SDEI_{PRIVATE, SHARED}_RESET. They are used by the guest to purge the private or shared SDEI events, which are registered previously. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 29 + 1 file changed, 29 insertions(+) diff --git a/arch/arm64

[PATCH v3 13/21] KVM: arm64: Impment SDEI event delivery

2021-05-06 Thread Gavin Shan
. * SDEI event with critical priority can preempt those with normal priority. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/arm.c | 3 ++ arch/arm64/kvm/sdei.c | 84

[PATCH v3 14/21] KVM: arm64: Support SDEI_EVENT_{COMPLETE, COMPLETE_AND_RESUME} hypercall

2021-05-06 Thread Gavin Shan
the interrupted context. * If it's SDEI_EVENT_COMPLETE_AND_RESUME hypercall, IRQ exception is injected. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 1 + arch/arm64/include/asm/kvm_host.h| 1 + arch/arm64/kvm/hyp/exception.c | 7 +++ arch/arm6

[PATCH v3 15/21] KVM: arm64: Support SDEI event notifier

2021-05-06 Thread Gavin Shan
The owner of the SDEI event, like asynchronous page fault, need know the state of injected SDEI event. This supports SDEI event state updating by introducing notifier mechanism. It's notable the notifier (handler) should be capable of migration. Signed-off-by: Gavin Shan --- arch/arm64/in

[PATCH v3 16/21] KVM: arm64: Support SDEI ioctl commands on VM

2021-05-06 Thread Gavin Shan
ulate the registered SDEI event Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 17 +++ arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/sdei.c | 171 + include/uapi/linux/

[PATCH v3 17/21] KVM: arm64: Support SDEI ioctl commands on vCPU

2021-05-06 Thread Gavin Shan
state related to SDEI handling * KVM_SDEI_CMD_SET_VCPU_STATE Populate vCPU state related to SDEI handling Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 7 + arch/arm64/kvm/arm.c | 3 + arch/arm6

[PATCH v3 18/21] KVM: arm64: Support SDEI event injection

2021-05-06 Thread Gavin Shan
This supports SDEI event injection by implementing kvm_sdei_inject(). It's called by kernel directly or VMM through ioctl command to inject SDEI event to the specific vCPU. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 2 + arch/arm64/include/uapi/asm/kvm_sdei.h

[PATCH v3 19/21] KVM: arm64: Support SDEI event cancellation

2021-05-06 Thread Gavin Shan
ynchronous page fault. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/sdei.c | 49 +++ 2 files changed, 50 insertions(+) diff --git a/arch/arm64/include/asm/kvm_sdei.h b/arch/arm64/include/asm/kvm_sdei.h ind

[PATCH v3 20/21] KVM: arm64: Export SDEI capability

2021-05-06 Thread Gavin Shan
The SDEI functionality is ready to be exported so far. This adds new capability (KVM_CAP_ARM_SDEI) and exports it. Signed-off-by: Gavin Shan --- arch/arm64/kvm/arm.c | 3 +++ include/uapi/linux/kvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm

[PATCH v3 21/21] KVM: selftests: Add SDEI test case

2021-05-06 Thread Gavin Shan
ster event) SDEI_1_0_FN_SDEI_PE_MASK(CPU offline) Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/aarch64/sdei.c | 172 + 2 files changed, 173 insertions(+) create mode 100644 tools/testing/selftests/kvm/aarch64/sdei.c di

[PATCH v3 01/15] KVM: async_pf: Move struct kvm_async_pf around

2021-05-06 Thread Gavin Shan
uot;struct kvm_async_pf". * Added stub kvm_check_async_pf_completion() when CONFIG_KVM_ASYMC_PF is disabled. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 44 +--- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/include/linux/kvm_

[PATCH v3 00/15] Support Asynchronous Page Fault

2021-05-06 Thread Gavin Shan
h_async_control" dymaicall and use it to check if the feature has been enabled. The kernel option (CONFIG_KVM_ASYNC_PF) isn't used. (James) * Add document to explain the design (James) * Make GFN hash table management generi

[PATCH v3 02/15] KVM: async_pf: Add helper function to check completion queue

2021-05-06 Thread Gavin Shan
y the newly added inline function since list_empty() and list_empty_careful() are interchangeable. Signed-off-by: Gavin Shan --- arch/x86/kvm/x86.c | 2 +- include/linux/kvm_host.h | 10 ++ virt/kvm/async_pf.c | 10 +- virt/kvm/kvm_main.c | 4 +--- 4 files change

[PATCH v3 03/15] KVM: async_pf: Make GFN slot management generic

2021-05-06 Thread Gavin Shan
rm and arm64 in subsequent patches. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 18 + virt/kvm/Kconfig | 3 ++ virt/kvm/async_pf.c | 85 3 files changed, 106 insertions(+) diff --git a/include/linux/kvm_host.h b/include/l

[PATCH v3 04/15] KVM: x86: Use generic async PF slot management

2021-05-06 Thread Gavin Shan
ff-by: Gavin Shan --- arch/x86/include/asm/kvm_host.h | 2 - arch/x86/kvm/Kconfig| 1 + arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/x86.c | 86 +++-- 4 files changed, 8 insertions(+), 83 deletions(-) diff --git a/arch/x86/includ

[PATCH v3 06/15] KVM: arm64: Add paravirtualization header files

2021-05-06 Thread Gavin Shan
onous page fault in the subsequent patches: include/uapi/asm-generic/kvm_para.h include/asm-generic/kvm_para.h arch/arm64/include/uapi/asm/kvm_para.h arch/arm64/include/asm/kvm_para.h Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_para.h | 27 ++

[PATCH v3 05/15] KVM: arm64: Export kvm_handle_user_mem_abort()

2021-05-06 Thread Gavin Shan
ingly. is_exec_fault: kvm_vcpu_trap_is_exec_fault is_write_fault: kvm_is_write_fault() esr_abt_fault_level: kvm_vcpu_trap_get_fault_level Signed-off-by: Gavin Shan --- arch/arm64/include/asm/esr.h | 6 arch/arm64/include/asm/kvm_emulate.h | 27 ++--- arch/arm64/in

[PATCH v3 07/15] KVM: arm64: Support page-not-present notification

2021-05-06 Thread Gavin Shan
uested page. "struct kvm{_,_arch}async_pf" is associated with the worker, to track the work. The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the page-ready notification delivery and control path isn't implemented and will be done in the subsequent patches. Si

[PATCH v3 08/15] KVM: arm64: Support page-ready notification

2021-05-06 Thread Gavin Shan
ready notification. The region is represented by "struct kvm_vcpu_pv_apf_data". The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the control path isn't implemented and will be done in the subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/

[PATCH v3 09/15] KVM: arm64: Support async PF hypercalls

2021-05-06 Thread Gavin Shan
quent patches. Signed-off-by: Gavin Shan --- arch/arm64/kvm/async_pf.c | 119 ++ include/linux/arm-smccc.h | 5 ++ 2 files changed, 124 insertions(+) diff --git a/arch/arm64/kvm/async_pf.c b/arch/arm64/kvm/async_pf.c index 0d2393e24ce6..3bc69a631996 100644 --- a

[PATCH v3 11/15] KVM: arm64: Export async PF capability

2021-05-06 Thread Gavin Shan
This exports the asynchronous page fault capability: * Identify capability KVM_CAP_ASYNC_{PF, PF_INT}. * Standardize SDEI event for asynchronous page fault. * Enable kernel config CONFIG_KVM_ASYNC_{PF, PF_SLOT}. Signed-off-by: Gavin Shan --- arch/arm64/include/uapi/asm/kvm_sdei.h

[PATCH v3 10/15] KVM: arm64: Support async PF ioctl commands

2021-05-06 Thread Gavin Shan
KVM_ARM_ASYNC_PF_CMD_SET_CONTROL Set control block when VM is migrated Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 14 +++ arch/arm64/include/uapi/asm/kvm.h | 19 + arch/arm64/kvm/arm.c | 6 +++ arch/arm64/kvm/async_pf.c | 64

[PATCH v3 12/15] arm64: Detect async PF para-virtualization feature

2021-05-06 Thread Gavin Shan
page fault. This also adds kernel option (CONFIG_KVM_GUEST), which is the umbrella for the optimizations related to KVM para-virtualization. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 +++ arch/arm64/include/asm/kvm_para.h | 12 +++- arch/arm64

[PATCH v3 13/15] arm64: Reschedule process on aync PF

2021-05-06 Thread Gavin Shan
state for the process, to be rescheduled. With the flag is set, there is a head of wait-queue is associated with the process. The process keeps rescheduling itself until the flag is cleared when page-ready notification is received through (PPI) interrupt. Signed-off-by: Gavin Shan --- arch/arm64/i

[PATCH v3 15/15] KVM: arm64: Add async PF document

2021-05-06 Thread Gavin Shan
This adds document to explain the interface for asynchronous page fault and how it works in general. Signed-off-by: Gavin Shan --- Documentation/virt/kvm/arm/apf.rst | 143 +++ Documentation/virt/kvm/arm/index.rst | 1 + 2 files changed, 144 insertions(+) create

[PATCH v3 14/15] arm64: Enable async PF

2021-05-06 Thread Gavin Shan
ough SMCCC interface. Besides, the version of the asynchronous page fault is validated when the feature is enabled on the guest. * The feature is disabled on guest when boot parameter "no-kvmapf" is specified. Signed-off-by: Gavin Shan --- arch/arm64/kernel/Makefile |

[PATCH] KVM: arm64: selftests: Request PMU feature in get-reg-list

2021-05-13 Thread Gavin Shan
64_SYS_REG(3, 3, 14, 15, 7), This fixes the issue of wrongly reported missing PMU registers by requesting it explicitly. Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/aarch64/get-reg-list.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/ge

Re: [PATCH] KVM: arm64: selftests: Request PMU feature in get-reg-list

2021-05-13 Thread Gavin Shan
On 5/13/21 9:14 PM, Marc Zyngier wrote: On 2021-05-13 14:06, Gavin Shan wrote: Since the following commit, PMU registers are hidden from user until it's explicitly requested by feeding feature (KVM_ARM_VCPU_PMU_V3). Otherwise, 74 missing PMU registers are missing as the following log indi

[PATCH v4 00/21] Support SDEI Virtualization

2021-08-14 Thread Gavin Shan
s almost rewritten as the data structures are totally changed (Gavin) * Added ioctl commands to support migration(Gavin) Gavin Shan (21): KVM: arm64: Introduce template for inline functions KVM: arm64: Add SDEI virtualization infras

[PATCH v4 01/21] KVM: arm64: Introduce template for inline functions

2021-08-14 Thread Gavin Shan
virtualization support. Signed-off-by: Gavin Shan --- include/kvm/arm_hypercalls.h | 34 +++--- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h index 0e2509d27910..ebecb6c68254 100644 --- a

[PATCH v4 02/21] KVM: arm64: Add SDEI virtualization infrastructure

2021-08-14 Thread Gavin Shan
ect to save the preempted context during SDEI event delivery. The error is returned for all SDEI hypercalls for now. They will be implemented by the subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 6 + arch/arm64/include/asm/kvm_sd

[PATCH v4 03/21] KVM: arm64: Support SDEI_VERSION hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_VERSION hypercall by returning v1.0.0 simply when the functionality is supported on the VM and vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index

[PATCH v4 04/21] KVM: arm64: Support SDEI_EVENT_REGISTER hypercall

2021-08-14 Thread Gavin Shan
registered successfully, the KVM SDEI event (object) is created or updated because the same KVM SDEI event is shared by multiple vCPUs if it's a private event. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 122 ++ 1 file changed, 122 insertions

[PATCH v4 05/21] KVM: arm64: Support SDEI_EVENT_{ENABLE, DISABLE} hypercall

2021-08-14 Thread Gavin Shan
ic vCPU. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 68 +++ 1 file changed, 68 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index d3ea3eee154b..b022ce0a202b 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei

[PATCH v4 06/21] KVM: arm64: Support SDEI_EVENT_CONTEXT hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_EVENT_CONTEXT hypercall. It's used by the guest to retrieved the original registers (R0 - R17) in its SDEI event handler. Those registers can be corrupted during the SDEI event delivery. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v4 07/21] KVM: arm64: Support SDEI_EVENT_UNREGISTER hypercall

2021-08-14 Thread Gavin Shan
cific vCPU once it's unregistered successfully. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 61 +++ 1 file changed, 61 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index b4162efda470..a3ba69dc91cb 100644 --- a/arch/arm64/kv

[PATCH v4 08/21] KVM: arm64: Support SDEI_EVENT_STATUS hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_EVENT_STATUS hypercall. It's used by the guest to retrieve a bitmap to indicate the SDEI event states, including registration, enablement and delivery state. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 50 +++ 1 file ch

[PATCH v4 09/21] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_EVENT_GET_INFO hypercall. It's used by the guest to retrieve various information about the supported (exported) events, including type, signaled, route mode and affinity for the shared events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c

[PATCH v4 10/21] KVM: arm64: Support SDEI_EVENT_ROUTING_SET hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_EVENT_ROUTING_SET hypercall. It's used by the guest to set route mode and affinity for the registered KVM event. It's only valid for the shared events. It's not allowed to do so when the corresponding event has been raised to the guest. Signed-off-by: Gavin

[PATCH v4 12/21] KVM: arm64: Support SDEI_{PRIVATE, SHARED}_RESET hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_{PRIVATE, SHARED}_RESET. They are used by the guest to purge the private or shared SDEI events, which are registered previously. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 29 + 1 file changed, 29 insertions(+) diff --git a/arch/arm64

[PATCH v4 11/21] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall

2021-08-14 Thread Gavin Shan
This supports SDEI_PE_{MASK, UNMASK} hypercall. They are used by the guest to stop the specific vCPU from receiving SDEI events. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b

[PATCH v4 13/21] KVM: arm64: Impment SDEI event delivery

2021-08-14 Thread Gavin Shan
. * SDEI event with critical priority can preempt those with normal priority. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/arm.c | 3 ++ arch/arm64/kvm/sdei.c | 84

[PATCH v4 14/21] KVM: arm64: Support SDEI_EVENT_{COMPLETE, COMPLETE_AND_RESUME} hypercall

2021-08-14 Thread Gavin Shan
the interrupted context. * If it's SDEI_EVENT_COMPLETE_AND_RESUME hypercall, IRQ exception is injected. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 1 + arch/arm64/include/asm/kvm_host.h| 1 + arch/arm64/kvm/hyp/exception.c | 7 +++ arch/arm6

[PATCH v4 15/21] KVM: arm64: Support SDEI event notifier

2021-08-14 Thread Gavin Shan
The owner of the SDEI event, like asynchronous page fault, need know the state of injected SDEI event. This supports SDEI event state updating by introducing notifier mechanism. It's notable the notifier (handler) should be capable of migration. Signed-off-by: Gavin Shan --- arch/arm64/in

[PATCH v4 16/21] KVM: arm64: Support SDEI ioctl commands on VM

2021-08-14 Thread Gavin Shan
ulate the registered SDEI event Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 17 +++ arch/arm64/kvm/arm.c | 3 + arch/arm64/kvm/sdei.c | 171 + include/uapi/linux/

[PATCH v4 17/21] KVM: arm64: Support SDEI ioctl commands on vCPU

2021-08-14 Thread Gavin Shan
state related to SDEI handling * KVM_SDEI_CMD_SET_VCPU_STATE Populate vCPU state related to SDEI handling Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/include/uapi/asm/kvm_sdei.h | 7 + arch/arm64/kvm/arm.c | 3 + arch/arm6

[PATCH v4 18/21] KVM: arm64: Support SDEI event injection

2021-08-14 Thread Gavin Shan
This supports SDEI event injection by implementing kvm_sdei_inject(). It's called by kernel directly or VMM through ioctl command to inject SDEI event to the specific vCPU. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 2 + arch/arm64/include/uapi/asm/kvm_sdei.h

[PATCH v4 19/21] KVM: arm64: Support SDEI event cancellation

2021-08-14 Thread Gavin Shan
ynchronous page fault. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 1 + arch/arm64/kvm/sdei.c | 49 +++ 2 files changed, 50 insertions(+) diff --git a/arch/arm64/include/asm/kvm_sdei.h b/arch/arm64/include/asm/kvm_sdei.h ind

[PATCH v4 20/21] KVM: arm64: Export SDEI capability

2021-08-14 Thread Gavin Shan
The SDEI functionality is ready to be exported so far. This adds new capability (KVM_CAP_ARM_SDEI) and exports it. Signed-off-by: Gavin Shan --- arch/arm64/kvm/arm.c | 3 +++ include/uapi/linux/kvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm

[PATCH v4 21/21] KVM: selftests: Add SDEI test case

2021-08-14 Thread Gavin Shan
ster event) SDEI_1_0_FN_SDEI_PE_MASK(CPU offline) Signed-off-by: Gavin Shan --- tools/testing/selftests/kvm/Makefile | 1 + tools/testing/selftests/kvm/aarch64/sdei.c | 171 + 2 files changed, 172 insertions(+) create mode 100644 tools/testing/selftests/kvm/aarch64/sdei.c di

Re: [PATCH v4 00/21] Support SDEI Virtualization

2021-08-14 Thread Gavin Shan
On 8/15/21 10:13 AM, Gavin Shan wrote: This series intends to virtualize Software Delegated Exception Interface (SDEI), which is defined by DEN0054A. It allows the hypervisor to deliver NMI-alike event to guest and it's needed by asynchronous page fault to deliver page-not-present notific

[PATCH v4 00/15] Support Asynchronous Page Fault

2021-08-14 Thread Gavin Shan
nc_control" dymaicall and use it to check if the feature has been enabled. The kernel option (CONFIG_KVM_ASYNC_PF) isn't used. (James) * Add document to explain the design (James) * Make GFN hash table management generic

[PATCH v4 01/15] KVM: async_pf: Move struct kvm_async_pf around

2021-08-14 Thread Gavin Shan
tub kvm_check_async_pf_completion() is also added on !CONFIG_KVM_ASYNC_PF, which is needed by subsequent patches to support asynchronous page fault on ARM64. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 44 +--- 1 file changed, 23 insertions(+), 21 deletions(-) d

[PATCH v4 02/15] KVM: async_pf: Add helper function to check completion queue

2021-08-14 Thread Gavin Shan
newly added inline function since list_empty() and list_empty_careful() are interchangeable. Signed-off-by: Gavin Shan --- arch/x86/kvm/x86.c | 2 +- include/linux/kvm_host.h | 10 ++ virt/kvm/async_pf.c | 10 +- virt/kvm/kvm_main.c | 4 +--- 4 files change

[PATCH v4 03/15] KVM: async_pf: Make GFN slot management generic

2021-08-14 Thread Gavin Shan
rm and arm64 in subsequent patches. Signed-off-by: Gavin Shan --- include/linux/kvm_host.h | 18 + virt/kvm/Kconfig | 3 ++ virt/kvm/async_pf.c | 85 3 files changed, 106 insertions(+) diff --git a/include/linux/kvm_host.h b/include/l

[PATCH v4 04/15] KVM: x86: Use generic async PF slot management

2021-08-14 Thread Gavin Shan
ff-by: Gavin Shan --- arch/x86/include/asm/kvm_host.h | 2 - arch/x86/kvm/Kconfig| 1 + arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/x86.c | 86 +++-- 4 files changed, 8 insertions(+), 83 deletions(-) diff --git a/arch/x86/includ

[PATCH v4 05/15] KVM: arm64: Export kvm_handle_user_mem_abort()

2021-08-14 Thread Gavin Shan
ingly. is_exec_fault: kvm_vcpu_trap_is_exec_fault is_write_fault: kvm_is_write_fault() esr_abt_fault_level: kvm_vcpu_trap_get_fault_level Signed-off-by: Gavin Shan --- arch/arm64/include/asm/esr.h | 6 arch/arm64/include/asm/kvm_emulate.h | 27 ++--- arch/arm64/in

[PATCH v4 06/15] KVM: arm64: Add paravirtualization header files

2021-08-14 Thread Gavin Shan
onous page fault in the subsequent patches: include/uapi/asm-generic/kvm_para.h include/asm-generic/kvm_para.h arch/arm64/include/uapi/asm/kvm_para.h arch/arm64/include/asm/kvm_para.h Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_para.h | 27 ++

[PATCH v4 07/15] KVM: arm64: Support page-not-present notification

2021-08-14 Thread Gavin Shan
uested page. "struct kvm{_,_arch}async_pf" is associated with the worker, to track the work. The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the page-ready notification delivery and control path isn't implemented and will be done in the subsequent patches. Si

[PATCH v4 08/15] KVM: arm64: Support page-ready notification

2021-08-14 Thread Gavin Shan
ready notification. The region is represented by "struct kvm_vcpu_pv_apf_data". The feature isn't enabled by CONFIG_KVM_ASYNC_PF yet. Also, the control path isn't implemented and will be done in the subsequent patches. Signed-off-by: Gavin Shan --- arch/arm64/include/

[PATCH v4 09/15] KVM: arm64: Support async PF hypercalls

2021-08-14 Thread Gavin Shan
quent patches. Signed-off-by: Gavin Shan --- arch/arm64/kvm/async_pf.c | 119 ++ include/linux/arm-smccc.h | 5 ++ 2 files changed, 124 insertions(+) diff --git a/arch/arm64/kvm/async_pf.c b/arch/arm64/kvm/async_pf.c index 0d2393e24ce6..3bc69a631996 100644 --- a

[PATCH v4 10/15] KVM: arm64: Support async PF ioctl commands

2021-08-14 Thread Gavin Shan
KVM_ARM_ASYNC_PF_CMD_SET_CONTROL Set control block when VM is migrated Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 14 +++ arch/arm64/include/uapi/asm/kvm.h | 19 + arch/arm64/kvm/arm.c | 6 +++ arch/arm64/kvm/async_pf.c | 64

[PATCH v4 11/15] KVM: arm64: Export async PF capability

2021-08-14 Thread Gavin Shan
This exports the asynchronous page fault capability: * Identify capability KVM_CAP_ASYNC_{PF, PF_INT}. * Standardize SDEI event for asynchronous page fault. * Enable kernel config CONFIG_KVM_ASYNC_{PF, PF_SLOT}. Signed-off-by: Gavin Shan --- arch/arm64/include/uapi/asm/kvm_sdei.h

  1   2   3   4   5   6   7   >