All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] KVM: s390: patches for kvm-next
@ 2014-01-17 13:44 Christian Borntraeger
  2014-01-17 13:44 ` [PULL 1/3] KVM: s390: enable Transactional Execution Christian Borntraeger
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christian Borntraeger @ 2014-01-17 13:44 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini; +Cc: kvm, Christian Borntraeger, Cornelia Huck

Paolo,

the following changes since commit 26a865f4aa8e66a6d94958de7656f7f1b03c6c56:

  KVM: VMX: fix use after free of vmx->loaded_vmcs (2014-01-08 19:14:08 -0200)

are available in the git repository at:

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

for you to fetch changes up to 19e4735bd7f02bd38db43a8521377b35f236b3b6:

  KVM: s390: virtio-ccw: Handle command rejects. (2014-01-17 13:12:22 +0100)

----------------------------------------------------------------
This deals with 2 guest features that need enablement in the kvm host:
- transactional execution
- lpp sampling support

In addition there is also a fix to the virtio-ccw guest driver. This will
enable future features

----------------------------------------------------------------
Cornelia Huck (1):
      KVM: s390: virtio-ccw: Handle command rejects.

Michael Mueller (1):
      KVM: s390: enable Transactional Execution

Thomas Huth (1):
      KVM: s390: Enable the LPP facility for guests

 arch/s390/include/asm/kvm_host.h |   15 ++++++++++++++-
 arch/s390/kvm/intercept.c        |   11 +++++++++++
 arch/s390/kvm/kvm-s390.c         |   17 +++++++++++------
 arch/s390/kvm/kvm-s390.h         |    6 ++++++
 drivers/s390/kvm/virtio_ccw.c    |   11 +++++++++--
 5 files changed, 51 insertions(+), 9 deletions(-)


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

* [PULL 1/3] KVM: s390: enable Transactional Execution
  2014-01-17 13:44 [PULL 0/3] KVM: s390: patches for kvm-next Christian Borntraeger
@ 2014-01-17 13:44 ` Christian Borntraeger
  2014-01-17 13:44 ` [PULL 2/3] KVM: s390: Enable the LPP facility for guests Christian Borntraeger
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Borntraeger @ 2014-01-17 13:44 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: kvm, Christian Borntraeger, Cornelia Huck, Michael Mueller

From: Michael Mueller <mimu@linux.vnet.ibm.com>

This patch enables transactional execution for KVM guests
on s390 systems zec12 or later.

We rework the allocation of the page containing the sie_block
to also back the Interception Transaction Diagnostic Block.
If available the TE facilities will be enabled.

Setting bit 73 and 50 in vfacilities bitmask reveals the HW
facilities Transactional Memory and Constraint Transactional
Memory respectively to the KVM guest.

Furthermore, the patch restores the Program-Interruption TDB
from the Interception TDB in case a program interception has
occurred and the ITDB has a valid format.

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h |   15 ++++++++++++++-
 arch/s390/kvm/intercept.c        |   11 +++++++++++
 arch/s390/kvm/kvm-s390.c         |   17 +++++++++++------
 arch/s390/kvm/kvm-s390.h         |    6 ++++++
 4 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index d5bc375..eef3dd3 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -106,9 +106,22 @@ struct kvm_s390_sie_block {
 	__u64	gbea;			/* 0x0180 */
 	__u8	reserved188[24];	/* 0x0188 */
 	__u32	fac;			/* 0x01a0 */
-	__u8	reserved1a4[92];	/* 0x01a4 */
+	__u8	reserved1a4[68];	/* 0x01a4 */
+	__u64	itdba;			/* 0x01e8 */
+	__u8	reserved1f0[16];	/* 0x01f0 */
 } __attribute__((packed));
 
+struct kvm_s390_itdb {
+	__u8	data[256];
+} __packed;
+
+struct sie_page {
+	struct kvm_s390_sie_block sie_block;
+	__u8 reserved200[1024];		/* 0x0200 */
+	struct kvm_s390_itdb itdb;	/* 0x0600 */
+	__u8 reserved700[2304];		/* 0x0700 */
+} __packed;
+
 struct kvm_vcpu_stat {
 	u32 exit_userspace;
 	u32 exit_null;
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 5ddbbde..eeb1ac7 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -112,6 +112,17 @@ static int handle_instruction(struct kvm_vcpu *vcpu)
 static int handle_prog(struct kvm_vcpu *vcpu)
 {
 	vcpu->stat.exit_program_interruption++;
+
+	/* Restore ITDB to Program-Interruption TDB in guest memory */
+	if (IS_TE_ENABLED(vcpu) &&
+	    !(current->thread.per_flags & PER_FLAG_NO_TE) &&
+	    IS_ITDB_VALID(vcpu)) {
+		copy_to_guest(vcpu, TDB_ADDR, vcpu->arch.sie_block->itdba,
+			      sizeof(struct kvm_s390_itdb));
+		memset((void *) vcpu->arch.sie_block->itdba, 0,
+		       sizeof(struct kvm_s390_itdb));
+	}
+
 	trace_kvm_s390_intercept_prog(vcpu, vcpu->arch.sie_block->iprcc);
 	return kvm_s390_inject_program_int(vcpu, vcpu->arch.sie_block->iprcc);
 }
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 1bb1dda..0084c2c2 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -395,6 +395,9 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 						    CPUSTAT_STOPPED |
 						    CPUSTAT_GED);
 	vcpu->arch.sie_block->ecb   = 6;
+	if (test_vfacility(50) && test_vfacility(73))
+		vcpu->arch.sie_block->ecb |= 0x10;
+
 	vcpu->arch.sie_block->ecb2  = 8;
 	vcpu->arch.sie_block->eca   = 0xC1002001U;
 	vcpu->arch.sie_block->fac   = (int) (long) vfacilities;
@@ -411,6 +414,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
 				      unsigned int id)
 {
 	struct kvm_vcpu *vcpu;
+	struct sie_page *sie_page;
 	int rc = -EINVAL;
 
 	if (id >= KVM_MAX_VCPUS)
@@ -422,12 +426,13 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
 	if (!vcpu)
 		goto out;
 
-	vcpu->arch.sie_block = (struct kvm_s390_sie_block *)
-					get_zeroed_page(GFP_KERNEL);
-
-	if (!vcpu->arch.sie_block)
+	sie_page = (struct sie_page *) get_zeroed_page(GFP_KERNEL);
+	if (!sie_page)
 		goto out_free_cpu;
 
+	vcpu->arch.sie_block = &sie_page->sie_block;
+	vcpu->arch.sie_block->itdba = (unsigned long) &sie_page->itdb;
+
 	vcpu->arch.sie_block->icpua = id;
 	if (!kvm_is_ucontrol(kvm)) {
 		if (!kvm->arch.sca) {
@@ -1178,8 +1183,8 @@ static int __init kvm_s390_init(void)
 		return -ENOMEM;
 	}
 	memcpy(vfacilities, S390_lowcore.stfle_fac_list, 16);
-	vfacilities[0] &= 0xff82fff3f47c0000UL;
-	vfacilities[1] &= 0x001c000000000000UL;
+	vfacilities[0] &= 0xff82fff3f47c2000UL;
+	vfacilities[1] &= 0x005c000000000000UL;
 	return 0;
 }
 
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 095cf51..f9559b0 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -26,6 +26,12 @@ extern unsigned long *vfacilities;
 
 int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu);
 
+/* Transactional Memory Execution related macros */
+#define IS_TE_ENABLED(vcpu)	((vcpu->arch.sie_block->ecb & 0x10))
+#define TDB_ADDR		0x1800UL
+#define TDB_FORMAT1		1
+#define IS_ITDB_VALID(vcpu)	((*(char *)vcpu->arch.sie_block->itdba == TDB_FORMAT1))
+
 #define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
 do { \
 	debug_sprintf_event(d_kvm->arch.dbf, d_loglevel, d_string "\n", \
-- 
1.7.9.5


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

* [PULL 2/3] KVM: s390: Enable the LPP facility for guests
  2014-01-17 13:44 [PULL 0/3] KVM: s390: patches for kvm-next Christian Borntraeger
  2014-01-17 13:44 ` [PULL 1/3] KVM: s390: enable Transactional Execution Christian Borntraeger
@ 2014-01-17 13:44 ` Christian Borntraeger
  2014-01-17 13:44 ` [PULL 3/3] KVM: s390: virtio-ccw: Handle command rejects Christian Borntraeger
  2014-01-23 10:40 ` [PULL 0/3] KVM: s390: patches for kvm-next Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Borntraeger @ 2014-01-17 13:44 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: kvm, Christian Borntraeger, Cornelia Huck, Thomas Huth

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

The Load-Program-Parameter Facility is available for guests without
any further ado, so we should indicate its availability by setting
facility bit 40 if it is supported by the host.

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

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 0084c2c2..597114b 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1183,7 +1183,7 @@ static int __init kvm_s390_init(void)
 		return -ENOMEM;
 	}
 	memcpy(vfacilities, S390_lowcore.stfle_fac_list, 16);
-	vfacilities[0] &= 0xff82fff3f47c2000UL;
+	vfacilities[0] &= 0xff82fff3f4fc2000UL;
 	vfacilities[1] &= 0x005c000000000000UL;
 	return 0;
 }
-- 
1.7.9.5


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

* [PULL 3/3] KVM: s390: virtio-ccw: Handle command rejects.
  2014-01-17 13:44 [PULL 0/3] KVM: s390: patches for kvm-next Christian Borntraeger
  2014-01-17 13:44 ` [PULL 1/3] KVM: s390: enable Transactional Execution Christian Borntraeger
  2014-01-17 13:44 ` [PULL 2/3] KVM: s390: Enable the LPP facility for guests Christian Borntraeger
@ 2014-01-17 13:44 ` Christian Borntraeger
  2014-01-23 10:40 ` [PULL 0/3] KVM: s390: patches for kvm-next Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Christian Borntraeger @ 2014-01-17 13:44 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini; +Cc: kvm, Christian Borntraeger, Cornelia Huck

From: Cornelia Huck <cornelia.huck@de.ibm.com>

A command reject for a ccw may happen if we run on a host not supporting
a certain feature. We want to be able to handle this as special case of
command failure, so let's split this off from the generic -EIO error code.

Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 drivers/s390/kvm/virtio_ccw.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/kvm/virtio_ccw.c b/drivers/s390/kvm/virtio_ccw.c
index d629717..0fc5848 100644
--- a/drivers/s390/kvm/virtio_ccw.c
+++ b/drivers/s390/kvm/virtio_ccw.c
@@ -642,8 +642,15 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev,
 	     (SCSW_STCTL_ALERT_STATUS | SCSW_STCTL_STATUS_PEND))) {
 		/* OK */
 	}
-	if (irb_is_error(irb))
-		vcdev->err = -EIO; /* XXX - use real error */
+	if (irb_is_error(irb)) {
+		/* Command reject? */
+		if ((scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK) &&
+		    (irb->ecw[0] & SNS0_CMD_REJECT))
+			vcdev->err = -EOPNOTSUPP;
+		else
+			/* Map everything else to -EIO. */
+			vcdev->err = -EIO;
+	}
 	if (vcdev->curr_io & activity) {
 		switch (activity) {
 		case VIRTIO_CCW_DOING_READ_FEAT:
-- 
1.7.9.5


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

* Re: [PULL 0/3] KVM: s390: patches for kvm-next
  2014-01-17 13:44 [PULL 0/3] KVM: s390: patches for kvm-next Christian Borntraeger
                   ` (2 preceding siblings ...)
  2014-01-17 13:44 ` [PULL 3/3] KVM: s390: virtio-ccw: Handle command rejects Christian Borntraeger
@ 2014-01-23 10:40 ` Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2014-01-23 10:40 UTC (permalink / raw)
  To: Christian Borntraeger, Gleb Natapov; +Cc: kvm, Cornelia Huck

