linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Leonardo Bras <leonardo@linux.ibm.com>
To: Gustavo Romero <gromero@linux.ibm.com>,
	kvm-ppc@vger.kernel.org, paulus@ozlabs.org
Cc: mikey@neuling.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH] KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones
Date: Thu, 20 Feb 2020 14:51:49 -0300	[thread overview]
Message-ID: <b19a8b0cb1ad8275458df16142756b30f8b288b7.camel@linux.ibm.com> (raw)
In-Reply-To: <20200218211324.23045-1-gromero@linux.ibm.com>

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

Hello Gustavo, comments inline:

On Tue, 2020-02-18 at 16:13 -0500, Gustavo Romero wrote:
<SNIP>
> diff --git a/arch/powerpc/kvm/book3s_hv_tm.c b/arch/powerpc/kvm/book3s_hv_tm.c
> index 0db937497169..cc90b8b82329 100644
> --- a/arch/powerpc/kvm/book3s_hv_tm.c
> +++ b/arch/powerpc/kvm/book3s_hv_tm.c
> @@ -3,6 +3,8 @@
>   * Copyright 2017 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
>   */
> 
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +

Could not see where is this used.

>  #include <linux/kvm_host.h>
> 
>  #include <asm/kvm_ppc.h>
> @@ -44,7 +46,18 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)
>  	u64 newmsr, bescr;
>  	int ra, rs;
> 
> -	switch (instr & 0xfc0007ff) {
> +	/*
> +	 * rfid, rfebb, and mtmsrd encode bit 31 = 0 since it's a reserved bit
> +	 * in these instructions, so masking bit 31 out doesn't change these
> +	 * instructions. For treclaim., tsr., and trechkpt. instructions if bit
> +	 * 31 = 0 then they are per ISA invalid forms, however P9 UM, in section
> +	 * 4.6.10 Book II Invalid Forms, informs specifically that ignoring bit
> +	 * 31 is an acceptable way to handle these invalid forms that have
> +	 * bit 31 = 0. Moreover, for emulation purposes both forms (w/ and wo/
> +	 * bit 31 set) can generate a softpatch interrupt. Hence both forms
> +	 * are handled below for these instructions so they behave the same way.
> +	 */
> +	switch (instr & PO_XOP_OPCODE_MASK) {
> 
<SNIP>
> -	case PPC_INST_TRECHKPT:
> +	/* ignore bit 31, see comment above */
> +	case (PPC_INST_TRECHKPT & PO_XOP_OPCODE_MASK):
>  		/* XXX do we need to check for PR=0 here? */
>  		/* check for TM disabled in the HFSCR or MSR */
>  		if (!(vcpu->arch.hfscr & HFSCR_TM)) {
> @@ -208,6 +224,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)
>  	}
> 

Seems good, using the same flag to mask out bit 31 of these macros.
They are used only in a few places, and I think removing the macro bit
would be ok, but I think your way is better to keep it documented. 

I just noticed that there is a similar function that uses PPC_INST_TSR:
kvmhv_p9_tm_emulation_early @ arch/powerpc/kvm/book3s_hv_tm_builtin.c.
Wouldn't it need to be changed as well?

>  	/* What should we do here? We didn't recognize the instruction */
> -	WARN_ON_ONCE(1);
> +	kvmppc_core_queue_program(vcpu, SRR1_PROGILL);
> +	pr_warn_ratelimited("Unrecognized TM-related instruction %#x for emulation", instr);
> +
>  	return RESUME_GUEST;
>  }

I suppose this is the right thing to do, but I think it would be better
to give this change it's own patch.

What do you think?

Best regards,
Leonardo Bras


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

  reply	other threads:[~2020-02-20 17:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 21:13 [PATCH] KVM: PPC: Book3S HV: Treat TM-related invalid form instructions on P9 like the valid ones Gustavo Romero
2020-02-20 17:51 ` Leonardo Bras [this message]
2020-02-20 21:40   ` Gustavo Romero

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=b19a8b0cb1ad8275458df16142756b30f8b288b7.camel@linux.ibm.com \
    --to=leonardo@linux.ibm.com \
    --cc=gromero@linux.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=paulus@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).