linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PULL 0/9] KVM: s390: some patches for kvm-next
@ 2013-11-28 14:06 Cornelia Huck
  2013-11-28 14:06 ` [PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL Cornelia Huck
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Cornelia Huck

Gleb, Paolo,

here's a pull request for some fixes/cleanups that have accumulated
on our side. As this is my first pull request via kernel.org, feel
free to tell me whether I messed up :)


The following changes since commit 0a00a775d2a49d16efba721c786859844184599c:

  KVM: Change maintainer email address (2013-11-27 17:56:36 +0100)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-20131128

for you to fetch changes up to 36daca9bb36f0395755817d1b0c45ab6fbf0441b:

  KVM: s390: Removed kvm_s390_inject_sigp_stop() (2013-11-28 11:08:17 +0100)

----------------------------------------------------------------
Several fixes for kvm-next.

The diagnose decoding and the missing store status are more major (can
cause the host to execute different things than the guest wanted resp.
produce unusable dumps when something breaks). The other patches contain
more minor fixes and cleanups.

----------------------------------------------------------------
Heiko Carstens (1):
  KVM: s390: fix diagnose code extraction

Thomas Huth (8):
  KVM: s390: Removed SIE_INTERCEPT_UCONTROL
  KVM: s390: Removed VIRTIODESCSPACE
  KVM: s390: Fix access to CR6 in TPI handler
  KVM: s390: Do not set CC3 for EQBS and SQBS
  KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS
  KVM: s390: Fix clock comparator field for STORE STATUS
  KVM: s390: Add SIGP store-status-at-address order
  KVM: s390: Removed kvm_s390_inject_sigp_stop()

 arch/s390/kvm/diag.c     |    2 +-
 arch/s390/kvm/kvm-s390.c |   53 ++++++++++++++++++++-----------------------
 arch/s390/kvm/kvm-s390.h |   10 ++-------
 arch/s390/kvm/priv.c     |    4 +---
 arch/s390/kvm/sigp.c     |   56 ++++++++++++++++++++++++++++++++++++++++------
 arch/s390/kvm/trace.h    |    1 +
 6 files changed, 78 insertions(+), 48 deletions(-)

-- 
1.7.9.5

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

* [PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 2/9] KVM: s390: Removed VIRTIODESCSPACE Cornelia Huck
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The SIE_INTERCEPT_UCONTROL can be removed by moving the related code
from kvm_arch_vcpu_ioctl_run() to vcpu_post_run().

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c |   24 ++++++------------------
 arch/s390/kvm/kvm-s390.h |    2 --
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 569494e..7f47835 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -732,14 +732,12 @@ static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)
 
 	if (exit_reason >= 0) {
 		rc = 0;
-	} else {
-		if (kvm_is_ucontrol(vcpu->kvm)) {
-			rc = SIE_INTERCEPT_UCONTROL;
-		} else {
-			VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction");
-			trace_kvm_s390_sie_fault(vcpu);
-			rc = kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
-		}
+	} else if (kvm_is_ucontrol(vcpu->kvm)) {
+		vcpu->run->exit_reason = KVM_EXIT_S390_UCONTROL;
+		vcpu->run->s390_ucontrol.trans_exc_code =
+						current->thread.gmap_addr;
+		vcpu->run->s390_ucontrol.pgm_code = 0x10;
+		rc = -EREMOTE;
 	}
 
 	memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
@@ -833,16 +831,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 		rc = -EINTR;
 	}
 
-#ifdef CONFIG_KVM_S390_UCONTROL
-	if (rc == SIE_INTERCEPT_UCONTROL) {
-		kvm_run->exit_reason = KVM_EXIT_S390_UCONTROL;
-		kvm_run->s390_ucontrol.trans_exc_code =
-			current->thread.gmap_addr;
-		kvm_run->s390_ucontrol.pgm_code = 0x10;
-		rc = 0;
-	}
-#endif
-
 	if (rc == -EOPNOTSUPP) {
 		/* intercept cannot be handled in-kernel, prepare kvm-run */
 		kvm_run->exit_reason         = KVM_EXIT_S390_SIEIC;
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index b44912a..aad541f 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -27,8 +27,6 @@ typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
 /* declare vfacilities extern */
 extern unsigned long *vfacilities;
 
-/* negativ values are error codes, positive values for internal conditions */
-#define SIE_INTERCEPT_UCONTROL		(1<<0)
 int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu);
 
 #define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
-- 
1.7.9.5

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

* [PULL 2/9] KVM: s390: Removed VIRTIODESCSPACE
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
  2013-11-28 14:06 ` [PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 3/9] KVM: s390: Fix access to CR6 in TPI handler Cornelia Huck
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

