xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] x86/clang: build fixes
@ 2021-04-23  9:43 Roger Pau Monne
  2021-04-23  9:43 ` [PATCH 1/2] x86/oprofile: fix oprofile for clang build Roger Pau Monne
  2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
  0 siblings, 2 replies; 6+ messages in thread
From: Roger Pau Monne @ 2021-04-23  9:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Roger Pau Monne, Jan Beulich, Andrew Cooper, Wei Liu

Hello,

Two clang related build fixes to get the hypervisor building again with
clang without CONFIG_PV32.

Thanks, Roger.

Roger Pau Monne (2):
  x86/oprofile: fix oprofile for clang build
  x86/pv: fix clang build without CONFIG_PV32

 xen/arch/x86/oprofile/backtrace.c |  2 ++
 xen/arch/x86/pv/hypercall.c       | 18 +++++++++---------
 2 files changed, 11 insertions(+), 9 deletions(-)

-- 
2.30.1



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

* [PATCH 1/2] x86/oprofile: fix oprofile for clang build
  2021-04-23  9:43 [PATCH 0/2] x86/clang: build fixes Roger Pau Monne
@ 2021-04-23  9:43 ` Roger Pau Monne
  2021-04-23  9:45   ` Jan Beulich
  2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
  1 sibling, 1 reply; 6+ messages in thread
From: Roger Pau Monne @ 2021-04-23  9:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Roger Pau Monne, Jan Beulich, Andrew Cooper, Wei Liu

Clang complains with:

backtrace.c:46:19: error: unused function 'is_32bit_vcpu' [-Werror,-Wunused-function]
static inline int is_32bit_vcpu(struct vcpu *vcpu)
                  ^

Fix this by guarding the function with CONFIG_COMPAT, as it's only
caller is also doing so.

Fixes: d23d792478d ('x86: avoid building COMPAT code when !HVM && !PV32')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/oprofile/backtrace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/oprofile/backtrace.c b/xen/arch/x86/oprofile/backtrace.c
index 929bf51a408..bd5d1b0f6ce 100644
--- a/xen/arch/x86/oprofile/backtrace.c
+++ b/xen/arch/x86/oprofile/backtrace.c
@@ -43,6 +43,7 @@ dump_hypervisor_backtrace(struct vcpu *vcpu, const struct frame_head *head,
     return head->ebp;
 }
 
+#ifdef CONFIG_COMPAT
 static inline int is_32bit_vcpu(struct vcpu *vcpu)
 {
     if (is_hvm_vcpu(vcpu))
@@ -50,6 +51,7 @@ static inline int is_32bit_vcpu(struct vcpu *vcpu)
     else
         return is_pv_32bit_vcpu(vcpu);
 }
+#endif
 
 static struct frame_head *
 dump_guest_backtrace(struct vcpu *vcpu, const struct frame_head *head,
-- 
2.30.1



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

* [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32
  2021-04-23  9:43 [PATCH 0/2] x86/clang: build fixes Roger Pau Monne
  2021-04-23  9:43 ` [PATCH 1/2] x86/oprofile: fix oprofile for clang build Roger Pau Monne
@ 2021-04-23  9:43 ` Roger Pau Monne
  2021-04-23  9:46   ` Roger Pau Monné
  2021-04-23  9:48   ` Jan Beulich
  1 sibling, 2 replies; 6+ messages in thread
From: Roger Pau Monne @ 2021-04-23  9:43 UTC (permalink / raw)
  To: xen-devel; +Cc: Roger Pau Monne, Jan Beulich, Andrew Cooper, Wei Liu

Clang reports the following build error without CONFIG_PV:

hypercall.c:253:10: error: variable 'op' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
    if ( !is_pv_32bit_vcpu(curr) )
         ^~~~~~~~~~~~~~~~~~~~~~~
hypercall.c:282:21: note: uninitialized use occurs here
    return unlikely(op == __HYPERVISOR_iret)
                    ^~
/root/src/xen/xen/include/xen/compiler.h:21:43: note: expanded from macro 'unlikely'
#define unlikely(x)   __builtin_expect(!!(x),0)
                                          ^
hypercall.c:253:5: note: remove the 'if' if its condition is always true
    if ( !is_pv_32bit_vcpu(curr) )
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hypercall.c:251:21: note: initialize the variable 'op' to silence this warning
    unsigned long op;
                    ^
                     = 0

Rearrange the code in arch_do_multicall_call so that the if guards the
32bit branch and when CONFIG_PV32 is not set there's no conditional at
all.

Fixes: 527922008bc ('x86: slim down hypercall handling when !PV32')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Should the is_pv_32bit_vcpu be wrapped in an unlikely hint?
---
 xen/arch/x86/pv/hypercall.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c
index e30c59b6286..d573f74aa1e 100644
--- a/xen/arch/x86/pv/hypercall.c
+++ b/xen/arch/x86/pv/hypercall.c
@@ -250,34 +250,34 @@ enum mc_disposition arch_do_multicall_call(struct mc_state *state)
     struct vcpu *curr = current;
     unsigned long op;
 
-    if ( !is_pv_32bit_vcpu(curr) )
+#ifdef CONFIG_PV32
+    if ( is_pv_32bit_vcpu(curr) )
     {
-        struct multicall_entry *call = &state->call;
+        struct compat_multicall_entry *call = &state->compat_call;
 
         op = call->op;
         if ( (op < ARRAY_SIZE(pv_hypercall_table)) &&
-             pv_hypercall_table[op].native )
-            call->result = pv_hypercall_table[op].native(
+             pv_hypercall_table[op].compat )
+            call->result = pv_hypercall_table[op].compat(
                 call->args[0], call->args[1], call->args[2],
                 call->args[3], call->args[4], call->args[5]);
         else
             call->result = -ENOSYS;
     }
-#ifdef CONFIG_PV32
     else
+#endif
     {
-        struct compat_multicall_entry *call = &state->compat_call;
+        struct multicall_entry *call = &state->call;
 
         op = call->op;
         if ( (op < ARRAY_SIZE(pv_hypercall_table)) &&
-             pv_hypercall_table[op].compat )
-            call->result = pv_hypercall_table[op].compat(
+             pv_hypercall_table[op].native )
+            call->result = pv_hypercall_table[op].native(
                 call->args[0], call->args[1], call->args[2],
                 call->args[3], call->args[4], call->args[5]);
         else
             call->result = -ENOSYS;
     }
-#endif
 
     return unlikely(op == __HYPERVISOR_iret)
            ? mc_exit
-- 
2.30.1



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

* Re: [PATCH 1/2] x86/oprofile: fix oprofile for clang build
  2021-04-23  9:43 ` [PATCH 1/2] x86/oprofile: fix oprofile for clang build Roger Pau Monne
@ 2021-04-23  9:45   ` Jan Beulich
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2021-04-23  9:45 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: Andrew Cooper, Wei Liu, xen-devel

On 23.04.2021 11:43, Roger Pau Monne wrote:
> Clang complains with:
> 
> backtrace.c:46:19: error: unused function 'is_32bit_vcpu' [-Werror,-Wunused-function]
> static inline int is_32bit_vcpu(struct vcpu *vcpu)
>                   ^
> 
> Fix this by guarding the function with CONFIG_COMPAT, as it's only
> caller is also doing so.
> 
> Fixes: d23d792478d ('x86: avoid building COMPAT code when !HVM && !PV32')
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

See my "x86/oprof: fix !HVM && !PV32 build" from the 16th.

Jan


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

* Re: [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32
  2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
@ 2021-04-23  9:46   ` Roger Pau Monné
  2021-04-23  9:48   ` Jan Beulich
  1 sibling, 0 replies; 6+ messages in thread
From: Roger Pau Monné @ 2021-04-23  9:46 UTC (permalink / raw)
  To: xen-devel; +Cc: Jan Beulich, Andrew Cooper, Wei Liu

On Fri, Apr 23, 2021 at 11:43:43AM +0200, Roger Pau Monne wrote:
> Clang reports the following build error without CONFIG_PV:

s/CONFIG_PV/CONFIG_PV32/ on the line above, sorry.

Thanks, Roger.


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

* Re: [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32
  2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
  2021-04-23  9:46   ` Roger Pau Monné
@ 2021-04-23  9:48   ` Jan Beulich
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2021-04-23  9:48 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: Andrew Cooper, Wei Liu, xen-devel

On 23.04.2021 11:43, Roger Pau Monne wrote:
> Clang reports the following build error without CONFIG_PV:
> 
> hypercall.c:253:10: error: variable 'op' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
>     if ( !is_pv_32bit_vcpu(curr) )
>          ^~~~~~~~~~~~~~~~~~~~~~~
> hypercall.c:282:21: note: uninitialized use occurs here
>     return unlikely(op == __HYPERVISOR_iret)
>                     ^~
> /root/src/xen/xen/include/xen/compiler.h:21:43: note: expanded from macro 'unlikely'
> #define unlikely(x)   __builtin_expect(!!(x),0)
>                                           ^
> hypercall.c:253:5: note: remove the 'if' if its condition is always true
>     if ( !is_pv_32bit_vcpu(curr) )
>     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> hypercall.c:251:21: note: initialize the variable 'op' to silence this warning
>     unsigned long op;
>                     ^
>                      = 0
> 
> Rearrange the code in arch_do_multicall_call so that the if guards the
> 32bit branch and when CONFIG_PV32 is not set there's no conditional at
> all.
> 
> Fixes: 527922008bc ('x86: slim down hypercall handling when !PV32')
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

I find it odd for the compiler to warn like this, but well ...
Acked-by: Jan Beulich <jbeulich@suse.com>

> Should the is_pv_32bit_vcpu be wrapped in an unlikely hint?

Not sure. Andrew did some similar rearrangement elsewhere for
other reasons, without adding unlikely(). Personally I think
we'd better add them, but then preferably add consistently as
possible.

Jan


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

end of thread, other threads:[~2021-04-23  9:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23  9:43 [PATCH 0/2] x86/clang: build fixes Roger Pau Monne
2021-04-23  9:43 ` [PATCH 1/2] x86/oprofile: fix oprofile for clang build Roger Pau Monne
2021-04-23  9:45   ` Jan Beulich
2021-04-23  9:43 ` [PATCH 2/2] x86/pv: fix clang build without CONFIG_PV32 Roger Pau Monne
2021-04-23  9:46   ` Roger Pau Monné
2021-04-23  9:48   ` Jan Beulich

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).