public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Michael Mueller <mimu@linux.ibm.com>
To: Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Janosch Frank <frankja@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>
Subject: Re: [PATCH v1 1/1] KVM: s390: Don't cast parameter in bit operations
Date: Thu, 24 Feb 2022 13:10:34 +0100	[thread overview]
Message-ID: <3640a910-60fe-0935-4dfc-55bb65a75ce5@linux.ibm.com> (raw)
In-Reply-To: <20220224123620.57fd6c8b@p-imbrenda>



On 24.02.22 12:36, Claudio Imbrenda wrote:
> On Wed, 23 Feb 2022 18:44:20 +0200
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
>> While in this particular case it would not be a (critical) issue,
>> the pattern itself is bad and error prone in case somebody blindly
>> copies to their code.
>>
>> Don't cast parameter to unsigned long pointer in the bit operations.
>> Instead copy to a local variable on stack of a proper type and use.
>>
>> Fixes: d77e64141e32 ("KVM: s390: implement GISA IPM related primitives")
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>>   arch/s390/include/asm/kvm_host.h | 5 ++++-
>>   arch/s390/kvm/interrupt.c        | 6 +++---
>>   2 files changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
>> index a22c9266ea05..f1c4a1b9b360 100644
>> --- a/arch/s390/include/asm/kvm_host.h
>> +++ b/arch/s390/include/asm/kvm_host.h
>> @@ -867,7 +867,10 @@ struct kvm_s390_gisa {
>>   			u8  reserved03[11];
>>   			u32 airq_count;
>>   		} g1;
>> -		struct {
>> +		struct { /* as a 256-bit bitmap */
>> +			DECLARE_BITMAP(b, 256);
>> +		} bitmap;
>> +		struct { /* as a set of 64-bit words */
>>   			u64 word[4];
>>   		} u64;
>>   	};
>> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
>> index db933c252dbc..04e055cbd080 100644
>> --- a/arch/s390/kvm/interrupt.c
>> +++ b/arch/s390/kvm/interrupt.c
>> @@ -304,7 +304,7 @@ static inline int gisa_in_alert_list(struct kvm_s390_gisa *gisa)
>>   
>>   static inline void gisa_set_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
>>   {
>> -	set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
>> +	set_bit_inv(IPM_BIT_OFFSET + gisc, gisa->bitmap.b);
> 
> wouldn't it be enough to pass gisa->u64.word here?
> then no cast would be necessary


we do that at several places

arch/s390/kernel/processor.c:	for_each_set_bit_inv(bit, (long 
*)&stfle_fac_list, MAX_FACILITY_BIT)
arch/s390/kvm/interrupt.c:	set_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned 
long *) gisa);
arch/s390/kvm/kvm-s390.c:		set_bit_inv(vcpu->vcpu_id, (unsigned long *) 
sca->mcn);
arch/s390/kvm/kvm-s390.c:		set_bit_inv(vcpu->vcpu_id, (unsigned long *) 
&sca->mcn);

> 
>>   }
>>   
>>   static inline u8 gisa_get_ipm(struct kvm_s390_gisa *gisa)
>> @@ -314,12 +314,12 @@ static inline u8 gisa_get_ipm(struct kvm_s390_gisa *gisa)
>>   
>>   static inline void gisa_clear_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
>>   {
>> -	clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
>> +	clear_bit_inv(IPM_BIT_OFFSET + gisc, gisa->bitmap.b);
>>   }
>>   
>>   static inline int gisa_tac_ipm_gisc(struct kvm_s390_gisa *gisa, u32 gisc)
>>   {
>> -	return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, (unsigned long *) gisa);
>> +	return test_and_clear_bit_inv(IPM_BIT_OFFSET + gisc, gisa->bitmap.b);
>>   }
>>   
>>   static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu)
> 

  reply	other threads:[~2022-02-24 12:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 16:44 [PATCH v1 1/1] KVM: s390: Don't cast parameter in bit operations Andy Shevchenko
2022-02-24 11:36 ` Claudio Imbrenda
2022-02-24 12:10   ` Michael Mueller [this message]
2022-03-02 15:44     ` Andy Shevchenko
2022-03-02 17:18       ` Yury Norov
2022-03-02 17:31         ` Andy Shevchenko
2022-03-02 18:43           ` Yury Norov
2022-03-03 10:19             ` Andy Shevchenko
2022-02-24 19:51   ` Andy Shevchenko
2022-02-24 23:15     ` David Laight
2022-03-02 15:45 ` Andy Shevchenko

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=3640a910-60fe-0935-4dfc-55bb65a75ce5@linux.ibm.com \
    --to=mimu@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=svens@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox