fixes for kvm on s390
cover fixes for kvm on s390
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
PATCH 1/3 kvm-s390: Fix memslot initialization for userspace_addr != 0
From: Christian Borntraeger <[email protected]>
Since
commit 854b5338196b1175706e99d63be43a4f8d8ab607
Author: Christian Ehrhardt <[email protected]>
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?
--- virt/kvm/kvm_main.c | 4 ++++ 1 file changed, 4 insertions(+)
virt/kvm/kvm_main.c +4 -0
@@ -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)
PATCH 2/3 kvm-s390: Allow stfle instruction in the guest
In reply to Christian BorntraegerFrom: Christian Borntraeger <[email protected]>
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.
--- 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(-)
arch/s390/include/asm/kvm_host.h +3 -1
@@ -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 {
arch/s390/kvm/kvm-s390.c +22 -1
@@ -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_vcpuset_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_tstatic 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 (); }
arch/s390/kvm/priv.c +1 -1
@@ -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));
PATCH 3/3 kvm-s390: Remove some unused variables
In reply to Christian BorntraegerFrom: Christian Borntraeger <[email protected]>
This patch fixes the following warnings that were introduced by commit 2921292f45733bccdb53e426bcf65ceb13f53d94
Author: Gleb Natapov <[email protected]>
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'
--- arch/s390/kvm/kvm-s390.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kvm/kvm-s390.c +1 -1
@@ -684,7 +684,7 @@ int kvm_arch_set_memory_region(struct kvstruct 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
Quoted 6 lines · Christian Borntraeger
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.
Signature · 1 line
error compiling committee.c: too many arguments to function
Am Mittwoch 24 Juni 2009 10:09:18 schrieben Sie:
Quoted 9 lines · Christian Borntraeger
Quoted 4 lines
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
Quoted 5 lines · Christian Bornträger
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.
Signature · 1 line
error compiling committee.c: too many arguments to function
Am Mittwoch 24 Juni 2009 11:18:32 schrieb Avi Kivity:
Quoted 7 lines · Christian Bornträger
Quoted 3 lines
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.