From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============3342850509033534555==" MIME-Version: 1.0 From: Peter Zijlstra To: kbuild-all@lists.01.org Subject: Re: [peterz-queue:x86/objtool 4/20] arch/x86/kernel/relocate_kernel_64.o: warning: objtool: .text+0x0: unreachable instruction Date: Sun, 22 Mar 2020 11:39:44 +0100 Message-ID: <20200322103944.GG2452@worktop.programming.kicks-ass.net> In-Reply-To: <202003221657.gVRW0vRM%lkp@intel.com> List-Id: --===============3342850509033534555== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: unr= eachable 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 :=3D n # by several compilation units. To be safe, disable all instrumentation. KCSAN_SANITIZE :=3D n = -OBJECT_FILES_NON_STANDARD_relocate_kernel_$(BITS).o :=3D y OBJECT_FILES_NON_STANDARD_test_nx.o :=3D y OBJECT_FILES_NON_STANDARD_paravirt_patch.o :=3D y = --- a/arch/x86/kernel/relocate_kernel_64.S +++ b/arch/x86/kernel/relocate_kernel_64.S @@ -9,6 +9,7 @@ #include #include #include +#include = /* * 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 --===============3342850509033534555==--