From patchwork Wed Apr 2 13:57:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 14036074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C232EC28B20 for ; Wed, 2 Apr 2025 13:58:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.935742.1337133 (Exim 4.92) (envelope-from ) id 1tzybS-0005la-01; Wed, 02 Apr 2025 13:58:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 935742.1337133; Wed, 02 Apr 2025 13:58:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzybR-0005lT-T2; Wed, 02 Apr 2025 13:58:01 +0000 Received: by outflank-mailman (input) for mailman id 935742; Wed, 02 Apr 2025 13:58:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzybQ-0005kV-M0 for xen-devel@lists.xenproject.org; Wed, 02 Apr 2025 13:58:00 +0000 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [2a00:1450:4864:20::42d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7c8ce4f1-0fca-11f0-9ea9-5ba50f476ded; Wed, 02 Apr 2025 15:57:59 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-39c266c2dd5so1280170f8f.3 for ; Wed, 02 Apr 2025 06:57:59 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b7a41f5sm16850495f8f.84.2025.04.02.06.57.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 06:57:58 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7c8ce4f1-0fca-11f0-9ea9-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743602279; x=1744207079; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=Wvo15DS2o3owPyk9r+14HmKhMwdf4HpSiy1AYZEx6FU=; b=gUd6KJWJo66qrP3F+gJnG3Bh7b5qYyhSon4t+AE0K5Jttk8C+5zMF4S3H7y/tDKrmZ 0EcNb0LepAa7d75GnJC6Fda6HPKDCBFC8b5rZMzysWLduCQ89MeKd7OcVXLWtqyZkMx4 Ov4XaT0yX/sSLfGax1jAXf2F+rdkpavjalJbhR+mMD5MSQm5kfVvfXHU8dtVkC9i+RGR fWBmHg7PrteXBTok8xq9EJkDWOjomlD2tk2FgpiWuVViaNhR9E9jP6A61/5Itzc6IdUD TYc70fM7htk11cE7gnptEz8VnV7k1Y9YhF8CZ1zvFn8Niqb5aEA1+JTulDCBLGYORQH7 VXxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743602279; x=1744207079; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Wvo15DS2o3owPyk9r+14HmKhMwdf4HpSiy1AYZEx6FU=; b=jNEfrgk5EUCs52bkOmDpi3OdSKQme/5VRF7LP8tbqD50egjC9ucuGpg0S3qrhu2650 havtBG1TgKUY0B41+gHyd1FuCNETkRPM+oP6AnLD+Kyt34L1l+rXYb2JcYxh2qTtc7B0 guixg2nygv9coG/RB33YJhPNZS6Mm6VxSf/jLWHdf7/5zucl8u+78vDX4l7rtI5jltbI 9iNdpjF6P37R39SMwPDZZ3/x0mN4M1Ue9iOaTmdFRUN3FpfTFqAzXzfGVjcHKs5h5pVY Vc+oRc5C6+YMRICnP3l666EBPgTUJBKUKk87mrdJ8gPOSDVOtelcc8I0gOmy4MjHGsp9 9LOQ== X-Gm-Message-State: AOJu0YyO44j9PnEs0lj/89TQfWZRHNeJVjowV770zYSUDVnbcBTCNvxL eDZXJXUDjEgUk+9rHiR7wtWfcVRv5bbq1fy8LgRiuvNqliNNF5C5JogScY+PmijjRDdQkUqaeZo = X-Gm-Gg: ASbGncsDdeBTcaG5bfsAAt7sNRusdkXqJcVIHp/Cp7Jvn239vRNukaR2RJyq/p4tzCX hiHxxVV9x0j5Kl1/4aXU/JfQa5ihTq+oH08o4kcU+UC0uPgGd09XIP+PdjzcUc5gIWIldVJ0tNl ygWTiJt0KbrpVRkMOMAV+x5zw1BSBGdWRVcRZs7zBaLRVv74mUbI8Hz/QfqkoI66QF0M3idsOVw 7sVb4w0fy4UNmXAJEcKwnKQO3eX+1j5myQUC57wGOPFshO4B7wkTlnU9awzNmWqEil8zsgIlmI+ qs4UJ1HKaoH92GFC26PDUBM8WNLt9GssbY01ND2razzmY7Y53b+xhLKQn3z/dt+Ld3xgKxmjidU EdpX+dzpuprhWtJqf+ELj0OFZC7jhrQ== X-Google-Smtp-Source: AGHT+IEvAMaGKn2Ttwk6M7eKwGqm0dtPoHP8cqbSjO8/vuoj4E5L4kwjV5UwiuRxQkhnHa0WG3iBUw== X-Received: by 2002:a05:6000:2a10:b0:39c:1257:ccad with SMTP id ffacd0b85a97d-39c1257ccdamr9248107f8f.56.1743602279222; Wed, 02 Apr 2025 06:57:59 -0700 (PDT) Message-ID: <879646dd-b55e-4b42-b637-d3b14570b880@suse.com> Date: Wed, 2 Apr 2025 15:57:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 1/5] symbols: add minimal self-test From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: ... before making changes to the involved logic. Signed-off-by: Jan Beulich --- While Andrew validly suggests cf_check isn't a requirement for selecting which function(s) to use (with the non-upstream gcc patch that we're using in CI), that's only because of how the non-upstream patch works. Going function-pointer -> unsigned long -> function-pointer without it being diagnosed that the cf_check is missing is a shortcoming there, and might conceivably be fixed at some point. (Imo any address-taking on a function should require it to be cf_check.) Hence I'd like to stick to using cf_check functions only for passing to test_lookup(). With this FAST_SYMBOL_LOOKUP may make sense to permit enabling even when LIVEPATCH=n. Thoughts? (In this case "symbols: centralize and re- arrange $(all_symbols) calculation" would want pulling ahead.) --- a/xen/common/symbols.c +++ b/xen/common/symbols.c @@ -260,6 +260,41 @@ unsigned long symbols_lookup_by_name(con return 0; } +#ifdef CONFIG_SELF_TESTS + +static void __init test_lookup(unsigned long addr, const char *expected) +{ + char buf[KSYM_NAME_LEN + 1]; + const char *name, *symname; + unsigned long size, offs; + + name = symbols_lookup(addr, &size, &offs, buf); + if ( !name ) + panic("%s: address not found\n", expected); + if ( offs ) + panic("%s: non-zero offset (%#lx) unexpected\n", expected, offs); + + /* Cope with static symbols, where varying file names/paths may be used. */ + symname = strchr(name, '#'); + symname = symname ? symname + 1 : name; + if ( strcmp(symname, expected) ) + panic("%s: unexpected symbol name: '%s'\n", expected, symname); + + offs = symbols_lookup_by_name(name); + if ( offs != addr ) + panic("%s: address %#lx unexpected; wanted %#lx\n", + expected, offs, addr); +} + +static void __init __constructor test_symbols(void) +{ + /* Be sure to only try this for cf_check functions. */ + test_lookup((unsigned long)dump_execstate, "dump_execstate"); + test_lookup((unsigned long)test_symbols, __func__); +} + +#endif /* CONFIG_SELF_TESTS */ + /* * Local variables: * mode: C From patchwork Wed Apr 2 13:58:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 14036075 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D8D83C36017 for ; Wed, 2 Apr 2025 13:58:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.935747.1337143 (Exim 4.92) (envelope-from ) id 1tzybl-00068M-6y; Wed, 02 Apr 2025 13:58:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 935747.1337143; Wed, 02 Apr 2025 13:58:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzybl-000682-3X; Wed, 02 Apr 2025 13:58:21 +0000 Received: by outflank-mailman (input) for mailman id 935747; Wed, 02 Apr 2025 13:58:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzybj-0005kV-Qk for xen-devel@lists.xenproject.org; Wed, 02 Apr 2025 13:58:19 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 879344c6-0fca-11f0-9ea9-5ba50f476ded; Wed, 02 Apr 2025 15:58:19 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-399749152b4so3295683f8f.3 for ; Wed, 02 Apr 2025 06:58:19 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43eb6135dc4sm21915525e9.33.2025.04.02.06.58.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 06:58:17 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 879344c6-0fca-11f0-9ea9-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743602298; x=1744207098; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=P+LOVlzxlWAhiyLhRnyUc5EdBZYUf7MC1TaE2FmTLf4=; b=ZVZ3Iw/qtaE/AnBK3ohe8LRCktJ4RD+ZeblpFnP+oHoD12GfiqJZf9IxkUNHJDgODk VPBjnOS00WnLAyRtaplMkWZ/UitzVuVdLZdIfUGicMKE9w2xfhSnsx5rdpjNxDOvYHDU Bwafz8XzYiLucos3uP+bhNR5FEwPZMvPa/ledbccFGjAPMUTbIFJHN2dKYtjuKBJuga9 3USC6R41Yh6tZZkKDSm5HWvwvgmmLj/z7hB0qKtbLCwmupXbJl3vHZOaEgsKy3Wiv7rD 4L7hYqXUE7ONFXfmrf1MWQnxo/BVTAmjBODLctHocxR93Z0CLGGP+sLjsgzaD60nQrw2 VGWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743602298; x=1744207098; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P+LOVlzxlWAhiyLhRnyUc5EdBZYUf7MC1TaE2FmTLf4=; b=r9+DxBOmiMhNmvTOY4sXR4h0tdXT3EHITBHCkJlhmZ/fxoGp1mOHdW6ZOGmIcuGZ68 fsmBcONNljMT1/HS5XD5LURB1vbhH+L1vHhUHZ4R0dYq7ei90MV+39V89mbddDgimlSc 7ExJ7uUzsA78iQfZPBqz7gGcuzOjSn6wRovumEfXQS5NiyWGBrdnBcUqM7wpmZUV/XcS ztxmSrwkrFJzrztJ5c+MJCJr+tw4tdlw735AdFvewGNUoD4GyPzw0PS70ozinTEOXy5/ WoXt0xB9qBLs4qpxBY3vaRNXV1Usunaa7hH9rME/+jX6wM43gwOoAllW7L15T7KRb+K7 lxOw== X-Gm-Message-State: AOJu0YzA6rI5BIXNzc2ar+R1G94HYYxo/ueJ+9J0+GOmfmkjKqHslmOP 2+82uguikX9PEHv8ahU5dkdIqI7TFrInJiE5SEdkL0o23MumicX4/EyGpI+K9cBTRLR0CFPsYI8 = X-Gm-Gg: ASbGncuPKARzE++rjr8hFD6Ol8q233VHTjXQLkMWtwB0rpAxVAksbEjMIj5FU7bENQb fp4nWsQNE+ao/LrNS3d2PINlX1/8P5Xudc55nRYYo+BfzO0+HqjkBnSaCwgY+Vh5ToTibAV6C6m OgPppieaWFZxyOa69HkRoICgy01apTT+FFvSWyactDqzeERd2gWxK5Cj/jmv3S3wgjRL0zs7X+I YIOmeWZfYGOKTIo3IoGYWy0EFt+I1qK5HFDqvf/1hZuwDeL/zWFijzfrlb7TkYhlnLujtXO6mit +VCAqc8SuDI0MQzyu0SBmKQdLgXwFZ83yOUVBXbgndrtYnk2Y0YfhvGK8CRTPr9Bq+npOA+nMtx KTyvSFHc+/LYIbpNh0JgNXCjese4BGwZ+ZHQQr5PI X-Google-Smtp-Source: AGHT+IEPWM4pLIvNJKv9hvi5KcBEPkQlR1qwBmNSaJR90hRsMiKg3Eqggx0tBeXaRir6xP01k69eGw== X-Received: by 2002:a05:6000:420c:b0:390:f902:f973 with SMTP id ffacd0b85a97d-39c23646776mr5682274f8f.8.1743602297716; Wed, 02 Apr 2025 06:58:17 -0700 (PDT) Message-ID: <5015ce6d-a961-491b-9fe7-f6628329f3f0@suse.com> Date: Wed, 2 Apr 2025 15:58:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 2/5] symbols: split symbols_num_syms From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/Br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VSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: In preparation for inserting address entries into symbols_addresses[] / symbols_offsets[] without enlarging symbols_sorted_offsets[], split symbols_num_syms into symbols_num_addrs (counting entries in the former plus symbols_names[] as well as, less directly, symbols_markers[]) and symbols_num_names (counting entries in the latter). While doing the adjustment move declarations to a new private symbols.h, to be used by both symbols.c and symbols-dummy.c. Replace u8/u16 while doing so. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- a/xen/common/symbols.c +++ b/xen/common/symbols.c @@ -10,7 +10,6 @@ * compression (see tools/symbols.c for a more complete description) */ -#include #include #include #include @@ -21,22 +20,7 @@ #include #include -#ifdef SYMBOLS_ORIGIN -extern const unsigned int symbols_offsets[]; -#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n]) -#else -extern const unsigned long symbols_addresses[]; -#define symbols_address(n) symbols_addresses[n] -#endif -extern const unsigned int symbols_num_syms; -extern const u8 symbols_names[]; - -extern const struct symbol_offset symbols_sorted_offsets[]; - -extern const u8 symbols_token_table[]; -extern const u16 symbols_token_index[]; - -extern const unsigned int symbols_markers[]; +#include "symbols.h" /* expand a compressed symbol data into the resulting uncompressed string, given the offset to where the symbol is in the compressed stream */ @@ -124,7 +108,7 @@ const char *symbols_lookup(unsigned long /* do a binary search on the sorted symbols_addresses array */ low = 0; - high = symbols_num_syms; + high = symbols_num_addrs; while (high-low > 1) { mid = (low + high) / 2; @@ -141,7 +125,7 @@ const char *symbols_lookup(unsigned long symbols_expand_symbol(get_symbol_offset(low), namebuf); /* Search for next non-aliased symbol */ - for (i = low + 1; i < symbols_num_syms; i++) { + for (i = low + 1; i < symbols_num_addrs; i++) { if (symbols_address(i) > symbols_address(low)) { symbol_end = symbols_address(i); break; @@ -182,9 +166,9 @@ int xensyms_read(uint32_t *symnum, char static unsigned int next_symbol, next_offset; static DEFINE_SPINLOCK(symbols_mutex); - if ( *symnum > symbols_num_syms ) + if ( *symnum > symbols_num_addrs ) return -ERANGE; - if ( *symnum == symbols_num_syms ) + if ( *symnum == symbols_num_addrs ) { /* No more symbols */ name[0] = '\0'; @@ -227,7 +211,7 @@ unsigned long symbols_lookup_by_name(con #ifdef CONFIG_FAST_SYMBOL_LOOKUP low = 0; - high = symbols_num_syms; + high = symbols_num_names; while ( low < high ) { unsigned long mid = low + ((high - low) / 2); --- /dev/null +++ b/xen/common/symbols.h @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include +#include + +#ifdef SYMBOLS_ORIGIN +extern const unsigned int symbols_offsets[]; +#define symbols_address(n) (SYMBOLS_ORIGIN + symbols_offsets[n]) +#else +extern const unsigned long symbols_addresses[]; +#define symbols_address(n) symbols_addresses[n] +#endif +extern const unsigned int symbols_num_addrs; +extern const unsigned char symbols_names[]; + +extern const unsigned int symbols_num_names; +extern const struct symbol_offset symbols_sorted_offsets[]; + +extern const uint8_t symbols_token_table[]; +extern const uint16_t symbols_token_index[]; + +extern const unsigned int symbols_markers[]; + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --- a/xen/common/symbols-dummy.c +++ b/xen/common/symbols-dummy.c @@ -3,22 +3,22 @@ * link of the hypervisor image. */ -#include -#include +#include "symbols.h" #ifdef SYMBOLS_ORIGIN const unsigned int symbols_offsets[1]; #else const unsigned long symbols_addresses[1]; #endif -const unsigned int symbols_num_syms; -const u8 symbols_names[1]; +const unsigned int symbols_num_addrs; +const unsigned char symbols_names[1]; #ifdef CONFIG_FAST_SYMBOL_LOOKUP +const unsigned int symbols_num_names; const struct symbol_offset symbols_sorted_offsets[1]; #endif -const u8 symbols_token_table[1]; -const u16 symbols_token_index[1]; +const uint8_t symbols_token_table[1]; +const uint16_t symbols_token_index[1]; const unsigned int symbols_markers[1]; --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -323,7 +323,7 @@ static void write_src(void) } printf("\n"); - output_label("symbols_num_syms"); + output_label("symbols_num_addrs"); printf("\t.long\t%d\n", table_cnt); printf("\n"); @@ -373,6 +373,10 @@ static void write_src(void) return; } + output_label("symbols_num_names"); + printf("\t.long\t%d\n", table_cnt); + printf("\n"); + /* Sorted by original symbol names and type. */ qsort(table, table_cnt, sizeof(*table), compare_name_orig); From patchwork Wed Apr 2 13:58:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 14036077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09EB2C28B20 for ; Wed, 2 Apr 2025 14:01:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.935777.1337163 (Exim 4.92) (envelope-from ) id 1tzyeU-0000Zr-Uk; Wed, 02 Apr 2025 14:01:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 935777.1337163; Wed, 02 Apr 2025 14:01:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzyeU-0000Zk-SA; Wed, 02 Apr 2025 14:01:10 +0000 Received: by outflank-mailman (input) for mailman id 935777; Wed, 02 Apr 2025 14:01:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzyc1-0005kV-IU for xen-devel@lists.xenproject.org; Wed, 02 Apr 2025 13:58:37 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 92a3c56e-0fca-11f0-9ea9-5ba50f476ded; Wed, 02 Apr 2025 15:58:36 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-39ac8e7688aso5226141f8f.2 for ; Wed, 02 Apr 2025 06:58:36 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43eb61b5768sm21420665e9.33.2025.04.02.06.58.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 06:58:35 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 92a3c56e-0fca-11f0-9ea9-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743602316; x=1744207116; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=e3lgQoWVEwKIU2psKovovYbn8xTJJbRXjtvyqx11OTY=; b=fIPdtene7QMz/+a1gdxCVElRmr6rJ358OYdtOgu6RqMpV0PfplwsVslKES9RjQt0v9 Gt6hCmg17nTtn5/Cc7qWO2ODt85T3zP/MihFEdUc2fOA7YnwYxB5RIDKRP3Nn2wW2G0y TC2deztkOIfxvnZQDzsD4VUYM/b3RyT5TzfNa1FtxqO7hWqw8C+930duCQxT2tZcG4sC RJrflkjljndEcxS90DiV0BSpM6m3sNL+ZFblsGdgG9I6dCmnj4RgilvF9NUM1TFEsy+2 WQ77zwZsoqwHm/I0IbRc1flrxDi4tUIAWK/2CBdglhCZuwU/pBYfr81hlAdu/LlzkZq4 vL9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743602316; x=1744207116; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e3lgQoWVEwKIU2psKovovYbn8xTJJbRXjtvyqx11OTY=; b=EjUA5wyozFLNo0KxCQpavQcAltlAsBskEhjtydDlnAZn7d6ZAT8Zfb84iiwhutlCh9 s5aNrC+5qYQAqDRpLcGYt0seJQL5oyg1+kKi8x8hDg+qj08JfqsFumjPkChbgISRPkAU kbQr4xQbxPLz+cExWW2LBPyDbJlz1kzG7ZBAz6uQRR9kelCsp9C/v9bq4CplXasJZXHT HCkL27NC3ldeFVYeLXZLXyH6EKLK8zlA1xHYUpN6Hz5gLRFVo/efSUVoVQnYO9JTWomg upCe4mhmaryZoSI2x45VOeBfKMSw45ZP0tx9itY1oAYXYNuGzukbK5DM+MIq6+t7kRnc v5Kg== X-Gm-Message-State: AOJu0YzxjW5vexGIPPq3ROnPNIWQDytWR7coXhDpR0PZCeBGz6l1SMV0 QwxYxEqCRzTTpp3TXXne/BFUiMjF1MJ2H7BNW6aRaq8IRllH5TOEXQXQYrSp4eC6UZ3hvFcG0HU = X-Gm-Gg: ASbGncs2Dn8M4AVTsGcoxvAiijdCtlxGrg0YJdHx4ZAhlOMtk54mB/sS0pNanApc3xb /+TKZGkq4rmZM4CKsMNoG/fTfSwwOrEMFBrjmvV2fDT2rArzaNUKdCGsspYiBpAODxOGBuToKQK dJXiJ1H0fSkNWZfw0jeirWkIyiIqa78V0O0jP8fkfgnONHZt1POybUQ9RU6lZt5MGsB/Ke1L7gd 2e5GcdjBeZXgselKWGqdIYon0Q/ScbVRV+ZBbOXQgop8LlVhvO2NaQOe4JdSPxI/ACgfDBVMfMU /Jb1hXXqpaPV4RiE0tC7g4W49xNrLxZxuUNedA3tK5N6/TR8r258QHeOkcXR9nXpNv0T9vJLUtP rBumGR3AVZpbdaFErL6zOjcTB6AVEtg== X-Google-Smtp-Source: AGHT+IGLmQhSCBY0UpP7m+2d+nwr4FWstvnmSxxJqz7JNHuoO6b7H2PAgbj4gvMi0VJF8W5LpG/fkA== X-Received: by 2002:a05:6000:40dd:b0:391:231b:8e0d with SMTP id ffacd0b85a97d-39c297e5c6dmr2109644f8f.39.1743602316126; Wed, 02 Apr 2025 06:58:36 -0700 (PDT) Message-ID: <10e116c5-5a62-4abc-a52a-e2ca12118cfe@suse.com> Date: Wed, 2 Apr 2025 15:58:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 3/5] symbols: arrange to know where functions end From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBt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MpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: When determining the symbol for a given address (e.g. for the %pS logging format specifier), so far the size of a symbol (function) was assumed to be everything until the next symbol. There may be gaps though, which would better be recognizable in output (often suggesting something odd is going on). Insert "fake" end symbols in the address table, accompanied by zero- length type/name entries (to keep lookup reasonably close to how it was). Note however that this, with present GNU binutils, won't work for xen.efi: The linker loses function sizes (they're not part of a normal symbol table entry), and hence nm has no way of reporting them. The address table growth is quite significant on x86 release builds (due to functions being aligned to 16-byte boundaries), though: Its size almost doubles. Requested-by: Andrew Cooper Signed-off-by: Jan Beulich --- Note: Style-wise this is a horrible mix. I'm trying to match styles with what's used in the respective functions. Older GNU ld retains section symbols, which nm then also lists. Should we perhaps strip those as we read in nm's output? They don't provide any useful extra information, as our linker scripts add section start symbols anyway. (For the purposes here, luckily such section symbols are at least emitted without size.) Even for section start symbols there is the question of whether they really need retaining (except perhaps when producing a map file). The main question here likely is whether livepatch may have a need to look them up by name. (Section end symbols may actually be slightly more useful to keep, but that may also want considering more closely.) --- v2: Deal with multiple symbols at the same address, but only some having a size specified. --- a/xen/common/symbols.c +++ b/xen/common/symbols.c @@ -116,6 +116,13 @@ const char *symbols_lookup(unsigned long else high = mid; } + /* If we hit an END symbol, move to the previous (real) one. */ + if (!symbols_names[get_symbol_offset(low)]) { + ASSERT(low); + symbol_end = symbols_address(low); + --low; + } + /* search for the first aliased symbol. Aliased symbols are symbols with the same address */ while (low && symbols_address(low - 1) == symbols_address(low)) @@ -124,11 +131,13 @@ const char *symbols_lookup(unsigned long /* Grab name */ symbols_expand_symbol(get_symbol_offset(low), namebuf); - /* Search for next non-aliased symbol */ - for (i = low + 1; i < symbols_num_addrs; i++) { - if (symbols_address(i) > symbols_address(low)) { - symbol_end = symbols_address(i); - break; + if (!symbol_end) { + /* Search for next non-aliased symbol */ + for (i = low + 1; i < symbols_num_addrs; i++) { + if (symbols_address(i) > symbols_address(low)) { + symbol_end = symbols_address(i); + break; + } } } @@ -170,6 +179,7 @@ int xensyms_read(uint32_t *symnum, char return -ERANGE; if ( *symnum == symbols_num_addrs ) { + no_symbol: /* No more symbols */ name[0] = '\0'; return 0; @@ -183,10 +193,31 @@ int xensyms_read(uint32_t *symnum, char /* Non-sequential access */ next_offset = get_symbol_offset(*symnum); + /* + * If we're at an END symbol, skip to the next (real) one. This can + * happen if the caller ignores the *symnum output from an earlier + * iteration (Linux'es /proc/xen/xensyms handling does as of 6.14-rc). + */ + if ( !symbols_names[next_offset] ) + { + ++next_offset; + if ( ++*symnum == symbols_num_addrs ) + goto no_symbol; + } + *type = symbols_get_symbol_type(next_offset); next_offset = symbols_expand_symbol(next_offset, name); *address = symbols_address(*symnum); + /* If next one is an END symbol, skip it. */ + if ( !symbols_names[next_offset] ) + { + ++next_offset; + /* Make sure not to increment past symbols_num_addrs below. */ + if ( *symnum + 1 < symbols_num_addrs ) + ++*symnum; + } + next_symbol = ++*symnum; spin_unlock(&symbols_mutex); --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -38,6 +38,7 @@ struct sym_entry { unsigned long long addr; + unsigned long size; unsigned int len; unsigned char *sym; char *orig_symbol; @@ -87,6 +88,8 @@ static int read_symbol(FILE *in, struct static char *filename; int rc = -1; + s->size = 0; + switch (input_format) { case fmt_bsd: rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); @@ -96,8 +99,12 @@ static int read_symbol(FILE *in, struct /* nothing */; rc = fscanf(in, "%499[^ |] |%llx | %c |", str, &s->addr, &stype); - if (rc == 3 && fscanf(in, " %19[^ |] |", type) != 1) - *type = '\0'; + if (rc == 3) { + if(fscanf(in, " %19[^ |] |", type) != 1) + *type = '\0'; + else if(fscanf(in, "%lx |", &s->size) != 1) + s->size = 0; + } break; } if (rc != 3) { @@ -287,9 +294,18 @@ static int compare_name_orig(const void return rc; } +/* Determine whether the symbol at address table @idx wants a fake END + * symbol (address only) emitted as well. */ +static bool want_symbol_end(unsigned int idx) +{ + return table[idx].size && + (idx + 1 == table_cnt || + table[idx].addr + table[idx].size < table[idx + 1].addr); +} + static void write_src(void) { - unsigned int i, k, off; + unsigned int i, k, off, ends; unsigned int best_idx[256]; unsigned int *markers; char buf[KSYM_NAME_LEN+1]; @@ -318,24 +334,42 @@ static void write_src(void) printf("#else\n"); output_label("symbols_offsets"); printf("#endif\n"); - for (i = 0; i < table_cnt; i++) { + for (i = 0, ends = 0; i < table_cnt; i++) { printf("\tPTR\t%#llx - SYMBOLS_ORIGIN\n", table[i].addr); + + table[i].addr_idx = i + ends; + + if (!want_symbol_end(i)) { + /* If there's another symbol at the same address, + * propagate this symbol's size if the next one has + * no size, or if the next one's size is larger. */ + if (table[i].size && + i + 1 < table_cnt && + table[i + 1].addr == table[i].addr && + (!table[i + 1].size || + table[i + 1].size > table[i].size)) + table[i + 1].size = table[i].size; + continue; + } + + ++ends; + printf("\tPTR\t%#llx - SYMBOLS_ORIGIN\n", + table[i].addr + table[i].size); } printf("\n"); output_label("symbols_num_addrs"); - printf("\t.long\t%d\n", table_cnt); + printf("\t.long\t%d\n", table_cnt + ends); printf("\n"); /* table of offset markers, that give the offset in the compressed stream * every 256 symbols */ - markers = (unsigned int *) malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256)); + markers = malloc(sizeof(*markers) * ((table_cnt + ends + 255) >> 8)); output_label("symbols_names"); - off = 0; - for (i = 0; i < table_cnt; i++) { - if ((i & 0xFF) == 0) - markers[i >> 8] = off; + for (i = 0, off = 0, ends = 0; i < table_cnt; i++) { + if (((i + ends) & 0xFF) == 0) + markers[(i + ends) >> 8] = off; printf("\t.byte 0x%02x", table[i].len); for (k = 0; k < table[i].len; k++) @@ -344,11 +378,22 @@ static void write_src(void) table[i].stream_offset = off; off += table[i].len + 1; + + if (!want_symbol_end(i)) + continue; + + /* END symbols have no name or type. */ + ++ends; + if (((i + ends) & 0xFF) == 0) + markers[(i + ends) >> 8] = off; + + printf("\t.byte 0\n"); + ++off; } printf("\n"); output_label("symbols_markers"); - for (i = 0; i < ((table_cnt + 255) >> 8); i++) + for (i = 0; i < ((table_cnt + ends + 255) >> 8); i++) printf("\t.long\t%d\n", markers[i]); printf("\n"); @@ -450,7 +495,6 @@ static void compress_symbols(unsigned ch len = table[i].len; p1 = table[i].sym; - table[i].addr_idx = i; /* find the token on the symbol */ p2 = memmem_pvt(p1, len, str, 2); if (!p2) continue; From patchwork Wed Apr 2 13:59:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 14036078 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3075FC28B20 for ; Wed, 2 Apr 2025 14:01:44 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.935781.1337174 (Exim 4.92) (envelope-from ) id 1tzyet-0001Wi-81; Wed, 02 Apr 2025 14:01:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 935781.1337174; Wed, 02 Apr 2025 14:01:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzyet-0001W7-2M; Wed, 02 Apr 2025 14:01:35 +0000 Received: by outflank-mailman (input) for mailman id 935781; Wed, 02 Apr 2025 14:01:33 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzycb-0005kV-EA for xen-devel@lists.xenproject.org; Wed, 02 Apr 2025 13:59:13 +0000 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [2a00:1450:4864:20::430]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a81e1e25-0fca-11f0-9ea9-5ba50f476ded; Wed, 02 Apr 2025 15:59:12 +0200 (CEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-39129fc51f8so5089913f8f.0 for ; Wed, 02 Apr 2025 06:59:12 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43eb5fc1b9esm21848495e9.6.2025.04.02.06.59.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 06:59:11 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a81e1e25-0fca-11f0-9ea9-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743602352; x=1744207152; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=5qdZYmy9cJ905wD0Otv7PRiJxoIoH9X0sUdlDkKSKcA=; b=Y84pn2cUzi96+haxqMOfvcQY7hcJR0PF0zrCRwraalJ+MEplLMb8frXZcRK/q4dzFc tw7cC97ABu7LrHAzEf8g9+0EQqYOs+FP8zPykniT5E4+i98cowy0ApG0VtO4u0pZEnCj 9C0TCQNjuem8Xw48wvReDPsifSTV8tQOSz8u4KUtJ70bUWWKjTsS0EBCyiLcDS2LImYb 8mpCfiVz6dJrGMb3eL5hi4OtMHuAOCaXccwkZS06aH/1x+i/o6d7Amlqz/46kGTL6COE 9UnvFBQ+r9oUQLtfh7Y/tpEz+2YLaDIDOfDBNwPEaVTwDQ6fFi1iE9Bf6KEkTaXb+2Ja y0IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743602352; x=1744207152; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5qdZYmy9cJ905wD0Otv7PRiJxoIoH9X0sUdlDkKSKcA=; b=PtZX41/oyzKO1g1ANTB5eFjtw/XH3FcES9gEr6NMbRd4kumjzqS47ImKriMX/Fbc9o sYWG3kPDFnhmUnOOBknzZzL2iSEn/A9o9bw7ymvRvE+ja75IDJKXT8FxOMMBgkvYXpu8 62zlwt28aEcr2XtZEf1WQqSmRCdOLDh459hhnLG0/MIg5Sc+UtUiaHXqt1Rt99ykX+RI cvpO38D5JL3JwQaXIkCCLn5Bk5vGSH9wIAiBqFKEAArO1h8NT0mCHC5Gem/DnzJcYDZc c1BBti2zIQEGF8RHjTIZ8TgB9wVqjK2Wi16uPBENDnECVxxrHtApMCKX9jMuWSvW1KJC NDDA== X-Gm-Message-State: AOJu0YxSqYn+daXVCW+mrtv+1d3f+h4v9+UB4oEAfqqswb9D1knFRYJm K7lfv03gVsQc+GrzGIaSU22XO3/VDYEerxqgFy3c0TkmkNkushGpIQ7zwqq/pyEJRjzV08Vw6PA = X-Gm-Gg: ASbGnctJN7ekac4qFAv16DXnPuxeYtQKJj2o3AYjA21OoELJx+aScjnVUzDM83VBA9V Pj18AvxvblVdJpklMDjxBr7Fwup7k6mtnmTxtiol5WTKXmKqv6BkCMvq8UvH7HMOdtc6Sj9BRB4 23HOZItYHNAUkZ2z4iByDwl0zhOk9GjBP0jFmztzQKwFp/2ej2BPfy0IHtkv1JO6/dI03u//mHf bVdzCIjYYl9xZ1+5U9vs7CrVxaXTOVb6xBGI3/xp8bBd25pHAFFS7ggxJZDzwlM+tEV0Bz8rcnj U0wKxDBQMliJ1Tp+425f5I7H+9t6nj03oZx4lkYNgc88JZqdB61sEpdsewH7ozd5r3f7DwO93Ll PVaS+uAhIE+mrZ7Z15p2ZBzMin4DGGg== X-Google-Smtp-Source: AGHT+IHOd3wRqTHID5d6KPFa4btlsYknPWJ6RTcqPa2SHO6OnvcQROz0ypVVkXn5/L2ZVZwycctLHQ== X-Received: by 2002:a05:6000:1862:b0:390:f6aa:4e7c with SMTP id ffacd0b85a97d-39c120e0bc1mr13767984f8f.28.1743602352238; Wed, 02 Apr 2025 06:59:12 -0700 (PDT) Message-ID: <5a77bb51-22d1-4956-8e45-c2412c413766@suse.com> Date: Wed, 2 Apr 2025 15:59:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 4/5] symbols: centralize and re-arrange $(all_symbols) calculation From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Bertrand Marquis , Volodymyr Babchuk References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+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CH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: For one there's no need for each architecture to have the same logic. Move to the root Makefile, also to calculate just once. And then re-arrange to permit FAST_SYMBOL_LOOKUP to be independent of LIVEPATCH, which may be useful in (at least) debugging. Signed-off-by: Jan Beulich --- Likely syms-warn-dup-y wants to follow suit; it doesn't even have an Arm counterpart right now. --- a/xen/Makefile +++ b/xen/Makefile @@ -460,6 +460,10 @@ ALL_OBJS-$(CONFIG_CRYPTO) += crypto/buil ALL_LIBS-y := lib/lib.a +all-symbols-y := +all-symbols-$(CONFIG_LIVEPATCH) += --all-symbols +all-symbols-$(CONFIG_FAST_SYMBOL_LOOKUP) += --sort-by-name + include $(srctree)/arch/$(SRCARCH)/arch.mk # define new variables to avoid the ones defined in Config.mk @@ -612,7 +616,8 @@ $(TARGET): outputmakefile asm-generic FO $(Q)$(MAKE) $(build)=include all $(Q)$(MAKE) $(build)=arch/$(SRCARCH) include $(Q)$(MAKE) $(build)=. arch/$(SRCARCH)/include/asm/asm-offsets.h - $(Q)$(MAKE) $(build)=. MKRELOC=$(MKRELOC) 'ALL_OBJS=$(ALL_OBJS-y)' 'ALL_LIBS=$(ALL_LIBS-y)' $@ + $(Q)$(MAKE) $(build)=. MKRELOC=$(MKRELOC) 'ALL_OBJS=$(ALL_OBJS-y)' \ + 'ALL_LIBS=$(ALL_LIBS-y)' 'all_symbols=$(all-symbols-y)' $@ SUBDIRS = xsm arch common crypto drivers lib test define all_sources --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -81,15 +81,6 @@ ifneq ($(CONFIG_DTB_FILE),"") obj-y += dtb.o endif -ifdef CONFIG_LIVEPATCH -all_symbols = --all-symbols -ifdef CONFIG_FAST_SYMBOL_LOOKUP -all_symbols = --all-symbols --sort-by-name -endif -else -all_symbols = -endif - $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ ifeq ($(CONFIG_ARM_64),y) --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -111,15 +111,6 @@ notes_phdrs = --notes endif endif -ifdef CONFIG_LIVEPATCH -all_symbols = --all-symbols -ifdef CONFIG_FAST_SYMBOL_LOOKUP -all_symbols = --all-symbols --sort-by-name -endif -else -all_symbols = -endif - syms-warn-dup-y := --warn-dup syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) := syms-warn-dup-$(CONFIG_ENFORCE_UNIQUE_SYMBOLS) := --error-dup From patchwork Wed Apr 2 14:00:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 14036076 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA753C28B20 for ; Wed, 2 Apr 2025 14:00:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.935766.1337152 (Exim 4.92) (envelope-from ) id 1tzydr-0007tH-Lu; Wed, 02 Apr 2025 14:00:31 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 935766.1337152; Wed, 02 Apr 2025 14:00:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzydr-0007tA-JG; Wed, 02 Apr 2025 14:00:31 +0000 Received: by outflank-mailman (input) for mailman id 935766; Wed, 02 Apr 2025 14:00:30 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzydq-0007t4-BD for xen-devel@lists.xenproject.org; Wed, 02 Apr 2025 14:00:30 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d52bd2ff-0fca-11f0-9ffb-bf95429c2676; Wed, 02 Apr 2025 16:00:28 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-43cf3192f3bso67742015e9.1 for ; Wed, 02 Apr 2025 07:00:28 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43eb619132esm21871615e9.32.2025.04.02.07.00.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Apr 2025 07:00:27 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d52bd2ff-0fca-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743602428; x=1744207228; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=aQQDd1gapuOKC8ERRVi4SvfFIF2zEKLTqlaKAIWA6lc=; b=FFME+Cu+NUZge2lreisO3+ZiSWA0s56nixzSNr2EptBiW/Vr3NAAd5u1mlfvmwPHZD 9p8gkoY2bAAczUQ3MDIMqzB+dtjy5tHSPjLl00NxG3TBPl+UpgqfUJ/nUBBsRgXwaS7D 6eTD0V+VoIkGaxTGTz+iOKYJDDCqYQG/cYkdWFVzJYZ6xUXf5uqoVHMBkLMFb1gwbXVO mRsy4pA/Fzv0EexUX4tUyZLhk0mRVafuS5Gh7N5JtTfFIrcAC88LLahVH+e9p+5Ys8nc v+e0iiOXdZMm1Y1aOzYsLiGuqZFJDc8M1aALlyNgLvOqg3ynKaincaQ29jfY9bWbtRMu VLzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743602428; x=1744207228; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aQQDd1gapuOKC8ERRVi4SvfFIF2zEKLTqlaKAIWA6lc=; b=MIqLQUNCLNZKESzRVzNGBlktRfMDVY6Sd1J5t3Igy+QKyBfr1/7RCP1OKMhr8GVYu4 11+rtrXmXwZUdAU/7vXRkj47sl8SXqyufLlX7RrYF07HytkIPe/bZ2ypBvd/ERfp55/o W3cDU7TaCHaiCv2l/OtwsJH2KVeH7Wp4f2VPIm2kzTpxgNUvwcsxC4LKNkwn158WEPKQ ZK3nPn68/Wvh20Hl64ja2yeFhQ6Kj5opFE3a4Ocv11FSv3C+DdG4Erqfu1H2NhIRepdA hH4XlMVHEQf7KTcIKTfMMJJPMmUzBu64ZV6jrKQAela0qFo8x1Of3/I7JbpOa3HuZ5af jFkg== X-Gm-Message-State: AOJu0YwRqQ9SCEGLQnHGI4yuZqa7tiEfKIhXU3b286bp7qh9xt33RtRe NJw+BX+5wv4b/1ZKJcR1DoRJzIcuXuLgEU078AEDg3+NG8ZXbMj78TmFltZ3l6jnf3YTJqnKtKY = X-Gm-Gg: ASbGncsH1LBvYnc4kdkalj2gJv0vGuFawaUmjn6SyNwrhX+FIgbeHTKYNLqIddNtIiV WTpLN7S40X1cDTR8R+IYv3/JlFkz3P2yGHa4EOJIjGlIGe9/26WA3e1ioYgLAhiSjAoSOcEboVx 0m7yxxz1aYbyEGtKuJ8LXVQhoSU+cxj8XLpZzZdmMiri5D2gRSJmL3AKIFwlbi4w38pfcm1iLJV TE3GNG2nbpuTSK6ObwQL/KN8LqJop02oOt1dETMlTlF7/QTpPrSfP6PHYOvQ6obJWnknUn2C3Ui h3aKfpc3g3PmW7buas8SF/1jXHqccI8Go8C0l0VjKtFASNNHL2YPebCBui3Ex/UjW4869ubLZha RtpBvu1RzIwdXesctbXywr07Q58tKgA== X-Google-Smtp-Source: AGHT+IF7C52hwri8XqctfZkS5LIAbXhdTYt5qRh8ZJuO7bII2d2p+oH8oXGLZUrSCyGsPzSnsxhO4A== X-Received: by 2002:a05:600c:42c8:b0:43a:b0ac:b10c with SMTP id 5b1f17b1804b1-43e8ff51423mr84298105e9.26.1743602427814; Wed, 02 Apr 2025 07:00:27 -0700 (PDT) Message-ID: Date: Wed, 2 Apr 2025 16:00:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 5/5] symbols: prefer symbols which have a type From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Julien Grall , Stefano Stabellini , Anthony PERARD , Michal Orzel , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnH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DSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: ... and thus typically also a size. Using global vs local is undesirable in certain situations, e.g. when a "real" symbol is local and at the same address as a section start/end one (which are all global). Note that for xen.efi the checking for "Function" is only forward- looking at this point: The function-ness of symbols (much like their size) is lost when linking PE/COFF binaries from ELF objects with GNU ld up to at least 2.44. Signed-off-by: Jan Beulich --- I didn't see much reason to also check for "Pointer" and "Array" or any of the basic types. While nm reports pointers and arrays (but not the basic types) for PE/COFF, making those up when linker input is ELF would be impossible without further auxiliary (and non-standard) data in the ELF symbol table. Transforming STT_FUNC, otoh, is in principle possible. Implicit from the above: Until GNU ld properly transforms STT_FUNC, symbol conflicts will be resolved differently for functions. Symbol conflicts will always be resolved differently for data. xen.efi stack traces may therefore be less informative than xen-syms ones. --- v2: New. --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -45,6 +45,7 @@ struct sym_entry { unsigned int addr_idx; unsigned int stream_offset; unsigned char type; + bool typed; }; #define SYMBOL_NAME(s) ((char *)(s)->sym + 1) @@ -180,6 +181,9 @@ static int read_symbol(FILE *in, struct s->type = stype; /* As s->sym[0] ends mangled. */ } s->sym[0] = stype; + s->typed = strcmp(type, "FUNC") == 0 || + strcmp(type, "OBJECT") == 0 || + strcmp(type, "Function") == 0; rc = 0; skip_tail: @@ -613,6 +617,13 @@ static int compare_value(const void *p1, return -1; if (sym1->addr > sym2->addr) return +1; + + /* Prefer symbols which have a type. */ + if (sym1->typed && !sym2->typed) + return -1; + if (sym2->typed && !sym1->typed) + return +1; + /* Prefer global symbols. */ if (isupper(*sym1->sym)) return -1;