From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yang Subject: Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits Date: Sat, 6 Oct 2018 07:08:49 +0000 Message-ID: <20181006070849.psgrrhiysnrytbjr@master> References: <20181006021127.zuic7afw42b3hzw2@master> <201810061131044868733@zte.com.cn> Reply-To: Wei Yang Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: richard.weiyang@gmail.com, penghao122@sina.com.cn, pbonzini@redhat.com, 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 To: peng.hao2@zte.com.cn Return-path: Content-Disposition: inline In-Reply-To: <201810061131044868733@zte.com.cn> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 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 >>> >>> modify AVIC_LOGICAL_ID_ENTRY_VALID_MASK to unsigned >>> >>>Signed-off-by: Peng Hao >>>--- >>> 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? >>-- >>Wei Yang >>Help you, Help me -- Wei Yang Help you, Help me