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 C547EC5321E for ; Mon, 26 Aug 2024 15:57:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TOn0YrUR59pYUWtd8UPrtUwr6uiIbMat3ULK/343R8s=; b=08RVesNlEPh3ngXoZyRijofXMA A4QJcSoe3TnSLzNFmYhSlzTM7+kjwQYDLSmZ+XHjgBFxYBML+RNF/ay6FPU7S/5BKU1l9jctRyXs4 S/3/0f6exgckSlRp4abXpmSEHCGN+8aMzsW7ol/F+dQuZjK/eS8cMGZjOoQq8Nhdk25ovYQz3IJjE ljAB9goT9UBLD9hvE13d1MOOuQkPwCuKtTMzAksNAEpWRoAnVcL/gP4ot19fLyrx+l0vBuA+1ZpBA Z03yOXgQXTsRauZGMUekP3Bs/AKxzlu7oTM+g+jxTqymuHSvlX49QtvWkwoJdkmo/sTHQukWQGDbA Ns6pLtEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sic66-00000007uQe-3kvR; Mon, 26 Aug 2024 15:57:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sic58-00000007uBY-16ON for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 15:56:39 +0000 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 4C3E111FB; Mon, 26 Aug 2024 08:57:03 -0700 (PDT) Received: from [10.57.71.136] (unknown [10.57.71.136]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB4023F762; Mon, 26 Aug 2024 08:56:33 -0700 (PDT) Message-ID: Date: Mon, 26 Aug 2024 17:56:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 3/3] arm64: entry: Convert to generic entry To: Jinjie Ruan Cc: catalin.marinas@arm.com, will@kernel.org, oleg@redhat.com, tglx@linutronix.de, peterz@infradead.org, luto@kernel.org, kees@kernel.org, wad@chromium.org, rostedt@goodmis.org, arnd@arndb.de, ardb@kernel.org, broonie@kernel.org, mark.rutland@arm.com, rick.p.edgecombe@intel.com, leobras@redhat.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20240629085601.470241-1-ruanjinjie@huawei.com> <20240629085601.470241-4-ruanjinjie@huawei.com> <4f79f56a-4019-46eb-91dc-f137b714acb7@arm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_085638_426499_429C2A1A X-CRM114-Status: GOOD ( 22.98 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/08/2024 14:30, Jinjie Ruan wrote: > On 2024/8/20 19:43, Kevin Brodsky wrote: >> On 29/06/2024 10:56, Jinjie Ruan wrote: >>> Currently, x86, Riscv, Loongarch use the generic entry. Convert arm64 >>> to use the generic entry infrastructure from kernel/entry/*. The generic >>> entry makes maintainers' work easier and codes more elegant, which also >>> removed duplicate 150+ LOC. The changes are below: >>> >>> - Remove TIF_SYSCALL_* flag, _TIF_WORK_MASK, _TIF_SYSCALL_WORK >>> >>> - Remove syscall_trace_enter/exit() and use generic one. >>> >>> - Remove *enter_from/exit_to_kernel_mode(), and wrap with generic >>> irqentry_enter/exit(). >>> >>> - Remove *enter_from/exit_to_user_mode(), and wrap with generic >>> irqentry_enter_from/exit_to_user_mode(). >>> >>> - Remove arm64_enter/exit_nmi() and use generic irqentry_nmi_enter/exit(). >>> >>> - Remove PREEMPT_DYNAMIC code, as generic entry will do it ok by >>> implementing arch_irqentry_exit_need_resched(). >> This is looking good to me overall, moving to using the generic helpers >> is a clear improvement. I've tried my best to check that the new > Thank you very much for the review, It does make the code more clear. > >> implementation is functionally equivalent to the old. Ignoring additions >> in the generic code (such as additional instrumentation_{begin,end}() >> pairs or assertions), this seems to be the case, with one exception. The >> MTE operations are done in a slightly different order on entry: >> >> * mte_disable_tco_entry() was called *after* the generic lockdep/CT >> functions in __enter_from_user_mode(). It is now called before those >> generic operations - arch_enter_from_user_mode() called at the beginning >> of enter_from_user_mode(). > The most special for arm64 are these MTE operations, the comment for > __enter_from_kernel_mode() and __enter_from_user_mode() said: > > " Handle IRQ/context state management when entering from user/kernel > mode. Before this function is called it is not safe to call regular > kernel code " > > I guess it is the reason why mte_disable_tco_entry() was called *after* > the generic lockdep/CT functions, but the first version of commit > 38ddf7dafaeaf ("arm64: mte: avoid clearing PSTATE.TCO on entry unless > necessary") call it in arch/arm64/kernel/entry.S, so I think the order > is not so important. Good point, before that commit TCO was disabled before any generic exception code was run so changing the ordering of mte_disable_tco_entry() is unlikely to be a problem (the current implementation doesn't do anything complex). > >> * Similarly mte_disable_tco_entry() and mte_check_tfsr_entry() was >> called after the generic operations in enter_from_kernel_mode(), and >> they are now called after - arch_enter_from_kernel_mode() called at the >> beginning of irqentry_enter(). > This can be adjusted to be consistent. I wonder if moving mte_check_tfsr_entry() is as harmless as mte_disable_tco_entry(), because the former can cause a stack dump. Is that safe to do before the lockdep/RCU handling? I would guess so but would be good for someone to confirm. Kevin