KVM: x86: Change parameter of kvm_mmu_slot_remove_write_access
This patch changes the second parameter of kvm_mmu_slot_remove_write_access from 'slot id' to 'struct kvm_memory_slot *' to align with kvm_x86_ops dirty logging hooks, which will be introduced in further patch. Better way is to change second parameter of kvm_arch_commit_memory_region from 'struct kvm_userspace_memory_region *' to 'struct kvm_memory_slot * new', but it requires changes on other non-x86 ARCH too, so avoid it now. Signed-off-by: Kai Huang <kai.huang@linux.intel.com> Reviewed-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
@@ -834,7 +834,8 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask,
|
|||||||
u64 dirty_mask, u64 nx_mask, u64 x_mask);
|
u64 dirty_mask, u64 nx_mask, u64 x_mask);
|
||||||
|
|
||||||
void kvm_mmu_reset_context(struct kvm_vcpu *vcpu);
|
void kvm_mmu_reset_context(struct kvm_vcpu *vcpu);
|
||||||
void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot);
|
void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
|
||||||
|
struct kvm_memory_slot *memslot);
|
||||||
void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
|
void kvm_mmu_slot_leaf_clear_dirty(struct kvm *kvm,
|
||||||
struct kvm_memory_slot *memslot);
|
struct kvm_memory_slot *memslot);
|
||||||
void kvm_mmu_slot_largepage_remove_write_access(struct kvm *kvm,
|
void kvm_mmu_slot_largepage_remove_write_access(struct kvm *kvm,
|
||||||
|
|||||||
+2
-3
@@ -4408,14 +4408,13 @@ void kvm_mmu_setup(struct kvm_vcpu *vcpu)
|
|||||||
init_kvm_mmu(vcpu);
|
init_kvm_mmu(vcpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
|
void kvm_mmu_slot_remove_write_access(struct kvm *kvm,
|
||||||
|
struct kvm_memory_slot *memslot)
|
||||||
{
|
{
|
||||||
struct kvm_memory_slot *memslot;
|
|
||||||
gfn_t last_gfn;
|
gfn_t last_gfn;
|
||||||
int i;
|
int i;
|
||||||
bool flush = false;
|
bool flush = false;
|
||||||
|
|
||||||
memslot = id_to_memslot(kvm->memslots, slot);
|
|
||||||
last_gfn = memslot->base_gfn + memslot->npages - 1;
|
last_gfn = memslot->base_gfn + memslot->npages - 1;
|
||||||
|
|
||||||
spin_lock(&kvm->mmu_lock);
|
spin_lock(&kvm->mmu_lock);
|
||||||
|
|||||||
+7
-3
@@ -7538,7 +7538,7 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
|
|||||||
const struct kvm_memory_slot *old,
|
const struct kvm_memory_slot *old,
|
||||||
enum kvm_mr_change change)
|
enum kvm_mr_change change)
|
||||||
{
|
{
|
||||||
|
struct kvm_memory_slot *new;
|
||||||
int nr_mmu_pages = 0;
|
int nr_mmu_pages = 0;
|
||||||
|
|
||||||
if ((mem->slot >= KVM_USER_MEM_SLOTS) && (change == KVM_MR_DELETE)) {
|
if ((mem->slot >= KVM_USER_MEM_SLOTS) && (change == KVM_MR_DELETE)) {
|
||||||
@@ -7557,6 +7557,10 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
|
|||||||
|
|
||||||
if (nr_mmu_pages)
|
if (nr_mmu_pages)
|
||||||
kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
|
kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
|
||||||
|
|
||||||
|
/* It's OK to get 'new' slot here as it has already been installed */
|
||||||
|
new = id_to_memslot(kvm->memslots, mem->slot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write protect all pages for dirty logging.
|
* Write protect all pages for dirty logging.
|
||||||
*
|
*
|
||||||
@@ -7566,8 +7570,8 @@ void kvm_arch_commit_memory_region(struct kvm *kvm,
|
|||||||
*
|
*
|
||||||
* See the comments in fast_page_fault().
|
* See the comments in fast_page_fault().
|
||||||
*/
|
*/
|
||||||
if ((change != KVM_MR_DELETE) && (mem->flags & KVM_MEM_LOG_DIRTY_PAGES))
|
if ((change != KVM_MR_DELETE) && (new->flags & KVM_MEM_LOG_DIRTY_PAGES))
|
||||||
kvm_mmu_slot_remove_write_access(kvm, mem->slot);
|
kvm_mmu_slot_remove_write_access(kvm, new);
|
||||||
}
|
}
|
||||||
|
|
||||||
void kvm_arch_flush_shadow_all(struct kvm *kvm)
|
void kvm_arch_flush_shadow_all(struct kvm *kvm)
|
||||||
|
|||||||
Reference in New Issue
Block a user