[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <9a114fdc-0924-9730-7ca4-c483ed2c4eb7@linux.ibm.com>
Date: Tue, 8 Jan 2019 09:06:59 +0100
From: Michael Mueller <mimu@...ux.ibm.com>
To: Halil Pasic <pasic@...ux.ibm.com>
Cc: KVM Mailing List <kvm@...r.kernel.org>,
Linux-S390 Mailing List <linux-s390@...r.kernel.org>,
linux-kernel@...r.kernel.org,
kvm390-list@...maker.boeblingen.de.ibm.com,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Heiko Carstens <heiko.carstens@...ibm.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
Janosch Frank <frankja@...ux.ibm.com>,
David Hildenbrand <david@...hat.com>,
Cornelia Huck <cohuck@...hat.com>,
Pierre Morel <pmorel@...ux.ibm.com>
Subject: Re: [PATCH v5 11/15] KVM: s390: restore IAM in get_ipm() when IPM is
clean
On 07.01.19 00:32, Halil Pasic wrote:
> On Wed, 19 Dec 2018 20:17:52 +0100
> Michael Mueller <mimu@...ux.ibm.com> wrote:
>
>> The patch adds the parameter irq_flags and allows to
>> restore the Interruption Alert Mask (IAM) in the GISA
>> atomically while guaranteeing the IPM is clean.
>>
>> The function returns the IPM of the GISA. If the returned
>> value is 0x00 and the IRQ_FLAG_IAM was set, the IAM has
>> been restored.
>>
>> New irq flag:
>> IRQ_FLAG_IAM: When set, the IAM is restored if no ISC bit
>> is set in the IPM, i.e. no new airqs are
>> pending. The test and restore operations
>> are done atomically.
>>
>> Signed-off-by: Michael Mueller <mimu@...ux.ibm.com>
>> ---
>> arch/s390/kvm/interrupt.c | 34 +++++++++++++++++++++++++++++-----
>> 1 file changed, 29 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
>> index 1cc3ad2e6c7e..8307717e3caf 100644
>> --- a/arch/s390/kvm/interrupt.c
>> +++ b/arch/s390/kvm/interrupt.c
>> @@ -37,6 +37,7 @@
>> #define IRQ_FLAG_LOCAL 0x8000 /* include local interruption pending mask */
>> #define IRQ_FLAG_FLOATING 0x4000 /* include float interruption pending mask */
>> #define IRQ_FLAG_GISA 0x2000 /* include GISA interruption pending mask */
>> +#define IRQ_FLAG_IAM 0x0080 /* when set try to restore IAM */
>>
>> #define IRQ_MASK_ALL (IRQ_FLAG_LOCAL | IRQ_FLAG_FLOATING | IRQ_FLAG_GISA)
>> #define IRQ_MASK_NO_GISA (IRQ_MASK_ALL & ~IRQ_FLAG_GISA)
>> @@ -253,9 +254,32 @@ static inline void set_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
>> set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
>> }
>>
>> -static inline u8 get_ipm(struct kvm_s390_gisa *gisa)
>> +static inline u8 get_ipm(struct kvm_s390_gisa *gisa, u16 irq_flags)
>> {
>> - return READ_ONCE(gisa->ipm);
>> + u64 word, _word;
>> + u8 ipm;
>> +
>> + if (!(irq_flags & IRQ_FLAG_IAM))
>> + return READ_ONCE(gisa->ipm);
>> +
>> + do {
>> + word = READ_ONCE(gisa->u64.word[0]);
>> + ipm = word >> 24;
>> + /* If the GISA is in the alert list, return the IPM. */
>> + if ((u64)gisa != word >> 32)
>> + return ipm;
>> + /* If the IPM is dirty, return the IPM. */
>> + if (ipm)
>> + return ipm;
>> + /*
>> + * Try to restore the IAM or loop, if the IPM is dirty
>> + * again or the GISA has been inserted into the alert list.
>> + */
>> + _word = (word & ~0xffUL) |
>> + container_of(gisa, struct sie_page2, gisa)->kvm->arch.iam;
>> + } while (cmpxchg(&gisa->u64.word[0], word, _word) != _word);
> ^^
>
> Shouldn't this rather be:
> } while (cmpxchg(&gisa->u64.word[0], word, _word) != word);
Yes, the comparison needs to be done against the old value of
the memory region.
>
> Regards,
> Halil
>> +
>> + return 0;
>> }
Powered by blists - more mailing lists