Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp44405pxm; Tue, 22 Feb 2022 06:06:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL2BlCmqKjqQUhQjTDYHdFLPee7YrgS1HPxlynFD6Lqz8/6VrSVEFw26w9MgDPo2eZxXKo X-Received: by 2002:a17:90a:2e0e:b0:1bc:dbe:2d04 with SMTP id q14-20020a17090a2e0e00b001bc0dbe2d04mr4354354pjd.74.1645538777509; Tue, 22 Feb 2022 06:06:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645538777; cv=none; d=google.com; s=arc-20160816; b=QmkafF6MuV6QrsH5YZhHpVNtDwqTGecol2kPxulYtxZ9+aiMKdk/l1PMZEvAAXEdO9 c1DjGkCun/qT/xI489jxTHX+o2etnBZ/DF0a6uhgrUkeqN8MLxyBruon2D5iNWPTfQCX J/esJAmL6O9cYAh+ghLBSWg1cetD/dzQi8HGXQpDItB2AlTjw2cfzu2wHfCRIANm0LR5 09vGTrBYVYhoWV6QVW6+BpK2Nx+MYW3zCzY5H0wQyPw9wY2dLuTI6pdR+dnVxRgWACZE /R9u496JrN3vhD1gTFTWN9UbfPT2pDdnGdrONAC+NQZ5dCUtTrpfDH+MtiIlM0m1imIU AG8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=9YLfdLDX50M/ZkhtC5IB+zCV0i6JtJQXN7NqFd+CRpY=; b=A0uAuyonAuMzbVBjMvGHR8eJEH6WkNlBpkRuItqvfPTpTCjqH+b4SgOrJDGLyuTf23 5MjgXnlrRPksgbmGsj8zwvcu2RuQ3VwCsOcUzFzMXNPF2BKaAFlqwKjDQgy3/nNYyd1t RMyD1j3Uf3RY6wGWNYZZxSLfM2ywY5VxBnGj53hQ0z58pepTaip2Z4HBiCkOClokcfTB ha0fiay41cJjdwbzkPYIZSkYu3mtRmL0SlR90xGjZSeuvyn22uX1QHyCZ9Qq+5zfJSma 5JXEdooyGYAZKI1FWzD2i0f7nt3QXRkzZnf01TSv1nWcx+A+w3Gq4MVUXyLC+n9yvcLN uD2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i8pfb9al; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11si11699365pfh.44.2022.02.22.06.06.00; Tue, 22 Feb 2022 06:06:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i8pfb9al; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231924AbiBVNB6 (ORCPT + 99 others); Tue, 22 Feb 2022 08:01:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbiBVNB5 (ORCPT ); Tue, 22 Feb 2022 08:01:57 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90C1558F for ; Tue, 22 Feb 2022 05:01:31 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id lw4so42691450ejb.12 for ; Tue, 22 Feb 2022 05:01:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=9YLfdLDX50M/ZkhtC5IB+zCV0i6JtJQXN7NqFd+CRpY=; b=i8pfb9alhkTcpLZj0VvRWw/SByHorpH2HXvfuMZjGoh0KKG0Vhepn7lR2NSf2v6bBs dxZrjMmM3LzSvKkkfIHKKT9MhOub4+fHYWtfcajasoGut28hS4ddFrX0DEEyBxqTSpZS 8AmOb4HCThgAlUmdvwC4ywVwJ+3jp3ZNtqKiPHv/edcW6y6LLdZtM8dXt4i+SvOPAjUn vIL7Y8oHT9HjQuUFXx+3kjtF0WqlMDdZfmf75WeHUySDsjTAfnA2EXYLRyqlYyG+rYz6 H0XBCTwxUaN9U7y5y7Tp0iK6XOSBX3xwdVwoYLmE257N9gLUfXF50Yxdyy20ooX8V4Zg t1Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=9YLfdLDX50M/ZkhtC5IB+zCV0i6JtJQXN7NqFd+CRpY=; b=JfLOiFzHxRQoNKDsOChfLEiRnlYG8Qy6MogiEnt9FqGM/0gLSPey6NMOf1wSo6RqKP LBpSFucTuvVzhRw8KKZSe8S9YNqTS9lEJOK3aKMvgJDkfMFcskIW8CkdoZDYJcJGTlsB fCgbZ5jUaB0i438xM1XeIRp9CkUe8uOEgl2w0AM1p9045ooep3WhlalYlGcFYWca1vbU 163JQgGvRaFqfMNn6YaAAMCZqT8tKu724P8wZmw20+Gn2xyRJ8Tc6CKmTYlOhlAQ/rXf 0oA6iewnEV3hvLh+RilP8qJePwH23i6HGfUeQvsEqAdZ4vO7VKjTgAncnqOH8djG2jBI jxjg== X-Gm-Message-State: AOAM533JIfTniB5pcn5B1vC6x1wIvtc/UJg0dXaqH9n1AY2TO1EQkOpd HZaRmrxX+dGD+iHyp93d8g== X-Received: by 2002:a17:907:9691:b0:6d1:711d:9050 with SMTP id hd17-20020a170907969100b006d1711d9050mr8154251ejc.755.1645534890128; Tue, 22 Feb 2022 05:01:30 -0800 (PST) Received: from localhost.localdomain ([46.53.254.189]) by smtp.gmail.com with ESMTPSA id s15sm6291542ejj.84.2022.02.22.05.01.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 05:01:29 -0800 (PST) Date: Tue, 22 Feb 2022 16:01:27 +0300 From: Alexey Dobriyan To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86, alternative: record .altinstructions section entity size Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org .altinstructions entry was 12 bytes in size, then it was 13 bytes, now it is 12 again. Record this information as section sh_entsize value so that tools which parse .altinstructions have easier time. Dividing section size by 12 or 13 and looking at the remainder doesn't work because the number of alternative entries itself can be multiple of entry size. Signed-off-by: Alexey Dobriyan (CloudLinux) --- arch/x86/include/asm/alternative.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -9,6 +9,8 @@ #define ALTINSTR_FLAG_INV (1 << 15) #define ALT_NOT(feat) ((feat) | ALTINSTR_FLAG_INV) +#define sizeof_struct_alt_instr 12 + #ifndef __ASSEMBLY__ #include @@ -66,6 +68,7 @@ struct alt_instr { u8 instrlen; /* length of original instruction */ u8 replacementlen; /* length of new instruction */ } __packed; +_Static_assert(sizeof(struct alt_instr) == sizeof_struct_alt_instr); /* * Debug flag that can be tested to see whether alternative @@ -159,7 +162,7 @@ static inline int alternatives_text_reserved(void *start, void *end) /* alternative assembly primitive: */ #define ALTERNATIVE(oldinstr, newinstr, feature) \ OLDINSTR(oldinstr, 1) \ - ".pushsection .altinstructions,\"a\"\n" \ + ".pushsection .altinstructions,\"aM\",@progbits," __stringify(sizeof_struct_alt_instr) "\n"\ ALTINSTR_ENTRY(feature, 1) \ ".popsection\n" \ ".pushsection .altinstr_replacement, \"ax\"\n" \ @@ -168,7 +171,7 @@ static inline int alternatives_text_reserved(void *start, void *end) #define ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2)\ OLDINSTR_2(oldinstr, 1, 2) \ - ".pushsection .altinstructions,\"a\"\n" \ + ".pushsection .altinstructions,\"aM\",@progbits," __stringify(sizeof_struct_alt_instr) "\n"\ ALTINSTR_ENTRY(feature1, 1) \ ALTINSTR_ENTRY(feature2, 2) \ ".popsection\n" \ @@ -184,7 +187,7 @@ static inline int alternatives_text_reserved(void *start, void *end) #define ALTERNATIVE_3(oldinsn, newinsn1, feat1, newinsn2, feat2, newinsn3, feat3) \ OLDINSTR_3(oldinsn, 1, 2, 3) \ - ".pushsection .altinstructions,\"a\"\n" \ + ".pushsection .altinstructions,\"aM\",@progbits," __stringify(sizeof_struct_alt_instr) "\n"\ ALTINSTR_ENTRY(feat1, 1) \ ALTINSTR_ENTRY(feat2, 2) \ ALTINSTR_ENTRY(feat3, 3) \ @@ -331,7 +334,7 @@ static inline int alternatives_text_reserved(void *start, void *end) .skip -(((144f-143f)-(141b-140b)) > 0) * ((144f-143f)-(141b-140b)),0x90 142: - .pushsection .altinstructions,"a" + .pushsection .altinstructions,"aM",@progbits,sizeof_struct_alt_instr altinstruction_entry 140b,143f,\feature,142b-140b,144f-143f .popsection @@ -368,7 +371,7 @@ static inline int alternatives_text_reserved(void *start, void *end) (alt_max_short(new_len1, new_len2) - (old_len)),0x90 142: - .pushsection .altinstructions,"a" + .pushsection .altinstructions,"aM",@progbits,sizeof_struct_alt_instr altinstruction_entry 140b,143f,\feature1,142b-140b,144f-143f altinstruction_entry 140b,144f,\feature2,142b-140b,145f-144f .popsection