Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1740463pxb; Fri, 20 Aug 2021 12:47:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+dWYWBn3bni3/NwEn++61gXky2OLFwLSib+sMiI+eoVXyLcF/r9BeahoGW3GRzvGWL0Av X-Received: by 2002:a17:906:9b87:: with SMTP id dd7mr22233962ejc.99.1629488847633; Fri, 20 Aug 2021 12:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629488847; cv=none; d=google.com; s=arc-20160816; b=s2Uv7HXn38XLy6e/QyacsNY1BXlJ4RoOPtiR46Gu88OQ+bcrGgPZ7MdUSO94warzMm X4ANOhBkEhUFYm7i7LiXvZ4OapCz8eyE3Ilqv6scFXtBwBDOryEfMjfhf4WhJhE7Ovep rcAcdrq1irWRqTAf8v0lIDcI6JymfFYuPpJsnXqfyYO1E+p6wN40tRhUM0uGHavhmPU1 3AxbzLFQLQwTsm4X78cgKvOVsRx+HVjb/xwzi4DT55Fkqf/gUMrsb3uVgwHrnSif2xmA 660xrkjXFDzFOqC7ysDOxkshol3sihMR0SlGBY1pLNRU9KyTgtfBfgdcEO7snG4ybgvU bE7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=duj3eJCfkQ3SsfuEPSBfbAS1EI7agW472Nt8jTDSwdk=; b=kRDiwYP+ALgg98gLMjWcp5Zsk3FuHz+cCjkWjrI+N1H2pqSyYv5rWAqg0YHhqopz75 HebYFXBy5+y+sPSBwiaNdydIaDZzMtsBF1HbbIMWQ2554mWSAcij7sM1tqNoeoWZCCVU +gXQmqgrOdkaQ17wRxFqTA2ZkugZIVisg6JJSxqG0x8MS4LPBPgHTWdPYkXV0Gy+i2j1 ndRlZi0qVqxfkuDiKrc/VTgATSuvNRv7gFNti+7DFw4TwB1m5k7XHXS6HIDwmQ+MgmeA RwUGshznNZP/67MM7s2shdIZOKsJ/+ekRutE86ZrGwagXl+NaKixiUMziLvxtvadDFuV VSFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejCRWVPe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw3si1531171edb.297.2021.08.20.12.47.03; Fri, 20 Aug 2021 12:47:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejCRWVPe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238278AbhHTTps (ORCPT + 99 others); Fri, 20 Aug 2021 15:45:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46756 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229771AbhHTTpn (ORCPT ); Fri, 20 Aug 2021 15:45:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629488705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=duj3eJCfkQ3SsfuEPSBfbAS1EI7agW472Nt8jTDSwdk=; b=ejCRWVPexpwEnBTzJwiEfTJ57a6QNsaaCZ1aU1YLrwBTeiB8oHfhDZ3s+Fx9YH1vLJAC3r mH+mnolV/DW+VhW2LbGKSJUChzxvwSCnnsbwKPr4ujM3ro0VBOQzBPm7txdPiB4nZx+pZz lucetDqylBvzgyRmLcS6AYnnSWLxLsc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-cXTw8EgpOReNC6j5cGmuLw-1; Fri, 20 Aug 2021 15:45:01 -0400 X-MC-Unique: cXTw8EgpOReNC6j5cGmuLw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD95F107ACF5; Fri, 20 Aug 2021 19:45:00 +0000 (UTC) Received: from jlaw-desktop.redhat.com (unknown [10.22.16.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C06E18436; Fri, 20 Aug 2021 19:44:59 +0000 (UTC) From: Joe Lawrence To: x86@kernel.org, Josh Poimboeuf , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Miroslav Benes Subject: [PATCH v2 1/2] objtool: make .altinstructions section entry size consistent Date: Fri, 20 Aug 2021 15:44:52 -0400 Message-Id: <20210820194453.395548-2-joe.lawrence@redhat.com> In-Reply-To: <20210820194453.395548-1-joe.lawrence@redhat.com> References: <20210820194453.395548-1-joe.lawrence@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit e31694e0a7a7 ("objtool: Don't make .altinstructions writable") aligned objtool-created and kernel-created .altinstructions section flags, but there remains a minor discrepency in their use of a section entry size: objtool sets one while the kernel build does not. While sh_entsize of sizeof(struct alt_instr) seems intuitive, this small deviation can cause failures with external tooling (kpatch-build). Fix this by creating new .altinstructions sections with sh_entsize of 0 and then later updating sec->sh_size as alternatives are added to the section. An added benefit is avoiding the data descriptor and buffer created by elf_create_section(), but previously unused by elf_add_alternative(). Fixes: 9bc0bb50727c ("objtool/x86: Rewrite retpoline thunk calls") Signed-off-by: Joe Lawrence --- tools/objtool/arch/x86/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c index bc821056aba9..0893436cc09f 100644 --- a/tools/objtool/arch/x86/decode.c +++ b/tools/objtool/arch/x86/decode.c @@ -684,7 +684,7 @@ static int elf_add_alternative(struct elf *elf, sec = find_section_by_name(elf, ".altinstructions"); if (!sec) { sec = elf_create_section(elf, ".altinstructions", - SHF_ALLOC, size, 0); + SHF_ALLOC, 0, 0); if (!sec) { WARN_ELF("elf_create_section"); -- 2.26.3