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
Kirill Smelkov
linux
Commits
d5d1cf47
Commit
d5d1cf47
authored
Nov 26, 2021
by
Paolo Bonzini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'kvm-5.16-fixes-pre-rc2' into HEAD
parents
3d627cc3
8ed716ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
30 deletions
+42
-30
arch/x86/kvm/ioapic.h
arch/x86/kvm/ioapic.h
+0
-1
arch/x86/kvm/irq.h
arch/x86/kvm/irq.h
+0
-1
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/mmu/mmu.c
+3
-3
arch/x86/kvm/mmu/tdp_mmu.c
arch/x86/kvm/mmu/tdp_mmu.c
+6
-8
virt/kvm/kvm_main.c
virt/kvm/kvm_main.c
+33
-17
No files found.
arch/x86/kvm/ioapic.h
View file @
d5d1cf47
...
...
@@ -81,7 +81,6 @@ struct kvm_ioapic {
unsigned
long
irq_states
[
IOAPIC_NUM_PINS
];
struct
kvm_io_device
dev
;
struct
kvm
*
kvm
;
void
(
*
ack_notifier
)(
void
*
opaque
,
int
irq
);
spinlock_t
lock
;
struct
rtc_status
rtc_status
;
struct
delayed_work
eoi_inject
;
...
...
arch/x86/kvm/irq.h
View file @
d5d1cf47
...
...
@@ -56,7 +56,6 @@ struct kvm_pic {
struct
kvm_io_device
dev_master
;
struct
kvm_io_device
dev_slave
;
struct
kvm_io_device
dev_elcr
;
void
(
*
ack_notifier
)(
void
*
opaque
,
int
irq
);
unsigned
long
irq_states
[
PIC_NUM_PINS
];
};
...
...
arch/x86/kvm/mmu/mmu.c
View file @
d5d1cf47
...
...
@@ -1582,7 +1582,7 @@ bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range)
flush
=
kvm_handle_gfn_range
(
kvm
,
range
,
kvm_unmap_rmapp
);
if
(
is_tdp_mmu_enabled
(
kvm
))
flush
|
=
kvm_tdp_mmu_unmap_gfn_range
(
kvm
,
range
,
flush
);
flush
=
kvm_tdp_mmu_unmap_gfn_range
(
kvm
,
range
,
flush
);
return
flush
;
}
...
...
@@ -5854,7 +5854,7 @@ static bool kvm_mmu_zap_collapsible_spte(struct kvm *kvm,
void
kvm_mmu_zap_collapsible_sptes
(
struct
kvm
*
kvm
,
const
struct
kvm_memory_slot
*
slot
)
{
bool
flush
=
false
;
bool
flush
;
if
(
kvm_memslots_have_rmaps
(
kvm
))
{
write_lock
(
&
kvm
->
mmu_lock
);
...
...
@@ -5871,7 +5871,7 @@ void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
if
(
is_tdp_mmu_enabled
(
kvm
))
{
read_lock
(
&
kvm
->
mmu_lock
);
flush
=
kvm_tdp_mmu_zap_collapsible_sptes
(
kvm
,
slot
,
f
lush
);
flush
=
kvm_tdp_mmu_zap_collapsible_sptes
(
kvm
,
slot
,
f
alse
);
if
(
flush
)
kvm_arch_flush_remote_tlbs_memslot
(
kvm
,
slot
);
read_unlock
(
&
kvm
->
mmu_lock
);
...
...
arch/x86/kvm/mmu/tdp_mmu.c
View file @
d5d1cf47
...
...
@@ -317,9 +317,6 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, tdp_ptep_t pt,
struct
kvm_mmu_page
*
sp
=
sptep_to_sp
(
rcu_dereference
(
pt
));
int
level
=
sp
->
role
.
level
;
gfn_t
base_gfn
=
sp
->
gfn
;
u64
old_child_spte
;
u64
*
sptep
;
gfn_t
gfn
;
int
i
;
trace_kvm_mmu_prepare_zap_page
(
sp
);
...
...
@@ -327,8 +324,9 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, tdp_ptep_t pt,
tdp_mmu_unlink_page
(
kvm
,
sp
,
shared
);
for
(
i
=
0
;
i
<
PT64_ENT_PER_PAGE
;
i
++
)
{
sptep
=
rcu_dereference
(
pt
)
+
i
;
gfn
=
base_gfn
+
i
*
KVM_PAGES_PER_HPAGE
(
level
);
u64
*
sptep
=
rcu_dereference
(
pt
)
+
i
;
gfn_t
gfn
=
base_gfn
+
i
*
KVM_PAGES_PER_HPAGE
(
level
);
u64
old_child_spte
;
if
(
shared
)
{
/*
...
...
@@ -374,7 +372,7 @@ static void handle_removed_tdp_mmu_page(struct kvm *kvm, tdp_ptep_t pt,
shared
);
}
kvm_flush_remote_tlbs_with_address
(
kvm
,
gfn
,
kvm_flush_remote_tlbs_with_address
(
kvm
,
base_
gfn
,
KVM_PAGES_PER_HPAGE
(
level
+
1
));
call_rcu
(
&
sp
->
rcu_head
,
tdp_mmu_free_sp_rcu_callback
);
...
...
@@ -1034,8 +1032,8 @@ bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
struct
kvm_mmu_page
*
root
;
for_each_tdp_mmu_root
(
kvm
,
root
,
range
->
slot
->
as_id
)
flush
|
=
zap_gfn_range
(
kvm
,
root
,
range
->
start
,
range
->
end
,
range
->
may_block
,
flush
,
false
);
flush
=
zap_gfn_range
(
kvm
,
root
,
range
->
start
,
range
->
end
,
range
->
may_block
,
flush
,
false
);
return
flush
;
}
...
...
virt/kvm/kvm_main.c
View file @
d5d1cf47
...
...
@@ -1531,11 +1531,10 @@ static struct kvm_memslots *kvm_dup_memslots(struct kvm_memslots *old,
static
int
kvm_set_memslot
(
struct
kvm
*
kvm
,
const
struct
kvm_userspace_memory_region
*
mem
,
struct
kvm_memory_slot
*
old
,
struct
kvm_memory_slot
*
new
,
int
as_id
,
enum
kvm_mr_change
change
)
{
struct
kvm_memory_slot
*
slot
;
struct
kvm_memory_slot
*
slot
,
old
;
struct
kvm_memslots
*
slots
;
int
r
;
...
...
@@ -1566,7 +1565,7 @@ static int kvm_set_memslot(struct kvm *kvm,
* Note, the INVALID flag needs to be in the appropriate entry
* in the freshly allocated memslots, not in @old or @new.
*/
slot
=
id_to_memslot
(
slots
,
old
->
id
);
slot
=
id_to_memslot
(
slots
,
new
->
id
);
slot
->
flags
|=
KVM_MEMSLOT_INVALID
;
/*
...
...
@@ -1597,6 +1596,26 @@ static int kvm_set_memslot(struct kvm *kvm,
kvm_copy_memslots
(
slots
,
__kvm_memslots
(
kvm
,
as_id
));
}
/*
* Make a full copy of the old memslot, the pointer will become stale
* when the memslots are re-sorted by update_memslots(), and the old
* memslot needs to be referenced after calling update_memslots(), e.g.
* to free its resources and for arch specific behavior. This needs to
* happen *after* (re)acquiring slots_arch_lock.
*/
slot
=
id_to_memslot
(
slots
,
new
->
id
);
if
(
slot
)
{
old
=
*
slot
;
}
else
{
WARN_ON_ONCE
(
change
!=
KVM_MR_CREATE
);
memset
(
&
old
,
0
,
sizeof
(
old
));
old
.
id
=
new
->
id
;
old
.
as_id
=
as_id
;
}
/* Copy the arch-specific data, again after (re)acquiring slots_arch_lock. */
memcpy
(
&
new
->
arch
,
&
old
.
arch
,
sizeof
(
old
.
arch
));
r
=
kvm_arch_prepare_memory_region
(
kvm
,
new
,
mem
,
change
);
if
(
r
)
goto
out_slots
;
...
...
@@ -1604,14 +1623,18 @@ static int kvm_set_memslot(struct kvm *kvm,
update_memslots
(
slots
,
new
,
change
);
slots
=
install_new_memslots
(
kvm
,
as_id
,
slots
);
kvm_arch_commit_memory_region
(
kvm
,
mem
,
old
,
new
,
change
);
kvm_arch_commit_memory_region
(
kvm
,
mem
,
&
old
,
new
,
change
);
/* Free the old memslot's metadata. Note, this is the full copy!!! */
if
(
change
==
KVM_MR_DELETE
)
kvm_free_memslot
(
kvm
,
&
old
);
kvfree
(
slots
);
return
0
;
out_slots:
if
(
change
==
KVM_MR_DELETE
||
change
==
KVM_MR_MOVE
)
{
slot
=
id_to_memslot
(
slots
,
old
->
id
);
slot
=
id_to_memslot
(
slots
,
new
->
id
);
slot
->
flags
&=
~
KVM_MEMSLOT_INVALID
;
slots
=
install_new_memslots
(
kvm
,
as_id
,
slots
);
}
else
{
...
...
@@ -1626,7 +1649,6 @@ static int kvm_delete_memslot(struct kvm *kvm,
struct
kvm_memory_slot
*
old
,
int
as_id
)
{
struct
kvm_memory_slot
new
;
int
r
;
if
(
!
old
->
npages
)
return
-
EINVAL
;
...
...
@@ -1639,12 +1661,7 @@ static int kvm_delete_memslot(struct kvm *kvm,
*/
new
.
as_id
=
as_id
;
r
=
kvm_set_memslot
(
kvm
,
mem
,
old
,
&
new
,
as_id
,
KVM_MR_DELETE
);
if
(
r
)
return
r
;
kvm_free_memslot
(
kvm
,
old
);
return
0
;
return
kvm_set_memslot
(
kvm
,
mem
,
&
new
,
as_id
,
KVM_MR_DELETE
);
}
/*
...
...
@@ -1672,7 +1689,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
id
=
(
u16
)
mem
->
slot
;
/* General sanity checks */
if
(
mem
->
memory_size
&
(
PAGE_SIZE
-
1
))
if
((
mem
->
memory_size
&
(
PAGE_SIZE
-
1
))
||
(
mem
->
memory_size
!=
(
unsigned
long
)
mem
->
memory_size
))
return
-
EINVAL
;
if
(
mem
->
guest_phys_addr
&
(
PAGE_SIZE
-
1
))
return
-
EINVAL
;
...
...
@@ -1718,7 +1736,6 @@ int __kvm_set_memory_region(struct kvm *kvm,
if
(
!
old
.
npages
)
{
change
=
KVM_MR_CREATE
;
new
.
dirty_bitmap
=
NULL
;
memset
(
&
new
.
arch
,
0
,
sizeof
(
new
.
arch
));
}
else
{
/* Modify an existing slot. */
if
((
new
.
userspace_addr
!=
old
.
userspace_addr
)
||
(
new
.
npages
!=
old
.
npages
)
||
...
...
@@ -1732,9 +1749,8 @@ int __kvm_set_memory_region(struct kvm *kvm,
else
/* Nothing to change. */
return
0
;
/* Copy dirty_bitmap
and arch
from the current memslot. */
/* Copy dirty_bitmap from the current memslot. */
new
.
dirty_bitmap
=
old
.
dirty_bitmap
;
memcpy
(
&
new
.
arch
,
&
old
.
arch
,
sizeof
(
new
.
arch
));
}
if
((
change
==
KVM_MR_CREATE
)
||
(
change
==
KVM_MR_MOVE
))
{
...
...
@@ -1760,7 +1776,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
bitmap_set
(
new
.
dirty_bitmap
,
0
,
new
.
npages
);
}
r
=
kvm_set_memslot
(
kvm
,
mem
,
&
old
,
&
new
,
as_id
,
change
);
r
=
kvm_set_memslot
(
kvm
,
mem
,
&
new
,
as_id
,
change
);
if
(
r
)
goto
out_bitmap
;
...
...
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