All of lore.kernel.org
 help / color / mirror / Atom feed
* PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4
@ 2016-07-20 12:39 Christian Borntraeger
  2016-07-20 12:39 ` [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000 Christian Borntraeger
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christian Borntraeger @ 2016-07-20 12:39 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger, David Hildenbrand

Paolo, Radim,

hopefully the last update for s390 for 4.8.
Please note the CAP number conflicts with kvmarm, when merging the one
or the other first. You might also need to adopt the number in
Documentation/virtual/kvm/api.txt in case arm has something in here as well.


The following changes since commit af1bae5497b98cb99d6b0492e6981f060420a00c:

  KVM: x86: bump KVM_MAX_VCPU_ID to 1023 (2016-07-14 09:29:35 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-4.8-4

for you to fetch changes up to 9acc317b183fdd3ed3bca218271875c0e808daae:

  KVM: s390: let ptff intercepts result in cc=3 (2016-07-18 14:15:00 +0200)

----------------------------------------------------------------
KVM: s390: : Feature and fix for kvm/next (4.8) part 4

1. Provide an exit to userspace for the invalid opcode 0 (used for
   software breakpoints)
2. "Fix" (by returning condition code 3) some unhandled PTFF subcodes

----------------------------------------------------------------
David Hildenbrand (2):
      KVM: s390: allow user space to handle instr 0x0000
      KVM: s390: let ptff intercepts result in cc=3

 Documentation/virtual/kvm/api.txt | 13 +++++++++++++
 arch/s390/include/asm/kvm_host.h  |  2 ++
 arch/s390/kvm/intercept.c         |  3 +++
 arch/s390/kvm/kvm-s390.c          | 26 ++++++++++++++++++++++++--
 arch/s390/kvm/priv.c              |  8 ++++++++
 include/uapi/linux/kvm.h          |  1 +
 6 files changed, 51 insertions(+), 2 deletions(-)

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

* [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000
  2016-07-20 12:39 PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
@ 2016-07-20 12:39 ` Christian Borntraeger
  2016-07-20 14:35   ` Christian Borntraeger
  2016-07-20 12:40 ` [GIT PULL 2/2] KVM: s390: let ptff intercepts result in cc=3 Christian Borntraeger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Christian Borntraeger @ 2016-07-20 12:39 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger, David Hildenbrand

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

We will use illegal instruction 0x0000 for handling 2 byte sw breakpoints
from user space. As it can be enabled dynamically via a capability,
let's move setting of ICTL_OPEREXC to the post creation step, so we avoid
any races when enabling that capability just while adding new cpus.

Acked-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 Documentation/virtual/kvm/api.txt | 13 +++++++++++++
 arch/s390/include/asm/kvm_host.h  |  2 ++
 arch/s390/kvm/intercept.c         |  3 +++
 arch/s390/kvm/kvm-s390.c          | 26 ++++++++++++++++++++++++--
 include/uapi/linux/kvm.h          |  1 +
 5 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
index c4d2fb0..299306d 100644
--- a/Documentation/virtual/kvm/api.txt
+++ b/Documentation/virtual/kvm/api.txt
@@ -3857,6 +3857,19 @@ as a broadcast even in x2APIC mode in order to support physical x2APIC
 without interrupt remapping.  This is undesirable in logical mode,
 where 0xff represents CPUs 0-7 in cluster 0.
 
+7.8 KVM_CAP_S390_USER_INSTR0
+
+Architectures: s390
+Parameters: none
+
+With this capability enabled, all illegal instructions 0x0000 (2 bytes) will
+be intercepted and forwarded to user space. User space can use this
+mechanism e.g. to realize 2-byte software breakpoints. The kernel will
+not inject an operating exception for these instructions, user space has
+to take care of that.
+
+This capability can be enabled dynamically even if VCPUs were already
+created and are running.
 
 8. Other capabilities.
 ----------------------
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 946fc86..183b017 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -43,6 +43,7 @@
 /* s390-specific vcpu->requests bit members */
 #define KVM_REQ_ENABLE_IBS         8
 #define KVM_REQ_DISABLE_IBS        9
+#define KVM_REQ_ICPT_OPEREXC       10
 
 #define SIGP_CTRL_C		0x80
 #define SIGP_CTRL_SCN_MASK	0x3f
@@ -666,6 +667,7 @@ struct kvm_arch{
 	int user_cpu_state_ctrl;
 	int user_sigp;
 	int user_stsi;
+	int user_instr0;
 	struct s390_io_adapter *adapters[MAX_S390_IO_ADAPTERS];
 	wait_queue_head_t ipte_wq;
 	int ipte_lock_count;
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 850be47..7a2f155 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -359,6 +359,9 @@ static int handle_operexc(struct kvm_vcpu *vcpu)
 	    test_kvm_facility(vcpu->kvm, 74))
 		return handle_sthyi(vcpu);
 
+	if (vcpu->arch.sie_block->ipa == 0 && vcpu->kvm->arch.user_instr0)
+		return -EOPNOTSUPP;
+
 	return kvm_s390_inject_program_int(vcpu, PGM_OPERATION);
 }
 
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d42428c..63ac7c1 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -364,6 +364,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 	case KVM_CAP_S390_USER_STSI:
 	case KVM_CAP_S390_SKEYS:
 	case KVM_CAP_S390_IRQ_STATE:
+	case KVM_CAP_S390_USER_INSTR0:
 		r = 1;
 		break;
 	case KVM_CAP_S390_MEM_OP:
@@ -456,6 +457,16 @@ out:
 	return r;
 }
 
+static void icpt_operexc_on_all_vcpus(struct kvm *kvm)
+{
+	unsigned int i;
+	struct kvm_vcpu *vcpu;
+
+	kvm_for_each_vcpu(i, vcpu, kvm) {
+		kvm_s390_sync_request(KVM_REQ_ICPT_OPEREXC, vcpu);
+	}
+}
+
 static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
 {
 	int r;
@@ -507,6 +518,12 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap)
 		kvm->arch.user_stsi = 1;
 		r = 0;
 		break;
+	case KVM_CAP_S390_USER_INSTR0:
+		VM_EVENT(kvm, 3, "%s", "ENABLE: CAP_S390_USER_INSTR0");
+		kvm->arch.user_instr0 = 1;
+		icpt_operexc_on_all_vcpus(kvm);
+		r = 0;
+		break;
 	default:
 		r = -EINVAL;
 		break;
@@ -1836,6 +1853,8 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
 		vcpu->arch.gmap = vcpu->kvm->arch.gmap;
 		sca_add_vcpu(vcpu);
 	}
+	if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0)
+		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
 	/* make vcpu_load load the right gmap on the first trigger */
 	vcpu->arch.enabled_gmap = vcpu->arch.gmap;
 }
@@ -1923,8 +1942,6 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
 	}
 	vcpu->arch.sie_block->riccbd = (unsigned long) &vcpu->run->s.regs.riccb;
 	vcpu->arch.sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE;
-	if (test_kvm_facility(vcpu->kvm, 74))
-		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
 
 	if (vcpu->kvm->arch.use_cmma) {
 		rc = kvm_s390_vcpu_setup_cmma(vcpu);
@@ -2369,6 +2386,11 @@ retry:
 		goto retry;
 	}
 
+	if (kvm_check_request(KVM_REQ_ICPT_OPEREXC, vcpu)) {
+		vcpu->arch.sie_block->ictl |= ICTL_OPEREXC;
+		goto retry;
+	}
+
 	/* nothing to do, just clear the request */
 	clear_bit(KVM_REQ_UNHALT, &vcpu->requests);
 
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 4f8030e..70941f4 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -867,6 +867,7 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_VCPU_ATTRIBUTES 127
 #define KVM_CAP_MAX_VCPU_ID 128
 #define KVM_CAP_X2APIC_API 129
+#define KVM_CAP_S390_USER_INSTR0 130
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
-- 
2.5.5

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

* [GIT PULL 2/2] KVM: s390: let ptff intercepts result in cc=3
  2016-07-20 12:39 PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
  2016-07-20 12:39 ` [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000 Christian Borntraeger
@ 2016-07-20 12:40 ` Christian Borntraeger
  2016-07-20 12:41 ` PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
  2016-07-21 13:07 ` Radim Krčmář
  3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2016-07-20 12:40 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger, David Hildenbrand

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

We don't emulate ptff subfunctions, therefore react on any attempt of
execution by setting cc=3 (Requested function not available).

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/priv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index c77ad2d..4616038 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -1185,7 +1185,15 @@ static int handle_sckpf(struct kvm_vcpu *vcpu)
 	return 0;
 }
 
+static int handle_ptff(struct kvm_vcpu *vcpu)
+{
+	/* we don't emulate any control instructions yet */
+	kvm_s390_set_psw_cc(vcpu, 3);
+	return 0;
+}
+
 static const intercept_handler_t x01_handlers[256] = {
+	[0x04] = handle_ptff,
 	[0x07] = handle_sckpf,
 };
 
-- 
2.5.5

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

* Re: PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4
  2016-07-20 12:39 PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
  2016-07-20 12:39 ` [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000 Christian Borntraeger
  2016-07-20 12:40 ` [GIT PULL 2/2] KVM: s390: let ptff intercepts result in cc=3 Christian Borntraeger
@ 2016-07-20 12:41 ` Christian Borntraeger
  2016-07-21 13:07 ` Radim Krčmář
  3 siblings, 0 replies; 8+ messages in thread
