From 07f29b74020fa3b3f4fc2209e620e71a838062b4 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 6 Mar 2017 13:31:42 +0000 Subject: [PATCH] Fix x{get,set}bv() build with Clang 3.9 In 32bit builds, Clang objects to using uint64_t's with 32bit asm operands. In file included from /local/xen-test-framework.git/arch/x86/pv/traps.c:7: /local/xen-test-framework.git/arch/x86/include/arch/lib.h:404:52: error: invalid output size for constraint '=d' asm volatile ("xgetbv" : "=a" (feat_lo), "=d" (feat_hi) ^ /local/xen-test-framework.git/arch/x86/include/arch/lib.h:412:59: error: invalid input size for constraint 'd' asm volatile ("xsetbv" :: "a" ((uint32_t)value), "d" (value >> 32), ^ Signed-off-by: Andrew Cooper --- arch/x86/include/arch/lib.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/arch/lib.h b/arch/x86/include/arch/lib.h index cb3cde0..405343c 100644 --- a/arch/x86/include/arch/lib.h +++ b/arch/x86/include/arch/lib.h @@ -398,18 +398,18 @@ static inline unsigned int str(void) static inline uint64_t xgetbv(uint32_t index) { - uint32_t feat_lo; - uint64_t feat_hi; + uint32_t feat_lo, feat_hi; asm volatile ("xgetbv" : "=a" (feat_lo), "=d" (feat_hi) : "c" (index) ); - return feat_lo | (feat_hi << 32); + return feat_lo | ((uint64_t)feat_hi << 32); } static inline void xsetbv(uint32_t index, uint64_t value) { - asm volatile ("xsetbv" :: "a" ((uint32_t)value), "d" (value >> 32), + asm volatile ("xsetbv" :: "a" ((uint32_t)value), + "d" ((uint32_t)(value >> 32)), "c" (index) ); } -- 2.39.5