linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Sedat Dilek <sedat.dilek@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	clang-built-linux@googlegroups.com,
	Miroslav Benes <mbenes@suse.cz>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Juergen Gross <jgross@suse.com>
Subject: [PATCH 13/21] x86/xen: Support objtool validation in xen-asm.S
Date: Thu, 14 Jan 2021 13:40:09 -0600	[thread overview]
Message-ID: <77629463ea258e47d8d53bc8947da24dd2923931.1610652862.git.jpoimboe@redhat.com> (raw)
In-Reply-To: <cover.1610652862.git.jpoimboe@redhat.com>

The OBJECT_FILES_NON_STANDARD annotation is used to tell objtool to
ignore a file.  File-level ignores won't work when validating vmlinux.o.

Tweak the ELF metadata and unwind hints to allow objtool to follow the
code.

Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
---
 arch/x86/xen/Makefile  |  1 -
 arch/x86/xen/xen-asm.S | 29 +++++++++++++++++++----------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index fc5c5ba4aacb..40b5779fce21 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -1,5 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-OBJECT_FILES_NON_STANDARD_xen-asm.o := y
 
 ifdef CONFIG_FUNCTION_TRACER
 # Do not profile debug and lowlevel utilities
diff --git a/arch/x86/xen/xen-asm.S b/arch/x86/xen/xen-asm.S
index 1cb0e84b9161..a05e80b552c0 100644
--- a/arch/x86/xen/xen-asm.S
+++ b/arch/x86/xen/xen-asm.S
@@ -14,6 +14,7 @@
 #include <asm/thread_info.h>
 #include <asm/asm.h>
 #include <asm/frame.h>
+#include <asm/unwind_hints.h>
 
 #include <xen/interface/xen.h>
 
@@ -146,6 +147,7 @@ SYM_FUNC_END(xen_read_cr2_direct);
 
 .macro xen_pv_trap name
 SYM_CODE_START(xen_\name)
+	UNWIND_HINT_EMPTY
 	pop %rcx
 	pop %r11
 	jmp  \name
@@ -184,6 +186,7 @@ xen_pv_trap asm_exc_xen_hypervisor_callback
 SYM_CODE_START(xen_early_idt_handler_array)
 	i = 0
 	.rept NUM_EXCEPTION_VECTORS
+	UNWIND_HINT_EMPTY
 	pop %rcx
 	pop %r11
 	jmp early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE
@@ -210,11 +213,13 @@ hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
  * rsp->rax		}
  */
 SYM_CODE_START(xen_iret)
+	UNWIND_HINT_EMPTY
 	pushq $0
 	jmp hypercall_iret
 SYM_CODE_END(xen_iret)
 
 SYM_CODE_START(xen_sysret64)
+	UNWIND_HINT_EMPTY
 	/*
 	 * We're already on the usermode stack at this point, but
 	 * still with the kernel gs, so we can easily switch back.
@@ -250,7 +255,8 @@ SYM_CODE_END(xen_sysret64)
  */
 
 /* Normal 64-bit system call target */
-SYM_FUNC_START(xen_syscall_target)
+SYM_CODE_START(xen_syscall_target)
+	UNWIND_HINT_EMPTY
 	popq %rcx
 	popq %r11
 
@@ -263,12 +269,13 @@ SYM_FUNC_START(xen_syscall_target)
 	movq $__USER_CS, 1*8(%rsp)
 
 	jmp entry_SYSCALL_64_after_hwframe
-SYM_FUNC_END(xen_syscall_target)
+SYM_CODE_END(xen_syscall_target)
 
 #ifdef CONFIG_IA32_EMULATION
 
 /* 32-bit compat syscall target */
-SYM_FUNC_START(xen_syscall32_target)
+SYM_CODE_START(xen_syscall32_target)
+	UNWIND_HINT_EMPTY
 	popq %rcx
 	popq %r11
 
@@ -281,10 +288,11 @@ SYM_FUNC_START(xen_syscall32_target)
 	movq $__USER32_CS, 1*8(%rsp)
 
 	jmp entry_SYSCALL_compat_after_hwframe
-SYM_FUNC_END(xen_syscall32_target)
+SYM_CODE_END(xen_syscall32_target)
 
 /* 32-bit compat sysenter target */
-SYM_FUNC_START(xen_sysenter_target)
+SYM_CODE_START(xen_sysenter_target)
+	UNWIND_HINT_EMPTY
 	/*
 	 * NB: Xen is polite and clears TF from EFLAGS for us.  This means
 	 * that we don't need to guard against single step exceptions here.
@@ -301,17 +309,18 @@ SYM_FUNC_START(xen_sysenter_target)
 	movq $__USER32_CS, 1*8(%rsp)
 
 	jmp entry_SYSENTER_compat_after_hwframe
-SYM_FUNC_END(xen_sysenter_target)
+SYM_CODE_END(xen_sysenter_target)
 
 #else /* !CONFIG_IA32_EMULATION */
 
-SYM_FUNC_START_ALIAS(xen_syscall32_target)
-SYM_FUNC_START(xen_sysenter_target)
+SYM_CODE_START(xen_syscall32_target)
+SYM_CODE_START(xen_sysenter_target)
+	UNWIND_HINT_EMPTY
 	lea 16(%rsp), %rsp	/* strip %rcx, %r11 */
 	mov $-ENOSYS, %rax
 	pushq $0
 	jmp hypercall_iret
-SYM_FUNC_END(xen_sysenter_target)
-SYM_FUNC_END_ALIAS(xen_syscall32_target)
+SYM_CODE_END(xen_sysenter_target)
+SYM_CODE_END(xen_syscall32_target)
 
 #endif	/* CONFIG_IA32_EMULATION */
-- 
2.29.2


  parent reply	other threads:[~2021-01-14 19:43 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-14 19:39 [PATCH 00/21] objtool: vmlinux.o and CLANG LTO support Josh Poimboeuf
2021-01-14 19:39 ` [PATCH 01/21] objtool: Fix seg fault in BT_FUNC() with fake jump Josh Poimboeuf
2021-01-14 20:04   ` Josh Poimboeuf
2021-01-14 19:39 ` [PATCH 02/21] objtool: Fix error handling for STD/CLD warnings Josh Poimboeuf
2021-01-14 19:39 ` [PATCH 03/21] objtool: Fix retpoline detection in asm code Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 04/21] objtool: Fix ".cold" section suffix check for newer versions of GCC Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 05/21] objtool: Support retpoline jump detection for vmlinux.o Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 06/21] x86/ftrace: Add UNWIND_HINT_FUNC annotation for ftrace_stub Josh Poimboeuf
2021-01-14 20:42   ` Steven Rostedt
2021-01-14 19:40 ` [PATCH 07/21] objtool: Assume only ELF functions do sibling calls Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 08/21] objtool: Add asm version of STACK_FRAME_NON_STANDARD Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 09/21] objtool: Combine UNWIND_HINT_RET_OFFSET and UNWIND_HINT_FUNC Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 10/21] objtool: Add xen_start_kernel() to noreturn list Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 11/21] objtool: Move unsuffixed symbol conversion to a helper function Josh Poimboeuf
2021-01-14 20:55   ` [PATCH v1.1 " Josh Poimboeuf
2021-01-14 21:30     ` Sedat Dilek
2021-01-14 19:40 ` [PATCH 12/21] objtool: Add CONFIG_CFI_CLANG support Josh Poimboeuf
2021-01-14 20:49   ` Sami Tolvanen
2021-01-14 20:52     ` Josh Poimboeuf
2021-01-14 20:56   ` [PATCH v1.1 " Josh Poimboeuf
2021-01-14 19:40 ` Josh Poimboeuf [this message]
2021-01-15  0:31   ` [PATCH 13/21] x86/xen: Support objtool validation in xen-asm.S boris.ostrovsky
2021-01-14 19:40 ` [PATCH 14/21] x86/xen: Support objtool vmlinux.o validation in xen-head.S Josh Poimboeuf
2021-01-15  0:32   ` boris.ostrovsky
2021-01-15  5:17   ` Jürgen Groß
2021-01-15 19:46     ` Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 15/21] x86/xen/pvh: Convert indirect jump to retpoline Josh Poimboeuf
2021-01-15  0:33   ` boris.ostrovsky
2021-01-15  5:24   ` Jürgen Groß
2021-01-15 15:08     ` Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 16/21] x86/ftrace: Support objtool vmlinux.o validation in ftrace_64.S Josh Poimboeuf
2021-01-14 20:42   ` Steven Rostedt
2021-01-14 19:40 ` [PATCH 17/21] x86/acpi: Convert indirect jump to retpoline Josh Poimboeuf
2021-01-14 22:59   ` Andrew Cooper
2021-01-14 23:47     ` Josh Poimboeuf
2021-01-15  0:54       ` Andrew Cooper
2021-01-14 19:40 ` [PATCH 18/21] x86/acpi: Support objtool validation in wakeup_64.S Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 19/21] x86/power: Convert indirect jumps to retpolines Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 20/21] x86/power: Move restore_registers() to top of the file Josh Poimboeuf
2021-01-14 19:40 ` [PATCH 21/21] x86/power: Support objtool validation in hibernate_asm_64.S Josh Poimboeuf
2021-01-15  0:41 ` [PATCH 00/21] objtool: vmlinux.o and CLANG LTO support Sami Tolvanen
2021-01-15  0:49   ` Nick Desaulniers
2021-01-15 19:52   ` Josh Poimboeuf
2021-01-15 20:19     ` Sedat Dilek
2021-01-15 20:59       ` Josh Poimboeuf
2021-01-15 21:01         ` Sedat Dilek
2021-01-18 17:22   ` Josh Poimboeuf
2021-01-19 21:29     ` Nick Desaulniers
2021-01-20 15:37       ` Josh Poimboeuf
2021-01-15  4:51 ` Sedat Dilek
2021-01-15  5:18   ` Sedat Dilek
2021-01-15 15:30   ` Sedat Dilek
2021-01-15 18:54     ` Sedat Dilek
2021-01-15 19:28       ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77629463ea258e47d8d53bc8947da24dd2923931.1610652862.git.jpoimboe@redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=jgross@suse.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=samitolvanen@google.com \
    --cc=sedat.dilek@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).