| 
    
 [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v4 1/3] xen/arm: add support for run_in_exception_handler()
 On 14.12.20 11:17, Julien Grall wrote: Hi Juergen, On 14/12/2020 07:56, Juergen Gross wrote:Add support to run a function in an exception handler for Arm. Do it the same way as on x86 via a bug_frame. Unfortunately inline assembly on Arm seems to be less capable than on x86, leading to functions called via run_in_exception_handler() having to be globally visible.Jan already commented on this, so I am not going to comment again. 
Maybe I can ask some Arm specific question related to this:
In my experiments the only working solution was using the "i" constraint
for the function pointer. Do you know whether this is supported for all
gcc versions we care about?
Or is there another way to achieve the desired functionality? I'm using
now the following macros:
#define BUG_FRAME_run_fn(fn) do {                                      \
    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 - 2b)\n"                                           \
         ".long 0\n"                                                   \
         ".hword 0, 0\n"                                               \
         ".popsection" :: "i" (fn));                                   \
} while (0)
#define run_in_exception_handler(fn) BUG_FRAME_run_fn(fn)
Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- V4: - new patch I have verified the created bugframe is correct by inspecting the created binary. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- xen/arch/arm/traps.c | 10 +++++++++- xen/drivers/char/ns16550.c | 3 ++- xen/include/asm-arm/bug.h | 32 +++++++++++++++++++++----------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 22bd1bd4c6..6e677affe2 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c@@ -1236,8 +1236,16 @@ int do_bug_frame(const struct cpu_user_regs *regs, vaddr_t pc) This matches x86 definition. IMO there is no reason to have a different definition and this will make it more obvious that it might be a good idea to have a common include/xen/bug.h header. Juergen Attachment:
OpenPGP_0xB0DE9DD628BF132F.asc Attachment:
OpenPGP_signature 
 
 
  | 
  
![]()  | 
            
         Lists.xenproject.org is hosted with RackSpace, monitoring our  |