From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C26BC54FCD for ; Thu, 30 Jul 2026 01:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r88gkyp3tnoix3EQhLdo5VdpLbZjak+hr4pDnGs8gX4=; b=FvGfWihZlGFTLj0caiWlAKen9N yf9RqOPVPi1d3urrU+yJ5OVIo+MRwZgugtAK7IQqqTCvlr141jM4Ta6xzkOqzB8BG6lSIWvmQbvpZ MiJqMhgzc2WpdEbBxECigUEaHz1q+m1mA2jsN4Q9zmPnHhxoujG0SLfNbP3BCMppVRfI1a1U5D6UN 9xszR+keO1pFDnFe7EBx9mFXghZHBuyi0B36wja7yYZ/WdDXIHmLn8TzmTOuxdddC+IL712rh8J8X O3cDCDEmyu+em2HVv3O7RS3yPlqKRH85OuziVEa+5+q9zONbBk3e8DNxhL1VFmGW2o3EopDftnygn jf5Myuxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wpFfK-00000009GGZ-04X3; Thu, 30 Jul 2026 01:34:30 +0000 Received: from trager.us ([52.5.81.116]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wpFfH-00000009GFw-3a3B for linux-arm-kernel@lists.infradead.org; Thu, 30 Jul 2026 01:34:28 +0000 Received: from c-73-254-161-40.hsd1.wa.comcast.net ([73.254.161.40] helo=[192.168.1.226]) by trager.us with esmtpsa (TLSv1.3:TLS_AES_128_GCM_SHA256:128) (Exim 4.92.3) (envelope-from ) id 1wpFfA-0008Il-1M; Thu, 30 Jul 2026 01:34:20 +0000 Message-ID: Date: Wed, 29 Jul 2026 18:34:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 10/10] arm_mpam: detect and enable MPAM-Fb PCC support To: Andre Przywara , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" , Len Brown , James Morse , Ben Horgan , Reinette Chatre , Fenghua Yu Cc: Jonathan Cameron , Srivathsa L Rao , Ganapatrao Kulkarni , Trilok Soni , Srinivas Ramana , Niyas Sait , linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20260729134124.2506269-1-andre.przywara@arm.com> <20260729134124.2506269-11-andre.przywara@arm.com> Content-Language: en-US From: Lee Trager In-Reply-To: <20260729134124.2506269-11-andre.przywara@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260729_183427_897812_93B6D064 X-CRM114-Status: GOOD ( 19.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/29/26 6:41 AM, Andre Przywara wrote: > @@ -2231,7 +2316,7 @@ static void mpam_msc_drv_remove(struct platform_device *pdev) > static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev) > { > int err; > - u32 tmp; > + u32 pcc_subspace_id; > struct mpam_msc *msc; > struct resource *msc_res; > struct device *dev = &pdev->dev; > @@ -2279,7 +2364,7 @@ static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev) > if (err) > return ERR_PTR(err); > > - if (device_property_read_u32(&pdev->dev, "pcc-channel", &tmp)) > + if (device_property_read_u32(dev, "pcc-channel", &pcc_subspace_id)) > msc->iface = MPAM_IFACE_MMIO; > else > msc->iface = MPAM_IFACE_PCC; > @@ -2295,6 +2380,36 @@ static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev) > } > msc->mapped_hwpage_sz = msc_res->end - msc_res->start; > msc->mapped_hwpage = io; > + } else if (msc->iface == MPAM_IFACE_PCC) { > + int ret; > + > + msc->pcc_chan = mpam_pcc_chan_get(dev, pcc_subspace_id); > + if (IS_ERR(msc->pcc_chan)) { > + pr_err("Failed to request MSC PCC channel\n"); > + return ERR_CAST(msc->pcc_chan); > + } > + > + if (msc->pcc_chan->pcc_chan->shmem_size < MPAM_FB_MAX_MSG_SIZE) { I think the PCC shared-memory size undercounts the required region. From my understanding shmem_size is the length of the complete PCC shared-memory region advertised by the PCCT and mapped by the PCC driver. MPAM_FB_MAX_MSG_SIZE is the 4-byte protocol header stored in pcc_shmem->command + the 16-byte write payload. However, mpam_fb_build_write_message() places the payload after the complete 16 byte struct acpi_pcct_ext_pcc_shared_memory. The largest request therefore occupies 32 bytes of shared memory region(16-byte PCC header+ 16-byte write payload). Thus a firmware region between 20 and 31 bytes currently passes the check but overruns when constructing a write request. I think this should be if (msc->pcc_chan->pcc_chan->shmem_size <     sizeof(struct acpi_pcct_ext_pcc_shared_memory) +     MPAM_FB_MAX_MSG_SIZE - MPAM_FB_PROT_HEADER_LEN) > > diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h > index a2193e7df57c..e926b7feb72a 100644 > --- a/drivers/resctrl/mpam_internal.h > +++ b/drivers/resctrl/mpam_internal.h > @@ -77,7 +77,6 @@ struct mpam_msc { > /* Not modified after mpam_is_enabled() becomes true */ > enum mpam_msc_iface iface; > struct mpam_pcc_chan *pcc_chan; > - int mpam_fb_msc_id; /* in its own name space */ > u32 nrdy_usec; > cpumask_t accessibility; > bool has_extd_esr; > @@ -532,6 +531,11 @@ int mpam_fb_send_write_request(struct mpam_msc *msc, u16 reg, u32 value); > int mpam_fb_get_protocol_version(struct mpam_msc *msc); > > #define MPAM_FB_PROT_HEADER_LEN sizeof(u32) > +/* The longest message is MPAM_MSC_WRITE, with 4 parameters. */ > +#define MPAM_FB_MAX_MSG_SIZE (MPAM_FB_PROT_HEADER_LEN + 4 * sizeof(u32)) > + > +#define MPAM_FB_VERSION_MAJOR_MASK GENMASK(31, 16) > +#define MPAM_FB_VERSION_MINOR_MASK GENMASK(15, 0) > > /* > * MPAM MSCs have the following register layout. See: