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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8E6AD24459 for ; Thu, 10 Oct 2024 22:54:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EFF56B007B; Thu, 10 Oct 2024 18:54:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2785E6B0082; Thu, 10 Oct 2024 18:54:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F2DF6B0083; Thu, 10 Oct 2024 18:54:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E198C6B007B for ; Thu, 10 Oct 2024 18:54:20 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3C05BC07C3 for ; Thu, 10 Oct 2024 22:54:16 +0000 (UTC) X-FDA: 82659197880.13.6D08339 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 0ECD440005 for ; Thu, 10 Oct 2024 22:54:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QiUIOLSB; spf=pass (imf17.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728600675; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=CtnQW9M1qfhCyoSIRxyhjm78v3iEbXx5vUa6szTpCQ0=; b=J5rxe/0vqaeZg6qnCljgS+t/OtJRRlMdgIAhF2hBYGtmoCNYNKnDLOFDwB7CtflvYOTx2a 2Ej0MrB9pjVKkFq5cE5SVWbUJxATnJHQ+01PzHVl6sRge5Uh6vmH800ZXe3rmNDXv/Tztf +1P0WKybAxw3aMzMRFeoKzxg4bykwdA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QiUIOLSB; spf=pass (imf17.hostedemail.com: domain of nathan@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728600675; a=rsa-sha256; cv=none; b=QR9qburoFWYOm4hXmT7lHbwldz7v17o3jwMI7lLMIOwu6NEdnk7SPDvtDbSbTmm2xP9jGu HoYGWtdUU5CM/GCG+s+cp9j1A7cWJ8DsPq32D+WjKAse2DZ7qnG/sHi/Ipo+SYN87Y3SlO MaUfZnr89WIASyFoJZwHYwVaRy7UB98= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 072705C5FDE; Thu, 10 Oct 2024 22:54:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7BFC4CEC5; Thu, 10 Oct 2024 22:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728600856; bh=dRFHj5mtH0xn8PBj2ZbOuI6o6u0ly0QH1iws5fctk8A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QiUIOLSBcasoVYYND8KdWz7eQh/+0boOgNRGeOQlhf5jvA1/EBnMYKjn5VICJ3eAY cnnu9shlCLMfTHHTHra7MnZ0rLJlXd0Hph0c0PBZ21X9KTVg4eVdzFCTR7+dIRdltD hxCWp0qmt+fIbgTEcIZSFHp2Q6iE2wK9yyyZ4vyAJOkCE63MHkbL8C+vAlgxvUIB86 jOXbNmyf7S3aQkYS+MyXLrzvy5GjYypHqnc1WER+qWs986tCcEJrL1436xfNVNVaY8 SuEhjakzc9ZUyRU5YtUSasIp4EiqD3HrJhbPDpQFeVHrdwLEF3yFgOYnlD+BEfVYYI t/83JFWrskzLQ== Date: Thu, 10 Oct 2024 15:54:11 -0700 From: Nathan Chancellor To: Mike Rapoport Cc: Andrew Morton , Andreas Larsson , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Brian Cain , Catalin Marinas , Christoph Hellwig , Christophe Leroy , Dave Hansen , Dinh Nguyen , Geert Uytterhoeven , Guo Ren , Helge Deller , Huacai Chen , Ingo Molnar , Johannes Berg , John Paul Adrian Glaubitz , Kent Overstreet , "Liam R. Howlett" , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Matt Turner , Max Filippov , Michael Ellerman , Michal Simek , Oleg Nesterov , Palmer Dabbelt , Peter Zijlstra , Richard Weinberger , Russell King , Song Liu , Stafford Horne , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , Uladzislau Rezki , Vineet Gupta , Will Deacon , bpf@vger.kernel.org, linux-alpha@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-trace-kernel@vger.kernel.org, linux-um@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v5 6/8] x86/module: perpare module loading for ROX allocations of text Message-ID: <20241010225411.GA922684@thelio-3990X> References: <20241009180816.83591-1-rppt@kernel.org> <20241009180816.83591-7-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241009180816.83591-7-rppt@kernel.org> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0ECD440005 X-Stat-Signature: uio9ywekibwfih47ku6up3ibuhon9xap X-Rspam-User: X-HE-Tag: 1728600856-762790 X-HE-Meta: U2FsdGVkX1/Ib9ACAHR8CHV5rLKBYDIDDDW1MfntzPWIyzwuhOZA494eRjTJS6VABe6camAaDzGbQMPOOZOTYSqk/f8X+RgatND8NeRfVu3wrhml05G5qsEqkgv+VsJ1Qw0qo81xtT/iZDn2YwKH4IhnHt2eDO3kfDkVj74iD6mEPPwV+FkzaYqE8hPusbSMYBW8M5nwPqJXhyVm3TCwoTqKd0fGr1lGgoSkKh5Oe5f2i0hlg3gDtzpyydAMwPUfI2ofoOaJq/eVZivIbsVMoYjiAY9f8dSDUVYLDSSy7O4dCDRin342VSfTbgFqbl/brBlHqYvv4zqflEGmHE+Uu+UR4zZm4pAZy1Dizcre8+xPRtI1e2uQA6aJYaXnSti+5hTBjkCUvevwzXtW5rP5R+2VnX7IXYJ54gaMf1wCnYXZo4WWgB/cfI7ZoTWIDU/Crdf9uYmD9eEwx8PVOocONCwnw2byfynFzHdkpfi9OftPgA8qO0m9LaR6mXetpXbDIpF6uH7ELBrBRQM89OF2IxTLAV8+4jQPS3hRcZOP3ytbbxmzOTXlNajGGSintbaj7ZFZD1PLuXTRRo/TmP0gC1EQ+wqs8KM8NOqD9xPv9zBb4LX2NBNrdd6Y8eo2jlY1+0PuBj0PC19QmMqTJP8eKoTbz7ptmecc5M4HClsNkhKBN6iBT5dwsTyyxyok+iK1FJD6AR4EzJPwB93PEJC7skmOzRY//CcpB4XiGsk9FedzAWuU5dCra6to6UEtS+LO/063a6yJT0r6b5bsEqoTaj5DG1z12+SCPykUUJcfs3v1YuKAAT9NkD9nWQfmzwB4riZ75a1rxZ9tM9uRnWIE9yq3jeDLEDNxM2K1I5j24fFJg92Wl/D+kGtYYN1Xj2uqwwPqNzaAi1t7ID9O7yW7LdCNkZ57eg1McePn+UftCjngHG2sbY3mCepMSTGttmu0O9Aj5mStWaE8Eif4Sy1 ybn8RVCL RMEEMFrNUbkipYtcI2mO+r4oWySvSgZcI1ZWOouiUHX3iPC/FSEHw8SBzgf8ikGyLPTTAzTEbwSmz/DwkLux9g46Y+U7nTLwD5hRuMHT5R2fCLvlW61WLqdBGO3bUCJefvBiFVJvYZVm9J7GsiLPAgpfq2RVcp1zAFQEaGP6VJhGM43N3a9a+aCK3s1ihoyf/a6CP3F8tYlI4YeUZtGrUyJJjlkuahSsuaQp8IFwo+XyC6TkpS+iaLUbw9tVaqDwCSFDDVu/Gyu1qlfM3nwqKhQ/38hbESmC3jcuxA0TIYb/aisRNb7Fdksw097ltFSyPqF3W2bdMZ110yZtE+SZg8SKNBg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Mike, On Wed, Oct 09, 2024 at 09:08:14PM +0300, Mike Rapoport wrote: > From: "Mike Rapoport (Microsoft)" > > When module text memory will be allocated with ROX permissions, the > memory at the actual address where the module will live will contain > invalid instructions and there will be a writable copy that contains the > actual module code. > > Update relocations and alternatives patching to deal with it. > > Signed-off-by: Mike Rapoport (Microsoft) I bisected a boot failure that I see with CONFIG_CFI_CLANG enabled to this change as commit be712757cabd ("x86/module: perpare module loading for ROX allocations of text") in -next. $ echo CONFIG_CFI_CLANG=y >arch/x86/configs/cfi.config $ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 mrproper defconfig cfi.config bzImage $ curl -LSs https://github.com/ClangBuiltLinux/boot-utils/releases/download/20230707-182910/x86_64-rootfs.cpio.zst | zstd -d >rootfs.cpio $ qemu-system-x86_64 \ -display none \ -nodefaults \ -M q35 \ -d unimp,guest_errors \ -append 'console=ttyS0 earlycon=uart8250,io,0x3f8' \ -kernel arch/x86/boot/bzImage \ -initrd rootfs.cpio \ -cpu host \ -enable-kvm \ -m 512m \ -smp 8 \ -serial mon:stdio [ 0.000000] Linux version 6.12.0-rc2-00140-gbe712757cabd (nathan@n3-xlarge-x86) (ClangBuiltLinux clang version 19.1.0 (https://github.com/llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4), ClangBuiltLinux LLD 19.1.0 (https://github.com/llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)) #1 SMP PREEMPT_DYNAMIC Thu Oct 10 22:42:57 UTC 2024 ... [ 0.092204] Speculative Store Bypass: Mitigation: Speculative Store Bypass disabled via prctl [ 0.093207] TAA: Mitigation: TSX disabled [ 0.093711] MMIO Stale Data: Mitigation: Clear CPU buffers [ 0.094228] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' [ 0.095203] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' [ 0.096203] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' [ 0.097203] x86/fpu: Supporting XSAVE feature 0x020: 'AVX-512 opmask' [ 0.098003] x86/fpu: Supporting XSAVE feature 0x040: 'AVX-512 Hi256' [ 0.098203] x86/fpu: Supporting XSAVE feature 0x080: 'AVX-512 ZMM_Hi256' [ 0.099203] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers' [ 0.100204] x86/fpu: xstate_offset[2]: 576, xstate_sizes[2]: 256 [ 0.101204] x86/fpu: xstate_offset[5]: 832, xstate_sizes[5]: 64 [ 0.102203] x86/fpu: xstate_offset[6]: 896, xstate_sizes[6]: 512 [ 0.103204] x86/fpu: xstate_offset[7]: 1408, xstate_sizes[7]: 1024 [ 0.104051] x86/fpu: xstate_offset[9]: 2432, xstate_sizes[9]: 8 [ 0.104204] x86/fpu: Enabled xstate features 0x2e7, context size is 2440 bytes, using 'compacted' format. then nothing after that. Boot is successful if CFI is not enabled (the initrd will just shutdown the machine after printing the version string). If there is any further information I can provide or patches I can test, I am more than happy to do so. Cheers, Nathan