Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4226512ybb; Mon, 23 Mar 2020 16:23:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuCxY6Y8PF3EPl+wO6afIILE5A1EupN9Zbi3n1GJyykRX4OBD5l5QQmMHuDEiyceww+KchA X-Received: by 2002:aca:ad88:: with SMTP id w130mr1447946oie.82.1585005791907; Mon, 23 Mar 2020 16:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585005791; cv=none; d=google.com; s=arc-20160816; b=PbGsUgQ1R8cgcgm8KWgN9G5R0G6bUAxrC5J2cT3criWK2N+ud6asZ/7SR5HOT+32Hx h0We8U92aaNg4ZCnEa79G2uS1XH46RXYpwaAuPCb/DWd7EZS+Ld+WYEQSIhitCTmFwca O2vXhhkbqitI5oT+4j5XbE24TVbNEOmlhP6eFIRHMYecSvrjO9fEy2GsgiQVo/TBcK2M rhCqbOMo3703g8pJ9yiu9rtl14AO2wIGjjUE8keT1iOP2IueRXhPbqWffU3vAUEvLpi+ zF8PiPZ1gDX6HcPv7cSAHBQhw7bFo2su5YxcVGMEpPF2gMThC6J3tGa1W5+mmdiSfvAK 3r+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:mime-version :message-id:date:dkim-signature; bh=nGAFHlfBd3e/4DpEoxTJ41Z972i/CI0Z5FKhkiHor+U=; b=hTSZfri1J8b4KxwiLQeHavWO7qC3ASntfki/N/QX1mKaOYC/49byEywR7lKJ5m20OJ pABMWUS2EeuBHi6/JL6flWQBQ9CgqGW8hheaIokYpXFif3DxxNQDx0CBgAFp0dinAeZe k/uCkJuPIDd10nFGjES8XJF3YokQ295KmlYxwFN5t8ue2RXhL97Vj5VvRa+RrzVhxxuc mXqvegknU39J2evEdqYCUnbyyXN/EUB1wJjo+9KZUOlnlEzNHGvtHVzPYdUj4z7+ddId lpGT7ci+XYnNOaMzxAg7owOz4lXE0xbMXBvRCoHaCFotKh+ovogdQvn2rGm2PqtMIOat 1Qgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KkVzm046; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si8425033oif.204.2020.03.23.16.22.57; Mon, 23 Mar 2020 16:23:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KkVzm046; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727005AbgCWXWY (ORCPT + 99 others); Mon, 23 Mar 2020 19:22:24 -0400 Received: from mail-vk1-f202.google.com ([209.85.221.202]:51557 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbgCWXWY (ORCPT ); Mon, 23 Mar 2020 19:22:24 -0400 Received: by mail-vk1-f202.google.com with SMTP id c127so5802632vkh.18 for ; Mon, 23 Mar 2020 16:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=nGAFHlfBd3e/4DpEoxTJ41Z972i/CI0Z5FKhkiHor+U=; b=KkVzm0461yU6p8JLPw5BdoWxzunch2vLEcP54K5QZvsLM4QoavKN+hEQuBLXUZlmd8 6y1ZQrF318g9bGJkcYAo3JjgjZwIh7/5zTFX8r7ZTNLHmekAAY+NLyZVPp/fBWEHPzI8 F36WcYCv4PNE9M2wNe6yEni6hoT0UiB6CoCXBV+YYjezYkDJRKQLf8kFLyoJZzVnbhtf Az7Lh4RV8yf8M821Z8dWCJcAjiGmb4JeiM7KCafgK2JjhOTg+PBY3KtGO3gm/Fy46KUL kkYHU9VbxZ2TT3+qkvTSei9kIe/XRbm4ydvwomJ2LbpBP6pkJKhuYp8a/naTLHheYtFc U62g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=nGAFHlfBd3e/4DpEoxTJ41Z972i/CI0Z5FKhkiHor+U=; b=JjZGYJuHvI4RoWvayUYeNAQ7SWtq2NKYsWBnAS8qpvyhfMe0qb/2IZ3Dwonqdpc27C 2TBzmchrynGcFeyFBOQSwve2mertqqgHwvEj6hXFQwi5qOUDjeyxQsS0wxKEiUQcAZFa mH5t6ZbCW9VAR8tH1Aq/UNrQzdnDHdvz66/t4skDDj/X1EuWcZgi5Kuyj9pTx1yOys2P eVaq7Iii1/KERsY1++uHXXhCKDhxCWpaZ+o3HkGcW1ZjXBvWdBzfNuD6Za680dmsymAL kX+3d2hlAcUqLQ3TqsK304cWqdggEY1FbDnIoYiLWfpZvfDmBvgMBfCt6fgR0XZV8x5+ ds0A== X-Gm-Message-State: ANhLgQ1w0BFSjPt4Ds5yjXpt6DKG+FV2ZAIvkgtcDilniVEnArpaVufu wQAoS4EuxyBF67nXj3XtL/nJDr9SrGWrYMIdxuc= X-Received: by 2002:ab0:2553:: with SMTP id l19mr5446513uan.128.1585005742543; Mon, 23 Mar 2020 16:22:22 -0700 (PDT) Date: Mon, 23 Mar 2020 16:22:14 -0700 Message-Id: <20200323232214.24939-1-ndesaulniers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.25.1.696.g5e7596f4ac-goog Subject: [PATCH] Documentation: x86: exception-tables: document CONFIG_BUILDTIME_TABLE_SORT From: Nick Desaulniers To: corbet@lwn.net Cc: Nick Desaulniers , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide more information about __ex_table sorting post link. The exception tables and fixup tables use a commonly recurring pattern in the kernel of storing the address of labels as date in custom ELF sections, then finding these sections, iterating elements within them, and possibly revisiting them or modifying the data at these addresses. Sorting readonly arrays to minimize runtime penalties is quite clever. Signed-off-by: Nick Desaulniers --- Documentation/x86/exception-tables.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/x86/exception-tables.rst b/Documentation/x86/exception-tables.rst index ed6d4b0cf62c..15455b2f7ba8 100644 --- a/Documentation/x86/exception-tables.rst +++ b/Documentation/x86/exception-tables.rst @@ -257,6 +257,9 @@ the fault, in our case the actual value is c0199ff5: the original assembly code: > 3: movl $-14,%eax and linked in vmlinux : > c0199ff5 <.fixup+10b5> movl $0xfffffff2,%eax +If the fixup was able to handle the exception, control flow may be returned +to the instruction after the one that triggered the fault, ie. local label 2b. + The assembly code:: > .section __ex_table,"a" @@ -344,3 +347,9 @@ pointer which points to one of: it as special. More functions can easily be added. + +CONFIG_BUILDTIME_TABLE_SORT allows the __ex_table section to be sorted post +link of the kernel image, via a host utility scripts/sorttable. It will set the +symbol main_extable_sort_needed to 0, avoiding sorting the __ex_table section +at boot time. With the exception table sorted, at runtime when an exception +occurs we can quickly lookup the __ex_table entry via binary search. -- 2.25.1.696.g5e7596f4ac-goog