All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-23 21:24 ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

By replacing, we would reduce the use of 'global' current on code,
relying more in the contents of kvm struct.

On code, I found that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have tests like that:
if (kvm->mm != current->mm)
        return -EIO;

So this change would be safe.

I split the changes in 3 patches, so it would be easier to read
and reject separated parts. If decided that squashing is better,
I see no problem doing that.

Best regards,

Leonardo Bras (3):
  powerpc/kvm/book3s: Replace current->mm by kvm->mm
  powerpc/kvm/book3e: Replace current->mm by kvm->mm
  powerpc/kvm/e500: Replace current->mm by kvm->mm

 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 arch/powerpc/kvm/booke.c            |  2 +-
 arch/powerpc/kvm/e500_mmu_host.c    |  6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-23 21:24 ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

By replacing, we would reduce the use of 'global' current on code,
relying more in the contents of kvm struct.

On code, I found that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have tests like that:
if (kvm->mm != current->mm)
        return -EIO;

So this change would be safe.

I split the changes in 3 patches, so it would be easier to read
and reject separated parts. If decided that squashing is better,
I see no problem doing that.

Best regards,

Leonardo Bras (3):
  powerpc/kvm/book3s: Replace current->mm by kvm->mm
  powerpc/kvm/book3e: Replace current->mm by kvm->mm
  powerpc/kvm/e500: Replace current->mm by kvm->mm

 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 arch/powerpc/kvm/booke.c            |  2 +-
 arch/powerpc/kvm/e500_mmu_host.c    |  6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm
  2019-09-23 21:24 ` Leonardo Bras
@ 2019-09-23 21:24   ` Leonardo Bras
  -1 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
	return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index f2b9aea43216..2f23cbc6c23e 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -296,7 +296,7 @@ static long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags,
 	/* Protect linux PTE lookup from page table destruction */
 	rcu_read_lock_sched();	/* this disables preemption too */
 	ret = kvmppc_do_h_enter(kvm, flags, pte_index, pteh, ptel,
-				current->mm->pgd, false, pte_idx_ret);
+				kvm->mm->pgd, false, pte_idx_ret);
 	rcu_read_unlock_sched();
 	if (ret == H_TOO_HARD) {
 		/* this can't happen */
@@ -585,7 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	is_ci = false;
 	pfn = 0;
 	page = NULL;
-	mm = current->mm;
+	mm = kvm->mm;
 	pte_size = PAGE_SIZE;
 	writing = (dsisr & DSISR_ISSTORE) != 0;
 	/* If writing != 0, then the HPTE must allow writing, if we get here */
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index c4b606fe73eb..8069b35f2905 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -255,7 +255,7 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
 
 	kvm_put_kvm(stt->kvm);
 
-	account_locked_vm(current->mm,
+	account_locked_vm(kvm->mm,
 		kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false);
 	call_rcu(&stt->rcu, release_spapr_tce_table);
 
@@ -280,7 +280,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
 		return -EINVAL;
 
 	npages = kvmppc_tce_pages(size);
-	ret = account_locked_vm(current->mm, kvmppc_stt_pages(npages), true);
+	ret = account_locked_vm(kvm->mm, kvmppc_stt_pages(npages), true);
 	if (ret)
 		return ret;
 
@@ -326,7 +326,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
 
 	kfree(stt);
  fail_acct:
-	account_locked_vm(current->mm, kvmppc_stt_pages(npages), false);
+	account_locked_vm(kvm->mm, kvmppc_stt_pages(npages), false);
 	return ret;
 }
 
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index cde3f5a4b3e4..c5b6081b6de0 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4265,7 +4265,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	user_vrsave = mfspr(SPRN_VRSAVE);
 
 	vcpu->arch.wqp = &vcpu->arch.vcore->wq;
-	vcpu->arch.pgdir = current->mm->pgd;
+	vcpu->arch.pgdir = kvm->mm->pgd;
 	vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST;
 
 	do {
@@ -4597,14 +4597,14 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 
 	/* Look up the VMA for the start of this memory slot */
 	hva = memslot->userspace_addr;
-	down_read(&current->mm->mmap_sem);
-	vma = find_vma(current->mm, hva);
+	down_read(&kvm->mm->mmap_sem);
+	vma = find_vma(kvm->mm, hva);
 	if (!vma || vma->vm_start > hva || (vma->vm_flags & VM_IO))
 		goto up_out;
 
 	psize = vma_kernel_pagesize(vma);
 
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->mm->mmap_sem);
 
 	/* We can handle 4k, 64k or 16M pages in the VRMA */
 	if (psize >= 0x1000000)
@@ -4637,7 +4637,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 	return err;
 
  up_out:
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->mm->mmap_sem);
 	goto out_srcu;
 }
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm
@ 2019-09-23 21:24   ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
	return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index f2b9aea43216..2f23cbc6c23e 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -296,7 +296,7 @@ static long kvmppc_virtmode_do_h_enter(struct kvm *kvm, unsigned long flags,
 	/* Protect linux PTE lookup from page table destruction */
 	rcu_read_lock_sched();	/* this disables preemption too */
 	ret = kvmppc_do_h_enter(kvm, flags, pte_index, pteh, ptel,
-				current->mm->pgd, false, pte_idx_ret);
+				kvm->mm->pgd, false, pte_idx_ret);
 	rcu_read_unlock_sched();
 	if (ret = H_TOO_HARD) {
 		/* this can't happen */
@@ -585,7 +585,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
 	is_ci = false;
 	pfn = 0;
 	page = NULL;
-	mm = current->mm;
+	mm = kvm->mm;
 	pte_size = PAGE_SIZE;
 	writing = (dsisr & DSISR_ISSTORE) != 0;
 	/* If writing != 0, then the HPTE must allow writing, if we get here */
diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
index c4b606fe73eb..8069b35f2905 100644
--- a/arch/powerpc/kvm/book3s_64_vio.c
+++ b/arch/powerpc/kvm/book3s_64_vio.c
@@ -255,7 +255,7 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
 
 	kvm_put_kvm(stt->kvm);
 
-	account_locked_vm(current->mm,
+	account_locked_vm(kvm->mm,
 		kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false);
 	call_rcu(&stt->rcu, release_spapr_tce_table);
 
@@ -280,7 +280,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
 		return -EINVAL;
 
 	npages = kvmppc_tce_pages(size);
-	ret = account_locked_vm(current->mm, kvmppc_stt_pages(npages), true);
+	ret = account_locked_vm(kvm->mm, kvmppc_stt_pages(npages), true);
 	if (ret)
 		return ret;
 
@@ -326,7 +326,7 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
 
 	kfree(stt);
  fail_acct:
-	account_locked_vm(current->mm, kvmppc_stt_pages(npages), false);
+	account_locked_vm(kvm->mm, kvmppc_stt_pages(npages), false);
 	return ret;
 }
 
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index cde3f5a4b3e4..c5b6081b6de0 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4265,7 +4265,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
 	user_vrsave = mfspr(SPRN_VRSAVE);
 
 	vcpu->arch.wqp = &vcpu->arch.vcore->wq;
-	vcpu->arch.pgdir = current->mm->pgd;
+	vcpu->arch.pgdir = kvm->mm->pgd;
 	vcpu->arch.state = KVMPPC_VCPU_BUSY_IN_HOST;
 
 	do {
@@ -4597,14 +4597,14 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 
 	/* Look up the VMA for the start of this memory slot */
 	hva = memslot->userspace_addr;
-	down_read(&current->mm->mmap_sem);
-	vma = find_vma(current->mm, hva);
+	down_read(&kvm->mm->mmap_sem);
+	vma = find_vma(kvm->mm, hva);
 	if (!vma || vma->vm_start > hva || (vma->vm_flags & VM_IO))
 		goto up_out;
 
 	psize = vma_kernel_pagesize(vma);
 
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->mm->mmap_sem);
 
 	/* We can handle 4k, 64k or 16M pages in the VRMA */
 	if (psize >= 0x1000000)
@@ -4637,7 +4637,7 @@ static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu)
 	return err;
 
  up_out:
