From: Thomas Gleixner <tglx@kernel.org>
To: Chen Yu <yu.c.chen@intel.com>,
tony.luck@intel.com, reinette.chatre@intel.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de,
mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com,
dave.martin@arm.com, james.morse@arm.com, fenghuay@nvidia.com,
babu.moger@amd.com, anil.keshavamurthy@broadcom.com
Subject: Re: [PATCH v3 1/6] x86/resctrl: Parse ACPI ERDT table and map RMDD domains by L3 cache ID
Date: Mon, 08 Jun 2026 10:59:56 +0200 [thread overview]
Message-ID: <87qzmh4dbn.ffs@fw13> (raw)
In-Reply-To: <53eeaead2d02cfa53204fe3101df3c0a09796ff9.1780710620.git.yu.c.chen@intel.com>
On Sat, Jun 06 2026 at 10:32, Chen Yu wrote:
> +
> +static inline struct acpi_subtbl_hdr_16 *rmdd_subtbl(struct acpi_erdt_rmdd *rmdd)
> +{
> + return (void *)rmdd + sizeof(*rmdd);
> +}
> +
> +static inline struct acpi_subtbl_hdr_16 *next_subtbl(struct acpi_subtbl_hdr_16 *subtbl)
> +{
> + return (void *)subtbl + subtbl->length;
> +}
Second thoughts on this. Hit send too fast.
> +static inline bool subtbl_valid(struct acpi_erdt_rmdd *rmdd, struct acpi_subtbl_hdr_16 *subtbl)
> +{
> + void *rmdd_end = (void *)rmdd + rmdd->header.length;
> +
> + if (subtbl->length < sizeof(*subtbl))
> + return false;
> +
> + if ((void *)subtbl + sizeof(*subtbl) > rmdd_end)
> + return false;
> +
> + if ((void *)subtbl + subtbl->length > rmdd_end)
> + return false;
These conditions are confusing. This basically allows subtbl->length to
be larger than sizeof(tbl) as long as it's within the limits.
If that's intentional then the second condition is pointless because
according to the first condition
length >= sizeof(tbl)
so
tbl + length <= end
is catching both. No?
> + return true;
> +static __init int enumerate_erdt_table(struct acpi_table_header *table_hdr)
> +{
> + struct acpi_table_erdt *erdt = (struct acpi_table_erdt *)table_hdr;
> + struct acpi_subtbl_hdr_16 *subtbl;
> + void *table_end;
> +
> + if (erdt->header.revision != ERDT_VALID_VERSION) {
> + pr_info("Unknown ERDT table revision %d\n", erdt->header.revision);
> + return -EINVAL;
> + }
> +
> + if (erdt->header.length < sizeof(*erdt)) {
> + pr_info(FW_BUG "ERDT: Invalid table length %u\n", erdt->header.length);
> + return -EINVAL;
> + }
> +
> + subtbl = (void *)erdt + sizeof(struct acpi_table_erdt);
> + table_end = (void *)erdt + erdt->header.length;
> +
> + while ((void *)subtbl + sizeof(*subtbl) <= table_end) {
> + if (subtbl->length < sizeof(*subtbl) ||
> + (void *)subtbl + subtbl->length > table_end) {
> + pr_info("ERDT: Invalid subtable length\n");
> + goto cleanup;
> + }
So this is yet another version of the above, just slighty different with
the same strange conditions.
If you make subtbl_valid():
static inline bool subtbl_valid(void *end, struct acpi_subtbl_hdr_16 *subtbl)
and calculate the end at the call sites you can reuse that function.
> +
> + if (subtbl->type == ACPI_ERDT_TYPE_RMDD)
> + if (!parse_rmdd_entry(subtbl))
> + goto cleanup;
> +
> + subtbl = (void *)subtbl + subtbl->length;
open coded variant of next_subtbl()
next prev parent reply other threads:[~2026-06-08 8:59 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 2:31 [PATCH v3 0/6] Introduce MMIO-based CMT access for Enhanced RDT Chen Yu
2026-06-06 2:32 ` [PATCH v3 1/6] x86/resctrl: Parse ACPI ERDT table and map RMDD domains by L3 cache ID Chen Yu
2026-06-08 8:59 ` Thomas Gleixner [this message]
2026-06-08 11:20 ` Chen, Yu C
2026-06-06 2:33 ` [PATCH v3 2/6] x86/resctrl: Parse ACPI CMRC table Chen Yu
2026-06-08 8:30 ` Thomas Gleixner
2026-06-06 2:35 ` [PATCH v3 3/6] x86/resctrl: Rename prev_msr to prev_mon_val Chen Yu
2026-06-08 8:32 ` Thomas Gleixner
2026-06-06 2:38 ` [PATCH v3 4/6] x86/resctrl: Refactor the monitor read function Chen Yu
2026-06-06 2:38 ` [PATCH v3 5/6] fs/resctrl: Do not invoke smp_processor_id() in preemptible context Chen Yu
2026-06-08 8:36 ` Thomas Gleixner
2026-06-08 11:26 ` Chen, Yu C
2026-06-08 15:10 ` Reinette Chatre
2026-06-08 16:45 ` Chen, Yu C
2026-06-08 15:32 ` Luck, Tony
2026-06-08 16:54 ` Chen, Yu C
2026-06-06 2:38 ` [PATCH v3 6/6] x86/resctrl: Add support for L3 occupancy monitoring via RMID MMIO read Chen Yu
2026-06-08 8:33 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87qzmh4dbn.ffs@fw13 \
--to=tglx@kernel.org \
--cc=anil.keshavamurthy@broadcom.com \
--cc=babu.moger@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dave.martin@arm.com \
--cc=fenghuay@nvidia.com \
--cc=hpa@zytor.com \
--cc=james.morse@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=reinette.chatre@intel.com \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
--cc=yu.c.chen@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox