public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/3] fixes for kvm on s390
@ 2009-06-23 15:24 Christian Borntraeger
  2009-06-23 15:24 ` [patch 1/3] kvm-s390: Fix memslot initialization for userspace_addr != 0 Christian Borntraeger
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christian Borntraeger @ 2009-06-23 15:24 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM

Hello Avi,

here are three patches against kvm.git that fix several issues in our
kvm port. Please review and consider all patches for 2.6.31.

Christian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 1/3] kvm-s390: Fix memslot initialization for userspace_addr != 0
  2009-06-23 15:24 [patch 0/3] fixes for kvm on s390 Christian Borntraeger
@ 2009-06-23 15:24 ` Christian Borntraeger
  2009-06-23 15:24 ` [patch 2/3] kvm-s390: Allow stfle instruction in the guest Christian Borntraeger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2009-06-23 15:24 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM,
	Christian Borntraeger

[-- Attachment #1: fix_memslot.patch --]
[-- Type: text/plain, Size: 1445 bytes --]

From: Christian Borntraeger <borntraeger@de.ibm.com>

Since
commit 854b5338196b1175706e99d63be43a4f8d8ab607
Author: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
    KVM: s390: streamline memslot handling

s390 uses the values of the memslot instead of doing everything in the arch
ioctl handler of the KVM_SET_USER_MEMORY_REGION. Unfortunately we missed to
set the userspace_addr of our memslot due to our s390 ifdef in 
__kvm_set_memory_region.
Old s390 userspace launchers did not notice, since they started the guest at
userspace address 0. 
Because of CONFIG_DEFAULT_MMAP_MIN_ADDR we now put the guest at 1M userspace,
which does not work. This patch makes sure that new.userspace_addr is set
on s390.
This fix should go in quickly. Nevertheless, looking at the code we should
clean up that ifdef in the long term. Any kernel janitors?

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 virt/kvm/kvm_main.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: kvm/virt/kvm/kvm_main.c
===================================================================
--- kvm.orig/virt/kvm/kvm_main.c
+++ kvm/virt/kvm/kvm_main.c
@@ -1199,6 +1199,10 @@ int __kvm_set_memory_region(struct kvm *
 		if (old.npages)
 			kvm_arch_flush_shadow(kvm);
 	}
+#else  /* not defined CONFIG_S390 */
+	new.user_alloc = user_alloc;
+	if (user_alloc)
+		new.userspace_addr = mem->userspace_addr;
 #endif /* not defined CONFIG_S390 */
 
 	if (!npages)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 2/3] kvm-s390: Allow stfle instruction in the guest
  2009-06-23 15:24 [patch 0/3] fixes for kvm on s390 Christian Borntraeger
  2009-06-23 15:24 ` [patch 1/3] kvm-s390: Fix memslot initialization for userspace_addr != 0 Christian Borntraeger
@ 2009-06-23 15:24 ` Christian Borntraeger
  2009-06-23 15:24 ` [patch 3/3] kvm-s390: Remove some unused variables Christian Borntraeger
  2009-06-24  8:09 ` [patch 0/3] fixes for kvm on s390 Avi Kivity
  3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2009-06-23 15:24 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM,
	Christian Borntraeger

[-- Attachment #1: stfle.patch --]
[-- Type: text/plain, Size: 3563 bytes --]

From: Christian Borntraeger <borntraeger@de.ibm.com>

2.6.31-rc introduced an architecture level set checker based on facility
bits. e.g. if the kernel is compiled to run only on z9, several facility 
bits are checked very early and the kernel refuses to boot if a z9 specific
facility is missing.
Until now kvm on s390 did not implement the store facility extended (STFLE)
instruction. A 2.6.31-rc kernel that was compiled for z9 or higher did not
boot in kvm. This patch implements stfle.

This patch should go in before 2.6.31.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h |    4 +++-
 arch/s390/kvm/kvm-s390.c         |   23 ++++++++++++++++++++++-
 arch/s390/kvm/priv.c             |    2 +-
 3 files changed, 26 insertions(+), 3 deletions(-)

Index: kvm/arch/s390/include/asm/kvm_host.h
===================================================================
--- kvm.orig/arch/s390/include/asm/kvm_host.h
+++ kvm/arch/s390/include/asm/kvm_host.h
@@ -99,7 +99,9 @@ struct kvm_s390_sie_block {
 	__u8	reservedd0[48];		/* 0x00d0 */
 	__u64	gcr[16];		/* 0x0100 */
 	__u64	gbea;			/* 0x0180 */
-	__u8	reserved188[120];	/* 0x0188 */
+	__u8	reserved188[24];	/* 0x0188 */
+	__u32	fac;			/* 0x01a0 */
+	__u8	reserved1a4[92];	/* 0x01a4 */
 } __attribute__((packed));
 
 struct kvm_vcpu_stat {
Index: kvm/arch/s390/kvm/kvm-s390.c
===================================================================
--- kvm.orig/arch/s390/kvm/kvm-s390.c
+++ kvm/arch/s390/kvm/kvm-s390.c
@@ -26,6 +26,7 @@
 #include <asm/lowcore.h>
 #include <asm/pgtable.h>
 #include <asm/nmi.h>
+#include <asm/system.h>
 #include "kvm-s390.h"
 #include "gaccess.h"
 
@@ -70,6 +71,7 @@ struct kvm_stats_debugfs_item debugfs_en
 	{ NULL }
 };
 
+static unsigned long long *facilities;
 
 /* Section: not file related */
 void kvm_arch_hardware_enable(void *garbage)
@@ -287,6 +289,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu 
 	set_bit(KVM_REQ_MMU_RELOAD, &vcpu->requests);
 	vcpu->arch.sie_block->ecb   = 2;
 	vcpu->arch.sie_block->eca   = 0xC1002001U;
+	vcpu->arch.sie_block->fac   = (int) (long) facilities;
 	hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
 	tasklet_init(&vcpu->arch.tasklet, kvm_s390_tasklet,
 		     (unsigned long) vcpu);
@@ -727,11 +730,29 @@ gfn_t unalias_gfn(struct kvm *kvm, gfn_t
 
 static int __init kvm_s390_init(void)
 {
-	return kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE);
+	int ret;
+	ret = kvm_init(NULL, sizeof(struct kvm_vcpu), THIS_MODULE);
+	if (ret)
+		return ret;
+
+	/*
+	 * guests can ask for up to 255+1 double words, we need a full page
+	 * to hold the maximum amount of facilites. On the other hand, we
+	 * only set facilities that are known to work in KVM.
+	 */
+	facilities = (unsigned long long *) get_zeroed_page(GFP_DMA);
+	if (!facilities) {
+		kvm_exit();
+		return -ENOMEM;
+	}
+	stfle(facilities, 1);
+	facilities[0] &= 0xff00fff3f0700000ULL;
+	return 0;
 }
 
 static void __exit kvm_s390_exit(void)
 {
+	free_page((unsigned long) facilities);
 	kvm_exit();
 }
 
Index: kvm/arch/s390/kvm/priv.c
===================================================================
--- kvm.orig/arch/s390/kvm/priv.c
+++ kvm/arch/s390/kvm/priv.c
@@ -158,7 +158,7 @@ static int handle_stfl(struct kvm_vcpu *
 
 	vcpu->stat.instruction_stfl++;
 	/* only pass the facility bits, which we can handle */
-	facility_list &= 0xfe00fff3;
+	facility_list &= 0xff00fff3;
 
 	rc = copy_to_guest(vcpu, offsetof(struct _lowcore, stfl_fac_list),
 			   &facility_list, sizeof(facility_list));


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [patch 3/3] kvm-s390: Remove some unused variables
  2009-06-23 15:24 [patch 0/3] fixes for kvm on s390 Christian Borntraeger
  2009-06-23 15:24 ` [patch 1/3] kvm-s390: Fix memslot initialization for userspace_addr != 0 Christian Borntraeger
  2009-06-23 15:24 ` [patch 2/3] kvm-s390: Allow stfle instruction in the guest Christian Borntraeger
@ 2009-06-23 15:24 ` Christian Borntraeger
  2009-06-24  8:09 ` [patch 0/3] fixes for kvm on s390 Avi Kivity
  3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2009-06-23 15:24 UTC (permalink / raw)
  To: Avi Kivity
  Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM,
	Gleb Natapov, Christian Borntraeger

[-- Attachment #1: fix_warnings.patch --]
[-- Type: text/plain, Size: 1051 bytes --]

From: Christian Borntraeger <borntraeger@de.ibm.com>

This patch fixes the following warnings that were introduced by
commit 2921292f45733bccdb53e426bcf65ceb13f53d94
Author: Gleb Natapov <gleb@redhat.com>
    KVM: Use macro to iterate over vcpus.

arch/s390/kvm/kvm-s390.c: In function 'kvm_arch_set_memory_region':
arch/s390/kvm/kvm-s390.c:687: warning: unused variable 'r'
arch/s390/kvm/kvm-s390.c:687: warning: unused variable 'j'

CC: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: kvm/arch/s390/kvm/kvm-s390.c
===================================================================
--- kvm.orig/arch/s390/kvm/kvm-s390.c
+++ kvm/arch/s390/kvm/kvm-s390.c
@@ -684,7 +684,7 @@ int kvm_arch_set_memory_region(struct kv
 				struct kvm_memory_slot old,
 				int user_alloc)
 {
-	int i, j = 0, r = -EINVAL;
+	int i;
 	struct kvm_vcpu *vcpu;
 
 	/* A few sanity checks. We can have exactly one memory slot which has


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 0/3] fixes for kvm on s390
  2009-06-23 15:24 [patch 0/3] fixes for kvm on s390 Christian Borntraeger
                   ` (2 preceding siblings ...)
  2009-06-23 15:24 ` [patch 3/3] kvm-s390: Remove some unused variables Christian Borntraeger
@ 2009-06-24  8:09 ` Avi Kivity
  2009-06-24  8:18   ` Christian Bornträger
  3 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-06-24  8:09 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM

On 06/23/2009 06:24 PM, Christian Borntraeger wrote:
> Hello Avi,
>
> here are three patches against kvm.git that fix several issues in our
> kvm port. Please review and consider all patches for 2.6.31.
>
>    

Applied all, and queued the stfle patch for 2.6.31.  The commits 
referenced in patch 1 and 3 doesn't exist in 2.6.31.  Please correct me 
if I misread things.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 0/3] fixes for kvm on s390
  2009-06-24  8:09 ` [patch 0/3] fixes for kvm on s390 Avi Kivity
@ 2009-06-24  8:18   ` Christian Bornträger
  2009-06-24  9:18     ` Avi Kivity
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Bornträger @ 2009-06-24  8:18 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM

Am Mittwoch 24 Juni 2009 10:09:18 schrieben Sie:
> On 06/23/2009 06:24 PM, Christian Borntraeger wrote:
> > Hello Avi,
> >
> > here are three patches against kvm.git that fix several issues in our
> > kvm port. Please review and consider all patches for 2.6.31.
>
> Applied all, and queued the stfle patch for 2.6.31.  The commits
> referenced in patch 1 and 3 doesn't exist in 2.6.31.  Please correct me
> if I misread things.

Yes, the stfle issue is present on linus git and should go to Linus.

Fixes 1 and 3 are only for your kvm.git-tree. They should go to Linus in as soon 
as you push the referenced commits to Linus.

Christian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 0/3] fixes for kvm on s390
  2009-06-24  8:18   ` Christian Bornträger
@ 2009-06-24  9:18     ` Avi Kivity
  2009-06-24  9:23       ` Christian Bornträger
  0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-06-24  9:18 UTC (permalink / raw)
  To: Christian Bornträger
  Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM

On 06/24/2009 11:18 AM, Christian Bornträger wrote:
> Yes, the stfle issue is present on linus git and should go to Linus.
> Fixes 1 and 3 are only for your kvm.git-tree. They should go to Linus in as soon
> as you push the referenced commits to Linus.
>
>    

That'll be 2.6.32.  I generally fold commits that fix other commits in 
the same pull.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch 0/3] fixes for kvm on s390
  2009-06-24  9:18     ` Avi Kivity
@ 2009-06-24  9:23       ` Christian Bornträger
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Bornträger @ 2009-06-24  9:23 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Carsten Otte, Heiko Carstens, Martin Schwidefsky, KVM

Am Mittwoch 24 Juni 2009 11:18:32 schrieb Avi Kivity:
> On 06/24/2009 11:18 AM, Christian Bornträger wrote:
> > Yes, the stfle issue is present on linus git and should go to Linus.
> > Fixes 1 and 3 are only for your kvm.git-tree. They should go to Linus in
> > as soon as you push the referenced commits to Linus.
>
> That'll be 2.6.32.  I generally fold commits that fix other commits in
> the same pull.

That would be fine with me.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-06-24  9:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-23 15:24 [patch 0/3] fixes for kvm on s390 Christian Borntraeger
2009-06-23 15:24 ` [patch 1/3] kvm-s390: Fix memslot initialization for userspace_addr != 0 Christian Borntraeger
2009-06-23 15:24 ` [patch 2/3] kvm-s390: Allow stfle instruction in the guest Christian Borntraeger
2009-06-23 15:24 ` [patch 3/3] kvm-s390: Remove some unused variables Christian Borntraeger
2009-06-24  8:09 ` [patch 0/3] fixes for kvm on s390 Avi Kivity
2009-06-24  8:18   ` Christian Bornträger
2009-06-24  9:18     ` Avi Kivity
2009-06-24  9:23       ` Christian Bornträger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox