Re: [PATCH] KVM: arm/arm64: vgic: Drop the kvm_vgic_register_mmio_region()

2020-01-20 Thread Gavin Shan
Signed-off-by: Zenghui Yu --- Reviewed-by: Gavin Shan virt/kvm/arm/vgic/vgic-mmio.h | 5 - 1 file changed, 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-mmio.h b/virt/kvm/arm/vgic/vgic-mmio.h index 836f418f1ee8..5af2aefad435 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.h +++ b/virt/kvm/arm

Re: [PATCH] KVM: arm/arm64: Fix young bit from mmu notifier

2020-01-22 Thread Gavin Shan
On 1/22/20 12:28 AM, Marc Zyngier wrote: On 2020-01-21 05:56, Gavin Shan wrote: kvm_test_age_hva() is called upon mmu_notifier_test_young(), but wrong address range has been passed to handle_hva_to_gpa(). With the wrong address range, no young bits will be checked in handle_hva_to_gpa

[PATCH] KVM: arm/arm64: Fix young bit from mmu notifier

2020-01-21 Thread Gavin Shan
by passing correct address range to the underly function handle_hva_to_gpa(), so that the hardware young (access) bit will be visited. Cc: sta...@vger.kernel.org # v4.1+ Fixes: 35307b9a5f7e ("arm/arm64: KVM: Implement Stage-2 page aging") Signed-off-by: Gavin Shan --- virt/kvm/arm/mmu.c

[PATCH RFCv1 0/7] Support Async Page Fault

2020-04-10 Thread Gavin Shan
, to allocate (and access) all free memory. No system hang is found. Gavin Shan (7): kvm/arm64: Rename kvm_vcpu_get_hsr() to kvm_vcpu_get_esr() kvm/arm64: Detach ESR operator from vCPU struct kvm/arm64: Replace hsr with esr kvm/arm64: Export kvm_handle_user_mem_abort() with prefault mode

[PATCH RFCv1 2/7] kvm/arm64: Detach ESR operator from vCPU struct

2020-04-10 Thread Gavin Shan
. With this, the caller has flexibility on where the ESR is read. It shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 83 +++- arch/arm64/kvm/handle_exit.c | 20 -- arch/arm64/kvm/hyp/switch.c | 24

[PATCH RFCv1 4/7] kvm/arm64: Export kvm_handle_user_mem_abort() with prefault mode

2020-04-10 Thread Gavin Shan
by @esr. * The parameters are reorder based on their importance. This shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 4 virt/kvm/arm/mmu.c| 14 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff

[PATCH RFCv1 7/7] arm64: Support async page fault

2020-04-10 Thread Gavin Shan
. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 ++ arch/arm64/include/asm/exception.h | 5 + arch/arm64/include/asm/kvm_para.h | 42 - arch/arm64/kernel/smp.c| 47 ++ arch/arm64/mm/fault.c | 239 - 5 files

[PATCH RFCv1 5/7] kvm/arm64: Allow inject data abort with specified DFSC

2020-04-10 Thread Gavin Shan
The data abort will be used as signal by the asynchronous page fault. However, the specific IMPDEF Data Fault Status Code (DFSC) is used. Currently, there is no API to inject data abort with specific DSC. This fixes the gap by introducing kvm_inject_dabt_with_dfsc(). Signed-off-by: Gavin Shan

[PATCH RFCv1 3/7] kvm/arm64: Replace hsr with esr

2020-04-10 Thread Gavin Shan
This replace the variable names to make them self-explaining. The tracepoint isn't changed accordingly because they're part of ABI: * @hsr to @esr * @hsr_ec to @ec * Use kvm_vcpu_trap_get_class() helper if possible Signed-off-by: Gavin Shan --- arch/arm64/kvm/handle_exit.c | 28

[PATCH RFCv1 1/7] kvm/arm64: Rename kvm_vcpu_get_hsr() to kvm_vcpu_get_esr()

2020-04-10 Thread Gavin Shan
Since kvm/arm32 was removed, this renames kvm_vcpu_get_hsr() to kvm_vcpu_get_esr() to it a bit more self-explaining because the functions returns ESR instead of HSR on aarch64. This shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 36

[PATCH RFCv1 6/7] kvm/arm64: Support async page fault

2020-04-10 Thread Gavin Shan
duplicate signals will be fired for one gfn. * The signal is conveyed through data abort with IMPDEF Data Fault Status Code (DFSC), which is 0x34. the specific events are stored in the control block, waiting for guest to read. Signed-off-by: Gavin Shan --- arch/arm64/include/asm

Re: [PATCH RFCv1 0/7] Support Async Page Fault

2020-04-14 Thread Gavin Shan
Hi Marc, On 4/10/20 10:52 PM, Marc Zyngier wrote: Hi Gavin, On 2020-04-10 09:58, Gavin Shan wrote: There are two stages of page faults and the stage one page fault is handled by guest itself. The guest is trapped to host when the page fault is caused by stage 2 page table, for example missing

