From: Heiko Carstens Subject: Re: [PATCH 3/3] kvm-s390: provide standard guest registers via kvm_run Date: Wed, 4 Jan 2012 09:16:46 +0100 Message-ID: <20120104081646.GA2522@osiris.boeblingen.de.ibm.com> References: <20111222115646.248800653@de.ibm.com> <1325605858-30492-1-git-send-email-borntraeger@de.ibm.com> <1325605858-30492-4-git-send-email-borntraeger@de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , Marcelo Tossati , Carsten Otte , Alexander Graf , Jens Freimann , Cornelia Huck , Martin Schwidefsky , KVM To: Christian Borntraeger Return-path: Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:50421 "EHLO e06smtp11.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754063Ab2ADIQu (ORCPT ); Wed, 4 Jan 2012 03:16:50 -0500 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Jan 2012 08:16:49 -0000 Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q048Glfo2732172 for ; Wed, 4 Jan 2012 08:16:47 GMT Received: from d06av11.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q048Gk0Z012571 for ; Wed, 4 Jan 2012 01:16:47 -0700 Content-Disposition: inline In-Reply-To: <1325605858-30492-4-git-send-email-borntraeger@de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jan 03, 2012 at 04:50:58PM +0100, Christian Borntraeger wrote: > struct kvm_sync_rw_regs { > + __u64 gprs[16]; /* general purpose registers */ > + s390_fp_regs fpregs; > + unsigned int acrs[16]; So, if I got this right, userspace is allowed to map this shared read/write with the kernel? If that's the case then... > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c > index 0badc9f..a7b7ae0 100644 > --- a/arch/s390/kvm/kvm-s390.c > +++ b/arch/s390/kvm/kvm-s390.c > @@ -269,9 +269,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) > { > save_fp_regs(&vcpu->arch.host_fpregs); > save_access_regs(vcpu->arch.host_acrs); > - vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK; > - restore_fp_regs(&vcpu->arch.guest_fpregs); > - restore_access_regs(vcpu->arch.guest_acrs); > + vcpu->run->sync_rw.fpregs.fpc &= FPC_VALID_MASK; > + restore_fp_regs(&vcpu->run->sync_rw.fpregs); ...this is broken, since userspace can update the floating point control register contents after the kernel has masked out the offending bits but before the register is actually loaded. Which in turn could cause a kernel crash, hm?