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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CDE19CD1284 for ; Thu, 11 Apr 2024 09:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PYrHfIf67bX5qKk99g7Ml8EnsCc3VRdwyNM+1Ti+/PQ=; b=v3cOzCG+lq5jgD 1VmLQUdyS5QIYF6NtAU2fV7Ar1wSahhxeTssW6CUCcgUhqecBxGbhpzFP8EwDP+/XKrlj0ZLTfV96 90/lqx0LkQn+bG1LO/v1+OzeOJiGr4fDiOaSfhDC0Uc14I6duROm3uUiNR7rpo0FwjSaXW3jKQn2M yIF7tuRRHzk5SHDgXEdcogTIGQkmCsChOspOmzoBdThIUiIXn7tPF5k90/2IRrJdkZZfWD2S9Lnh7 p9dGRJFYOgf1QauG4bxoT7HjaE7nH7VxP05hhIrp7wstr/CpeugoxoIhU1O2Dt18PJR+E3+b4LIiu UZFQaseYYsnF8GWjlWDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rurDU-0000000BQWO-1YsW; Thu, 11 Apr 2024 09:59:36 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rurDR-0000000BQU2-3gUh for linux-arm-kernel@lists.infradead.org; Thu, 11 Apr 2024 09:59:35 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 904CECE2FC1; Thu, 11 Apr 2024 09:59:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 804BFC433C7; Thu, 11 Apr 2024 09:59:23 +0000 (UTC) Date: Thu, 11 Apr 2024 10:59:21 +0100 From: Catalin Marinas To: Kefeng Wang Cc: Andrew Morton , Russell King , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Subject: Re: [PATCH 1/2] arm64: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS Message-ID: References: <20240407081211.2292362-1-wangkefeng.wang@huawei.com> <20240407081211.2292362-2-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240411_025934_226547_5BBB7666 X-CRM114-Status: GOOD ( 23.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 10, 2024 at 06:58:27PM +0800, Kefeng Wang wrote: > On 2024/4/10 9:30, Kefeng Wang wrote: > > On 2024/4/9 22:28, Catalin Marinas wrote: > > > On Sun, Apr 07, 2024 at 04:12:10PM +0800, Kefeng Wang wrote: > > > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > > > > index 405f9aa831bd..61a2acae0dca 100644 > > > > --- a/arch/arm64/mm/fault.c > > > > +++ b/arch/arm64/mm/fault.c > > > > @@ -500,9 +500,6 @@ static bool is_write_abort(unsigned long esr) > > > > =A0=A0=A0=A0=A0 return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM); > > > > =A0 } > > > > -#define VM_FAULT_BADMAP=A0=A0=A0=A0=A0=A0=A0 ((__force vm_fault_t)= 0x010000) > > > > -#define VM_FAULT_BADACCESS=A0=A0=A0 ((__force vm_fault_t)0x020000) > > > > - > > > > =A0 static int __kprobes do_page_fault(unsigned long far, unsigned > > > > long esr, > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 struct= pt_regs *regs) > > > > =A0 { > > > > @@ -513,6 +510,7 @@ static int __kprobes do_page_fault(unsigned > > > > long far, unsigned long esr, > > > > =A0=A0=A0=A0=A0 unsigned int mm_flags =3D FAULT_FLAG_DEFAULT; > > > > =A0=A0=A0=A0=A0 unsigned long addr =3D untagged_addr(far); > > > > =A0=A0=A0=A0=A0 struct vm_area_struct *vma; > > > > +=A0=A0=A0 int si_code; > > > = > > > I think we should initialise this to 0. Currently all paths seem to s= et > > > si_code to something meaningful but I'm not sure the last 'else' close > > > in this patch is guaranteed to always cover exactly those earlier code > > > paths updating si_code. I'm not talking about the 'goto bad_area' pat= hs > > > since they set 'fault' to 0 but the fall through after the second (un= der > > > the mm lock) handle_mm_fault(). [...] > > > > +=A0=A0=A0 fault =3D handle_mm_fault(vma, addr, mm_flags, regs); > > > > =A0=A0=A0=A0=A0 /* Quick path to respond to signals */ > > > > =A0=A0=A0=A0=A0 if (fault_signal_pending(fault, regs)) { > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 if (!user_mode(regs)) > > > > @@ -626,13 +628,11 @@ static int __kprobes do_page_fault(unsigned l= ong far, unsigned long esr, > > > > =A0=A0=A0=A0=A0 mmap_read_unlock(mm); > > > > =A0 done: > > > > -=A0=A0=A0 /* > > > > -=A0=A0=A0=A0 * Handle the "normal" (no error) case first. > > > > -=A0=A0=A0=A0 */ > > > > -=A0=A0=A0 if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | > > > > -=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 VM_FAULT_BADAC= CESS)))) > > > > +=A0=A0=A0 /* Handle the "normal" (no error) case first. */ > > > > +=A0=A0=A0 if (likely(!(fault & VM_FAULT_ERROR))) > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0; > = > Another choice, we set si_code =3D SEGV_MAPERR here, since normal > pagefault don't use si_code, only the error patch need to initialize. Yes, I think initialising it here would be fine. That's the fall-through case I was concerned about. All the other goto bad_area places already initialise si_code. -- = Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel