lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <OSZPR01MB87982085E0E5B09D0FBB58208B85A@OSZPR01MB8798.jpnprd01.prod.outlook.com>
Date: Thu, 8 Jan 2026 10:18:49 +0000
From: "Shaopeng Tan (Fujitsu)" <tan.shaopeng@...itsu.com>
To: Ben Horgan <ben.horgan@....com>
CC: "amitsinght@...vell.com" <amitsinght@...vell.com>,
	"baisheng.gao@...soc.com" <baisheng.gao@...soc.com>,
	"baolin.wang@...ux.alibaba.com" <baolin.wang@...ux.alibaba.com>,
	"carl@...amperecomputing.com" <carl@...amperecomputing.com>,
	"dave.martin@....com" <dave.martin@....com>, "david@...nel.org"
	<david@...nel.org>, "dfustini@...libre.com" <dfustini@...libre.com>,
	"fenghuay@...dia.com" <fenghuay@...dia.com>, "gshan@...hat.com"
	<gshan@...hat.com>, "james.morse@....com" <james.morse@....com>,
	"jonathan.cameron@...wei.com" <jonathan.cameron@...wei.com>,
	"kobak@...dia.com" <kobak@...dia.com>, "lcherian@...vell.com"
	<lcherian@...vell.com>, "linux-arm-kernel@...ts.infradead.org"
	<linux-arm-kernel@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, "peternewman@...gle.com"
	<peternewman@...gle.com>, "punit.agrawal@....qualcomm.com"
	<punit.agrawal@....qualcomm.com>, "quic_jiles@...cinc.com"
	<quic_jiles@...cinc.com>, "reinette.chatre@...el.com"
	<reinette.chatre@...el.com>, "rohit.mathew@....com" <rohit.mathew@....com>,
	"scott@...amperecomputing.com" <scott@...amperecomputing.com>,
	"sdonthineni@...dia.com" <sdonthineni@...dia.com>, "xhao@...ux.alibaba.com"
	<xhao@...ux.alibaba.com>, "catalin.marinas@....com"
	<catalin.marinas@....com>, "will@...nel.org" <will@...nel.org>,
	"corbet@....net" <corbet@....net>, "maz@...nel.org" <maz@...nel.org>,
	"oupton@...nel.org" <oupton@...nel.org>, "joey.gouly@....com"
	<joey.gouly@....com>, "suzuki.poulose@....com" <suzuki.poulose@....com>,
	"kvmarm@...ts.linux.dev" <kvmarm@...ts.linux.dev>, "dave.martin@....com"
	<dave.martin@....com>
Subject: Re: [PATCH v2 12/45] arm64: mpam: Add helpers to change a task or
 cpu's MPAM PARTID/PMG values

Hello  Ben,

> From: James Morse <james.morse@....com>
> 
> Care must be taken when modifying the PARTID and PMG of a task in any
> per-task structure as writing these values may race with the task being
> scheduled in, and reading the modified values.
> 
> Add helpers to set the task properties, and the CPU default value.  These
> use WRITE_ONCE() that pairs with the READ_ONCE() in mpam_get_regval() to
> avoid causing torn values.
> 
> CC: Dave Martin <Dave.Martin@....com>
> Signed-off-by: James Morse <james.morse@....com>
> Signed-off-by: Ben Horgan <ben.horgan@....com>
> ---
> Changes since rfc:
> Keep comment attached to mpam_get_regval()
> Add internal helper, __mpam_regval() (Jonathan)
> ---
>  arch/arm64/include/asm/mpam.h | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/mpam.h b/arch/arm64/include/asm/mpam.h
> index c4cb015e8d8f..a7fd0656bf90 100644
> --- a/arch/arm64/include/asm/mpam.h
> +++ b/arch/arm64/include/asm/mpam.h
> @@ -4,6 +4,7 @@
>  #ifndef __ASM__MPAM_H
>  #define __ASM__MPAM_H
>  
> +#include <linux/bitfield.h>
>  #include <linux/jump_label.h>
>  #include <linux/percpu.h>
>  #include <linux/sched.h>
> @@ -22,6 +23,22 @@ DECLARE_PER_CPU(u64, arm64_mpam_current);
>   */
>  extern u64 arm64_mpam_global_default;
>  
> +static inline u64 __mpam_regval(u16 partid_d, u16 partid_i, u8 pmg_d, u8 pmg_i)
> +{
> +       return FIELD_PREP(MPAM0_EL1_PARTID_D, partid_d) |
> +               FIELD_PREP(MPAM0_EL1_PARTID_I, partid_i) |
> +               FIELD_PREP(MPAM0_EL1_PMG_D, pmg_d) |
> +               FIELD_PREP(MPAM0_EL1_PMG_I, pmg_i);
> +}
> +
> +static inline void mpam_set_cpu_defaults(int cpu, u16 partid_d, u16 partid_i,
> +                                        u8 pmg_d, u8 pmg_i)
> +{
> +       u64 default_val = __mpam_regval(partid_d, partid_i, pmg_d, pmg_i);
> +
> +       WRITE_ONCE(per_cpu(arm64_mpam_default, cpu), default_val);
> +}
> +
>  /*
>   * The resctrl filesystem writes to the partid/pmg values for threads and CPUs,
>   * which may race with reads in mpam_thread_switch(). Ensure only one of the old
> @@ -45,6 +62,17 @@ static inline u64 mpam_get_regval(struct task_struct *tsk)
>  #endif
>  }
>  
> +static inline void mpam_set_task_partid_pmg(struct task_struct *tsk,
> +                                           u16 partid_d, u16 partid_i,
> +                                           u8 pmg_d, u8 pmg_i)
> +{
> +#ifdef CONFIG_ARM64_MPAM

Since `mpam_set_task_partid_pmg()` is only called from MPAM, is this necessary?

Best regards,
Shaopeng TAN

> +       u64 regval = __mpam_regval(partid_d, partid_i, pmg_d, pmg_i);
> +
> +       WRITE_ONCE(task_thread_info(tsk)->mpam_partid_pmg, regval);
> +#endif
> +}
> +
>  static inline void mpam_thread_switch(struct task_struct *tsk)
>  {
>          u64 oldregval;
> --
> 2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