-	up_read(&current->mm->mmap_sem);
+	up_read(&kvm->mm->mmap_sem);
 	goto out_srcu;
 }
 
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
  2019-09-23 21:24 ` Leonardo Bras
@ 2019-09-23 21:24   ` Leonardo Bras
  -1 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
	return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/booke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index be9a45874194..383108263af5 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 	debug = current->thread.debug;
 	current->thread.debug = vcpu->arch.dbg_reg;
 
-	vcpu->arch.pgdir = current->mm->pgd;
+	vcpu->arch.pgdir = kvm->mm->pgd;
 	kvmppc_fix_ee_before_entry();
 
 	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
@ 2019-09-23 21:24   ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
	return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/booke.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index be9a45874194..383108263af5 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
 	debug = current->thread.debug;
 	current->thread.debug = vcpu->arch.dbg_reg;
 
-	vcpu->arch.pgdir = current->mm->pgd;
+	vcpu->arch.pgdir = kvm->mm->pgd;
 	kvmppc_fix_ee_before_entry();
 
 	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] powerpc/kvm/e500: Replace current->mm by kvm->mm
  2019-09-23 21:24 ` Leonardo Bras
@ 2019-09-23 21:24   ` Leonardo Bras
  -1 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
        return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/e500_mmu_host.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 321db0fdb9db..425d13806645 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -355,9 +355,9 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 
 	if (tlbsel == 1) {
 		struct vm_area_struct *vma;
-		down_read(&current->mm->mmap_sem);
+		down_read(&kvm->mm->mmap_sem);
 
-		vma = find_vma(current->mm, hva);
+		vma = find_vma(kvm->mm, hva);
 		if (vma && hva >= vma->vm_start &&
 		    (vma->vm_flags & VM_PFNMAP)) {
 			/*
@@ -441,7 +441,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 			tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
 		}
 
-		up_read(&current->mm->mmap_sem);
+		up_read(&kvm->mm->mmap_sem);
 	}
 
 	if (likely(!pfnmap)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/3] powerpc/kvm/e500: Replace current->mm by kvm->mm
@ 2019-09-23 21:24   ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 21:24 UTC (permalink / raw)
  To: kvm, kvm-ppc
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

Given that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have:
if (kvm->mm != current->mm)
        return -EIO;

I see no reason to keep using current->mm instead of kvm->mm.

By doing so, we would reduce the use of 'global' variables on code, relying
more in the contents of kvm struct.

Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
---
 arch/powerpc/kvm/e500_mmu_host.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c
index 321db0fdb9db..425d13806645 100644
--- a/arch/powerpc/kvm/e500_mmu_host.c
+++ b/arch/powerpc/kvm/e500_mmu_host.c
@@ -355,9 +355,9 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 
 	if (tlbsel = 1) {
 		struct vm_area_struct *vma;
-		down_read(&current->mm->mmap_sem);
+		down_read(&kvm->mm->mmap_sem);
 
-		vma = find_vma(current->mm, hva);
+		vma = find_vma(kvm->mm, hva);
 		if (vma && hva >= vma->vm_start &&
 		    (vma->vm_flags & VM_PFNMAP)) {
 			/*
@@ -441,7 +441,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
 			tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
 		}
 
-		up_read(&current->mm->mmap_sem);
+		up_read(&kvm->mm->mmap_sem);
 	}
 
 	if (likely(!pfnmap)) {
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
  2019-09-23 21:24 ` Leonardo Bras
@ 2019-09-24  2:00   ` Paul Mackerras
  -1 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-09-24  2:00 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:06PM -0300, Leonardo Bras wrote:
> By replacing, we would reduce the use of 'global' current on code,
> relying more in the contents of kvm struct.
> 
> On code, I found that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have tests like that:
> if (kvm->mm != current->mm)
>         return -EIO;
> 
> So this change would be safe.
> 
> I split the changes in 3 patches, so it would be easier to read
> and reject separated parts. If decided that squashing is better,
> I see no problem doing that.

The patch series looks fine.  It has missed the 5.4 merge window, and
it doesn't fix any bugs, so I will queue it up for the 5.5 merge
window, meaning that I will put it into my kvm-ppc-next branch when I
prepare it for the 5.5 merge window, probably in about a month from
now.

This remark also applies to your other patch "Reduce calls to get
current->mm by storing the value locally".

Thanks,
Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-24  2:00   ` Paul Mackerras
  0 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-09-24  2:00 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:06PM -0300, Leonardo Bras wrote:
> By replacing, we would reduce the use of 'global' current on code,
> relying more in the contents of kvm struct.
> 
> On code, I found that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have tests like that:
> if (kvm->mm != current->mm)
>         return -EIO;
> 
> So this change would be safe.
> 
> I split the changes in 3 patches, so it would be easier to read
> and reject separated parts. If decided that squashing is better,
> I see no problem doing that.

The patch series looks fine.  It has missed the 5.4 merge window, and
it doesn't fix any bugs, so I will queue it up for the 5.5 merge
window, meaning that I will put it into my kvm-ppc-next branch when I
prepare it for the 5.5 merge window, probably in about a month from
now.

This remark also applies to your other patch "Reduce calls to get
current->mm by storing the value locally".

Thanks,
Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
  2019-09-24  2:00   ` Paul Mackerras
@ 2019-09-24 13:46     ` Leonardo Bras
  -1 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-24 13:46 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

On Tue, 2019-09-24 at 12:00 +1000, Paul Mackerras wrote:
> On Mon, Sep 23, 2019 at 06:24:06PM -0300, Leonardo Bras wrote:
> > By replacing, we would reduce the use of 'global' current on code,
> > relying more in the contents of kvm struct.
> > 
> > On code, I found that in kvm_create_vm() there is:
> > kvm->mm = current->mm;
> > 
> > And that on every kvm_*_ioctl we have tests like that:
> > if (kvm->mm != current->mm)
> >         return -EIO;
> > 
> > So this change would be safe.
> > 
> > I split the changes in 3 patches, so it would be easier to read
> > and reject separated parts. If decided that squashing is better,
> > I see no problem doing that.
> 
> The patch series looks fine.  It has missed the 5.4 merge window, and
> it doesn't fix any bugs, so I will queue it up for the 5.5 merge
> window, meaning that I will put it into my kvm-ppc-next branch when I
> prepare it for the 5.5 merge window, probably in about a month from
> now.
> 
> This remark also applies to your other patch "Reduce calls to get
> current->mm by storing the value locally".
> 
> Thanks,
> Paul.

Thanks!
Leonardo Bras

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-24 13:46     ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-24 13:46 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

On Tue, 2019-09-24 at 12:00 +1000, Paul Mackerras wrote:
> On Mon, Sep 23, 2019 at 06:24:06PM -0300, Leonardo Bras wrote:
> > By replacing, we would reduce the use of 'global' current on code,
> > relying more in the contents of kvm struct.
> > 
> > On code, I found that in kvm_create_vm() there is:
> > kvm->mm = current->mm;
> > 
> > And that on every kvm_*_ioctl we have tests like that:
> > if (kvm->mm != current->mm)
> >         return -EIO;
> > 
> > So this change would be safe.
> > 
> > I split the changes in 3 patches, so it would be easier to read
> > and reject separated parts. If decided that squashing is better,
> > I see no problem doing that.
> 
> The patch series looks fine.  It has missed the 5.4 merge window, and
> it doesn't fix any bugs, so I will queue it up for the 5.5 merge
> window, meaning that I will put it into my kvm-ppc-next branch when I
> prepare it for the 5.5 merge window, probably in about a month from
> now.
> 
> This remark also applies to your other patch "Reduce calls to get
> current->mm by storing the value locally".
> 
> Thanks,
> Paul.

Thanks!
Leonardo Bras

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
  2019-09-23 21:24   ` Leonardo Bras
@ 2019-10-22  0:43     ` Paul Mackerras
  -1 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-10-22  0:43 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:08PM -0300, Leonardo Bras wrote:
> Given that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have:
> if (kvm->mm != current->mm)
> 	return -EIO;
> 
> I see no reason to keep using current->mm instead of kvm->mm.
> 
> By doing so, we would reduce the use of 'global' variables on code, relying
> more in the contents of kvm struct.
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
>  arch/powerpc/kvm/booke.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index be9a45874194..383108263af5 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	debug = current->thread.debug;
>  	current->thread.debug = vcpu->arch.dbg_reg;
>  
> -	vcpu->arch.pgdir = current->mm->pgd;
> +	vcpu->arch.pgdir = kvm->mm->pgd;
>  	kvmppc_fix_ee_before_entry();
>  
>  	ret = __kvmppc_vcpu_run(kvm_run, vcpu);

With this patch, I get compile errors for Book E configs:

  CC      arch/powerpc/kvm/booke.o
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c: In function ‘kvmppc_vcpu_run’:
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: error: ‘kvm’ undeclared (first use in this function)
  vcpu->arch.pgdir = kvm->mm->pgd;
                     ^
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: arch/powerpc/kvm/booke.o] Error 1
make[2]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:509: arch/powerpc/kvm] Error 2
make[1]: *** [/home/paulus/kernel/kvm/Makefile:1649: arch/powerpc] Error 2
make: *** [/home/paulus/kernel/kvm/Makefile:179: sub-make] Error 2

It seems that you didn't compile-test this patch.

Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
@ 2019-10-22  0:43     ` Paul Mackerras
  0 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-10-22  0:43 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:08PM -0300, Leonardo Bras wrote:
> Given that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have:
> if (kvm->mm != current->mm)
> 	return -EIO;
> 
> I see no reason to keep using current->mm instead of kvm->mm.
> 
> By doing so, we would reduce the use of 'global' variables on code, relying
> more in the contents of kvm struct.
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
>  arch/powerpc/kvm/booke.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index be9a45874194..383108263af5 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	debug = current->thread.debug;
>  	current->thread.debug = vcpu->arch.dbg_reg;
>  
> -	vcpu->arch.pgdir = current->mm->pgd;
> +	vcpu->arch.pgdir = kvm->mm->pgd;
>  	kvmppc_fix_ee_before_entry();
>  
>  	ret = __kvmppc_vcpu_run(kvm_run, vcpu);

With this patch, I get compile errors for Book E configs:

  CC      arch/powerpc/kvm/booke.o
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c: In function ‘kvmppc_vcpu_run’:
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: error: ‘kvm’ undeclared (first use in this function)
  vcpu->arch.pgdir = kvm->mm->pgd;
                     ^
/home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: note: each undeclared identifier is reported only once for each function it appears in
make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: arch/powerpc/kvm/booke.o] Error 1
make[2]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:509: arch/powerpc/kvm] Error 2
make[1]: *** [/home/paulus/kernel/kvm/Makefile:1649: arch/powerpc] Error 2
make: *** [/home/paulus/kernel/kvm/Makefile:179: sub-make] Error 2

It seems that you didn't compile-test this patch.

Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm
  2019-09-23 21:24   ` Leonardo Bras
@ 2019-10-22  5:28     ` Paul Mackerras
  -1 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-10-22  5:28 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:07PM -0300, Leonardo Bras wrote:
> Given that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have:
> if (kvm->mm != current->mm)
> 	return -EIO;
> 
> I see no reason to keep using current->mm instead of kvm->mm.
> 
> By doing so, we would reduce the use of 'global' variables on code, relying
> more in the contents of kvm struct.

This patch led to a crash on shutting down a VM, because of this hunk:

> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index c4b606fe73eb..8069b35f2905 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -255,7 +255,7 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
>  
>  	kvm_put_kvm(stt->kvm);
>  
> -	account_locked_vm(current->mm,
> +	account_locked_vm(kvm->mm,
>  		kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false);

You are referencing kvm->mm after having done kvm_put_kvm a couple of
lines earlier, which means that *kvm can be freed at the point where
you use kvm->mm.  If you want to make this change you will need to
move the kvm_put_kvm call to after the last use of it.

I have dropped this patch for now.

Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm
@ 2019-10-22  5:28     ` Paul Mackerras
  0 siblings, 0 replies; 20+ messages in thread
From: Paul Mackerras @ 2019-10-22  5:28 UTC (permalink / raw)
  To: Leonardo Bras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

On Mon, Sep 23, 2019 at 06:24:07PM -0300, Leonardo Bras wrote:
> Given that in kvm_create_vm() there is:
> kvm->mm = current->mm;
> 
> And that on every kvm_*_ioctl we have:
> if (kvm->mm != current->mm)
> 	return -EIO;
> 
> I see no reason to keep using current->mm instead of kvm->mm.
> 
> By doing so, we would reduce the use of 'global' variables on code, relying
> more in the contents of kvm struct.

This patch led to a crash on shutting down a VM, because of this hunk:

> diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c
> index c4b606fe73eb..8069b35f2905 100644
> --- a/arch/powerpc/kvm/book3s_64_vio.c
> +++ b/arch/powerpc/kvm/book3s_64_vio.c
> @@ -255,7 +255,7 @@ static int kvm_spapr_tce_release(struct inode *inode, struct file *filp)
>  
>  	kvm_put_kvm(stt->kvm);
>  
> -	account_locked_vm(current->mm,
> +	account_locked_vm(kvm->mm,
>  		kvmppc_stt_pages(kvmppc_tce_pages(stt->size)), false);

You are referencing kvm->mm after having done kvm_put_kvm a couple of
lines earlier, which means that *kvm can be freed at the point where
you use kvm->mm.  If you want to make this change you will need to
move the kvm_put_kvm call to after the last use of it.

I have dropped this patch for now.

Paul.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
  2019-10-22  0:43     ` Paul Mackerras
@ 2019-10-22 14:22       ` Leonardo Bras
  -1 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-10-22 14:22 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 2412 bytes --]

On Tue, 2019-10-22 at 11:43 +1100, Paul Mackerras wrote:
> On Mon, Sep 23, 2019 at 06:24:08PM -0300, Leonardo Bras wrote:
> > Given that in kvm_create_vm() there is:
> > kvm->mm = current->mm;
> > 
> > And that on every kvm_*_ioctl we have:
> > if (kvm->mm != current->mm)
> > 	return -EIO;
> > 
> > I see no reason to keep using current->mm instead of kvm->mm.
> > 
> > By doing so, we would reduce the use of 'global' variables on code, relying
> > more in the contents of kvm struct.
> > 
> > Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> > ---
> >  arch/powerpc/kvm/booke.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> > index be9a45874194..383108263af5 100644
> > --- a/arch/powerpc/kvm/booke.c
> > +++ b/arch/powerpc/kvm/booke.c
> > @@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> >  	debug = current->thread.debug;
> >  	current->thread.debug = vcpu->arch.dbg_reg;
> >  
> > -	vcpu->arch.pgdir = current->mm->pgd;
> > +	vcpu->arch.pgdir = kvm->mm->pgd;
> >  	kvmppc_fix_ee_before_entry();
> >  
> >  	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
> 
> With this patch, I get compile errors for Book E configs:
> 
>   CC      arch/powerpc/kvm/booke.o
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c: In function ‘kvmppc_vcpu_run’:
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: error: ‘kvm’ undeclared (first use in this function)
>   vcpu->arch.pgdir = kvm->mm->pgd;
>                      ^
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: note: each undeclared identifier is reported only once for each function it appears in
> make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: arch/powerpc/kvm/booke.o] Error 1
> make[2]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:509: arch/powerpc/kvm] Error 2
> make[1]: *** [/home/paulus/kernel/kvm/Makefile:1649: arch/powerpc] Error 2
> make: *** [/home/paulus/kernel/kvm/Makefile:179: sub-make] Error 2
> 
> It seems that you didn't compile-test this patch.
> 
> Paul.

Sorry Paul, 
I remember dealing with this before, but it looks like it was lost
during git context/branch switching. 

I will make sure that doesn't happen again.
A v2 will come soon, I will test it on travis.

Best regards,
Leonardo Bras


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 2/3] powerpc/kvm/book3e: Replace current->mm by kvm->mm
@ 2019-10-22 14:22       ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-10-22 14:22 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: kvm, kvm-ppc, Benjamin Herrenschmidt, Michael Ellerman

[-- Attachment #1: Type: text/plain, Size: 2412 bytes --]

On Tue, 2019-10-22 at 11:43 +1100, Paul Mackerras wrote:
> On Mon, Sep 23, 2019 at 06:24:08PM -0300, Leonardo Bras wrote:
> > Given that in kvm_create_vm() there is:
> > kvm->mm = current->mm;
> > 
> > And that on every kvm_*_ioctl we have:
> > if (kvm->mm != current->mm)
> > 	return -EIO;
> > 
> > I see no reason to keep using current->mm instead of kvm->mm.
> > 
> > By doing so, we would reduce the use of 'global' variables on code, relying
> > more in the contents of kvm struct.
> > 
> > Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> > ---
> >  arch/powerpc/kvm/booke.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> > index be9a45874194..383108263af5 100644
> > --- a/arch/powerpc/kvm/booke.c
> > +++ b/arch/powerpc/kvm/booke.c
> > @@ -775,7 +775,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> >  	debug = current->thread.debug;
> >  	current->thread.debug = vcpu->arch.dbg_reg;
> >  
> > -	vcpu->arch.pgdir = current->mm->pgd;
> > +	vcpu->arch.pgdir = kvm->mm->pgd;
> >  	kvmppc_fix_ee_before_entry();
> >  
> >  	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
> 
> With this patch, I get compile errors for Book E configs:
> 
>   CC      arch/powerpc/kvm/booke.o
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c: In function ‘kvmppc_vcpu_run’:
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: error: ‘kvm’ undeclared (first use in this function)
>   vcpu->arch.pgdir = kvm->mm->pgd;
>                      ^
> /home/paulus/kernel/kvm/arch/powerpc/kvm/booke.c:778:21: note: each undeclared identifier is reported only once for each function it appears in
> make[3]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:266: arch/powerpc/kvm/booke.o] Error 1
> make[2]: *** [/home/paulus/kernel/kvm/scripts/Makefile.build:509: arch/powerpc/kvm] Error 2
> make[1]: *** [/home/paulus/kernel/kvm/Makefile:1649: arch/powerpc] Error 2
> make: *** [/home/paulus/kernel/kvm/Makefile:179: sub-make] Error 2
> 
> It seems that you didn't compile-test this patch.
> 
> Paul.

Sorry Paul, 
I remember dealing with this before, but it looks like it was lost
during git context/branch switching. 

I will make sure that doesn't happen again.
A v2 will come soon, I will test it on travis.

Best regards,
Leonardo Bras


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-23 18:43 ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 18:43 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel
  Cc: Leonardo Bras, Paul Mackerras, Benjamin Herrenschmidt, Michael Ellerman

By replacing, we would reduce the use of 'global' current on code,
relying more in the contents of kvm struct.

On code, I found that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have tests like that:
if (kvm->mm != current->mm)
        return -EIO;

So this change would be safe.

I split the changes in 3 patches, so it would be easier to read
and reject separated parts. If decided that squashing is better,
I see no problem doing that.

Best regards,

Leonardo Bras (3):
  powerpc/kvm/book3s: Replace current->mm by kvm->mm
  powerpc/kvm/book3e: Replace current->mm by kvm->mm
  powerpc/kvm/e500: Replace current->mm by kvm->mm

 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 arch/powerpc/kvm/booke.c            |  2 +-
 arch/powerpc/kvm/e500_mmu_host.c    |  6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm
@ 2019-09-23 18:43 ` Leonardo Bras
  0 siblings, 0 replies; 20+ messages in thread
From: Leonardo Bras @ 2019-09-23 18:43 UTC (permalink / raw)
  To: linuxppc-dev, linux-kernel; +Cc: Leonardo Bras

By replacing, we would reduce the use of 'global' current on code,
relying more in the contents of kvm struct.

On code, I found that in kvm_create_vm() there is:
kvm->mm = current->mm;

And that on every kvm_*_ioctl we have tests like that:
if (kvm->mm != current->mm)
        return -EIO;

So this change would be safe.

I split the changes in 3 patches, so it would be easier to read
and reject separated parts. If decided that squashing is better,
I see no problem doing that.

Best regards,

Leonardo Bras (3):
  powerpc/kvm/book3s: Replace current->mm by kvm->mm
  powerpc/kvm/book3e: Replace current->mm by kvm->mm
  powerpc/kvm/e500: Replace current->mm by kvm->mm

 arch/powerpc/kvm/book3s_64_mmu_hv.c |  4 ++--
 arch/powerpc/kvm/book3s_64_vio.c    |  6 +++---
 arch/powerpc/kvm/book3s_hv.c        | 10 +++++-----
 arch/powerpc/kvm/booke.c            |  2 +-
 arch/powerpc/kvm/e500_mmu_host.c    |  6 +++---
 5 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-10-22 14:22 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23 21:24 [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm Leonardo Bras
2019-09-23 21:24 ` Leonardo Bras
2019-09-23 21:24 ` [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm Leonardo Bras
2019-09-23 21:24   ` Leonardo Bras
2019-10-22  5:28   ` Paul Mackerras
2019-10-22  5:28     ` Paul Mackerras
2019-09-23 21:24 ` [PATCH 2/3] powerpc/kvm/book3e: " Leonardo Bras
2019-09-23 21:24   ` Leonardo Bras
2019-10-22  0:43   ` Paul Mackerras
2019-10-22  0:43     ` Paul Mackerras
2019-10-22 14:22     ` Leonardo Bras
2019-10-22 14:22       ` Leonardo Bras
2019-09-23 21:24 ` [PATCH 3/3] powerpc/kvm/e500: " Leonardo Bras
2019-09-23 21:24   ` Leonardo Bras
2019-09-24  2:00 ` [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm Paul Mackerras
2019-09-24  2:00   ` Paul Mackerras
2019-09-24 13:46   ` Leonardo Bras
2019-09-24 13:46     ` Leonardo Bras
  -- strict thread matches above, loose matches on Subject: below --
2019-09-23 18:43 Leonardo Bras
2019-09-23 18:43 ` Leonardo Bras

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.