Re: [kvm-unit-tests PATCH v3 5/6] x86: use a non-negative number in shift

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30/10/2019 22.04, Bill Wendling wrote:
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@xxxxxxxxxx>
---
  x86/svm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/svm.c b/x86/svm.c
index 4ddfaa4..cef43d5 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -1122,7 +1122,7 @@ static bool npt_rw_l1mmio_check(struct 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 test *test)


Reviewed-by: Thomas Huth <thuth@xxxxxxxxxx>





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux