Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4178311imm; Mon, 15 Oct 2018 10:17:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vDQ3pLBH1coFi5QIh0GEb3CFX3nAYxSjlxI2Pl6ef4KbVEaoNZjao/oLkkgCd2Zmck1df X-Received: by 2002:a62:454d:: with SMTP id s74-v6mr18988470pfa.136.1539623872272; Mon, 15 Oct 2018 10:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539623872; cv=none; d=google.com; s=arc-20160816; b=GeRHPCaclWqUG6skbnNPBPjik2Df0h/Z64deTdNlehFlPtr/4dkSXME6GlbM2zycVy 4uqDY+CSti2xzSUGcXjFONAd198XsKA7Hg1zJzopmZhSuq4iBJRubNOrIxSnRVI2QTwF GivcOOMJXsdcm4PptRscvGmXU5DSLpplRi68COvb+crQyb8z+WRqE5LZ7u1/Tkx2aC8N PXTpWApcq9S7RFPTCaZeTylt8k0bEBqb5blHeXYkO1J13iknHe4BjWqS8QWd31YiUirf /r/BSRTKXWwBkpM+TbOJQ8r3xqtXeISwUOrkaPtzgR4OZOC7MDUA5tmpmT3mqrGPG5A8 Ah1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=FBt26GYzq1Ly0Pv0vWloPfjA1bI/U61XVicswkaWZBM=; b=KIlwrm6VpOQqXOlvvGkAgz+La/+PftsJxZnY33Df9WkDNgWRrSWKfuJJLKhXaSP9eq 79C20xGBN4X2E5E4Zqx3nQskV5S1917fD8NClNEU7fJn7TdNgLnSpbJNhNEDKUa3uzH/ ZXBtXYxSvovCvmAG7FckV9/H+nbDm2p5IqjPKNcreVGdmuXVDIGn653wNiCi5lVRbV/4 y0DFXotKuhOfuj5DD4L6Zq3fGqmZcTlyjnc9aPUlNJFkKl9rbDmXeb7x2mxT1EriTDPF 5wGJxtPSkqT1fqlP4vGZXAVyjAaYlDpgtCUT5C63V7BxWFcnBe3WeC40jfvSeEgDyVc9 ecJw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k198-v6si11411610pga.12.2018.10.15.10.17.35; Mon, 15 Oct 2018 10:17:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726815AbeJPBDU (ORCPT + 99 others); Mon, 15 Oct 2018 21:03:20 -0400 Received: from terminus.zytor.com ([198.137.202.136]:47105 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726585AbeJPBDU (ORCPT ); Mon, 15 Oct 2018 21:03:20 -0400 Received: from carbon-x1.hos.anvin.org (c-24-5-245-234.hsd1.ca.comcast.net [24.5.245.234] (may be forged)) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id w9FHGtRL3710778 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Mon, 15 Oct 2018 10:16:55 -0700 Subject: Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits To: peng.hao2@zte.com.cn, richard.weiyang@gmail.com Cc: penghao122@sina.com.cn, pbonzini@redhat.com, rkrcmar@redhat.com, tglx@linutronix.de, mingo@redhat.com, joro@8bytes.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, x86@kernel.org References: <201810080904344038939@zte.com.cn> From: "H. Peter Anvin" Message-ID: <717c02f3-bb36-33c4-a463-f5759fde30fd@zytor.com> Date: Mon, 15 Oct 2018 10:16:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <201810080904344038939@zte.com.cn> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/7/18 6:04 PM, peng.hao2@zte.com.cn wrote: \>>>>> >>>>> #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. The right way to do this would be to use the _BITUL() (or _BITULL()) macro. -hpa