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 A490ED1CA3B for ; Tue, 5 Nov 2024 07:03:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QyvZ5IlDQT7L74fwSI+cwWMg50FfR0nSMaM+QfdvvWI=; b=dJukcSaQ1aYKNV 2NyhQGjuNi/wpvsJUT+XRn3hgpH3ZBHbdd2ZmT1EbJtfBk9f4zOO3fG7u4F4/U/iwe/sJO7H8INBm +sv2CuqAqC1tZ/H8E4w2w5QeupDk/xkSzUQdVtUPI3GcW29GP9rFtOIkz8p9NxFaQmd3rhezwEHB4 dtxxTDtAyjhk7/6cAjHlblP/+iPE8O6kmHh8mhrbiEYHga6FDj/+OjBoFlHXNm4aTEjIn3nxC0ndI e+39Q5nlCI8Vz8aGHN+s0gx8O2EspkRduRWZz63stQalUzT5KL2Ny1vv3ULBFj2xWyfxl7MjsfEZK 2vqeHVDADmccn6ZlfI1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8Dae-0000000G8TX-1YMB; Tue, 05 Nov 2024 07:03:00 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8Daa-0000000G8Qv-0FZj; Tue, 05 Nov 2024 07:02:57 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id DE148A42167; Tue, 5 Nov 2024 07:00:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4B12C4CECF; Tue, 5 Nov 2024 07:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730790174; bh=vfcX72EWl1PlKyFBzjhHz5V71yaLAfzK3VjVgomZL4Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=i3dpbmwHLfd+qUmJoaWeTGPHb10DC+M0kf+DMEykGWoYpGOuSUDviaUCAAx4zIAfi my4z1l/oyVoPrY5WEhvGAqrSv0MLPuXbzVIKUoMd0jh8oEVUCEONnRV4s7PDepCIp9 ZD54y4ohFGVDY1Cs7nPdmpyfCNtvqUqW5KJ/Ch+xipF5ZFMCAivKT3JR6Xd9V1a/4G LvZ1wHQ1rlIUNyplCl+fPkOtsT/XeAFLJAPXe+EdvajpWUHCrgFIHiD89oCp0/Bkx4 xYtH7/sknC5+POJtdvm/YMmFy0WRYObll2kMIURKDi3pF/30ytxQP7HSq81EZrmTXO namiYtOl86+Aw== Date: Tue, 5 Nov 2024 09:02:26 +0200 From: Mike Rapoport To: Nathan Chancellor Cc: Andrew Morton , Luis Chamberlain , 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" , 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 , Suren Baghdasaryan , 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 v7 6/8] x86/module: prepare module loading for ROX allocations of text Message-ID: References: <20241023162711.2579610-1-rppt@kernel.org> <20241023162711.2579610-7-rppt@kernel.org> <20241104232741.GA3843610@thelio-3990X> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20241104232741.GA3843610@thelio-3990X> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_230256_232995_2BAA6EBE X-CRM114-Status: GOOD ( 35.53 ) X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+linux-snps-arc=archiver.kernel.org@lists.infradead.org Hi Nathan, On Mon, Nov 04, 2024 at 04:27:41PM -0700, Nathan Chancellor wrote: > Hi Mike, > > On Wed, Oct 23, 2024 at 07:27:09PM +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) > > Tested-by: kdevops > > Hopefully the last time you have to hear from me, as I am only > experiencing issues with only one of my test machines at this point and > it is my only machine that supports IBT, so it seems to point to > something specific with the IBT part of the FineIBT support. I notice > either a boot hang or an almost immediate reboot (triple fault?). I > guess this is how I missed reporting this earlier, as my machine was > falling back to the default distribution kernel after the restart and I > did not notice I was not actually testing a -next kernel. > > Checking out the version of this change that is in next-20241104, commit > 7ca6ed09db62 ("x86/module: prepare module loading for ROX allocations of > text"), it boots with either 'cfi=off' or 'cfi=kcfi' but it exhibits the > issues noted above with 'cfi=fineibt'. At the immediate parent, commit > b575d981092f ("arch: introduce set_direct_map_valid_noflush()"), all > three combinations boot fine. > > $ uname -r; tr ' ' '\n' > 6.12.0-rc5-debug-00214-g7ca6ed09db62 > cfi=kcfi > > 6.12.0-rc5-debug-00214-g7ca6ed09db62 > cfi=off > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=fineibt > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=kcfi > > 6.12.0-rc5-debug-00213-gb575d981092f > cfi=off > > I do not think this machine has an accessible serial port and I do not > think IBT virtualization is supported via either KVM or TCG in QEMU, so > I am not sure how to get more information about what is going on here. I > wanted to try reverting these changes on top of next-20241104 but there > was a non-trivial conflict in mm/execmem.c due to some changes on top, > so I just tested in the mm history. > > If there is any other information I can provide or patches I can test, I > am more than happy to do so. Yes, please :) There's a silly mistake in cfi_rewrite_endbr() in that commit, the patch below should fix it. Can you please test? diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 3407efc26528..243843e44e89 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -1241,7 +1241,7 @@ static void cfi_rewrite_endbr(s32 *start, s32 *end, struct module *mod) void *addr = (void *)s + *s; void *wr_addr = module_writable_address(mod, addr); - poison_endbr(addr+16, wr_addr, false); + poison_endbr(addr + 16, wr_addr + 16, false); } } > Cheers, > Nathan -- Sincerely yours, Mike. _______________________________________________ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc