From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3894A3081BD for ; Mon, 1 Dec 2025 10:30:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764585026; cv=none; b=NPeRLHo99uNzc1aEpKaDTCVoH937W8ouPAY8cxeeIybBfNfwCUnAy2i5ujl2ZCkwwjmRtWmgtDib9vr3WcL39f05r4JL176R2WbbubeVlMvHphUORrlq50H5ZN04xVQBdaqG0NDKB31DFtDV2AnJunIN/9TqjERjISTAq/Mftqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764585026; c=relaxed/simple; bh=E7ydo/6BGXF7SkUgHjB30Sd6dABPSAzRR8cJTRVe7DU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=q86Ba4peAE4upCJ6ALHUN1lFGTBrl4cDWstCipIKWo6mehY2FAzHvyOq7eDSbijTaqyTbwMVEx9nMDBeY9dGyZkjvxZWvGQz887zVlnBJtCgllCmvLM+79l0rXMb3OhgCZa4fhRL8aBMOazc6Papuvz+pL+Tu4PwjTwc3SI5a4E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E08CA1516; Mon, 1 Dec 2025 02:30:13 -0800 (PST) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D0B9E3F73B; Mon, 1 Dec 2025 02:30:18 -0800 (PST) Date: Mon, 1 Dec 2025 10:30:16 +0000 From: Mark Rutland To: david laight Cc: Jinjie Ruan , linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, chris@zankel.net, jcmvbkbc@gmail.com, akpm@linux-foundation.org, macro@orcam.me.uk, charlie@rivosinc.com, deller@gmx.de, ldv@strace.io, rostedt@goodmis.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] arm64: Avoid memcpy() for syscall_get_arguments() Message-ID: References: <20251127123630.4149828-1-ruanjinjie@huawei.com> <20251127123630.4149828-3-ruanjinjie@huawei.com> <20251201102633.17a99afc@pumpkin> 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=us-ascii Content-Disposition: inline In-Reply-To: <20251201102633.17a99afc@pumpkin> On Mon, Dec 01, 2025 at 10:26:33AM +0000, david laight wrote: > On Mon, 1 Dec 2025 10:13:54 +0000 > Mark Rutland wrote: > > On Thu, Nov 27, 2025 at 08:36:30PM +0800, Jinjie Ruan wrote: > > > Before: > > > : > > > aa0103e2 mov x2, x1 > > > 91002003 add x3, x0, #0x8 > > > f9408804 ldr x4, [x0, #272] > > > f8008444 str x4, [x2], #8 > > > a9409404 ldp x4, x5, [x0, #8] > > > a9009424 stp x4, x5, [x1, #8] > > > a9418400 ldp x0, x1, [x0, #24] > > > a9010440 stp x0, x1, [x2, #16] > > > f9401060 ldr x0, [x3, #32] > > > f9001040 str x0, [x2, #32] > > > d65f03c0 ret > > > d503201f nop > > > > > > After: > > > a9408e82 ldp x2, x3, [x20, #8] > > > 2a1603e0 mov w0, w22 > > > f9400e84 ldr x4, [x20, #24] > > > f9408a81 ldr x1, [x20, #272] > > > 9401c4ba bl ffff800080215ca8 <__audit_syscall_entry> > > > > It's probably worth noting that __audit_syscall_entry() only takes 4 > > syscall arguments, and hence the compiler has elided the copy of > > regs->regs[4] and regs->regs[5], which it apparently couldn't manage > > before. > > Hasn't it actually inlined it and completely optimised away the regs[] array? > It looks (from the asm) as though syscall_get_arguments() is followed by: > fn(regs[0], regs[1], regs[2], regs[3]) Yes; I was assuming that people could infer that. I was poining out that the elision of copies/loads of regs->regs[4] and regs->regs[5] in particular was not a bug. Mark.