From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2008030AABE for ; Mon, 3 Aug 2026 15:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785771166; cv=none; b=B/Gs0+dlIzhWh0emoT4UKDUBzaC6hNjiycSj2ckthzWCrQk4vMVInALa6G2njzcg5/xHhlVT7OxfIgT50LR9CZpWD7JJuLbyTJTX4NsHpMSmuTaQihnvd9aBQzGbY5DtVK3Hp+q3LgY9JIIt45+jAuBPQxj/tZtq+BMfAZ/eJQk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785771166; c=relaxed/simple; bh=2UMX24n7itPWmMCK/C5n9Su2cC4dvzwWHn33BpemKhs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BYvSoKY86n3I/1+d0boqzvYpliqS00rkO+j6D26s+v1xduEil6jDBKtFieLkRQ144Zk4O5XdGe/w4xpvdzjbcycZlgRkWgonm0bxxi7dY6Jz61DPumbcZ81etoZd7UZIZ1h2zF83kzJfc8OdDhW41MVHFGktRo0x362drXwfN+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WYg7oONs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WYg7oONs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BD9F1F00A3A; Mon, 3 Aug 2026 15:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785771164; bh=dtAprwl9YVKSgx2qkgDkJIY4Tilcw0HSTK5NvGoGEC4=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=WYg7oONsuX2Brvgwjitwk77p506v8el7XNP2buJRtdOxkH5PrcmxYad/4+siEEvi+ ngSsM83nqgyT19k3ROzH+GFDDT5o/PdfUBmLFewVJst0NyLUX/qVomM71taDAJmPaq qLRAesXU7j0fYjZpY71Ek+ECQFOynvtixDxkRJcrajEscwc/yi09TElybQ69+x6HlN eeBXN5dBQHJ4QARAv6jl96Oomj3R74GNuK59qp+vsBFi2/iL+5lahu1rYeQGYcZ77W n28Lu+D73MJvHHClLynmaxonmzIfYJ3AFSgBZ1uJOFvvzH5gExH+hhngKNOB5+JwHv 7MXXCtl99O6IA== Date: Mon, 3 Aug 2026 16:32:27 +0100 From: "Lorenzo Stoakes (ARM)" To: Barry Song Cc: akpm@linux-foundation.org, linux-mm@kvack.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, surenb@google.com, liam@infradead.org, vbabka@kernel.org, shakeel.butt@linux.dev, david@kernel.org, linux-kernel@vger.kernel.org, zhanghongru@xiaomi.com, willy@infradead.org, zhangbo56@xiaomi.com Subject: Re: [RFC PATCH v1 2/2] arm64/mm: use VMA lock for kernel faults on user addresses Message-ID: References: <20260802074018.73887-1-baohua@kernel.org> <20260802074018.73887-3-baohua@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Sun, Aug 02, 2026 at 04:49:04PM +0800, Barry Song wrote: > On Sun, Aug 2, 2026 at 3:40 PM Barry Song (Xiaomi) wrote: > > > > Use the VMA lock for kernel faults on user addresses. This also > > makes the existing code below meaningful: > > > > /* Quick path to respond to signals */ > > if (fault_signal_pending(fault, regs)) { > > if (!user_mode(regs)) > > goto no_context; > > return 0; > > } > > > > Right now, the code above is dead because !user_mode always > > takes the mmap_lock path. > > > > Co-developed-by: Bo Zhang > > Signed-off-by: Bo Zhang > > Signed-off-by: Barry Song (Xiaomi) > > --- > > arch/arm64/mm/fault.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > > index 85e23388f9bb..241f1ab07ab3 100644 > > --- a/arch/arm64/mm/fault.c > > +++ b/arch/arm64/mm/fault.c > > @@ -607,6 +607,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, > > unsigned int mm_flags = FAULT_FLAG_DEFAULT; > > unsigned long addr = untagged_addr(far); > > struct vm_area_struct *vma; > > + bool uaccess = false; > > int si_code; > > int pkey = -1; > > > > @@ -663,6 +664,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, > > if (!insn_may_access_user(regs->pc, esr)) > > die_kernel_fault("access to user memory outside uaccess routines", > > addr, esr, regs); > > + uaccess = true; > > https://sashiko.dev/#/patchset/20260802074018.73887-1-baohua%40kernel.org > > "Does this conditional bypass translation faults? Because this block is > guarded by: > if (is_ttbr0_addr(addr) && is_el1_permission_fault(addr, esr, regs)) { > it appears uaccess is only set for permission faults like CoW or PAN > violations. > If a kernel uaccess routine accesses an unmapped user address, a translation > fault occurs, making is_el1_permission_fault() evaluate to false. > Would this cause demand paging in uaccess routines to fall back to the slow > lock_mmap path, missing the intended optimization?" > > Good catch! I should have only modified a single line. Then > unmapped PTEs would also benefit from the VMA lock: > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index 85e23388f9bb..e1b406d667aa 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -674,7 +674,7 @@ static int __kprobes do_page_fault(unsigned long > far, unsigned long esr, > > perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr); > > - if (!(mm_flags & FAULT_FLAG_USER)) > + if (!(mm_flags & FAULT_FLAG_USER) && !is_ttbr0_addr(addr)) > goto lock_mmap; I mean honestly it feels like, with the permanent VMA flags change, that maybe this really needs to wait for Matthew's series? There's duplication here too of course :) But it begs the question of every other arch that does VMA page faulting. So feels better suited as part of that change I think? Maybe Matthew has thoughts. > > vma = lock_vma_under_rcu(mm, addr); -- Cheers, Lorenzo