Skip to contentSkip to conversation

suspicious compiler warning in vdso2c.h

PATCH Jan Beulich 2 participants 2 messages Sep 16, 2014 x86

lore
Share & tools
lore
#0 lore raw

Andy

following e6577a7ce9 ("x86, vdso: Move the vvar area before the vdso text") gcc 4.3.4 tells me

.../arch/x86/vdso/vdso2c.c: In function ‘main’:
.../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
.../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false

apparently because it unrolls the containing loop and finds i == sym_vvar_start on the first iteration. I think there was a hidden dependency before your change on required_syms[] first two entries matching up with special_pages[]. If that's correct, all syms[i] within said loop would seem to need replacing by syms[special_pages[i]] (similarly for required_syms[i] afaict, see below draft patch), which also is in line with the loop iterating over the array elements of special_pages[].

Question then of course is - are there any further hidden dependencies that already got or may eventually get broken?

Jan

arch/x86/vdso/vdso2c.h +7 -7
@@ -109,18 +109,18 @@ static void BITSFUNC(go)(void *raw_addr,
 
 	/* Validate mapping addresses. */
 	for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) {
-		if (!syms[i])
+		if (!syms[special_pages[i]])
 			continue;  /* The mapping isn't used; ignore it. */
 
-		if (syms[i] % 4096)
+		if (syms[special_pages[i]] % 4096)
 			fail("%s must be a multiple of 4096\n",
-			     required_syms[i].name);
-		if (syms[sym_vvar_start] > syms[i] + 4096)
+			     required_syms[special_pages[i]].name);
+		if (syms[sym_vvar_start] > syms[special_pages[i]] + 4096)
 			fail("%s underruns begin_vvar\n",
-			     required_syms[i].name);
-		if (syms[i] + 4096 > 0)
+			     required_syms[special_pages[i]].name);
+		if (syms[special_pages[i]] + 4096 > 0)
 			fail("%s is on the wrong side of the vdso text\n",
-			     required_syms[i].name);
+			     required_syms[special_pages[i]].name);
 	}
 	if (syms[sym_vvar_start] % 4096)
 		fail("vvar_begin must be a multiple of 4096\n");
#1 lore raw
Quoted 11 lines · Jan Beulich

Andy

following e6577a7ce9 ("x86, vdso: Move the vvar area before the vdso text") gcc 4.3.4 tells me

.../arch/x86/vdso/vdso2c.c: In function ‘main’:
.../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false
.../arch/x86/vdso/vdso2c.h:118: warning: assuming signed overflow does not occur when assuming that (X + c) < X is always false

Yes. There's a more or less equivalent fix sitting in -mm.

--Andy

Quoted 44 lines

apparently because it unrolls the containing loop and finds i == sym_vvar_start on the first iteration. I think there was a hidden dependency before your change on required_syms[] first two entries matching up with special_pages[]. If that's correct, all syms[i] within said loop would seem to need replacing by syms[special_pages[i]] (similarly for required_syms[i] afaict, see below draft patch), which also is in line with the loop iterating over the array elements of special_pages[].

Question then of course is - are there any further hidden dependencies that already got or may eventually get broken?

Jan

arch/x86/vdso/vdso2c.h +7 -7
@@ -109,18 +109,18 @@ static void BITSFUNC(go)(void *raw_addr,
 
        /* Validate mapping addresses. */
        for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) {
-               if (!syms[i])
+               if (!syms[special_pages[i]])
                        continue;  /* The mapping isn't used; ignore it. */
 
-               if (syms[i] % 4096)
+               if (syms[special_pages[i]] % 4096)
                        fail("%s must be a multiple of 4096\n",
-                            required_syms[i].name);
-               if (syms[sym_vvar_start] > syms[i] + 4096)
+                            required_syms[special_pages[i]].name);
+               if (syms[sym_vvar_start] > syms[special_pages[i]] + 4096)
                        fail("%s underruns begin_vvar\n",
-                            required_syms[i].name);
-               if (syms[i] + 4096 > 0)
+                            required_syms[special_pages[i]].name);
+               if (syms[special_pages[i]] + 4096 > 0)
                        fail("%s is on the wrong side of the vdso text\n",
-                            required_syms[i].name);
+                            required_syms[special_pages[i]].name);
        }
        if (syms[sym_vvar_start] % 4096)
                fail("vvar_begin must be a multiple of 4096\n");