From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RDNS_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 6796 invoked from network); 11 Mar 2020 02:18:25 -0000 Received-SPF: pass (mother.openwall.net: domain of lists.openwall.com designates 195.42.179.200 as permitted sender) receiver=inbox.vuxu.org; client-ip=195.42.179.200 envelope-from= Received: from unknown (HELO mother.openwall.net) (195.42.179.200) by inbox.vuxu.org with ESMTP; 11 Mar 2020 02:18:25 -0000 Received: (qmail 5442 invoked by uid 550); 11 Mar 2020 02:18:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5417 invoked from network); 11 Mar 2020 02:18:22 -0000 Date: Tue, 10 Mar 2020 22:18:08 -0400 From: Rich Felker To: Andreas =?utf-8?B?RHLDtnNjaGVy?= Cc: musl@lists.openwall.com Message-ID: <20200311021808.GG11469@brightrain.aerifal.cx> References: <20200311005553.GE11469@brightrain.aerifal.cx> <20200311014039.GF11469@brightrain.aerifal.cx> <5a45c0f9-21de-6649-d4d9-3d0804c3ca0e@droescher.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5a45c0f9-21de-6649-d4d9-3d0804c3ca0e@droescher.ch> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] mips32 little endian -ENOSYS is not -(-ENOSYS) On Wed, Mar 11, 2020 at 03:08:22AM +0100, Andreas Dröscher wrote: > >>Sorry for not including that excerpt in the first place: > >> > >>illegal_syscall: > >> li v0, -ENOSYS # error > >> sw v0, PT_R2(sp) > >> li t0, 1 # set error flag > >> sw t0, PT_R7(sp) > >> j o32_syscall_exit > >> END(handle_sys) > >> > >>Source: https://github.com/torvalds/linux/blob/62d0cfcb27cf755cebdc93ca95dabc83608007cd/arch/mips/kernel/scall32-o32.S#L186 > > > >OK, this was fixed by commit bda8229bdd087167f463ad5e74299987924f8137 > >in 2008. But it looks like there's still another path, called > >"einval" from before commit fb498e2570eedc6c9c3d165e370624dfc3aed97b, > >that returns -ENOSYS. All of this is awful, and I think your fix is > >probably the right thing to do. > > Thank you very much for your review. > > Just as a side note. I’ve just figured out that there is a second > issue with old kernels. > > The current implementation of __syscall5, __syscall6 and __syscall7 > (those use caller saved registers) violate the calling conventions > of MIPS32 Linux Kernels prior 2.6.35. Those were assuming that the > instruction immediately preceding the SYSCALL instruction was an > instruction for loading the syscall number. > > I’ll will try to rearrange the stack pushes to accommodate this > requirement and report back if I manage to come up with something > presentable. Uhg, so commit 604f8d3d8b08ee4f548de193050ef93a7753c2e0 was probably wrong and there was a reason for the nonsensical code it removed: making old broken kernels happy. I'm not sure if you can just revert it or need to make new changes. Do you know if this "rule" applies to n32/n64 too or just o32? Rich