Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1662981ioo; Sun, 22 May 2022 23:30:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQgb0LqQYwmMO156WHdkpK4WpMMl/izID65TNcZvYYJNM4+f6wcFZB/mCQsqxeKPzrin2G X-Received: by 2002:a63:2:0:b0:3f6:5b37:e94c with SMTP id 2-20020a630002000000b003f65b37e94cmr15542534pga.356.1653287452858; Sun, 22 May 2022 23:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653287452; cv=none; d=google.com; s=arc-20160816; b=UaPxPhXTjTKySknteU7ZCgwZ2R+j8xD52ReVIY2SXmrqLLasgNDl8qGBX0Xq2U8wGq 4o75eRuzgGutFLlwV0iKe+5jzwPfOgWyhQkaT978OzA3KlVatbLH0S6M2d1AG5pWUvL0 Haqd6KSg5nxtgsff7PehXuaQTf3SLmnTgGAMxonihXg5/tT5UeUuiNotvwv6U+oC1dTC d06B4iopOuLOeHuSaW6tXlOiDLfzP/9lxuqheTu7qWiKMvVxJQNp89i/v4OaY2AMT5Ea efDi1ZggkKHynGZSuDd88Tstpnd1QL+7E55eYSVE602TjgQONoUFr6YIqjrgFmQj2pGy ylaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to; bh=rFvkpi1Tll9+Wq7lX2nYCeTz0aTbu+GhjQ8gVAOUWKE=; b=B3frsL5E7Cj1Ut36gGTrv/6g8mQwou1TFEaFT2/t+jOmmtHPtpF940ivLQzSG6kpdZ pITiBFJOnxFjVZ3xU8v+Yk0QbUC4BQYt00z5LI3/TA38AebxlgSxEF47d5nJRf4GlNPU Fy/AsDFVY3pfAsNpsCf3wsF3jlRs3pDfDjQab1NIViGuXuMPmGdK8IulJOC3N+aw4ycM QdqUe8Sxafok1zteDSCMYWBHoboxNG273vuXVvfD0i++NHqAeXFBSPQasLOPLtZKwVYC vEYlZsW8en81cYLKju9AqweXlFroDFq18lzd1wmaOjxYu7KwgHOuNoagCukkuucwNgVV kw3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x14-20020a056a00188e00b0050de3100e2asi13392800pfh.97.2022.05.22.23.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 23:30:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=csail.mit.edu Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2EB313134A; Sun, 22 May 2022 23:08:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348519AbiETL3w (ORCPT + 99 others); Fri, 20 May 2022 07:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245486AbiETL3p (ORCPT ); Fri, 20 May 2022 07:29:45 -0400 Received: from outgoing-stata.csail.mit.edu (outgoing-stata.csail.mit.edu [128.30.2.210]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2A22215AB01 for ; Fri, 20 May 2022 04:29:40 -0700 (PDT) Received: from [77.23.249.31] (helo=srivatsab-a02.vmware.com) by outgoing-stata.csail.mit.edu with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1ns0p7-0005LB-Jg; Fri, 20 May 2022 07:29:37 -0400 To: Borislav Petkov , Shreenidhi Shedi Cc: amakhalov@vmware.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, virtualization@lists.linux-foundation.org, pv-drivers@vmware.com, x86@kernel.org, linux-kernel@vger.kernel.org, Shreenidhi Shedi References: <20220520072857.592746-1-sshedi@vmware.com> From: "Srivatsa S. Bhat" Subject: Re: [PATCH] x86/vmware: use unsigned integer for shifting Message-ID: Date: Fri, 20 May 2022 13:29:34 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Shreenidhi, Thank you for the patch! On 5/20/22 2:26 AM, Borislav Petkov wrote: > On Fri, May 20, 2022 at 12:58:57PM +0530, Shreenidhi Shedi wrote: >> Shifting signed 32-bit value by 31 bits is implementation-defined >> behaviour. Using unsigned is better option for this. >> Can you also add a "Fixes:" tag with the commit that introduced the issue? I believe it is 4cca6ea04d31 ("x86/apic: Allow x2apic without IR on VMware platform"). >> Signed-off-by: Shreenidhi Shedi >> --- >> arch/x86/kernel/cpu/vmware.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c >> index c04b933f48d3..b28f789d3c56 100644 >> --- a/arch/x86/kernel/cpu/vmware.c >> +++ b/arch/x86/kernel/cpu/vmware.c >> @@ -476,7 +476,7 @@ static bool __init vmware_legacy_x2apic_available(void) >> { >> uint32_t eax, ebx, ecx, edx; >> VMWARE_CMD(GETVCPU_INFO, eax, ebx, ecx, edx); >> - return (eax & (1 << VMWARE_CMD_VCPU_RESERVED)) == 0 && >> + return (eax & (1U << VMWARE_CMD_VCPU_RESERVED)) == 0 && >> (eax & (1 << VMWARE_CMD_LEGACY_X2APIC)) != 0; > > Or you can use the BIT() macro and simplify this expression even more: > > return !(eax & BIT(VMWARE_CMD_VCPU_RESERVED)) && > (eax & BIT(VMWARE_CMD_LEGACY_X2APIC)); > > That's better indeed. Regards, Srivatsa