VIRTIODESCSPACE is completely unused nowadays and thus can be removed
without any problems.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.h |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index aad541f..fcd25b4 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -19,9 +19,6 @@
 #include <linux/kvm.h>
 #include <linux/kvm_host.h>
 
-/* The current code can have up to 256 pages for virtio */
-#define VIRTIODESCSPACE (256ul * 4096ul)
-
 typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
 
 /* declare vfacilities extern */
-- 
1.7.9.5

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

* [PULL 3/9] KVM: s390: Fix access to CR6 in TPI handler
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
  2013-11-28 14:06 ` [PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL Cornelia Huck
  2013-11-28 14:06 ` [PULL 2/9] KVM: s390: Removed VIRTIODESCSPACE Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 4/9] KVM: s390: Do not set CC3 for EQBS and SQBS Cornelia Huck
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The TPI handler currently uses vcpu->run->s.regs.crs[6] to get the current
value of CR6. I think this is wrong, because vcpu->run->s.regs.crs is
only updated when kvm_arch_vcpu_ioctl_run() drops back to userspace.
So let's change the TPI handler to use vcpu->arch.sie_block->gcr[6] instead.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/priv.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index 2440602..b18fe52 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -197,7 +197,7 @@ static int handle_tpi(struct kvm_vcpu *vcpu)
 	if (addr & 3)
 		return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
 	cc = 0;
-	inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->run->s.regs.crs[6], 0);
+	inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0);
 	if (!inti)
 		goto no_interrupt;
 	cc = 1;
-- 
1.7.9.5

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

* [PULL 4/9] KVM: s390: Do not set CC3 for EQBS and SQBS
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (2 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 3/9] KVM: s390: Fix access to CR6 in TPI handler Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 5/9] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS Cornelia Huck
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The EQBS and SQBS instructions do not set CC3 for invalid channels, but
should throw an operation exception instead when not available. Thus they
should not be handled by the handle_io_inst() wrapper but drop to userspace
instead (which will then inject the operation exception).

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/priv.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index b18fe52..05537ab 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -638,7 +638,6 @@ static int handle_pfmf(struct kvm_vcpu *vcpu)
 
 static const intercept_handler_t b9_handlers[256] = {
 	[0x8d] = handle_epsw,
-	[0x9c] = handle_io_inst,
 	[0xaf] = handle_pfmf,
 };
 
@@ -731,7 +730,6 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
 
 static const intercept_handler_t eb_handlers[256] = {
 	[0x2f] = handle_lctlg,
-	[0x8a] = handle_io_inst,
 };
 
 int kvm_s390_handle_eb(struct kvm_vcpu *vcpu)
-- 
1.7.9.5

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

