All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Avi Kivity <avi@redhat.com>, Marcelo Tossati <mtosatti@redhat.com>
Cc: Carsten Otte <cotte@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	KVM <kvm@vger.kernel.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>
Subject: [patch 3/4] kvm-s390: fix register setting
Date: Tue, 18 Oct 2011 12:27:14 +0200	[thread overview]
Message-ID: <20111018103127.177787431@de.ibm.com> (raw)
In-Reply-To: 20111018102711.259185287@de.ibm.com

[-- Attachment #1: 502-kvm-register-setting.diff --]
[-- Type: text/plain, Size: 1686 bytes --]

From: Carsten Otte <cotte@de.ibm.com>

KVM common code does vcpu_load prior to calling our arch ioctls and
vcpu_put after we're done here. Via the kvm_arch_vcpu_load/put
callbacks we do load the fpu and access register state into the
processor, which saves us moving the state on every SIE exit the
kernel handles. However this breaks register setting from userspace,
because of the following sequence:
1a. vcpu load stores userspace register content
1b. vcpu load loads guest register content
2.  kvm_arch_vcpu_ioctl_set_fpu/sregs updates saved guest register content
3a. vcpu put stores the guest registers and overwrites the new content
3b. vcpu put loads the userspace register set again

This patch loads the new guest register state into the cpu, so that the correct
(new) set of guest registers will be stored in step 3a.

Signed-off-by: Carsten Otte <cotte@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---

 arch/s390/kvm/kvm-s390.c |    2 ++
 1 file changed, 2 insertions(+)

Index: b/arch/s390/kvm/kvm-s390.c
===================================================================
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -394,6 +394,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct
 {
 	memcpy(&vcpu->arch.guest_acrs, &sregs->acrs, sizeof(sregs->acrs));
 	memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs));
+	restore_access_regs(vcpu->arch.guest_acrs);
 	return 0;
 }
 
@@ -409,6 +410,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct k
 {
 	memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs));
 	vcpu->arch.guest_fpregs.fpc = fpu->fpc;
+	restore_fp_regs(&vcpu->arch.guest_fpregs);
 	return 0;
 }
 


  parent reply	other threads:[~2011-10-18 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 10:27 [patch 0/4] Fixes for kvm-s390 Christian Borntraeger
2011-10-18 10:27 ` [patch 1/4] kvm-s390: check cpu_id prior to using it Christian Borntraeger
2011-10-18 10:27 ` [patch 2/4] kvm-s390: fix return value of kvm_arch_init_vm Christian Borntraeger
2011-10-18 10:27 ` Christian Borntraeger [this message]
2011-10-18 10:27 ` [patch 4/4] kvm-s390: implement sigp external call Christian Borntraeger
2011-10-19 16:21 ` [patch 0/4] Fixes for kvm-s390 Marcelo Tosatti

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=20111018103127.177787431@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=avi@redhat.com \
    --cc=cotte@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=schwidefsky@de.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.