Skip to contentSkip to conversation

KVM: PPC: Book3S HV: Cleanups - constify memslots, fix comments

PATCH In review Paul Mackerras 3 participants 3 messages Dec 12, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/4 KVM: PPC: Book3S HV: Cleanups - constify memslots, fix comments

This adds 'const' to the declarations for the struct kvm_memory_slot pointer parameters of some functions, which will make it possible to call those functions from kvmppc_core_commit_memory_region_hv() in the next patch.

This also fixes some comments about locking.

---
 arch/powerpc/include/asm/kvm_book3s.h    | 9 +++------
 arch/powerpc/include/asm/kvm_book3s_64.h | 2 +-
 arch/powerpc/kvm/book3s_64_mmu_radix.c   | 9 +++++----
 arch/powerpc/kvm/book3s_hv_nested.c      | 2 +-
 arch/powerpc/kvm/book3s_hv_rm_mmu.c      | 2 +-
 5 files changed, 11 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/kvm_book3s.h +3 -6
index 09f8e9b..728d2b7 100644
@@ -197,7 +197,8 @@ extern int kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr,
 extern int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 			struct kvmppc_pte *gpte, bool data, bool iswrite);
 extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
-			unsigned int shift, struct kvm_memory_slot *memslot,
+			unsigned int shift,
+			const struct kvm_memory_slot *memslot,
 			unsigned int lpid);
 extern bool kvmppc_hv_handle_set_rc(struct kvm *kvm, pgd_t *pgtable,
 				    bool writing, unsigned long gpa,
@@ -215,10 +216,6 @@ extern int kvmppc_radix_init(void);
 extern void kvmppc_radix_exit(void);
 extern int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			unsigned long gfn);
-extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte,
-			     unsigned long gpa, unsigned int shift,
-			     struct kvm_memory_slot *memslot,
-			     unsigned int lpid);
 extern int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			unsigned long gfn);
 extern int kvm_test_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
@@ -242,7 +239,7 @@ extern kvm_pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa,
 			bool writing, bool *writable);
 extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
 			unsigned long *rmap, long pte_index, int realmode);
-extern void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+extern void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
 			unsigned long gfn, unsigned long psize);
 extern void kvmppc_invalidate_hpte(struct kvm *kvm, __be64 *hptep,
 			unsigned long pte_index);
arch/powerpc/include/asm/kvm_book3s_64.h +1 -1
index 6d29814..c9cbaf0 100644
@@ -625,7 +625,7 @@ extern int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
 extern void kvmhv_insert_nest_rmap(struct kvm *kvm, unsigned long *rmapp,
 				   struct rmap_nested **n_rmap);
 extern void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				struct kvm_memory_slot *memslot,
+				const struct kvm_memory_slot *memslot,
 				unsigned long gpa, unsigned long hpa,
 				unsigned long nbytes);
 
arch/powerpc/kvm/book3s_64_mmu_radix.c +5 -4
index 87ad35e..52711eb 100644
@@ -284,7 +284,8 @@ static void kvmppc_pmd_free(pmd_t *pmdp)
 
 /* Called with kvm->mmu_lock held */
 void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
-		      unsigned int shift, struct kvm_memory_slot *memslot,
+		      unsigned int shift,
+		      const struct kvm_memory_slot *memslot,
 		      unsigned int lpid)
 
 {
@@ -861,7 +862,7 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	return ret;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		    unsigned long gfn)
 {
@@ -876,7 +877,7 @@ int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 	return 0;				
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		  unsigned long gfn)
 {
@@ -895,7 +896,7 @@ int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 	return ref;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_test_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		       unsigned long gfn)
 {
arch/powerpc/kvm/book3s_hv_nested.c +1 -1
index 401d2ec..6d1b14b 100644
@@ -723,7 +723,7 @@ static void kvmhv_remove_nest_rmap_list(struct kvm *kvm, unsigned long *rmapp,
 
 /* called with kvm->mmu_lock held */
 void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				  struct kvm_memory_slot *memslot,
+				  const struct kvm_memory_slot *memslot,
 				  unsigned long gpa, unsigned long hpa,
 				  unsigned long nbytes)
 {
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
index a67cf1c..3b3791e 100644
@@ -107,7 +107,7 @@ void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
 EXPORT_SYMBOL_GPL(kvmppc_add_revmap_chain);
 
 /* Update the dirty bitmap of a memslot */
-void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
 			     unsigned long gfn, unsigned long psize)
 {
 	unsigned long npages;
Signature · 1 line
2.7.4
Reviewed-by on v1 3/4
#1 lore raw
Quoted 6 lines · Paul Mackerras

This adds 'const' to the declarations for the struct kvm_memory_slot pointer parameters of some functions, which will make it possible to call those functions from kvmppc_core_commit_memory_region_hv() in the next patch.

This also fixes some comments about locking.

Quoted 156 lines
---
 arch/powerpc/include/asm/kvm_book3s.h    | 9 +++------
 arch/powerpc/include/asm/kvm_book3s_64.h | 2 +-
 arch/powerpc/kvm/book3s_64_mmu_radix.c   | 9 +++++----
 arch/powerpc/kvm/book3s_hv_nested.c      | 2 +-
 arch/powerpc/kvm/book3s_hv_rm_mmu.c      | 2 +-
 5 files changed, 11 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/kvm_book3s.h +0 -1
index 09f8e9b..728d2b7 100644
@@ -197,7 +197,8 @@ extern int
 kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr,
 extern int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t
 eaddr,
 			struct kvmppc_pte *gpte, bool data, bool
 iswrite);
 extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned
 long gpa,
-			unsigned int shift, struct kvm_memory_slot

*memslot,

arch/powerpc/include/asm/kvm_book3s.h +2 -4
+			unsigned int shift,
+			const struct kvm_memory_slot *memslot,
 			unsigned int lpid);
 extern bool kvmppc_hv_handle_set_rc(struct kvm *kvm, pgd_t *pgtable,
 				    bool writing, unsigned long gpa,
@@ -215,10 +216,6 @@ extern int kvmppc_radix_init(void);
 extern void kvmppc_radix_exit(void);
 extern int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot
 *memslot,
 			unsigned long gfn);
-extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte,
-			     unsigned long gpa, unsigned int shift,
-			     struct kvm_memory_slot *memslot,
-			     unsigned int lpid);
 extern int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot
 *memslot,

unsigned long gfn);
extern int kvm_test_age_radix(struct kvm *kvm, struct
kvm_memory_slot *memslot,

arch/powerpc/include/asm/kvm_book3s.h +1 -1
@@ -242,7 +239,7 @@ extern kvm_pfn_t kvmppc_gpa_to_pfn(struct
 kvm_vcpu *vcpu, gpa_t gpa,
 			bool writing, bool *writable);
 extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct
 revmap_entry *rev,
 			unsigned long *rmap, long pte_index, int
 realmode);
-extern void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+extern void kvmppc_update_dirty_map(const struct kvm_memory_slot

*memslot,

arch/powerpc/include/asm/kvm_book3s.h +0 -0
 			unsigned long gfn, unsigned long psize);
 extern void kvmppc_invalidate_hpte(struct kvm *kvm, __be64 *hptep,
 			unsigned long pte_index);
arch/powerpc/include/asm/kvm_book3s_64.h +1 -1
index 6d29814..c9cbaf0 100644
@@ -625,7 +625,7 @@ extern int kvmppc_create_pte(struct kvm *kvm,
 pgd_t *pgtable, pte_t pte,
 extern void kvmhv_insert_nest_rmap(struct kvm *kvm, unsigned long
 *rmapp,
 				   struct rmap_nested **n_rmap);
 extern void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				struct kvm_memory_slot *memslot,
+				const struct kvm_memory_slot
 *memslot,

unsigned long gpa, unsigned long
hpa,

arch/powerpc/include/asm/kvm_book3s_64.h +0 -0
 				unsigned long nbytes);
arch/powerpc/kvm/book3s_64_mmu_radix.c +2 -1
index 87ad35e..52711eb 100644
@@ -284,7 +284,8 @@ static void kvmppc_pmd_free(pmd_t *pmdp)
 
 /* Called with kvm->mmu_lock held */
 void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long
 gpa,
-		      unsigned int shift, struct kvm_memory_slot
 *memslot,
+		      unsigned int shift,
+		      const struct kvm_memory_slot *memslot,
 		      unsigned int lpid)

{

arch/powerpc/kvm/book3s_64_mmu_radix.c +1 -1
@@ -861,7 +862,7 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run
 *run, struct kvm_vcpu *vcpu,
 	return ret;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot
 *memslot,
arch/powerpc/kvm/book3s_64_mmu_radix.c +1 -1
 		    unsigned long gfn)
 {
@@ -876,7 +877,7 @@ int kvm_unmap_radix(struct kvm *kvm, struct
 kvm_memory_slot *memslot,
 	return 0;				
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		  unsigned long gfn)

{

arch/powerpc/kvm/book3s_64_mmu_radix.c +1 -1
@@ -895,7 +896,7 @@ int kvm_age_radix(struct kvm *kvm, struct
 kvm_memory_slot *memslot,
 	return ref;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_test_age_radix(struct kvm *kvm, struct kvm_memory_slot
 *memslot,
arch/powerpc/kvm/book3s_64_mmu_radix.c +0 -0
 		       unsigned long gfn)
 {
arch/powerpc/kvm/book3s_hv_nested.c +1 -1
index 401d2ec..6d1b14b 100644
@@ -723,7 +723,7 @@ static void kvmhv_remove_nest_rmap_list(struct
 kvm *kvm, unsigned long *rmapp,
 
 /* called with kvm->mmu_lock held */
 void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				  struct kvm_memory_slot *memslot,
+				  const struct kvm_memory_slot
 *memslot,
 				  unsigned long gpa, unsigned long

hpa,

arch/powerpc/kvm/book3s_hv_nested.c +0 -0
 				  unsigned long nbytes)
 {
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
index a67cf1c..3b3791e 100644
@@ -107,7 +107,7 @@ void kvmppc_add_revmap_chain(struct kvm *kvm,
 struct revmap_entry *rev,
 EXPORT_SYMBOL_GPL(kvmppc_add_revmap_chain);
 
 /* Update the dirty bitmap of a memslot */
-void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
 			     unsigned long gfn, unsigned long psize)
 {

unsigned long npages;

Reviewed-by on v1 3/4
#2 lore raw
In reply to Paul Mackerras
Quoted 8 lines · Paul Mackerras

This adds 'const' to the declarations for the struct kvm_memory_slot pointer parameters of some functions, which will make it possible to call those functions from kvmppc_core_commit_memory_region_hv() in the next patch.

This also fixes some comments about locking.

Quoted 122 lines
---
 arch/powerpc/include/asm/kvm_book3s.h    | 9 +++------
 arch/powerpc/include/asm/kvm_book3s_64.h | 2 +-
 arch/powerpc/kvm/book3s_64_mmu_radix.c   | 9 +++++----
 arch/powerpc/kvm/book3s_hv_nested.c      | 2 +-
 arch/powerpc/kvm/book3s_hv_rm_mmu.c      | 2 +-
 5 files changed, 11 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/kvm_book3s.h +3 -6
index 09f8e9b..728d2b7 100644
@@ -197,7 +197,8 @@ extern int kvmppc_mmu_radix_translate_table(struct kvm_vcpu *vcpu, gva_t eaddr,
 extern int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
 			struct kvmppc_pte *gpte, bool data, bool iswrite);
 extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
-			unsigned int shift, struct kvm_memory_slot *memslot,
+			unsigned int shift,
+			const struct kvm_memory_slot *memslot,
 			unsigned int lpid);
 extern bool kvmppc_hv_handle_set_rc(struct kvm *kvm, pgd_t *pgtable,
 				    bool writing, unsigned long gpa,
@@ -215,10 +216,6 @@ extern int kvmppc_radix_init(void);
 extern void kvmppc_radix_exit(void);
 extern int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			unsigned long gfn);
-extern void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte,
-			     unsigned long gpa, unsigned int shift,
-			     struct kvm_memory_slot *memslot,
-			     unsigned int lpid);
 extern int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 			unsigned long gfn);
 extern int kvm_test_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
@@ -242,7 +239,7 @@ extern kvm_pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa,
 			bool writing, bool *writable);
 extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
 			unsigned long *rmap, long pte_index, int realmode);
-extern void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+extern void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
 			unsigned long gfn, unsigned long psize);
 extern void kvmppc_invalidate_hpte(struct kvm *kvm, __be64 *hptep,
 			unsigned long pte_index);
arch/powerpc/include/asm/kvm_book3s_64.h +1 -1
index 6d29814..c9cbaf0 100644
@@ -625,7 +625,7 @@ extern int kvmppc_create_pte(struct kvm *kvm, pgd_t *pgtable, pte_t pte,
 extern void kvmhv_insert_nest_rmap(struct kvm *kvm, unsigned long *rmapp,
 				   struct rmap_nested **n_rmap);
 extern void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				struct kvm_memory_slot *memslot,
+				const struct kvm_memory_slot *memslot,
 				unsigned long gpa, unsigned long hpa,
 				unsigned long nbytes);
 
arch/powerpc/kvm/book3s_64_mmu_radix.c +5 -4
index 87ad35e..52711eb 100644
@@ -284,7 +284,8 @@ static void kvmppc_pmd_free(pmd_t *pmdp)
 
 /* Called with kvm->mmu_lock held */
 void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte, unsigned long gpa,
-		      unsigned int shift, struct kvm_memory_slot *memslot,
+		      unsigned int shift,
+		      const struct kvm_memory_slot *memslot,
 		      unsigned int lpid)
 
 {
@@ -861,7 +862,7 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	return ret;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		    unsigned long gfn)
 {
@@ -876,7 +877,7 @@ int kvm_unmap_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 	return 0;				
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		  unsigned long gfn)
 {
@@ -895,7 +896,7 @@ int kvm_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 	return ref;
 }
 
-/* Called with kvm->lock held */
+/* Called with kvm->mmu_lock held */
 int kvm_test_age_radix(struct kvm *kvm, struct kvm_memory_slot *memslot,
 		       unsigned long gfn)
 {
arch/powerpc/kvm/book3s_hv_nested.c +1 -1
index 401d2ec..6d1b14b 100644
@@ -723,7 +723,7 @@ static void kvmhv_remove_nest_rmap_list(struct kvm *kvm, unsigned long *rmapp,
 
 /* called with kvm->mmu_lock held */
 void kvmhv_remove_nest_rmap_range(struct kvm *kvm,
-				  struct kvm_memory_slot *memslot,
+				  const struct kvm_memory_slot *memslot,
 				  unsigned long gpa, unsigned long hpa,
 				  unsigned long nbytes)
 {
arch/powerpc/kvm/book3s_hv_rm_mmu.c +1 -1
index a67cf1c..3b3791e 100644
@@ -107,7 +107,7 @@ void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
 EXPORT_SYMBOL_GPL(kvmppc_add_revmap_chain);
 
 /* Update the dirty bitmap of a memslot */
-void kvmppc_update_dirty_map(struct kvm_memory_slot *memslot,
+void kvmppc_update_dirty_map(const struct kvm_memory_slot *memslot,
 			     unsigned long gfn, unsigned long psize)
 {
 	unsigned long npages;
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson