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

2020-08-25 Thread Will Deacon
Convert kvm_set_spte_hva() to use kvm_pgtable_stage2_map() instead of stage2_set_pte(). Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 23 ++- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/a

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

2020-08-25 Thread Will Deacon
Introduce alloc() and free() functions to the generic page-table code for guest stage-2 page-tables and plumb these into the existing KVM page-table allocator. Subsequent patches will convert other operations within the KVM allocator over to the generic code. Cc: Marc Zyngier Cc: Quentin Perret

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

2020-08-25 Thread Will Deacon
Convert the page-aging functions and access fault handler to use the generic page-table code instead of walking the page-table directly. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 74 ++-- 1 file changed, 16

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

2020-08-25 Thread Will Deacon
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 --- arch/arm64/include/asm/kvm_pgtable.h | 15 +++ arch/arm64/kvm/hyp/pgtable.c | 6 ++ 2 files changed,

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

2020-08-25 Thread Will Deacon
Convert kvm_phys_addr_ioremap() to use kvm_pgtable_stage2_map() instead of stage2_set_pte(). Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/hyp/pgtable.c | 14 +- arch/arm64/kvm/mmu.c | 29 - 2 files changed, 13

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

2020-08-25 Thread Will Deacon
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 --- arch/arm64/include/asm/kvm_pgtable.h | 12 arch/arm64/kvm/hyp/pgtable.c

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

2020-08-25 Thread Will Deacon
In preparation for removing the 'pgd' field of 'struct kvm_s2_mmu', update the few remaining users to check the 'pgt' field instead. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a

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

2020-08-25 Thread Will Deacon
From: Quentin Perret Convert stage2_wp_range() to call the kvm_pgtable_stage2_wrprotect() function of the generic page-table code instead of walking the page-table directly. Cc: Marc Zyngier Signed-off-by: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 25 --

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

2020-08-25 Thread Will Deacon
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 +++ 2 files changed, 301 insertions(+

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

2020-08-25 Thread Will Deacon
Convert unmap_stage2_range() to use kvm_pgtable_stage2_unmap() instead of walking the page-table directly. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 57 +--- 1 file changed, 32 insertions(+), 25 deletions(-

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

2020-08-25 Thread Will Deacon
From: Quentin Perret Convert stage2_flush_memslot() to call the kvm_pgtable_stage2_flush() function of the generic page-table code instead of walking the page-table directly. Cc: Marc Zyngier Signed-off-by: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/kvm/mmu.c | 13 +

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

2020-08-25 Thread Will Deacon
The generic page-table walker is pretty useless as it stands, because it doesn't understand enough to allocate anything. Teach it about stage-1 page-tables, and hook up an API for allocating these for the hypervisor at EL2. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arc

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

2020-08-25 Thread Will Deacon
Convert user_mem_abort() to call kvm_pgtable_stage2_relax_perms() when handling a stage-2 permission fault and kvm_pgtable_stage2_map() when handling a stage-2 translation fault, rather than walking the page-table manually. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arc

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

2020-08-25 Thread Will Deacon
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 Changes since v2 include: * Rebased onto -rc2, which inc

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

2020-08-25 Thread Will Deacon
Now that KVM is using the generic page-table code to manage the guest stage-2 page-tables, we can remove a bunch of unused macros, #defines and static inline functions from the old implementation. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_mmu

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

2020-08-25 Thread Will Deacon
Add support for relaxing the permissions of a stage-2 mapping (i.e. adding additional permissions) to the generic page-table code. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_pgtable.h | 17 + arch/arm64/kvm/hyp/pgtable.c

[PATCH v3 01/21] KVM: arm64: Remove kvm_mmu_free_memory_caches()

2020-08-25 Thread Will Deacon
kvm_mmu_free_memory_caches() is only called by kvm_arch_vcpu_destroy(), so inline the implementation and get rid of the extra function. Cc: Marc Zyngier Cc: Quentin Perret Reviewed-by: Gavin Shan Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_mmu.h | 2 -- arch/arm64/kvm/arm.c

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

2020-08-25 Thread Will Deacon
Add stage-2 mkyoung(), mkold() and is_young() 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 | 38 arch/arm64/kvm/hyp/pgtable.c | 86 2 files ch

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

2020-08-25 Thread Will Deacon
Now that we have a shiny new page-table allocator, replace the hyp page-table code with calls into the new API. This also allows us to remove the extended idmap code, as we can now simply ensure that the VA size is large enough to map everything we need. Cc: Marc Zyngier Cc: Quentin Perret Signe

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

2020-08-25 Thread Will Deacon
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 make this work, and at the end of the day you're lim

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

2020-08-25 Thread Will Deacon
Now that the guest stage-2 page-tables are managed independently from the host stage-1 page-tables, we can avoid constraining the IPA size based on the host and instead limit it only based on the PARange field of the ID_AA64MMFR0 register. Cc: Marc Zyngier Cc: Quentin Perret Signed-off-by: Will

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

2020-08-25 Thread Will Deacon
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 Cc: Quentin Perret Signed-off-by: Will Deacon --- arch/arm64/include/asm/kvm_host.h | 1 - arch/arm64/kvm/mmu.c | 2 -- 2 files changed,

Re: [RFC PATCH 0/5] KVM: arm64: Add pvtime LPT support

2020-08-25 Thread Mark Rutland
On Wed, Aug 19, 2020 at 09:54:40AM +0100, Steven Price wrote: > On 18/08/2020 15:41, Marc Zyngier wrote: > > On 2020-08-17 09:41, Keqian Zhu wrote: > We are discussing (re-)releasing the spec with the LPT parts added. If you > have fundamental objections then please me know. Like Marc, I argued s