Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
b050b015
Commit
b050b015
authored
Dec 23, 2009
by
Marcelo Tosatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
KVM: use SRCU for dirty log
Signed-off-by:
Marcelo Tosatti
<
mtosatti@redhat.com
>
parent
bc6678a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
8 deletions
+41
-8
arch/x86/kvm/x86.c
arch/x86/kvm/x86.c
+41
-8
No files found.
arch/x86/kvm/x86.c
View file @
b050b015
...
...
@@ -2415,27 +2415,60 @@ static int kvm_vm_ioctl_reinject(struct kvm *kvm,
int
kvm_vm_ioctl_get_dirty_log
(
struct
kvm
*
kvm
,
struct
kvm_dirty_log
*
log
)
{
int
r
;
int
n
;
int
r
,
n
,
i
;
struct
kvm_memory_slot
*
memslot
;
int
is_dirty
=
0
;
unsigned
long
is_dirty
=
0
;
unsigned
long
*
dirty_bitmap
=
NULL
;
down_write
(
&
kvm
->
slots_lock
);
r
=
kvm_get_dirty_log
(
kvm
,
log
,
&
is_dirty
);
if
(
r
)
r
=
-
EINVAL
;
if
(
log
->
slot
>=
KVM_MEMORY_SLOTS
)
goto
out
;
memslot
=
&
kvm
->
memslots
->
memslots
[
log
->
slot
];
r
=
-
ENOENT
;
if
(
!
memslot
->
dirty_bitmap
)
goto
out
;
n
=
ALIGN
(
memslot
->
npages
,
BITS_PER_LONG
)
/
8
;
r
=
-
ENOMEM
;
dirty_bitmap
=
vmalloc
(
n
);
if
(
!
dirty_bitmap
)
goto
out
;
memset
(
dirty_bitmap
,
0
,
n
);
for
(
i
=
0
;
!
is_dirty
&&
i
<
n
/
sizeof
(
long
);
i
++
)
is_dirty
=
memslot
->
dirty_bitmap
[
i
];
/* If nothing is dirty, don't bother messing with page tables. */
if
(
is_dirty
)
{
struct
kvm_memslots
*
slots
,
*
old_slots
;
spin_lock
(
&
kvm
->
mmu_lock
);
kvm_mmu_slot_remove_write_access
(
kvm
,
log
->
slot
);
spin_unlock
(
&
kvm
->
mmu_lock
);
memslot
=
&
kvm
->
memslots
->
memslots
[
log
->
slot
];
n
=
ALIGN
(
memslot
->
npages
,
BITS_PER_LONG
)
/
8
;
memset
(
memslot
->
dirty_bitmap
,
0
,
n
);
slots
=
kzalloc
(
sizeof
(
struct
kvm_memslots
),
GFP_KERNEL
);
if
(
!
slots
)
goto
out_free
;
memcpy
(
slots
,
kvm
->
memslots
,
sizeof
(
struct
kvm_memslots
));
slots
->
memslots
[
log
->
slot
].
dirty_bitmap
=
dirty_bitmap
;
old_slots
=
kvm
->
memslots
;
rcu_assign_pointer
(
kvm
->
memslots
,
slots
);
synchronize_srcu_expedited
(
&
kvm
->
srcu
);
dirty_bitmap
=
old_slots
->
memslots
[
log
->
slot
].
dirty_bitmap
;
kfree
(
old_slots
);
}
r
=
0
;
if
(
copy_to_user
(
log
->
dirty_bitmap
,
dirty_bitmap
,
n
))
r
=
-
EFAULT
;
out_free:
vfree
(
dirty_bitmap
);
out:
up_write
(
&
kvm
->
slots_lock
);
return
r
;
...
...
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