Re: [PATCH RFCv1 0/7] Support Async Page Fault

2020-04-17 Thread Gavin Shan
Hi Mark, On 4/16/20 7:16 PM, Mark Rutland wrote: On Thu, Apr 16, 2020 at 05:59:33PM +1000, Gavin Shan wrote: On 4/14/20 9:05 PM, Mark Rutland wrote: On Tue, Apr 14, 2020 at 03:39:56PM +1000, Gavin Shan wrote: On 4/10/20 10:52 PM, Marc Zyngier wrote: On 2020-04-10 09:58, Gavin Shan wrote

Re: [PATCH RFCv1 0/7] Support Async Page Fault

2020-04-16 Thread Gavin Shan
Hi Mark, On 4/14/20 9:05 PM, Mark Rutland wrote: On Tue, Apr 14, 2020 at 03:39:56PM +1000, Gavin Shan wrote: On 4/10/20 10:52 PM, Marc Zyngier wrote: On 2020-04-10 09:58, Gavin Shan wrote: In order to fulfil the control flow and convey signals between host and guest. A IMPDEF system register

[PATCH RFCv2 3/9] kvm/arm64: Rename kvm_vcpu_get_hsr() to kvm_vcpu_get_esr()

2020-05-08 Thread Gavin Shan
Since kvm/arm32 was removed, this renames kvm_vcpu_get_hsr() to kvm_vcpu_get_esr() to it a bit more self-explaining because the functions returns ESR instead of HSR on aarch64. This shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 36

[PATCH RFCv2 4/9] kvm/arm64: Detach ESR operator from vCPU struct

2020-05-08 Thread Gavin Shan
. With this, the caller has flexibility on where the ESR is read. It shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 83 +++- arch/arm64/kvm/handle_exit.c | 20 -- arch/arm64/kvm/hyp/switch.c | 24

[PATCH RFCv2 1/9] arm64: Probe for the presence of KVM hypervisor services during boot

2020-05-08 Thread Gavin Shan
compatible with KVM. Once this has been established, additional services can be discovered via a feature bitmap. Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- arch/arm64/include/asm/hypervisor.h | 11 + arch/arm64/kernel/setup.c

[PATCH RFCv2 9/9] arm64: Support async page fault

2020-05-08 Thread Gavin Shan
he feature. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 + arch/arm64/include/asm/exception.h | 3 + arch/arm64/include/asm/kvm_para.h | 27 +- arch/arm64/kernel/entry.S | 33 +++ arch/arm64/kernel/process.c| 4 + arch/arm64/mm/fault.c

[PATCH RFCv2 2/9] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC

2020-05-08 Thread Gavin Shan
From: Will Deacon We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services. Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- virt/kvm/arm/hypercalls.c | 29 +++-- 1 file

[PATCH RFCv2 7/9] kvm/arm64: Support async page fault

2020-05-08 Thread Gavin Shan
are fired and consumed in sequential fashion. It means no more signals will be fired if there is pending one, awaiting the guest to consume. It's because the injected data abort faults have to be done in sequential fashion. Signed-off-by: Gavin Shan --- arch/arm64/include/asm

[PATCH RFCv2 0/9] kvm/arm64: Support Async Page Fault

2020-05-08 Thread Gavin Shan
elayed wakeup mechanism in guest kernel (Gavin Shan) * Stability improvement in the guest kernel: delayed wakeup mechanism, external abort disallowed region, lazily clear async page fault, disabled interrupt on acquiring the head's lock and so on

[PATCH RFCv2 6/9] kvm/arm64: Export kvm_handle_user_mem_abort() with prefault mode

2020-05-08 Thread Gavin Shan
by @esr. * The parameters are reorder based on their importance. This shouldn't cause any functional changes. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_host.h | 4 virt/kvm/arm/mmu.c| 14 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff

[PATCH RFCv2 8/9] kernel/sched: Add cpu_rq_is_locked()

2020-05-08 Thread Gavin Shan
This adds API cpu_rq_is_locked() to check if the CPU's runqueue has been locked or not. It's used in the subsequent patch to determine the task wakeup should be executed immediately or delayed. Signed-off-by: Gavin Shan --- include/linux/sched.h | 1 + kernel/sched/core.c | 8 2

[PATCH RFCv2 5/9] kvm/arm64: Replace hsr with esr

2020-05-08 Thread Gavin Shan
This replace the variable names to make them self-explaining. The tracepoint isn't changed accordingly because they're part of ABI: * @hsr to @esr * @hsr_ec to @ec * Use kvm_vcpu_trap_get_class() helper if possible Signed-off-by: Gavin Shan --- arch/arm64/kvm/handle_exit.c | 28

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-03 Thread Gavin Shan
Hi Will, On 9/3/20 9:13 PM, Gavin Shan wrote: On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Hello folks, This is version three of the KVM page-table rework that I previously posted here:    v1: https://lore.kernel.org/r/20200730153406.25136-1-w...@kernel.org

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-04 Thread Gavin Shan
Hi Marc, On 9/4/20 8:07 PM, Marc Zyngier wrote: On 2020-09-04 01:51, Gavin Shan wrote: On 9/3/20 10:16 PM, Will Deacon wrote: On Thu, Sep 03, 2020 at 09:48:18PM +1000, Gavin Shan wrote: On 9/3/20 9:13 PM, Gavin Shan wrote: On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-03 Thread Gavin Shan
Hi Will, On 9/3/20 10:16 PM, Will Deacon wrote: On Thu, Sep 03, 2020 at 09:48:18PM +1000, Gavin Shan wrote: On 9/3/20 9:13 PM, Gavin Shan wrote: On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Hello folks, This is version three of the KVM page-table rework

