Skip to content

Commit 0d8598d

Browse files
committed
test/vdso-proxy: handle merged vma-s
When we compare two list of vma-s, we need to take into account that some of them could be merged. Fixes #12286 Signed-off-by: Andrei Vagin <avagin@google.com>
1 parent 5a04cdb commit 0d8598d

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

test/zdtm/static/vdso-proxy.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static int parse_maps(struct vm_area *vmas)
7070
#endif
7171
v->is_vvar_or_vdso |= strstr(buf, "[vdso]") != NULL;
7272
v->is_vvar_or_vdso |= strstr(buf, "[vvar]") != NULL;
73+
v->is_vvar_or_vdso |= strstr(buf, "[vvar_vclock]") != NULL;
7374
test_msg("[NOTE]\tVMA: [%#" PRIx64 ", %#" PRIx64 "]\n", v->start, v->end);
7475
}
7576

@@ -104,24 +105,30 @@ static int check_vvar_vdso(struct vm_area *before, struct vm_area *after)
104105
{
105106
int i, j = 0;
106107

107-
for (i = 0; i < MAX_VMAS && j < MAX_VMAS; i++, j++) {
108-
int cmp = compare_vmas(&before[i], &after[j]);
109-
110-
if (cmp == 0)
111-
continue;
112-
113-
if (cmp < 0) { /* Lost mapping */
108+
for (i = 0; i < MAX_VMAS && j < MAX_VMAS;) {
109+
if (before[i].start < after[j].start) {
114110
test_msg("[NOTE]\tLost mapping: %#" PRIx64 "-%#" PRIx64 "\n", before[i].start, before[i].end);
115-
j--;
116111
if (before[i].is_vvar_or_vdso) {
117112
fail("Lost vvar/vdso mapping");
118113
return -1;
119114
}
115+
i++;
120116
continue;
121117
}
122-
123-
test_msg("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n", after[j].start, after[j].end);
124-
i--;
118+
if (before[i].start > after[j].start) {
119+
test_msg("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n", after[j].start, after[j].end);
120+
j++;
121+
continue;
122+
}
123+
if (before[i].end == after[j].end) {
124+
i++; j++;
125+
} else if (before[i].end > after[j].end) {
126+
before[i].start = after[j].end;
127+
j++;
128+
} else {
129+
after[j].start = before[i].end;
130+
i++;
131+
}
125132
}
126133

127134
return 0;

0 commit comments

Comments
 (0)