All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: KVM <kvm@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	Cornelia Huck <cornelia.huck@de.ibm.com>,
	Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Alexander Graf <agraf@suse.de>
Subject: [GIT PULL 04/18] KVM: s390: migration / injection of prog irq ilc
Date: Fri, 12 Feb 2016 14:22:48 +0100	[thread overview]
Message-ID: <1455283382-62999-5-git-send-email-borntraeger@de.ibm.com> (raw)
In-Reply-To: <1455283382-62999-1-git-send-email-borntraeger@de.ibm.com>

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

We have to migrate the program irq ilc and someday we will have to
specify the ilc without KVM trying to autodetect the value.

Let's reuse one of the spare fields in our program irq that should
always be set to 0 by user space. Because we also want to make use
of 0 ilcs ("not available"), we need a validity indicator.

If no valid ilc is given, we try to autodetect the ilc via the current
icptcode and icptstatus + parameter and store the valid ilc in the
irq structure.

This has a nice effect: QEMU's making use of KVM_S390_IRQ /
KVM_S390_SET_IRQ_STATE / KVM_S390_GET_IRQ_STATE for migration will
directly migrate the ilc without any changes.

Please note that we use bit 0 as validity and bit 1,2 for the ilc, so
by applying the ilc mask we directly get the ilen which is usually what
we work with.

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 arch/s390/kvm/interrupt.c | 12 +++++++++++-
 include/uapi/linux/kvm.h  |  7 ++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index daa4fdb..e594a78 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -571,7 +571,7 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu)
 	struct kvm_s390_local_interrupt *li = &vcpu->arch.local_int;
 	struct kvm_s390_pgm_info pgm_info;
 	int rc = 0, nullifying = false;
-	u16 ilen = kvm_s390_get_ilen(vcpu);
+	u16 ilen;
 
 	spin_lock(&li->lock);
 	pgm_info = li->irq.pgm;
@@ -579,6 +579,7 @@ static int __must_check __deliver_prog(struct kvm_vcpu *vcpu)
 	memset(&li->irq.pgm, 0, sizeof(pgm_info));
 	spin_unlock(&li->lock);
 
+	ilen = pgm_info.flags & KVM_S390_PGM_FLAGS_ILC_MASK;
 	VCPU_EVENT(vcpu, 3, "deliver: program irq code 0x%x, ilen:%d",
 		   pgm_info.code, ilen);
 	vcpu->stat.deliver_program_int++;
@@ -1043,8 +1044,16 @@ static int __inject_prog(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
 	trace_kvm_s390_inject_vcpu(vcpu->vcpu_id, KVM_S390_PROGRAM_INT,
 				   irq->u.pgm.code, 0);
 
+	if (!(irq->u.pgm.flags & KVM_S390_PGM_FLAGS_ILC_VALID)) {
+		/* auto detection if no valid ILC was given */
+		irq->u.pgm.flags &= ~KVM_S390_PGM_FLAGS_ILC_MASK;
+		irq->u.pgm.flags |= kvm_s390_get_ilen(vcpu);
+		irq->u.pgm.flags |= KVM_S390_PGM_FLAGS_ILC_VALID;
+	}
+
 	if (irq->u.pgm.code == PGM_PER) {
 		li->irq.pgm.code |= PGM_PER;
+		li->irq.pgm.flags = irq->u.pgm.flags;
 		/* only modify PER related information */
 		li->irq.pgm.per_address = irq->u.pgm.per_address;
 		li->irq.pgm.per_code = irq->u.pgm.per_code;
@@ -1053,6 +1062,7 @@ static int __inject_prog(struct kvm_vcpu *vcpu, struct kvm_s390_irq *irq)
 	} else if (!(irq->u.pgm.code & PGM_PER)) {
 		li->irq.pgm.code = (li->irq.pgm.code & PGM_PER) |
 				   irq->u.pgm.code;
+		li->irq.pgm.flags = irq->u.pgm.flags;
 		/* only modify non-PER information */
 		li->irq.pgm.trans_exc_code = irq->u.pgm.trans_exc_code;
 		li->irq.pgm.mon_code = irq->u.pgm.mon_code;
diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 9da9051..4e20a40 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -541,7 +541,12 @@ struct kvm_s390_pgm_info {
 	__u8 exc_access_id;
 	__u8 per_access_id;
 	__u8 op_access_id;
-	__u8 pad[3];
+#define KVM_S390_PGM_FLAGS_ILC_VALID	0x01
+#define KVM_S390_PGM_FLAGS_ILC_0	0x02
+#define KVM_S390_PGM_FLAGS_ILC_1	0x04
+#define KVM_S390_PGM_FLAGS_ILC_MASK	0x06
+	__u8 flags;
+	__u8 pad[2];
 };
 
 struct kvm_s390_prefix_info {
-- 
2.3.0

  parent reply	other threads:[~2016-02-12 13:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12 13:22 [GIT PULL 00/18] KVM: s390: Fixes and features for kvm/next (4.6) Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 01/18] KVM: s390: allow sync of fp registers via vregs Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 02/18] KVM: s390: sync of fp registers via kvm_run Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 03/18] KVM: s390: PSW forwarding / rewinding / ilc rework Christian Borntraeger
2016-02-12 13:22 ` Christian Borntraeger [this message]
2016-02-12 13:22 ` [GIT PULL 05/18] KVM: s390: gaccess: introduce access modes Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 06/18] KVM: s390: gaccess: implement instruction fetching mode Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 07/18] KVM: s390: read the correct opcode on SIE faults Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 08/18] KVM: s390: clean up prog irq injection on prog irq icpts Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 09/18] KVM: s390: irq delivery should not rely on icptcode Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 10/18] KVM: s390: provide prog irq ilc on SIE faults Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 11/18] KVM: s390: instruction-fetching exceptions " Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 12/18] KVM: s390: remove old fragment of vector registers Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 13/18] KVM: s390: add documentation of KVM_S390_VM_TOD Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 14/18] KVM: s390: add documentation of KVM_S390_VM_CRYPTO Christian Borntraeger
2016-02-12 13:22 ` [GIT PULL 15/18] KVM: s390: usage hint for adapter mappings Christian Borntraeger
2016-02-12 13:23 ` [GIT PULL 16/18] KVM: s390: do not take mmap_sem on dirty log query Christian Borntraeger
2016-02-12 13:23 ` [GIT PULL 17/18] KVM: s390: do not block CPU on dirty logging Christian Borntraeger
2016-02-12 13:23 ` [GIT PULL 18/18] KVM: s390: bail out early on fatal signal in " Christian Borntraeger
2016-02-12 15:51 ` [GIT PULL 00/18] KVM: s390: Fixes and features for kvm/next (4.6) Paolo Bonzini
2016-02-12 15:54   ` Christian Borntraeger
2016-02-12 16:00     ` Paolo Bonzini
2016-02-12 16:08       ` Christian Borntraeger
2016-02-12 16:15         ` Christian Borntraeger
2016-02-12 16:18         ` Paolo Bonzini
2016-02-12 19:31           ` Christian Borntraeger
2016-02-12 22:25             ` Paolo Bonzini
2016-02-16 17:48 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455283382-62999-5-git-send-email-borntraeger@de.ibm.com \
    --to=borntraeger@de.ibm.com \
    --cc=agraf@suse.de \
    --cc=cornelia.huck@de.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.