Skip to contentSkip to conversation

alpha: Fix build error for linux-user

PATCH In review Pranith Kumar 4 participants 9 messages Jun 16, 2016 – Jun 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alpha: Fix build error for linux-user

Using gcc 6.1 for alpha-linux-user target we see the following build error:

/mnt/devops/code/qemu/target-alpha/translate.c: In function ‘in_superpage’:
/mnt/devops/code/qemu/target-alpha/translate.c:454:52: error: self-comparison always evaluates to true [-Werror=tautological-compare]

             && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);

Fix it by replacing (addr >> 63) by '1' which is what it evaluates to since addr is negative.

---
 target-alpha/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-alpha/translate.c +1 -1
index f9b2426..31da6ea 100644
@@ -451,7 +451,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr)
     return ((ctx->tb->flags & TB_FLAGS_USER_MODE) == 0
             && addr < 0
             && ((addr >> 41) & 3) == 2
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
 }
 
 static bool use_goto_tb(DisasContext *ctx, uint64_t dest)
Signature · 1 line
2.9.0
#1 lore raw
Quoted 20 lines · Pranith Kumar

Using gcc 6.1 for alpha-linux-user target we see the following build error:

/mnt/devops/code/qemu/target-alpha/translate.c: In function ‘in_superpage’:
/mnt/devops/code/qemu/target-alpha/translate.c:454:52: error: self-comparison always evaluates to true [-Werror=tautological-compare]

             && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);

Fix it by replacing (addr >> 63) by '1' which is what it evaluates to since addr is negative.

---
 target-alpha/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-alpha/translate.c +0 -0
index f9b2426..31da6ea 100644

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 455

Quoted 6 lines
target-alpha/translate.c +1 -1
@@ -451,7 +451,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr)
     return ((ctx->tb->flags & TB_FLAGS_USER_MODE) == 0
             && addr < 0
             && ((addr >> 41) & 3) == 2
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
 }

This fix is incorrect.

(1) addr is not always negative.
(2) in_superpage is only relevant for alpha-softmmu, where TARGET_VIRT_ADDR_SPACE_BITS is not 63.

r~

#2 lore raw
Quoted 30 lines · Richard Henderson
Quoted 20 lines · Pranith Kumar

Using gcc 6.1 for alpha-linux-user target we see the following build error:

/mnt/devops/code/qemu/target-alpha/translate.c: In function ‘in_superpage’:
/mnt/devops/code/qemu/target-alpha/translate.c:454:52: error: self-comparison always evaluates to true [-Werror=tautological-compare]

             && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);

Fix it by replacing (addr >> 63) by '1' which is what it evaluates to since addr is negative.

---
 target-alpha/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-alpha/translate.c +0 -0
index f9b2426..31da6ea 100644

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 455

Quoted 6 lines
target-alpha/translate.c +1 -1
@@ -451,7 +451,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr)
     return ((ctx->tb->flags & TB_FLAGS_USER_MODE) == 0
             && addr < 0
             && ((addr >> 41) & 3) == 2
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
 }

This fix is incorrect.

Quoted 3 lines

(1) addr is not always negative.
(2) in_superpage is only relevant for alpha-softmmu, where TARGET_VIRT_ADDR_SPACE_BITS is not 63.

If you see line 2 of the condition you check for (addr < 0). Only if this evaluates to true do you check the right shift value of addr.

Reg. (2), I think that is what gcc is erroring out for. TARGET_VIRT_ADDR_SPACE_BITS is 63 for linux-user and we are comparing (addr >> 63) with itself. GCC rightly says that it is a tautological compare and errors out. May be we can have a better work around.

Thanks!

Signature · 1 line
Pranith
#3 lore raw
Quoted 35 lines · Pranith Kumar
Quoted 30 lines · Richard Henderson
Quoted 20 lines · Pranith Kumar

Using gcc 6.1 for alpha-linux-user target we see the following build error:

/mnt/devops/code/qemu/target-alpha/translate.c: In function ‘in_superpage’:
/mnt/devops/code/qemu/target-alpha/translate.c:454:52: error: self-comparison always evaluates to true [-Werror=tautological-compare]

             && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);

Fix it by replacing (addr >> 63) by '1' which is what it evaluates to since addr is negative.

---
 target-alpha/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-alpha/translate.c +0 -0
index f9b2426..31da6ea 100644

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 455

Quoted 6 lines
target-alpha/translate.c +1 -1
@@ -451,7 +451,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr)
     return ((ctx->tb->flags & TB_FLAGS_USER_MODE) == 0
             && addr < 0
             && ((addr >> 41) & 3) == 2
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
 }

This fix is incorrect.

Quoted 3 lines

(1) addr is not always negative.
(2) in_superpage is only relevant for alpha-softmmu, where TARGET_VIRT_ADDR_SPACE_BITS is not 63.

Quoted 7 lines

If you see line 2 of the condition you check for (addr < 0). Only if this evaluates to true do you check the right shift value of addr.

Reg. (2), I think that is what gcc is erroring out for. TARGET_VIRT_ADDR_SPACE_BITS is 63 for linux-user and we are comparing (addr >> 63) with itself. GCC rightly says that it is a tautological compare and errors out. May be we can have a better work around.

Perhaps something like:

#ifndef CONFIG_USER_ONLY
static bool in_superpage(DisasContext *ctx, int64_t addr) {
...
}
#endif
...

