From patchwork Tue Apr 1 13:08:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034818 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 CB9E3C36010 for ; Tue, 1 Apr 2025 13:09:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934107.1335907 (Exim 4.92) (envelope-from ) id 1tzbMI-00006x-1z; Tue, 01 Apr 2025 13:08:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934107.1335907; Tue, 01 Apr 2025 13:08:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbMH-00006q-Td; Tue, 01 Apr 2025 13:08:49 +0000 Received: by outflank-mailman (input) for mailman id 934107; Tue, 01 Apr 2025 13:08:47 +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 1tzbMF-0008KU-Sl for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:08:47 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7275c56e-0efa-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 15:08:47 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5e6194e9d2cso10754572a12.2 for ; Tue, 01 Apr 2025 06:08:47 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5edc17dfe1dsm7009648a12.69.2025.04.01.06.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:46 -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: 7275c56e-0efa-11f0-9ea7-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512927; x=1744117727; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/ptGrBuxtEj31Q7M6MgPsMH1aHP2RP83UeWmucEzVyU=; b=C6vtzZBGnKO/n0dgmtDMCGVg962H3wjnYye2aLXeWBN7OAd2pAOrzABJ2SKLFIf2tP oQUtPGiYGIYF8V1d/GVsonyQNhh9UpAK/upcwx7M6ds8eVPQ0p0+nSznsUVJDgyP1Xxb V9z8sNXM2VHdVaGFQNRNvF0iiF7nET4LRa7AA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512927; x=1744117727; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ptGrBuxtEj31Q7M6MgPsMH1aHP2RP83UeWmucEzVyU=; b=F2LTdQ4uUY4R9HmhSihkTdzRiKw1wFehyjWUI6AgtnIuKc1CLpyoUR7WGzBlmJ4CkK 6oZOrur3dTwpmsdPNyCMt55zPiXlbpVhjLl6wjBH0OSWNpJYcERDx3oENQ/DlThC6+g+ A2zwttyKWsyDZQR4nWba4lv/GP4vyhbZzXhBMU/D3KeZ7zVx+WUiHKitKJg8m+HB74WJ S0/uzv2XlE8DwClqWh8RlQWwKJyLjijDkUwG9oeCPeAfzhRrudgc/natacZjk8poxifi 0oYZ2n7BYvjUa9ijoRXmngLEB3NJGzAkU5oUpAvE1lok5PsylvLIeVcu6r2fEtqMJqFE DDKg== X-Gm-Message-State: AOJu0YwK4GiS3Yb3uh1wbnDUVazIxf+fcDHgvF0kuBi9W3qeUli+WLrs ffW7XK5FlE7vlZhxRww/h2aJfxZf2+8AoMnbebxSHBFXz+AujE5fLZfWJSAD7E+fYvwMJhzPKru j X-Gm-Gg: ASbGncuUM11sNJVEaOO5F0HFbfhFl6yatZIqWeHTLi3D92Jz61paG1KjOQh4I7nCe/x zmFf8ZpIngEwPMvyAsEB8q0k0+0g1HOUH1k2Swm0K9bvR4BzopqywOfSfH6sc8QuM+GrtgBBQyO 530HCdB/leRFvsbLb64dNpkVJlkLDwSctth3gGjPGLIKlgUeiNS30iSXXq3iMMGt+POh+3Q+VsN cwhJQKqGAZ70k+ktFPWcj+WiGMmR51tz6sVTJQGJYn6SrflHuOE6ESogWKNmhDZqZQ69LBjphen CDRXYw+4XdmSqFQGGGZ5R0InvU1AeGlB5Gc5oP7qRrGY1Tn8ww== X-Google-Smtp-Source: AGHT+IHEWU/Tdnp6Rgb2HZZhYTozC4Ntsq+w55gYeFC4BgiTnRNz4Ghw0pw6dxqwj1LLsltSzA6ocA== X-Received: by 2002:a05:6402:2706:b0:5e5:3610:8b7a with SMTP id 4fb4d7f45d1cf-5edfcfe6179mr10612256a12.17.1743512926585; Tue, 01 Apr 2025 06:08:46 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Doug Goldstein , Stefano Stabellini Subject: [PATCH v2 01/11] automation/dockers: add to README how to rebuild all containers Date: Tue, 1 Apr 2025 15:08:30 +0200 Message-ID: <20250401130840.72119-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 Document in the README how to rebuild all containers. This is helpful when populating a local docker registry for testing purposes. Signed-off-by: Roger Pau Monné Acked-by: Andrew Cooper Reviewed-by: Stefano Stabellini --- automation/build/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/automation/build/README.md b/automation/build/README.md index ecc898680c91..6c647b1b2a68 100644 --- a/automation/build/README.md +++ b/automation/build/README.md @@ -108,6 +108,13 @@ env CONTAINER_NO_PULL=1 \ make -C automation/build opensuse/tumbleweed-x86_64 PUSH=1 ``` +To rebuild all containers the `all` make target can be used, with or without +the `PUSH` environment variable: + +``` +make -C automation/build all PUSH=1 +``` + [BuildKit]: https://docs.docker.com/build/buildkit/ [registry]: https://gitlab.com/xen-project/xen/container_registry [registry help]: https://docs.gitlab.com/ee/user/packages/container_registry/ From patchwork Tue Apr 1 13:08:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034820 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 DDB15C3601B for ; Tue, 1 Apr 2025 13:09:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934110.1335916 (Exim 4.92) (envelope-from ) id 1tzbMQ-0000QL-8m; Tue, 01 Apr 2025 13:08:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934110.1335916; Tue, 01 Apr 2025 13:08:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbMQ-0000QC-5G; Tue, 01 Apr 2025 13:08:58 +0000 Received: by outflank-mailman (input) for mailman id 934110; Tue, 01 Apr 2025 13:08:57 +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 1tzbMP-0000Od-8u for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:08:57 +0000 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [2a00:1450:4864:20::532]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 76ee7198-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:08:55 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-5e6f4b3ebe5so10105035a12.0 for ; Tue, 01 Apr 2025 06:08:55 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac719278d40sm758430666b.43.2025.04.01.06.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:47 -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: 76ee7198-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512934; x=1744117734; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NsEpEdsMppdQXfKAAy8KJLkcIZ3dN80EvB2RdrH7vDo=; b=TvDoznc4sPuIsNPC+8tzsVYHSzRFgVmjwpFGZMTiRg2vleHRbsvNuKel5vgbh+pTwj 8RKxRZj1C90M75lrlYxnfDyoMY8boKCWhHWegcwHq18xxN3XWPx3qfb1YNYshENmR4RW az5w8NAcBOlUlyvIdk4RunMQp2WEopyeTNOg0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512934; x=1744117734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NsEpEdsMppdQXfKAAy8KJLkcIZ3dN80EvB2RdrH7vDo=; b=N5Byvf8iw3Ii90N6h6ZPFTKZh5HxiYnehH1QmtG4f35OCIE/fayRbqnWByRqGIvmrx QpgPug7CL6tu+ygUqa+RToXCR178XAmunHlfoqloJtx+qE5j6deE56D7hJ4yjsHJp8IU npl8dLsldp5rVg7gHgGqTJxhPzVFqcnWuNEiED59rU39ZsmpkleTahlzYp9iPosUiqK5 DVVcZZhwlafLg/6xPBrq6Mhn5cE6MxNsp3S9caWaYtlnpDCBXPDVV5dULGWsQnj4gXzm aAWcv8G122BM//DDv8O37sapFkpy3jdYQ+R/Ivf2eC6U1yWPIV/tsRVuqo8Sv5I/X3al 1L3A== X-Gm-Message-State: AOJu0YySjyILldvr9ItkD/aF0KvW/q38K/J4YGzcwgpkLsfNjlKiEigT 3nhP019VA8LAKdi+xBi8g/rg0whpgiESJQR6JBcQkOK/G2KJVV69Mr2ZyGjcwT6/VrDtfGHUarp c X-Gm-Gg: ASbGnct/WyIoYzuwqza8cVoaHzLkjXhlqVqVuToQyJEndshQJTiSCLn1wXNaducuECB jcQSAbu00h8+bk+yQiUoVDU2F/mJiADLZxlxYMrVaHk8OCgkwCP6KElLaMXMKj3HrT7DG7bOKea /smZlmz+9dGb4R7kp1/+uTYmYRdgj/hEk3dje2DNR+guwKGZLWnJjFHuh03Sffw38/8vHqUk2yv tLRioINJfBn4E9nLdVI2dIBQSaRTnd6w/aSxZU6qE96TQbSs8Pn3EddqjJNJTsvrl+hx2EwK7lu JBJoDEPFUnGlIRYTOMd0/PReNzLi/EEwUwEXu21ZzDj0STDGAA== X-Google-Smtp-Source: AGHT+IEjNM0hl1ZuDEUz8kinw6uldqxQXFDuinCrTlRAbXXd1L6CBSNezmpIgEeTcYwhFpI/avEATA== X-Received: by 2002:a17:907:3e1d:b0:ac3:3f11:2955 with SMTP id a640c23a62f3a-ac738bae5ffmr1213282666b.39.1743512928140; Tue, 01 Apr 2025 06:08:48 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , "Daniel P. Smith" , =?utf-8?q?Marek_Marczykow?= =?utf-8?q?ski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper Subject: [PATCH v2 02/11] x86/mkreloc: fix obtaining PE image base address Date: Tue, 1 Apr 2025 15:08:31 +0200 Message-ID: <20250401130840.72119-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 The base address is in the pe32_opt_hdr, not after it. Previous to commit f7f42accbbbb the base was read standalone (as the first field of pe32_opt_hdr). However with the addition of reading the full contents of pe32_opt_hdr, such read will also fetch the base. The current attempt to read the base after pe32_opt_hdr is bogus, and could only work if the file cursor is repositioned using lseek(), but there's no need for that as the data is already fetched in pe32_opt_hdr. Fixes: f7f42accbbbb ('x86/efi: Use generic PE/COFF structures') Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper Reported-by: Roger Pau Monné Signed-off-by: Jan Beulich --- xen/arch/x86/efi/mkreloc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/efi/mkreloc.c b/xen/arch/x86/efi/mkreloc.c index 375cb79d6959..1a6cfc845cba 100644 --- a/xen/arch/x86/efi/mkreloc.c +++ b/xen/arch/x86/efi/mkreloc.c @@ -35,7 +35,6 @@ static unsigned int load(const char *name, int *handle, struct mz_hdr mz_hdr; struct pe_hdr pe_hdr; struct pe32_opt_hdr pe32_opt_hdr; - uint32_t base; if ( in < 0 || read(in, &mz_hdr, sizeof(mz_hdr)) != sizeof(mz_hdr) ) @@ -55,7 +54,6 @@ static unsigned int load(const char *name, int *handle, if ( lseek(in, mz_hdr.peaddr, SEEK_SET) < 0 || read(in, &pe_hdr, sizeof(pe_hdr)) != sizeof(pe_hdr) || read(in, &pe32_opt_hdr, sizeof(pe32_opt_hdr)) != sizeof(pe32_opt_hdr) || - read(in, &base, sizeof(base)) != sizeof(base) || /* * Luckily the image size field lives at the * same offset for both formats. @@ -73,11 +71,12 @@ static unsigned int load(const char *name, int *handle, { case PE_OPT_MAGIC_PE32: *width = 32; - *image_base = base; + *image_base = pe32_opt_hdr.image_base; break; case PE_OPT_MAGIC_PE32PLUS: *width = 64; - *image_base = ((uint64_t)base << 32) | pe32_opt_hdr.data_base; + *image_base = ((uint64_t)pe32_opt_hdr.image_base << 32) | + pe32_opt_hdr.data_base; break; default: fprintf(stderr, "%s: Wrong PE file format\n", name); From patchwork Tue Apr 1 13:08:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034822 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 0B51BC36010 for ; Tue, 1 Apr 2025 13:09:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934111.1335925 (Exim 4.92) (envelope-from ) id 1tzbMR-0000fo-HP; Tue, 01 Apr 2025 13:08:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934111.1335925; Tue, 01 Apr 2025 13:08:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbMR-0000fg-DY; Tue, 01 Apr 2025 13:08:59 +0000 Received: by outflank-mailman (input) for mailman id 934111; Tue, 01 Apr 2025 13:08:58 +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 1tzbMQ-0000Od-8w for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:08:58 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7787ab51-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:08:56 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5e5e0caa151so10451659a12.0 for ; Tue, 01 Apr 2025 06:08:56 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5edc17dfe1dsm7009781a12.69.2025.04.01.06.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:54 -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: 7787ab51-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512935; x=1744117735; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iNjc/wja0hxlH+2aMQfRdD42ULkgPnjmDI4A0WYPe2E=; b=bXvlFdocO5yNuYroTWHqc48h/QWhoBA4lDGkA/sf3ssLH7ZUwfIZVG6T3pgTT8Bl2D U2ThE9KZUqK9PJPtj9DjDJlUCrqqB51PRORbh8vr/zfyI3mXi+fBpEfxtM3W1+sEsfYb TvYCZMv6+kcJHVh4E2ryoTIJTC7zSKRfpvh6k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512935; x=1744117735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iNjc/wja0hxlH+2aMQfRdD42ULkgPnjmDI4A0WYPe2E=; b=U+W6/v0CS0cn+vWwQUSqvcRyY/Ju61UmD4cZo30OAgNPbNw7QdnLBAP9ey+6OnpchN BmPqBVVJEUDkyyt5R/AFN4JGKT6qwc22zo73ixGZ5XzniQbDQgBx9Q5MQVVJyDFiDLDk UwfBlhqSBHbuVd92aGtpQU+cUVzS2cuGE0LLTr8PXbamRDuBpwltp5s/dLUP3AJP1aoH 1Xo1onKxXoASKI2NmczXnMEkQxiIhmssp38nXPKmWRs1B2s43M74PsinO7ncrpuLs3XC YwnuzocLMY1/bMUtkqNtCrLCOO8N1KzUWZZYkzKHkb0+6zXZ1A/QpxtQ5xHAFU2/lqhm 6DlQ== X-Gm-Message-State: AOJu0YxDh+MY/KCAppIdU2IvuE+YxSx6kUWVwrk/qtJvK/JB8Nl/+m8O 7D4czhRK3khU5ykFOOFmwdcqn65S8ThUW6d0ayOGD8mnWA5M1ymig6WV5PPEfJb/h1UCeVcfelk 6 X-Gm-Gg: ASbGncsFRqLPx+qktkkdZarVPSFvtkGVkrQVGhTAdXVUPriENjmrvGAh0HnbMDIv3lJ OM7O2QBqKK3ebaqmdFocKbp5eiSiZmbRj5f1wYHNp9ViQTDdDmWfXjrmvGXi9mzeYJimGD4fmtg 8QWWUygSzxCEK0fqwLSqKGnV8m2/2+jc8xLa8CHbvLYAb4hlA1tulQDQDC0l5BukTmdUROJyIFO SP5TssTK0kkeyQ4eR7+qd+dUtuLS88NqpW0+2nuLQzp0HkfXWsb+WIO+srVlCOfjJN5OAaF3CmW uiNN70kBXP4Fg5HOCWtF+ot16VODszvgmChtcW5pG7Lg0pZ5Yw== X-Google-Smtp-Source: AGHT+IEbNjBBsUGdEZiCoaAKgdqxjc289hgYwwv3U8wReSm/CSYqDlTS21ANBN4YU43+aDtmHqTlGA== X-Received: by 2002:a05:6402:2709:b0:5e5:ca1b:c425 with SMTP id 4fb4d7f45d1cf-5edfd101725mr11186425a12.17.1743512935025; Tue, 01 Apr 2025 06:08:55 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , "Daniel P. Smith" , =?utf-8?q?Marek_Marczykow?= =?utf-8?q?ski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper Subject: [PATCH v2 03/11] x86/mkreloc: use the string table to get names Date: Tue, 1 Apr 2025 15:08:32 +0200 Message-ID: <20250401130840.72119-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 When using PE format names greater than 8 characters are placed in the string table, and a reference using the '/' format is placed in the name field. Read the string table if present, and decode names as required. No functional change intended, but the name references printed in error messages are now human readable: Warning: relocation to r/o section /4:00042d43 Becomes: Warning: relocation to r/o section .init.text:000446c3 Note the introduced helper to print names relies on a static internal buffer to make sure the returned string are always null terminated. This is enough for the current use-case, but if the returned value is to stay valid between calls the current static buffer won't work as expected. Signed-off-by: Roger Pau Monné --- xen/arch/x86/efi/mkreloc.c | 69 +++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/efi/mkreloc.c b/xen/arch/x86/efi/mkreloc.c index 1a6cfc845cba..cc106bd875ba 100644 --- a/xen/arch/x86/efi/mkreloc.c +++ b/xen/arch/x86/efi/mkreloc.c @@ -17,6 +17,12 @@ #define PE_BASE_RELOC_HIGHLOW 3 #define PE_BASE_RELOC_DIR64 10 +/* The size of a symbol table entry is always 18 bytes. */ +#define SYM_SIZE 18 + +const char *string_table; +unsigned int string_table_size; + static void usage(const char *cmd, int rc) { fprintf(rc ? stderr : stdout, @@ -25,6 +31,28 @@ static void usage(const char *cmd, int rc) exit(rc); } +const char *get_name(const char *name) +{ + static char buffer[sizeof(((struct section_header *)NULL)->name) + 1] = {}; + unsigned long offset; + + if ( name[0] != '/' ) + { + /* + * Use a temporary buffer in case the name is 8 characters long, as + * then there's no terminating null character in the input string. + */ + strncpy(buffer, name, sizeof(buffer) - 1); + return buffer; + } + + offset = strtoul(&name[1], NULL, 10); + if ( !string_table || offset < 4 || offset >= string_table_size ) + return name; + + return &string_table[offset - 4]; +} + static unsigned int load(const char *name, int *handle, struct section_header **sections, uint_fast64_t *image_base, @@ -83,6 +111,31 @@ static unsigned int load(const char *name, int *handle, exit(3); } + if ( !string_table && pe_hdr.symbol_table ) + { + char *strings; + + if ( lseek(in, pe_hdr.symbol_table + pe_hdr.symbols * SYM_SIZE, + SEEK_SET) < 0 || + read(in, &string_table_size, sizeof(string_table_size)) != + sizeof(string_table_size) ) + { + perror(name); + exit(3); + } + + string_table_size -= sizeof(string_table_size); + strings = malloc(string_table_size); + + if ( read(in, strings, string_table_size) != string_table_size ) + { + perror(name); + exit(3); + } + + string_table = strings; + } + *sections = malloc(pe_hdr.sections * sizeof(**sections)); if ( !*sections ) { @@ -173,8 +226,8 @@ static void diff_sections(const unsigned char *ptr1, const unsigned char *ptr2, if ( i < disp || i + width - disp > sec->raw_data_size ) { fprintf(stderr, - "Bogus difference at %.8s:%08" PRIxFAST32 "\n", - sec->name, i); + "Bogus difference at %s:%08" PRIxFAST32 "\n", + get_name(sec->name), i); exit(3); } @@ -184,9 +237,9 @@ static void diff_sections(const unsigned char *ptr1, const unsigned char *ptr2, if ( delta != diff ) { fprintf(stderr, - "Difference at %.8s:%08" PRIxFAST32 " is %#" PRIxFAST64 + "Difference at %s:%08" PRIxFAST32 " is %#" PRIxFAST64 " (expected %#" PRIxFAST64 ")\n", - sec->name, i - disp, delta, diff); + get_name(sec->name), i - disp, delta, diff); continue; } if ( width == 8 && (val1.u64 < base || val1.u64 > end) ) @@ -210,15 +263,15 @@ static void diff_sections(const unsigned char *ptr1, const unsigned char *ptr2, else if ( rva != cur_rva ) { fprintf(stderr, - "Cannot handle decreasing RVA (at %.8s:%08" PRIxFAST32 ")\n", - sec->name, i - disp); + "Cannot handle decreasing RVA (at %s:%08" PRIxFAST32 ")\n", + get_name(sec->name), i - disp); exit(3); } if ( !(sec->flags & IMAGE_SCN_MEM_WRITE) ) fprintf(stderr, - "Warning: relocation to r/o section %.8s:%08" PRIxFAST32 "\n", - sec->name, i - disp); + "Warning: relocation to r/o section %s:%08" PRIxFAST32 "\n", + get_name(sec->name), i - disp); printf("\t.word (%u << 12) | 0x%03" PRIxFAST32 "\n", reloc, sec->rva + i - disp - rva); From patchwork Tue Apr 1 13:08:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034825 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 D913AC3601E for ; Tue, 1 Apr 2025 13:09:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934113.1335946 (Exim 4.92) (envelope-from ) id 1tzbMT-0001B7-BB; Tue, 01 Apr 2025 13:09:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934113.1335946; Tue, 01 Apr 2025 13:09: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 1tzbMT-0001AK-6t; Tue, 01 Apr 2025 13:09:01 +0000 Received: by outflank-mailman (input) for mailman id 934113; Tue, 01 Apr 2025 13:08:59 +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 1tzbMR-0000Od-9G for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:08:59 +0000 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [2a00:1450:4864:20::535]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 78222bfe-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:08:57 +0200 (CEST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-5eb92df4fcbso10046686a12.0 for ; Tue, 01 Apr 2025 06:08:57 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5edc16aae9esm7227853a12.11.2025.04.01.06.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:55 -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: 78222bfe-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512936; x=1744117736; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6J5IWMe9fuG9cz0NbV8d3wevTadFVymZS2btgRyX9fc=; b=E1z28gwBLqGYK9HtjIdkgSxq5pBONngrJu1ubGuZsPiJlWs9XZlIRv9wHrHFRygPZ2 LctCd+SsPSv2frdWb/3SYOZq2nbifRJZgRLnN19Ql6WsBBYRQ/MGkq8g2y4yuAEVkz4o N/UDrjwKl5BqxRFZaww11LJrboolLH8fBFhbA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512936; x=1744117736; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6J5IWMe9fuG9cz0NbV8d3wevTadFVymZS2btgRyX9fc=; b=Z6YNc/5SOCm9XSu2jiU6TofpDp/rxG4lX/wdvJn3637GjkFFaxiO0xeX+wmt6IO5ap 7l4Q5HyuxU61MVmIqgsC57eg0g0TTfpJpy3pSKjHigMr5hZmKerQisr9hAi0PcsMPTlX 2IdgRTHC7A1ag6RcuuJIJ1AArACA+1hT4Gi/ScqjOZqDSNafpemlC/yrA/iBCdfB8+L5 yhwiKXA5P9fVy+W3ZjVT5Hn6fCCI860o6vRmk+lRU8ziEpAr2oeB2i/5gYxDFTWFcomJ 2yp2SSGEHTrWMkvXtZGZv5N244NFTol6UYC+nBjrBFHD04+IlHTzRlej069cFQe+I1p7 qIgg== X-Gm-Message-State: AOJu0Yxfb3Anqsj0ku7C1TWo9dXw9YttheO4Wd+MC6iqR28yWAVwU4lq 7sKxnBLx2DJaZSivBoLhnPSQAaJmym9D9U9rBCIpyHhRHmO8QbBYwJp46uwZhZLzJ3SbmGDaDum L X-Gm-Gg: ASbGncsJmL4RlXPTbrj4zc1zaENzUyihkIlpX7uhS45vXHxJHIagwO5nPLG0dlyObxo fM94mK6dq/BnzyDbu2u0t4ocbF3qdAVVtDyH8VCvWYuLiZi/lhkKmz44DT8E6Kundi5x7hRVg2l XNRvBLN4qpStNRyi9wnpPses4m3eC8FG8Ul4UVDezRi7h3IP3SMDUsr9eAU++MGvrS39ODJO80i QY5kdgogeYl/sPvVA28Jv8dzj/k8c2lCSL9xPOtROXeJ0SJEMN4uEyw1KQmiVf+vjLCOzlADzZ1 rYVIiY4mRDxTeTzvC3zwgfk06+oS/FCAf2/H+flTnoD8iLVW9OOhAusvepXX X-Google-Smtp-Source: AGHT+IFlaBZQNfY0LTeE/fILoefvlfJB50Sqda8agd9IG5gVxT9iBNOHCfoQMcaMzWfevyEFGUdD9Q== X-Received: by 2002:a05:6402:24a4:b0:5e7:8501:8c86 with SMTP id 4fb4d7f45d1cf-5edfd6fdbdemr12939174a12.22.1743512936181; Tue, 01 Apr 2025 06:08:56 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , "Daniel P. Smith" , =?utf-8?q?Marek_Marczykow?= =?utf-8?q?ski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper Subject: [PATCH v2 04/11] x86/mkreloc: print the linear address of relocations to read-only sections Date: Tue, 1 Apr 2025 15:08:33 +0200 Message-ID: <20250401130840.72119-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 Expand the warning message about relocations generated against read-only sections, so it also contains the linear address of the offending relocation, like: Warning: relocation to r/o section .text:00000048 @ 0xffff82d040200048 Signed-off-by: Roger Pau Monné --- xen/arch/x86/efi/mkreloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/efi/mkreloc.c b/xen/arch/x86/efi/mkreloc.c index cc106bd875ba..fa50314ae945 100644 --- a/xen/arch/x86/efi/mkreloc.c +++ b/xen/arch/x86/efi/mkreloc.c @@ -270,8 +270,9 @@ static void diff_sections(const unsigned char *ptr1, const unsigned char *ptr2, if ( !(sec->flags & IMAGE_SCN_MEM_WRITE) ) fprintf(stderr, - "Warning: relocation to r/o section %s:%08" PRIxFAST32 "\n", - get_name(sec->name), i - disp); + "Warning: relocation to r/o section %s:%08" PRIxFAST32 " @ %p\n", + get_name(sec->name), i - disp, + (void *)(base + sec->rva + i - disp)); printf("\t.word (%u << 12) | 0x%03" PRIxFAST32 "\n", reloc, sec->rva + i - disp - rva); From patchwork Tue Apr 1 13:08:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034823 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 4610CC36018 for ; Tue, 1 Apr 2025 13:09:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934112.1335931 (Exim 4.92) (envelope-from ) id 1tzbMR-0000j2-TU; Tue, 01 Apr 2025 13:08:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934112.1335931; Tue, 01 Apr 2025 13:08:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbMR-0000iG-N3; Tue, 01 Apr 2025 13:08:59 +0000 Received: by outflank-mailman (input) for mailman id 934112; Tue, 01 Apr 2025 13:08:58 +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 1tzbMQ-0008KU-J8 for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:08:58 +0000 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [2a00:1450:4864:20::530]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 78e5185f-0efa-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 15:08:58 +0200 (CEST) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5e66407963fso10569369a12.2 for ; Tue, 01 Apr 2025 06:08:58 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5edc16d38e3sm7060814a12.24.2025.04.01.06.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:57 -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: 78e5185f-0efa-11f0-9ea7-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512937; x=1744117737; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jfWLQG6h7frzFHFbSmMTlSLAtyeTFMN2ST7SsEhdNzA=; b=UsP4WOptdov6oxd3WY8aRQ9XNQo5MA98OlOCErowTJONQbpCGdj778+wbAbk3P9EO1 ehw0tJ36hEA2+XbZavFByRk2TdlAClZ3nnD80jDAKHNd0ctphwMCRTVpq42B/DWjojy+ jo/uf4gMvk/2zuIKVbPjhf3u4KFj+IoxQ6z4c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512937; x=1744117737; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jfWLQG6h7frzFHFbSmMTlSLAtyeTFMN2ST7SsEhdNzA=; b=n79ZsNyUzEMKdh/hRJLKG3n6eEkhvakiamVZv6AQ/mmSaTSqVBcRVCrFWKvZ5m9nOf J2eR9d9cdwWYOWGaTf0Qc4LXb8rhGnt5+rTMhxqNxA558cPwjt8T1QCxjDD9bEnm70yT W7qRLNGqQXVjw/Ji9LhkbPYfI3PtO71XQQsdO6zB68Y4bjnl1mDi5MEDnBKPY4otnr32 ZCPVhOodISkj6B9tAIB2sil9JBR3Ov+eUpOVvt92Kj60/LS1onFE1c+cnn3Hyilmp6oI iINhholYqVHhKIHJmvdfujc3/K4rErdfVFrtQ3UqgGayRkfedwwTX3QzYMxbwvtrQat+ /Gng== X-Gm-Message-State: AOJu0YwTbhG+bPLHsmNTW0OVBPufCQBvy6fTrw1Wu6kncQFfXHTNPPyk rctRiEkNwR32IOxkCbdBjrklk5R2Z/591zUl2UXU+JZ1VMziMTMt3aajeXC6XNt6pVNDpqJltHB 0 X-Gm-Gg: ASbGncug5Oh6PzBmg2wDgjouUFCvnGdEEwS8LFwzMpIn0efDRJvDrHpqhmtMzEnfqse v3Jtk8b0LQAy2b0mQgK1442ovej5i7mjFvF7o4nZQXvPA9EUSoWnizDwcbWPFXRiXrB2m6LHZPF jBfDdIV+GtFoZ3wq2fag8TszC5MpGem206Z7J8osZkqItKZXhkijrP43ujTGxklhDD2nVzLpHci Kn//oGTfnPnqcmx8wl94a62zzxQP8NEb0uis3rLhJ8XndcrC6EpK8rniXR6QE1nuv2slYKlrbp2 p9BUia5ZTxErD0H29StQvhwOkgatoFGFyGLoHT+N+MfWuqbG7hkdpFJFLXuI X-Google-Smtp-Source: AGHT+IFBCFclBJDg35uPgPPiBhTX81NYsoap5Pfs68kxM6wnIjcu3k+NCH+4yhuhaKAXVWCJOl7MEg== X-Received: by 2002:a05:6402:1d4d:b0:5ed:921a:ded6 with SMTP id 4fb4d7f45d1cf-5edfd1242ecmr11615211a12.18.1743512937276; Tue, 01 Apr 2025 06:08:57 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Shawn Anastasio , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Jan Beulich , Andrew Cooper Subject: [PATCH v2 05/11] xen: remove -N from the linker command line Date: Tue, 1 Apr 2025 15:08:34 +0200 Message-ID: <20250401130840.72119-6-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 It's unclear why -N is being used in the first place. It was added by commit 4676bbf96dc8 back in 2002 without any justification. When building a PE image it's actually detrimental to forcefully set the .text section as writable. The GNU LD man page contains the following warning regarding the -N option: > Note: Although a writable text section is allowed for PE-COFF targets, it > does not conform to the format specification published by Microsoft. Remove the usage of -N uniformly on all architectures, assuming that the addition was simply done as a copy and paste of the original x86 linking rune. Signed-off-by: Roger Pau Monné Reviewed-by: Andrew Cooper Reviewed-by: Oleksii Kurochko Acked-by: Julien Grall --- xen/arch/arm/Makefile | 6 +++--- xen/arch/ppc/Makefile | 6 +++--- xen/arch/riscv/Makefile | 6 +++--- xen/arch/x86/Makefile | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 4837ad467a06..129a109d6ec5 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -97,19 +97,19 @@ ifeq ($(CONFIG_ARM_64),y) endif $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ diff --git a/xen/arch/ppc/Makefile b/xen/arch/ppc/Makefile index 655d212f6687..cf27bcebb25a 100644 --- a/xen/arch/ppc/Makefile +++ b/xen/arch/ppc/Makefile @@ -12,19 +12,19 @@ $(TARGET): $(TARGET)-syms cp -f $< $@ $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index b0c8270a9947..516f5d505ca8 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -16,19 +16,19 @@ $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< \ $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index f59c9665fdd0..c2f1dcf301d6 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -139,19 +139,19 @@ $(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(objtree)/common/symbols-dummy.o -o $(dot-target).0 $(NM) -pa --format=sysv $(dot-target).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).0.S $(MAKE) $(build)=$(@D) $(dot-target).0.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(dot-target).0.o -o $(dot-target).1 $(NM) -pa --format=sysv $(dot-target).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ > $(dot-target).1.S $(MAKE) $(build)=$(@D) $(dot-target).1.o - $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds -N $< $(build_id_linker) \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(orphan-handling-y) $(dot-target).1.o -o $@ $(NM) -pa --format=sysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ @@ -212,7 +212,7 @@ ifeq ($(CONFIG_DEBUG_INFO),y) $(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "Will strip debug info from $(@F)" endif $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ - $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds -N $< $(relocs-dummy) \ + $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< $(relocs-dummy) \ $(objtree)/common/symbols-dummy.o $(note_file_option) \ -o $(dot-target).$(base).0 &&) : $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(dot-target).$(base).0) \ @@ -222,7 +222,7 @@ endif > $(dot-target).0s.S $(MAKE) $(build)=$(@D) .$(@F).0r.o .$(@F).0s.o $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ - $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds -N $< \ + $(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< \ $(dot-target).0r.o $(dot-target).0s.o $(note_file_option) \ -o $(dot-target).$(base).1 &&) : $(MKRELOC) $(foreach base,$(VIRT_BASE) $(ALT_BASE),$(dot-target).$(base).1) \ @@ -231,7 +231,7 @@ endif | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).1s.S $(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o - $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds -N $< \ + $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \ $(dot-target).1r.o $(dot-target).1s.o $(orphan-handling-y) \ $(note_file_option) -o $@ $(NM) -pa --format=sysv $@ \ From patchwork Tue Apr 1 13:08:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034824 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 903E7C36014 for ; Tue, 1 Apr 2025 13:09:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934116.1335965 (Exim 4.92) (envelope-from ) id 1tzbMV-0001e0-4j; Tue, 01 Apr 2025 13:09:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934116.1335965; Tue, 01 Apr 2025 13:09:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbMU-0001be-VP; Tue, 01 Apr 2025 13:09:02 +0000 Received: by outflank-mailman (input) for mailman id 934116; Tue, 01 Apr 2025 13:09:01 +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 1tzbMT-0000Od-9s for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:01 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 79a8e624-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:08:59 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-ac339f53df9so982517566b.1 for ; Tue, 01 Apr 2025 06:08:59 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac71961f0e9sm766309366b.101.2025.04.01.06.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08: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: 79a8e624-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512939; x=1744117739; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Eaji7nWfNm9j69tZV5bRL2oO0fL1lVBczAnwU7AW6j8=; b=Ty5wJy1ey/X8Hh+lhVbhCdO2jqlU4i2iinCjw0NVNgGwLDPJ02YNG/afzjuJFNbJ28 Cv9ab+fkbKA7/iV4S6Vvo2XwYZLszMwl++KBwZjp3zq+j56sFi1g7w+VnaXgfWql0HiE dcW2Ft5h2T6vPSnQ8eZCiYlRGc02yhKSWQebI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512939; x=1744117739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Eaji7nWfNm9j69tZV5bRL2oO0fL1lVBczAnwU7AW6j8=; b=J7far2vTxLEKL/4GujufO6JGwl9b97RE7XHaYmQBgZVs5ZFeXNuT72xfaEHcDnajz3 QXHMX2L3n+/tXo+LsENF1+U5yVs/AHQnz39xMz6/fMD78kgxHAalxm8VMYrH4t36CrC6 gy7+MX6JPMK0MzTxrsTaqxrG2MEm0pVLj9LORdMwymEA5aoTLKsOxnAW2wH9REnCmXTg n4PfaqGA6oe2GecBoNd9vKGREU71tL7/j+5J4Dmux+5uKa8fu02pf5hd+GYpC/0KVuG5 qD/Ijr9gMRGDFVu1pYZK+VHRm8mQbAxPV03EubBjKCvfRsknxKbd75AkRRN5ktTt+JaO t+og== X-Gm-Message-State: AOJu0YyYn4bTnUu6+WfVMTL6QWoF7AZmWG3MdOYfzR+tcuXB3CqWIhUX IbM/FScS4/Jut3W4OiWTZHRdROxWQArTMkK/LkNSZ25U9cf6FJSmnAhXhRlEOLsbPCY08tL8UCz 8 X-Gm-Gg: ASbGncuCPFIo1HwtLjgL/X/ifS2kuW/TujW6cE5zvVAtydX54Sp1GFBg4QYT+ArdLGH FJlnNxjX992BMoCaiVlikhI2nJTLsZE1eDQxJ7OLj8RNdU/tZNQ9o0vILFdrfIpJe3dOd7LfGgy M2Usc1W0jySuiJtnRuxXC8ATy5xwrqHq4o+vIHhb/JMoPy5kNp0flEoTX9tDnXuArBfKN/lKd3M KF776EGeQFJNVusYyWX6C6JH0vw74X8y3VLUYvUEryr52Z3a+5oB33elQGgPpMBgIisz3NEKHdT 7ZJhTdVasAI14136NAacj6n0q3eOeV5iVCA+l9uis2HI5KEGVTmWcRFlc+M9 X-Google-Smtp-Source: AGHT+IFEAYGnrYThDPAMGzjbZHMr1I7RawUz/d9U/DPxyEPsI8rXQHzi8rJZZziXUhur4LUgDCyORg== X-Received: by 2002:a17:907:3f09:b0:ac3:ec70:18ae with SMTP id a640c23a62f3a-ac73897605dmr1150923666b.3.1743512938462; Tue, 01 Apr 2025 06:08:58 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v2 06/11] x86/efi: discard .text.header for PE binary Date: Tue, 1 Apr 2025 15:08:35 +0200 Message-ID: <20250401130840.72119-7-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 The multiboot headers are not consumed in the PE binary, hence discard them in the linker script when doing a PE build. That removes some relocations that otherwise appear due to the usage of the start and __efi64_mb2_start symbols in the multiboot2 header. No functional change intended. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- We could also place the multiboot header in it's own isolated section and skip such section for relocations generation in mkreloc, but it seems best to just remove the code if it's unused. --- xen/arch/x86/xen.lds.S | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index d4dd6434c466..ad908539f38a 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -61,6 +61,9 @@ SECTIONS __image_base__ = .; #else . = __image_base__; + /DISCARD/ : { + *(.text.header) + } #endif #if 0 From patchwork Tue Apr 1 13:08:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034821 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 CA23DC3601C for ; Tue, 1 Apr 2025 13:09:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934115.1335952 (Exim 4.92) (envelope-from ) id 1tzbMT-0001FH-PZ; Tue, 01 Apr 2025 13:09:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934115.1335952; Tue, 01 Apr 2025 13:09: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 1tzbMT-0001Do-J8; Tue, 01 Apr 2025 13:09:01 +0000 Received: by outflank-mailman (input) for mailman id 934115; Tue, 01 Apr 2025 13:09:01 +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 1tzbMT-0008KU-0K for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:01 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7a42de4d-0efa-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 15:09:00 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-ac2a089fbbdso991083966b.1 for ; Tue, 01 Apr 2025 06:09:00 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac71961f9b9sm761161266b.114.2025.04.01.06.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:08:59 -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: 7a42de4d-0efa-11f0-9ea7-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512940; x=1744117740; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EPf0H0iWY3C1zaNGO1+8PzDu8ltCUQ9Xi40SfByzm4E=; b=K8UwQuVbMzyrzUXvk2qATMdJKPjMEWnpIfMw67Xnr+gmVqQYDulAd1LCY39VZfQbNx yuIela0a++A9gmIrfNFb7cyK+Th1NaoqVtoRO9nfE8fLYtgrOkJh4nkUVmdY/WONkhj6 3s80bTl517LlLwGTvzozHo9MpmAdV6W4otF0o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512940; x=1744117740; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EPf0H0iWY3C1zaNGO1+8PzDu8ltCUQ9Xi40SfByzm4E=; b=a27K0dLBHNtozf7oyLJjotsUyu6LFwZMgXCYE1Qh7/XGmAuEUZGFFdCNIoPVPI9+8o U2AD3wzBFl/BELrrvlDapOhvUdvhAYIJburuRDdMdlQ4rxjWcye8l3Yll8ej79jwiGOg eFbg+A3mgtJTTuLPpsy0LIqmv/g0FMaKOWv8dXZ8rZSxbIPQfgqBjHVkcfdQHPLPZpS1 BwDkiJWLRA00EUUFuwy5iYYn3+9pRXLwcK+XKoqNTUEV1tkHUY9Tgt2B6+Y5mKx2CgR1 Wos4/7MpqzkCD/pXuKr+nFAw0GiHr3CIVcFEQ+W12uHRx/HgfFz5AF5BeHRp5VSEDICQ 3zxQ== X-Gm-Message-State: AOJu0YwULyxcufj97cjfrcnpCfCgXE2uCpTVsIWt7xZZH/BsAJDMl0f3 AFdijWPJWbDPV8A3ZeCjQi88A/z7QtL7HWF9BegAuGhOILLTC9Y4hFl1NAWP2nohwTwiL99yZys 2 X-Gm-Gg: ASbGnctUAr79TCkHC4H5yHX7DFVpY3w0GgT/5tHrk+1dF+ewgkteC0XD8GBoERoAip8 VYawBmohJ3ODrvJ1htdCuLzwtPQymNH3Pvc2S8M+5F3B1O5HI2bhGhrsV4z8eS0ITW+BcUENNbJ hRCprbrK6EOgVANnhbR0LJMJz3XJ5pyAdP/RJtGfrq9nxMkxpmsh2/LhKVCXHcsNgyve2fELsE6 ZtpNjADJvXJlOR81H+rhO4GmIYvhSTTG0bDl5oUz78LhNwcQ1uufh9ofpZ9xA11OwEAOxQQFY9g LDmEqeUYUtfEju655bysTNR4NZDuKV9kL4HEYiW6OXPf8bum1g== X-Google-Smtp-Source: AGHT+IHY/qPLexqKDJxO4g24fcXOb0HmgauV7SPAPnQfLmH6qR3xT3USyAbirTGkx2VpSSrw64zi3w== X-Received: by 2002:a17:907:1c97:b0:ac6:e42a:fb4c with SMTP id a640c23a62f3a-ac71ec04f5cmr1466839766b.9.1743512939707; Tue, 01 Apr 2025 06:08:59 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v2 07/11] x86/efi: discard multiboot related entry code for PE binary Date: Tue, 1 Apr 2025 15:08:36 +0200 Message-ID: <20250401130840.72119-8-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 The multiboot and PVH entry points are not used in the PE binary, hence discard them in the linker script when doing a PE build. That removes some relocations that otherwise appear due to the entry point code in head.S not being position independent. No functional change intended. Signed-off-by: Roger Pau Monné Reviewed-by: Jan Beulich --- We could also place the entry points in it's own isolated section and skip such section for relocations generation in mkreloc, but it seems best to just remove the code if it's unused. --- xen/arch/x86/boot/head.S | 3 ++- xen/arch/x86/xen.lds.S | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 81473578fe84..774894954e44 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -151,7 +151,7 @@ vga_text_buffer: efi_platform: .byte 0 - .section .init.text, "ax", @progbits + .section .init.multiboot, "ax", @progbits early_error: /* Here to improve the disassembly. */ @@ -709,6 +709,7 @@ trampoline_setup: /* Jump into the relocated trampoline. */ lret + .section .init.text, "ax", @progbits ENTRY(trampoline_start) #include "trampoline.S" ENTRY(trampoline_end) diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index ad908539f38a..1191bf4e2ddd 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -63,6 +63,7 @@ SECTIONS . = __image_base__; /DISCARD/ : { *(.text.header) + *(.init.multiboot) } #endif @@ -208,6 +209,7 @@ SECTIONS _sinittext = .; *(.init.text) *(.text.startup) + *(.init.multiboot) _einittext = .; /* * Here are the replacement instructions. The linker sticks them From patchwork Tue Apr 1 13:08:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034828 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 2F551C36018 for ; Tue, 1 Apr 2025 13:12:22 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934201.1336007 (Exim 4.92) (envelope-from ) id 1tzbPb-0007h5-Fu; Tue, 01 Apr 2025 13:12:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934201.1336007; Tue, 01 Apr 2025 13:12:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbPb-0007gq-98; Tue, 01 Apr 2025 13:12:15 +0000 Received: by outflank-mailman (input) for mailman id 934201; Tue, 01 Apr 2025 13:12:13 +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 1tzbMY-0008KU-L5 for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:06 +0000 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [2a00:1450:4864:20::536]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7d87fe32-0efa-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 15:09:06 +0200 (CEST) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5edc07c777eso5614074a12.3 for ; Tue, 01 Apr 2025 06:09:06 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id 4fb4d7f45d1cf-5edc16d5077sm7044407a12.32.2025.04.01.06.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:09:00 -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: 7d87fe32-0efa-11f0-9ea7-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512945; x=1744117745; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TZxBOQSFyBxeOjrMoPK4/0WOsmdYg4n3s13OFZoBbPU=; b=YiCO8ulVsFFFvFuU6WtuBxTveEgQd1mmsQ7Hll5Tag/ki+HU/HC/WNSUfAkf2rMr7w ID1LngUaHVfoYuuel6vFaOyk+J3L9ZowlBcnDjWgo/ds+yeyKcYQdzGOPUWX6VpVkn7t 9rpNOkyDBya8ixHmoC2N3VxgmrpKyrKPrOMqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512945; x=1744117745; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TZxBOQSFyBxeOjrMoPK4/0WOsmdYg4n3s13OFZoBbPU=; b=Ix1qikTl+TAp15IxTHfCXJiChcaPweQwtml083pOjHjURqdIGjvizw316E38r8JqBa xMzlC08Dwh+9EU3FUuVM7tE0+0FkqIALSxlFQFI+rV4vFu5NRriBWQR6rlXXmtyLJwjQ sWe58UZsMavZaqO/UK/4EATF20JDYodPNmzIs8tavEcLesgoyu8PJOJFhMyy+4H4tOmo J/f7gep9oSMFUDmu8L1qbg78I2KJLJsEfk0r557v19L0oPKak9NccP8+HPZbVNWBQgbN M3+GHc93iivTguLGIt5LNexzqVJcw4Ux9Jym5PO+W+VBllVILY/ih3cZV3dm7OiAZPi0 DAoA== X-Gm-Message-State: AOJu0Yze5qh7NP083mgsmRpTAysleNpiNP5/jJJCG6LKWe2IBU9mCumG l2CzPfac4+7kKy7WA2z/wg9Nhv1rpFPtaBsvkNkgmrYT+nQL31ztSr0uSZUqXw5sYbfmn2Y90om X X-Gm-Gg: ASbGncurXRwsOHt+EE/NrpteXEIIZKndn6OWLC1jSuJtqKfMLIV80nNSUytLyPhWfmB I/B/Mr6sED+fcH5gqAvaJNTE3yL3ceiskyrIHo1g8A9QW851Gr8Ekx6ssdZW8F7G+Kug4E/vc/r S52PUNW2LZMYefeQ2voe8f+CY8+WJENwGRFoxZC+hoQAf5MNFv42g2+Gew+PP2r8XVmrWIAZQUg 40NWNJcM/mbxVoZL7P/WhYsiv+wq5Q8bViwlVmaWpl/1QBCpNGzmMvWbuXsnG1UvUrzsEukmLm2 P+FNXTgx1hvENKJOHn2lOZREVuAxHrWRnOFoICM6eL3WkihyNA== X-Google-Smtp-Source: AGHT+IE/BKGYvhgZRW5pouc3MtVys3s9WDTS+gmscGkaRwz0gTdBrRfVUs0dYAvq+MEuHWARTmvC6g== X-Received: by 2002:a05:6402:2b8b:b0:5ed:994c:7e75 with SMTP id 4fb4d7f45d1cf-5edfd9f7c9emr10260312a12.24.1743512940814; Tue, 01 Apr 2025 06:09:00 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v2 08/11] x86/boot: place trampoline code in a non-execute section Date: Tue, 1 Apr 2025 15:08:37 +0200 Message-ID: <20250401130840.72119-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 The trampoline code is never executed in the position placed by the loader. It's first copied to the low 1MB, and always executed from there. Move the trampoline code from being in .init.text section into .init.data, so it's not in an executable section. This allows applying the relocations safely against a non-executable (and thus non-read only) section, and then copy the relocated trampoline to the low 1MB. Note that the trampoline code is placed on an .init section, so zapped after boot has finished. No functional change intended. Signed-off-by: Roger Pau Monné --- An alternative approach is to apply the relocations after having copied the trampoline to the low 1MB, but that still generates relocations in mkreloc, which is not helpful for the goal of having no relocations applied to read-execute code sections. This approach however places code in a data section, which might cause issues when debugging it. --- xen/arch/x86/boot/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 774894954e44..f5a2d08d0d0e 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -709,7 +709,7 @@ trampoline_setup: /* Jump into the relocated trampoline. */ lret - .section .init.text, "ax", @progbits + .section .init.data, "aw", @progbits ENTRY(trampoline_start) #include "trampoline.S" ENTRY(trampoline_end) From patchwork Tue Apr 1 13:08:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034829 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 BF7AEC36014 for ; Tue, 1 Apr 2025 13:12:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934208.1336016 (Exim 4.92) (envelope-from ) id 1tzbPd-00084R-Ny; Tue, 01 Apr 2025 13:12:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934208.1336016; Tue, 01 Apr 2025 13:12:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbPd-000847-JP; Tue, 01 Apr 2025 13:12:17 +0000 Received: by outflank-mailman (input) for mailman id 934208; Tue, 01 Apr 2025 13:12:16 +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 1tzbMb-0000Od-JU for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:09 +0000 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [2a00:1450:4864:20::52c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7e3f2c1c-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:09:07 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5e5c7d6b96fso10198523a12.3 for ; Tue, 01 Apr 2025 06:09:07 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac71927b013sm774356166b.63.2025.04.01.06.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:09:06 -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: 7e3f2c1c-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512946; x=1744117746; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3Qwa4790XsBU40/HS4XW3tzOpxssCxzWLfWfhM2utiU=; b=BkvfiEE7gG+1K3C9XyJGMTrQg+FNHyl+MsDTN9zPCawRnuBV232J4lrMwk6eVzh4rS H+7kv35lKaHOCyl/b63ZMZznKXyQijbnk0Y+XMc90HWb47EcZfTpgx4DVcVKIgPDEhVv jN1ucFGRGeubeXmKUw5U8JulmsF5Y4Q6GPtkM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512946; x=1744117746; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Qwa4790XsBU40/HS4XW3tzOpxssCxzWLfWfhM2utiU=; b=JkLcV2X9wXb9WiDFg2cyJVwZdRcyyz43HQf8y6e4V3Z2U/i+vfsQoZZ4MgLYevCtxH wt+kSU00GI0e8ZsmCcwEazc7n4YswklEkK8j8+XSAwpdrF54mjlqu7iC4St8dKOGw0Bo oXXtipEdmjGaCWZ5mzVFz4o9M/Q1AIBajFZ1jRAZnU+XAOrbKDC0WtPFB1/SkenmmD+P A7ZuI1k7XP+x7y9aXwmJ3UHzcFRF5UEe9t/Og/S3h7lE5wnKKhevQtBsfpnncL1z+o0P VFwDXB1kf8pi8tzpbz2HaOPfsBlZhFGExPvF93M4k9h4A5zGzfRG86k1Xp7yesKbrVzL hcag== X-Gm-Message-State: AOJu0YwVg+sqoMl+t4bKwXrhwuhOtg75iNyx36VLZj6jaF7usj8IgGP+ phgve2XoA0dkQDwPRFQ5gNMUzUeVDlfTk9ViGcDMoFTk/FFB3iLBidL8mZacviV3+rrybMugqE9 R X-Gm-Gg: ASbGnct5LwZGfHkos4lixRAPMLV6dgb7RkvdwO+DL8B3IfLph9GX4IFcgQQ1w7+27v+ cV6kQ8SPaH10Z2B7AmRUFyyMVjaxWr7IREu8ehHshhYWQ0Ig8nqUxw9EM5AzVpvo1VSbcKH6TdY JymXxySlBO9T4e0RY4tUt3eMvpgO1uvvirQilWQ3XN/5ArRyrg7xSH1WXtYzwIX3j9TjlcSJWBs ZbJK8VwK/Er3+O4of2/Jhc+eezj4dNdWI9JB2juoFV/E9cKMwiEg3uGIVR78yxxzhoUcqnsoJ98 sK6j19PiMK65i7Apj3OrA2chAW5NXKpxiKpjVjMwisO0wyFDbiH+BPsyAftT X-Google-Smtp-Source: AGHT+IGaTL4+DNncckQbpL2w1mfIC0PN54mgxJ8UCHZmW+A0RvqhvxCvguiv22/squAYZqlGE4+Jag== X-Received: by 2002:a17:906:d551:b0:ac3:26ff:11a0 with SMTP id a640c23a62f3a-ac738bac990mr1068582266b.38.1743512946332; Tue, 01 Apr 2025 06:09:06 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , "Daniel P. Smith" , =?utf-8?q?Marek_Marczykow?= =?utf-8?q?ski-G=C3=B3recki?= , Jan Beulich , Andrew Cooper Subject: [PATCH v2 09/11] x86/efi: avoid a relocation in efi_arch_post_exit_boot() Date: Tue, 1 Apr 2025 15:08:38 +0200 Message-ID: <20250401130840.72119-10-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 Instead of using the absolute __start_xen address, calculate it as an offset from the current instruction pointer. The relocation would be problematic if the loader has acknowledged the Xen image section attributes, and mapped .init.text with just read and execute permissions. No functional change intended. Signed-off-by: Roger Pau Monné --- xen/arch/x86/efi/efi-boot.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 1d8902a9a724..c5cbf56cc0c4 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -266,7 +266,9 @@ static void __init noreturn efi_arch_post_exit_boot(void) /* Jump to higher mappings. */ "mov stack_start(%%rip), %%rsp\n\t" - "movabs $__start_xen, %[rip]\n\t" + "lea __start_xen(%%rip), %[rip]\n\t" + "add %[offset], %[rip]\n\t" + "push %[cs]\n\t" "push %[rip]\n\t" "lretq" @@ -274,7 +276,8 @@ static void __init noreturn efi_arch_post_exit_boot(void) [cr4] "+&r" (cr4) : [cr3] "r" (idle_pg_table), [cs] "i" (__HYPERVISOR_CS), - [ds] "r" (__HYPERVISOR_DS) + [ds] "r" (__HYPERVISOR_DS), + [offset] "r" (__XEN_VIRT_START - xen_phys_start) : "memory" ); unreachable(); } From patchwork Tue Apr 1 13:08:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034826 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 614FCC36010 for ; Tue, 1 Apr 2025 13:12:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934184.1335981 (Exim 4.92) (envelope-from ) id 1tzbPM-0006Uc-Qx; Tue, 01 Apr 2025 13:12:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934184.1335981; Tue, 01 Apr 2025 13:12:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbPM-0006TW-La; Tue, 01 Apr 2025 13:12:00 +0000 Received: by outflank-mailman (input) for mailman id 934184; Tue, 01 Apr 2025 13:11:59 +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 1tzbMf-0000Od-KR for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:13 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7f3c5ade-0efa-11f0-9ffb-bf95429c2676; Tue, 01 Apr 2025 15:09:08 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-ac2bdea5a38so907883266b.0 for ; Tue, 01 Apr 2025 06:09:08 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac719223e4dsm763101066b.24.2025.04.01.06.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:09:07 -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: 7f3c5ade-0efa-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512947; x=1744117747; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0LTQkhLhC9QAjpitQrbO7ny5f+6pVlhp14370Lqax5o=; b=t/Ui8srvOTYkPt3TB9gdcPzITc1WARf0mT4nefjh/e3Eoli69wcAxNIngVMCqiDtQa ORzg4Afr8dPi8omud4jaGXG2uZNXuFNfZHOLuFXkpzTVol8an2R2MQrd1hvknPoeXivs s0kVlhSaD5Lh/EUAFOEnkimpgLD/tHNft/dn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512947; x=1744117747; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0LTQkhLhC9QAjpitQrbO7ny5f+6pVlhp14370Lqax5o=; b=vt3uJi3o5fDoRyZyqpjOBg1wbmOtzY7LMaitmWXBjoML+30Cn48JzXIxjakwe88T0/ WR4CKwC3z2be2dsqWhu8QV9KHj8KJNA6MwS8J7aqImu+tXj6C7OISiIbten7J+ZrwwHN dt3C2SMmL29zruOXBaD5EzBmP83RgcRsAJ4jJjbpAkPlzq+fFU0fqeDCoD/YYs/fNJsT YlFCOnNIC19j6FY4s26+B/CIvQW/a2tpv1CwCXC6cB9c3tW9R7GGYy0BtAwqbobzjpVQ J+/ClvKvkF7b6Zb/r0RhmL/PcARMbZOJbEFKwsqxF/RZ5VsGjFckVYyruNC//1B3Hx8c CmXg== X-Gm-Message-State: AOJu0YwjvgSUuvvaGpnOxNVdU9MGhTk2PiRwIHm/JgOFpp+hVjpjGIG9 ztcpu+eBk6g7JkwV62NL5e9AjTAq0v/JuiizeJuTdvrpvGxGJUXk8cnBg8h0YsDxHHA1Tb5tUGS X X-Gm-Gg: ASbGncsAA8xddCIUju/A+HdGlY5P4BqAxVCijOKkDp2zlYgsMxYyNhyfB53t6bRar6Q NczaO6caqr4KpzFyNKGwa+wuljojoDamt0fJiS+milsMVTYznPqcPeN8BmPSa4YQTTieRBQ2wN/ TCri/B0iB0Cn+MtLGd0Apgp2AGDtmZ+Y95m7QyoP3BAKHP3TG4tUypas35+GFNl1GvdyWahgg+Q TxrO0gjqZoBY3Q29hxs+AAIgwkOO9q4kVtKod+k5kVcheb8Dvjdirmb9vwKd6MYCKnt5rCUdrlp XaSLaYA5ve/J9pWFMh3FD5Kzhg/Biu5YUFSN9Qd3ymsWBy2SCw== X-Google-Smtp-Source: AGHT+IG1AIAtLq4CiN9qMplBG9p/hjmatcs3t1KrHTBJAC7KcEg/Oo4Z4AuluQw1FWKNeNMhFndeBg== X-Received: by 2002:a17:907:97c2:b0:abf:63fa:43d4 with SMTP id a640c23a62f3a-ac738bbe89bmr1018652166b.44.1743512947558; Tue, 01 Apr 2025 06:09:07 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper Subject: [PATCH v2 10/11] x86/efi: do not merge all .init sections Date: Tue, 1 Apr 2025 15:08:39 +0200 Message-ID: <20250401130840.72119-11-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 As a result of having no relocations against text sections, there's no need for a single .init section that's read-write-execute, as .init.text is no longer modified. Remove the bodge and fallback to the layout used by ELF images with an .init.text and .init.data section. The resulting PE sections are: Sections: Idx Name Size VMA LMA File off Algn 0 .text 00193f6b ffff82d040200000 ffff82d040200000 00000480 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE 1 .rodata 0008a010 ffff82d040400000 ffff82d040400000 00194400 2**2 CONTENTS, ALLOC, LOAD, DATA 2 .buildid 00000035 ffff82d04048a010 ffff82d04048a010 0021e420 2**2 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 .init.text 00049e70 ffff82d040600000 ffff82d040600000 0021e460 2**2 CONTENTS, ALLOC, LOAD, READONLY, CODE 4 .init.data 000560a8 ffff82d040800000 ffff82d040800000 002682e0 2**2 CONTENTS, ALLOC, LOAD, DATA [...] Signed-off-by: Roger Pau Monné --- Changes since v1: - Align .init.text. - Clarify commit message. --- xen/arch/x86/xen.lds.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 1191bf4e2ddd..852aa135a76c 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -201,11 +201,7 @@ SECTIONS __2M_init_start = .; /* Start of 2M superpages, mapped RWX (boot only). */ . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - DECL_SECTION(.init) { -#else DECL_SECTION(.init.text) { -#endif _sinittext = .; *(.init.text) *(.text.startup) @@ -218,12 +214,15 @@ SECTIONS */ *(.altinstr_replacement) -#ifdef EFI /* EFI wants to merge all of .init.* ELF doesn't. */ - . = ALIGN(SMP_CACHE_BYTES); -#else } PHDR(text) - DECL_SECTION(.init.data) { +#ifdef EFI + /* + * Align to prevent the data section from re-using the tail of an RX mapping + * from the previous text section. + */ + . = ALIGN(SECTION_ALIGN); #endif + DECL_SECTION(.init.data) { *(.init.bss.stack_aligned) . = ALIGN(POINTER_ALIGN); From patchwork Tue Apr 1 13:08:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roger Pau Monne X-Patchwork-Id: 14034827 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 74DCAC36014 for ; Tue, 1 Apr 2025 13:12:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.934190.1335996 (Exim 4.92) (envelope-from ) id 1tzbPV-00074x-5X; Tue, 01 Apr 2025 13:12:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 934190.1335996; Tue, 01 Apr 2025 13:12:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tzbPV-00074q-24; Tue, 01 Apr 2025 13:12:09 +0000 Received: by outflank-mailman (input) for mailman id 934190; Tue, 01 Apr 2025 13:12:08 +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 1tzbMe-0008KU-BX for xen-devel@lists.xenproject.org; Tue, 01 Apr 2025 13:09:12 +0000 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [2a00:1450:4864:20::635]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 7fdb7702-0efa-11f0-9ea7-5ba50f476ded; Tue, 01 Apr 2025 15:09:10 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-ac29fd22163so926513066b.3 for ; Tue, 01 Apr 2025 06:09:09 -0700 (PDT) Received: from localhost ([84.78.159.3]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ac71927b7cfsm754553366b.49.2025.04.01.06.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 06:09:08 -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: 7fdb7702-0efa-11f0-9ea7-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1743512949; x=1744117749; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NMjGk2rTj1yEkoZ9b/TWFB91n+XjEue7/7KXBnaUhCc=; b=eiSNgyT0eOS3FieQZdky1f+9BRhQrxOKnQ7VP8FlX+hyyQADbPxb0bqEhX9kdW050R OJON/U1vHojc3kVREzLpS03v3OQq10aozH3JR6w+/dY0mbR7+1ga/OmzDNhomKHzOjJa rKEYTKqlu6kQuF2rLK9n6Mh62+pxMXl1oOdaw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743512949; x=1744117749; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NMjGk2rTj1yEkoZ9b/TWFB91n+XjEue7/7KXBnaUhCc=; b=g1YGYNxqKO946VpdjP5JezL1i6w3IaLDkHue74OoBopArXwKcW+r+HGH7oVqXkz+m5 iN4xzYTcTL5DQ/D6jQ6ShMR/bGEt+BZCJCNPQeYwJVSBTvmx/w866XFhXDuejPo5Pg3p L7ZtHsdDBfTKEX40dac6cZX6QM7810/0zId1JR3KLxIzgijI4RERQAZWeF+jph8xA9/c gkoj1NdXGh8l8ERmKofjKItiZPRAhX/kU+yuZSIO/OrNo89rX88OAtCKBGQJrJaVoOP5 3dm9h9P2YmBIgHlfGsF2l8jhND6K8iICAmZitTYeA2aUkrsnffxhl4lPrSKYgv5Wch0C YqCg== X-Gm-Message-State: AOJu0Yww7d1JdyAfg6N6lF06ojK+OcI5X3nRWsiJP2h9NxwSGcTdPUiY +QwlPEOEtDaO8wTUZmbjjZlBGJ+fwQrAtQ2ucxU96wRuLZQqvJSoVwtX5kIDoScFgbgxs7wP4Nx a X-Gm-Gg: ASbGnctdV94zyQs0k9VXpvGwCEKr/UmVAL/eq90fpnlkUZImxBDji1ozzkUeS+TiLze fUsyhJ0ANe6cTL2BLC5Wg26Sqpv9jiksYo2b4hRyT7okWGsZdB6Syz3vSTZf+LEQp1J7X/AgLCI P2K+rJhsNcbdRxVWseHLt6JCGjU1x6R3Ais6zhOaCZwuIhLWowKYl3ja3C6X95sfyis24xK87fo CjxcP8b0ny1Vd9ebpzfF+usZJ9rvHX8M8rOyvAGs+GdOVVibJdLchOwItnlCsI3f2Zyuja1NCW6 TDxZLv6coyyonqgwgVhjRZY2sFc4PKCwwFeHEyFWYD02ZdAiRw== X-Google-Smtp-Source: AGHT+IFCculQFVIsAPIfraVZnCR3LJEGuoFKSvhvYzJv0ILOugajihhVFyqaE+eW8Eh1agmb3b2qsQ== X-Received: by 2002:a17:906:7955:b0:abf:4bde:51b1 with SMTP id a640c23a62f3a-ac738a4bf32mr1077303566b.21.1743512948972; Tue, 01 Apr 2025 06:09:08 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Doug Goldstein , Stefano Stabellini Subject: [PATCH v2 11/11] automation/x86: add a xen.efi test with a strict NX OVMF build Date: Tue, 1 Apr 2025 15:08:40 +0200 Message-ID: <20250401130840.72119-12-roger.pau@citrix.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401130840.72119-1-roger.pau@citrix.com> References: <20250401130840.72119-1-roger.pau@citrix.com> MIME-Version: 1.0 Such OVMF build does honor the PE sections attributes, and will not blindly create all section mappings with read-write-execute permissions. Strict NX build is only available in the Fedora edk2-experimental package, so add the required dependencies to run a QEMU EFI job on the Fedora 41 container and use it for the test. Signed-off-by: Roger Pau Monné --- automation/build/fedora/41-x86_64.dockerfile | 5 +++++ automation/gitlab-ci/test.yaml | 9 ++++++++ automation/scripts/qemu-smoke-x86-64-efi.sh | 22 ++++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/automation/build/fedora/41-x86_64.dockerfile b/automation/build/fedora/41-x86_64.dockerfile index 8032a2098632..84f366ac0643 100644 --- a/automation/build/fedora/41-x86_64.dockerfile +++ b/automation/build/fedora/41-x86_64.dockerfile @@ -65,6 +65,11 @@ RUN <&1 | tee ${LOGFILE} + needs: + - debian-12-x86_64-gcc-debug + qemu-smoke-riscv64-gcc: extends: .qemu-riscv64 script: diff --git a/automation/scripts/qemu-smoke-x86-64-efi.sh b/automation/scripts/qemu-smoke-x86-64-efi.sh index 7572722be6e5..fbb662f1a756 100755 --- a/automation/scripts/qemu-smoke-x86-64-efi.sh +++ b/automation/scripts/qemu-smoke-x86-64-efi.sh @@ -4,6 +4,7 @@ set -ex -o pipefail # variant should be either pv or pvh variant=$1 +mode=$2 # Clone and build XTF git clone https://xenbits.xen.org/git-http/xtf.git @@ -14,6 +15,19 @@ case $variant in *) k=test-pv64-example extra= ;; esac +case $mode in + strict) + ovmf_code=/usr/share/edk2/experimental/OVMF_CODE_4M.secboot.strictnx.qcow2 + ovmf_vars=/usr/share/edk2/ovmf/OVMF_VARS_4M.qcow2 + ovmf_format=qcow2 + ;; + *) + ovmf_code=/usr/share/OVMF/OVMF_CODE.fd + ovmf_vars=/usr/share/OVMF/OVMF_VARS.fd + ovmf_format=raw + ;; +esac + mkdir -p boot-esp/EFI/BOOT cp binaries/xen.efi boot-esp/EFI/BOOT/BOOTX64.EFI cp xtf/tests/example/$k boot-esp/EFI/BOOT/kernel @@ -27,13 +41,13 @@ options=loglvl=all console=com1 noreboot console_timestamps=boot $extra kernel=kernel EOF -cp /usr/share/OVMF/OVMF_CODE.fd OVMF_CODE.fd -cp /usr/share/OVMF/OVMF_VARS.fd OVMF_VARS.fd +cp $ovmf_code OVMF_CODE.fd +cp $ovmf_vars OVMF_VARS.fd rm -f smoke.serial export TEST_CMD="qemu-system-x86_64 -nographic -M q35,kernel-irqchip=split \ - -drive if=pflash,format=raw,readonly=on,file=OVMF_CODE.fd \ - -drive if=pflash,format=raw,file=OVMF_VARS.fd \ + -drive if=pflash,format=${ovmf_format},readonly=on,file=OVMF_CODE.fd \ + -drive if=pflash,format=${ovmf_format},file=OVMF_VARS.fd \ -drive file=fat:rw:boot-esp,media=disk,index=0,format=raw \ -m 512 -monitor none -serial stdio"