Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ada Couprie Diaz <ada.coupriediaz@arm.com>
To: Vladimir Murzin <vladimir.murzin@arm.com>,
	linux-arm-kernel@lists.infradead.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>, Barry Song <baohua@kernel.org>,
	Oliver Upton <oupton@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Shanker Donthineni <sdonthineni@nvidia.com>,
	Vikram Sethi <vsethi@nvidia.com>,
	James Morse <james.morse@arm.com>,
	Andre Przywara <andre.przywara@arm.com>,
	Tejun Heo <tj@kernel.org>, Lucas Wei <lucaswei@google.com>,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH 5/6] arm64: insn: operate on MSR/MRS sysreg field via defines
Date: Wed, 7 Oct 2026 17:31:43 +0100	[thread overview]
Message-ID: <76f25bff-4f5c-4234-ab8b-c5f96deea9c2@arm.com> (raw)
In-Reply-To: <f0acf203-2cb4-4cda-8e12-c45d02d7499e@arm.com>

Hi Vladimir,

On 07/10/2026 07:53, Vladimir Murzin wrote:
> Hi Ada,
>
> On 9/28/26 14:30, Ada Couprie Diaz wrote:
>> Replace the few instances of hard-coded system register offset and masks
>> used to operate on MSR/MRS instructions with defines.
>> This will allow re-use in future commits while making the connection
>> between those values more explicit.
>>
>> While we are here, mark `aarch64_insn_extract_system_reg()` `noinstr`
>> so it can be safe to use in alternative pacthing callbacks.
>>
>> Changing the mask used in `aarch64_insn_gen_mrs()` to exclude
>> the lower bits does not change behaviour,
>> as `aarch64_insn_encode_register()` already clears the bits
>> used to encode the target register.
>>
>> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@arm.com>
>> ---
>>   arch/arm64/include/asm/insn.h | 3 +++
>>   arch/arm64/lib/insn.c         | 8 ++++----
>>   2 files changed, 7 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h
>> index 40f13d28a5fd7..03620f67a3e47 100644
>> --- a/arch/arm64/include/asm/insn.h
>> +++ b/arch/arm64/include/asm/insn.h
>> @@ -753,6 +753,9 @@ static __always_inline u32 aarch64_insn_gen_dsb(enum aarch64_insn_mb_type type)
>>   	return insn;
>>   }
>>   
>> +#define AARCH64_INSN_SYSREG_OFFSET	5
>> +#define AARCH64_INSN_SYSREG_MASK	GENMASK(19, 5)
>> +
> Sashiko has raised comment [1]
>
> | Does this mask unintentionally exclude bit 20?
> | The previous hardcoded mask was 0x1FFFE0, which is equivalent to
> | GENMASK(20, 5) and includes 16 bits. Defining it as GENMASK(19, 5) yields
> | a 15-bit mask.
>
> [1] https://sashiko.dev/#/patchset/20260928133034.243541-1-ada.coupriediaz%40arm.com
>
> Cheers
> Vladimir

Thanks for bringing the report up, it does raise an interesting issue.

This does change the mask used and does indeed change the returned value,
potentially breaking comparisons to the return value of `aarch64_insn_extract_system_reg()`. However, the existing mask is 
incorrect as far as I can tell : the function is supposed to extract the 
Op and CR corresponding to the system registers of the MSR/MRS 
instructions. Those fields are encoded in bits 19-5, which corresponds 
to the GENMASK I used. I think it would make more sense to fix the `enum 
aarch64_insn_special_register` values to represent the registers 
properly and drop bit 20, which is 1 in all cases anyway... I would be 
happy to send a quick v2 with this change ! Thanks for bringing it up, 
Kind regards Ada



  reply	other threads:[~2026-10-07 16:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 13:30 [PATCH 0/6] arm64: alternatives: switch most used alternatives to callbacks Ada Couprie Diaz
2026-09-28 13:30 ` [PATCH 1/6] arm64: insn: remove deprecated memory barrier types Ada Couprie Diaz
2026-10-07  6:21   ` Vladimir Murzin
2026-10-07 17:05     ` Ada Couprie Diaz
2026-10-09 10:19       ` Vladimir Murzin
2026-09-28 13:30 ` [PATCH 2/6] arm64: insn: make `aarch64_insn_gen_d{m,s}b()` alternative-safe Ada Couprie Diaz
2026-09-28 13:30 ` [PATCH 3/6] arm64: io: replace NVIDIA Olympus erratum alternative with callback Ada Couprie Diaz
2026-09-28 13:30 ` [PATCH 4/6] arm64: io: replace ARM erratum 832075 " Ada Couprie Diaz
2026-09-28 13:30 ` [PATCH 5/6] arm64: insn: operate on MSR/MRS sysreg field via defines Ada Couprie Diaz
2026-10-07  6:53   ` Vladimir Murzin
2026-10-07 16:31     ` Ada Couprie Diaz [this message]
2026-10-09  9:14       ` Vladimir Murzin
2026-09-28 13:30 ` [PATCH 6/6] arm64: use alternatie callback to patch TPIDR_EL1 accesses Ada Couprie Diaz
2026-10-06 16:28 ` [PATCH 0/6] arm64: alternatives: switch most used alternatives to callbacks Catalin Marinas
2026-10-06 17:30   ` Ada Couprie Diaz

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=76f25bff-4f5c-4234-ab8b-c5f96deea9c2@arm.com \
    --to=ada.coupriediaz@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=arnd@arndb.de \
    --cc=baohua@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=lucaswei@google.com \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=sdonthineni@nvidia.com \
    --cc=tj@kernel.org \
    --cc=vladimir.murzin@arm.com \
    --cc=vsethi@nvidia.com \
    --cc=will@kernel.org \
    /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