From: Akshay Adiga <email@example.com> To: Nicholas Piggin <firstname.lastname@example.org> Cc: email@example.com Subject: Re: [PATCH] powerpc/powernv/idle: Restore IAMR after idle Date: Wed, 20 Feb 2019 11:34:11 +0530 Message-ID: <20190220060353.GA21952@aks.ibm> (raw) In-Reply-To: <firstname.lastname@example.org> On Tue, Feb 19, 2019 at 02:21:04PM +1000, Nicholas Piggin wrote: > Michael Ellerman's on February 8, 2019 11:04 am: > > Nicholas Piggin <email@example.com> writes: > >> Russell Currey's on February 6, 2019 4:28 pm: > >>> Without restoring the IAMR after idle, execution prevention on POWER9 > >>> with Radix MMU is overwritten and the kernel can freely execute userspace without > >>> faulting. > >>> > >>> This is necessary when returning from any stop state that modifies user > >>> state, as well as hypervisor state. > >>> > >>> To test how this fails without this patch, load the lkdtm driver and > >>> do the following: > >>> > >>> echo EXEC_USERSPACE > /sys/kernel/debug/provoke-crash/DIRECT > >>> > >>> which won't fault, then boot the kernel with powersave=off, where it > >>> will fault. Applying this patch will fix this. > >>> > >>> Fixes: 3b10d0095a1e ("powerpc/mm/radix: Prevent kernel execution of user > >>> space") > >>> Cc: <firstname.lastname@example.org> > >>> Signed-off-by: Russell Currey <email@example.com> > >> > >> Good catch and debugging. This really should be a quirk, we don't want > >> to have to restore this thing on a thread switch. > > > > I'm not sure I follow. We don't context switch it on Radix, but we do > > on hash if pkeys are enabled. > > Badly worded, I mean a hardware quirk. It should follow thread > switches. Still, avoiding it for the no-loss case is better than > nothing. We can just revisit it as an optimization if future > hardware does not require the restore. Apparently, the POWER9 Processor User’s Manual v2.0 documents that IAMR can be lost, and that is not just the end. Pasting excerpt from "Section 184.108.40.206 State Loss and Restoration,Page 309" On the POWER9 core, the only state that can be lost for Stop levels less than four, when PSSCR[ESL] = ‘1’ are the following SPRs: CR, FPSCR, VSCR, XER, DSCR, AMR, IAMR, UAMOR, AMOR, DAWR, DAWRX. My observation is that AMOR is being used in kernel as of today and AMOR is also lost (recreated in similar scenarios where IAMR is lost).
next prev parent reply index Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-06 6:28 Russell Currey 2019-02-07 4:29 ` Michael Ellerman 2019-02-07 6:28 ` Russell Currey 2019-02-07 5:08 ` Nicholas Piggin 2019-02-07 6:33 ` Russell Currey 2019-02-07 16:37 ` Thiago Jung Bauermann 2019-02-07 22:38 ` Russell Currey 2019-02-08 1:04 ` Michael Ellerman 2019-02-19 4:21 ` Nicholas Piggin 2019-02-20 6:04 ` Akshay Adiga [this message] 2019-02-20 11:18 ` Russell Currey 2019-02-20 7:15 ` Akshay Adiga 2019-02-20 11:25 ` Russell Currey 2019-02-20 8:58 ` Akshay Adiga 2019-02-20 11:20 ` Russell Currey
Reply instructions: You may reply publically 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=20190220060353.GA21952@aks.ibm \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.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
LinuxPPC-Dev Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linuxppc-dev/0 linuxppc-dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linuxppc-dev linuxppc-dev/ https://lore.kernel.org/linuxppc-dev \ email@example.com firstname.lastname@example.org email@example.com public-inbox-index linuxppc-dev Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.ozlabs.lists.linuxppc-dev AGPL code for this site: git clone https://public-inbox.org/ public-inbox