@@ -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
@@ -86,54 +87,46 @@ static int parse_maps(struct vm_area *vmas)
8687 return i ;
8788}
8889
89- int compare_vmas (struct vm_area * vmax , struct vm_area * vmay )
90- {
91- if (vmax -> start > vmay -> start )
92- return 1 ;
93- if (vmax -> start < vmay -> start )
94- return -1 ;
95- if (vmax -> end > vmay -> end )
96- return 1 ;
97- if (vmax -> end < vmay -> end )
98- return -1 ;
99-
100- return 0 ;
101- }
102-
103- static int check_vvar_vdso (struct vm_area * before , struct vm_area * after )
90+ static int check_vvar_vdso (struct vm_area * before , int nr_before , struct vm_area * after , int nr_after )
10491{
10592 int i , j = 0 ;
10693
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 */
94+ for (i = 0 , j = 0 ; i < nr_before || j < nr_after ;) {
95+ if (j == nr_after || before [i ].start < after [j ].start ) {
11496 test_msg ("[NOTE]\tLost mapping: %#" PRIx64 "-%#" PRIx64 "\n" , before [i ].start , before [i ].end );
115- j -- ;
11697 if (before [i ].is_vvar_or_vdso ) {
11798 fail ("Lost vvar/vdso mapping" );
11899 return -1 ;
119100 }
101+ i ++ ;
120102 continue ;
121103 }
122-
123- test_msg ("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n" , after [j ].start , after [j ].end );
124- i -- ;
104+ if (i == nr_before || before [i ].start > after [j ].start ) {
105+ test_msg ("[NOTE]\tNew mapping appeared: %#" PRIx64 "-%#" PRIx64 "\n" , after [j ].start , after [j ].end );
106+ j ++ ;
107+ continue ;
108+ }
109+ if (before [i ].end == after [j ].end ) {
110+ i ++ ;
111+ j ++ ;
112+ } else if (before [i ].end > after [j ].end ) {
113+ before [i ].start = after [j ].end ;
114+ j ++ ;
115+ } else {
116+ after [j ].start = before [i ].end ;
117+ i ++ ;
118+ }
125119 }
126120
127121 return 0 ;
128122}
129123
130124static struct vm_area vmas_before [MAX_VMAS ];
131125static struct vm_area vmas_after [MAX_VMAS ];
126+ static int nr_before , nr_after ;
132127
133128int main (int argc , char * argv [])
134129{
135- int nr_before , nr_after ;
136-
137130 test_init (argc , argv );
138131
139132 test_msg ("[NOTE]\tMappings before:\n" );
@@ -154,7 +147,7 @@ int main(int argc, char *argv[])
154147 }
155148
156149 /* After restore vDSO/VVAR blobs must remain in the old place. */
157- if (check_vvar_vdso (vmas_before , vmas_after ))
150+ if (check_vvar_vdso (vmas_before , nr_before , vmas_after , nr_after ))
158151 return -1 ;
159152
160153 if (nr_before + 2 < nr_after ) {
0 commit comments