From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sinmsgout02.his.huawei.com (sinmsgout02.his.huawei.com [119.8.177.37]) (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 8C57F2494FF for ; Tue, 16 Dec 2025 18:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=119.8.177.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765908771; cv=none; b=fp9pgWTqsXUwboq1VHu4JIinjz4IfmQhxoc88f1Cuy8Dm3vIm2HxQAvfmotRFvrOXmn8ssK8Cv2YNTLuf+pRB6erPZeRKkIrn9J0m6+IwA4zWurS5NBep1rxBGypQczU2KcyPDj/uxlyQTZdUSpU+JWzUVWJ6uPSUJVISINbb7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765908771; c=relaxed/simple; bh=lYVExBF5+cp599aAwqtd7rWmnEnxh6SJUY6zaJ+mC/c=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jFfl0VCVFHax3WeRty5iweuF4lD5D1YiKeMGWOh+Lh2I6gUcVtrHFmbVp2wGgcNy3kK2Bt5ACpbdM77H6BkR3TOQdFkihoPljAH2f8WPJiQyYUeP36Vf+XzlNUR8F6xglZuJphAfJwJHt/T6ytnIKGgISYfDvBuuFZL/jnomHks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=I5JAuXPV; arc=none smtp.client-ip=119.8.177.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="I5JAuXPV" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=c/i4yuWPRNaB87nSLMg+01ui8PpsrLcXHmWjY1b4M4w=; b=I5JAuXPV6pwPgJLEt4N5R3FO1CHuhBIZE2LHGDXqK1TX3P2+BxqrtcuY7NjuJp3HkqVxHE9Kd D6FxCs+7KTYjAm+HQ7fJAQBhmoFMW2fc51TiQP1MnlDRdGn+6QAr1c7WEWhBSzTAGOA8wvKo1H+ 4Gd0Mt/hkx1XmoJVrFnTBy8= Received: from frasgout.his.huawei.com (unknown [172.18.146.33]) by sinmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4dW4HP6jytz1vnwZ; Wed, 17 Dec 2025 01:51:29 +0800 (CST) Received: from mail.maildlp.com (unknown [172.18.224.83]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4dW4Jq4rtxzJ468v; Wed, 17 Dec 2025 01:52:43 +0800 (CST) Received: from dubpeml100005.china.huawei.com (unknown [7.214.146.113]) by mail.maildlp.com (Postfix) with ESMTPS id B8AE140086; Wed, 17 Dec 2025 01:53:11 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml100005.china.huawei.com (7.214.146.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 16 Dec 2025 17:53:10 +0000 Date: Tue, 16 Dec 2025 17:53:09 +0000 From: Jonathan Cameron To: Ryan Roberts CC: Will Deacon , Ard Biesheuvel , "Catalin Marinas" , Mark Rutland , Linus Torvalds , Oliver Upton , Marc Zyngier , Dev Jain , Linu Cherian , , Subject: Re: [PATCH v1 01/13] arm64: mm: Re-implement the __tlbi_level macro as a C function Message-ID: <20251216175309.00001935@huawei.com> In-Reply-To: <20251216144601.2106412-2-ryan.roberts@arm.com> References: <20251216144601.2106412-1-ryan.roberts@arm.com> <20251216144601.2106412-2-ryan.roberts@arm.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) 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-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To dubpeml100005.china.huawei.com (7.214.146.113) 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. > + } > + > + op(arg); > +} > > #define __tlbi_user_level(op, arg, level) do { \ > if (arm64_kernel_unmapped_at_el0()) \