* Re: [peterz-queue:x86/objtool 4/20] arch/x86/kernel/relocate_kernel_64.o: warning: objtool: .text+0x0: unreachable instruction
2020-03-22 8:02 [peterz-queue:x86/objtool 4/20] arch/x86/kernel/relocate_kernel_64.o: warning: objtool: .text+0x0: unreachable instruction kbuild test robot
@ 2020-03-22 10:39 ` Peter Zijlstra
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2020-03-22 10:39 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 1871 bytes --]
On Sun, Mar 22, 2020 at 04:02:21PM +0800, kbuild test robot wrote:
> All warnings (new ones prefixed by >>):
>
> >> arch/x86/kernel/relocate_kernel_64.o: warning: objtool: .text+0x0: unreachable instruction
Josh, the below patch generates this warning. It actually does get
there:
/* jump to identity mapped page */
addq $(identity_mapped - relocate_kernel), %r8
pushq %r8
ret
But I don't blame objtool for not actually grokking that. Any idea what
the best way to fix this would be? The annotate_reachable() annotation
doesn't seem to work...
SYM_CODE_START_NOALIGN(relocate_kernel)
+ 999:
+ .pushsection .discard.reachable
+ .long 999b - .
+ .popsection
/*
* %rdi indirection_page
* %rsi page_list
---
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -32,7 +32,6 @@ KASAN_SANITIZE_paravirt.o := n
# by several compilation units. To be safe, disable all instrumentation.
KCSAN_SANITIZE := n
-OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_test_nx.o := y
OBJECT_FILES_NON_STANDARD_paravirt_patch.o := y
--- a/arch/x86/kernel/relocate_kernel_64.S
+++ b/arch/x86/kernel/relocate_kernel_64.S
@@ -9,6 +9,7 @@
#include <asm/kexec.h>
#include <asm/processor-flags.h>
#include <asm/pgtable_types.h>
+#include <asm/nospec-branch.h>
/*
* Must be relocatable PIC code callable as a C function
@@ -192,14 +193,12 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_ma
1:
popq %rdx
leaq PAGE_SIZE(%r10), %rsp
+ ANNOTATE_RETPOLINE_SAFE
call *%rdx
/* get the re-entry point of the peer system */
movq 0(%rsp), %rbp
- call 1f
-1:
- popq %r8
- subq $(1b - relocate_kernel), %r8
+ leaq relocate_kernel(%rip), %r8
movq CP_PA_SWAP_PAGE(%r8), %r10
movq CP_PA_BACKUP_PAGES_MAP(%r8), %rdi
movq CP_PA_TABLE_PAGE(%r8), %rax
^ permalink raw reply [flat|nested] 2+ messages in thread