Message ID | 20230411064815.31456-12-baolu.lu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2373184vqo; Mon, 10 Apr 2023 23:55:03 -0700 (PDT) X-Google-Smtp-Source: AKy350ZUf6dhYT2g+mGsiA+UaIDAQ6DTS3UlPv4yQe8Qo7IZcycXMuUU6H8lFaWkXK+qWPSpm8yn X-Received: by 2002:a05:6402:31e3:b0:504:8c65:d277 with SMTP id dy3-20020a05640231e300b005048c65d277mr7808571edb.19.1681196103587; Mon, 10 Apr 2023 23:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681196103; cv=none; d=google.com; s=arc-20160816; b=FbbMC0a0hKu6eV1/hNA5jSg7oxZPUeKFyhNpTi1iDHmID7QWWNSm0h9/wV84VZ+w+s 9H+CTm03csjdY9O3J7JGt7DWiBExl3KxRRVDID2ol8mCUs1oKjMiRe2QAlVpbx/8LWNC Scz4miuaI2f0gzNQqpCvDleVbTXmqs2LxVPLmuzmPYTeJKb+59gwUeMsZaBYr/c1+HwF 7P4b3bSmVIDZKnqxHMPTOzniOkFkILLo3Zne+pDJ61lYgmhvjvUbVSiXr06lmDlcgeYs 8o8GLRLpV3tzU5R9TvDvZOPNaGsFERGnUbmCgJIlrTw3JwC0UClI8py26Cezd7SZEsNV 0uyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3rgJUuhznbz7+IKrs6uwZfwZ9X3MmjI0xiAcLTwmTw0=; b=QF81Z16oT6Dj7HmLJRn0jp05UcGINp60ATYMiV+Y6T5EzUP/jwWebV5gzXhi8YT3i6 qhHeCtC2UYvbrCuHreoh6InknZI2+qVSvFL3A5azLd+uZtXXuxhreD+T+HNSKeOYaRaT 69ElqE7eKgxxI8BLxGS2hX6Rwjm/WPfod4MUzVLkeXKB6l7zM3pLRpNnzLxWiWCpc/3z vzQsFmu5N+8EekUVDSmua4E+EDd/KAD4cd5R+ccUCte99BRzdOH9v8/S52Us78zNbkpv 7vDWEV60L7vv4DEZ3y5g6ah/7hFBg2xwlnmZdEilEWJuFQCBZ2izTF20A467LjKt305l 7iDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dwVhYuC2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a056402020200b005049b7f3dcasi4571739edv.661.2023.04.10.23.54.39; Mon, 10 Apr 2023 23:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dwVhYuC2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbjDKGuj (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Tue, 11 Apr 2023 02:50:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjDKGuR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Apr 2023 02:50:17 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BB7E423F for <linux-kernel@vger.kernel.org>; Mon, 10 Apr 2023 23:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681195784; x=1712731784; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fHc/Dt3WZSFDnH//DR0PtW4o8sOEHZYZ41tbx+9UmIU=; b=dwVhYuC2L1KsP/sTK63g3tc+rivKc/wENqYW8HWayZq2XZqNBc1r0RFe TYmd8gUEfEB7fR3S3nBuCfXv4cbcDZDyAeHUQJjIpjzHMQBQW4mv5/B5v P8VlcFxG/ymsuzAT96l7eIEujR+56Vrkm2/a6rcyKdKUIfcGZ1zU/rbIt T3kzz1pHBTOf9TguFoozkGjqdeLiRrpIdDdFmucQd7TWUwQnsdU1X146J oCQI4RX/bMUPEs245jCbxTAmElITh2wL/L5e/lamg8leiLXJ/R0dwTYnT KGPhSZIRohnIJzaGrvU+hQ7TfH+GesVjYHivmpTYNeOZdyi2AaUpXolmG A==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="341028600" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="341028600" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2023 23:48:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="1018256620" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="1018256620" Received: from allen-box.sh.intel.com ([10.239.159.127]) by fmsmga005.fm.intel.com with ESMTP; 10 Apr 2023 23:48:33 -0700 From: Lu Baolu <baolu.lu@linux.intel.com> To: Joerg Roedel <joro@8bytes.org> Cc: Vinod Koul <vkoul@kernel.org>, Tina Zhang <tina.zhang@intel.com>, Jacob Pan <jacob.jun.pan@linux.intel.com>, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 11/17] iommu/vt-d: Fix operand size in bitwise operation Date: Tue, 11 Apr 2023 14:48:09 +0800 Message-Id: <20230411064815.31456-12-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230411064815.31456-1-baolu.lu@linux.intel.com> References: <20230411064815.31456-1-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762861885541159703?= X-GMAIL-MSGID: =?utf-8?q?1762861885541159703?= |
Series |
Intel IOMMU updates for Linux v6.4
|
|
Commit Message
Baolu Lu
April 11, 2023, 6:48 a.m. UTC
From: Tina Zhang <tina.zhang@intel.com> The patch fixes the klocwork issues that operands in a bitwise operation have different size at line 1692 of dmar.c, line 1898 and line 1907 of iommu.c. Reported-by: Yongwei Ma <yongwei.ma@intel.com> Signed-off-by: Tina Zhang <tina.zhang@intel.com> Link: https://lore.kernel.org/r/20230406065944.2773296-2-tina.zhang@intel.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> --- drivers/iommu/intel/dmar.c | 2 +- drivers/iommu/intel/iommu.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Comments
From: Lu Baolu > Sent: 11 April 2023 07:48 > > From: Tina Zhang <tina.zhang@intel.com> > > The patch fixes the klocwork issues that operands in a bitwise operation > have different size at line 1692 of dmar.c, line 1898 and line 1907 of > iommu.c. Why is this any kind of thing that needs fixing? David > Reported-by: Yongwei Ma <yongwei.ma@intel.com> > Signed-off-by: Tina Zhang <tina.zhang@intel.com> > Link: https://lore.kernel.org/r/20230406065944.2773296-2-tina.zhang@intel.com > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> > --- > drivers/iommu/intel/dmar.c | 2 +- > drivers/iommu/intel/iommu.c | 4 ++-- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c > index 23828d189c2a..f0f51c957ccb 100644 > --- a/drivers/iommu/intel/dmar.c > +++ b/drivers/iommu/intel/dmar.c > @@ -1690,7 +1690,7 @@ static void __dmar_enable_qi(struct intel_iommu *iommu) > * is present. > */ > if (ecap_smts(iommu->ecap)) > - val |= (1 << 11) | 1; > + val |= BIT_ULL(11) | BIT_ULL(0); > > raw_spin_lock_irqsave(&iommu->register_lock, flags); > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index f4e536fd5a28..acbf82fa90e7 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -1870,7 +1870,7 @@ context_set_sm_rid2pasid(struct context_entry *context, unsigned long pasid) > */ > static inline void context_set_sm_dte(struct context_entry *context) > { > - context->lo |= (1 << 2); > + context->lo |= BIT_ULL(2); > } > > /* > @@ -1879,7 +1879,7 @@ static inline void context_set_sm_dte(struct context_entry *context) > */ > static inline void context_set_sm_pre(struct context_entry *context) > { > - context->lo |= (1 << 4); > + context->lo |= BIT_ULL(4); > } > > /* Convert value to context PASID directory size field coding. */ > -- > 2.34.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On 4/12/23 5:22 AM, David Laight wrote: >> Sent: 11 April 2023 07:48 >> >> From: Tina Zhang<tina.zhang@intel.com> >> >> The patch fixes the klocwork issues that operands in a bitwise operation >> have different size at line 1692 of dmar.c, line 1898 and line 1907 of >> iommu.c. > Why is this any kind of thing that needs fixing? This description is a bit misleading. Actually I queued it as a cleanup patch. Best regards, baolu
From: Baolu Lu > Sent: 12 April 2023 02:32 > > On 4/12/23 5:22 AM, David Laight wrote: > >> Sent: 11 April 2023 07:48 > >> > >> From: Tina Zhang<tina.zhang@intel.com> > >> > >> The patch fixes the klocwork issues that operands in a bitwise operation > >> have different size at line 1692 of dmar.c, line 1898 and line 1907 of > >> iommu.c. > > Why is this any kind of thing that needs fixing? > > This description is a bit misleading. Actually I queued it as a cleanup > patch. Hopefully without 'fix' anywhere in the description. Otherwise the scripts will pick it for a back-port. > > - val |= (1 << 11) | 1; > > + val |= BIT_ULL(11) | BIT_ULL(0); More problematic it what is bit 11 anyway? David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Hi David, > -----Original Message----- > From: David Laight <David.Laight@ACULAB.COM> > Sent: Wednesday, April 12, 2023 3:11 PM > To: 'Baolu Lu' <baolu.lu@linux.intel.com>; Joerg Roedel <joro@8bytes.org> > Cc: Vinod Koul <vkoul@kernel.org>; Zhang, Tina <tina.zhang@intel.com>; Jacob > Pan <jacob.jun.pan@linux.intel.com>; Christophe JAILLET > <christophe.jaillet@wanadoo.fr>; iommu@lists.linux.dev; linux- > kernel@vger.kernel.org > Subject: RE: [PATCH 11/17] iommu/vt-d: Fix operand size in bitwise operation > > From: Baolu Lu > > Sent: 12 April 2023 02:32 > > > > On 4/12/23 5:22 AM, David Laight wrote: > > >> Sent: 11 April 2023 07:48 > > >> > > >> From: Tina Zhang<tina.zhang@intel.com> > > >> > > >> The patch fixes the klocwork issues that operands in a bitwise > > >> operation have different size at line 1692 of dmar.c, line 1898 and > > >> line 1907 of iommu.c. > > > Why is this any kind of thing that needs fixing? > > > > This description is a bit misleading. Actually I queued it as a > > cleanup patch. > > Hopefully without 'fix' anywhere in the description. > Otherwise the scripts will pick it for a back-port. Sure. > > > > - val |= (1 << 11) | 1; > > > + val |= BIT_ULL(11) | BIT_ULL(0); > > More problematic it what is bit 11 anyway? The magic number should be removed from here. Regards, -Tina > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 > 1PT, UK Registration No: 1397386 (Wales)
On 2023/4/12 15:11, David Laight wrote: > From: Baolu Lu >> Sent: 12 April 2023 02:32 >> >> On 4/12/23 5:22 AM, David Laight wrote: >>>> Sent: 11 April 2023 07:48 >>>> >>>> From: Tina Zhang<tina.zhang@intel.com> >>>> >>>> The patch fixes the klocwork issues that operands in a bitwise operation >>>> have different size at line 1692 of dmar.c, line 1898 and line 1907 of >>>> iommu.c. >>> Why is this any kind of thing that needs fixing? >> >> This description is a bit misleading. Actually I queued it as a cleanup >> patch. > > Hopefully without 'fix' anywhere in the description. > Otherwise the scripts will pick it for a back-port. Fair enough.I will refine the commit message like below: iommu/vt-d: Make size of operands same in bitwise operations The addresses the following issue reported by klocwork tool: - operands of different size in bitwise operations Suggested-by: Yongwei Ma <yongwei.ma@intel.com> Signed-off-by: Tina Zhang <tina.zhang@intel.com> > >>> - val |= (1 << 11) | 1; >>> + val |= BIT_ULL(11) | BIT_ULL(0); > > More problematic it what is bit 11 anyway? There is already a comment at the top of the code explaining the meaning of these bits. Because this is not a newly added code, it is not displayed in this patch. /* * Set DW=1 and QS=1 in IQA_REG when Scalable Mode capability * is present. */ if (ecap_smts(iommu->ecap)) val |= BIT_ULL(11) | BIT_ULL(0); Best regards, baolu
From: Baolu Lu > Sent: 12 April 2023 14:11 ... > The addresses the following issue reported by klocwork tool: > > - operands of different size in bitwise operations Then fix the stupid tool to not be that pedantic. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
On 2023/4/12 21:27, David Laight wrote: > From: Baolu Lu >> Sent: 12 April 2023 14:11 > ... >> The addresses the following issue reported by klocwork tool: >> >> - operands of different size in bitwise operations > Then fix the stupid tool to not be that pedantic. Good idea. But before the users/customers stop complaining, let's have a cleanup like this. :-) Best regards, baolu
diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 23828d189c2a..f0f51c957ccb 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1690,7 +1690,7 @@ static void __dmar_enable_qi(struct intel_iommu *iommu) * is present. */ if (ecap_smts(iommu->ecap)) - val |= (1 << 11) | 1; + val |= BIT_ULL(11) | BIT_ULL(0); raw_spin_lock_irqsave(&iommu->register_lock, flags); diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index f4e536fd5a28..acbf82fa90e7 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -1870,7 +1870,7 @@ context_set_sm_rid2pasid(struct context_entry *context, unsigned long pasid) */ static inline void context_set_sm_dte(struct context_entry *context) { - context->lo |= (1 << 2); + context->lo |= BIT_ULL(2); } /* @@ -1879,7 +1879,7 @@ static inline void context_set_sm_dte(struct context_entry *context) */ static inline void context_set_sm_pre(struct context_entry *context) { - context->lo |= (1 << 4); + context->lo |= BIT_ULL(4); } /* Convert value to context PASID directory size field coding. */