Date: Tue, 14 Feb 2017 09:17:57 -0800 From: Mark Millard <markmi@dsl-only.net> To: Andrew Turner <andrew@fubar.geek.nz> Cc: Shawn Webb <shawn.webb@hardenedbsd.org>, Tom Vijlbrief <tvijlbrief@gmail.com>, freebsd-arm <freebsd-arm@freebsd.org> Subject: Re: A potential fix for arm64's: sh`forkshell child-process path after fork sometimes has a bad stack pointer value Message-ID: <6EED2BFF-CAFB-4F58-8D0D-8E060319278C@dsl-only.net> In-Reply-To: <20170214165644.15dedf6e@zapp> References: <DC3CC3BE-9D8C-41ED-ADD0-AFD4019B2E90@dsl-only.net> <2D04FF37-DEC8-42CE-961D-AE8CD58A0EAA@dsl-only.net> <93064627-5F72-4167-90B1-0A98ABF4C99C@dsl-only.net> <3BC697B9-4A3E-49FF-AB11-1106E2EF8399@dsl-only.net> <20170214165644.15dedf6e@zapp>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2017-Feb-14, at 8:56 AM, Andrew Turner <andrew at fubar.geek.nz> wrote: On Tue, 14 Feb 2017 08:35:54 -0800 > Mark Millard <markmi at dsl-only.net> wrote: > >> The following change has let my test run for 8.5 hours so far without >> a fork-failure in sh`forkshell : >> >> # svnlite diff /usr/src/sys/arm64/arm64/swtch.S >> Index: /usr/src/sys/arm64/arm64/swtch.S >> =================================================================== >> --- /usr/src/sys/arm64/arm64/swtch.S (revision 312982) >> +++ /usr/src/sys/arm64/arm64/swtch.S (working copy) >> @@ -241,6 +241,12 @@ >> mov fp, #0 /* Stack traceback stops here. */ >> bl _C_LABEL(fork_exit) >> >> + /* >> + * Disable interrupts to avoid >> + * overwriting sp_el0 and spsr_el1 by an IRQ exception. >> + */ >> + msr daifset, #2 >> + >> /* Restore sp and lr */ >> ldp x0, x1, [sp] >> msr sp_el0, x0 >> @@ -263,12 +269,6 @@ >> ldp x28, x29, [sp, #TF_X + 28 * 8] >> /* Skip x30 as it was restored above as lr */ >> >> - /* >> - * Disable interrupts to avoid >> - * overwriting spsr_el1 by an IRQ exception. >> - */ >> - msr daifset, #2 >> - >> /* Restore elr and spsr */ >> ldp x0, x1, [sp, #16] >> msr elr_el1, x0 >> >> I'm going to switch to attempting a self-hosted buildworld >> buildkernel again. > > Can you try the patch in https://reviews.freebsd.org/D9593. It moves > loading of sp_el0 until after interrupts have been disabled. > > Andrew Sure. I'll stop the self-hosted buildworld buildkernel and switch over to your source. One minor point: /* Skip x30 as it was restored above as lr */ now should say something like: /* Skip x30 as it is restored below as lr */ === Mark Millard markmi at dsl-only.net
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6EED2BFF-CAFB-4F58-8D0D-8E060319278C>