Re: [PATCH v3 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table

2020-09-03 Thread Gavin Shan
Hi Will, On 9/4/20 2:15 AM, Will Deacon wrote: On Thu, Sep 03, 2020 at 01:30:32PM +0100, Will Deacon wrote: On Thu, Sep 03, 2020 at 09:18:27PM +1000, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: +static int stage2_map_walk_table_post(u64 addr, u64 end, u32 level

Re: [PATCH v3 20/21] KVM: arm64: Remove unused 'pgd' field from 'struct kvm_s2_mmu'

2020-09-03 Thread Gavin Shan
Hi Will, On 9/4/20 2:50 AM, Will Deacon wrote: On Thu, Sep 03, 2020 at 03:07:17PM +1000, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: The stage-2 page-tables are entirely encapsulated by the 'pgt' field of 'struct kvm_s2_mmu', so remove the unused 'pgd' field. Cc: Marc Zyngier

Re: [PATCH v3 10/21] KVM: arm64: Add support for stage-2 page-aging in generic page-table

2020-09-03 Thread Gavin Shan
Hi Will, On 9/4/20 2:48 AM, Will Deacon wrote: On Thu, Sep 03, 2020 at 02:33:22PM +1000, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Add stage-2 mkyoung(), mkold() and is_young() operations to the generic page-table code. Cc: Marc Zyngier Cc: Quentin Perret Signed-off

Re: [PATCH 1/2] KVM: arm64: Update page shift if stage 2 block mapping not supported

2020-09-01 Thread Gavin Shan
("KVM: arm/arm64: Re-check VMA on detecting a poisoned page") Signed-off-by: Alexandru Elisei --- Reviewed-by: Gavin Shan arch/arm64/kvm/mmu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index ba00bcc0c884..25e7dc52c086 100644 --

Re: [PATCH v3 02/21] KVM: arm64: Add stand-alone page-table walker infrastructure

2020-09-02 Thread Gavin Shan
Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: The KVM page-table code is intricately tied into the kernel page-table code and re-uses the pte/pmd/pud/p4d/pgd macros directly in an attempt to reduce code duplication. Unfortunately, the reality is that there is an awful lot of code required to

Re: [PATCH 2/2] KVM: arm64: Try PMD block mappings if PUD mappings are not supported

2020-09-01 Thread Gavin Shan
Hi Alexandru, On 9/1/20 11:33 PM, Alexandru Elisei wrote: When userspace uses hugetlbfs for the VM memory, user_mem_abort() tries to use the same block size to map the faulting IPA in stage 2. If stage 2 cannot use the same size mapping because the block size doesn't fit in the memslot or the

Re: [PATCH v3 05/21] KVM: arm64: Add support for creating kernel-agnostic stage-2 page tables

2020-09-02 Thread Gavin Shan
+++- 4 files changed, 99 insertions(+), 26 deletions(-) With the following one question resolved: Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e52c927aade5..0b7c702b2151 100644 --- a/arch/arm64

Re: [PATCH v4 03/21] KVM: arm64: Add support for creating kernel-agnostic stage-1 page tables

2020-09-07 Thread Gavin Shan
Perret Signed-off-by: Will Deacon --- Reviewed-by: Gavin Shan arch/arm64/include/asm/kvm_pgtable.h | 36 arch/arm64/kvm/hyp/pgtable.c | 133 +++ 2 files changed, 169 insertions(+) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64

Re: [PATCH v4 04/21] KVM: arm64: Use generic allocator for hyp stage-1 page-tables

2020-09-07 Thread Gavin Shan
need. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- With following one question resolved if getting a chance for another respin: Reviewed-by: Gavin Shan arch/arm64/include/asm/kvm_mmu.h | 78 + arch/arm64/include/asm/kvm_pgtable.h | 5 + arch/arm64

Re: [PATCH v4 02/21] KVM: arm64: Add stand-alone page-table walker infrastructure

2020-09-07 Thread Gavin Shan
to add some comments about kvm_block_mapping_supported(). More details are provoided below. Reviewed-by: Gavin Shan arch/arm64/include/asm/kvm_pgtable.h | 101 ++ arch/arm64/kvm/hyp/Makefile | 2 +- arch/arm64/kvm/hyp/pgtable.c | 285 +++ 3

Re: [PATCH v4 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-09 Thread Gavin Shan
Hi Will and Marc, On 9/8/20 1:23 AM, Will Deacon wrote: Hi all, Here's version four of the KVM page-table rework I previously posted here: v1: https://lore.kernel.org/r/20200730153406.25136-1-w...@kernel.org v2: https://lore.kernel.org/r/20200818132818.16065-1-w...@kernel.org v3:

Re: [PATCH v4 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-09 Thread Gavin Shan
On 9/10/20 2:06 PM, Gavin Shan wrote: Hi Will and Marc, On 9/8/20 1:23 AM, Will Deacon wrote: Hi all, Here's version four of the KVM page-table rework I previously posted here:    v1: https://lore.kernel.org/r/20200730153406.25136-1-w...@kernel.org    v2: https://lore.kernel.org/r

Re: [PATCH v3 02/21] KVM: arm64: Add stand-alone page-table walker infrastructure

2020-09-02 Thread Gavin Shan
Hi Will, On 9/2/20 9:02 PM, Will Deacon wrote: On Wed, Sep 02, 2020 at 04:31:32PM +1000, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: The KVM page-table code is intricately tied into the kernel page-table code and re-uses the pte/pmd/pud/p4d/pgd macros directly in an attempt

Re: [PATCH] arm64/kvm: Fix zapping stage2 page table wrongly

2020-09-02 Thread Gavin Shan
only try and map a PUD when its size is different from that of a PMD. Cc: sta...@vger.kernel.org Fixes: b8e0ba7c8bea ("KVM: arm64: Add support for creating PUD hugepages at stage 2") Reported-by: Gavin Shan Reported-by: Eric Auger Signed-off-by: Marc Zyngier ---  arch/arm64/kvm/mmu.c

Re: [PATCH 2/2] KVM: arm64: Try PMD block mappings if PUD mappings are not supported

2020-09-02 Thread Gavin Shan
Hi Alex, On 9/2/20 7:01 PM, Alexandru Elisei wrote: On 9/2/20 2:23 AM, Gavin Shan wrote: On 9/1/20 11:33 PM, Alexandru Elisei wrote: When userspace uses hugetlbfs for the VM memory, user_mem_abort() tries to use the same block size to map the faulting IPA in stage 2. If stage 2 cannot use

Re: [PATCH v3 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table

2020-09-02 Thread Gavin Shan
+++ 2 files changed, 301 insertions(+) With the following questions resolved: Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 3389f978d573..8ab0d5f43817 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-03 Thread Gavin Shan
Hi Will, On 9/3/20 5:34 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Hello folks, This is version three of the KVM page-table rework that I previously posted here:    v1: https://lore.kernel.org/r/20200730153406.25136-1-w...@kernel.org    v2: https://lore.kernel.org/r

Re: [PATCH v3 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table

2020-09-03 Thread Gavin Shan
Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: Add stage-2 map() and unmap() operations to the generic page-table code. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_pgtable.h | 39 arch/arm64/kvm/hyp/pgtable.c | 262

Re: [PATCH v3 09/21] KVM: arm64: Convert unmap_stage2_range() to generic page-table API

2020-09-02 Thread Gavin Shan
+--- 1 file changed, 32 insertions(+), 25 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 704b471a48ce..751ce2462765 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -39,6 +39,33 @@ static bool is_iomap(unsigned long flags

Re: [PATCH v3 11/21] KVM: arm64: Convert page-aging and access faults to generic page-table API

2020-09-02 Thread Gavin Shan
++-- 1 file changed, 16 insertions(+), 58 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 751ce2462765..d3db8e00ce0a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1698,46 +1698,23 @@ static

Re: [PATCH v3 20/21] KVM: arm64: Remove unused 'pgd' field from 'struct kvm_s2_mmu'

2020-09-02 Thread Gavin Shan
/arm64/kvm/mmu.c | 2 -- 2 files changed, 3 deletions(-) I think this might be folded into PATCH[18] as both patches are simple enough. I'm not sure the changes introduced in PATCH[19] prevent us doing this. There is another question below. Reviewed-by: Gavin Shan diff --git

Re: [PATCH v3 19/21] KVM: arm64: Remove unused page-table code

2020-09-03 Thread Gavin Shan
5 files changed, 1141 deletions(-) With the following questions resolved: Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 42fb50cfe0d8..13ff00d9f16d 100644 --- a/arch/arm64/include/asm/kvm_mmu.h +++ b/arch/arm64/include/asm

Re: [PATCH v3 08/21] KVM: arm64: Convert kvm_set_spte_hva() to generic page-table API

2020-09-02 Thread Gavin Shan
(+), 13 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 33146d3dc93a..704b471a48ce 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1911,28 +1911,27 @@ int kvm_unmap_hva_range(struct kvm *kvm, static int kvm_set_spte_handler

Re: [PATCH v3 15/21] KVM: arm64: Convert memslot cache-flushing code to generic page-table API

2020-09-02 Thread Gavin Shan
-by: Will Deacon --- arch/arm64/kvm/mmu.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index ca2c37c91e0b..d4b0716a6ab4 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -455,21

Re: [PATCH v3 14/21] KVM: arm64: Add support for stage-2 cache flushing in generic page-table

2020-09-02 Thread Gavin Shan
Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: From: Quentin Perret Add support for cache flushing a range of the stage-2 address space to the generic page-table code. Cc: Marc Zyngier Signed-off-by: Quentin Perret Signed-off-by: Will Deacon --- Reviewed-by: Gavin Shan arch/arm64

Re: [PATCH v3 18/21] KVM: arm64: Check the pgt instead of the pgd when modifying page-table

2020-09-02 Thread Gavin Shan
changed, 3 insertions(+), 3 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index cfbf32cae3a5..050eab71de31 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1813,7 +1813,7 @@ static int kvm_unmap_hva_handler(struct kvm *kvm, gpa_t

Re: [PATCH v3 17/21] KVM: arm64: Convert user_mem_abort() to generic page-table API

2020-09-03 Thread Gavin Shan
with various configuration on different machines. I will update the result when it's finished. Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index d4b0716a6ab4..cfbf32cae3a5 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -1491,7 +1491,8 @@ static int

Re: [PATCH v3 10/21] KVM: arm64: Add support for stage-2 page-aging in generic page-table

2020-09-02 Thread Gavin Shan
| 86 2 files changed, 124 insertions(+) With the following one question resolved: Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 8ab0d5f43817..ae56534f87a0 100644 --- a/arch/arm64

Re: [PATCH v3 13/21] KVM: arm64: Convert write-protect operation to generic page-table API

2020-09-02 Thread Gavin Shan
-by: Will Deacon --- arch/arm64/kvm/mmu.c | 25 - 1 file changed, 4 insertions(+), 21 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index d3db8e00ce0a..ca2c37c91e0b 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c

Re: [PATCH v3 16/21] KVM: arm64: Add support for relaxing stage-2 perms in generic page-table code

2020-09-02 Thread Gavin Shan
+ arch/arm64/kvm/hyp/pgtable.c | 20 2 files changed, 37 insertions(+) Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index ea823fe31913..0d7077c34152 100644 --- a/arch/arm64

Re: [PATCH v3 06/21] KVM: arm64: Add support for stage-2 map()/unmap() in generic page-table

2020-09-02 Thread Gavin Shan
Hi Will, On 9/3/20 12:57 PM, Gavin Shan wrote: On 8/25/20 7:39 PM, Will Deacon wrote: Add stage-2 map() and unmap() operations to the generic page-table code. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon ---   arch/arm64/include/asm/kvm_pgtable.h |  39   arch/arm64

Re: [PATCH v3 07/21] KVM: arm64: Convert kvm_phys_addr_ioremap() to generic page-table API

2020-09-02 Thread Gavin Shan
- 2 files changed, 13 insertions(+), 30 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 41ee8f3c0369..6f65d3841ec9 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -439,18

Re: [PATCH v3 12/21] KVM: arm64: Add support for stage-2 write-protect in generic page-table

2020-09-02 Thread Gavin Shan
Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: From: Quentin Perret Add a stage-2 wrprotect() operation to the generic page-table code. Cc: Marc Zyngier Signed-off-by: Quentin Perret Signed-off-by: Will Deacon --- Reviewed-by: Gavin Shan arch/arm64/include/asm/kvm_pgtable.h | 15

Re: [PATCH v3 21/21] KVM: arm64: Don't constrain maximum IPA size based on host configuration

2020-09-02 Thread Gavin Shan
: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/reset.c | 38 +- 1 file changed, 5 insertions(+), 33 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index ee33875c5c2a

Re: [PATCH v3 00/21] KVM: arm64: Rewrite page-table code and fault handling

2020-09-03 Thread Gavin Shan
Hi Will, On 8/25/20 7:39 PM, Will Deacon wrote: Hello folks, This is version three of the KVM page-table rework that I previously posted here: v1: https://lore.kernel.org/r/20200730153406.25136-1-w...@kernel.org v2: https://lore.kernel.org/r/20200818132818.16065-1-w...@kernel.org

[PATCH 1/2] arm64/kvm: Drop unnecessary check in kvm_vcpu_preferred_target()

2020-08-25 Thread Gavin Shan
Since commit ("arm64/kvm: Add generic v8 KVM target"), there is no negative number returned from kvm_target_cpu(). So it's not needed to validate its return value in kvm_vcpu_preferred_target() and this just drops the unnecessary check. Signed-off-by: Gavin Shan --- arch/arm64/kvm/g

[PATCH 2/2] arm64/kvm: Drop checking target CPU type on initializing module

2020-08-25 Thread Gavin Shan
The target CPU type is validated when KVM module is initialized. However, we always have a valid target CPU type since commit ("arm64/kvm: Add generic v8 KVM target"). So it's unnecessary to validate the target CPU type at that time and this just drops it. Signed-off-by: Gavin Shan

[PATCH 4/6] arm64/kvm: Support async page fault

2020-08-17 Thread Gavin Shan
locate the required resources. ARM_SMCCC_KVM_FUNC_APF_SDEI ARM_SMCCC_KVM_FUNC_APF_IRQ Used by guest to confiugre the SDEI event and PPI numbers. ARM_SMCCC_KVM_FUNC_APF_IRQ_ACK Acknowledge the page-ready notificaton in the PPI handler. Signed-off-by: Gavin Shan --- arch/arm64/i

[PATCH 2/6] arm/arm64: KVM: Advertise KVM UID to guests via SMCCC

2020-08-17 Thread Gavin Shan
From: Will Deacon We can advertise ourselves to guests as KVM and provide a basic features bitmap for discoverability of future hypervisor services. Cc: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- arch/arm64/kvm/hypercalls.c | 29 +++-- 1

[PATCH 6/6] arm64/kernel: Support async page fault

2020-08-17 Thread Gavin Shan
eature has to be enabled after SDEI service is settled down because this depends on SDEI service. Signed-off-by: Gavin Shan --- arch/arm64/Kconfig | 11 + arch/arm64/include/asm/kvm_para.h| 26 +- arch/arm64/include/asm/processor.h | 1 + arch/arm64/include/asm/thread_in

[PATCH 3/6] kvm/arm64: Export kvm_handle_user_mem_abort() with prefault mode

2020-08-17 Thread Gavin Shan
. Signed-off-by: Gavin Shan --- arch/arm64/include/asm/esr.h | 5 + arch/arm64/include/asm/kvm_emulate.h | 8 arch/arm64/include/asm/kvm_host.h| 4 arch/arm64/kvm/mmu.c | 18 -- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git

[PATCH 5/6] drivers/acpi: Import ACPI APF table

2020-08-17 Thread Gavin Shan
* @interrupt_flags: PPI's mode and polarity Signed-off-by: Gavin Shan --- include/acpi/actbl2.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index ec66779cb193..2eb715f4463b 100644 --- a/include/acpi/actbl2.h +++ b/include

[PATCH 1/6] arm64: Probe for the presence of KVM hypervisor services during boot

2020-08-17 Thread Gavin Shan
compatible with KVM. Once this has been established, additional services can be discovered via a feature bitmap. Signed-off-by: Will Deacon Signed-off-by: Gavin Shan --- arch/arm64/include/asm/hypervisor.h | 11 ++ arch/arm64/kernel/setup.c | 32 + include

[PATCH 0/6] Support Asynchronous Page Fault

2020-08-17 Thread Gavin Shan
2>&1" Idx Disabled Enabled Output == 1 2049s 1850s +9.7% 2 2144s 1947s +9.1% 3 2164s 1997s +7.7% 4 2192s 2031s +7.3% 5 2515s 2141s +14.8%

Re: [PATCH v2 01/22] KVM: arm64: Don't free memcache pages in kvm_phys_addr_ioremap()

2020-08-18 Thread Gavin Shan
Hi Will, On 8/18/20 11:27 PM, Will Deacon wrote: kvm_phys_addr_ioremap() unconditionally empties out the memcache pages for the current vCPU on return. This causes subsequent topups to allocate fresh pages and is at odds with the behaviour when mapping memory in user_mem_abort(). Remove the

Re: [PATCH v2 02/22] KVM: arm64: Remove kvm_mmu_free_memory_caches()

2020-08-18 Thread Gavin Shan
/arm64/kvm/arm.c | 2 +- arch/arm64/kvm/mmu.c | 5 - 3 files changed, 1 insertion(+), 8 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h index 189839c3706a..0f078b1920ff 100644 --- a/arch/arm64

[PATCH] arm64/kvm: Fix zapping stage2 page table wrongly

2020-08-21 Thread Gavin Shan
Eric Auger Signed-off-by: Gavin Shan Tested-by: Eric Auger Reviewed-by: Eric Auger --- arch/arm64/kvm/mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 0121ef2c7c8d..deb1819ba9e2 100644 --- a/arch/arm64/kvm/mmu.c +++ b/

Re: [PATCH] arm64/kvm: Fix zapping stage2 page table wrongly

2020-08-22 Thread Gavin Shan
Hi Marc, On 8/22/20 8:01 PM, Marc Zyngier wrote: On Sat, 22 Aug 2020 03:44:44 +0100, Gavin Shan wrote: Depending on the kernel configuration, PUD_SIZE could be equal to PMD_SIZE. For example, both of them are 512MB with the following kernel configuration. In this case, both PUD and PMD

[PATCH 01/18] drivers/firmware/sdei: Retrieve event signaled property on registration

2020-08-17 Thread Gavin Shan
This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 6 ++ include/linux/arm_sdei.h| 1 + 2 files changed, 7 insertions(+) diff

[PATCH 00/18] Support SDEI Virtualization

2020-08-17 Thread Gavin Shan
ssthrou SDEI events to target VMs and vCPUs. PATCH[15-16] Support more hypercalls like COMPLETE, COMPLETE_AND_RESUME, and CONTEXT. PATCH[17]Support injecting KVM private SDEI event and expose the SDEI capability. PATCH[18]Add self-test case for KVM private SDE

[PATCH 03/18] arm/smccc: Introduce template for inline functions

2020-08-17 Thread Gavin Shan
. 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 --- a/include/kvm/arm_hypercalls.h

[PATCH 02/18] drivers/firmware/sdei: Add sdei_event_get_info()

2020-08-17 Thread Gavin Shan
This adds API sdei_event_get_info(), to be used when virtualized SDEI is supported to retrieve the information about the specified event. Signed-off-by: Gavin Shan --- drivers/firmware/arm_sdei.c | 13 + include/linux/arm_sdei.h| 2 ++ 2 files changed, 15 insertions(+) diff

[PATCH 04/18] arm64/kvm: Add SDEI virtualization infrastructure

2020-08-17 Thread Gavin Shan
CPU. These events forms a link list through @vcpu->arch.sdei_events, protected by lock @vcpu->arch.sdei_lock. For now, errno (SDEI_NOT_SUPPORTED) is returned for all SDEI hypercalls and they will be implemented and suppoerted one by one in the subsequent patches. Signed-off-by: Gavin S

Re: [PATCH 00/18] Support SDEI Virtualization

2020-08-17 Thread Gavin Shan
On 8/17/20 8:05 PM, Gavin Shan wrote: This series intends to support SDEI virtualization. The background is the feature (Asynchronous Page Fault) needs virtualized SDEI event to deliver page-not-present notification from host to guest. This series depends on the series "Refactor SDEI C

[PATCH 18/18] kvm/selftests: Add SDEI test case

2020-08-17 Thread Gavin Shan
) 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 | 170 + 2 files changed, 171 insertions(+) create mode 100644 tools/testing/selftests/kvm/aarch64/sdei.c diff --git

[PATCH 16/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_CONTEXT hypercall

2020-08-17 Thread Gavin Shan
This supports SDEI_1_0_FN_SDEI_EVENT_CONTEXT hypercall by implementing kvm_sdei_hypercall_context(). If there is valid context on the current vCPU and the register index isn't out of scope, the register values are returned. Otherwise, errno is returned. Signed-off-by: Gavin Shan --- arch/arm64

[PATCH 14/18] arm64/kvm: Implement event handler

2020-08-17 Thread Gavin Shan
rrupted PC/PState are saved. * x0/x1/x2/x3 is set to the event number, event parameter, the interrupt PC and PState separately. * PSTATE is modified as follows: DAIF=0b, EL=ELc, nRW=0, SP=1 * PC is set to the address of the handler Signed-off-by: Gavin Shan --- arch/arm64/i

[PATCH 17/18] arm64/kvm: Expose SDEI capability

2020-08-17 Thread Gavin Shan
: kvm_sdei_register_notifier() and kvm_sdei_cancel(). Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_sdei.h | 4 + arch/arm64/kvm/arm.c | 8 ++ arch/arm64/kvm/reset.c| 3 + arch/arm64/kvm/sdei.c | 134 ++ include/uapi

[PATCH 10/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_GET_INFO hypercall

2020-08-17 Thread Gavin Shan
retrieved from underly firmware if applicable. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 125 ++ 1 file changed, 125 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index 2d2135a5c3ea..529505c4f0cf 100644 --- a/arch/arm64

[PATCH 09/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_STATUS hypercall

2020-08-17 Thread Gavin Shan
This supports SDEI_1_0_FN_SDEI_EVENT_STATUS hypercall by adding the function kvm_sdei_hypercall_status(). On success, the event's current status is returned. Otherwise, errno is returned. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 50 +++ 1

[PATCH 15/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_{COMPLETE, COMPLETE_AND_RESUME} hypercall

2020-08-17 Thread Gavin Shan
ich is originated from KVM itself, the notfier is executed. Besides, the IRQ exception is injected if the request is to resume the guest by SDEI_1_0_FN_SDEI_EVENT_RESUME. The behaviour is defined in SDEI specification (v1.0). Signed-off-by: Gavin Shan --- arch/arm64/include/asm/kvm_emulate.h | 2 + a

[PATCH 05/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_VERSION hypercall

2020-08-17 Thread Gavin Shan
-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 17 + 1 file changed, 17 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index e2090e9bab8b..f5739c0063df 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm/sdei.c @@ -36,6 +36,21 @@ static inline int

[PATCH 06/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_REGISTER

2020-08-17 Thread Gavin Shan
exist, the kvm event is created and put into the RB-tree of the parent event. The registered status is updated either. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 230 ++ 1 file changed, 230 insertions(+) diff --git a/arch/arm64/kvm

[PATCH 12/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_PE_{MASK, UNMASK} hypercall

2020-08-17 Thread Gavin Shan
might be shared by multiple VMs. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 24 1 file changed, 24 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index 1e7291acea0d..0816136e73a6 100644 --- a/arch/arm64/kvm/sdei.c +++ b/arch/arm64/kvm

[PATCH 07/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_{ENABLE, DISABLE} hypercall

2020-08-17 Thread Gavin Shan
we need is to update the enabled bits, which will be serving as filters during the event delivery to the target VMs and vCPUs. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 68 +++ 1 file changed, 68 insertions(+) diff --git a/arch/arm64/kvm/sdei.c

[PATCH 13/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_{PRIVATE, SHARED}_RESET hypercall

2020-08-17 Thread Gavin Shan
) events which have been registered on the speicific VM. However, the request is directed to underly firmware by calling sdei_event_unregister() when last event (reference) exits. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 18 ++ 1 file changed, 18 insertions(+) diff

[PATCH 08/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_UNREGISTER hypercall

2020-08-17 Thread Gavin Shan
the underly firmware in that case. Signed-off-by: Gavin Shan --- arch/arm64/kvm/sdei.c | 73 +++ 1 file changed, 73 insertions(+) diff --git a/arch/arm64/kvm/sdei.c b/arch/arm64/kvm/sdei.c index 320b79528211..63d621dc9711 100644 --- a/arch/arm64/kvm/sdei.c

[PATCH 11/18] arm64/kvm: Support SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET hypercall

2020-08-17 Thread Gavin Shan
This supports SDEI_1_0_FN_SDEI_EVENT_ROUTING_SET hypercall by adding kvm_sdei_hypercall_route(). On success, the specified routing mode and affinity is set. Otherwise, errno is returned. The route mode or affinity is updated to the KVM SDEI event. Signed-off-by: Gavin Shan --- arch/arm64/kvm

Re: [PATCH] KVM: arm64: Pass level hint to TLBI during stage-2 permission fault

2020-09-30 Thread Gavin Shan
/pgtable.c | 23 --- 1 file changed, 16 insertions(+), 7 deletions(-) Reviewed-by: Gavin Shan diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 603d6b415337..0cdf6e461cbd 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp

Re: [PATCH] KVM: arm64: Ensure user_mem_abort() return value is initialised

2020-09-30 Thread Gavin Shan
of an external abort into the guest or a spurious return to userspace. Neither or these are what we want to do. Initialise 'ret' to 0 in user_mem_abort() so that bailing due to a change in the MMU notrifier sequence number is treated as though the fault was handled. Cc: Gavin Shan Cc: Alexandru

Re: [PATCH RFCv2 3/9] kvm/arm64: Rename kvm_vcpu_get_hsr() to kvm_vcpu_get_esr()

2020-05-28 Thread Gavin Shan
On 5/27/20 5:20 PM, Marc Zyngier wrote: On 2020-05-27 03:43, Gavin Shan wrote: Hi Mark, On 5/26/20 8:42 PM, Mark Rutland wrote: On Fri, May 08, 2020 at 01:29:13PM +1000, Gavin Shan wrote: Since kvm/arm32 was removed, this renames kvm_vcpu_get_hsr() to kvm_vcpu_get_esr() to it a bit more self

Re: [PATCH RFCv2 9/9] arm64: Support async page fault

2020-05-28 Thread Gavin Shan
Hi Paolo, On 5/27/20 4:48 PM, Paolo Bonzini wrote: I definitely appreciate the work, but this is repeating most of the mistakes done in the x86 implementation. In particular: - the page ready signal can be done as an interrupt, rather than an exception. This is because "page ready" can be

Re: [PATCH RFCv2 7/9] kvm/arm64: Support async page fault

2020-05-28 Thread Gavin Shan
Hi Marc, On 5/27/20 5:37 PM, Marc Zyngier wrote: On 2020-05-27 05:05, Gavin Shan wrote: [...] +struct kvm_vcpu_pv_apf_data { +    __u32    reason; +    __u8    pad[60]; +    __u32    enabled; +}; What's all the padding for? The padding is ensure the @reason and @enabled in different

  1   2   3   4   5   6   7   >