From: "Aiqun(Maria) Yu" <quic_aiquny@quicinc.com>
To: Ard Biesheuvel <ardb@kernel.org>, Nathan Chancellor <nathan@kernel.org>
Cc: <linux@armlinux.org.uk>, <mhiramat@kernel.org>,
<kernel@quicinc.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<quic_lijuang@quicinc.com>, <stable@vger.kernel.org>
Subject: Re: [PATCH v2 1/1] ARM: kprobes: Explicitly reserve r7 for local variables
Date: Mon, 20 Nov 2023 10:00:40 +0800 [thread overview]
Message-ID: <3fbc49da-99ac-4499-84df-064f3dc429d2@quicinc.com> (raw)
In-Reply-To: <CAMj1kXE4stcFikmxBMY19CR4J0+EpaNW8J=xVyFVY3A7F7BpRQ@mail.gmail.com>
On 11/17/2023 1:36 AM, Ard Biesheuvel wrote:
> On Fri, 17 Nov 2023 at 03:24, Nathan Chancellor <nathan@kernel.org> wrote:
>>
>> On Wed, Nov 15, 2023 at 05:58:30PM +0800, Maria Yu wrote:
>>> Registers r7 is removed in clobber list, so compiler may choose r7 for
>>> local variables usage, while r7 will be actually updated by the inline asm
>>> code. This caused the runtime behavior wrong.
>>> While those kind of reserved registers cannot be set to clobber list
>>> because of error like "inline asm clobber list contains reserved
>>> registers".
>>> Explicitly reserve r7 by adding attribute no-omit-frame-pointer for needed
>>> function, then in T32 asm code r7 is used as a frame pointer and is not
>>> available for use as a general-purpose register.
>>> Note that "no-omit-frame-pointer" will make the code size a little bigger
>>> to store the stack frame pointer. So limited to needed functions can have
>>> the less impact than the full source file.
>>>
>>> Fixes: dd12e97f3c72 ("ARM: kprobes: treat R7 as the frame pointer register in Thumb2 builds")
>>> Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
>>> Cc: stable@vger.kernel.org
>>
>> This causes warnings with clang:
>>
>> arch/arm/probes/kprobes/actions-thumb.c:441:47: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
>> 441 | static unsigned long __kprobes __attribute__((optimize("no-omit-frame-pointer")))
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/arm/probes/kprobes/actions-thumb.c:524:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
>> 524 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer")))
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/arm/probes/kprobes/actions-thumb.c:560:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
>> 560 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer")))
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/arm/probes/kprobes/actions-thumb.c:579:38: warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
>> 579 | static void __kprobes __attribute__((optimize("no-omit-frame-pointer")))
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 4 warnings generated.
>>
>> Furthermore, as far as I am aware, the optimize attribute has other issues so
>> its use is discouraged, see commits 080b6f407635 ("bpf: Don't rely on GCC
>> __attribute__((optimize)) to disable GCSE") and a7223f5bfcae ("powerpc: Avoid
>> broken GCC __attribute__((optimize))").
Thx for trying this. I was tested with arm-linux-gnueabihf-gcc and not
notice this.
>>
>
> Ah yes, apalogies for missing that. I did a test build with Clang but
> I did not spot the errors. So
>
> Unreviewed-by: ....
>
> Maria, please use the Makefile based per-file CFLAGS override that I
> suggested before. There is really no reason to make this per-function.
Ok. I will upload a new patchset.
--
Thx and BRs,
Aiqun(Maria) Yu
prev parent reply other threads:[~2023-11-20 2:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 9:58 [PATCH v2 1/1] ARM: kprobes: Explicitly reserve r7 for local variables Maria Yu
2023-11-16 11:11 ` Ard Biesheuvel
2023-11-16 17:24 ` Nathan Chancellor
2023-11-16 17:36 ` Ard Biesheuvel
2023-11-20 2:00 ` Aiqun(Maria) Yu [this message]
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=3fbc49da-99ac-4499-84df-064f3dc429d2@quicinc.com \
--to=quic_aiquny@quicinc.com \
--cc=ardb@kernel.org \
--cc=kernel@quicinc.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mhiramat@kernel.org \
--cc=nathan@kernel.org \
--cc=quic_lijuang@quicinc.com \
--cc=stable@vger.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