From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EE9AC433EF for ; Mon, 21 Feb 2022 13:26:24 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4K2NNt60G6z3cPT for ; Tue, 22 Feb 2022 00:26:22 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=permerror (SPF Permanent Error: Missing IP4: 193.174.2.0/24) smtp.helo=elvis.franken.de (client-ip=193.175.24.41; helo=elvis.franken.de; envelope-from=tsbogend@alpha.franken.de; receiver=) Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by lists.ozlabs.org (Postfix) with ESMTP id 4K2NNL1BXFz2yJM for ; Tue, 22 Feb 2022 00:25:51 +1100 (AEDT) Received: from uucp (helo=alpha) by elvis.franken.de with local-bsmtp (Exim 3.36 #1) id 1nM8h9-0001Eo-00; Mon, 21 Feb 2022 14:25:39 +0100 Received: by alpha.franken.de (Postfix, from userid 1000) id E4525C25DD; Mon, 21 Feb 2022 14:24:56 +0100 (CET) Date: Mon, 21 Feb 2022 14:24:56 +0100 From: Thomas Bogendoerfer To: Arnd Bergmann Subject: Re: [PATCH v2 09/18] mips: use simpler access_ok() Message-ID: <20220221132456.GA7139@alpha.franken.de> References: <20220216131332.1489939-1-arnd@kernel.org> <20220216131332.1489939-10-arnd@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220216131332.1489939-10-arnd@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, dalias@libc.org, linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, peterz@infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, guoren@kernel.org, sparclinux@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-riscv@lists.infradead.org, will@kernel.org, Christoph Hellwig , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, bcain@codeaurora.org, deller@gmx.de, x86@kernel.org, linux@armlinux.org.uk, linux-csky@vger.kernel.org, ardb@kernel.org, mingo@redhat.com, geert@linux-m68k.org, linux-snps-arc@lists.infradead.org, linux-xtensa@linux-xtensa.org, arnd@arndb.de, hca@linux.ibm.com, linux-alpha@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-m68k@lists.linux-m68k.org, openrisc@lists.librecores.org, viro@zeniv.linux.org.uk, shorne@gmail.com, monstr@monstr.eu, linux-parisc@vger.kernel.org, nickhu@andestech.com, jcmvbkbc@gmail.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, dinguyen@kernel.org, ebiederm@xmission.com, richard@nod.at, akpm@linux-foundation.org, Linus Torvalds , davem@davemloft.net, green.hu@gmail.com Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, Feb 16, 2022 at 02:13:23PM +0100, Arnd Bergmann wrote: > > diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h > index db9a8e002b62..d7c89dc3426c 100644 > --- a/arch/mips/include/asm/uaccess.h > +++ b/arch/mips/include/asm/uaccess.h > @@ -19,6 +19,7 @@ > #ifdef CONFIG_32BIT > > #define __UA_LIMIT 0x80000000UL > +#define TASK_SIZE_MAX __UA_LIMIT > > #define __UA_ADDR ".word" > #define __UA_LA "la" > @@ -33,6 +34,7 @@ > extern u64 __ua_limit; > > #define __UA_LIMIT __ua_limit > +#define TASK_SIZE_MAX XKSSEG this doesn't work. For every access above maximum implemented virtual address space of the CPU an address error will be issued, but not a TLB miss. And address error isn't able to handle this situation. With this patch diff --git a/arch/mips/kernel/unaligned.c b/arch/mips/kernel/unaligned.c index df4b708c04a9..3911f1481f3d 100644 --- a/arch/mips/kernel/unaligned.c +++ b/arch/mips/kernel/unaligned.c @@ -1480,6 +1480,13 @@ asmlinkage void do_ade(struct pt_regs *regs) prev_state = exception_enter(); perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, regs->cp0_badvaddr); + + /* Are we prepared to handle this kernel fault? */ + if (fixup_exception(regs)) { + current->thread.cp0_baduaddr = regs->cp0_badvaddr; + return; + } + /* * Did we catch a fault trying to load an instruction? */ I at least get my simple test cases fixed, but I'm not sure this is correct. Is there a reason to not also #define TASK_SIZE_MAX __UA_LIMIT like for the 32bit case ? Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]