#ifdef CONFIG_USER_ONLY
    pc_mask = ~TARGET_PAGE_MASK;
#else
    if (in_superpage(&ctx, pc_start)) {
        pc_mask = (1ULL << 41) - 1;
    } else {
       pc_mask = ~TARGET_PAGE_MASK;
    }

#endif

Laurent

#4 lore raw
Quoted 64 lines · Laurent Vivier
Quoted 35 lines · Pranith Kumar
Quoted 30 lines · Richard Henderson
Quoted 20 lines · Pranith Kumar

Using gcc 6.1 for alpha-linux-user target we see the following build error:

/mnt/devops/code/qemu/target-alpha/translate.c: In function ‘in_superpage’:
/mnt/devops/code/qemu/target-alpha/translate.c:454:52: error: self-comparison always evaluates to true [-Werror=tautological-compare]

             && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);

Fix it by replacing (addr >> 63) by '1' which is what it evaluates to since addr is negative.

---
 target-alpha/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-alpha/translate.c +0 -0
index f9b2426..31da6ea 100644

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 455

Quoted 6 lines
target-alpha/translate.c +1 -1
@@ -451,7 +451,7 @@ static bool in_superpage(DisasContext *ctx, int64_t addr)
     return ((ctx->tb->flags & TB_FLAGS_USER_MODE) == 0
             && addr < 0
             && ((addr >> 41) & 3) == 2
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
 }

This fix is incorrect.

Quoted 3 lines

(1) addr is not always negative.
(2) in_superpage is only relevant for alpha-softmmu, where TARGET_VIRT_ADDR_SPACE_BITS is not 63.

Quoted 7 lines

If you see line 2 of the condition you check for (addr < 0). Only if this evaluates to true do you check the right shift value of addr.

Reg. (2), I think that is what gcc is erroring out for. TARGET_VIRT_ADDR_SPACE_BITS is 63 for linux-user and we are comparing (addr >> 63) with itself. GCC rightly says that it is a tautological compare and errors out. May be we can have a better work around.

Perhaps something like:

#ifndef CONFIG_USER_ONLY
static bool in_superpage(DisasContext *ctx, int64_t addr) {
...
}
#endif
...

#ifdef CONFIG_USER_ONLY
    pc_mask = ~TARGET_PAGE_MASK;
#else
    if (in_superpage(&ctx, pc_start)) {
        pc_mask = (1ULL << 41) - 1;
    } else {
       pc_mask = ~TARGET_PAGE_MASK;
    }
Quoted 2 lines

#endif

OK, I will use this.

Thanks!

Signature · 1 line
Pranith
#5 lore raw
In reply to Richard Henderson
Quoted 3 lines · Richard Henderson

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 454

Quoted 3 lines
             && ((addr >> 41) & 3) == 2
target-alpha/translate.c +1 -1
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);

What you want here is

+ addr >> TARGET_VIRT_ADDR_SPACE_BITS == -1

since that's what addr >> 63 is. With this change the patch should be fine.

Alternatively, combining this condition with addr < 0 should be

	(uint64_t)addr >= (-1ull << TARGET_VIRT_ADDR_SPACE_BITS)

I think (I might have an off by one here, sorry). If you go this way, it's of course nicer to change the argument type to uint64_t.

Paolo

#6 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Richard Henderson

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 454

Quoted 3 lines
             && ((addr >> 41) & 3) == 2
target-alpha/translate.c +1 -1
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
Quoted 5 lines

What you want here is

+ addr >> TARGET_VIRT_ADDR_SPACE_BITS == -1

since that's what addr >> 63 is. With this change the patch should be fine.

Isn't (addr >> 63) supposed to be 1? How can it be -1?

Signature · 1 line
Pranith
#7 lore raw
Quoted 8 lines · Pranith Kumar
Quoted 7 lines · Paolo Bonzini
Quoted 3 lines · Richard Henderson
Quoted 3 lines
             && ((addr >> 41) & 3) == 2
target-alpha/translate.c +1 -1
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);
Quoted 7 lines
Quoted 5 lines

What you want here is

+ addr >> TARGET_VIRT_ADDR_SPACE_BITS == -1

since that's what addr >> 63 is. With this change the patch should be fine.

Isn't (addr >> 63) supposed to be 1? How can it be -1?

Signed right shift.

I'll prepare a patch for all of this.

r~

#8 lore raw
Quoted 11 lines · Richard Henderson
Quoted 10 lines · Pranith Kumar
Quoted 9 lines · Paolo Bonzini
Quoted 3 lines · Richard Henderson

target-alpha/translate.c static bool in_superpage(DisasContext *ctx, int64_t addr) · line 454

Quoted 3 lines
             && ((addr >> 41) & 3) == 2
target-alpha/translate.c +1 -1
-            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == addr >> 63);
+            && addr >> TARGET_VIRT_ADDR_SPACE_BITS == 1);

What you want here is

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

+ addr >> TARGET_VIRT_ADDR_SPACE_BITS == -1

since that's what addr >> 63 is. With this change the patch should be fine.

Isn't (addr >> 63) supposed to be 1? How can it be -1?

Signed right shift.

Ah, got it. :)

Quoted 2 lines

I'll prepare a patch for all of this.

Thanks!

Signature · 1 line
Pranith