The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Wei Yang <richard.weiyang@gmail.com>, peng.hao2@zte.com.cn
Cc: penghao122@sina.com.cn, rkrcmar@redhat.com, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com, joro@8bytes.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	x86@kernel.org
Subject: Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits
Date: Mon, 15 Oct 2018 19:12:30 +0200	[thread overview]
Message-ID: <b5d38cfe-b617-835c-8444-9419f95bea1c@redhat.com> (raw)
In-Reply-To: <20181008022532.4ve2xww4yphk6f5d@master>

On 08/10/2018 04:25, Wei Yang wrote:
> On Mon, Oct 08, 2018 at 09:04:34AM +0800, peng.hao2@zte.com.cn wrote:
>>> On Sat, Oct 06, 2018 at 11:31:04AM +0800, peng.hao2@zte.com.cn wrote:
>>>>> On Thu, Oct 04, 2018 at 01:47:18PM -0400, Peng Hao wrote:
>>>>>>
>>>>>> From: Peng Hao <peng.hao2@zte.com.cn>
>>>>>>
>>>>>>  modify AVIC_LOGICAL_ID_ENTRY_VALID_MASK to unsigned
>>>>>>
>>>>>> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
>>>>>> ---
>>>>>> arch/x86/kvm/svm.c | 2 +-
>>>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>>>>>> index d96092b..bf1ded4 100644
>>>>>> --- a/arch/x86/kvm/svm.c
>>>>>> +++ b/arch/x86/kvm/svm.c
>>>>>> @@ -262,7 +262,7 @@ struct amd_svm_iommu_ir {
>>>>>> };
>>>>>>
>>>>>> #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK    (0xFF)
>>>>>> -#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK        (1 << 31)
>>>>>> +#define AVIC_LOGICAL_ID_ENTRY_VALID_MASK        (1UL << 31)
>>>>
>>>>> It is reasonable to change to unsigned, while not necessary to unsigned
>>>>> long?
>>>> AVIC_LOGICAL_ID_ENTRY_VALID_MASK is used in function avic_ldr_write.
>>>> here I think it doesn't matter if you use unsigned or unsigned long. Do you have any suggestions?
>>
>>> In current case, AVIC_LOGICAL_ID_ENTRY_VALID_MASK is used to calculate
>>> the value of new_entry with type of u32. So the definition here is not
>>> harmful.
>>
>>> Also, I did a quick grep and found similar definition (1 << 31) is popular
>>> in the whole kernel tree.
>>
>>> The reason to make this change is not that strong to me. Would you
>>> minding sharing more reason behind this change?
>> oh, I'm just thinking logically, not more reason.
> 
> This definition may introduce problem when this value is used to
> calculate a 64bit data.
> 
> Since current entry is 32bit, we may leave it as it is for now.

I agree.

Paolo


  reply	other threads:[~2018-10-15 17:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04 17:47 [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits Peng Hao
2018-10-06  2:11 ` Wei Yang
     [not found]   ` <201810061131044868733@zte.com.cn>
2018-10-06  7:08     ` Wei Yang
     [not found]       ` <201810080904344038939@zte.com.cn>
2018-10-08  2:25         ` Wei Yang
2018-10-15 17:12           ` Paolo Bonzini [this message]
2018-10-15 17:16         ` H. Peter Anvin
2018-10-15 17:23           ` Paolo Bonzini
2018-10-15 17:30             ` H. Peter Anvin

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=b5d38cfe-b617-835c-8444-9419f95bea1c@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peng.hao2@zte.com.cn \
    --cc=penghao122@sina.com.cn \
    --cc=richard.weiyang@gmail.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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