From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>
Subject: Re: [RFC PATCH 1/5] powerpc/64s/hash: convert SLB miss handlers to C
Date: Mon, 20 Aug 2018 20:08:22 +1000 [thread overview]
Message-ID: <20180820200822.111a659e@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20180820094200.13003-2-npiggin@gmail.com>
On Mon, 20 Aug 2018 19:41:56 +1000
Nicholas Piggin <npiggin@gmail.com> wrote:
> +long do_slb_fault(struct pt_regs *regs, unsigned long ea)
> +{
> + unsigned long id = REGION_ID(ea);
> +
> + /* IRQs are not reconciled here, so can't check irqs_disabled */
> + VM_WARN_ON(mfmsr() & MSR_EE);
> +
> + /*
> + * SLB kernel faults must be very careful not to touch anything
> + * that is not bolted. E.g., PACA and global variables are okay,
> + * mm->context stuff is not.
> + *
> + * SLB user faults can access all of kernel memory, but must be
> + * careful not to touch things like IRQ state because it is not
> + * "reconciled" here. The difficulty is that we must use
> + * fast_exception_return to return from kernel SLB faults without
> + * looking at possible non-bolted memory. We could test user vs
> + * kernel faults in the interrupt handler asm and do a full fault,
> + * reconcile, ret_from_except for user faults which would make them
> + * first class kernel code. But for performance it's probably nicer
> + * if they go via fast_exception_return too.
> + */
> + if (id >= KERNEL_REGION_ID) {
> + return slb_allocate_kernel(ea, id);
> + } else {
> + struct mm_struct *mm = current->mm;
> +
> + if (unlikely(!mm))
> + return -EFAULT;
>
> - handle_multi_context_slb_miss(context, ea);
> - exception_exit(prev_state);
> - return;
> + return slb_allocate_user(mm, ea);
> + }
> +}
>
> -slb_bad_addr:
> +void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err)
> +{
> if (user_mode(regs))
> _exception(SIGSEGV, regs, SEGV_BNDERR, ea);
> else
> bad_page_fault(regs, ea, SIGSEGV);
> - exception_exit(prev_state);
> }
I knew I forgot something -- forgot to test MSR[RI] here. That can be
done just by returning a different error from do_slb_fault if RI is
clear, and do_bad_slb_fault will call unrecoverable_exception() if it
sees that code.
Thanks,
Nick
next prev parent reply other threads:[~2018-08-20 10:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 9:41 [RFC PATCH 0/5] rewriting SLB miss handler in C Nicholas Piggin
2018-08-20 9:41 ` [RFC PATCH 1/5] powerpc/64s/hash: convert SLB miss handlers to C Nicholas Piggin
2018-08-20 10:08 ` Nicholas Piggin [this message]
2018-08-21 6:46 ` Michael Ellerman
2018-08-22 3:17 ` Nicholas Piggin
2018-08-22 10:11 ` Michael Ellerman
2018-08-20 9:41 ` [RFC PATCH 2/5] powerpc/64s/hash: remove user SLB data from the paca Nicholas Piggin
2018-08-20 9:41 ` [RFC PATCH 3/5] powerpc/64s/hash: remove the first vmalloc segment from the bolted SLB Nicholas Piggin
2018-08-20 9:41 ` [RFC PATCH 4/5] powerpc/64s/hash: Add SLB allocation bitmaps Nicholas Piggin
2018-08-20 9:42 ` [RFC PATCH 5/5] powerpc/64s/hash: Add a SLB preload cache Nicholas Piggin
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=20180820200822.111a659e@roar.ozlabs.ibm.com \
--to=npiggin@gmail.com \
--cc=aneesh.kumar@linux.ibm.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).