* [PULL 5/9] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (3 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 4/9] KVM: s390: Do not set CC3 for EQBS and SQBS Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 6/9] KVM: s390: Fix clock comparator field for STORE STATUS Cornelia Huck
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth, stable,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The SIGP order STOP_AND_STORE_STATUS is defined to stop a CPU and store
its status. However, we only stored the status if the CPU was still
running, so make sure that the status is now also stored if the CPU was
already stopped. This fixes the problem that the CPU information was
not stored correctly in kdump files, rendering them unreadable.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c |   25 +++++++++++++++----------
 arch/s390/kvm/kvm-s390.h |    4 ++--
 arch/s390/kvm/sigp.c     |   15 ++++++++++++++-
 3 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 7f47835..55eb8de 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -873,7 +873,7 @@ static int __guestcopy(struct kvm_vcpu *vcpu, u64 guestdest, void *from,
  * KVM_S390_STORE_STATUS_NOADDR: -> 0x1200 on 64 bit
  * KVM_S390_STORE_STATUS_PREFIXED: -> prefix
  */
-int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
+int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr)
 {
 	unsigned char archmode = 1;
 	int prefix;
@@ -891,15 +891,6 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
 	} else
 		prefix = 0;
 
-	/*
-	 * The guest FPRS and ACRS are in the host FPRS/ACRS due to the lazy
-	 * copying in vcpu load/put. Lets update our copies before we save
-	 * it into the save area
-	 */
-	save_fp_ctl(&vcpu->arch.guest_fpregs.fpc);
-	save_fp_regs(vcpu->arch.guest_fpregs.fprs);
-	save_access_regs(vcpu->run->s.regs.acrs);
-
 	if (__guestcopy(vcpu, addr + offsetof(struct save_area, fp_regs),
 			vcpu->arch.guest_fpregs.fprs, 128, prefix))
 		return -EFAULT;
@@ -944,6 +935,20 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
 	return 0;
 }
 
+int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
+{
+	/*
+	 * The guest FPRS and ACRS are in the host FPRS/ACRS due to the lazy
+	 * copying in vcpu load/put. Lets update our copies before we save
+	 * it into the save area
+	 */
+	save_fp_ctl(&vcpu->arch.guest_fpregs.fpc);
+	save_fp_regs(vcpu->arch.guest_fpregs.fprs);
+	save_access_regs(vcpu->run->s.regs.acrs);
+
+	return kvm_s390_store_status_unloaded(vcpu, addr);
+}
+
 static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
 				     struct kvm_enable_cap *cap)
 {
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index fcd25b4..36f6b18 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -145,8 +145,8 @@ int kvm_s390_handle_eb(struct kvm_vcpu *vcpu);
 int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu);
 
 /* implemented in kvm-s390.c */
-int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu,
-				 unsigned long addr);
+int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr);
+int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr);
 void s390_vcpu_block(struct kvm_vcpu *vcpu);
 void s390_vcpu_unblock(struct kvm_vcpu *vcpu);
 void exit_sie(struct kvm_vcpu *vcpu);
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index bec398c..6805601 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -130,6 +130,7 @@ unlock:
 static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
 {
 	struct kvm_s390_interrupt_info *inti;
+	int rc = SIGP_CC_ORDER_CODE_ACCEPTED;
 
 	inti = kzalloc(sizeof(*inti), GFP_ATOMIC);
 	if (!inti)
@@ -139,6 +140,8 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
 	spin_lock_bh(&li->lock);
 	if ((atomic_read(li->cpuflags) & CPUSTAT_STOPPED)) {
 		kfree(inti);
+		if ((action & ACTION_STORE_ON_STOP) != 0)
+			rc = -ESHUTDOWN;
 		goto out;
 	}
 	list_add_tail(&inti->list, &li->list);
@@ -150,7 +153,7 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
 out:
 	spin_unlock_bh(&li->lock);
 
-	return SIGP_CC_ORDER_CODE_ACCEPTED;
+	return rc;
 }
 
 static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action)
@@ -174,6 +177,16 @@ static int __sigp_stop(struct kvm_vcpu *vcpu, u16 cpu_addr, int action)
 unlock:
 	spin_unlock(&fi->lock);
 	VCPU_EVENT(vcpu, 4, "sent sigp stop to cpu %x", cpu_addr);
+
+	if ((action & ACTION_STORE_ON_STOP) != 0 && rc == -ESHUTDOWN) {
+		/* If the CPU has already been stopped, we still have
+		 * to save the status when doing stop-and-store. This
+		 * has to be done after unlocking all spinlocks. */
+		struct kvm_vcpu *dst_vcpu = kvm_get_vcpu(vcpu->kvm, cpu_addr);
+		rc = kvm_s390_store_status_unloaded(dst_vcpu,
+						KVM_S390_STORE_STATUS_NOADDR);
+	}
+
 	return rc;
 }
 
-- 
1.7.9.5

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

* [PULL 6/9] KVM: s390: Fix clock comparator field for STORE STATUS
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (4 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 5/9] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 7/9] KVM: s390: fix diagnose code extraction Cornelia Huck
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

Only the most 7 significant bytes of the clock comparator must be
saved to the status area, and the byte at offset 304 has to be zero.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 55eb8de..1bb1dda 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -877,6 +877,7 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr)
 {
 	unsigned char archmode = 1;
 	int prefix;
+	u64 clkcomp;
 
 	if (addr == KVM_S390_STORE_STATUS_NOADDR) {
 		if (copy_to_guest_absolute(vcpu, 163ul, &archmode, 1))
@@ -920,8 +921,9 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr)
 			&vcpu->arch.sie_block->cputm, 8, prefix))
 		return -EFAULT;
 
+	clkcomp = vcpu->arch.sie_block->ckc >> 8;
 	if (__guestcopy(vcpu, addr + offsetof(struct save_area, clk_cmp),
-			&vcpu->arch.sie_block->ckc, 8, prefix))
+			&clkcomp, 8, prefix))
 		return -EFAULT;
 
 	if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs),
-- 
1.7.9.5

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

* [PULL 7/9] KVM: s390: fix diagnose code extraction
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (5 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 6/9] KVM: s390: Fix clock comparator field for STORE STATUS Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 8/9] KVM: s390: Add SIGP store-status-at-address order Cornelia Huck
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Heiko Carstens, stable,
	Cornelia Huck

From: Heiko Carstens <heiko.carstens@de.ibm.com>

The diagnose code to be used is the contents of the base register (if not
zero), plus the displacement. The current code ignores the base register
contents. So let's fix that...

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/diag.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 78d967f..5ff29be 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -137,7 +137,7 @@ static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu)
 
 int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
 {
-	int code = (vcpu->arch.sie_block->ipb & 0xfff0000) >> 16;
+	int code = kvm_s390_get_base_disp_rs(vcpu) & 0xffff;
 
 	if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE)
 		return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP);
-- 
1.7.9.5

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

* [PULL 8/9] KVM: s390: Add SIGP store-status-at-address order
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (6 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 7/9] KVM: s390: fix diagnose code extraction Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:06 ` [PULL 9/9] KVM: s390: Removed kvm_s390_inject_sigp_stop() Cornelia Huck
  2013-11-28 14:31 ` [PULL 0/9] KVM: s390: some patches for kvm-next Paolo Bonzini
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The STORE STATUS AT ADDRESS order of SIGP was still missing.
Now it is supported, using the common kvm_s390_store_status()
function.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/sigp.c  |   35 +++++++++++++++++++++++++++++++++++
 arch/s390/kvm/trace.h |    1 +
 2 files changed, 36 insertions(+)

diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 6805601..c137ed3 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -275,6 +275,37 @@ out_fi:
 	return rc;
 }
 
