public inbox for kvm-ppc@vger.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: Leonardo Bras <leonardo@linux.ibm.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: Re: [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm
Date: Tue, 22 Oct 2019 05:28:12 +0000	[thread overview]
Message-ID: <20191022052812.GA22958@oak.ozlabs.ibm.com> (raw)
In-Reply-To: <20190923212409.7153-2-leonardo@linux.ibm.com>

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.

  reply	other threads:[~2019-10-22  5:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23 21:24 [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm Leonardo Bras
2019-09-23 21:24 ` [PATCH 1/3] powerpc/kvm/book3s: Replace current->mm by kvm->mm Leonardo Bras
2019-10-22  5:28   ` Paul Mackerras [this message]
2019-09-23 21:24 ` [PATCH 2/3] powerpc/kvm/book3e: " Leonardo Bras
2019-10-22  0:43   ` Paul Mackerras
2019-10-22 14:22     ` Leonardo Bras
2019-09-23 21:24 ` [PATCH 3/3] powerpc/kvm/e500: " Leonardo Bras
2019-09-24  2:00 ` [PATCH 0/3] Replace current->mm by kvm->mm on powerpc/kvm Paul Mackerras
2019-09-24 13:46   ` Leonardo Bras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191022052812.GA22958@oak.ozlabs.ibm.com \
    --to=paulus@ozlabs.org \
    --cc=benh@kernel.crashing.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=leonardo@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox