From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96CF4C41603 for ; Wed, 12 May 2021 20:21:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86BF361476 for ; Wed, 12 May 2021 20:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385958AbhELURR (ORCPT ); Wed, 12 May 2021 16:17:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344424AbhELT0K (ORCPT ); Wed, 12 May 2021 15:26:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 429C4C06138F; Wed, 12 May 2021 12:20:17 -0700 (PDT) Date: Wed, 12 May 2021 19:20:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1620847215; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8acsnM4HzJ2odlgZZUPnssvVTLGfHQehLruvUSsNGQ0=; b=V1PjK7etsr1GsyvM2sz78Y3MELbeJ5xmSEUjquJipi1nkNHKejMQLq/mjOC1abqCIwVwDR JmRSQfsuCdzGBHMHuB6+1uvxr1pL5YyPHp775BQkSv4tc5Mwsbavc7WLi8vMb7Nf/HSgj1 ykWFwgikXtt2NqzRsm8wVD3O1pgUsY85nlh6dKpX9gckxZxzIuHALSj93mjRURJxTTzF3W pXa23RC1aNDqbzDJn8IqrUbJVhuf/s2oG3bB1IZe9F84ZFBh5xE4lUOvg+U6ZP7UAxhK0c G6XZH5X9M7nIX7r4lqtGQHYQRRWH9ckGPdMXcUsr+9EpmNthpRDt8tszE+SilA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1620847215; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8acsnM4HzJ2odlgZZUPnssvVTLGfHQehLruvUSsNGQ0=; b=HUGRxZeanjgKX0Vu0jW1azbJCVbdqBhGouGlC6Mpp9i+3Dzffh7Iu9l6PLLenw1vCU5nuI c7EcQkHZMaUWAsCw== From: "tip-bot2 for Vasily Gorbik" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/urgent] objtool/x86: Fix elf_add_alternative() endianness Cc: Vasily Gorbik , Ingo Molnar , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: =?utf-8?q?=3Cpatch-2=2Ethread-6c9df9=2Egit-6c9df9a8098d=2Eyou?= =?utf-8?q?r-ad-here=2Ecall-01620841104-ext-2554=40work=2Ehours=3E?= References: =?utf-8?q?=3Cpatch-2=2Ethread-6c9df9=2Egit-6c9df9a8098d=2Eyour?= =?utf-8?q?-ad-here=2Ecall-01620841104-ext-2554=40work=2Ehours=3E?= MIME-Version: 1.0 Message-ID: <162084721395.29796.17337977266072814235.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/urgent branch of tip: Commit-ID: f66c05d6baf36069c01a02f869bebb75586f2318 Gitweb: https://git.kernel.org/tip/f66c05d6baf36069c01a02f869bebb75586f2318 Author: Vasily Gorbik AuthorDate: Wed, 12 May 2021 19:42:13 +02:00 Committer: Ingo Molnar CommitterDate: Wed, 12 May 2021 21:17:01 +02:00 objtool/x86: Fix elf_add_alternative() endianness Currently x86 kernel cross-compiled on big endian system fails at boot with: kernel BUG at arch/x86/kernel/alternative.c:258! Corresponding bug condition look like the following: BUG_ON(feature >= (NCAPINTS + NBUGINTS) * 32); Fix that by converting alternative feature/cpuid to target endianness. Fixes: 9bc0bb50727c ("objtool/x86: Rewrite retpoline thunk calls") Signed-off-by: Vasily Gorbik Signed-off-by: Ingo Molnar Acked-by: Peter Zijlstra Link: https://lore.kernel.org/r/patch-2.thread-6c9df9.git-6c9df9a8098d.your-ad-here.call-01620841104-ext-2554@work.hours --- tools/objtool/arch/x86/decode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index cedf3ed..24295d3 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -19,6 +19,7 @@ #include #include #include +#include #include static int is_x86_64(const struct elf *elf) @@ -725,7 +726,7 @@ static int elf_add_alternative(struct elf *elf, return -1; } - alt->cpuid = cpuid; + alt->cpuid = bswap_if_needed(cpuid); alt->instrlen = orig_len; alt->replacementlen = repl_len;