linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sam Bobroff <sam.bobroff@au1.ibm.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 01/12] powerpc: Disable HFSCR:TM if TM not supported
Date: Tue, 28 Mar 2017 14:12:43 +1100	[thread overview]
Message-ID: <20170328031243.GA5808@tungsten.ozlabs.ibm.com> (raw)
In-Reply-To: <20170320065053.6CB64112051@b01ledav004.gho.pok.ibm.com>

On Mon, Mar 20, 2017 at 05:49:03PM +1100, Benjamin Herrenschmidt wrote:
> Otherwise KVM guests might mess with it even when told not
> to causing bad thing interrupts in the host
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

I've tested this on a P8, with a kernel and QEMU close to their
respective current master branches, and if:
* the host is configured without CONFIG_PPC_TRANSACTIONAL_MEM,
* and the guest is configured with CONFIG_PPC_TRANSACTIONAL_MEM,
* and the guest runs a program that uses HTM (in my tests, just a loop
  doing some floating point multiplies in a transaction)...

Without the patch the host will OOPS, usually in __kvmppc_vcore_entry,
and kill QEMU. On a busy host this is sometimes followed by "Oops: Bad
kernel stack pointer, sig: 6" and the host dies.

With the patch the userspace test program is killed with a SIGILL. The
guest and host are unaffected.

Cheers,
Sam.
> ---
>  arch/powerpc/kernel/setup_64.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
> index 9cfaa8b..b372b23 100644
> --- a/arch/powerpc/kernel/setup_64.c
> +++ b/arch/powerpc/kernel/setup_64.c
> @@ -236,6 +236,16 @@ static void cpu_ready_for_interrupts(void)
>  		mtspr(SPRN_LPCR, lpcr | LPCR_AIL_3);
>  	}
>  
> +	/*
> +	 * Fixup HFSCR:TM based on CPU features. The bit is set by our
> +	 * early asm init because at that point we haven't updated our
> +	 * CPU features from firmware and device-tree. Here we have,
> +	 * so let's do it
> +	 */
> +	if (early_cpu_has_feature(CPU_FTR_HVMODE) &&
> +	    !early_cpu_has_feature(CPU_FTR_TM_COMP))
> +		mtspr(SPRN_HFSCR, mfspr(SPRN_HFSCR) & ~HFSCR_TM);
> +
>  	/* Set IR and DR in PACA MSR */
>  	get_paca()->kernel_msr = MSR_KERNEL;
>  }
> -- 
> 2.9.3

       reply	other threads:[~2017-03-28  3:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170320065053.6CB64112051@b01ledav004.gho.pok.ibm.com>
2017-03-28  3:12 ` Sam Bobroff [this message]
2017-03-20  6:49 [PATCH 01/12] powerpc: Disable HFSCR:TM if TM not supported Benjamin Herrenschmidt

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=20170328031243.GA5808@tungsten.ozlabs.ibm.com \
    --to=sam.bobroff@au1.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).