public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoffer Dall <c.dall@virtualopensystems.com>
To: android-virt@lists.cs.columbia.edu, kvm@vger.kernel.org
Cc: tech@virtualopensystems.com
Subject: [PATCH v6 12/12] ARM: KVM: Handle CP15 CR9 accesses for L2CTLR emulation
Date: Thu, 23 Feb 2012 02:33:28 -0500	[thread overview]
Message-ID: <20120223073328.3266.26424.stgit@ubuntu> (raw)
In-Reply-To: <20120223073159.3266.45217.stgit@ubuntu>

From: Marc Zyngier <marc.zyngier@arm.com>

Note: This is an awful hack and will go away as soon as the emulation and
decoding code has been changed to a table-driven approach.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 arch/arm/kvm/emulate.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
index 20269f8..4f5f2de 100644
--- a/arch/arm/kvm/emulate.c
+++ b/arch/arm/kvm/emulate.c
@@ -206,6 +206,39 @@ int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
 }
 
 /**
+ * emulate_cp15_c9_access -- emulates cp15 accesses for CRn == 9
+ * @vcpu: The VCPU pointer
+ * @p:    The coprocessor parameters struct pointer holding trap inst. details
+ */
+static int emulate_cp15_c9_access(struct kvm_vcpu *vcpu,
+				  struct coproc_params *p)
+{
+	BUG_ON(p->CRn != 9);
+	BUG_ON(p->is_64bit);
+
+	if (p->CRm == 0 && p->Op1 == 1 && p->Op2 == 2) {
+		/* Emulate L2CTLR access */
+		u32 l2ctlr, ncores;
+
+		if (p->is_write)
+			return 0;
+
+		asm volatile("mrc p15, 1, %0, c9, c0, 2\n" : "=r" (l2ctlr));
+		l2ctlr &= ~(3 << 24);
+		ncores = atomic_read(&vcpu->kvm->online_vcpus) - 1;
+		l2ctlr |= (ncores & 3) << 24;
+		*vcpu_reg(vcpu, p->Rt1) = l2ctlr;
+
+		return 0;
+	}
+
+	/* hack alert!!! */
+	if (!p->is_write)
+		*vcpu_reg(vcpu, p->Rt1) = 0;
+	return 0;
+}
+
+/**
  * emulate_cp15_c10_access -- emulates cp15 accesses for CRn == 10
  * @vcpu: The VCPU pointer
  * @p:    The coprocessor parameters struct pointer holding trap inst. details
@@ -310,6 +343,9 @@ int kvm_handle_cp15_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
 		goto unsupp_err_out;
 
 	switch (params.CRn) {
+	case 9:
+		ret = emulate_cp15_c9_access(vcpu, &params);
+		break;
 	case 10:
 		ret = emulate_cp15_c10_access(vcpu, &params);
 		break;


      parent reply	other threads:[~2012-02-23  7:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-23  7:32 [PATCH v6 00/12] KVM/ARM Implementation Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 01/12] KVM: Introduce __KVM_HAVE_IRQ_LINE Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 02/12] ARM: KVM: Initial skeleton to compile KVM support Christoffer Dall
2012-02-24  3:32   ` Rusty Russell
2012-02-24  4:43     ` Christoffer Dall
2012-02-25  3:50       ` Rusty Russell
2012-02-25 15:20         ` Christoffer Dall
2012-03-11 21:41     ` Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 03/12] ARM: KVM: Hypervisor identity mapping Christoffer Dall
2012-02-24  3:33   ` Rusty Russell
2012-02-23  7:32 ` [PATCH v6 04/12] ARM: KVM: Hypervisor inititalization Christoffer Dall
2012-02-24  4:00   ` Rusty Russell
2012-03-11 22:24     ` Christoffer Dall
2012-03-13  3:20       ` Rusty Russell
2012-03-05  1:12   ` Rusty Russell
2012-03-05  2:13     ` Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 05/12] ARM: KVM: Memory virtualization setup Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 06/12] ARM: KVM: Inject IRQs and FIQs from userspace Christoffer Dall
2012-02-23  7:32 ` [PATCH v6 07/12] ARM: KVM: World-switch implementation Christoffer Dall
2012-02-23  7:33 ` [PATCH v6 08/12] ARM: KVM: Emulation framework and CP15 emulation Christoffer Dall
2012-02-23  7:33 ` [PATCH v6 09/12] ARM: KVM: Handle guest faults in KVM Christoffer Dall
2012-02-23  7:33 ` [PATCH v6 10/12] ARM: KVM: Handle I/O aborts Christoffer Dall
2012-02-23  7:33 ` [PATCH v6 11/12] ARM: KVM: Guest wait-for-interrupts (WFI) support Christoffer Dall
2012-02-23  7:33 ` Christoffer Dall [this message]

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=20120223073328.3266.26424.stgit@ubuntu \
    --to=c.dall@virtualopensystems.com \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=kvm@vger.kernel.org \
    --cc=tech@virtualopensystems.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: link
Be 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