Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
fce8cac1
Commit
fce8cac1
authored
Mar 04, 2015
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mem: Move private vmas maping code into subroutine
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
dceb6633
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
32 deletions
+41
-32
cr-restore.c
cr-restore.c
+41
-32
No files found.
cr-restore.c
View file @
fce8cac1
...
...
@@ -337,6 +337,44 @@ static int map_private_vma(pid_t pid, struct vma_area *vma, void **tgt_addr,
return
0
;
}
static
int
premap_priv_vmas
(
pid_t
pid
,
struct
vm_area_list
*
vmas
,
void
*
at
)
{
struct
list_head
*
parent_vmas
;
struct
vma_area
*
pvma
,
*
vma
;
unsigned
long
pstart
=
0
;
int
ret
=
0
;
LIST_HEAD
(
empty
);
/*
* Keep parent vmas at hands to check whether we can "inherit" them.
* See comments in map_private_vma.
*/
if
(
current
->
parent
)
parent_vmas
=
&
rsti
(
current
->
parent
)
->
vmas
.
h
;
else
parent_vmas
=
&
empty
;
pvma
=
list_first_entry
(
parent_vmas
,
struct
vma_area
,
list
);
list_for_each_entry
(
vma
,
&
vmas
->
h
,
list
)
{
if
(
pstart
>
vma
->
e
->
start
)
{
ret
=
-
1
;
pr_err
(
"VMA-s are not sorted in the image file
\n
"
);
break
;
}
pstart
=
vma
->
e
->
start
;
if
(
!
vma_priv
(
vma
->
e
))
continue
;
ret
=
map_private_vma
(
pid
,
vma
,
&
at
,
&
pvma
,
parent_vmas
);
if
(
ret
<
0
)
break
;
}
return
ret
;
}
static
int
restore_priv_vma_content
(
pid_t
pid
)
{
struct
vma_area
*
vma
;
...
...
@@ -483,28 +521,16 @@ err_addr:
static
int
prepare_mappings
(
int
pid
)
{
int
ret
=
0
;
struct
vma_area
*
pvma
,
*
vma
;
void
*
addr
;
struct
vm_area_list
*
vmas
;
struct
list_head
*
parent_vmas
=
NULL
;
LIST_HEAD
(
empty
);
void
*
old_premmapped_addr
=
NULL
;
unsigned
long
old_premmapped_len
,
pstart
=
0
;
unsigned
long
old_premmapped_len
;
vmas
=
&
rsti
(
current
)
->
vmas
;
if
(
vmas
->
nr
==
0
)
/* Zombie */
goto
out
;
/*
* Keep parent vmas at hands to check whether we can "inherit" them.
* See comments in map_private_vma.
*/
if
(
current
->
parent
)
parent_vmas
=
&
rsti
(
current
->
parent
)
->
vmas
.
h
;
else
parent_vmas
=
&
empty
;
/* Reserve a place for mapping private vma-s one by one */
addr
=
mmap
(
NULL
,
vmas
->
priv_size
,
PROT_NONE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
0
,
0
);
if
(
addr
==
MAP_FAILED
)
{
...
...
@@ -517,25 +543,8 @@ static int prepare_mappings(int pid)
rsti
(
current
)
->
premmapped_addr
=
addr
;
rsti
(
current
)
->
premmapped_len
=
vmas
->
priv_size
;
pvma
=
list_first_entry
(
parent_vmas
,
struct
vma_area
,
list
);
list_for_each_entry
(
vma
,
&
vmas
->
h
,
list
)
{
if
(
pstart
>
vma
->
e
->
start
)
{
ret
=
-
1
;
pr_err
(
"VMA-s are not sorted in the image file
\n
"
);
break
;
}
pstart
=
vma
->
e
->
start
;
if
(
!
vma_priv
(
vma
->
e
))
continue
;
ret
=
map_private_vma
(
pid
,
vma
,
&
addr
,
&
pvma
,
parent_vmas
);
if
(
ret
<
0
)
break
;
}
if
(
ret
>=
0
)
ret
=
premap_priv_vmas
(
pid
,
vmas
,
addr
);
if
(
ret
==
0
)
ret
=
restore_priv_vma_content
(
pid
);
out:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment