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 545892C3745 for ; Fri, 2 Jan 2026 14:18:50 +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=1767363532; cv=none; b=qrL59+gvg/orF4MVZMKiBr7pcpxyk8zbPB9KkRDdFkYx8CwW3my/CZvq9X1EmkJlXtteRhBwween4ujqz7LNlScNbl4SNTKtr3FQd9mafMvtzboX97e8hegezIuNmbWiN4TH3UR81dh1WcjcRq9YQI/VNiyPlYh7+UAAhHAKPXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767363532; c=relaxed/simple; bh=lJjFUr5WEQFTu5D8LcIvJXshkk3QENUOwcs71bl5bPI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dJ70N4Oqyl+GME8V9XsS4xejPIthQ5dRGK+Ou6YJzgkWgMApwpflnpiasl2WnhcVO5NTzFXF+yo9GhyDShD3xktj2FxoADMP/KF+gyy8mv3+k0CpEQLwcKasxgRCjQDanip3beaVgl/AvK/8KRyNeRs5/xIqVUOAkx+Am3dwJlw= 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 6EB18497; Fri, 2 Jan 2026 06:18:42 -0800 (PST) Received: from [10.57.94.221] (unknown [10.57.94.221]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 943E03F63F; Fri, 2 Jan 2026 06:18:46 -0800 (PST) Message-ID: Date: Fri, 2 Jan 2026 14:18:44 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 01/13] arm64: mm: Re-implement the __tlbi_level macro as a C function Content-Language: en-GB To: Jonathan Cameron Cc: Will Deacon , Ard Biesheuvel , Catalin Marinas , Mark Rutland , Linus Torvalds , Oliver Upton , Marc Zyngier , Dev Jain , Linu Cherian , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20251216144601.2106412-1-ryan.roberts@arm.com> <20251216144601.2106412-2-ryan.roberts@arm.com> <20251216175309.00001935@huawei.com> From: Ryan Roberts In-Reply-To: <20251216175309.00001935@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Happy new year! On 16/12/2025 17:53, Jonathan Cameron wrote: > On Tue, 16 Dec 2025 14:45:46 +0000 > Ryan Roberts wrote: > >> As part of efforts to reduce our reliance on complex preprocessor macros >> for TLB invalidation routines, convert the __tlbi_level macro to a C >> function for by-level TLB invalidation. >> >> Each specific tlbi level op is implemented as a C function and the >> appropriate function pointer is passed to __tlbi_level(). Since >> everything is declared inline and is statically resolvable, the compiler >> will convert the indirect function call to a direct inline execution. >> >> Suggested-by: Linus Torvalds >> Signed-off-by: Ryan Roberts >> --- > >> +static __always_inline void __tlbi_level(tlbi_op op, u64 addr, u32 level) >> +{ >> + u64 arg = addr; >> + >> + if (alternative_has_cap_unlikely(ARM64_HAS_ARMv8_4_TTL) && level <= 3) { >> + u64 ttl = level | (get_trans_granule() << 2); >> + >> + arg &= ~TLBI_TTL_MASK; >> + arg |= FIELD_PREP(TLBI_TTL_MASK, ttl); > > Probably don't care, but I think you could do > FIELD_MODIFY(TLBI_TTL_MASK, &arg, ttl); > instead of those two lines. Code generation hopefully similar? > So depends on which macros you find more readable. Yeah that's probably slightly neater - I'll switch to this for the next version. Thanks, Ryan > >> + } >> + >> + op(arg); >> +} >> >> #define __tlbi_user_level(op, arg, level) do { \ >> if (arm64_kernel_unmapped_at_el0()) \ >