From: James Hogan <james.hogan@imgtec.com> To: <linux-mips@linux-mips.org> Cc: "James Hogan" <james.hogan@imgtec.com>, "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com>, "Ralf Baechle" <ralf@linux-mips.org>, kvm@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/30] KVM: MIPS: Implement GVA page tables Date: Thu, 2 Feb 2017 12:04:13 +0000 [thread overview] Message-ID: <cover.e37f86dece46fc3ed00a075d68119cab361cda8e.1486036366.git-series.james.hogan@imgtec.com> (raw) Note: My intention is to take this series via the MIPS KVM tree, with a topic branch for the MIPS architecture changes, so acks welcome for the relevant parts (mainly patches 1-4, 15, 28), and please don't apply yet. This series primarily implements GVA->HPA page tables for MIPS T&E KVM implementation, and a fast TLB refill handler generated at runtime using uasm (sharing MIPS arch code to do this), accompanied by a bunch of related cleanups. There are several solid advantages of this: - An optimised TLB refill handler will be much faster than using the slow exit path through C code. It also avoids repeated guest TLB lookups for guest mapped addresses that are evicted from the host TLB (which are currently implemented as a linear walk through the guest TLB array). - The TLB refill handler can be pretty much reused in future for VZ, to fill the root TLB with GPA->HPA mappings from a soon to be implemented GPA page table. - Although not enabled yet, it potentially allows page table walker hardware (HTW) to be used during guest execution (both for VZ GPA mappings, and potentially T&E GVA mappings) further reducing TLB refill overhead. - It improves the robustness of direct access to guest memory by KVM, i.e. reading guest instructions for emulation, writing guest instructions for dynamic translation, and emulating CACHE instructions. This is because the standard userland memory accessors can be used, allowing the host kernel TLB refill handler to safely fill from the GVA page table, allowing faults to be sanely detected, and allowing it to work when EVA is enabled (which requires different instructions to be used when accessing the user address space). The main disadvantage is a higher flushing overhead when the guest ASID is changed, due to the need to walk and invalidate GVA page tables (since we only manage a single GVA page table for each guest privilege mode, across all guest ASIDs). Changes in v2: [1/30] MIPS: Move pgd_alloc() out of header - Move pgd_alloc() into C code rather than exporting init_mm itself (feedback from Arjan van de Ven). [2/30] MIPS: Export pgd/pmd symbols for KVM - Don't bother exporting pgd_init(), as it was used by pgd_alloc() which is moved out of the headers and exported itself now. [12/30] KVM: MIPS/T&E: active_mm = init_mm in guest context - Use well defined helpers in static kernel code to avoid having to export init_mm to modules. The patches are roughly grouped as follows: Patches 1-4: These are generic or MIPS architecture changes needed by the later patches, mainly to expose the existing MIPS TLB exception generation cade to KVM. As I mentioned above I intend to combine the MIPS ones into a topic branch which can be merged into both the MIPS architecture tree and the MIPS KVM tree. Patches 5-13: These are preliminary MIPS KVM changes and cleanups. Patches 14-25: These incrementally add GVA page table support, allocating the GVA page tables, adding the fast TLB refill handler, adding page table invalidation, and finally converting guest fault handling (KSeg0, TLB mapped, and commpage) to use the GVA page table rather than injecting entries directly into the host TLB. Patches 26-27: These switch to using uaccess and protected cache ops, which fixes KVM on EVA enabled host kernels. Patches 28-30: These make some final cleanups. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Cc: linux-mm@kvack.org James Hogan (30): MIPS: Move pgd_alloc() out of header MIPS: Export pgd/pmd symbols for KVM MIPS: uasm: Add include guards in asm/uasm.h MIPS: Export some tlbex internals for KVM to use KVM: MIPS: Drop partial KVM_NMI implementation KVM: MIPS/MMU: Simplify ASID restoration KVM: MIPS: Convert get/set_regs -> vcpu_load/put KVM: MIPS/MMU: Move preempt/ASID handling to implementation KVM: MIPS: Remove duplicated ASIDs from vcpu KVM: MIPS: Add vcpu_run() & vcpu_reenter() callbacks KVM: MIPS/T&E: Restore host asid on return to host KVM: MIPS/T&E: active_mm = init_mm in guest context KVM: MIPS: Wire up vcpu uninit KVM: MIPS/T&E: Allocate GVA -> HPA page tables KVM: MIPS/T&E: Activate GVA page tables in guest context KVM: MIPS: Support NetLogic KScratch registers KVM: MIPS: Add fast path TLB refill handler KVM: MIPS/TLB: Fix off-by-one in TLB invalidate KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes KVM: MIPS/MMU: Invalidate stale GVA PTEs on TLBW KVM: MIPS/MMU: Convert KSeg0 faults to page tables KVM: MIPS/MMU: Convert TLB mapped faults to page tables KVM: MIPS/MMU: Convert commpage fault handling to page tables KVM: MIPS: Drop vm_init() callback KVM: MIPS: Use uaccess to read/modify guest instructions KVM: MIPS/Emulate: Fix CACHE emulation for EVA hosts KVM: MIPS/TLB: Drop kvm_local_flush_tlb_all() KVM: MIPS/Emulate: Drop redundant TLB flushes on exceptions KVM: MIPS/MMU: Drop kvm_get_new_mmu_context() arch/mips/include/asm/kvm_host.h | 79 ++-- arch/mips/include/asm/mmu_context.h | 9 +- arch/mips/include/asm/pgalloc.h | 16 +- arch/mips/include/asm/tlbex.h | 26 +- arch/mips/include/asm/uasm.h | 5 +- arch/mips/kvm/dyntrans.c | 28 +- arch/mips/kvm/emulate.c | 59 +-- arch/mips/kvm/entry.c | 141 +++++++- arch/mips/kvm/mips.c | 130 +------ arch/mips/kvm/mmu.c | 545 +++++++++++++++++------------ arch/mips/kvm/tlb.c | 256 +++----------- arch/mips/kvm/trap_emul.c | 216 ++++++++++- arch/mips/mm/Makefile | 2 +- arch/mips/mm/init.c | 1 +- arch/mips/mm/pgtable-64.c | 2 +- arch/mips/mm/pgtable.c | 25 +- arch/mips/mm/tlbex.c | 38 +- 17 files changed, 916 insertions(+), 662 deletions(-) create mode 100644 arch/mips/include/asm/tlbex.h create mode 100644 arch/mips/mm/pgtable.c -- git-series 0.8.10
WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@imgtec.com> To: linux-mips@linux-mips.org Cc: "James Hogan" <james.hogan@imgtec.com>, "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com>, "Ralf Baechle" <ralf@linux-mips.org>, kvm@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/30] KVM: MIPS: Implement GVA page tables Date: Thu, 2 Feb 2017 12:04:13 +0000 [thread overview] Message-ID: <cover.e37f86dece46fc3ed00a075d68119cab361cda8e.1486036366.git-series.james.hogan@imgtec.com> (raw) Message-ID: <20170202120413.Ck48G2d5suE4nDwrk4YMjIlQXD6x58Gl8xLCInSRrhM@z> (raw) Note: My intention is to take this series via the MIPS KVM tree, with a topic branch for the MIPS architecture changes, so acks welcome for the relevant parts (mainly patches 1-4, 15, 28), and please don't apply yet. This series primarily implements GVA->HPA page tables for MIPS T&E KVM implementation, and a fast TLB refill handler generated at runtime using uasm (sharing MIPS arch code to do this), accompanied by a bunch of related cleanups. There are several solid advantages of this: - An optimised TLB refill handler will be much faster than using the slow exit path through C code. It also avoids repeated guest TLB lookups for guest mapped addresses that are evicted from the host TLB (which are currently implemented as a linear walk through the guest TLB array). - The TLB refill handler can be pretty much reused in future for VZ, to fill the root TLB with GPA->HPA mappings from a soon to be implemented GPA page table. - Although not enabled yet, it potentially allows page table walker hardware (HTW) to be used during guest execution (both for VZ GPA mappings, and potentially T&E GVA mappings) further reducing TLB refill overhead. - It improves the robustness of direct access to guest memory by KVM, i.e. reading guest instructions for emulation, writing guest instructions for dynamic translation, and emulating CACHE instructions. This is because the standard userland memory accessors can be used, allowing the host kernel TLB refill handler to safely fill from the GVA page table, allowing faults to be sanely detected, and allowing it to work when EVA is enabled (which requires different instructions to be used when accessing the user address space). The main disadvantage is a higher flushing overhead when the guest ASID is changed, due to the need to walk and invalidate GVA page tables (since we only manage a single GVA page table for each guest privilege mode, across all guest ASIDs). Changes in v2: [1/30] MIPS: Move pgd_alloc() out of header - Move pgd_alloc() into C code rather than exporting init_mm itself (feedback from Arjan van de Ven). [2/30] MIPS: Export pgd/pmd symbols for KVM - Don't bother exporting pgd_init(), as it was used by pgd_alloc() which is moved out of the headers and exported itself now. [12/30] KVM: MIPS/T&E: active_mm = init_mm in guest context - Use well defined helpers in static kernel code to avoid having to export init_mm to modules. The patches are roughly grouped as follows: Patches 1-4: These are generic or MIPS architecture changes needed by the later patches, mainly to expose the existing MIPS TLB exception generation cade to KVM. As I mentioned above I intend to combine the MIPS ones into a topic branch which can be merged into both the MIPS architecture tree and the MIPS KVM tree. Patches 5-13: These are preliminary MIPS KVM changes and cleanups. Patches 14-25: These incrementally add GVA page table support, allocating the GVA page tables, adding the fast TLB refill handler, adding page table invalidation, and finally converting guest fault handling (KSeg0, TLB mapped, and commpage) to use the GVA page table rather than injecting entries directly into the host TLB. Patches 26-27: These switch to using uaccess and protected cache ops, which fixes KVM on EVA enabled host kernels. Patches 28-30: These make some final cleanups. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Cc: linux-mm@kvack.org James Hogan (30): MIPS: Move pgd_alloc() out of header MIPS: Export pgd/pmd symbols for KVM MIPS: uasm: Add include guards in asm/uasm.h MIPS: Export some tlbex internals for KVM to use KVM: MIPS: Drop partial KVM_NMI implementation KVM: MIPS/MMU: Simplify ASID restoration KVM: MIPS: Convert get/set_regs -> vcpu_load/put KVM: MIPS/MMU: Move preempt/ASID handling to implementation KVM: MIPS: Remove duplicated ASIDs from vcpu KVM: MIPS: Add vcpu_run() & vcpu_reenter() callbacks KVM: MIPS/T&E: Restore host asid on return to host KVM: MIPS/T&E: active_mm = init_mm in guest context KVM: MIPS: Wire up vcpu uninit KVM: MIPS/T&E: Allocate GVA -> HPA page tables KVM: MIPS/T&E: Activate GVA page tables in guest context KVM: MIPS: Support NetLogic KScratch registers KVM: MIPS: Add fast path TLB refill handler KVM: MIPS/TLB: Fix off-by-one in TLB invalidate KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes KVM: MIPS/MMU: Invalidate stale GVA PTEs on TLBW KVM: MIPS/MMU: Convert KSeg0 faults to page tables KVM: MIPS/MMU: Convert TLB mapped faults to page tables KVM: MIPS/MMU: Convert commpage fault handling to page tables KVM: MIPS: Drop vm_init() callback KVM: MIPS: Use uaccess to read/modify guest instructions KVM: MIPS/Emulate: Fix CACHE emulation for EVA hosts KVM: MIPS/TLB: Drop kvm_local_flush_tlb_all() KVM: MIPS/Emulate: Drop redundant TLB flushes on exceptions KVM: MIPS/MMU: Drop kvm_get_new_mmu_context() arch/mips/include/asm/kvm_host.h | 79 ++-- arch/mips/include/asm/mmu_context.h | 9 +- arch/mips/include/asm/pgalloc.h | 16 +- arch/mips/include/asm/tlbex.h | 26 +- arch/mips/include/asm/uasm.h | 5 +- arch/mips/kvm/dyntrans.c | 28 +- arch/mips/kvm/emulate.c | 59 +-- arch/mips/kvm/entry.c | 141 +++++++- arch/mips/kvm/mips.c | 130 +------ arch/mips/kvm/mmu.c | 545 +++++++++++++++++------------ arch/mips/kvm/tlb.c | 256 +++----------- arch/mips/kvm/trap_emul.c | 216 ++++++++++- arch/mips/mm/Makefile | 2 +- arch/mips/mm/init.c | 1 +- arch/mips/mm/pgtable-64.c | 2 +- arch/mips/mm/pgtable.c | 25 +- arch/mips/mm/tlbex.c | 38 +- 17 files changed, 916 insertions(+), 662 deletions(-) create mode 100644 arch/mips/include/asm/tlbex.h create mode 100644 arch/mips/mm/pgtable.c -- git-series 0.8.10
next reply other threads:[~2017-02-02 12:05 UTC|newest] Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-02-02 12:04 James Hogan [this message] 2017-02-02 12:04 ` [PATCH v2 0/30] KVM: MIPS: Implement GVA page tables James Hogan 2017-02-02 12:04 ` [PATCH v2 1/30] MIPS: Move pgd_alloc() out of header James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 2/30] MIPS: Export pgd/pmd symbols for KVM James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 3/30] MIPS: uasm: Add include guards in asm/uasm.h James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 4/30] MIPS: Export some tlbex internals for KVM to use James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 5/30] KVM: MIPS: Drop partial KVM_NMI implementation James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 6/30] KVM: MIPS/MMU: Simplify ASID restoration James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 7/30] KVM: MIPS: Convert get/set_regs -> vcpu_load/put James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 8/30] KVM: MIPS/MMU: Move preempt/ASID handling to implementation James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 9/30] KVM: MIPS: Remove duplicated ASIDs from vcpu James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 10/30] KVM: MIPS: Add vcpu_run() & vcpu_reenter() callbacks James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 11/30] KVM: MIPS/T&E: Restore host asid on return to host James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 12/30] KVM: MIPS/T&E: active_mm = init_mm in guest context James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 13/30] KVM: MIPS: Wire up vcpu uninit James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 14/30] KVM: MIPS/T&E: Allocate GVA -> HPA page tables James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 15/30] KVM: MIPS/T&E: Activate GVA page tables in guest context James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 16/30] KVM: MIPS: Support NetLogic KScratch registers James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 17/30] KVM: MIPS: Add fast path TLB refill handler James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 18/30] KVM: MIPS/TLB: Fix off-by-one in TLB invalidate James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 19/30] KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 20/30] KVM: MIPS/MMU: Invalidate GVA PTs on ASID changes James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 21/30] KVM: MIPS/MMU: Invalidate stale GVA PTEs on TLBW James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 22/30] KVM: MIPS/MMU: Convert KSeg0 faults to page tables James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 23/30] KVM: MIPS/MMU: Convert TLB mapped " James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 24/30] KVM: MIPS/MMU: Convert commpage fault handling " James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 25/30] KVM: MIPS: Drop vm_init() callback James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 26/30] KVM: MIPS: Use uaccess to read/modify guest instructions James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 27/30] KVM: MIPS/Emulate: Fix CACHE emulation for EVA hosts James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 28/30] KVM: MIPS/TLB: Drop kvm_local_flush_tlb_all() James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 29/30] KVM: MIPS/Emulate: Drop redundant TLB flushes on exceptions James Hogan 2017-02-02 12:04 ` James Hogan 2017-02-02 12:04 ` [PATCH v2 30/30] KVM: MIPS/MMU: Drop kvm_get_new_mmu_context() James Hogan 2017-02-02 12:04 ` James Hogan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=cover.e37f86dece46fc3ed00a075d68119cab361cda8e.1486036366.git-series.james.hogan@imgtec.com \ --to=james.hogan@imgtec.com \ --cc=kvm@vger.kernel.org \ --cc=linux-mips@linux-mips.org \ --cc=linux-mm@kvack.org \ --cc=pbonzini@redhat.com \ --cc=ralf@linux-mips.org \ --cc=rkrcmar@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).