Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BA62606A332 for ; Wed, 2 Dec 2026 09:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=brnj1uJQ Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xYgVz-0003Ci-Pg; Wed, 02 Dec 2026 04:20:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYgVT-00025N-5J; Wed, 02 Dec 2026 04:20:10 -0500 Received: from canpmsgout12.his.huawei.com ([113.46.200.227]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xYgVN-0007G8-EK; Wed, 02 Dec 2026 04:20:05 -0500 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=o/lRboKHS25vO5xEeeyMaA0GOp6pmgUT6OeMmDtAV/k=; b=brnj1uJQfk0YhiTwS4ZYHuJDWxr4zAv/eR/YZ1/+JQM1XT2JiTu9TR35WQWqkNfdGxGEaphLB 5iJMi9eu3MSprbI55KcO3PteEGm+gHi/ortB+26RjldDFuRmjt9waLVOG+uZ3Ma4v09kvxEo9/Y W+pT531mibuK6iqJ7Jqna8k= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4jfXJD3vgvznTYT; Wed, 2 Dec 2026 17:19:08 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 7CBA940580; Wed, 2 Dec 2026 17:19:53 +0800 (CST) Received: from [10.67.110.68] (10.67.110.68) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Wed, 2 Dec 2026 17:19:52 +0800 Message-ID: <7c7790c8-3ee6-40ce-a401-37d7abd73d6c@huawei.com> Date: Wed, 2 Dec 2026 17:19:52 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 16/37] hw/arm/mpam: Implement PARTID narrowing To: Jonathan Cameron , Jinjie Ruan <2118537295@qq.com> CC: , , , , , , , , , References: <20261016094733.1898485-1-2118537295@qq.com> <20261103014824.1174340e@jic23-hlaptop> From: Jinjie Ruan In-Reply-To: <20261103014824.1174340e@jic23-hlaptop> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) To kwepemk200008.china.huawei.com (7.202.194.74) Received-SPF: pass client-ip=113.46.200.227; envelope-from=ruanjinjie@huawei.com; helo=canpmsgout12.his.huawei.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 在 2026/11/3 9:48, Jonathan Cameron 写道: > On Fri, 16 Oct 2026 17:47:10 +0800 > Jinjie Ruan <2118537295@qq.com> wrote: > >> From: Jinjie Ruan >> >> The MPAMCFG_INTPARTID register (0x600) was defined but never handled, > > Never handled in original set? I can't remember but it seems an odd > comment to have in this series. Or is intent to say it's there earlier > in the series. If so I'd say "has been define but not yet handled" > > I'm guessing it was buggy in the RFC. Not sure I tested it so I'm > certainly not surprised it was! > >> so a guest could not program the request PARTID to internal PARTID >> mapping that PARTID narrowing is based on. Add read/write support: >> >> - Writing MPAMCFG_INTPARTID stores the mapping for the request PARTID >> selected by MPAMCFG_PART_SEL; reads return the stored mapping. >> - At realize, initialise the map to partid % num_int_partid so the >> indirection is always in range before a driver programs it, >> mirroring the Linux driver's fallback mapping. MBW_MAX also resets >> to 0xffff (full bandwidth) for every internal PARTID, matching >> hardware: an unprogrammed PARTID must not read as zero bandwidth. >> - Clamp the narrowing indirection lookup to num_int_partid, and wrap >> MPAMCFG_PART_SEL writes into the supported PARTID space (the >> narrowed space for INTERNAL selectors) so a guest cannot trigger >> out-of-bounds accesses on the emulated arrays. >> >> A guest driver can now exercise PARTID narrowing: several request >> PARTIDs share one internal PARTID's configuration, and the guest can >> re-map them at runtime. >> >> Signed-off-by: Jinjie Ruan > > Just trivial stuff. Looks good to me and having looked again, > the RFC clearly failed to do half of what was needed :( > > Reviewed-by: Jonathan Cameron > > >> @@ -482,12 +497,38 @@ static void mpam_msc_write_reg(void *opaque, hwaddr offset, uint64_t value, >> s->num_ris); >> return; >> } >> + { >> + /* >> + * IHI 0099 7.2.1: the MSC does not check PARTID_SEL on write >> + * (the first IMPLEMENTATION DEFINED behaviour); the selector >> + * wraps into the supported PARTID space instead. >> + */ >> + uint32_t limit = FIELD_EX32(value, MPAMF_CFG_PART_SEL, INTERNAL) ? >> + s->num_int_partid : s->num_partid; >> + >> + s->part_sel = FIELD_EX32(value, MPAMF_CFG_PART_SEL, >> + PARTID_SEL) % limit; > > I'd rewrap that. I think slightly over 80 chars is fine here. Will be more clear, Thank you > >> + } > >> case A_MPAMF_MPAMCFG_CMAX: >> if (value & ~MPAMF_MPAMCFG_CMAX_WRITE_MASK) { >> qemu_log_mask(LOG_UNIMP, >> @@ -619,8 +660,25 @@ static void mpam_msc_realize(DeviceState *dev, Error **errp) >> >> s->mpamf = g_new0(Mpamf, s->num_ris); >> for (i = 0; i < s->num_ris; i++) { >> + int p; >> + >> s->mpamf[i].per_nrw_id = g_new0(MpamfPerNrwId, s->num_int_partid); >> s->mpamf[i].cfg_intpartid = g_new0(uint32_t, s->num_partid); >> + /* >> + * Until resctrl programs the map, wrap each request PARTID onto an >> + * internal PARTID so the narrowing indirection is always in range. >> + */ >> + for (p = 0; p < s->num_partid; p++) { > for (int p = 0; >> + s->mpamf[i].cfg_intpartid[p] = p % s->num_int_partid; OK >> + } >> + /* >> + * per_nrw_id is indexed by INTERNAL PARTID: it has num_int_partid >> + * entries, not num_partid. >> + */ >> + for (p = 0; p < s->num_int_partid; p++) { > for (int p = 0; > > particularly given it has a different use to previous p! ok > >> + /* MBW_MAX resets to full bandwidth on real hardware */ >> + s->mpamf[i].per_nrw_id[p].cfg_mbw_max = 0xffff; >> + } >> } >> >> memory_region_init_io(&s->mr, OBJECT(s), &mpam_msc_ops, s, "mpam_msc", >