Il 17/01/2014 14:44, Christian Borntraeger ha scritto:
> Paolo,
>
> the following changes since commit 26a865f4aa8e66a6d94958de7656f7f1b03c6c56:
>
>   KVM: VMX: fix use after free of vmx->loaded_vmcs (2014-01-08 19:14:08 -0200)
>
> are available in the git repository at:
>
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-20140117
>
> for you to fetch changes up to 19e4735bd7f02bd38db43a8521377b35f236b3b6:
>
>   KVM: s390: virtio-ccw: Handle command rejects. (2014-01-17 13:12:22 +0100)
>
> ----------------------------------------------------------------
> This deals with 2 guest features that need enablement in the kvm host:
> - transactional execution
> - lpp sampling support
>
> In addition there is also a fix to the virtio-ccw guest driver. This will
> enable future features
>
> ----------------------------------------------------------------
> Cornelia Huck (1):
>       KVM: s390: virtio-ccw: Handle command rejects.
>
> Michael Mueller (1):
>       KVM: s390: enable Transactional Execution
>
> Thomas Huth (1):
>       KVM: s390: Enable the LPP facility for guests
>
>  arch/s390/include/asm/kvm_host.h |   15 ++++++++++++++-
>  arch/s390/kvm/intercept.c        |   11 +++++++++++
>  arch/s390/kvm/kvm-s390.c         |   17 +++++++++++------
>  arch/s390/kvm/kvm-s390.h         |    6 ++++++
>  drivers/s390/kvm/virtio_ccw.c    |   11 +++++++++--
>  5 files changed, 51 insertions(+), 9 deletions(-)
>

Pulled, thanks!

Paolo

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

end of thread, other threads:[~2014-01-23 10:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-17 13:44 [PULL 0/3] KVM: s390: patches for kvm-next Christian Borntraeger
2014-01-17 13:44 ` [PULL 1/3] KVM: s390: enable Transactional Execution Christian Borntraeger
2014-01-17 13:44 ` [PULL 2/3] KVM: s390: Enable the LPP facility for guests Christian Borntraeger
2014-01-17 13:44 ` [PULL 3/3] KVM: s390: virtio-ccw: Handle command rejects Christian Borntraeger
2014-01-23 10:40 ` [PULL 0/3] KVM: s390: patches for kvm-next Paolo Bonzini

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.