From: Julien Grall <julien@xen.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
Xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Oleksii Kurochko <oleksii.kurochko@gmail.com>
Subject: Re: [PATCH 2/4] ARM: Fix register constraints in run_in_exception_handler()
Date: Mon, 10 Feb 2025 21:29:23 +0000 [thread overview]
Message-ID: <e46af210-4e99-4324-aaae-d531e88c4792@xen.org> (raw)
In-Reply-To: <20250208000256.431883-3-andrew.cooper3@citrix.com>
Hi,
On 08/02/2025 00:02, Andrew Cooper wrote:
> Right now, run_in_exception_handler() takes an input in an arbitrary register,
> and clobbers BUG_FN_REG. This causes the compiler to calculate fn in the
> wrong regsiter.
Just to confirm, you mean, the compiler is not clever enough to notice
that the value should be in the register BUG_FN_REG and therefore, two
registers will be clobbered. Is that correct?
> > Instead, use `register asm()` which is the normal way of tying register
> constraints to exact registers.
>
> Bloat-o-meter reports:
>
> ARM64:
> Function old new delta
> dump_registers 356 348 -8
>
> ARM32:
> ns16550_poll 52 48 -4
> dump_registers 432 428 -4
>
> The other instruction dropped in ARM64's dump_registers() is an alignment nop.
>
> No functional change.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ----> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien@xen.org>
> CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
> CC: Bertrand Marquis <bertrand.marquis@arm.com>
> CC: Michal Orzel <michal.orzel@amd.com>
> CC: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> ---
> xen/arch/arm/include/asm/bug.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/arm/include/asm/bug.h b/xen/arch/arm/include/asm/bug.h
> index cacaf014ab09..8bf71587bea1 100644
> --- a/xen/arch/arm/include/asm/bug.h
> +++ b/xen/arch/arm/include/asm/bug.h
> @@ -59,15 +59,15 @@ struct bug_frame {
> * be called function in a fixed register.
> */
> #define run_in_exception_handler(fn) do { \
> - asm ("mov " __stringify(BUG_FN_REG) ", %0\n" \
> - "1:"BUG_INSTR"\n" \
> + register unsigned long _fn asm (STR(BUG_FN_REG)) = (unsigned long)(fn); \
> + asm ("1:"BUG_INSTR"\n" \
> ".pushsection .bug_frames." __stringify(BUGFRAME_run_fn) "," \
> " \"a\", %%progbits\n" \
> "2:\n" \
> ".p2align 2\n" \
> ".long (1b - 2b)\n" \
> ".long 0, 0, 0\n" \
> - ".popsection" :: "r" (fn) : __stringify(BUG_FN_REG) ); \
> + ".popsection" :: "r" (_fn) ); \
> } while (0)
>
> #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "")
--
Julien Grall
next prev parent reply other threads:[~2025-02-10 21:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 0:02 [PATCH 0/4] Other fixes from UBSAN enablement Andrew Cooper
2025-02-08 0:02 ` [PATCH for-4.20? 1/4] ARM32/traps: Fix do_trap_undefined_instruction()'s detection of kernel text Andrew Cooper
2025-02-10 10:13 ` Orzel, Michal
2025-02-10 22:31 ` Andrew Cooper
2025-02-10 21:23 ` Julien Grall
2025-02-10 22:23 ` Andrew Cooper
2025-02-11 10:05 ` Julien Grall
2025-02-08 0:02 ` [PATCH 2/4] ARM: Fix register constraints in run_in_exception_handler() Andrew Cooper
2025-02-10 9:21 ` Oleksii Kurochko
2025-02-10 21:31 ` Julien Grall
2025-02-10 22:41 ` Andrew Cooper
2025-02-12 22:59 ` Julien Grall
2025-02-10 10:33 ` Orzel, Michal
2025-02-10 21:29 ` Julien Grall [this message]
2025-02-10 22:10 ` Andrew Cooper
2025-02-08 0:02 ` [PATCH 3/4] xen: Centralise the declaration of dump_execution_state() Andrew Cooper
2025-02-10 9:23 ` Oleksii Kurochko
2025-02-10 9:25 ` Jan Beulich
2025-02-08 0:02 ` [PATCH 4/4] [BROKEN] PPC: Activate UBSAN in testing Andrew Cooper
2025-02-21 19:49 ` Shawn Anastasio
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=e46af210-4e99-4324-aaae-d531e88c4792@xen.org \
--to=julien@xen.org \
--cc=Volodymyr_Babchuk@epam.com \
--cc=andrew.cooper3@citrix.com \
--cc=bertrand.marquis@arm.com \
--cc=michal.orzel@amd.com \
--cc=oleksii.kurochko@gmail.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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 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.