From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C5E641D5ADC; Sat, 3 May 2025 10:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746266770; cv=none; b=sNkNu+DT1CwN5uSSzrW9VrATEoknIT37i4dmFCcU58Hm0Iv+KP3Mog2DFKisu+N/6LCtvispnpkRxUrV6wDJbhJtiP3ZzK6Au++VogQ85AmMqRZQfVEOI0vGqdZmI0ASzFr91roQzVAE0ldSycsyBiMQBRgjkn714nZNwG39IyM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746266770; c=relaxed/simple; bh=7/cQZqkxkHiOalA49M4Elh0cibV7uEPqheQC1nTN8Io=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nhrMxqD6CPEkWpg8Ne9AHA/CwOC5Ss7RtsBbH6msHeAGoqw8fb9cJVrsHAnXK0uaig6dfVMh5jNRmD0082PW+N4vM+G59ez5Uth6KqMDboF98t5eiewUZSsbMmbTScJVRvWSZQlYsBzkjQ/+edtbl+ys2XHew8Niss0g3hcfD88= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 046B7C4CEE3; Sat, 3 May 2025 10:06:05 +0000 (UTC) Date: Sat, 3 May 2025 11:06:03 +0100 From: Catalin Marinas To: Yeoreum Yun Cc: Ard Biesheuvel , will@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, broonie@kernel.org, maz@kernel.org, oliver.upton@linux.dev, frederic@kernel.org, joey.gouly@arm.com, james.morse@arm.com, hardevsinh.palaniya@siliconsignals.io, shameerali.kolothum.thodi@huawei.com, ryan.roberts@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH] arm64/cpufeature: annotate arm64_use_ng_mappings with ro_after_init to prevent wrong idmap generation Message-ID: References: <20250502145755.3751405-1-yeoreum.yun@arm.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, May 02, 2025 at 07:14:12PM +0100, Yeoreum Yun wrote: > > On Fri, May 02, 2025 at 06:41:33PM +0200, Ard Biesheuvel wrote: > > > Making arm64_use_ng_mappings __ro_after_init seems like a useful > > > change by itself, so I am not objecting to that. But we don't solve it > > > more fundamentally, please at least add a big fat comment why it is > > > important that the variable remains there. > > > > Maybe something like the section reference checker we use for __init - > > verify that the early C code does not refer anything in the BSS section. > > Maybe but it would be better to be checked at compile time (I don't > know it's possible) otherwise, early C code writer should check > mandatroy by calling is_kernel_bss_data() (not exist) for data it refers. This would be compile time (or rather final link time). See scripts/mod/modpost.c (the sectioncheck[] array) on how we check if, for example, a .text section references a .init one. We could move the whole pi code to its own section (e.g. .init.nommu.*) and add modpost checks for references to the bss or other sections. -- Catalin