Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2377546rda; Wed, 25 Oct 2023 00:24:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqnO0RqY2o/s/5KLOD8YH9pklOVmwtt/XoKVyWqo/M9NqCyTp84DEAguGSOMbZJgC8RScw X-Received: by 2002:a25:e80f:0:b0:d9b:6c9d:e6a with SMTP id k15-20020a25e80f000000b00d9b6c9d0e6amr12845719ybd.0.1698218640043; Wed, 25 Oct 2023 00:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698218640; cv=none; d=google.com; s=arc-20160816; b=r/o81dRym7Rc0JeiHXWBqYFSpDol7Lye1hhAsWtFx7vhxSMExxfSn/gomdLGl06Jvi BzYXWaX3ySVcyW+xdEmgQiyI93qf39pbtwm/Wu72WLAeZPGhR1+rShCY9zeAOBdE8Ll/ oNJW4u5dFMIHzkkHQ32R/vTUk74Xptx7WCoK3A1pajPqPpE8lAHM4YJus25rCV6AjUJk hEtkKQFK8j3s4BNqkEA1mEhxj5/tGhIxjuclizM2MpbjqccSv56NsN22g/fZ/kxnlYcE aFVw7fFianb1fpa6sfnk9ISn9Kf/CJiEorlou5KVwx1ZUodztpU8ZYfjIVO9RiFkoc55 T15g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oJ5H5HuNeUS44YCodtmW5YmlPErriupXrPKUq6nl7ds=; fh=QP64bVDKm+Z2RBpHBeJD0gaHXh88HleYN/fzKB+1CBI=; b=Mdvv+T3tai6kqdWPtnt5smMfNXfSD6jnqlcTBR0rVVtolQnnogIN2ZSj+e30QKZYv/ d4dB7L2C2VDxED2zi4nuJRMNWiWg8XfGx2uRvjqx597fSXq4dmwbrlZ54M+atKeHubcE EawXrFCO/zBczerX+yioXKanJCpfSPyJkimP5Y1AxkBcieN7w7zVDuzdOAQaY4FyArJ8 oN/OkxQ8lZOKkIG4NPvKSBP5QnXJeDBIyG9sGo+qZW/lERqcWw1IjoMM0tK5GRDJ6dn8 9MJwfEaemiDrS8KRBF25dPOFdxKc8TuueWgM8CSGFOcIVIZy5hA/lZjnCyt0Las5DMWw lgCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=b+BSOUSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w20-20020a25ac14000000b00d9caba4deb1si9484223ybi.23.2023.10.25.00.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 00:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=b+BSOUSU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1B8D1803F63F; Wed, 25 Oct 2023 00:23:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232721AbjJYHXm (ORCPT + 99 others); Wed, 25 Oct 2023 03:23:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbjJYHXk (ORCPT ); Wed, 25 Oct 2023 03:23:40 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8E8A185; Wed, 25 Oct 2023 00:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oJ5H5HuNeUS44YCodtmW5YmlPErriupXrPKUq6nl7ds=; b=b+BSOUSUQZ5rSGSPcCKM8aHQzz mgUmSZOyVtiTAQ6g6Vo0bJpvEV1Ybl3fTSfU/lwrBibTCBcGsWdDUyPHzGfdYi4Hgo1FQYs01XPJN eCJZ5/cBBQRNAVLz/uAPJHn0NKXaLdyBaaw0Jufj6txzi+dD2HaoDqnRgMMz2a8KjO6W1k37RfWZW WbKhNqdZiB/448MUC7WbrFkBLFHj4oBll1nDDgiVFZexO+HdVa/igEoHvMOE0sNz37Sh6gTjF9b5Y QgNsACZWTW/stWlCMJpowpKI4TJGieizTwEbnwxrbfzDVhHXSbNXGSNAqTU6B99RxkmUmtgg1V39l 9K0hqNcw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qvYEC-00GBPR-0G; Wed, 25 Oct 2023 07:22:56 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id B84DC30047C; Wed, 25 Oct 2023 09:22:55 +0200 (CEST) Date: Wed, 25 Oct 2023 09:22:55 +0200 From: Peter Zijlstra To: Pawan Gupta Cc: Andrew Cooper , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Josh Poimboeuf , Andy Lutomirski , Jonathan Corbet , Sean Christopherson , Paolo Bonzini , tony.luck@intel.com, ak@linux.intel.com, tim.c.chen@linux.intel.com, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kvm@vger.kernel.org, Alyssa Milburn , Daniel Sneddon , antonio.gomez.iglesias@linux.intel.com, Alyssa Milburn Subject: Re: [RESEND][PATCH 1/6] x86/bugs: Add asm helpers for executing VERW Message-ID: <20231025072255.GA37471@noisy.programming.kicks-ass.net> References: <20231020-delay-verw-v1-0-cff54096326d@linux.intel.com> <20231020-delay-verw-v1-1-cff54096326d@linux.intel.com> <20231025062818.7kaerqklaut7dg5r@desk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231025062818.7kaerqklaut7dg5r@desk> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 25 Oct 2023 00:23:57 -0700 (PDT) On Tue, Oct 24, 2023 at 11:28:18PM -0700, Pawan Gupta wrote: > With .text.entry section I am getting getting below warnings and an > error: > > ----------------------------------------------------------------- > LD vmlinux.o > vmlinux.o: warning: objtool: .text.entry+0x0: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x40: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x80: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0xc0: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x100: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x140: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x180: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x1c0: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x200: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x240: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x280: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x2c0: unreachable instruction > vmlinux.o: warning: objtool: .text.entry+0x300: unreachable instruction > vmlinux.o: warning: objtool: .altinstr_replacement+0x2c: relocation to !ENDBR: .text.entry+0x0 > vmlinux.o: warning: objtool: .altinstr_replacement+0x1c4: relocation to !ENDBR: .text.entry+0x0 > vmlinux.o: warning: objtool: .altinstr_replacement+0x1d0: relocation to !ENDBR: .text.entry+0x0 > vmlinux.o: warning: objtool: .altinstr_replacement+0x2d2: relocation to !ENDBR: .text.entry+0x80 > vmlinux.o: warning: objtool: .altinstr_replacement+0x5d5: relocation to !ENDBR: .text.entry+0xc0 > OBJCOPY modules.builtin.modinfo > GEN modules.builtin > MODPOST vmlinux.symvers > UPD include/generated/utsversion.h > CC init/version-timestamp.o > LD .tmp_vmlinux.kallsyms1 > ld: error: unplaced orphan section `.text.entry' from `vmlinux.o' > make[2]: *** [scripts/Makefile.vmlinux:36: vmlinux] Error 1 > ----------------------------------------------------------------- > > ... because my config has CONFIG_LD_ORPHAN_WARN_LEVEL="error" and > objtool needs to be told about this entry. > > Do you think its worth fighting these warnings and error, or simply use > .rodata section for verw memory operand? I'm thinking you need to at the very least stay in a section that's actually still mapped with PTI :-) .entry.text is the only thing that is reliably mapped with PTI (IIRC), some configs also get a chunk of the kernel image, but not all. Something like the below should do I suppose. --- arch/x86/entry/entry.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/entry/entry.S b/arch/x86/entry/entry.S index bfb7bcb362bc..9eb2b532c92a 100644 --- a/arch/x86/entry/entry.S +++ b/arch/x86/entry/entry.S @@ -6,6 +6,8 @@ #include #include #include +#include +#include .pushsection .noinstr.text, "ax" @@ -20,3 +22,16 @@ SYM_FUNC_END(entry_ibpb) EXPORT_SYMBOL_GPL(entry_ibpb); .popsection + +.pushsection .entry.text, "ax" + +.align 64 +SYM_CODE_START_NOALIGN(mds_verw_sel) + UNWIND_HINT_UNDEFINED + ANNOTATE_NOENDBR +1: + .word __KERNEL_DS + .skip 64 - (. - 1b), 0xcc +SYM_CODE_END(mds_verw_sel); + +.popsection