From: Nicholas Piggin <npiggin@gmail.com>
To: Haren Myneni <haren@linux.ibm.com>,
linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au
Subject: Re: [PATCH v3 08/10] powerpc/vas: Return paste instruction failure if no active window
Date: Mon, 14 Feb 2022 13:41:24 +1000 [thread overview]
Message-ID: <1644809992.wf4i5w12rf.astroid@bobo.none> (raw)
In-Reply-To: <854cd12884080c6ac0d21f24502fffed0fae4e8e.camel@linux.ibm.com>
Excerpts from Haren Myneni's message of January 22, 2022 5:59 am:
>
> The VAS window may not be active if the system looses credits and
> the NX generates page fault when it receives request on unmap
> paste address.
>
> The kernel handles the fault by remap new paste address if the
> window is active again, Otherwise return the paste instruction
> failure if the executed instruction that caused the fault was
> a paste.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> ---
> arch/powerpc/include/asm/ppc-opcode.h | 2 ++
> arch/powerpc/platforms/book3s/vas-api.c | 47 ++++++++++++++++++++++++-
> 2 files changed, 48 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
> index efad07081cc0..fe2a69206588 100644
> --- a/arch/powerpc/include/asm/ppc-opcode.h
> +++ b/arch/powerpc/include/asm/ppc-opcode.h
> @@ -262,6 +262,8 @@
> #define PPC_INST_MFSPR_PVR 0x7c1f42a6
> #define PPC_INST_MFSPR_PVR_MASK 0xfc1ffffe
> #define PPC_INST_MTMSRD 0x7c000164
> +#define PPC_INST_PASTE 0x7c20070d
> +#define PPC_INST_PASTE_MASK 0xfc2007ff
> #define PPC_INST_POPCNTB 0x7c0000f4
> #define PPC_INST_POPCNTB_MASK 0xfc0007fe
> #define PPC_INST_RFEBB 0x4c000124
> diff --git a/arch/powerpc/platforms/book3s/vas-api.c b/arch/powerpc/platforms/book3s/vas-api.c
> index 5ceba75c13eb..2ffd34bc4032 100644
> --- a/arch/powerpc/platforms/book3s/vas-api.c
> +++ b/arch/powerpc/platforms/book3s/vas-api.c
> @@ -351,6 +351,41 @@ static int coproc_release(struct inode *inode, struct file *fp)
> return 0;
> }
>
> +/*
> + * If the executed instruction that caused the fault was a paste, then
> + * clear regs CR0[EQ], advance NIP, and return 0. Else return error code.
> + */
> +static int do_fail_paste(void)
> +{
> + struct pt_regs *regs = current->thread.regs;
> + u32 instword;
> +
> + if (WARN_ON_ONCE(!regs))
> + return -EINVAL;
> +
> + if (WARN_ON_ONCE(!user_mode(regs)))
> + return -EINVAL;
> +
> + /*
> + * If we couldn't translate the instruction, the driver should
> + * return success without handling the fault, it will be retried
> + * or the instruction fetch will fault.
> + */
> + if (get_user(instword, (u32 __user *)(regs->nip)))
> + return -EAGAIN;
We say this, and yet the caller seems to SIGBUS us on this return
value.
> +
> + /*
> + * Not a paste instruction, driver may fail the fault.
> + */
> + if ((instword & PPC_INST_PASTE_MASK) != PPC_INST_PASTE)
> + return -ENOENT;
> +
> + regs->ccr &= ~0xe0000000; /* Clear CR0[0-2] to fail paste */
> + regs_add_return_ip(regs, 4); /* Skip the paste */
Maybe instead of 'Skip the paste' the comment should be 'Emulated the
paste'.
> +
> + return 0;
> +}
> +
> /*
> * This fault handler is invoked when the VAS/NX generates page fault on
> * the paste address. Happens if the kernel closes window in hypervisor
> @@ -403,9 +438,19 @@ static vm_fault_t vas_mmap_fault(struct vm_fault *vmf)
> }
> mutex_unlock(&txwin->task_ref.mmap_mutex);
>
> - return VM_FAULT_SIGBUS;
> + /*
> + * Received this fault due to closing the actual window.
> + * It can happen during migration or lost credits.
> + * Since no mapping, return the paste instruction failure
> + * to the user space.
> + */
> + ret = do_fail_paste();
> + if (!ret)
> + return VM_FAULT_NOPAGE;
if (!ret || ret == -EAGAIN)
?
Thanks,
Nick
>
> + return VM_FAULT_SIGBUS;
> }
> +
> static const struct vm_operations_struct vas_vm_ops = {
> .fault = vas_mmap_fault,
> };
> --
> 2.27.0
>
>
>
next prev parent reply other threads:[~2022-02-14 3:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 19:52 [PATCH v3 00/10] powerpc/pseries/vas: NXGZIP support with DLPAR Haren Myneni
2022-01-21 19:54 ` [PATCH v3 01/10] powerpc/pseries/vas: Use common names in VAS capability structure Haren Myneni
2022-02-14 2:14 ` Nicholas Piggin
2022-02-15 18:32 ` Haren Myneni
2022-01-21 19:54 ` [PATCH v3 02/10] powerpc/pseries/vas: Add notifier for DLPAR core removal/add Haren Myneni
2022-02-14 2:27 ` Nicholas Piggin
2022-02-16 1:07 ` Haren Myneni
2022-01-21 19:55 ` [PATCH v3 03/10] powerpc/pseries/vas: Save LPID in pseries_vas_window struct Haren Myneni
2022-02-14 2:41 ` Nicholas Piggin
2022-02-16 1:09 ` Haren Myneni
2022-01-21 19:56 ` [PATCH v3 04/10] powerpc/pseries/vas: Reopen windows with DLPAR core add Haren Myneni
2022-02-14 3:08 ` Nicholas Piggin
2022-02-16 1:38 ` Haren Myneni
2022-01-21 19:57 ` [PATCH v3 05/10] powerpc/pseries/vas: Close windows with DLPAR core removal Haren Myneni
2022-02-14 3:17 ` Nicholas Piggin
2022-02-16 1:48 ` Haren Myneni
2022-01-21 19:58 ` [PATCH v3 06/10] powerpc/vas: Map paste address only if window is active Haren Myneni
2022-02-14 3:20 ` Nicholas Piggin
2022-02-16 1:58 ` Haren Myneni
2022-01-21 19:59 ` [PATCH v3 07/10] powerpc/vas: Add paste address mmap fault handler Haren Myneni
2022-02-14 3:37 ` Nicholas Piggin
2022-02-16 2:21 ` Haren Myneni
2022-01-21 19:59 ` [PATCH v3 08/10] powerpc/vas: Return paste instruction failure if no active window Haren Myneni
2022-02-14 3:41 ` Nicholas Piggin [this message]
2022-01-21 20:00 ` [PATCH v3 09/10] powerpc/pseries/vas: sysfs interface to export capabilities Haren Myneni
2022-02-14 3:49 ` Nicholas Piggin
2022-01-21 20:01 ` [PATCH v3 10/10] powerpc/pseries/vas: Write 'target_creds' for QoS credits change Haren Myneni
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=1644809992.wf4i5w12rf.astroid@bobo.none \
--to=npiggin@gmail.com \
--cc=haren@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--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;
as well as URLs for NNTP newsgroup(s).