From patchwork Tue Oct 20 16:40:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carsten Otte X-Patchwork-Id: 36493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2605AB7B9C for ; Wed, 21 Oct 2009 15:26:12 +1100 (EST) Received: from localhost ([127.0.0.1]:40789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0Sm0-0006KD-8T for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 00:26:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0Hl7-0000da-Ci for qemu-devel@nongnu.org; Tue, 20 Oct 2009 12:40:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0Hl3-0000dG-PW for qemu-devel@nongnu.org; Tue, 20 Oct 2009 12:40:29 -0400 Received: from [199.232.76.173] (port=56803 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0Hl3-0000dD-MR for qemu-devel@nongnu.org; Tue, 20 Oct 2009 12:40:25 -0400 Received: from mtagate4.uk.ibm.com ([195.212.29.137]:50193) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N0Hl3-0006tc-2m for qemu-devel@nongnu.org; Tue, 20 Oct 2009 12:40:25 -0400 Received: from d06nrmr1407.portsmouth.uk.ibm.com (d06nrmr1407.portsmouth.uk.ibm.com [9.149.38.185]) by mtagate4.uk.ibm.com (8.14.3/8.13.8) with ESMTP id n9KGe5b7206082 for ; Tue, 20 Oct 2009 16:40:10 GMT Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by d06nrmr1407.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9KGdr7E1310960 for ; Tue, 20 Oct 2009 17:39:55 +0100 Received: from d06av01.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n9KGdq2V012293 for ; Tue, 20 Oct 2009 17:39:53 +0100 Received: from [9.152.222.138] (dyn-9-152-222-138.boeblingen.de.ibm.com [9.152.222.138]) by d06av01.portsmouth.uk.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n9KGdpf3012265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 20 Oct 2009 17:39:52 +0100 Message-ID: <4ADDE7E3.9090601@de.ibm.com> Date: Tue, 20 Oct 2009 18:40:03 +0200 From: Carsten Otte Organization: IBM Deutschland Research & Development GmbH User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 To: Alexander Graf , avi@redhat.com References: <1255963059-10298-1-git-send-email-agraf@suse.de> In-Reply-To: <1255963059-10298-1-git-send-email-agraf@suse.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.0.3x (2) X-Mailman-Approved-At: Wed, 21 Oct 2009 00:19:13 -0400 Cc: Carsten Otte , qemu-devel , hare@suse.de Subject: [Qemu-devel] Re: [PATCH 0/9] S390x KVM support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Alexander Graf wrote: > This is the resulting code. Please comment on things you like and also on the > ones you don't :-). I've reviewed and tested it, great work Alex :-) > Also to actually run this code you need a patch for an ugly bug in the kernel > module: http://alex.csgraf.de/psw.patch Well, it was not exactly a bug. Kuli does'nt need the psw to be updated in kvm_run at all times. Your hotfix updates the psw in a union, even if the exit reason indicates that s390_sieic is not valid. The patch at the end of this mail moves the PSW out of the union. I think it makes most sense if Avi picks this patch and you adopt your series to it. This way the user interface of the kvm module works for both kuli and qemu. This patch moves s390 processor status word into the base kvm_run struct and keeps it up-to date on all userspace exits. Signed-off-by: Carsten Otte --- arch/s390/kvm/kvm-s390.c | 14 ++++++++------ include/linux/kvm.h | 8 ++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) Index: kvm/include/linux/kvm.h =================================================================== --- kvm.orig/include/linux/kvm.h 2009-10-20 15:00:40.000000000 +0200 +++ kvm/include/linux/kvm.h 2009-10-20 16:51:48.000000000 +0200 @@ -7,6 +7,7 @@ * Note: you must update KVM_API_VERSION if you change this interface. */ +#include #include #include #include @@ -116,6 +117,11 @@ __u64 cr8; __u64 apic_base; +#ifdef CONFIG_S390 + /* the processor status word for s390 */ + __u64 psw_mask; /* psw upper half */ + __u64 psw_addr; /* psw lower half */ +#endif union { /* KVM_EXIT_UNKNOWN */ struct { @@ -167,8 +173,6 @@ /* KVM_EXIT_S390_SIEIC */ struct { __u8 icptcode; - __u64 mask; /* psw upper half */ - __u64 addr; /* psw lower half */ __u16 ipa; __u32 ipb; } s390_sieic; Index: kvm/arch/s390/kvm/kvm-s390.c =================================================================== --- kvm.orig/arch/s390/kvm/kvm-s390.c 2009-10-20 15:01:02.000000000 +0200 +++ kvm/arch/s390/kvm/kvm-s390.c 2009-10-20 18:13:45.000000000 +0200 @@ -421,7 +421,8 @@ if (atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_RUNNING) rc = -EBUSY; else - vcpu->arch.sie_block->gpsw = psw; + vcpu->run->psw_mask = psw.mask; + vcpu->run->psw_addr = psw.addr; vcpu_put(vcpu); return rc; } @@ -509,9 +510,6 @@ switch (kvm_run->exit_reason) { case KVM_EXIT_S390_SIEIC: - vcpu->arch.sie_block->gpsw.mask = kvm_run->s390_sieic.mask; - vcpu->arch.sie_block->gpsw.addr = kvm_run->s390_sieic.addr; - break; case KVM_EXIT_UNKNOWN: case KVM_EXIT_INTR: case KVM_EXIT_S390_RESET: @@ -520,6 +518,9 @@ BUG(); } + vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask; + vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr; + might_fault(); do { @@ -539,8 +540,6 @@ /* intercept cannot be handled in-kernel, prepare kvm-run */ kvm_run->exit_reason = KVM_EXIT_S390_SIEIC; kvm_run->s390_sieic.icptcode = vcpu->arch.sie_block->icptcode; - kvm_run->s390_sieic.mask = vcpu->arch.sie_block->gpsw.mask; - kvm_run->s390_sieic.addr = vcpu->arch.sie_block->gpsw.addr; kvm_run->s390_sieic.ipa = vcpu->arch.sie_block->ipa; kvm_run->s390_sieic.ipb = vcpu->arch.sie_block->ipb; rc = 0; @@ -552,6 +551,9 @@ rc = 0; } + kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask; + kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr; + if (vcpu->sigset_active) sigprocmask(SIG_SETMASK, &sigsaved, NULL);