diff mbox series

[v3,09/12] KVM: s390: add functions to (un)register GISC with GISA

Message ID 20181128101943.155542-10-mimu@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series KVM: s390: make use of the GIB | expand

Commit Message

Michael Mueller Nov. 28, 2018, 10:19 a.m. UTC
Add the IAM (Interruption Alert Mask) to the architectue 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.

Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
---
 arch/s390/include/asm/kvm_host.h |  6 ++++++
 arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

Comments

Pierre Morel Nov. 28, 2018, 4:19 p.m. UTC | #1
On 28/11/2018 11:19, Michael Mueller wrote:
> Add the IAM (Interruption Alert Mask) to the architectue 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.
> 
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> ---
>   arch/s390/include/asm/kvm_host.h |  6 ++++++
>   arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 50 insertions(+)

Reviewed-by: Pierre Morel<pmorel@linux.ibm.com>
Cornelia Huck Nov. 29, 2018, 10:55 a.m. UTC | #2
On Wed, 28 Nov 2018 11:19:40 +0100
Michael Mueller <mimu@linux.ibm.com> wrote:

> Add the IAM (Interruption Alert Mask) to the architectue 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.
> 
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> ---
>  arch/s390/include/asm/kvm_host.h |  6 ++++++
>  arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+)

I've started at this and the following patches and have not found a
place where the functions are called... leftover from a previous
version?
Michael Mueller Nov. 29, 2018, 11:24 a.m. UTC | #3
On 29.11.18 11:55, Cornelia Huck wrote:
> On Wed, 28 Nov 2018 11:19:40 +0100
> Michael Mueller <mimu@linux.ibm.com> wrote:
> 
>> Add the IAM (Interruption Alert Mask) to the architectue 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.
>>
>> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
>> ---
>>   arch/s390/include/asm/kvm_host.h |  6 ++++++
>>   arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 50 insertions(+)
> 
> I've started at this and the following patches and have not found a
> place where the functions are called... leftover from a previous
> version?

No, these functions are required by the related driver code.

Pls. see:

Message ID: 1542906675-7949-4-git-send-email-pmorel@linux.ibm.com

[v2,3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls

>
Cornelia Huck Nov. 29, 2018, 11:48 a.m. UTC | #4
On Thu, 29 Nov 2018 12:24:36 +0100
Michael Mueller <mimu@linux.ibm.com> wrote:

> On 29.11.18 11:55, Cornelia Huck wrote:
> > On Wed, 28 Nov 2018 11:19:40 +0100
> > Michael Mueller <mimu@linux.ibm.com> wrote:
> >   
> >> Add the IAM (Interruption Alert Mask) to the architectue 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.
> >>
> >> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> >> ---
> >>   arch/s390/include/asm/kvm_host.h |  6 ++++++
> >>   arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
> >>   2 files changed, 50 insertions(+)  
> > 
> > I've started at this and the following patches and have not found a
> > place where the functions are called... leftover from a previous
> > version?  
> 
> No, these functions are required by the related driver code.
> 
> Pls. see:
> 
> Message ID: 1542906675-7949-4-git-send-email-pmorel@linux.ibm.com
> 
> [v2,3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls
> 
> >   
> 

I guess they should go with that series, then.
Michael Mueller Nov. 29, 2018, 12:35 p.m. UTC | #5
On 29.11.18 12:48, Cornelia Huck wrote:
> On Thu, 29 Nov 2018 12:24:36 +0100
> Michael Mueller <mimu@linux.ibm.com> wrote:
> 
>> On 29.11.18 11:55, Cornelia Huck wrote:
>>> On Wed, 28 Nov 2018 11:19:40 +0100
>>> Michael Mueller <mimu@linux.ibm.com> wrote:
>>>    
>>>> Add the IAM (Interruption Alert Mask) to the architectue 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.
>>>>
>>>> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
>>>> ---
>>>>    arch/s390/include/asm/kvm_host.h |  6 ++++++
>>>>    arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
>>>>    2 files changed, 50 insertions(+)
>>>
>>> I've started at this and the following patches and have not found a
>>> place where the functions are called... leftover from a previous
>>> version?
>>
>> No, these functions are required by the related driver code.
>>
>> Pls. see:
>>
>> Message ID: 1542906675-7949-4-git-send-email-pmorel@linux.ibm.com
>>
>> [v2,3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls
>>
>>>    
>>
> 
> I guess they should go with that series, then.

No, I don't think so. These functions are part of the
*GIB infrastructure* and will by consumed e.g. by VFIO AP
with irqs but also by PCI.

>
Cornelia Huck Nov. 29, 2018, 12:46 p.m. UTC | #6
On Thu, 29 Nov 2018 13:35:07 +0100
Michael Mueller <mimu@linux.ibm.com> wrote:

> On 29.11.18 12:48, Cornelia Huck wrote:
> > On Thu, 29 Nov 2018 12:24:36 +0100
> > Michael Mueller <mimu@linux.ibm.com> wrote:
> >   
> >> On 29.11.18 11:55, Cornelia Huck wrote:  
> >>> On Wed, 28 Nov 2018 11:19:40 +0100
> >>> Michael Mueller <mimu@linux.ibm.com> wrote:
> >>>      
> >>>> Add the IAM (Interruption Alert Mask) to the architectue 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.
> >>>>
> >>>> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> >>>> ---
> >>>>    arch/s390/include/asm/kvm_host.h |  6 ++++++
> >>>>    arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
> >>>>    2 files changed, 50 insertions(+)  
> >>>
> >>> I've started at this and the following patches and have not found a
> >>> place where the functions are called... leftover from a previous
> >>> version?  
> >>
> >> No, these functions are required by the related driver code.
> >>
> >> Pls. see:
> >>
> >> Message ID: 1542906675-7949-4-git-send-email-pmorel@linux.ibm.com
> >>
> >> [v2,3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls
> >>  
> >>>      
> >>  
> > 
> > I guess they should go with that series, then.  
> 
> No, I don't think so. These functions are part of the
> *GIB infrastructure* and will by consumed e.g. by VFIO AP
> with irqs but also by PCI.

I disagree. The rest of this series lays the groundwork, this patch
exports two unused functions, and it is much clearer how they are
supposed to be used with an actual user. Of course PCI can use them
later on as well :)

But in the end, your call.
Michael Mueller Nov. 29, 2018, 1:16 p.m. UTC | #7
On 29.11.18 13:46, Cornelia Huck wrote:
> On Thu, 29 Nov 2018 13:35:07 +0100
> Michael Mueller <mimu@linux.ibm.com> wrote:
> 
>> On 29.11.18 12:48, Cornelia Huck wrote:
>>> On Thu, 29 Nov 2018 12:24:36 +0100
>>> Michael Mueller <mimu@linux.ibm.com> wrote:
>>>    
>>>> On 29.11.18 11:55, Cornelia Huck wrote:
>>>>> On Wed, 28 Nov 2018 11:19:40 +0100
>>>>> Michael Mueller <mimu@linux.ibm.com> wrote:
>>>>>       
>>>>>> Add the IAM (Interruption Alert Mask) to the architectue 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.
>>>>>>
>>>>>> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
>>>>>> ---
>>>>>>     arch/s390/include/asm/kvm_host.h |  6 ++++++
>>>>>>     arch/s390/kvm/interrupt.c        | 44 ++++++++++++++++++++++++++++++++++++++++
>>>>>>     2 files changed, 50 insertions(+)
>>>>>
>>>>> I've started at this and the following patches and have not found a
>>>>> place where the functions are called... leftover from a previous
>>>>> version?
>>>>
>>>> No, these functions are required by the related driver code.
>>>>
>>>> Pls. see:
>>>>
>>>> Message ID: 1542906675-7949-4-git-send-email-pmorel@linux.ibm.com
>>>>
>>>> [v2,3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls
>>>>   
>>>>>       
>>>>   
>>>
>>> I guess they should go with that series, then.
>>
>> No, I don't think so. These functions are part of the
>> *GIB infrastructure* and will by consumed e.g. by VFIO AP
>> with irqs but also by PCI.
> 
> I disagree. The rest of this series lays the groundwork, this patch
> exports two unused functions, and it is much clearer how they are
> supposed to be used with an actual user. Of course PCI can use them
> later on as well :)

Then you could even argue the whole series has to go together with the
AP irq series as it has no effect unless kvm->arch.iam is assigned a
value... ;)

> 
> But in the end, your call.
>
diff mbox series

Patch

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 3e3225ea303b..3b7902a8573d 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -850,6 +850,9 @@  struct kvm_arch{
 	struct kvm_s390_gisa *gisa;
 	int gib_in_use;
 	atomic_t vcpus_in_sie;
+	u8 iam;
+	u32 iam_ref_count[MAX_ISC + 1];
+	spinlock_t iam_ref_lock;
 };
 
 #define KVM_HVA_ERR_BAD		(-1UL)
@@ -883,6 +886,9 @@  void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,
 extern int sie64a(struct kvm_s390_sie_block *, u64 *);
 extern char sie_exit;
 
+extern int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc);
+extern int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc);
+
 static inline void kvm_arch_hardware_disable(void) {}
 static inline void kvm_arch_check_processor_compat(void *rtn) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 37a5df4e8dac..dd80bdc056a5 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -2962,6 +2962,8 @@  void kvm_s390_gisa_init(struct kvm *kvm)
 {
 	if (css_general_characteristics.aiv) {
 		kvm->arch.gisa = &kvm->arch.sie_page2->gisa;
+		kvm->arch.iam = 0;
+		spin_lock_init(&kvm->arch.iam_ref_lock);
 		VM_EVENT(kvm, 3, "gisa 0x%pK initialized", kvm->arch.gisa);
 		kvm_s390_gisa_clear(kvm);
 		kvm->arch.gib_in_use = !!gib;
@@ -2973,8 +2975,50 @@  void kvm_s390_gisa_destroy(struct kvm *kvm)
 	if (!kvm->arch.gisa)
 		return;
 	kvm->arch.gisa = NULL;
+	kvm->arch.iam = 0;
 }
 
+int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc)
+{
+	if (!kvm->arch.gib_in_use)
+		return -ENODEV;
+	if (gisc > MAX_ISC)
+		return -EINVAL;
+
+	spin_lock(&kvm->arch.iam_ref_lock);
+	if (kvm->arch.iam_ref_count[gisc] == 0)
+		kvm->arch.iam |= 0x80 >> gisc;
+	kvm->arch.iam_ref_count[gisc]++;
+	spin_unlock(&kvm->arch.iam_ref_lock);
+
+	return gib->nisc;
+}
+EXPORT_SYMBOL_GPL(kvm_s390_gisc_register);
+
+int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc)
+{
+	int rc = 0;
+
+	if (!kvm->arch.gib_in_use)
+		return -ENODEV;
+	if (gisc > MAX_ISC)
+		return -EINVAL;
+
+	spin_lock(&kvm->arch.iam_ref_lock);
+	if (kvm->arch.iam_ref_count[gisc] == 0) {
+		rc = -EFAULT;
+		goto out;
+	}
+	kvm->arch.iam_ref_count[gisc]--;
+	if (kvm->arch.iam_ref_count[gisc] == 0)
+		kvm->arch.iam &= ~(0x80 >> gisc);
+out:
+	spin_unlock(&kvm->arch.iam_ref_lock);
+
+	return rc;
+}
+EXPORT_SYMBOL_GPL(kvm_s390_gisc_unregister);
+
 void kvm_s390_gib_destroy(void)
 {
 	if (!gib)