Message ID | 20230329170619.183064-2-saikrishnag@marvell.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 b10csp580276vqo; Wed, 29 Mar 2023 10:37:27 -0700 (PDT) X-Google-Smtp-Source: AKy350ap5lE1o/WZK7akUR0EWyNjSE46Cv6a5vj9BYIb8gMMOL+PvYnV9x4OVlkCUTCCGfDaj9Wx X-Received: by 2002:a17:907:a50f:b0:8e6:bcb6:469e with SMTP id vr15-20020a170907a50f00b008e6bcb6469emr22821611ejc.0.1680111447199; Wed, 29 Mar 2023 10:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680111447; cv=none; d=google.com; s=arc-20160816; b=BoL3Vfx1bmu+Cz4nrvx36d9PNSJHff3gUsOj2lbiePPg24Xx3Ibk5FedV1pADK2CXX qPFNGcNtUP6kYslJlb1jPpX2NXGYCEjbYR7ZFhL3oCh6/CEG3+Ldjpm2NbgprbJRZQsg Zpnn0B63jww6j5C0TOGswiHog1qNToSUQB9qNE+MOdjXCNBoLzRePyCPbNCvxVGWVS31 Zcr8HbonFiwqL8LjATMaaMf71MzYyb7yq+21LaI263APIYegnArLVFJoINS02G1uhCFP ACaT8s6b5RiqOljN33p+Oz7TrlKeIN5eTtxHUMjLW0I3QdL3DYHLjFDMFTs+gl2My023 q16w== 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=aJ4BaAT3AGcAdjDo2xWVNbwi49MYlxqi2NK5V4zd0ms=; b=M73/GjbVJ5z3ip1HgPxGqb6aqSoOAMlWsAUIqNMQWhdYb8sqsYv4oWVoTPjlt4wfQ4 ATx9v/SAoBeUuCVx1Cc+WBEjVB4peGaDVoNDPuSvbRxGL17QHgrJtL60jBVsWg6T9zhO 8dMtT3utfwpaOc0uyTgMAby2v/Pkx2xOVvehvIwxRMBXB8iBMDk6x1eAtg+/3P5CGUlV fNX9CqyJRRoaSgQTstzY76cndkKjzsCwarRF0QmbKc0+WBzAGNPJgETsdIFxpYMe+SWv LwKMMOwjaNOceOpGatU4WMqcuBjX8TJhrdlbELnDNH+1MyHJwJ2Kk6v15MUIc0fyqgCs iPsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=ixf8laCR; 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=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn7-20020a17090794c700b00944d95c1f2dsi9186833ejc.541.2023.03.29.10.37.04; Wed, 29 Mar 2023 10:37:27 -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=@marvell.com header.s=pfpt0220 header.b=ixf8laCR; 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=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231536AbjC2RKq (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Wed, 29 Mar 2023 13:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231402AbjC2RKP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 29 Mar 2023 13:10:15 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE4D45276; Wed, 29 Mar 2023 10:09:26 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32TFobCU032164; Wed, 29 Mar 2023 10:09:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=aJ4BaAT3AGcAdjDo2xWVNbwi49MYlxqi2NK5V4zd0ms=; b=ixf8laCR8w83NOcjv7pjzD5Cqxb3YCyOxsiO4lrarWtoBhnMr4KTRS/xJN2GxDvaZgPB ZsTAnL3+DN8XCSb4etL1orPRU4pV1qqnaKhde+H9zrPVOa34mnHh6x9nPqhrtg2ZTWUv Sh0/7yhhWZmGhRWxJsfpAXjfNhMc8NlZfbLS3D+M3tmuDj5TRDnF9v+rxiWZpVp/RuV/ 3IWfuGM5aj1bpUdFNaEbNZTzSloy7ascHz7EB8gaX38FMETCMeMIxXg4EXVxaQ27Og9G l4Y9psf85J2jOgdZwCOg36AvX28LYr3xQ+lkHtZpadTo+DSePhVmTc9Ez2EfVIWaQ1U7 RQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3pmhc4a0jv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 29 Mar 2023 10:09:15 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 29 Mar 2023 10:06:47 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 29 Mar 2023 10:06:47 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 134633F7054; Wed, 29 Mar 2023 10:06:43 -0700 (PDT) From: Sai Krishna <saikrishnag@marvell.com> To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <sgoutham@marvell.com>, <richardcochran@gmail.com> CC: Geetha sowjanya <gakula@marvell.com>, Sai Krishna <saikrishnag@marvell.com> Subject: [net PATCH 1/7] octeontx2-af: Secure APR table update with the lock Date: Wed, 29 Mar 2023 22:36:13 +0530 Message-ID: <20230329170619.183064-2-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230329170619.183064-1-saikrishnag@marvell.com> References: <20230329170619.183064-1-saikrishnag@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: -PLAjqLFZZ0-tnJWnSD6MGLJu9SqHYNA X-Proofpoint-GUID: -PLAjqLFZZ0-tnJWnSD6MGLJu9SqHYNA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-29_10,2023-03-28_02,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1761724541003689957?= X-GMAIL-MSGID: =?utf-8?q?1761724541003689957?= |
Series |
octeontx2: Miscellaneous fixes
|
|
Commit Message
Sai Krishna Gajula
March 29, 2023, 5:06 p.m. UTC
From: Geetha sowjanya <gakula@marvell.com> APR table contains the lmtst base address of PF/VFs. These entries are updated by the PF/VF during the device probe. Due to race condition while updating the entries are getting corrupted. Hence secure the APR table update with the lock. Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST regions") Signed-off-by: Geetha sowjanya <gakula@marvell.com> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> Signed-off-by: Sai Krishna <saikrishnag@marvell.com> --- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Comments
On Wed, Mar 29, 2023 at 10:36:13PM +0530, Sai Krishna wrote: > From: Geetha sowjanya <gakula@marvell.com> > > APR table contains the lmtst base address of PF/VFs. > These entries are updated by the PF/VF during the > device probe. Due to race condition while updating the > entries are getting corrupted. Hence secure the APR > table update with the lock. However, I don't see rsrc_lock in probe path. otx2_probe() -> cn10k_lmtst_init() -> lmt_base/lmstst is updated with and without mbox.lock. Where did you take rsrc_lock in probe flow? Thanks > > Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST regions") > Signed-off-by: Geetha sowjanya <gakula@marvell.com> > Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> > Signed-off-by: Sai Krishna <saikrishnag@marvell.com> > --- > drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > index 4ad9ff025c96..8530250f6fba 100644 > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > * region, if so, convert that IOVA to physical address and > * populate LMT table with that address > */ > + mutex_lock(&rvu->rsrc_lock); > if (req->use_local_lmt_region) { > err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, > req->lmt_iova, &lmt_addr); > if (err < 0) > - return err; > + goto error; > > /* Update the lmt addr for this PFFUNC in the LMT table */ > err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); > if (err) > - return err; > + goto error; > } > > /* Reconfiguring lmtst map table in lmt region shared mode i.e. make > @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > */ > err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); > if (err) > - return err; > + goto error; > } > > /* This mailbox can also be used to update word1 of APR_LMT_MAP_ENTRY_S > @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > } > > error: > + mutex_unlock(&rvu->rsrc_lock); > return err; > } > > -- > 2.25.1 >
>-----Original Message----- >From: Leon Romanovsky <leon@kernel.org> >Sent: Thursday, March 30, 2023 11:26 AM >To: Sai Krishna Gajula <saikrishnag@marvell.com> >Cc: davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Sunil Kovvuri Goutham <sgoutham@marvell.com>; >richardcochran@gmail.com; Geethasowjanya Akula <gakula@marvell.com> >Subject: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table update with the lock >External Email >---------------------------------------------------------------------- >On Wed, Mar 29, 2023 at 10:36:13PM +0530, Sai Krishna wrote: >> From: Geetha sowjanya <gakula@marvell.com> >> >> APR table contains the lmtst base address of PF/VFs. >> These entries are updated by the PF/VF during the device probe. Due to >> race condition while updating the entries are getting corrupted. Hence >> secure the APR table update with the lock. >However, I don't see rsrc_lock in probe path. >otx2_probe() >-> cn10k_lmtst_init() > -> lmt_base/lmstst is updated with and without mbox.lock. >Where did you take rsrc_lock in probe flow? rsrc_lock is initialized in AF driver. PF/VF driver in cn10k_lmtst_init() send a mbox request to AF to update the lmtst table. mbox handler in AF takes rsrc_lock to update lmtst table. Thanks, Geetha. >Thanks >> >> Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST >> regions") >> Signed-off-by: Geetha sowjanya <gakula@marvell.com> >> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> >> Signed-off-by: Sai Krishna <saikrishnag@marvell.com> >> --- >> drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> index 4ad9ff025c96..8530250f6fba 100644 >> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> * region, if so, convert that IOVA to physical address and >> * populate LMT table with that address >> */ >> + mutex_lock(&rvu->rsrc_lock); >> if (req->use_local_lmt_region) { >> err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, >> req->lmt_iova, &lmt_addr); >> if (err < 0) >> - return err; >> + goto error; >> >> /* Update the lmt addr for this PFFUNC in the LMT table */ >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); >> if (err) >> - return err; >> + goto error; >> } >> >> /* Reconfiguring lmtst map table in lmt region shared mode i.e. make >> @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> */ >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); >> if (err) >> - return err; >> + goto error; >> } >> >> /* This mailbox can also be used to update word1 of >> APR_LMT_MAP_ENTRY_S @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> } >> >> error: >> + mutex_unlock(&rvu->rsrc_lock); >> return err; >> } >> >> -- >> 2.25.1 >>
On Thu, Mar 30, 2023 at 06:56:54AM +0000, Geethasowjanya Akula wrote: > > >-----Original Message----- > >From: Leon Romanovsky <leon@kernel.org> > >Sent: Thursday, March 30, 2023 11:26 AM > >To: Sai Krishna Gajula <saikrishnag@marvell.com> > >Cc: davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Sunil Kovvuri Goutham <sgoutham@marvell.com>; >richardcochran@gmail.com; Geethasowjanya Akula <gakula@marvell.com> > >Subject: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table update with the lock > > >External Email > > >---------------------------------------------------------------------- > >On Wed, Mar 29, 2023 at 10:36:13PM +0530, Sai Krishna wrote: > >> From: Geetha sowjanya <gakula@marvell.com> > >> > >> APR table contains the lmtst base address of PF/VFs. > >> These entries are updated by the PF/VF during the device probe. Due to > >> race condition while updating the entries are getting corrupted. Hence > >> secure the APR table update with the lock. > > >However, I don't see rsrc_lock in probe path. > >otx2_probe() > >-> cn10k_lmtst_init() > > -> lmt_base/lmstst is updated with and without mbox.lock. > > >Where did you take rsrc_lock in probe flow? > > rsrc_lock is initialized in AF driver. PF/VF driver in cn10k_lmtst_init() send a mbox request to AF to update the lmtst table. > mbox handler in AF takes rsrc_lock to update lmtst table. Can you please present the stack trace of such flow? What are the actual variables/struct rsrc_lock is protecting? Thanks > > Thanks, > Geetha. > > >Thanks > > >> > >> Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable LMTST > >> regions") > >> Signed-off-by: Geetha sowjanya <gakula@marvell.com> > >> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> > >> Signed-off-by: Sai Krishna <saikrishnag@marvell.com> > >> --- > >> drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- > >> 1 file changed, 5 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > >> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > >> index 4ad9ff025c96..8530250f6fba 100644 > >> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > >> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c > >> @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > >> * region, if so, convert that IOVA to physical address and > >> * populate LMT table with that address > >> */ > >> + mutex_lock(&rvu->rsrc_lock); > >> if (req->use_local_lmt_region) { > >> err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, > >> req->lmt_iova, &lmt_addr); > >> if (err < 0) > >> - return err; > >> + goto error; > >> > >> /* Update the lmt addr for this PFFUNC in the LMT table */ > >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); > >> if (err) > >> - return err; > >> + goto error; > >> } > >> > >> /* Reconfiguring lmtst map table in lmt region shared mode i.e. make > >> @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > >> */ > >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); > >> if (err) > >> - return err; > >> + goto error; > >> } > >> > >> /* This mailbox can also be used to update word1 of > >> APR_LMT_MAP_ENTRY_S @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, > >> } > >> > >> error: > >> + mutex_unlock(&rvu->rsrc_lock); > >> return err; > >> } > >> > >> -- > >> 2.25.1 > >>
>-----Original Message----- >From: Leon Romanovsky <leon@kernel.org> >Sent: Thursday, March 30, 2023 12:46 PM >To: Geethasowjanya Akula <gakula@marvell.com> >Cc: Sai Krishna Gajula <saikrishnag@marvell.com>; davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Sunil >Kovvuri Goutham <sgoutham@marvell.com>; richardcochran@gmail.com >Subject: Re: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table update with the lock > >On Thu, Mar 30, 2023 at 06:56:54AM +0000, Geethasowjanya Akula wrote: >> >> >-----Original Message----- >> >From: Leon Romanovsky <leon@kernel.org> >> >Sent: Thursday, March 30, 2023 11:26 AM >> >To: Sai Krishna Gajula <saikrishnag@marvell.com> >> >Cc: davem@davemloft.net; edumazet@google.com; kuba@kernel.org; >> >pabeni@redhat.com; netdev@vger.kernel.org; >> >linux-kernel@vger.kernel.org; Sunil Kovvuri Goutham >> ><sgoutham@marvell.com>; >richardcochran@gmail.com; Geethasowjanya >> >Akula <gakula@marvell.com> >> >Subject: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table >> >update with the lock >> >> >External Email >> >> >--------------------------------------------------------------------- >> >- On Wed, Mar 29, 2023 at 10:36:13PM +0530, Sai Krishna wrote: >> >> From: Geetha sowjanya <gakula@marvell.com> >> >> >> >> APR table contains the lmtst base address of PF/VFs. >> >> These entries are updated by the PF/VF during the device probe. Due >> >> to race condition while updating the entries are getting corrupted. >> >> Hence secure the APR table update with the lock. >> >> >However, I don't see rsrc_lock in probe path. >> >otx2_probe() >> >-> cn10k_lmtst_init() >> > -> lmt_base/lmstst is updated with and without mbox.lock. >> >> >Where did you take rsrc_lock in probe flow? >> >> rsrc_lock is initialized in AF driver. PF/VF driver in cn10k_lmtst_init() send a mbox request to AF to update the lmtst table. >> mbox handler in AF takes rsrc_lock to update lmtst table. >Can you please present the stack trace of such flow? What are the actual variables/struct rsrc_lock is protecting? The lock tries to protect the request and response register at line#73 and line#83 in below function, from getting overwritten when Multiple PFs invokes rvu_get_lmtaddr() simultaneously. For example, if PF1 submit the request at line#73 and got permitted before it reads the response at line#80. PF2 got scheduled submit the request then the response of PF1 is overwritten by the PF2 response. When PF1 gets reschedule, it reads wrong data. #static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc, 59 u64 iova, u64 *lmt_addr) 60 { 61 [...] 68 69 rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_REQ, iova); 70 pf = rvu_get_pf(pcifunc) & 0x1F; 71 val = BIT_ULL(63) | BIT_ULL(14) | BIT_ULL(13) | pf << 8 | 72 ((pcifunc & RVU_PFVF_FUNC_MASK) & 0xFF); 73 rvu_write64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_TXN_REQ, val); 74 75 err = rvu_poll_reg(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_RSP_STS, BIT_ULL(0), false); 76 if (err) { 77 dev_err(rvu->dev, "%s LMTLINE iova transulation failed\n", __func__); 78 return err; 79 } 80 val = rvu_read64(rvu, BLKADDR_RVUM, RVU_AF_SMMU_ADDR_RSP_STS); 81 if (val & ~0x1ULL) { 82 dev_err(rvu->dev, "%s LMTLINE iova transulation failed err:%llx\n", __func__, val); 83 return -EIO; 84 } 85 Thanks. >>Thanks >> >> Thanks, >> Geetha. >> >> >Thanks >> >> >> >> >> Fixes: 893ae97214c3 ("octeontx2-af: cn10k: Support configurable >> >> LMTST >> >> regions") >> >> Signed-off-by: Geetha sowjanya <gakula@marvell.com> >> >> Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com> >> >> Signed-off-by: Sai Krishna <saikrishnag@marvell.com> >> >> --- >> >> drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 8 +++++--- >> >> 1 file changed, 5 insertions(+), 3 deletions(-) >> >> >> >> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> >> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> >> index 4ad9ff025c96..8530250f6fba 100644 >> >> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> >> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c >> >> @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> >> * region, if so, convert that IOVA to physical address and >> >> * populate LMT table with that address >> >> */ >> >> + mutex_lock(&rvu->rsrc_lock); >> >> if (req->use_local_lmt_region) { >> >> err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, >> >> req->lmt_iova, &lmt_addr); >> >> if (err < 0) >> >> - return err; >> >> + goto error; >> >> >> >> /* Update the lmt addr for this PFFUNC in the LMT table */ >> >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); >> >> if (err) >> >> - return err; >> >> + goto error; >> >> } >> >> >> >> /* Reconfiguring lmtst map table in lmt region shared mode i.e. >> >> make @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> >> */ >> >> err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); >> >> if (err) >> >> - return err; >> >> + goto error; >> >> } >> >> >> >> /* This mailbox can also be used to update word1 of >> >> APR_LMT_MAP_ENTRY_S @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, >> >> } >> >> >> >> error: >> >> + mutex_unlock(&rvu->rsrc_lock); >> >> return err; >> >> } >> >> >> >> -- >> >> 2.25.1 >> >>
On Fri, Mar 31, 2023 at 08:56:59AM +0000, Geethasowjanya Akula wrote: > > > >-----Original Message----- > >From: Leon Romanovsky <leon@kernel.org> > >Sent: Thursday, March 30, 2023 12:46 PM > >To: Geethasowjanya Akula <gakula@marvell.com> > >Cc: Sai Krishna Gajula <saikrishnag@marvell.com>; davem@davemloft.net; edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Sunil >Kovvuri Goutham <sgoutham@marvell.com>; richardcochran@gmail.com > >Subject: Re: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table update with the lock > > > >On Thu, Mar 30, 2023 at 06:56:54AM +0000, Geethasowjanya Akula wrote: > >> > >> >-----Original Message----- > >> >From: Leon Romanovsky <leon@kernel.org> > >> >Sent: Thursday, March 30, 2023 11:26 AM > >> >To: Sai Krishna Gajula <saikrishnag@marvell.com> > >> >Cc: davem@davemloft.net; edumazet@google.com; kuba@kernel.org; > >> >pabeni@redhat.com; netdev@vger.kernel.org; > >> >linux-kernel@vger.kernel.org; Sunil Kovvuri Goutham > >> ><sgoutham@marvell.com>; >richardcochran@gmail.com; Geethasowjanya > >> >Akula <gakula@marvell.com> > >> >Subject: [EXT] Re: [net PATCH 1/7] octeontx2-af: Secure APR table > >> >update with the lock > >> > >> >External Email > >> > >> >--------------------------------------------------------------------- > >> >- On Wed, Mar 29, 2023 at 10:36:13PM +0530, Sai Krishna wrote: > >> >> From: Geetha sowjanya <gakula@marvell.com> > >> >> > >> >> APR table contains the lmtst base address of PF/VFs. > >> >> These entries are updated by the PF/VF during the device probe. Due > >> >> to race condition while updating the entries are getting corrupted. > >> >> Hence secure the APR table update with the lock. > >> > >> >However, I don't see rsrc_lock in probe path. > >> >otx2_probe() > >> >-> cn10k_lmtst_init() > >> > -> lmt_base/lmstst is updated with and without mbox.lock. > >> > >> >Where did you take rsrc_lock in probe flow? > >> > >> rsrc_lock is initialized in AF driver. PF/VF driver in cn10k_lmtst_init() send a mbox request to AF to update the lmtst table. > >> mbox handler in AF takes rsrc_lock to update lmtst table. > > >Can you please present the stack trace of such flow? What are the actual variables/struct rsrc_lock is protecting? > > The lock tries to protect the request and response register at line#73 and line#83 in below function, from getting overwritten when > Multiple PFs invokes rvu_get_lmtaddr() simultaneously. > For example, if PF1 submit the request at line#73 and got permitted before it reads the response at line#80. > PF2 got scheduled submit the request then the response of PF1 is overwritten by the PF2 response. > When PF1 gets reschedule, it reads wrong data. I see, thanks
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c index 4ad9ff025c96..8530250f6fba 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c @@ -142,16 +142,17 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, * region, if so, convert that IOVA to physical address and * populate LMT table with that address */ + mutex_lock(&rvu->rsrc_lock); if (req->use_local_lmt_region) { err = rvu_get_lmtaddr(rvu, req->hdr.pcifunc, req->lmt_iova, &lmt_addr); if (err < 0) - return err; + goto error; /* Update the lmt addr for this PFFUNC in the LMT table */ err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, lmt_addr); if (err) - return err; + goto error; } /* Reconfiguring lmtst map table in lmt region shared mode i.e. make @@ -181,7 +182,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, */ err = rvu_update_lmtaddr(rvu, req->hdr.pcifunc, val); if (err) - return err; + goto error; } /* This mailbox can also be used to update word1 of APR_LMT_MAP_ENTRY_S @@ -230,6 +231,7 @@ int rvu_mbox_handler_lmtst_tbl_setup(struct rvu *rvu, } error: + mutex_unlock(&rvu->rsrc_lock); return err; }