Skip to contentSkip to conversation

x86/pmu: Fix compilation on 32-bit hosts

PATCH In review Thomas Huth 3 participants 4 messages Jun 16, 2020 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pmu: Fix compilation on 32-bit hosts

When building for 32-bit hosts, the compiler currently complains:

x86/pmu.c: In function 'check_gp_counters_write_width':
x86/pmu.c:490:30: error: left shift count >= width of type

Use the correct suffix to avoid this problem.

---
 x86/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/pmu.c +1 -1
index 57a2b23..91a6fb4 100644
@@ -487,7 +487,7 @@ static void do_unsupported_width_counter_write(void *index)
 static void  check_gp_counters_write_width(void)
 {
 	u64 val_64 = 0xffffff0123456789ull;
-	u64 val_32 = val_64 & ((1ul << 32) - 1);
+	u64 val_32 = val_64 & ((1ull << 32) - 1);
 	u64 val_max_width = val_64 & ((1ul << eax.split.bit_width) - 1);
 	int i;
 
Signature · 1 line
2.18.1
#1 lore raw
Quoted 8 lines · Thomas Huth

When building for 32-bit hosts, the compiler currently complains:

x86/pmu.c: In function 'check_gp_counters_write_width':
x86/pmu.c:490:30: error: left shift count >= width of type

Use the correct suffix to avoid this problem.

Thanks, I admit I did not test it on a 32-bit host.

Quoted 17 lines
---
  x86/pmu.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
x86/pmu.c +1 -1
index 57a2b23..91a6fb4 100644
@@ -487,7 +487,7 @@ static void do_unsupported_width_counter_write(void *index)
  static void  check_gp_counters_write_width(void)
  {
  	u64 val_64 = 0xffffff0123456789ull;
-	u64 val_32 = val_64 & ((1ul << 32) - 1);
+	u64 val_32 = val_64 & ((1ull << 32) - 1);
  	u64 val_max_width = val_64 & ((1ul << eax.split.bit_width) - 1);
  	int i;
 
#2 lore raw
Quoted 11 lines · Like
Quoted 8 lines · Thomas Huth

When building for 32-bit hosts, the compiler currently complains:

  x86/pmu.c: In function 'check_gp_counters_write_width':
  x86/pmu.c:490:30: error: left shift count >= width of type

Use the correct suffix to avoid this problem.

Thanks, I admit I did not test it on a 32-bit host.

No problem, that's what the CI is good for :-)

(if you have a github or gitlab account, you can also run the tests there before submitting a patch)

Thomas

maintainer
#3 lore raw
In reply to Thomas Huth
Quoted 18 lines · Thomas Huth

When building for 32-bit hosts, the compiler currently complains:

x86/pmu.c: In function 'check_gp_counters_write_width':
x86/pmu.c:490:30: error: left shift count >= width of type

Use the correct suffix to avoid this problem.

---
 x86/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/pmu.c +0 -0
index 57a2b23..91a6fb4 100644

x86/pmu.c static void do_unsupported_width_counter_write(void *index) · line 493

Quoted 8 lines
x86/pmu.c +1 -1
@@ -487,7 +487,7 @@ static void do_unsupported_width_counter_write(void *index)
 static void  check_gp_counters_write_width(void)
 {
 	u64 val_64 = 0xffffff0123456789ull;
-	u64 val_32 = val_64 & ((1ul << 32) - 1);
+	u64 val_32 = val_64 & ((1ull << 32) - 1);
 	u64 val_max_width = val_64 & ((1ul << eax.split.bit_width) - 1);
 	int i;
 

Oh ok, applied. Thanks,

Paolo