All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksii <oleksii.kurochko@gmail.com>
To: Julien Grall <julien@xen.org>, xen-devel@lists.xenproject.org
Cc: Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	 Stefano Stabellini <sstabellini@kernel.org>,
	Gianluca Guida <gianluca@rivosinc.com>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v3 3/4] xen/arm: switch ARM to use generic implementation of bug.h
Date: Tue, 28 Feb 2023 19:21:17 +0200	[thread overview]
Message-ID: <6735859208c6dcb7320f89664ae298005f70827b.camel@gmail.com> (raw)
In-Reply-To: <ae96eb36-aeba-86f0-3b72-a8b62f4dce60@xen.org>

Hi Julien,

On Sat, 2023-02-25 at 17:05 +0000, Julien Grall wrote:
> 
> 
> On 25/02/2023 16:49, Julien Grall wrote:
> > Hi Oleksii,
> > 
> > On 24/02/2023 11:31, Oleksii Kurochko wrote:
> > > The following changes were made:
> > > * make GENERIC_BUG_FRAME mandatory for ARM
> > 
> > I have asked in patch #1 but will ask it again because I think this
> > should be recorded in the commit message. Can you outline why it is
> > not 
> > possible to completely switch to the generic version?
> 
> I have just tried to remove it on arm64 and it seems to work. This
> was 
> only tested with GCC 10 though. But given the generic version is not
> not 
> using the %c modifier, then I wouldn't expect any issue.
> 
> Cheers,
> 

I tried to switch ARM to generic implementation.

Here is the patch: [1]

diff --git a/xen/arch/arm/include/asm/bug.h
b/xen/arch/arm/include/asm/bug.h
index e6cc37e1d6..ffb0f569fc 100644
--- a/xen/arch/arm/include/asm/bug.h
+++ b/xen/arch/arm/include/asm/bug.h
@@ -1,8 +1,6 @@
 #ifndef __ARM_BUG_H__
 #define __ARM_BUG_H__
 
-#include <xen/types.h>
-
 #if defined(CONFIG_ARM_32)
 # include <asm/arm32/bug.h>
 #elif defined(CONFIG_ARM_64)
@@ -11,63 +9,7 @@
 # error "unknown ARM variant"
 #endif
 
-#define BUG_FRAME_STRUCT
-
-struct bug_frame {
-    signed int loc_disp;    /* Relative address to the bug address */
-    signed int file_disp;   /* Relative address to the filename */
-    signed int msg_disp;    /* Relative address to the predicate (for
ASSERT) */
-    uint16_t line;          /* Line number */
-    uint32_t pad0:16;       /* Padding for 8-bytes align */
-};
-
-#define bug_ptr(b) ((const void *)(b) + (b)->file_disp)
-#define bug_line(b) ((b)->line)
-#define bug_msg(b) ((const char *)(b) + (b)->msg_disp)
-
-/* Many versions of GCC doesn't support the asm %c parameter which
would
- * be preferable to this unpleasantness. We use mergeable string
- * sections to avoid multiple copies of the string appearing in the
- * Xen image. BUGFRAME_run_fn needs to be handled separately.
- */
-#define BUG_FRAME(type, line, file, has_msg, msg) do {               
\
-    BUILD_BUG_ON((line) >> 16);                                      
\
-    BUILD_BUG_ON((type) >= BUGFRAME_NR);                             
\
-    asm ("1:"BUG_INSTR"\n"                                           
\
-         ".pushsection .rodata.str, \"aMS\", %progbits, 1\n"         
\
-         "2:\t.asciz " __stringify(file) "\n"                        
\
-         "3:\n"                                                      
\
-         ".if " #has_msg "\n"                                        
\
-         "\t.asciz " #msg "\n"                                       
\
-         ".endif\n"                                                  
\
-         ".popsection\n"                                             
\
-         ".pushsection .bug_frames." __stringify(type) ", \"a\",
%progbits\n"\
-         "4:\n"                                                      
\
-         ".p2align 2\n"                                              
\
-         ".long (1b - 4b)\n"                                         
\
-         ".long (2b - 4b)\n"                                         
\
-         ".long (3b - 4b)\n"                                         
\
-         ".hword " __stringify(line) ", 0\n"                         
\
-         ".popsection");                                             
\
-} while (0)
-
-/*
- * GCC will not allow to use "i"  when PIE is enabled (Xen doesn't set
the
- * flag but instead rely on the default value from the compiler). So
the
- * easiest way to implement run_in_exception_handler() is to pass the
to
- * 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"                                           
\
-         ".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) );      
\
-} while (0)
+#define BUG_ASM_CONST   "c"
 
 #endif /* __ARM_BUG_H__ */
...
(it will be merged with patch 3 if it is OK )

And looks like we can switch ARM to generic implementation as all tests
passed:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/791549396

The only issue is with yocto-arm:
https://gitlab.com/xen-project/people/olkur/xen/-/pipelines/791549396/failures
But I am not sure that it is because of my patch

Is this enough from a verification point of view?

[1]
https://gitlab.com/xen-project/people/olkur/xen/-/commit/5ff7a06e1d354e1e42bde1c203f3cf05a3653ad6
https://gitlab.com/xen-project/people/olkur/xen/-/commit/5ff7a06e1d354e1e42bde1c203f3cf05a3653ad6


  reply	other threads:[~2023-02-28 17:21 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-24 11:31 [PATCH v3 0/4] introduce generic implementation of macros from bug.h Oleksii Kurochko
2023-02-24 11:31 ` [PATCH v3 1/4] xen: introduce CONFIG_GENERIC_BUG_FRAME Oleksii Kurochko
2023-02-25 16:42   ` Julien Grall
2023-02-27  9:48     ` Jan Beulich
2023-02-28 17:21     ` Oleksii
2023-02-28 18:01       ` Julien Grall
2023-02-28 20:24         ` Oleksii
2023-02-27 14:23   ` Jan Beulich
2023-02-28 10:30     ` Oleksii
2023-02-28 10:42       ` Jan Beulich
2023-02-24 11:31 ` [PATCH v3 2/4] xen: change <asm/bug.h> to <xen/bug.h> Oleksii Kurochko
2023-02-25 16:47   ` Julien Grall
2023-02-28 12:38     ` Oleksii
2023-02-28 14:04       ` Julien Grall
2023-02-28 13:07     ` Oleksii
2023-02-28 13:30       ` Jan Beulich
2023-02-28 16:00         ` Oleksii
2023-02-27 14:29   ` Jan Beulich
2023-02-28 13:14     ` Oleksii
2023-02-24 11:31 ` [PATCH v3 3/4] xen/arm: switch ARM to use generic implementation of bug.h Oleksii Kurochko
2023-02-25 16:49   ` Julien Grall
2023-02-25 17:05     ` Julien Grall
2023-02-28 17:21       ` Oleksii [this message]
2023-02-28 17:57         ` Julien Grall
2023-03-01 12:31           ` Oleksii
2023-03-01 13:58             ` Julien Grall
2023-03-01 15:16               ` Oleksii
2023-03-01 15:21                 ` Julien Grall
2023-03-01 15:28                   ` Oleksii
2023-03-01 15:58                   ` Oleksii
2023-02-28 15:09     ` Oleksii
2023-02-28 17:48       ` Julien Grall
2023-03-01  8:58         ` Oleksii
2023-03-01  9:31           ` Julien Grall
2023-03-01 12:33             ` Oleksii
2023-02-24 11:31 ` [PATCH v3 4/4] xen/x86: switch x86 to use generic implemetation " Oleksii Kurochko
2023-02-27 14:46   ` Jan Beulich
2023-02-28 16:28     ` Oleksii
2023-02-28 16:36       ` Jan Beulich

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=6735859208c6dcb7320f89664ae298005f70827b.camel@gmail.com \
    --to=oleksii.kurochko@gmail.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=gianluca@rivosinc.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --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.