linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3
@ 2016-07-05 12:21 Christian Borntraeger
  2016-07-05 12:21 ` [GIT PULL 1/1] KVM: s390: inject PER i-fetch events on applicable icpts Christian Borntraeger
  2016-07-05 12:42 ` [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Borntraeger @ 2016-07-05 12:21 UTC (permalink / raw)
  To: Paolo Bonzini, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, Christian Borntraeger, David Hildenbrand

Paolo, Radim,

The following changes since commit 196f20ca52e8c7281932663c348fa54b82d03914:

  KVM: vmx: fix missed cancellation of TSC deadline timer (2016-07-01 11:03:42 +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-3

for you to fetch changes up to 5ffe466cd3a33543306c37a0789e2116286367f1:

  KVM: s390: inject PER i-fetch events on applicable icpts (2016-07-05 12:02:56 +0200)

----------------------------------------------------------------
KVM: s390: Fix for kvm/next (4.8) part 3

This contains a fix for PER ifetch events. As we now have a handler
for a problem state instruction (sthyi) that could be stepped with a
debugger we should try to do the right thing regarding PER in our
instruction handlers.  With this fix the handling for intercepted
instructions is fixed in general, thus fixing other oddball cases as
well (e.g. kprobes single stepping)

----------------------------------------------------------------
David Hildenbrand (1):
      KVM: s390: inject PER i-fetch events on applicable icpts

 arch/s390/kvm/guestdbg.c  | 17 +++++++++++++++++
 arch/s390/kvm/intercept.c | 17 ++++++++++++++---
 arch/s390/kvm/kvm-s390.h  |  3 +++
 3 files changed, 34 insertions(+), 3 deletions(-)

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

* [GIT PULL 1/1] KVM: s390: inject PER i-fetch events on applicable icpts
  2016-07-05 12:21 [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 Christian Borntraeger
@ 2016-07-05 12:21 ` Christian Borntraeger
  2016-07-05 12:42 ` [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2016-07-05 12:21 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>

In case we have to emuluate an instruction or part of it (instruction,
partial instruction, operation exception), we have to inject a PER
instruction-fetching event for that instruction, if hardware told us to do
so.

In case we retry an instruction, we must not inject the PER event.

Please note that we don't filter the events properly yet, so guest
debugging will be visible for the guest.

Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/guestdbg.c  | 17 +++++++++++++++++
 arch/s390/kvm/intercept.c | 17 ++++++++++++++---
 arch/s390/kvm/kvm-s390.h  |  3 +++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kvm/guestdbg.c b/arch/s390/kvm/guestdbg.c
index 1e0849e..31a0533 100644
--- a/arch/s390/kvm/guestdbg.c
+++ b/arch/s390/kvm/guestdbg.c
@@ -439,6 +439,23 @@ exit_required:
 #define guest_per_enabled(vcpu) \
 			     (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PER)
 
+int kvm_s390_handle_per_ifetch_icpt(struct kvm_vcpu *vcpu)
+{
+	const u8 ilen = kvm_s390_get_ilen(vcpu);
+	struct kvm_s390_pgm_info pgm_info = {
+		.code = PGM_PER,
+		.per_code = PER_EVENT_IFETCH >> 24,
+		.per_address = __rewind_psw(vcpu->arch.sie_block->gpsw, ilen),
+	};
+
+	/*
+	 * The PSW points to the next instruction, therefore the intercepted
+	 * instruction generated a PER i-fetch event. PER address therefore
+	 * points at the previous PSW address (could be an EXECUTE function).
+	 */
+	return kvm_s390_inject_prog_irq(vcpu, &pgm_info);
+}
+
 static void filter_guest_per_event(struct kvm_vcpu *vcpu)
 {
 	u32 perc = vcpu->arch.sie_block->perc << 24;
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 9359f65..850be47 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -364,6 +364,8 @@ static int handle_operexc(struct kvm_vcpu *vcpu)
 
 int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
 {
+	int rc, per_rc = 0;
+
 	if (kvm_is_ucontrol(vcpu->kvm))
 		return -EOPNOTSUPP;
 
@@ -372,7 +374,8 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
 	case 0x18:
 		return handle_noop(vcpu);
 	case 0x04:
-		return handle_instruction(vcpu);
+		rc = handle_instruction(vcpu);
+		break;
 	case 0x08:
 		return handle_prog(vcpu);
 	case 0x14:
@@ -384,10 +387,18 @@ int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
 	case 0x28:
 		return handle_stop(vcpu);
 	case 0x2c:
-		return handle_operexc(vcpu);
+		rc = handle_operexc(vcpu);
+		break;
 	case 0x38:
-		return handle_partial_execution(vcpu);
+		rc = handle_partial_execution(vcpu);
+		break;
 	default:
 		return -EOPNOTSUPP;
 	}
+
+	/* process PER, also if the instrution is processed in user space */
+	if (vcpu->arch.sie_block->icptstatus & 0x02 &&
+	    (!rc || rc == -EOPNOTSUPP))
+		per_rc = kvm_s390_handle_per_ifetch_icpt(vcpu);
+	return per_rc ? per_rc : rc;
 }
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 031f451..b843286 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -238,6 +238,8 @@ static inline void kvm_s390_forward_psw(struct kvm_vcpu *vcpu, int ilen)
 }
 static inline void kvm_s390_retry_instr(struct kvm_vcpu *vcpu)
 {
+	/* don't inject PER events if we re-execute the instruction */
+	vcpu->arch.sie_block->icptstatus &= ~0x02;
 	kvm_s390_rewind_psw(vcpu, kvm_s390_get_ilen(vcpu));
 }
 
@@ -377,6 +379,7 @@ int kvm_s390_import_bp_data(struct kvm_vcpu *vcpu,
 			    struct kvm_guest_debug *dbg);
 void kvm_s390_clear_bp_data(struct kvm_vcpu *vcpu);
 void kvm_s390_prepare_debug_exit(struct kvm_vcpu *vcpu);
+int kvm_s390_handle_per_ifetch_icpt(struct kvm_vcpu *vcpu);
 void kvm_s390_handle_per_event(struct kvm_vcpu *vcpu);
 
 /* support for Basic/Extended SCA handling */
-- 
2.5.5

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

* Re: [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3
  2016-07-05 12:21 [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 Christian Borntraeger
  2016-07-05 12:21 ` [GIT PULL 1/1] KVM: s390: inject PER i-fetch events on applicable icpts Christian Borntraeger
@ 2016-07-05 12:42 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-07-05 12:42 UTC (permalink / raw)
  To: Christian Borntraeger, Radim Krčmář
  Cc: KVM, Cornelia Huck, linux-s390, David Hildenbrand



On 05/07/2016 14:21, Christian Borntraeger wrote:
>   git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git  tags/kvm-s390-next-4.8-3

Pulled, thanks.

Paolo

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

end of thread, other threads:[~2016-07-05 12:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-05 12:21 [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 Christian Borntraeger
2016-07-05 12:21 ` [GIT PULL 1/1] KVM: s390: inject PER i-fetch events on applicable icpts Christian Borntraeger
2016-07-05 12:42 ` [GIT PULL 0/1] KVM: s390: Fix for kvm/next (4.8) part 3 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).