+static int __sigp_store_status_at_addr(struct kvm_vcpu *vcpu, u16 cpu_id,
+					u32 addr, u64 *reg)
+{
+	struct kvm_vcpu *dst_vcpu = NULL;
+	int flags;
+	int rc;
+
+	if (cpu_id < KVM_MAX_VCPUS)
+		dst_vcpu = kvm_get_vcpu(vcpu->kvm, cpu_id);
+	if (!dst_vcpu)
+		return SIGP_CC_NOT_OPERATIONAL;
+
+	spin_lock_bh(&dst_vcpu->arch.local_int.lock);
+	flags = atomic_read(dst_vcpu->arch.local_int.cpuflags);
+	spin_unlock_bh(&dst_vcpu->arch.local_int.lock);
+	if (!(flags & CPUSTAT_STOPPED)) {
+		*reg &= 0xffffffff00000000UL;
+		*reg |= SIGP_STATUS_INCORRECT_STATE;
+		return SIGP_CC_STATUS_STORED;
+	}
+
+	addr &= 0x7ffffe00;
+	rc = kvm_s390_store_status_unloaded(dst_vcpu, addr);
+	if (rc == -EFAULT) {
+		*reg &= 0xffffffff00000000UL;
+		*reg |= SIGP_STATUS_INVALID_PARAMETER;
+		rc = SIGP_CC_STATUS_STORED;
+	}
+	return rc;
+}
+
 static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
 				u64 *reg)
 {
@@ -379,6 +410,10 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
 		rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
 						 ACTION_STOP_ON_STOP);
 		break;
+	case SIGP_STORE_STATUS_AT_ADDRESS:
+		rc = __sigp_store_status_at_addr(vcpu, cpu_addr, parameter,
+						 &vcpu->run->s.regs.gprs[r1]);
+		break;
 	case SIGP_SET_ARCHITECTURE:
 		vcpu->stat.instruction_sigp_arch++;
 		rc = __sigp_set_arch(vcpu, parameter);
diff --git a/arch/s390/kvm/trace.h b/arch/s390/kvm/trace.h
index 0c991c6..3db76b2 100644
--- a/arch/s390/kvm/trace.h
+++ b/arch/s390/kvm/trace.h
@@ -175,6 +175,7 @@ TRACE_EVENT(kvm_s390_intercept_validity,
 	{SIGP_STOP_AND_STORE_STATUS, "stop and store status"},	\
 	{SIGP_SET_ARCHITECTURE, "set architecture"},		\
 	{SIGP_SET_PREFIX, "set prefix"},			\
+	{SIGP_STORE_STATUS_AT_ADDRESS, "store status at addr"},	\
 	{SIGP_SENSE_RUNNING, "sense running"},			\
 	{SIGP_RESTART, "restart"}
 
-- 
1.7.9.5

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

* [PULL 9/9] KVM: s390: Removed kvm_s390_inject_sigp_stop()
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (7 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 8/9] KVM: s390: Add SIGP store-status-at-address order Cornelia Huck
@ 2013-11-28 14:06 ` Cornelia Huck
  2013-11-28 14:31 ` [PULL 0/9] KVM: s390: some patches for kvm-next Paolo Bonzini
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2013-11-28 14:06 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, kvm, linux-s390, Thomas Huth,
	Cornelia Huck

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The function kvm_s390_inject_sigp_stop() as been unused since the
removal of the old mmu reload code and thus can be removed safely.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 arch/s390/kvm/kvm-s390.h |    1 -
 arch/s390/kvm/sigp.c     |    6 ------
 2 files changed, 7 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 36f6b18..095cf51 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -128,7 +128,6 @@ int __must_check kvm_s390_inject_vm(struct kvm *kvm,
 int __must_check kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
 				      struct kvm_s390_interrupt *s390int);
 int __must_check kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
-int __must_check kvm_s390_inject_sigp_stop(struct kvm_vcpu *vcpu, int action);
 struct kvm_s390_interrupt_info *kvm_s390_get_io_int(struct kvm *kvm,
 						    u64 cr6, u64 schid);
 
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index c137ed3..c370058 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -190,12 +190,6 @@ unlock:
 	return rc;
 }
 
-int kvm_s390_inject_sigp_stop(struct kvm_vcpu *vcpu, int action)
-{
-	struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
-	return __inject_sigp_stop(li, action);
-}
-
 static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
 {
 	int rc;
-- 
1.7.9.5

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

* Re: [PULL 0/9] KVM: s390: some patches for kvm-next
  2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
                   ` (8 preceding siblings ...)
  2013-11-28 14:06 ` [PULL 9/9] KVM: s390: Removed kvm_s390_inject_sigp_stop() Cornelia Huck
@ 2013-11-28 14:31 ` Paolo Bonzini
  9 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2013-11-28 14:31 UTC (permalink / raw)
  To: Cornelia Huck; +Cc: Gleb Natapov, Christian Borntraeger, kvm, linux-s390

Il 28/11/2013 15:06, Cornelia Huck ha scritto:
> Gleb, Paolo,
> 
> here's a pull request for some fixes/cleanups that have accumulated
> on our side. As this is my first pull request via kernel.org, feel
> free to tell me whether I messed up :)
> 
> 
> The following changes since commit 0a00a775d2a49d16efba721c786859844184599c:
> 
>   KVM: Change maintainer email address (2013-11-27 17:56:36 +0100)
> 
> are available in the git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-20131128
> 
> for you to fetch changes up to 36daca9bb36f0395755817d1b0c45ab6fbf0441b:
> 
>   KVM: s390: Removed kvm_s390_inject_sigp_stop() (2013-11-28 11:08:17 +0100)
> 
> ----------------------------------------------------------------
> Several fixes for kvm-next.
> 
> The diagnose decoding and the missing store status are more major (can
> cause the host to execute different things than the guest wanted resp.
> produce unusable dumps when something breaks). The other patches contain
> more minor fixes and cleanups.
> 
> ----------------------------------------------------------------
> Heiko Carstens (1):
>   KVM: s390: fix diagnose code extraction
> 
> Thomas Huth (8):
>   KVM: s390: Removed SIE_INTERCEPT_UCONTROL
>   KVM: s390: Removed VIRTIODESCSPACE
>   KVM: s390: Fix access to CR6 in TPI handler
>   KVM: s390: Do not set CC3 for EQBS and SQBS
>   KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS
>   KVM: s390: Fix clock comparator field for STORE STATUS
>   KVM: s390: Add SIGP store-status-at-address order
>   KVM: s390: Removed kvm_s390_inject_sigp_stop()
> 
>  arch/s390/kvm/diag.c     |    2 +-
>  arch/s390/kvm/kvm-s390.c |   53 ++++++++++++++++++++-----------------------
>  arch/s390/kvm/kvm-s390.h |   10 ++-------
>  arch/s390/kvm/priv.c     |    4 +---
>  arch/s390/kvm/sigp.c     |   56 ++++++++++++++++++++++++++++++++++++++++------
>  arch/s390/kvm/trace.h    |    1 +
>  6 files changed, 78 insertions(+), 48 deletions(-)
> 

Pulled, thanks.

Paolo

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

end of thread, other threads:[~2013-11-28 14:31 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 14:06 [PULL 0/9] KVM: s390: some patches for kvm-next Cornelia Huck
2013-11-28 14:06 ` [PULL 1/9] KVM: s390: Removed SIE_INTERCEPT_UCONTROL Cornelia Huck
2013-11-28 14:06 ` [PULL 2/9] KVM: s390: Removed VIRTIODESCSPACE Cornelia Huck
2013-11-28 14:06 ` [PULL 3/9] KVM: s390: Fix access to CR6 in TPI handler Cornelia Huck
2013-11-28 14:06 ` [PULL 4/9] KVM: s390: Do not set CC3 for EQBS and SQBS Cornelia Huck
2013-11-28 14:06 ` [PULL 5/9] KVM: s390: Always store status during SIGP STOP_AND_STORE_STATUS Cornelia Huck
2013-11-28 14:06 ` [PULL 6/9] KVM: s390: Fix clock comparator field for STORE STATUS Cornelia Huck
2013-11-28 14:06 ` [PULL 7/9] KVM: s390: fix diagnose code extraction Cornelia Huck
2013-11-28 14:06 ` [PULL 8/9] KVM: s390: Add SIGP store-status-at-address order Cornelia Huck
2013-11-28 14:06 ` [PULL 9/9] KVM: s390: Removed kvm_s390_inject_sigp_stop() Cornelia Huck
2013-11-28 14:31 ` [PULL 0/9] KVM: s390: some patches for kvm-next Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).