From: "Arnd Bergmann" <arnd@arndb.de>
To: "Catalin Marinas" <catalin.marinas@arm.com>,
"Arnd Bergmann" <arnd@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, apais@microsoft.com,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Fuad Tabba" <fuad.tabba@linux.dev>,
hargar@linux.microsoft.com, "Joey Gouly" <joey.gouly@arm.com>,
"Marc Zyngier" <maz@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Navneet Singh" <navneetsingh@microsoft.com>,
"Oliver Upton" <oupton@kernel.org>,
rlmenge@gmail.com,
"Siddharth Chintamaneni" <sidchintamaneni@gmail.com>,
"Steffen Eiden" <seiden@linux.ibm.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Sven Schnelle" <sven@linux.ibm.com>,
"Will Deacon" <will@kernel.org>,
"Yicong Yang" <yangyicong@hisilicon.com>,
"Zenghui Yu" <yuzenghui@huawei.com>,
"Zhou Wang" <wangzhou1@hisilicon.com>,
kvmarm@lists.linux.dev, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/3] arm64: dynamically enable st64bv0 for SVA
Date: Wed, 02 Dec 2026 23:32:09 +0100 [thread overview]
Message-ID: <0b51ebd4-f7a2-4300-a127-ac6617b8bbbe@app.fastmail.com> (raw)
In-Reply-To: <aw2xOFFqAXsx_Nqd@arm.com>
On Mon, Nov 30, 2026, at 18:24, Catalin Marinas wrote:
> Hi Arnd,
>
> (BTW, you dropped all cc from the cover letter in subsequent patches,
> re-adding them; forgot --cc-cover?)
Thanks for adding them, indeed I forgot.
> On Thu, Nov 26, 2026 at 04:53:37PM +0100, Arnd Bergmann wrote:
>> diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
>> index 12a500181291..56b4b68407a9 100644
>> --- a/arch/arm64/include/asm/el2_setup.h
>> +++ b/arch/arm64/include/asm/el2_setup.h
>> @@ -93,6 +93,9 @@
>> cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_V
>> b.lt .Lset_hcrx_\@
>> orr x0, x0, #HCRX_EL2_EnASR
>> + cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_ACCDATA
>> + b.lt .Lset_hcrx_\@
>> + orr x0, x0, #HCRX_EL2_EnAS0
>
> As reported by Siddharth (and Sashiko), we need to disable the
> ACCDATA_EL1 fine-grained traps (HFG{R,W}TR_EL2.nACCDATA_EL1) in
> __init_el2_fgt, similar to the existing PIE/POE/GCS blocks. Otherwise on
> an nVHE/pKVM host the ACCDATA_EL1 write in try_enable_st64bv0() traps to
> EL2 and hits the BUG() in handle_trap(). We should also add a note in
> booting.rst for cases where the kernel is entered at EL1 (HCRX_EL2.EnAS0
> and the nACCDATA_EL1 bits).
Ok, I think I understand the logic now. Does this version make sense?:
index 56b4b68407a9..fd6e06bdacfb 100644
--- a/arch/arm64/include/asm/el2_setup.h
+++ b/arch/arm64/include/asm/el2_setup.h
@@ -397,6 +397,15 @@
orr x0, x0, #HFGRTR_EL2_nGCS_EL0_MASK
.Lskip_gce_fgt_\@:
+ mrs_s x1, SYS_ID_AA64ISAR1_EL1
+ ubfx x1, x1, #ID_AA64ISAR1_EL1_LS64_SHIFT, #4
+ cmp x1, #ID_AA64ISAR1_EL1_LS64_LS64_ACCDATA
+ b.lt .Lskip_ls64_accdata_\@
+
+ /* Disable traps of access to ACCDATA_EL1 register */
+ orr x0, x0, #HFGRTR_EL2_nACCDATA_EL1
+
+.Lskip_ls64_accdata_\@:
.Lset_fgt_\@:
msr_s SYS_HFGRTR_EL2, x0
>> switch_mm(struct mm_struct *prev, struct mm_struct *next,
>> struct task_struct *tsk)
>> @@ -254,6 +269,8 @@ switch_mm(struct mm_struct *prev, struct mm_struct *next,
>> if (prev != next)
>> __switch_mm(next);
>>
>> + switch_iommu_mm(next, tsk);
>
> I don't think switch_mm() is the right place for this. Even if the PASID
> is per-mm, this function is about per-thread state (EnAS0, ACCDATA_EL1).
> I'd prefer something like ls64_accdata_thread_switch() called from
> __switch_to().
Right, that does seem more consistent. I was trying to be clever and
only change it when the mm changes, but __switch_to() is clearly the
right place here to avoid inconsistent state.
>> + */
>> +static bool try_enable_st64bv0(struct pt_regs *regs, unsigned long esr)
> Nit: are regs and esr used in later patches? They are unused here.
I've removed them now.
>> +
>> +void do_el0_other(struct pt_regs *regs, unsigned long esr)
>> +{
>> + switch (ESR_ELx_ISS(esr)) {
>> + case ESR_ELx_ISS_OTHER_ST64BV0:
>> + if (!system_supports_ls64_accdata())
>> + break;
>> +
>> + if (try_enable_st64bv0(regs, esr))
>> + return;
>> +
>> + force_signal_inject(SIGBUS, BUS_OBJERR, regs->pc, 0);
>> + break;
>
> As mentioned by Sashiko, with this 'break' we end up injecting two
> signals. So better to just return here.
done
>> +
>> + case ESR_ELx_ISS_OTHER_ST64BV:
>> + case ESR_ELx_ISS_OTHER_LDST64B:
>> + default:
>> + break;
>> + }
>> +
>> + /* Treat all other "other" trapping instructions as illegal opcode */
>> + force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0);
>
> Prior to this patch, we passed the esr_context to the user signal
> handler via bad_el0_sync(). You could pass esr as the last argument or
> just reuse bad_el0_sync().
Most other SIGILL injections don't pass esr even when it's available.
Do you know if that is intentional or we should changed others
as well?
>> diff --git a/arch/arm64/tools/sysreg b/arch/arm64/tools/sysreg
>> index 28d319e63d8f..7612bacdb018 100644
>> --- a/arch/arm64/tools/sysreg
>> +++ b/arch/arm64/tools/sysreg
>> @@ -3707,6 +3707,11 @@ Sysreg TPIDR_EL1 3 0 13 0 4
>> Field 63:0 ThreadID
>> EndSysreg
>>
>> +Sysreg ACCDATA_EL1 3 0 13 0 5
>> +Res0 63:32
>> +Field 31:0 ACCDATA
>> +EndSysreg
>
> It makes sense to define this but I think we should remove the
> equivalent in asm/sysreg.h.
done.
Thanks a lot for the review!
Arnd
next prev parent reply other threads:[~2026-12-02 22:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 15:53 [PATCH v2 0/3] st64bv0 support in iommu-sva Arnd Bergmann
[not found] ` <20261126155339.1349218-2-arnd@kernel.org>
2026-11-30 17:24 ` [PATCH v2 1/3] arm64: dynamically enable st64bv0 for SVA Catalin Marinas
2026-12-02 22:32 ` Arnd Bergmann [this message]
[not found] ` <20261126155339.1349218-3-arnd@kernel.org>
2026-11-30 18:02 ` [PATCH v2 2/3] arm64: add HWCAP3_LS64_ACCDATA Catalin Marinas
2026-12-02 22:53 ` Arnd Bergmann
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=0b51ebd4-f7a2-4300-a127-ac6617b8bbbe@app.fastmail.com \
--to=arnd@arndb.de \
--cc=apais@microsoft.com \
--cc=arnd@kernel.org \
--cc=borntraeger@linux.ibm.com \
--cc=catalin.marinas@arm.com \
--cc=fuad.tabba@linux.dev \
--cc=hargar@linux.microsoft.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=navneetsingh@microsoft.com \
--cc=oupton@kernel.org \
--cc=rlmenge@gmail.com \
--cc=seiden@linux.ibm.com \
--cc=sidchintamaneni@gmail.com \
--cc=suzuki.poulose@arm.com \
--cc=sven@linux.ibm.com \
--cc=wangzhou1@hisilicon.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=yuzenghui@huawei.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
all inboxes | Powered by JetHome®