Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Babu Moger" <babu.moger@amd.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v6 03/18] x86/resctrl: Add PLZA configuration definitions and data structures
Date: Thu, 01 Oct 2026 15:30:57 +0000	[thread overview]
Message-ID: <20261001153058.373AE1F00898@smtp.kernel.org> (raw)
In-Reply-To: <608876cedf5eece3f8b9297bcf21663a86a6380d.1790867441.git.babu.moger@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] x86/resctrl: silent truncation of closid in msr_pqr_plza_assoc
--

commit 850d244de0af8ce075ea53a011e816d9227fff52
Author: Babu Moger <babu.moger@amd.com>

x86/resctrl: Add PLZA configuration definitions and data structures

Privilege Level Zero Association (PLZA) enables the kernel to switch to
a different CLOSID and/or RMID than those used in user mode when entering
kernel mode. CLOSID and RMID selection are independent and can be
configured separately.

> diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h
> index e3cfa0c10e92d..44ecde20b1b43 100644
> --- a/arch/x86/kernel/cpu/resctrl/internal.h
> +++ b/arch/x86/kernel/cpu/resctrl/internal.h

[ ... ]

> @@ -222,6 +222,55 @@ union l3_qos_abmc_cfg {
>  	unsigned long full;
>  };
>  
> +/*
> + * Privilege Level Zero Association (PLZA) is configured via
> + * MSR_IA32_PQR_PLZA_ASSOC.

[ ... ]

> + * This allows PLZA to override only RMID, only CLOSID, or both. If both
> + * rmid_en and closid_en are clear, the effective behavior is the same as
> + * when PLZA is disabled, with RMID and CLOSID used from MSR_IA32_PQR_ASSOC
> + * irrespective of privilege level.
> + */
> +union msr_pqr_plza_assoc {
> +	struct {
> +		u64	rmid		:12,
> +			reserved1	:19,
> +			rmid_en		: 1,
> +			closid		: 4,
> +			reserved2	:11,

[Severity: High]
Does this correctly size the closid field?

The closid is defined as a 4-bit field, which could cause a regression
through silent data truncation when assigned a value >= 16.

resctrl dynamically discovers the maximum number of CLOSIDs supported by the
hardware via CPUID. If the hardware reports support for more than 16 CLOSIDs,
resctrl will allocate closid values >= 16.

When a resource group with closid >= 16 is assigned to PLZA via
resctrl_arch_configure_kmode_global(), the u32 closid is assigned to the
4-bit split.closid bitfield, silently truncating the upper bits. This
programs an incorrect CLOSID into the MSR, breaking the requested
cache/bandwidth isolation for kernel mode operations without any warning
or error.

If the AMD specification allows a 15-bit CLOSID (like standard
MSR_IA32_PQR_ASSOC), does the struct bitfield incorrectly split 15 bits
into 4 bits for closid and 11 bits for reserved2?

If the hardware is strictly limited to 4 bits, should there be a bounds
check (if (closid > 15)) or a cap on num_closids when PLZA is enabled?

> +			closid_en	: 1,
> +			reserved3	:15,
> +			plza_en		: 1;
> +	} split;
> +	u64	full;
> +};
> +
>  void rdt_ctrl_update(void *arg);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790867441.git.babu.moger@amd.com?part=3

  reply	other threads:[~2026-10-01 15:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 15:10 [PATCH v6 00/18] x86,fs/resctrl: Add kernel-mode (e.g., PLZA) support to the resctrl subsystem Babu Moger
2026-10-01 15:10 ` [PATCH v6 01/18] x86/cpufeatures: Support Privilege Level Zero Association (PLZA) Babu Moger
2026-10-01 15:22   ` sashiko-bot
2026-10-01 15:10 ` [PATCH v6 02/18] x86/resctrl: Add PLZA support to command-line options Babu Moger
2026-10-01 15:10 ` [PATCH v6 03/18] x86/resctrl: Add PLZA configuration definitions and data structures Babu Moger
2026-10-01 15:30   ` sashiko-bot [this message]
2026-10-01 15:10 ` [PATCH v6 04/18] fs/resctrl: Introduce kernel mode enum Babu Moger
2026-10-01 15:10 ` [PATCH v6 05/18] x86,arm,fs/resctrl: Introduce architecture hook to program global kernel mode Babu Moger
2026-10-01 15:35   ` sashiko-bot
2026-10-01 15:10 ` [PATCH v6 06/18] fs/resctrl: Introduce kernel mode states for resctrl Babu Moger
2026-10-01 15:10 ` [PATCH v6 07/18] fs/resctrl: Introduce resctrl_set_kmode_support() to register supported modes Babu Moger
2026-10-01 15:10 ` [PATCH v6 08/18] x86/resctrl: Register RESCTRL_GLOBAL_ENABLE_PER_CPU when PLZA is available Babu Moger
2026-10-01 15:10 ` [PATCH v6 09/18] fs/resctrl: Add interface to display kernel mode status Babu Moger
2026-10-01 15:10 ` [PATCH v6 10/18] fs/resctrl: Add support for hidden resource group files Babu Moger
2026-10-01 15:10 ` [PATCH v6 11/18] fs/resctrl: Introduce kmode_cpus/kmode_cpus_list per rdtgroup Babu Moger
2026-10-01 15:10 ` [PATCH v6 12/18] fs/resctrl: Add CPU hotplug support for kernel mode associations Babu Moger
2026-10-01 15:10 ` [PATCH v6 13/18] fs/resctrl: Deactivate kernel mode associations when a group is removed Babu Moger
2026-10-01 15:10 ` [PATCH v6 14/18] fs/resctrl: Control visibility of global per-CPU kernel mode group files Babu Moger
2026-10-01 15:10 ` [PATCH v6 15/18] fs/resctrl: Reject mode changes for groups backing kernel mode Babu Moger
2026-10-01 15:10 ` [PATCH v6 16/18] fs/resctrl: Add interface to modify kernel mode via info/kernel_mode Babu Moger
2026-10-01 15:10 ` [PATCH v6 17/18] fs/resctrl: Allow user space to write kmode_cpus/kmode_cpus_list Babu Moger
2026-10-01 15:10 ` [PATCH v6 18/18] fs/resctrl: Add kernel mode documentation and examples Babu Moger

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=20261001153058.373AE1F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=babu.moger@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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