[kvm-unit-tests,08/11] x86: use a non-negative number in shift
diff mbox series

Message ID 20200514192626.9950-9-thuth@redhat.com
State New
Headers show
  • Misc fixes and CI improvements
Related show

Commit Message

Thomas Huth May 14, 2020, 7:26 p.m. UTC
From: Bill Wendling <morbo@google.com>

Shifting a negative number is undefined. Clang complains about it:

x86/svm.c:1131:38: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
    test->vmcb->control.tsc_offset = TSC_OFFSET_VALUE;

Using "~0ull" results in identical asm code:

	before: movabsq $-281474976710656, %rsi
	after:  movabsq $-281474976710656, %rsi

Signed-off-by: Bill Wendling <morbo@google.com>
[thuth: Rebased to master - code is in svm_tests.c instead of svm.c now]
Signed-off-by: Thomas Huth <thuth@redhat.com>
 x86/svm_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff mbox series

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 2f53b8f..be1bddf 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -844,7 +844,7 @@  static bool npt_rw_l1mmio_check(struct svm_test *test)
 #define TSC_ADJUST_VALUE    (1ll << 32)
-#define TSC_OFFSET_VALUE    (-1ll << 48)
+#define TSC_OFFSET_VALUE    (~0ull << 48)
 static bool ok;
 static void tsc_adjust_prepare(struct svm_test *test)