kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: Linuxppc-dev <linuxppc-dev@ozlabs.org>, KVM list <kvm@vger.kernel.org>
Subject: [PATCH 13/35] KVM: PPC: Add feature bitmap for magic page
Date: Tue, 31 Aug 2010 04:31:54 +0200	[thread overview]
Message-ID: <1283221937-21006-14-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1283221937-21006-1-git-send-email-agraf@suse.de>

We will soon add SR PV support to the shared page, so we need some
infrastructure that allows the guest to query for features KVM exports.

This patch adds a second return value to the magic mapping that
indicated to the guest which features are available.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/include/asm/kvm_para.h |    2 ++
 arch/powerpc/kernel/kvm.c           |   21 +++++++++++++++------
 arch/powerpc/kvm/powerpc.c          |    5 ++++-
 3 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 7438ab3..43c1b22 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -47,6 +47,8 @@ struct kvm_vcpu_arch_shared {
 
 #define KVM_FEATURE_MAGIC_PAGE	1
 
+#define KVM_MAGIC_FEAT_SR	(1 << 0)
+
 #ifdef __KERNEL__
 
 #ifdef CONFIG_KVM_GUEST
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index e936817..f48144f 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -267,12 +267,20 @@ static void kvm_patch_ins_wrteei(u32 *inst)
 
 static void kvm_map_magic_page(void *data)
 {
-	kvm_hypercall2(KVM_HC_PPC_MAP_MAGIC_PAGE,
-		       KVM_MAGIC_PAGE,  /* Physical Address */
-		       KVM_MAGIC_PAGE); /* Effective Address */
+	u32 *features = data;
+
+	ulong in[8];
+	ulong out[8];
+
+	in[0] = KVM_MAGIC_PAGE;
+	in[1] = KVM_MAGIC_PAGE;
+
+	kvm_hypercall(in, out, HC_VENDOR_KVM | KVM_HC_PPC_MAP_MAGIC_PAGE);
+
+	*features = out[0];
 }
 
-static void kvm_check_ins(u32 *inst)
+static void kvm_check_ins(u32 *inst, u32 features)
 {
 	u32 _inst = *inst;
 	u32 inst_no_rt = _inst & ~KVM_MASK_RT;
@@ -368,9 +376,10 @@ static void kvm_use_magic_page(void)
 	u32 *p;
 	u32 *start, *end;
 	u32 tmp;
+	u32 features;
 
 	/* Tell the host to map the magic page to -4096 on all CPUs */
-	on_each_cpu(kvm_map_magic_page, NULL, 1);
+	on_each_cpu(kvm_map_magic_page, &features, 1);
 
 	/* Quick self-test to see if the mapping works */
 	if (__get_user(tmp, (u32*)KVM_MAGIC_PAGE)) {
@@ -383,7 +392,7 @@ static void kvm_use_magic_page(void)
 	end = (void*)_etext;
 
 	for (p = start; p < end; p++)
-		kvm_check_ins(p);
+		kvm_check_ins(p, features);
 
 	printk(KERN_INFO "KVM: Live patching for a fast VM %s\n",
 			 kvm_patching_worked ? "worked" : "failed");
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 6a53a3f..496d7a5 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -66,6 +66,8 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 		vcpu->arch.magic_page_pa = param1;
 		vcpu->arch.magic_page_ea = param2;
 
+		r2 = 0;
+
 		r = HC_EV_SUCCESS;
 		break;
 	}
@@ -76,13 +78,14 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
 #endif
 
 		/* Second return value is in r4 */
-		kvmppc_set_gpr(vcpu, 4, r2);
 		break;
 	default:
 		r = HC_EV_UNIMPLEMENTED;
 		break;
 	}
 
+	kvmppc_set_gpr(vcpu, 4, r2);
+
 	return r;
 }
 
-- 
1.6.0.2


  parent reply	other threads:[~2010-08-31  2:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-31  2:31 [PULL 00/35] KVM: PPC: End-August patch queue Alexander Graf
2010-08-31  2:31 ` [PATCH 01/35] KVM: PPC: Move EXIT_DEBUG partially to tracepoints Alexander Graf
2010-08-31  2:31 ` [PATCH 02/35] KVM: PPC: Move book3s_64 mmu map debug print to trace point Alexander Graf
2010-08-31  2:31 ` [PATCH 07/35] KVM: PPC: Preload magic page when in kernel mode Alexander Graf
2010-08-31  2:31 ` [PATCH 08/35] KVM: PPC: Don't flush PTEs on NX/RO hit Alexander Graf
2010-08-31  2:31 ` [PATCH 10/35] KVM: PPC: Move slb debugging to tracepoints Alexander Graf
     [not found] ` <1283221937-21006-1-git-send-email-agraf-l3A5Bk7waGM@public.gmane.org>
2010-08-31  2:31   ` [PATCH 03/35] KVM: PPC: Add tracepoint for generic mmu map Alexander Graf
2010-08-31  2:31   ` [PATCH 04/35] KVM: PPC: Move pte invalidate debug code to tracepoint Alexander Graf
2010-08-31  2:31   ` [PATCH 05/35] KVM: PPC: Fix sid map search after flush Alexander Graf
2010-08-31  2:31   ` [PATCH 06/35] KVM: PPC: Add tracepoints for generic spte flushes Alexander Graf
2010-08-31  2:31   ` [PATCH 09/35] KVM: PPC: Make invalidation code more reliable Alexander Graf
2010-08-31  2:31   ` [PATCH 11/35] KVM: PPC: Revert "KVM: PPC: Use kernel hash function" Alexander Graf
2010-08-31  2:31   ` [PATCH 12/35] KVM: PPC: Remove unused define Alexander Graf
2010-08-31  2:31   ` [PATCH 16/35] KVM: PPC: Put segment registers in shared page Alexander Graf
2010-08-31  2:32   ` [PATCH 19/35] KVM: PPC: Update int_pending also on dequeue Alexander Graf
2010-08-31  2:32   ` [PATCH 21/35] KVM: PPC: Force enable nap on KVM Alexander Graf
2010-08-31  2:32   ` [PATCH 24/35] KVM: PPC: initialize IVORs in addition to IVPR Alexander Graf
2010-08-31  2:32   ` [PATCH 29/35] KVM: PPC: Fix CONFIG_KVM_GUEST && !CONFIG_KVM case Alexander Graf
2010-08-31  2:32   ` [PATCH 33/35] KVM: PPC: e500_tlb: Fix a minor copy-paste tracing bug Alexander Graf
2010-08-31  2:32   ` [PATCH 35/35] KVM: PPC: Add documentation for magic page enhancements Alexander Graf
2010-08-31  2:31 ` Alexander Graf [this message]
2010-08-31  2:31 ` [PATCH 14/35] KVM: PPC: Move BAT handling code into spr handler Alexander Graf
2010-08-31  2:31 ` [PATCH 15/35] KVM: PPC: Interpret SR registers on demand Alexander Graf
2010-08-31  2:31 ` [PATCH 17/35] KVM: PPC: Add mtsrin PV code Alexander Graf
2010-08-31  2:31 ` [PATCH 18/35] KVM: PPC: Make PV mtmsr work with r30 and r31 Alexander Graf
2010-08-31  2:32 ` [PATCH 20/35] KVM: PPC: Make PV mtmsrd L=1 " Alexander Graf
2010-08-31  2:32 ` [PATCH 22/35] KVM: PPC: Implement correct SID mapping on Book3s_32 Alexander Graf
2010-08-31  2:32 ` [PATCH 23/35] KVM: PPC: Don't put MSR_POW in MSR Alexander Graf
2010-08-31  2:32 ` [PATCH 25/35] KVM: PPC: fix compilation of "dump tlbs" debug function Alexander Graf
2010-08-31  2:32 ` [PATCH 26/35] KVM: PPC: allow ppc440gp to pass the compatibility check Alexander Graf
2010-08-31  2:32 ` [PATCH 27/35] KVM: PPC: Enable napping only for Book3s_64 Alexander Graf
2010-08-31  2:32 ` [PATCH 28/35] KVM: PPC: Implement Level interrupts on Book3S Alexander Graf
2010-08-31  2:32 ` [PATCH 30/35] KVM: PPC: Expose level based interrupt cap Alexander Graf
2010-08-31  2:32 ` [PATCH 31/35] KVM: PPC: Implement level interrupts for BookE Alexander Graf
2010-08-31  2:32 ` [PATCH 32/35] KVM: PPC: Document KVM_INTERRUPT ioctl Alexander Graf
2010-08-31  2:32 ` [PATCH 34/35] KVM: PPC: Fix compile error in e500_tlb.c Alexander Graf
2010-09-01  7:50 ` [PULL 00/35] KVM: PPC: End-August patch queue Avi Kivity

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=1283221937-21006-14-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).