kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15
@ 2021-08-29  6:01 Christian Borntraeger
  2021-08-29  6:01 ` [GIT PULL 1/2] KVM: s390: Enable specification exception interpretation Christian Borntraeger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christian Borntraeger @ 2021-08-29  6:01 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Cornelia Huck, linux-s390, Christian Borntraeger, Heiko Carstens,
	Vasily Gorbik, Halil Pasic, Janis Schoetterl-Glausch

Paolo,

sorry for being so late. One feature (enable hardware interpretion of
specification exceptions) and one fix targeted for stable. Given the
short runway to 5.14 I decided to let this go via next and not try to
sneak it into 5.14.

The following changes since commit 1f703d2cf20464338c3d5279dddfb65ac79b8782:

  KVM: s390: allow facility 192 (vector-packed-decimal-enhancement facility 2) (2021-06-23 09:35:20 +0200)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-5.15-1

for you to fetch changes up to a3e03bc1368c1bc16e19b001fc96dc7430573cc8:

  KVM: s390: index kvm->arch.idle_mask by vcpu_idx (2021-08-27 18:35:41 +0200)

----------------------------------------------------------------
KVM: s390: Fix and feature for 5.15

- enable interpretion of specification exceptions
- fix a vcpu_idx vs vcpu_id mixup

----------------------------------------------------------------
Halil Pasic (1):
      KVM: s390: index kvm->arch.idle_mask by vcpu_idx

Janis Schoetterl-Glausch (1):
      KVM: s390: Enable specification exception interpretation

 arch/s390/include/asm/kvm_host.h |  2 ++
 arch/s390/kvm/interrupt.c        | 12 ++++++------
 arch/s390/kvm/kvm-s390.c         |  4 +++-
 arch/s390/kvm/kvm-s390.h         |  2 +-
 arch/s390/kvm/vsie.c             |  2 ++
 5 files changed, 14 insertions(+), 8 deletions(-)

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

* [GIT PULL 1/2] KVM: s390: Enable specification exception interpretation
  2021-08-29  6:01 [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Christian Borntraeger
@ 2021-08-29  6:01 ` Christian Borntraeger
  2021-08-29  6:01 ` [GIT PULL 2/2] KVM: s390: index kvm->arch.idle_mask by vcpu_idx Christian Borntraeger
  2021-09-06 10:35 ` [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2021-08-29  6:01 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Cornelia Huck, linux-s390, Christian Borntraeger, Heiko Carstens,
	Vasily Gorbik, Halil Pasic, Janis Schoetterl-Glausch

From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>

When this feature is enabled the hardware is free to interpret
specification exceptions generated by the guest, instead of causing
program interruption interceptions.

This benefits (test) programs that generate a lot of specification
exceptions (roughly 4x increase in exceptions/sec).

Interceptions will occur as before if ICTL_PINT is set,
i.e. if guest debug is enabled.

There is no indication if this feature is available or not and the
hardware is free to interpret or not. So we can simply set this bit and
if the hardware ignores it we fall back to intercept 8 handling.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Link: https://lore.kernel.org/linux-s390/20210706114714.3936825-1-scgl@linux.ibm.com/
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h | 1 +
 arch/s390/kvm/kvm-s390.c         | 2 ++
 arch/s390/kvm/vsie.c             | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 8925f3969478..118d5450c523 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -244,6 +244,7 @@ struct kvm_s390_sie_block {
 	__u8	fpf;			/* 0x0060 */
 #define ECB_GS		0x40
 #define ECB_TE		0x10
+#define ECB_SPECI	0x08
 #define ECB_SRSI	0x04
 #define ECB_HOSTPROTINT	0x02
 	__u8	ecb;			/* 0x0061 */
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index f72f361d39dd..5b45c83ced21 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -3180,6 +3180,8 @@ static int kvm_s390_vcpu_setup(struct kvm_vcpu *vcpu)
 		vcpu->arch.sie_block->ecb |= ECB_SRSI;
 	if (test_kvm_facility(vcpu->kvm, 73))
 		vcpu->arch.sie_block->ecb |= ECB_TE;
+	if (!kvm_is_ucontrol(vcpu->kvm))
+		vcpu->arch.sie_block->ecb |= ECB_SPECI;
 
 	if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi)
 		vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI;
diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c
index 4002a24bc43a..acda4b6fc851 100644
--- a/arch/s390/kvm/vsie.c
+++ b/arch/s390/kvm/vsie.c
@@ -510,6 +510,8 @@ static int shadow_scb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 			prefix_unmapped(vsie_page);
 		scb_s->ecb |= ECB_TE;
 	}
+	/* specification exception interpretation */
+	scb_s->ecb |= scb_o->ecb & ECB_SPECI;
 	/* branch prediction */
 	if (test_kvm_facility(vcpu->kvm, 82))
 		scb_s->fpf |= scb_o->fpf & FPF_BPBC;
-- 
2.31.1


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

* [GIT PULL 2/2] KVM: s390: index kvm->arch.idle_mask by vcpu_idx
  2021-08-29  6:01 [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Christian Borntraeger
  2021-08-29  6:01 ` [GIT PULL 1/2] KVM: s390: Enable specification exception interpretation Christian Borntraeger
@ 2021-08-29  6:01 ` Christian Borntraeger
  2021-09-06 10:35 ` [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2021-08-29  6:01 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Cornelia Huck, linux-s390, Christian Borntraeger, Heiko Carstens,
	Vasily Gorbik, Halil Pasic, Janis Schoetterl-Glausch

From: Halil Pasic <pasic@linux.ibm.com>

While in practice vcpu->vcpu_idx ==  vcpu->vcp_id is often true, it may
not always be, and we must not rely on this. Reason is that KVM decides
the vcpu_idx, userspace decides the vcpu_id, thus the two might not
match.

Currently kvm->arch.idle_mask is indexed by vcpu_id, which implies
that code like
for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) {
                vcpu = kvm_get_vcpu(kvm, vcpu_id);
		do_stuff(vcpu);
}
is not legit. Reason is that kvm_get_vcpu expects an vcpu_idx, not an
vcpu_id.  The trouble is, we do actually use kvm->arch.idle_mask like
this. To fix this problem we have two options. Either use
kvm_get_vcpu_by_id(vcpu_id), which would loop to find the right vcpu_id,
or switch to indexing via vcpu_idx. The latter is preferable for obvious
reasons.

Let us make switch from indexing kvm->arch.idle_mask by vcpu_id to
indexing it by vcpu_idx.  To keep gisa_int.kicked_mask indexed by the
same index as idle_mask lets make the same change for it as well.

Fixes: 1ee0bc559dc3 ("KVM: s390: get rid of local_int array")
Signed-off-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Christian Bornträger <borntraeger@de.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: <stable@vger.kernel.org> # 3.15+
Link: https://lore.kernel.org/r/20210827125429.1912577-1-pasic@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/include/asm/kvm_host.h |  1 +
 arch/s390/kvm/interrupt.c        | 12 ++++++------
 arch/s390/kvm/kvm-s390.c         |  2 +-
 arch/s390/kvm/kvm-s390.h         |  2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 118d5450c523..611f18ecde91 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -963,6 +963,7 @@ struct kvm_arch{
 	atomic64_t cmma_dirty_pages;
 	/* subset of available cpu features enabled by user space */
 	DECLARE_BITMAP(cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
+	/* indexed by vcpu_idx */
 	DECLARE_BITMAP(idle_mask, KVM_MAX_VCPUS);
 	struct kvm_s390_gisa_interrupt gisa_int;
 	struct kvm_s390_pv pv;
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index d548d60caed2..16256e17a544 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -419,13 +419,13 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
 static void __set_cpu_idle(struct kvm_vcpu *vcpu)
 {
 	kvm_s390_set_cpuflags(vcpu, CPUSTAT_WAIT);
-	set_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
+	set_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
 }
 
 static void __unset_cpu_idle(struct kvm_vcpu *vcpu)
 {
 	kvm_s390_clear_cpuflags(vcpu, CPUSTAT_WAIT);
-	clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
+	clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
 }
 
 static void __reset_intercept_indicators(struct kvm_vcpu *vcpu)
@@ -3050,18 +3050,18 @@ int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu, __u8 __user *buf, int len)
 
 static void __airqs_kick_single_vcpu(struct kvm *kvm, u8 deliverable_mask)
 {
-	int vcpu_id, online_vcpus = atomic_read(&kvm->online_vcpus);
+	int vcpu_idx, online_vcpus = atomic_read(&kvm->online_vcpus);
 	struct kvm_s390_gisa_interrupt *gi = &kvm->arch.gisa_int;
 	struct kvm_vcpu *vcpu;
 
-	for_each_set_bit(vcpu_id, kvm->arch.idle_mask, online_vcpus) {
-		vcpu = kvm_get_vcpu(kvm, vcpu_id);
+	for_each_set_bit(vcpu_idx, kvm->arch.idle_mask, online_vcpus) {
+		vcpu = kvm_get_vcpu(kvm, vcpu_idx);
 		if (psw_ioint_disabled(vcpu))
 			continue;
 		deliverable_mask &= (u8)(vcpu->arch.sie_block->gcr[6] >> 24);
 		if (deliverable_mask) {
 			/* lately kicked but not yet running */
-			if (test_and_set_bit(vcpu_id, gi->kicked_mask))
+			if (test_and_set_bit(vcpu_idx, gi->kicked_mask))
 				return;
 			kvm_s390_vcpu_wakeup(vcpu);
 			return;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 5b45c83ced21..e144c8046ceb 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -4026,7 +4026,7 @@ static int vcpu_pre_run(struct kvm_vcpu *vcpu)
 		kvm_s390_patch_guest_per_regs(vcpu);
 	}
 
-	clear_bit(vcpu->vcpu_id, vcpu->kvm->arch.gisa_int.kicked_mask);
+	clear_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.gisa_int.kicked_mask);
 
 	vcpu->arch.sie_block->icptcode = 0;
 	cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags);
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 9fad25109b0d..ecd741ee3276 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -79,7 +79,7 @@ static inline int is_vcpu_stopped(struct kvm_vcpu *vcpu)
 
 static inline int is_vcpu_idle(struct kvm_vcpu *vcpu)
 {
-	return test_bit(vcpu->vcpu_id, vcpu->kvm->arch.idle_mask);
+	return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask);
 }
 
 static inline int kvm_is_ucontrol(struct kvm *kvm)
-- 
2.31.1


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

* Re: [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15
  2021-08-29  6:01 [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Christian Borntraeger
  2021-08-29  6:01 ` [GIT PULL 1/2] KVM: s390: Enable specification exception interpretation Christian Borntraeger
  2021-08-29  6:01 ` [GIT PULL 2/2] KVM: s390: index kvm->arch.idle_mask by vcpu_idx Christian Borntraeger
@ 2021-09-06 10:35 ` Paolo Bonzini
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-09-06 10:35 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: KVM, Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Cornelia Huck, linux-s390, Heiko Carstens, Vasily Gorbik,
	Halil Pasic, Janis Schoetterl-Glausch

On 29/08/21 08:01, Christian Borntraeger wrote:
> Paolo,
> 
> sorry for being so late. One feature (enable hardware interpretion of
> specification exceptions) and one fix targeted for stable. Given the
> short runway to 5.14 I decided to let this go via next and not try to
> sneak it into 5.14.
> 
> The following changes since commit 1f703d2cf20464338c3d5279dddfb65ac79b8782:
> 
>    KVM: s390: allow facility 192 (vector-packed-decimal-enhancement facility 2) (2021-06-23 09:35:20 +0200)
> 
> are available in the Git repository at:
> 
>    git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-5.15-1
> 
> for you to fetch changes up to a3e03bc1368c1bc16e19b001fc96dc7430573cc8:
> 
>    KVM: s390: index kvm->arch.idle_mask by vcpu_idx (2021-08-27 18:35:41 +0200)
> 
> ----------------------------------------------------------------
> KVM: s390: Fix and feature for 5.15
> 
> - enable interpretion of specification exceptions
> - fix a vcpu_idx vs vcpu_id mixup
> 
> ----------------------------------------------------------------
> Halil Pasic (1):
>        KVM: s390: index kvm->arch.idle_mask by vcpu_idx
> 
> Janis Schoetterl-Glausch (1):
>        KVM: s390: Enable specification exception interpretation
> 
>   arch/s390/include/asm/kvm_host.h |  2 ++
>   arch/s390/kvm/interrupt.c        | 12 ++++++------
>   arch/s390/kvm/kvm-s390.c         |  4 +++-
>   arch/s390/kvm/kvm-s390.h         |  2 +-
>   arch/s390/kvm/vsie.c             |  2 ++
>   5 files changed, 14 insertions(+), 8 deletions(-)
> 

Pulled now, thanks!

Paolo


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

end of thread, other threads:[~2021-09-06 10:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29  6:01 [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 Christian Borntraeger
2021-08-29  6:01 ` [GIT PULL 1/2] KVM: s390: Enable specification exception interpretation Christian Borntraeger
2021-08-29  6:01 ` [GIT PULL 2/2] KVM: s390: index kvm->arch.idle_mask by vcpu_idx Christian Borntraeger
2021-09-06 10:35 ` [GIT PULL 0/2] KVM: s390: Fix and feature for 5.15 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).