From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: riteshh@linux.ibm.com, linux-kernel@vger.kernel.org,
hbathini@linux.ibm.com, maddy@linux.ibm.com,
linuxppc-dev@lists.ozlabs.org, rostedt@goodmis.org,
mhiramat@kernel.org, Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH 0/1] powerpc: Fix kuap warnings
Date: Fri, 9 Jan 2026 13:54:06 +0100 [thread overview]
Message-ID: <336d274e-c831-4af9-ae65-42908b3c2c61@kernel.org> (raw)
In-Reply-To: <fe9b9c66-d1cd-4570-91fa-54329d8c6a37@linux.ibm.com>
Hi Shrikanth,
Le 09/01/2026 à 13:19, Shrikanth Hegde a écrit :
> Hi Christophe.
>
> On 1/9/26 1:41 PM, Christophe Leroy (CS GROUP) wrote:
>>
>>
>> Le 09/01/2026 à 07:49, Shrikanth Hegde a écrit :
>>> Recently stumbled upon these kuap warnings. This happens with
>>> preempt=full/lazy kernel with function tracing enabled. What irked
>>> me was kernel compilation was getting failed when i had tracing
>>> enabled. It doesn't fail everytime. While running stress-ng memory class
>>> it threw same warnings. So that helped to narrow it down.
>>> So one possible way is to disable tracing for these enter/exit
>>> vmx_usercopy. That seems to fix the bug/warnings. But that will make
>>> them as non trace-able. If there is a better way to fix these warning
>>> while
>>> keeping them as trace-able, please let me know.
>>>
>>> Anyone with insights on amr, vmx and tracing, please advise.
>>
>> The main principle with KUAP is to not call subfunctions once
>> userspace access enabled. There are a few exceptions like
>> __copy_tofrom_user() that are allowed in order to optimise large
>> copies. However this needs to be handled very carefully, and in
>> principle we don't expect __copy_tofrom_user() to call other functions.
>>
>
> I didn't understand. My knowledge is quite limited in this space.
> Could you please explain how this will help us avoid the warnings?
> or are you saying we have more callsites which needs to worked upon.
Read tools/objtool/Documentation/objtool.txt section "Objtool warning"
item 9.
Unfortunately powerpc doesn't yet implement objtool to detect it, but
the principle applies anyway.
>
>> So it might require wider rework but we should narrow as much as
>> possible the period during which access to userspace is opened, with
>> something like:
>>
>> raw_coy_to_user_power7()
>> {
>> enter_vmx_usercopy();
>
> I think the problem is when it comes here, it has some AMR state, but
> it is preemptible. So shouldn't call schedule IIUC.
See commit 00ff1eaac129 ("powerpc: Fix reschedule bug in KUAP-unlocked
user copy")
The problem is because enter_vmx_usercopy() is called _after_
allow_write_to_user() which changes AMR.
If you call enter_vmx_usercopy() _before_ allow_write_to_user() and call
exit_vmx_usercopy() _after_ prevent_write_to_user() the problem is solved.
>
>> allow_write_to_user(to, n);
>> ret = __copy_tofrom_user_power7();
>> prevent_write_to_user(to, n);
>> exit_vmx_usercopy();
>> return ret;
>> }
>>
>> raw_copy_to_user()
>> {
>> if (cpu_has_feature(CPU_FTR_VMX_COPY))
>> raw_copy_to_user_power7();
>>
>> allow_write_to_user(to, n);
>> ret = __copy_tofrom_user(to, (__force const void __user *)from, n);
>> prevent_write_to_user(to, n);
>> return ret;
>> }
>
next prev parent reply other threads:[~2026-01-09 12:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 6:49 [PATCH 0/1] powerpc: Fix kuap warnings Shrikanth Hegde
2026-01-09 6:49 ` [PATCH 1/1] powerpc: Fix kuap warnings on lazy/full preemption with tracing Shrikanth Hegde
2026-01-09 8:11 ` [PATCH 0/1] powerpc: Fix kuap warnings Christophe Leroy (CS GROUP)
2026-01-09 12:19 ` Shrikanth Hegde
2026-01-09 12:54 ` Christophe Leroy (CS GROUP) [this message]
2026-01-26 13:54 ` Shrikanth Hegde
2026-02-17 9:31 ` Ritesh Harjani
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=336d274e-c831-4af9-ae65-42908b3c2c61@kernel.org \
--to=chleroy@kernel.org \
--cc=hbathini@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mhiramat@kernel.org \
--cc=npiggin@gmail.com \
--cc=riteshh@linux.ibm.com \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.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