From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2262weaaZS7SmJi7mcmtCsM1ies4hCoYHtfhutPG3npXjln1vR2MtaWtEvuwpm7CxYCeYkzk ARC-Seal: i=1; a=rsa-sha256; t=1517302322; cv=none; d=google.com; s=arc-20160816; b=gcVrlRse+/oTq9ZEvvoI19fjiDtVeXUi3zhUr5hmBE35aWHezSvAWfIuJawf9sXK3e 3TbafBMLtrQlekDUlUfEmsMBUlBf8WKRmSb2rz4Qk6JR1HF6zz9Q263t4/1sR8S8XNOY P09t1YsdlZ394riQX9ttLzvFyTOc64UraAGq1oFyd0XDz1mC9UWsvL2zkhC+3FwqaPkj 3zfi/exDEVQFE2L0pEralSrxLZOC7SwGpYXZ9Rd4++0t5yq8uUxRvrjYnGsYOQmI0B1C pdhC5MIWfH/lOJ+vlR54gcFq/GgBPTVDTc/rce5AwpyuD4X/Sb6OzQv9bChaIw8d7nkA eAOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=precedence:content-disposition:content-transfer-encoding :mime-version:robot-unsubscribe:robot-id:git-commit-id:subject:to :references:in-reply-to:reply-to:cc:message-id:from:sender:date :arc-authentication-results; bh=CY7Cuvh3dwKp/s2+WNiJPG7cVZYYlFDzE2mpFafGn3I=; b=MUYi/t87+be/VFtDfld4nNau/T3BTtmd1RIN3oOZJvu9QJmO6K+z7yX9IBozjUOQiF vC6S4ZikjwfZvOlqlXVHf3WqaSlL3wdRheR0LlZLnJwYHBtU/bb/d7YpvClER+CHUTez KFgWr4JVacZR8NTjncj3S4pLhn3kpymaNsEZG74iopSLyxV/DjkFjFaO8Cw6x8wdokRL QYAPWimQ/9gUehwQ/wdD6saqTqS1+1W0+pc/xjr5VfgT2ikWowKJlxXExKaw3O9GXVjm Br5Jo2wdEmDV0ts8arQ4TmlYoNmIWQUZaGg5QH2JtKpIVFwa8qy+sh8ZJ6fKNZg8idrk QKCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of tipbot@zytor.com designates 65.50.211.136 as permitted sender) smtp.mailfrom=tipbot@zytor.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of tipbot@zytor.com designates 65.50.211.136 as permitted sender) smtp.mailfrom=tipbot@zytor.com Date: Tue, 30 Jan 2018 00:46:45 -0800 Sender: tip tree robot From: tip-bot for Josh Poimboeuf Message-ID: Cc: tglx@linutronix.de, luto@kernel.org, gregkh@linuxfoundation.org, hpa@zytor.com, jgross@suse.com, linux@roeck-us.net, linux-kernel@vger.kernel.org, dwmw2@infradead.org, torvalds@linux-foundation.org, peterz@infradead.org, bp@alien8.de, jpoimboe@redhat.com, dave.hansen@linux.intel.com, mingo@kernel.org Reply-To: gregkh@linuxfoundation.org, hpa@zytor.com, tglx@linutronix.de, luto@kernel.org, bp@alien8.de, mingo@kernel.org, dave.hansen@linux.intel.com, jpoimboe@redhat.com, linux-kernel@vger.kernel.org, linux@roeck-us.net, jgross@suse.com, peterz@infradead.org, torvalds@linux-foundation.org, dwmw2@infradead.org In-Reply-To: <2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com> References: <2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] objtool: Add support for alternatives at the end of a section Git-Commit-ID: b18cbc614b4ddca4019ecd2e6663d54bd495d413 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1591006800156475116?= X-GMAIL-MSGID: =?utf-8?q?1591006800156475116?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: Commit-ID: b18cbc614b4ddca4019ecd2e6663d54bd495d413 Gitweb: https://git.kernel.org/tip/b18cbc614b4ddca4019ecd2e6663d54bd495d413 Author: Josh Poimboeuf AuthorDate: Mon, 29 Jan 2018 22:00:40 -0600 Committer: Ingo Molnar CommitDate: Tue, 30 Jan 2018 07:55:05 +0100 objtool: Add support for alternatives at the end of a section Now that the previous patch gave objtool the ability to read retpoline alternatives, it shows a new warning: arch/x86/entry/entry_64.o: warning: objtool: .entry_trampoline: don't know how to handle alternatives at end of section This is due to the JMP_NOSPEC in entry_SYSCALL_64_trampoline(). Previously, objtool ignored this situation because it wasn't needed, and it would have required a bit of extra code. Now that this case exists, add proper support for it. Signed-off-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Guenter Roeck Cc: H. Peter Anvin Cc: Juergen Gross Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/2a30a3c2158af47d891a76e69bb1ef347e0443fd.1517284349.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar --- tools/objtool/check.c | 53 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index bc3490d..9cd028a 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -594,7 +594,7 @@ static int handle_group_alt(struct objtool_file *file, struct instruction *orig_insn, struct instruction **new_insn) { - struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump; + struct instruction *last_orig_insn, *last_new_insn, *insn, *fake_jump = NULL; unsigned long dest_off; last_orig_insn = NULL; @@ -610,28 +610,30 @@ static int handle_group_alt(struct objtool_file *file, last_orig_insn = insn; } - if (!next_insn_same_sec(file, last_orig_insn)) { - WARN("%s: don't know how to handle alternatives at end of section", - special_alt->orig_sec->name); - return -1; - } - - fake_jump = malloc(sizeof(*fake_jump)); - if (!fake_jump) { - WARN("malloc failed"); - return -1; + if (next_insn_same_sec(file, last_orig_insn)) { + fake_jump = malloc(sizeof(*fake_jump)); + if (!fake_jump) { + WARN("malloc failed"); + return -1; + } + memset(fake_jump, 0, sizeof(*fake_jump)); + INIT_LIST_HEAD(&fake_jump->alts); + clear_insn_state(&fake_jump->state); + + fake_jump->sec = special_alt->new_sec; + fake_jump->offset = -1; + fake_jump->type = INSN_JUMP_UNCONDITIONAL; + fake_jump->jump_dest = list_next_entry(last_orig_insn, list); + fake_jump->ignore = true; } - memset(fake_jump, 0, sizeof(*fake_jump)); - INIT_LIST_HEAD(&fake_jump->alts); - clear_insn_state(&fake_jump->state); - - fake_jump->sec = special_alt->new_sec; - fake_jump->offset = -1; - fake_jump->type = INSN_JUMP_UNCONDITIONAL; - fake_jump->jump_dest = list_next_entry(last_orig_insn, list); - fake_jump->ignore = true; if (!special_alt->new_len) { + if (!fake_jump) { + WARN("%s: empty alternative at end of section", + special_alt->orig_sec->name); + return -1; + } + *new_insn = fake_jump; return 0; } @@ -654,8 +656,14 @@ static int handle_group_alt(struct objtool_file *file, continue; dest_off = insn->offset + insn->len + insn->immediate; - if (dest_off == special_alt->new_off + special_alt->new_len) + if (dest_off == special_alt->new_off + special_alt->new_len) { + if (!fake_jump) { + WARN("%s: alternative jump to end of section", + special_alt->orig_sec->name); + return -1; + } insn->jump_dest = fake_jump; + } if (!insn->jump_dest) { WARN_FUNC("can't find alternative jump destination", @@ -670,7 +678,8 @@ static int handle_group_alt(struct objtool_file *file, return -1; } - list_add(&fake_jump->list, &last_new_insn->list); + if (fake_jump) + list_add(&fake_jump->list, &last_new_insn->list); return 0; }