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 Subject: [PATCH 0/10] KVM: MIPS: Implement GPA page tables and shadow flushing Date: Mon, 9 Jan 2017 20:51:52 +0000 [thread overview] Message-ID: <cover.4133d2f24fd73c1889a46ea05bb8924867b33747.1483993967.git-series.james.hogan@imgtec.com> (raw) Note: My intention is to take this series via the MIPS KVM tree along with the others for v4.11, with a topic branch containing the MIPS architecture change, so an ack is welcome for patch 1 in particular. This series first converts MIPS KVM to use page tables for its GPA -> HPA mappings instead of a linear array. The linear array was only really meant to be temporary, and isn't sparse so its wasteful of memory. It also never handled resizing of the array for multiple or changed memory regions, which a sparse page table pretty much handles automatically. We then go on to implement the shadow flushing architecture callbacks to allow the mappings (page tables and TLB entries) to be flushed in response to memory region changes. This is fairly straightforward for GPA which is shared between VCPUs as the kvm->mmu_lock can protect it, but GVA page tables are specific to a VCPU so are accessed locklessly. This would make it unsafe to directly modify any GVA page tables, so we wire up the TLB flush VCPU request so that we can tell a possibly running VCPU to flush its own GVA mappings. Since MIPS KVM emulation code can also access GVA mappings directly, we use the READING_SHADOW_PAGE_TABLES VCPU mode similar to how x86 does to locklessly protect these accesses. This ensures that either the flush will take place before the GVA access, or an IPI will be sent to confirm receipt of the request which will be delayed until after the GVA access is complete. The patches are roughly grouped as follows: Patch 1: This is a MIPS architecture change needed for patch 9. As I mentioned above I intend to combine this into a topic branch which can be merged into both the MIPS architecture tree and the MIPS KVM tree. Patch 2: This singularly converts GPA to use page tables. Patches 3-10: These implement shadow flushing, first laying the ground work to allow TLB flush requests to work and to protect direct GVA access from asynchronous flush requests. 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 James Hogan (10): MIPS: Add return errors to protected cache ops KVM: MIPS/MMU: Convert guest physical map to page table KVM: MIPS: Update vcpu->mode and vcpu->cpu KVM: MIPS/T&E: Handle TLB invalidation requests KVM: MIPS/T&E: Reduce stale ASID checks KVM: MIPS/T&E: Add lockless GVA access helpers KVM: MIPS/T&E: Use lockless GVA helpers for dyntrans KVM: MIPS/MMU: Use lockless GVA helpers for get_inst() KVM: MIPS/Emulate: Use lockless GVA helpers for cache emulation KVM: MIPS: Implement kvm_arch_flush_shadow_all/memslot arch/mips/include/asm/kvm_host.h | 35 ++- arch/mips/include/asm/r4kcache.h | 55 +++-- arch/mips/kvm/dyntrans.c | 26 +- arch/mips/kvm/emulate.c | 149 +++++-------- arch/mips/kvm/mips.c | 92 +++++--- arch/mips/kvm/mmu.c | 367 ++++++++++++++++++++++++++++---- arch/mips/kvm/tlb.c | 35 +--- arch/mips/kvm/trap_emul.c | 185 ++++++++++++---- 8 files changed, 690 insertions(+), 254 deletions(-) -- 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 Subject: [PATCH 0/10] KVM: MIPS: Implement GPA page tables and shadow flushing Date: Mon, 9 Jan 2017 20:51:52 +0000 [thread overview] Message-ID: <cover.4133d2f24fd73c1889a46ea05bb8924867b33747.1483993967.git-series.james.hogan@imgtec.com> (raw) Message-ID: <20170109205152.psCYWXv5AXj6Ep1vHDp4HgaxD1aZ_I9Kn4_Es5ccwP0@z> (raw) Note: My intention is to take this series via the MIPS KVM tree along with the others for v4.11, with a topic branch containing the MIPS architecture change, so an ack is welcome for patch 1 in particular. This series first converts MIPS KVM to use page tables for its GPA -> HPA mappings instead of a linear array. The linear array was only really meant to be temporary, and isn't sparse so its wasteful of memory. It also never handled resizing of the array for multiple or changed memory regions, which a sparse page table pretty much handles automatically. We then go on to implement the shadow flushing architecture callbacks to allow the mappings (page tables and TLB entries) to be flushed in response to memory region changes. This is fairly straightforward for GPA which is shared between VCPUs as the kvm->mmu_lock can protect it, but GVA page tables are specific to a VCPU so are accessed locklessly. This would make it unsafe to directly modify any GVA page tables, so we wire up the TLB flush VCPU request so that we can tell a possibly running VCPU to flush its own GVA mappings. Since MIPS KVM emulation code can also access GVA mappings directly, we use the READING_SHADOW_PAGE_TABLES VCPU mode similar to how x86 does to locklessly protect these accesses. This ensures that either the flush will take place before the GVA access, or an IPI will be sent to confirm receipt of the request which will be delayed until after the GVA access is complete. The patches are roughly grouped as follows: Patch 1: This is a MIPS architecture change needed for patch 9. As I mentioned above I intend to combine this into a topic branch which can be merged into both the MIPS architecture tree and the MIPS KVM tree. Patch 2: This singularly converts GPA to use page tables. Patches 3-10: These implement shadow flushing, first laying the ground work to allow TLB flush requests to work and to protect direct GVA access from asynchronous flush requests. 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 James Hogan (10): MIPS: Add return errors to protected cache ops KVM: MIPS/MMU: Convert guest physical map to page table KVM: MIPS: Update vcpu->mode and vcpu->cpu KVM: MIPS/T&E: Handle TLB invalidation requests KVM: MIPS/T&E: Reduce stale ASID checks KVM: MIPS/T&E: Add lockless GVA access helpers KVM: MIPS/T&E: Use lockless GVA helpers for dyntrans KVM: MIPS/MMU: Use lockless GVA helpers for get_inst() KVM: MIPS/Emulate: Use lockless GVA helpers for cache emulation KVM: MIPS: Implement kvm_arch_flush_shadow_all/memslot arch/mips/include/asm/kvm_host.h | 35 ++- arch/mips/include/asm/r4kcache.h | 55 +++-- arch/mips/kvm/dyntrans.c | 26 +- arch/mips/kvm/emulate.c | 149 +++++-------- arch/mips/kvm/mips.c | 92 +++++--- arch/mips/kvm/mmu.c | 367 ++++++++++++++++++++++++++++---- arch/mips/kvm/tlb.c | 35 +--- arch/mips/kvm/trap_emul.c | 185 ++++++++++++---- 8 files changed, 690 insertions(+), 254 deletions(-) -- git-series 0.8.10
next reply other threads:[~2017-01-09 20:53 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-01-09 20:51 James Hogan [this message] 2017-01-09 20:51 ` [PATCH 0/10] KVM: MIPS: Implement GPA page tables and shadow flushing James Hogan 2017-01-09 20:51 ` [PATCH 1/10] MIPS: Add return errors to protected cache ops James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-17 16:05 ` Ralf Baechle 2017-01-09 20:51 ` [PATCH 2/10] KVM: MIPS/MMU: Convert guest physical map to page table James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:51 ` [PATCH 3/10] KVM: MIPS: Update vcpu->mode and vcpu->cpu James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:51 ` [PATCH 4/10] KVM: MIPS/T&E: Handle TLB invalidation requests James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:51 ` [PATCH 5/10] KVM: MIPS/T&E: Reduce stale ASID checks James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:51 ` [PATCH 6/10] KVM: MIPS/T&E: Add lockless GVA access helpers James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:51 ` [PATCH 7/10] KVM: MIPS/T&E: Use lockless GVA helpers for dyntrans James Hogan 2017-01-09 20:51 ` James Hogan 2017-01-09 20:52 ` [PATCH 8/10] KVM: MIPS/MMU: Use lockless GVA helpers for get_inst() James Hogan 2017-01-09 20:52 ` James Hogan 2017-01-09 20:52 ` [PATCH 9/10] KVM: MIPS/Emulate: Use lockless GVA helpers for cache emulation James Hogan 2017-01-09 20:52 ` James Hogan 2017-01-09 20:52 ` [PATCH 10/10] KVM: MIPS: Implement kvm_arch_flush_shadow_all/memslot James Hogan 2017-01-09 20:52 ` 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.4133d2f24fd73c1889a46ea05bb8924867b33747.1483993967.git-series.james.hogan@imgtec.com \ --to=james.hogan@imgtec.com \ --cc=kvm@vger.kernel.org \ --cc=linux-mips@linux-mips.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).