xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] clang/llvm: build fixes
@ 2020-06-01 13:53 Roger Pau Monne
  2020-06-01 13:53 ` [PATCH v3 1/2] x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean Roger Pau Monne
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Roger Pau Monne @ 2020-06-01 13:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Roger Pau Monne, Wei Liu, Jan Beulich, paul

Hello,

Two pending bug fixes for clang/llvm toolstacks.

Roger Pau Monne (2):
  x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean
  build32: don't discard .shstrtab in linker script

 xen/arch/x86/boot/build32.lds | 14 ++++++++++++++
 xen/arch/x86/mm.c             |  9 ++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean
  2020-06-01 13:53 [PATCH v3 0/2] clang/llvm: build fixes Roger Pau Monne
@ 2020-06-01 13:53 ` Roger Pau Monne
  2020-06-01 13:53 ` [PATCH v3 2/2] build32: don't discard .shstrtab in linker script Roger Pau Monne
  2020-06-01 15:24 ` [PATCH v3 0/2] clang/llvm: build fixes Paul Durrant
  2 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monne @ 2020-06-01 13:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Roger Pau Monne, Wei Liu, Jan Beulich, paul

Clang 10 complains with:

mm.c:1239:10: error: converting the result of '<<' to a boolean always evaluates to true
      [-Werror,-Wtautological-constant-compare]
    if ( _PAGE_GNTTAB && (l1e_get_flags(l1e) & _PAGE_GNTTAB) &&
         ^
xen/include/asm/x86_64/page.h:161:25: note: expanded from macro '_PAGE_GNTTAB'
#define _PAGE_GNTTAB (1U<<22)
                        ^

Remove the conversion of _PAGE_GNTTAB to a boolean and instead use a
preprocessor conditional to check if _PAGE_GNTTAB is defined.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes since v2:
 - Add comment.

Changes since v1:
 - Use a preprocessor conditional.
---
 xen/arch/x86/mm.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 53e3dcb2d4..e376fc7e8f 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -1235,8 +1235,14 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner)
      *
      * (Note that the undestroyable active grants are not a security hole in
      * Xen. All active grants can safely be cleaned up when the domain dies.)
+     *
+     * NB: the preprocessor conditional is required in order to prevent clang's
+     * -Wtautological-constant-compare complaining about converting the result
+     * of a << into a bool is always true if it's evaluated directly in the if
+     * condition.
      */
-    if ( _PAGE_GNTTAB && (l1e_get_flags(l1e) & _PAGE_GNTTAB) &&
+#if _PAGE_GNTTAB
+    if ( (l1e_get_flags(l1e) & _PAGE_GNTTAB) &&
          !l1e_owner->is_shutting_down && !l1e_owner->is_dying )
     {
         gdprintk(XENLOG_WARNING,
@@ -1244,6 +1250,7 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner)
                  l1e_get_intpte(l1e));
         domain_crash(l1e_owner);
     }
+#endif
 
     /*
      * Remember we didn't take a type-count of foreign writable mappings
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] build32: don't discard .shstrtab in linker script
  2020-06-01 13:53 [PATCH v3 0/2] clang/llvm: build fixes Roger Pau Monne
  2020-06-01 13:53 ` [PATCH v3 1/2] x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean Roger Pau Monne
@ 2020-06-01 13:53 ` Roger Pau Monne
  2020-06-01 15:24 ` [PATCH v3 0/2] clang/llvm: build fixes Paul Durrant
  2 siblings, 0 replies; 4+ messages in thread
From: Roger Pau Monne @ 2020-06-01 13:53 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Roger Pau Monne, Wei Liu, Jan Beulich, paul

LLVM linker doesn't support discarding .shstrtab, and complains with:

ld -melf_i386_fbsd -N -T build32.lds -o reloc.lnk reloc.o
ld: error: discarding .shstrtab section is not allowed

Add an explicit .shstrtab, .strtab and .symtab sections to the linker
script after the text section in order to make LLVM LD happy and match
the behavior of GNU LD.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Changes since v2:
 - Also add .strtab and .symtab sections to match GNU behavior.
---
 xen/arch/x86/boot/build32.lds | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/xen/arch/x86/boot/build32.lds b/xen/arch/x86/boot/build32.lds
index 97454b40ff..1ab9418793 100644
--- a/xen/arch/x86/boot/build32.lds
+++ b/xen/arch/x86/boot/build32.lds
@@ -50,6 +50,20 @@ SECTIONS
         *(.got.plt)
   }
 
+  /*
+   * Discarding .shstrtab is not supported by LLD (LLVM LD) and will trigger an
+   * error. Also keep the rest of the control sections to match GNU LD behavior.
+   */
+  .shstrtab : {
+        *(.shstrtab)
+  }
+  .strtab : {
+        *(.strtab)
+  }
+  .symtab : {
+        *(.symtab)
+  }
+
   /DISCARD/ : {
         /*
          * Discard everything else, to prevent linkers from putting
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v3 0/2] clang/llvm: build fixes
  2020-06-01 13:53 [PATCH v3 0/2] clang/llvm: build fixes Roger Pau Monne
  2020-06-01 13:53 ` [PATCH v3 1/2] x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean Roger Pau Monne
  2020-06-01 13:53 ` [PATCH v3 2/2] build32: don't discard .shstrtab in linker script Roger Pau Monne
@ 2020-06-01 15:24 ` Paul Durrant
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Durrant @ 2020-06-01 15:24 UTC (permalink / raw)
  To: 'Roger Pau Monne', xen-devel
  Cc: 'Andrew Cooper', 'Wei Liu', 'Jan Beulich'

> -----Original Message-----
> From: Roger Pau Monne <roger.pau@citrix.com>
> Sent: 01 June 2020 14:53
> To: xen-devel@lists.xenproject.org
> Cc: paul@xen.org; Roger Pau Monne <roger.pau@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew
> Cooper <andrew.cooper3@citrix.com>; Wei Liu <wl@xen.org>
> Subject: [PATCH v3 0/2] clang/llvm: build fixes
> 
> Hello,
> 
> Two pending bug fixes for clang/llvm toolstacks.

I'm assuming you intend this to be in 4.14. If so,

Release-acked-by: Paul Durrant <paul@xen.org>

> 
> Roger Pau Monne (2):
>   x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean
>   build32: don't discard .shstrtab in linker script
> 
>  xen/arch/x86/boot/build32.lds | 14 ++++++++++++++
>  xen/arch/x86/mm.c             |  9 ++++++++-
>  2 files changed, 22 insertions(+), 1 deletion(-)
> 
> --
> 2.26.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-01 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-01 13:53 [PATCH v3 0/2] clang/llvm: build fixes Roger Pau Monne
2020-06-01 13:53 ` [PATCH v3 1/2] x86/mm: do not attempt to convert _PAGE_GNTTAB to a boolean Roger Pau Monne
2020-06-01 13:53 ` [PATCH v3 2/2] build32: don't discard .shstrtab in linker script Roger Pau Monne
2020-06-01 15:24 ` [PATCH v3 0/2] clang/llvm: build fixes Paul Durrant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).