Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1554065
| Path | csiph.com!feeder.erje.net!2.eu.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!news.highwinds-media.com!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Jintack Lim <jintack@cs.columbia.edu> |
| Newsgroups | linux.kernel |
| Subject | [RFC 52/55] KVM: arm/arm64: Create a vcpu mapping for the nested VM |
| Date | Mon, 09 Jan 2017 07:30:02 +0100 |
| Message-ID | <sXBCW-wl-41@gated-at.bofh.it> (permalink) |
| References | <sXBCV-wl-3@gated-at.bofh.it> |
| X-Original-To | christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, vladimir.murzin@arm.com, suzuki.poulose@arm.com, mark.rutland@arm.com, james.morse@arm.com, lorenzo.pieralisi@arm.com, kevin.brodsky@arm.com, wcohen@redhat.com, shankerd@codeaurora.org, geoff@infradead.org, andre.przywara@arm.com, eric.auger@redhat.com, anna-maria@linutronix.de, shihwei@cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U2YE8NBef5BiGS07jyDZ37X+JqAOdVZl1coK9YhHYxA=; b=TDjJl1HHYD5LuTDuPslfJ6UK5PQeXW4QsPIe1+qvy1gcp9zXkCR5mb+zR+/U6O48kS sTZ5KCCjdVCQsEELGWxlmjUyRtYxUfKUl2uVEmpMBwD4e1pn4s7jGPZozuDcQCH3DcI9 qIIUTO2IkHkM6IVbGhyWGUpGyxxkBF9/yKwqL9W5i4jsmkrU3T4F1DQRC/fBTTlzHgWw ovwsTaZpwkS14wXax6HSuUzkcRFETIjTUF2yESB/Rx0F1M9Zj1An8ZjK1ttK/gPEqAGM nv/IdTsNWSlRIVoRd2uNAf+n7M+f1jZ6vBNa7dGFoJQ3dvRCwn1NzxLc7wLyESz4vn/o S8Vg== |
| X-Gm-Message-State | AIkVDXIjTz9jP543bNrZlKJf/w4ZtCIUePpl3cF6nfX7RPJTxXslrRrxgSZqgjGi//M+oxO5wRcBio0ec2UvxYKKqj/sFDdBvLhoIy+ijqwxh5SrscRUYNooHlmTipgyzU3I+4q9ixxFjgJ0Ey+xDuuMAYo= |
| X-Received | by 10.237.34.167 with SMTP id p36mr79091993qtc.286.1483943196956; Sun, 08 Jan 2017 22:26:36 -0800 (PST) |
| X-Received | by 10.237.34.167 with SMTP id p36mr79091965qtc.286.1483943196783; Sun, 08 Jan 2017 22:26:36 -0800 (PST) |
| X-Mailer | git-send-email 1.9.1 |
| X-No-Spam-Score | Local |
| X-Scanned-By | MIMEDefang 2.78 on 128.59.72.14 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 101 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | jintack@cs.columbia.edu |
| X-Original-Date | Mon, 9 Jan 2017 01:24:48 -0500 |
| X-Original-Message-ID | <1483943091-1364-53-git-send-email-jintack@cs.columbia.edu> |
| X-Original-References | <1483943091-1364-1-git-send-email-jintack@cs.columbia.edu> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| X-Received-Bytes | 6700 |
| X-Received-Body-CRC | 4271962897 |
| Xref | csiph.com linux.kernel:1554065 |
Show key headers only | View raw
Create a mapping from the nested VM's cpu interface to the hardware
virtual cpu interface. This is to allow the nested VM to access virtual
cpu interface directly.
Signed-off-by: Jintack Lim <jintack@cs.columbia.edu>
---
arch/arm/include/asm/kvm_mmu.h | 3 +++
arch/arm/kvm/mmu.c | 5 +++++
arch/arm64/include/asm/kvm_mmu.h | 5 +++++
arch/arm64/kvm/mmu-nested.c | 26 ++++++++++++++++++++++++++
4 files changed, 39 insertions(+)
diff --git a/arch/arm/include/asm/kvm_mmu.h b/arch/arm/include/asm/kvm_mmu.h
index 0d106ae..048a021 100644
--- a/arch/arm/include/asm/kvm_mmu.h
+++ b/arch/arm/include/asm/kvm_mmu.h
@@ -254,6 +254,9 @@ static inline void kvm_nested_s2_teardown(struct kvm_vcpu *vcpu) { }
static inline void kvm_nested_s2_all_vcpus_wp(struct kvm *kvm) { }
static inline void kvm_nested_s2_all_vcpus_unmap(struct kvm *kvm) { }
static inline void kvm_nested_s2_all_vcpus_flush(struct kvm *kvm) { }
+static inline int kvm_nested_mmio_ondemand(struct kvm_vcpu *vcpu,
+ phys_addr_t fault_ipa,
+ phys_addr_t ipa) { return 0; }
static inline u64 kvm_get_vttbr(struct kvm_s2_vmid *vmid,
struct kvm_s2_mmu *mmu)
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index 2cd6a19..f7c2911 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -1615,6 +1615,11 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
goto out_unlock;
}
+ if (kvm_nested_mmio_ondemand(vcpu, fault_ipa, ipa)) {
+ ret = 1;
+ goto out_unlock;
+ }
+
/*
* The IPA is reported as [MAX:12], so we need to
* complement it with the bottom 12 bits from the
diff --git a/arch/arm64/include/asm/kvm_mmu.h b/arch/arm64/include/asm/kvm_mmu.h
index ec9e5e9..ee80a58 100644
--- a/arch/arm64/include/asm/kvm_mmu.h
+++ b/arch/arm64/include/asm/kvm_mmu.h
@@ -354,6 +354,8 @@ int kvm_s2_handle_perm_fault(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
void kvm_nested_s2_all_vcpus_wp(struct kvm *kvm);
void kvm_nested_s2_all_vcpus_unmap(struct kvm *kvm);
void kvm_nested_s2_all_vcpus_flush(struct kvm *kvm);
+int kvm_nested_mmio_ondemand(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ phys_addr_t ipa);
#else
static inline struct kvm_nested_s2_mmu *get_nested_mmu(struct kvm_vcpu *vcpu,
u64 vttbr)
@@ -389,6 +391,9 @@ static inline void kvm_nested_s2_teardown(struct kvm_vcpu *vcpu) { }
static inline void kvm_nested_s2_all_vcpus_wp(struct kvm *kvm) { }
static inline void kvm_nested_s2_all_vcpus_unmap(struct kvm *kvm) { }
static inline void kvm_nested_s2_all_vcpus_flush(struct kvm *kvm) { }
+static inline int kvm_nested_mmio_ondemand(struct kvm_vcpu *vcpu,
+ phys_addr_t fault_ipa,
+ phys_addr_t ipa) { return 0; }
#endif
static inline u64 kvm_get_vttbr(struct kvm_s2_vmid *vmid,
diff --git a/arch/arm64/kvm/mmu-nested.c b/arch/arm64/kvm/mmu-nested.c
index 65ad0da..bce0042 100644
--- a/arch/arm64/kvm/mmu-nested.c
+++ b/arch/arm64/kvm/mmu-nested.c
@@ -473,3 +473,29 @@ bool handle_vttbr_update(struct kvm_vcpu *vcpu, u64 vttbr)
return true;
}
+
+/*
+ * vcpu interface address. This address is supposed to come from the guest's
+ * device tree via QEMU. Here we just hardcoded it, but should be fixed.
+ */
+#define NESTED_VCPU_IF_ADDR 0x08010000
+int kvm_nested_mmio_ondemand(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
+ phys_addr_t ipa)
+{
+ int ret = 0;
+ phys_addr_t vcpu_base = vgic_vcpu_base();
+
+ /* Return if this fault is not from a nested VM */
+ if (vcpu->arch.hw_mmu == &vcpu->kvm->arch.mmu)
+ return ret;
+
+ if (ipa == NESTED_VCPU_IF_ADDR) {
+ ret = __kvm_phys_addr_ioremap(vcpu->kvm, vcpu->arch.hw_mmu,
+ fault_ipa, vcpu_base,
+ KVM_VGIC_V2_CPU_SIZE, true);
+ if (!ret)
+ ret = 1;
+ }
+
+ return ret;
+}
--
1.9.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC 52/55] KVM: arm/arm64: Create a vcpu mapping for the nested VM Jintack Lim <jintack@cs.columbia.edu> - 2017-01-09 07:30 +0100
csiph-web