From: Haren Myneni <haren@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>,
linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au,
nathanl@linux.ibm.com
Subject: Re: [PATCH v4 4/9] powerpc/vas: Return paste instruction failure if no active window
Date: Tue, 22 Feb 2022 23:56:12 -0800 [thread overview]
Message-ID: <c736a4ff9918aebc5be601e7d9fb1c2ca1ad4787.camel@linux.ibm.com> (raw)
In-Reply-To: <1645599884.mn9fi17enu.astroid@bobo.none>
On Wed, 2022-02-23 at 17:05 +1000, Nicholas Piggin wrote:
> Excerpts from Haren Myneni's message of February 20, 2022 5:58 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.
>
> Looks good, thanks for fixin the SIGBUS thing, was that my
> fault? I vaguely remember writing some of this patch :P
Thanks for your reviews on all patches.
No, it was my fault not handling the -EGAIN error.
>
> Thanks,
> Nick
>
> > 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 | 55
> > ++++++++++++++++++++++++-
> > 2 files changed, 56 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/powerpc/include/asm/ppc-opcode.h
> > b/arch/powerpc/include/asm/ppc-opcode.h
> > index 9675303b724e..82f1f0041c6f 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 f359e7b2bf90..f3e421511ea6 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;
> > +
> > + /*
> > + * 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); /* Emulate the paste */
> > +
> > + return 0;
> > +}
> > +
> > /*
> > * This fault handler is invoked when the core generates page
> > fault on
> > * the paste address. Happens if the kernel closes window in
> > hypervisor
> > @@ -408,9 +443,27 @@ 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();
> > + /*
> > + * The user space can retry several times until success (needed
> > + * for migration) or should fallback to SW compression or
> > + * manage with the existing open windows if available.
> > + * Looking at sysfs interface, it can determine whether these
> > + * failures are coming during migration or core removal:
> > + * nr_used_credits > nr_total_credits when lost credits
> > + */
> > + if (!ret || (ret == -EAGAIN))
> > + return VM_FAULT_NOPAGE;
> >
> > + 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-23 7:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 19:49 [PATCH v4 0/9] powerpc/pseries/vas: NXGZIP support with DLPAR Haren Myneni
2022-02-19 19:54 ` [PATCH v4 1/9] powerpc/pseries/vas: Use common names in VAS capability structure Haren Myneni
2022-02-19 19:55 ` [PATCH v4 2/9] powerpc/pseries/vas: Save PID in pseries_vas_window struct Haren Myneni
2022-02-23 7:00 ` Nicholas Piggin
2022-02-19 19:55 ` [PATCH v4 3/9] powerpc/vas: Add paste address mmap fault handler Haren Myneni
2022-02-23 7:03 ` Nicholas Piggin
2022-02-19 19:58 ` [PATCH v4 4/9] powerpc/vas: Return paste instruction failure if no active window Haren Myneni
2022-02-23 7:05 ` Nicholas Piggin
2022-02-23 7:56 ` Haren Myneni [this message]
2022-02-19 19:59 ` [PATCH v4 5/9] powerpc/vas: Map paste address only if window is active Haren Myneni
2022-02-23 7:11 ` Nicholas Piggin
2022-02-23 8:02 ` Haren Myneni
2022-02-19 20:00 ` [PATCH v4 6/9] powerpc/pseries/vas: Close windows with DLPAR core removal Haren Myneni
2022-02-23 7:23 ` Nicholas Piggin
2022-02-23 8:21 ` Haren Myneni
2022-02-19 20:01 ` [PATCH v4 7/9] powerpc/pseries/vas: Reopen windows with DLPAR core add Haren Myneni
2022-02-23 7:28 ` Nicholas Piggin
2022-02-23 8:32 ` Haren Myneni
2022-02-19 20:01 ` [PATCH v4 8/9] powerpc/pseries/vas: sysfs interface to export capabilities Haren Myneni
2022-02-23 7:29 ` Nicholas Piggin
2022-02-19 20:03 ` [PATCH v4 9/9] powerpc/pseries/vas: Write 'nr_total_credits' for QoS credits change Haren Myneni
2022-02-23 7:33 ` Nicholas Piggin
2022-02-23 8:39 ` 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=c736a4ff9918aebc5be601e7d9fb1c2ca1ad4787.camel@linux.ibm.com \
--to=haren@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
/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).