Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1300925imm; Sat, 6 Oct 2018 00:09:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV61l1swvSKlslUJ5YPz7lrdKT2A0/hNFbA7jPqVJcGFIp1WeICklpYfSrfWg5CO4rPOv3Pkk X-Received: by 2002:a63:7044:: with SMTP id a4-v6mr13127112pgn.63.1538809752835; Sat, 06 Oct 2018 00:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538809752; cv=none; d=google.com; s=arc-20160816; b=b8ppgnvd9ehCCC+1/UZZ1mKme+wx8JRu+8yyBg1hQdNUZ/8NFVU0Sxd/OtFlUkBH9o O8XAVfFaI/l+780ocf2MsdG4hSRRjT9A8ZyFN1tbm5vn2ViVE8oRNqrnN2JIirhtsJLX AI8aqLY3r7g9i28pGczTSrg+B2ponjDBkxy23U2IKW+90gMDnV1yrHwgi8C5rPTZQXnB DfSsk0wW+Wba3ezhuIS89LZGQ3wo5yELoqxd4ygHR8u8XU9FpJJyCOPQhImvP8SVZGmV AomY13bWHrNqEwNzdk/VDvtBCO0w02ZK2yIXQxDZTB9UwzM2iQOsNIkY2do+gVAzKSen awmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=rYdkerL+oEjs8hpavllDRz7I2n00g7VSgU7jIPV6ljY=; b=MI8V3j1opt/qXAhYAu6kMZdhZmT+5AsG5QYXYWsBNQStMmHtIjZt4O2IjZsA9cmGHk r94idEdNzkEdMMqcRlFS/GQfjzlqUxDOjTGls0i/dUIs+Qs3jXZQmxTBceFJ8YhGXIwA wuxmh3NDiplPLzFSot3lMuBJtO/LWEuu0ZsHwJAF3AixrMiYS3Siof6XnpvmGH0krDxU 6MG3K4Wyo/H2/ReHxgYM6FRom0yDIAxBC+HHSGqYaEVxsvjQ9Ug5K56puhBxTKcb4kXr UlsXvOwMPjEl3VdhsFN8ILowcSpM67QusyhTnVvC6q9u7lSm6oz0TFV7yoP95bZO7f2o C1Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QrbwlHAL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l36-v6si11421045plg.289.2018.10.06.00.08.56; Sat, 06 Oct 2018 00:09:12 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QrbwlHAL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbeJFOLF (ORCPT + 99 others); Sat, 6 Oct 2018 10:11:05 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34554 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbeJFOLE (ORCPT ); Sat, 6 Oct 2018 10:11:04 -0400 Received: by mail-ed1-f66.google.com with SMTP id q19-v6so13490211edr.1; Sat, 06 Oct 2018 00:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rYdkerL+oEjs8hpavllDRz7I2n00g7VSgU7jIPV6ljY=; b=QrbwlHALdWwdRGQ1a0RPqj/G9TwQHFcFE0x9I+5Czvb0+UEgm6lSDKLHci//HjzdGw 2cJloYuPUsDbJiRjkmMllFb+bTdKvZuPfo9KyKZsnmspC1rlQhB+8BErEbdPv1DOjOSt ifyGi08mdfv/iLXmm+p3RgxTmHV9JFYFSVoj/dkPxbQOOCim7u9tHhvhKVBC43siCi/C 6p8qqkhoiLX1azp6K4OXFwBr5gMIQ3hgBV7P7WeGgR4k3QpTWviGhpZKd32/IFlJkYYr OqjcObLK74bNzSt5NJNGtgb7aDQHk+2K/pAZxaeeBDcgGZeyZpstI3k1p0ZsoasbCwbl ewFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:reply-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=rYdkerL+oEjs8hpavllDRz7I2n00g7VSgU7jIPV6ljY=; b=MzGHZ+kqUIVT4DAvGsSOAqjXric/V83+n5gdeEm5xUC/Imo8H0wma+fHPRASSR/j8e trqXMZuXPJq0yOu+CTA0mXIfwQROQMU2xaNr5ZQSlh8OUyHt9GSGNVJkwS1tJZWIj8Sw 6XJ5kzYqxVciU2FQzfpySPsudVGSVkWEAANvvpwwEVKQloh4kfcoco72DvDILpo5Q6f0 QdfI+VBPTnRDsHqcYhCNSMGVYi5RvKopi1Y8dKCBE8QEJF3Jcwy3MCNNFMM9yJUYh5pz ARZ+eewaBuF6wJq4SWmDRax7awCslBYu6Aj/1CIVQbjLs4c7jhfqNtS9HI4IPUHLhSj9 T1MA== X-Gm-Message-State: ABuFfoisRs+X/tPVvQI5jitvVWCtOdLS7nQk28gyNzkdeRem5qc7KQqy v5KXCURpjdap2e9JKWMogaE= X-Received: by 2002:a50:ac76:: with SMTP id w51-v6mr18152632edc.211.1538809730611; Sat, 06 Oct 2018 00:08:50 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id 18-v6sm906476edt.34.2018.10.06.00.08.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 06 Oct 2018 00:08:49 -0700 (PDT) Date: Sat, 6 Oct 2018 07:08:49 +0000 From: Wei Yang To: peng.hao2@zte.com.cn 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 Subject: Re: [PATCH] kvm/x86 : avoid shifting signed 32-bit value by 31 bits Message-ID: <20181006070849.psgrrhiysnrytbjr@master> Reply-To: Wei Yang References: <20181006021127.zuic7afw42b3hzw2@master> <201810061131044868733@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201810061131044868733@zte.com.cn> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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