linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <bsingharora@gmail.com>
To: Chris Smart <chris@distroguy.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [Patch v2 1/2] powerpc: Send SIGBUS on unaligned copy and paste
Date: Fri, 17 Jun 2016 17:20:05 +1000	[thread overview]
Message-ID: <13e8530c-80d6-5475-f4f2-3a46e4a75a76@gmail.com> (raw)
In-Reply-To: <20160616233340.GA14449@distroguy.com>



On 17/06/16 09:33, Chris Smart wrote:
> Calling ISA 3.0 instructions copy, copy_first, paste and paste_last
> generates an alignment fault when copying or pasting unaligned
> data (128 byte). We catch this and send SIGBUS to the userspace
> process that caused it.
> 
> We do not emulate these because paste may contain additional metadata
> when pasting to a co-processor and paste_last is the synchronisation
> point for preceding copy/paste sequences.
> 
> Thanks to Michael Neuling <mikey@neuling.org> for his help.
> 
> Signed-off-by: Chris Smart <chris@distroguy.com>
> ---
> 
> Changes since v1:
> - define and use instruction for mask test
> 
> arch/powerpc/include/asm/ppc-opcode.h |  4 ++++
> arch/powerpc/kernel/align.c           | 14 ++++++++++++++
> 2 files changed, 18 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
> index 1d035c1cc889..7921d3e5704d 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -131,6 +131,8 @@
> /* sorted alphabetically */
> #define PPC_INST_BHRBE            0x7c00025c
> #define PPC_INST_CLRBHRB        0x7c00035c
> +#define PPC_INST_COPY            0x7c00060c
> +#define PPC_INST_COPY_FIRST        0x7c20060c
> #define PPC_INST_CP_ABORT        0x7c00068c
> #define PPC_INST_DCBA            0x7c0005ec
> #define PPC_INST_DCBA_MASK        0xfc0007fe
> @@ -159,6 +161,8 @@
> #define PPC_INST_MSGSNDP        0x7c00011c
> #define PPC_INST_MTTMR            0x7c0003dc
> #define PPC_INST_NOP            0x60000000
> +#define PPC_INST_PASTE            0x7c00070c
> +#define PPC_INST_PASTE_LAST        0x7c20070d
> #define PPC_INST_POPCNTB        0x7c0000f4
> #define PPC_INST_POPCNTB_MASK        0xfc0007fe
> #define PPC_INST_POPCNTD        0x7c0003f4
> diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
> index 8e7cb8e2b21a..6e0a1f8495f2 100644
> --- a/arch/powerpc/kernel/align.c
> +++ b/arch/powerpc/kernel/align.c
> @@ -875,6 +875,20 @@ int fix_alignment(struct pt_regs *regs)
>         return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize);
>     }
> #endif
> +
> +    /*
> +     * ISA 3.0 (such as P9) copy, copy_first, paste and paste_last alignment
> +     * check.
> +     *
> +     * Send a SIGBUS to the process that caused the fault.
> +     *
> +     * We do not emulate these because paste may contain additional metadata
> +     * when pasting to a co-processor. Furthermore, paste_last is the
> +     * synchronisation point for preceding copy/paste sequences.
> +     */
> +    if ((instruction & 0xfc0006fe) == PPC_INST_COPY)
> +        return -EIO;

Should this all be under cpu_has_feature(CPU_FTR_ARCH_300)?

Balbir Singh.

  parent reply	other threads:[~2016-06-17  7:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-16 23:33 [Patch v2 1/2] powerpc: Send SIGBUS on unaligned copy and paste Chris Smart
2016-06-17  4:04 ` Segher Boessenkool
2016-06-21  0:39   ` Chris Smart
2016-06-17  7:20 ` Balbir Singh [this message]
2016-06-19 23:48   ` Chris Smart
2016-06-20  3:06     ` Balbir Singh
2016-07-05 14:10 ` [v2,1/2] " Michael Ellerman

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=13e8530c-80d6-5475-f4f2-3a46e4a75a76@gmail.com \
    --to=bsingharora@gmail.com \
    --cc=chris@distroguy.com \
    --cc=linuxppc-dev@lists.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).