From: Christian Borntraeger @ 2016-07-20 12:41 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, David Hildenbrand

please ignore the "PREVIEW" word in the subject line, I forgot to switch back
my tooling...

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

* Re: [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000
  2016-07-20 12:39 ` [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000 Christian Borntraeger
@ 2016-07-20 14:35   ` Christian Borntraeger
  2016-07-20 14:43     ` Paolo Bonzini
  2016-07-20 17:47     ` Marc Zyngier
  0 siblings, 2 replies; 8+ messages in thread
From: Christian Borntraeger @ 2016-07-20 14:35 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, David Hildenbrand, marc.zyngier, cdall

Marc, Christoffer,
FYI/FYA
the CAP number will conflict with your kvmarm changes.
I assume Paolo/Radim will resolve this when merging.

Seems that you have no hit in api.txt, correct?



> diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt
> index c4d2fb0..299306d 100644
> --- a/Documentation/virtual/kvm/api.txt
> +++ b/Documentation/virtual/kvm/api.txt
[...]
> +7.8 KVM_CAP_S390_USER_INSTR0
> +
> +Architectures: s390
[...]

> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -867,6 +867,7 @@ struct kvm_ppc_smmu_info {
>  #define KVM_CAP_VCPU_ATTRIBUTES 127
>  #define KVM_CAP_MAX_VCPU_ID 128
>  #define KVM_CAP_X2APIC_API 129
> +#define KVM_CAP_S390_USER_INSTR0 130

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

* Re: [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000
  2016-07-20 14:35   ` Christian Borntraeger
@ 2016-07-20 14:43     ` Paolo Bonzini
  2016-07-20 17:47     ` Marc Zyngier
  1 sibling, 0 replies; 8+ messages in thread
From: Paolo Bonzini @ 2016-07-20 14:43 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Radim Krčmář,
	KVM, Cornelia Huck, linux-s390, David Hildenbrand, marc zyngier,
	cdall

> Marc, Christoffer,
> FYI/FYA
> the CAP number will conflict with your kvmarm changes.
> I assume Paolo/Radim will resolve this when merging.

Yup, we'll handle it.

Paolo

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

* Re: [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000
  2016-07-20 14:35   ` Christian Borntraeger
  2016-07-20 14:43     ` Paolo Bonzini
@ 2016-07-20 17:47     ` Marc Zyngier
  1 sibling, 0 replies; 8+ messages in thread
From: Marc Zyngier @ 2016-07-20 17:47 UTC (permalink / raw)
  To: Christian Borntraeger, Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, David Hildenbrand, cdall

On 20/07/16 15:35, Christian Borntraeger wrote:
> Marc, Christoffer,
> FYI/FYA
> the CAP number will conflict with your kvmarm changes.
> I assume Paolo/Radim will resolve this when merging.

Yea, that's usually the case.

> Seems that you have no hit in api.txt, correct?

There is a small update for the KVM_CAP_SIGNAL_MSI API, but we don't
seem to step on each other's toes over there.

Thanks for the heads up!

	M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4
  2016-07-20 12:39 PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
                   ` (2 preceding siblings ...)
  2016-07-20 12:41 ` PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
@ 2016-07-21 13:07 ` Radim Krčmář
  3 siblings, 0 replies; 8+ messages in thread
From: Radim Krčmář @ 2016-07-21 13:07 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Paolo Bonzini, KVM, Cornelia Huck, linux-s390, David Hildenbrand,
	Marc Zyngier, Christoffer Dall

2016-07-20 14:39+0200, Christian Borntraeger:
> Paolo, Radim,
> 
> hopefully the last update for s390 for 4.8.
> Please note the CAP number conflicts with kvmarm, when merging the one
> or the other first. You might also need to adopt the number in
> Documentation/virtual/kvm/api.txt in case arm has something in here as well.

Merged, thanks.  Capability 130 is KVM_CAP_S390_USER_INSTR0.

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

end of thread, other threads:[~2016-07-21 13:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-20 12:39 PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
2016-07-20 12:39 ` [GIT PULL 1/2] KVM: s390: allow user space to handle instr 0x0000 Christian Borntraeger
2016-07-20 14:35   ` Christian Borntraeger
2016-07-20 14:43     ` Paolo Bonzini
2016-07-20 17:47     ` Marc Zyngier
2016-07-20 12:40 ` [GIT PULL 2/2] KVM: s390: let ptff intercepts result in cc=3 Christian Borntraeger
2016-07-20 12:41 ` PREVIEW: [GIT PULL 0/2] KVM: s390: Feature and fix for kvm/next (4.8) part 4 Christian Borntraeger
2016-07-21 13:07 ` Radim Krčmář

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.