xsm: fix clang 3.5 build after c47d1d
PATCH 1/1 xsm: fix clang 3.5 build after c47d1d
The changes introduced on c47d1d broke the clang build due to undefined references to __xsm_action_mismatch_detected, because clang hasn't optimized the code properly. The following patch allows the clang build to work again, while keeping the same functionality.
---
Cc: Daniel De Graaf <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Tamas K Lengyel <[email protected]>
---
NB: this fixes travis build: https://travis-ci.org/royger/xen/builds/219697038
--- xen/include/xsm/dummy.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
xen/include/xsm/dummy.h +7 -9
@@ -557,25 +557,23 @@ static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) static XSM_INLINE int xsm_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *d, uint64_t mode, uint32_t op) { -xsm_default_t a;XSM_ASSERT_ACTION (XSM_OTHER );switch ( mode ) {case XEN_ALTP2M_mixed: - a =XSM_TARGET ; -break ; +return xsm_default_action (XSM_TARGET , current->domain, d);case XEN_ALTP2M_external: - a =XSM_DM_PRIV ; +return xsm_default_action (XSM_DM_PRIV , current->domain, d);break ;case XEN_ALTP2M_limited: - a = (HVMOP_altp2m_vcpu_enable_notify == op) ?XSM_TARGET :XSM_DM_PRIV ; -break ; +if ( HVMOP_altp2m_vcpu_enable_notify == op ) +return xsm_default_action (XSM_TARGET , current->domain, d); +else +return xsm_default_action (XSM_DM_PRIV , current->domain, d);default :return -EPERM ; - }; - -return xsm_default_action (a, current->domain, d); + } } static XSM_INLINE int xsm_vm_event_control(XSM_DEFAULT_ARG struct domain *d, int mode, int op)
Signature · 7 lines
2.11.0 (Apple Git-81) _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
On Fri, 7 Apr 2017, Roger Pau Monne wrote:
...
xen/include/xsm/dummy.h static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) · line 569
Quoted 6 lines
xen/include/xsm/dummy.h +2
-1+return xsm_default_action (XSM_TARGET , current->domain, d);case XEN_ALTP2M_external: - a =XSM_DM_PRIV ; +return xsm_default_action (XSM_DM_PRIV , current->domain, d);break ;case XEN_ALTP2M_limited:
It looks like you left a break; in there which will never be reached.
Michael Young
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 16:34, <[email protected]> wrote:
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly.
This starts to become annoying.
Quoted 9 lines
xen/include/xsm/dummy.h +0
-1@@ -557,25 +557,23 @@ static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) static XSM_INLINE int xsm_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *d, uint64_t mode, uint32_t op) { -xsm_default_t a;XSM_ASSERT_ACTION (XSM_OTHER );
xen/include/xsm/dummy.h static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) · line 568
Quoted 10 lines
xen/include/xsm/dummy.h +2
-3switch ( mode ) {case XEN_ALTP2M_mixed: - a =XSM_TARGET ; -break ; +return xsm_default_action (XSM_TARGET , current->domain, d);case XEN_ALTP2M_external: - a =XSM_DM_PRIV ; +return xsm_default_action (XSM_DM_PRIV , current->domain, d);break ;
Just like above, this break wants to be eliminated.
xen/include/xsm/dummy.h static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) · line 573
Quoted 7 lines
xen/include/xsm/dummy.h +4
-2case XEN_ALTP2M_limited: - a = (HVMOP_altp2m_vcpu_enable_notify == op) ?XSM_TARGET :XSM_DM_PRIV ; -break ; +if ( HVMOP_altp2m_vcpu_enable_notify == op ) +return xsm_default_action (XSM_TARGET , current->domain, d); +else +return xsm_default_action (XSM_DM_PRIV , current->domain, d);
Could you either keep the conditional expression at least (as a direct function parameter), or if that still doesn't work at the minimum drop the pointless "else"?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Hi,
Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 16:34, <[email protected]> wrote:
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly.This starts to become annoying.
This is also breaking ARM32 build with GCC (4.9 and 5.4) (see [1]):
ld -EL -T xen.lds -N prelink.o \
/home/osstest/build.107275.build-armhf-xsm/xen/xen/common/symbols-dummy.o -o /home/osstest/build.107275.build-armhf-xsm/xen/xen/.xen-syms.0prelink.o: In function `xsm_default_action':/home/osstest/build.107275.build-armhf-xsm/xen/xen/include/xsm/dummy.h:80: undefined reference to `__xsm_action_mismatch_detected'
gcc -DPIC -marm -DBUILD_ID -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement -Wno-unused-but-set-variable -Wno-unused-local-typedefs -g3 -O0 -fno-omit-frame-pointer -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__ -MMD -MF .xc_dom_boot.opic.d -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -I../../xen/common/libelf -Werror -Wmissing-prototypes -I. -I./include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -D__XEN_TOOLS__ -pthread -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/libs/toollog/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/libs/evtchn/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/libs/devicemodel/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -include /home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/config.h -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/libs/call/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/libs/foreignmemory/include -I/home/osstest/build.107275.build-armhf-xsm/xen/tools/libxc/../../tools/include -fPIC -c -o xc_dom_boot.opic xc_dom_boot.c
ld: /home/osstest/build.107275.build-armhf-xsm/xen/xen/.xen-syms.0: hidden symbol `__xsm_action_mismatch_detected' isn't defined
ld: final link failed: Bad value
make[3]: *** [/home/osstest/build.107275.build-armhf-xsm/xen/xen/xen-syms] Error 1
Makefile:96: recipe for target '/home/osstest/build.107275.build-armhf-xsm/xen/xen/xen-syms' failed
make[3]: Leaving directory '/home/osstest/build.107275.build-armhf-xsm/xen/xen/arch/arm'
make[2]: *** [/home/osstest/build.107275.build-armhf-xsm/xen/xen/xen] Error 2
Makefile:136: recipe for target '/home/osstest/build.107275.build-armhf-xsm/xen/xen/xen' failed
make[2]: Leaving directory '/home/osstest/build.107275.build-armhf-xsm/xen/xen'
Makefile:45: recipe for target 'install' failed
make[1]: Leaving directory '/home/osstest/build.107275.build-armhf-xsm/xen/xen'
Makefile:97: recipe for target 'install-xen' failed
make[1]: *** [install] Error 2
make: *** [install-xen] Error 2
make: *** Waiting for unfinished jobs....
[1] http://logs.test-lab.xenproject.org/osstest/logs/107275/build-armhf-xsm/5.ts-xen-build.log
Signature · 5 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 09.04.17 at 21:01, <[email protected]> wrote:
Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 16:34, <[email protected]> wrote:
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly.This starts to become annoying.
This is also breaking ARM32 build with GCC (4.9 and 5.4) (see [1]):
That's certainly unexpected, as we're building with -O1 even for debug builds (for this very reason).
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 16:34, <[email protected]> wrote:
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly.This starts to become annoying.
Yes, tell me about it... I don't think we can blame clang for those failures anyway. Xen is relying on optimizations to do compile time validations, and AFAIK this is a grey area. There's nothing in the C spec that guarantees you that those calls will be removed.
Anyway, will send a new version shortly.
Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 6 lines · Roger Pau Monne
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.04.17 at 16:34, <[email protected]> wrote:
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly.
Quoted 8 lines
Quoted 1 line
This starts to become annoying.
Yes, tell me about it... I don't think we can blame clang for those failures anyway. Xen is relying on optimizations to do compile time validations, and AFAIK this is a grey area. There's nothing in the C spec that guarantees you that those calls will be removed.
Anyway, will send a new version shortly.
If this problem expands more, I think it would be best to restrict the check to a particular compiler or #define (as long as it's one used in the build bot); there's no need to do this kind of check on every build as long as it's done on occasional builds. Alternatively, it could be done by a static analysis tool, but I've not looked into how to do that with Coverity.
Signature · 7 lines
Daniel De Graaf National Security Agency _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Hi Roger,
Quoted 6 lines · Roger Pau Monne
The changes introduced on c47d1d broke the clang build due to undefined references to
__xsm_action_mismatch_detected, because clang hasn't optimized the code properly. The following patch allows the clang build to work again, while keeping the same functionality.Signed-off-by Roger Pau Monné <[email protected]>
FWIW: this is fixing ARM32 build with XSM (blocks osstest).
Cheers,
Quoted 48 lines
---
Cc: Daniel De Graaf <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Tamas K Lengyel <[email protected]>
---
NB: this fixes travis build: https://travis-ci.org/royger/xen/builds/219697038--- xen/include/xsm/dummy.h | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)xen/include/xsm/dummy.h +7
-9@@ -557,25 +557,23 @@ static XSM_INLINE int xsm_hvm_param_altp2mhvm(XSM_DEFAULT_ARG struct domain *d) static XSM_INLINE int xsm_hvm_altp2mhvm_op(XSM_DEFAULT_ARG struct domain *d, uint64_t mode, uint32_t op) { -xsm_default_t a;XSM_ASSERT_ACTION (XSM_OTHER );switch ( mode ) {case XEN_ALTP2M_mixed: - a =XSM_TARGET ; -break ; +return xsm_default_action (XSM_TARGET , current->domain, d);case XEN_ALTP2M_external: - a =XSM_DM_PRIV ; +return xsm_default_action (XSM_DM_PRIV , current->domain, d);break ;case XEN_ALTP2M_limited: - a = (HVMOP_altp2m_vcpu_enable_notify == op) ?XSM_TARGET :XSM_DM_PRIV ; -break ; +if ( HVMOP_altp2m_vcpu_enable_notify == op ) +return xsm_default_action (XSM_TARGET , current->domain, d); +else +return xsm_default_action (XSM_DM_PRIV , current->domain, d);default :return -EPERM ; - }; - -return xsm_default_action (a, current->domain, d); + } } static XSM_INLINE int xsm_vm_event_control(XSM_DEFAULT_ARG struct domain *d, int mode, int op)
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel