From: "Troy Mitchell" <troy.mitchell@linux.dev>
To: "Guo Ren" <guoren@kernel.org>, "Troy Mitchell" <troy.mitchell@linux.dev>
Cc: "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Andy Chiu" <andybnac@gmail.com>,
"Vincent Chen" <vincent.chen@sifive.com>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Alexandre Ghiti" <alex@ghiti.fr>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
"Palmer Dabbelt" <palmer@rivosinc.com>,
"Greentime Hu" <greentime.hu@sifive.com>,
"Heiko Stuebner" <heiko@sntech.de>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Kevin Zhang" <zhangmeng.kevin@linux.spacemit.com>
Subject: Re: [PATCH] riscv: vector: Fix data pointer constraints in context save/restore
Date: Sat, 12 Sep 2026 17:21:46 +0800 [thread overview]
Message-ID: <DLD87F4KVA70.JK2UTB6A9HZF@linux.dev> (raw)
In-Reply-To: <CAJF2gTRn4keG=peEKkncgdsu=RLP3N0Ev6cO7mzXg-J48R+bEg@mail.gmail.com>
[-- Attachment #1.1: Type: text/plain, Size: 1393 bytes --]
On Fri Sep 11, 2026 at 2:56 PM +08, Guo Ren wrote:
> On Tue, Sep 8, 2026 at 9:03 PM Troy Mitchell <troy.mitchell@linux.dev> wrote:
>>
>> The standard vector save/restore asm advances datap but declares it as
>> input-only. An inlined caller reusing the original pointer may therefore
>> use the advanced address instead.
>>
>> Declare datap as read-write so the compiler can preserve the original
>> pointer when needed.
>>
>> Fixes: 03c3fcd9941a ("riscv: Introduce struct/helpers to save/restore per-task Vector state")
>> Signed-off-by: Troy Mitchell <troy.mitchell@linux.dev>
>> ---
>> arch/riscv/include/asm/vector.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
>> index fffe72a772080..c7fd6d50a7a47 100644
>> --- a/arch/riscv/include/asm/vector.h
>> +++ b/arch/riscv/include/asm/vector.h
>> @@ -230,7 +230,7 @@ static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to,
>> "add %1, %1, %0\n\t"
> Yes, %1 is modified. Good catch!
>
> Reviewed-by: GUO Ren (XuanTie) <guoren@kernel.org>
>
> PS:
> Don't forget "if (has_xtheadvector()) {" part, thx :)
The XTheadVector path copies datap into t0 and lists t0/t4 as
clobbers, so it doesn't have this issue. Thanks for the reminder!
--
Troy Mitchell
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-09-12 9:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 13:03 [PATCH] riscv: vector: Fix data pointer constraints in context save/restore Troy Mitchell
2026-09-11 6:56 ` Guo Ren
2026-09-12 9:21 ` Troy Mitchell [this message]
2026-09-11 18:23 ` Aurelien Jarno
2026-09-11 19:01 ` Andy Chiu
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=DLD87F4KVA70.JK2UTB6A9HZF@linux.dev \
--to=troy.mitchell@linux.dev \
--cc=alex@ghiti.fr \
--cc=andybnac@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=greentime.hu@sifive.com \
--cc=guoren@kernel.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=palmer@rivosinc.com \
--cc=pjw@kernel.org \
--cc=vincent.chen@sifive.com \
--cc=zhangmeng.kevin@linux.spacemit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.