Re: [PATCH v5 10/15] KVM: s390: add functions to (un)register GISC with GISA

From: Michael Mueller
Date: Thu Dec 20 2018 - 09:32:18 EST




On 19.12.18 20:17, Michael Mueller wrote:
Add the IAM (Interruption Alert Mask) to the architecture specific
kvm struct. This mask in the GISA is used to define for which ISC
a GIB alert can be issued.

The functions kvm_s390_gisc_register() and kvm_s390_gisc_unregister()
are used to (un)register a GISC (guest ISC) with a virtual machine and
its GISA.

Upon successful completion, kvm_s390_gisc_register() returns the
ISC to be used for GIB alert interruptions. A negative return code
indicates an error during registration.

Theses functions will be used by other adapter types like AP and PCI to
request pass-through interruption support.

Signed-off-by: Michael Mueller <mimu@xxxxxxxxxxxxx>
---
arch/s390/include/asm/kvm_host.h | 9 ++++++
arch/s390/kvm/interrupt.c | 66 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)


...

--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -229,6 +229,25 @@ static inline u8 int_word_to_isc(u32 int_word)
*/
#define IPM_BIT_OFFSET (offsetof(struct kvm_s390_gisa, ipm) * BITS_PER_BYTE)
+static inline int set_iam(struct kvm_s390_gisa *gisa, u8 iam)

I will rename this one here as well to gisa_set_iam()

+{
+ u64 word0, _word0;
+
+ do {
+ word0 = READ_ONCE(gisa->u64.word[0]);
+ /* If the GISA is in the alert list, do nothing. */
+ if ((u64)gisa != word0 >> 32)
+ return -EBUSY;
+ /*
+ * Try to set the IAM or loop, if the IPM has changed
+ * or the GISA has been inserted into the alert list.
+ */
+ _word0 = (word0 & ~0xffUL) | iam;
+ } while (cmpxchg(&gisa->u64.word[0], word0, _word0) != _word0);
+
+ return 0;
+}
+