From nobody Sat Apr 20 04:15:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678972977; cv=none; d=zohomail.com; s=zohoarc; b=eoDMHBGs7sHe8ZRIwBnfi9wR9fvh3RQfpop0hU2nWhDn3GuMYoWZvJQbLxtWoedwBwqTpObV/eMWUvjNW61/iuSW5gsKZAPOBnbwXFe7/xl9LYtmz/GTBQIaZ6FzyWwMqpXNb8kr1ZumzzAxL5T0/Ahi/j+WXud0vH3Fsg3uNXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678972977; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pxu23kp/Co+g/jvR7fkvKvV5XJ2nKBCMi+VMmTAzjTg=; b=bBo626/xwe8ujBWUxlVSg+hoXzAgJsArkToArohcIUPdg3P+BVSp+LPRlg7AXO/j6hiKJ1ieELsTTX8CjI3SgBI0XnBd8ygV8b9aqpETuyi/9cRk0zMmi/XkMDAXyoMakxdAkyivsNRgp5pCC+eeJyzcsw1DG2/ktwk6NirUXuo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678972977701965.1993020504141; Thu, 16 Mar 2023 06:22:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510592.788520 (Exim 4.92) (envelope-from ) id 1pcnYw-0004Kt-0k; Thu, 16 Mar 2023 13:22:34 +0000 Received: by outflank-mailman (output) from mailman id 510592.788520; Thu, 16 Mar 2023 13:22:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcnYv-0004KE-Qx; Thu, 16 Mar 2023 13:22:33 +0000 Received: by outflank-mailman (input) for mailman id 510592; Thu, 16 Mar 2023 13:22:32 +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 1pcnYu-0004I2-Gi for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 13:22:32 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9b296b40-c3fd-11ed-87f5-c1b5be75604c; Thu, 16 Mar 2023 14:22:31 +0100 (CET) Received: by mail-ed1-x52f.google.com with SMTP id z21so7622698edb.4 for ; Thu, 16 Mar 2023 06:22:31 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id u20-20020a50d514000000b004bd1fe2cc02sm3861728edi.16.2023.03.16.06.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 06:22:31 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9b296b40-c3fd-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678972951; 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=pxu23kp/Co+g/jvR7fkvKvV5XJ2nKBCMi+VMmTAzjTg=; b=JuPxK5JmZ1XRoZbrPERdvkj8ANr/IAYDVuqpN5+qXyxQdTva8B7XWJDBh1pzUIDn6o OpRYR+SG1QHl2ISi8A5iu35Sq1kXrBiMmQuqr5zjgMpUZR/7Y3AWr61A8Qxch6OT/F4P cwIzlcjZbva14tRb3s+NbKMxLMtNKFxym0QOv+Na3nAWqfsgk3u/e5p/KbuMdvWEGy7l 3RB+PZfl8b0n5++Ob+usOxRMTcihzFV5lcjokIhePN3QLniuic8FRk0dRAHVBOLv7e/J QzkJJ9O6J+9ILWouevK6BH0EmdDTY/YDMPFs4MiA49lUWKrDcSnaeGfZcTf9q5WDUST1 Pc/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678972951; 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=pxu23kp/Co+g/jvR7fkvKvV5XJ2nKBCMi+VMmTAzjTg=; b=ulNIgfogcbnsAsekADNl7NtKhYrs58GOqVHVyrFRSHZ6JeGPCcEIv0V1dOJ8ySwBVh U5fc4z/FZLli/DyLw5r6e0l/ENqu3H/ur42PWXIvgz9EphcW0KzV4jpC6DmL0sQp2nKt L8m6RFXlTSTwctbKvW2b64u/Pu1ZjOJvuYdV5ZyQC1YxtYYxEYYPNfu/B4M8K2j8jtNU i5QXD5bbCn+6GRHzXb0rnBJ+OCBYuwch1aaERKJcOA4pzU0BK6upndUMmTKkC9GYvWc+ YEPAjJxrVoPGRygVSKps85BbYhwgoKp4edHFPO2SBMdAgkXFUGb51VRcoIKRzE92HU6k ajUQ== X-Gm-Message-State: AO0yUKWWRebJ8botK9B1368yH39eiL6b6HwJIxuCavNnfedMeyxGZJQP ua3SPye6es3CklWDV9JKf93R5/aucb1I3w== X-Google-Smtp-Source: AK7set+wyuSBR8OMebkYVdgBkeDaNMzb/ir5HPfsX5t1/CNu9GwjIBms+Va+5nrDd8/IGyRXgpHryQ== X-Received: by 2002:a50:fe89:0:b0:4cf:c2f6:ca1 with SMTP id d9-20020a50fe89000000b004cfc2f60ca1mr6268399edt.1.1678972951339; Thu, 16 Mar 2023 06:22:31 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v2 1/2] xen/riscv: add EMBEDDED_EXTRA_CFLAGS to CFLAGS Date: Thu, 16 Mar 2023 15:22:24 +0200 Message-Id: <2785518800dce64fafb3096480a5ae4c4e026bcb.1678970065.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678972979351100004 Content-Type: text/plain; charset="utf-8" The patch is needed to keep all address of cpu0_boot_stack PC-relative. Pseudoinstruction 'la' can be transformed to 'auipc/addi' or 'auipc/l{w|d}'. It depends on the .option directive: nopic and pic or compiler flags. Right now, 'la' transforms to 'auipc/l{w|d}', which in case of cpu0_boot_stack[] will lead to the usage of _GLOBAL_OFFSET_TABLE_ where all addresses will be without counting that it might happen that linker address !=3D load address ( so addresses inside got sections will be relative to linker time ). It happens becuase the compiler from riscv64 docker compiled with --enable-default-pie: [user@49295ae49cbe build]$ riscv64-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=3Driscv64-linux-gnu-gcc COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/riscv64-linux-gnu/12.2.0/lto-wrapper Target: riscv64-linux-gnu Configured with: /build/riscv64-linux-gnu-gcc/src/gcc-12.2.0/configure --prefix=3D/usr --program-prefix=3Driscv64-linux-gnu- --with-local- prefix=3D/usr/riscv64-linux-gnu --with-sysroot=3D/usr/riscv64-linux-gnu -- with-build-sysroot=3D/usr/riscv64-linux-gnu --libdir=3D/usr/lib -- libexecdir=3D/usr/lib --target=3Driscv64-linux-gnu --host=3Dx86_64-pc-lin= ux- gnu --build=3Dx86_64-pc-linux-gnu --with-system-zlib --with-isl --with- linker-hash-style=3Dgnu --disable-nls --disable-libunwind-exceptions -- disable-libstdcxx-pch --disable-libssp --disable-multilib --disable- werror --enable-languages=3Dc,c++ --enable-shared --enable-threads=3Dposix --enable-__cxa_atexit --enable-clocale=3Dgnu --enable-gnu-unique-object - -enable-linker-build-id --enable-lto --enable-plugin --enable-install- libiberty --enable-gnu-indirect-function --enable-default-pie --enable- checking=3Drelease Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.0 (GCC) Looking at gcc spec file for the RISC-V architecture: [user@49295ae49cbe build]$ riscv64-linux-gnu-gcc -dumpspecs | grep -i pic --traditional-format %(subtarget_asm_debugging_spec) %{fno-pie|fno- PIE|fno-pic|fno-PIC:;:-fpic} %{march=3D*} %{mabi=3D*} %{mno-relax} %{mbig- endian} %{mlittle-endian} %(subtarget_asm_spec)%{misa-spec=3D*} which means that -fpic is enabled if none of the following options are present on the command line: -fno-pie -fno-PIE -fno-pic -fno-PIC That's the reasons why 'la' is transformed to 'aupic/l{w|d} GOT' and not be dependent on the toolchain used. Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis Acked-by: Andrew Cooper Reviewed-by: Jan Beulich --- Changes in V2: * instead of changing 'la' to 'lla' to keep cpu0_boot_stack PC-relative it was updated CFLAGS with EMBEDDED_EXTRA_CFLAGS which contains -fno-PIE thereby 'la' will be transformed to 'auipc/addi' without GOT usage. * update the commit message with additional details. --- xen/arch/riscv/arch.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/riscv/arch.mk b/xen/arch/riscv/arch.mk index 45fe858ee0..7448f759b4 100644 --- a/xen/arch/riscv/arch.mk +++ b/xen/arch/riscv/arch.mk @@ -1,6 +1,8 @@ ######################################## # RISCV-specific definitions =20 +$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) + CFLAGS-$(CONFIG_RISCV_64) +=3D -mabi=3Dlp64 =20 riscv-march-$(CONFIG_RISCV_ISA_RV64G) :=3D rv64g --=20 2.39.2 From nobody Sat Apr 20 04:15:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1678972978; cv=none; d=zohomail.com; s=zohoarc; b=NJF6tdIHkD8X7nkZkH4cVav5EL+IGdwmLzKfEuNKUHOYKRTKwbB/5VF2Z7ShKxKvVDrr6xe5c1zkEgoHp33cRKKVm4pzP2EWAKiZFQ9ahaz1cius+rzxTvrKvqGVB+SwbgSDFA+2I5aIt0MXVdIu5FeWuUb06Cb0miPceCltVXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678972978; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6IyJ7MXAQ+HTPg+dViNbR1hcc1rH6+rGQc4QTHNc1DY=; b=QfctRpLxogtwule1wV0+orNo4Ha9sNOEu1M1vSeSdMzrlwZsGFAX0weXRJhWR5GjJyeUGmrvC+TyVHDuGoFEaBD5WJnHSnPTPD0DijEi+ZX/Jwk92lnqNg+pfw4CcNW7paPgvZYcVZLvGYF7jkbPFNw/v2Iwe9q7i5g9In7sAq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1678972978217293.8122284076413; Thu, 16 Mar 2023 06:22:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.510593.788534 (Exim 4.92) (envelope-from ) id 1pcnYy-0004nY-Bu; Thu, 16 Mar 2023 13:22:36 +0000 Received: by outflank-mailman (output) from mailman id 510593.788534; Thu, 16 Mar 2023 13:22:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pcnYy-0004nP-7e; Thu, 16 Mar 2023 13:22:36 +0000 Received: by outflank-mailman (input) for mailman id 510593; Thu, 16 Mar 2023 13:22:35 +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 1pcnYx-0004ls-EO for xen-devel@lists.xenproject.org; Thu, 16 Mar 2023 13:22:35 +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 9c4a11b7-c3fd-11ed-b464-930f4c7d94ae; Thu, 16 Mar 2023 14:22:33 +0100 (CET) Received: by mail-ed1-x532.google.com with SMTP id ek18so7581830edb.6 for ; Thu, 16 Mar 2023 06:22:33 -0700 (PDT) Received: from fedora.. (46.204.101.131.nat.umts.dynamic.t-mobile.pl. [46.204.101.131]) by smtp.gmail.com with ESMTPSA id u20-20020a50d514000000b004bd1fe2cc02sm3861728edi.16.2023.03.16.06.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 06:22:32 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 9c4a11b7-c3fd-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678972953; 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=6IyJ7MXAQ+HTPg+dViNbR1hcc1rH6+rGQc4QTHNc1DY=; b=URkM0Vw7perMI/rpEQvsXvlwczqH+nO98aaalGr1PXPMqhJPAs3Pil44+hYR7QVFrq fGMMw6k3KmfeDx4L+qjF6HHU41jFUIx4f4pZVpjHJHWNbYWLXjSe2cwx3+RwMR9dalpG Y2JYYdfNhNNat0pB2fygUF/wWPdgeFDg6KLZ8Q6MEiK02twuzquPNCdV1MN8vScs++iD V/Ixs3e6efcAM+PxA05D8SkqWycVU6yI1gAFefta1D6B5q6xlw2aNYxhhSPf9ANvFI0n ivr12zEWvsXI1TVTikp27byuuSVv5r2I+rCJ39VtcxezfX23lAdH6YLV0xFGMA4n5kUs SAxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678972953; 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=6IyJ7MXAQ+HTPg+dViNbR1hcc1rH6+rGQc4QTHNc1DY=; b=yTtJ7Zd26+zU2NWeVVVPO0sMKfJyKYiuugWZ8VglcLFcIecWe92tAAWVZGv/9h7rA1 Mf76Vu9YYWYA9QRItwGzTwFBAQ3eN6I+TFAVeiemaZ0GiSeH9cX7FqPHg+THhzFX5G1z U1G4slkljdwxDz4HSxxhGgsl1RT2EJvDlnvOHYxlk7lDIkWOQ+VaySIIGY3x4r/4XIwL 0Fe0rb4IeSpVX9QUl5ZSI9L7sl1K0CFuQL4k3kNYJxlq3JtxhGz+E9Uc8BUuNLmpqxG8 pklASpuzWapkbhppMUushh9H53i+0G8Qf4v85+JJStJEpe3GyN/3aRd78k6XY399DFxi uvfQ== X-Gm-Message-State: AO0yUKVI5deaaXK0SWXLeNFKZGwHF4yYznTD2zC+x95d7Bvj7K/wJTmU NTX6db8faTYBmRnGP1IVFIAF0eRdQdN7lg== X-Google-Smtp-Source: AK7set9Llyn42OM3Ke9cC7KLN3s7QhJh5DZcryfjWp/tpI+E9/00mSNdDE0K7uNr08GDuhw0sxAl9A== X-Received: by 2002:aa7:c04f:0:b0:4fa:b302:84d0 with SMTP id k15-20020aa7c04f000000b004fab30284d0mr6618089edo.15.1678972952694; Thu, 16 Mar 2023 06:22:32 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Jan Beulich , Andrew Cooper , Stefano Stabellini , Gianluca Guida , Oleksii Kurochko , Bob Eshleman , Alistair Francis , Connor Davis Subject: [PATCH v2 2/2] xen/riscv: add explicit check that .got{.plt} is empty Date: Thu, 16 Mar 2023 15:22:25 +0200 Message-Id: <7c066d6dcc0618749df04785b34b93819148087d.1678970065.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1678972979203100001 Content-Type: text/plain; charset="utf-8" The GOT sections usage should be avoided in the hypervisor so to catch such use cases earlier when GOT things are produced the patch introduces .got and .got.plt sections and adds asserts that they're empty. The sections won't be created until they remain empty otherwise the asserts would cause early failure. Signed-off-by: Oleksii Kurochko Acked-by: Alistair Francis Acked-by: Andrew Cooper Reviewed-by: Jan Beulich --- Changes in V2: * the patch was introduced in patch series v2. --- xen/arch/riscv/xen.lds.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index ca57cce75c..f299ea8422 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -1,3 +1,4 @@ +#include #include =20 #undef ENTRY @@ -123,6 +124,15 @@ SECTIONS *(SORT(.init_array.*)) __ctors_end =3D .; } :text + + .got : { + *(.got) + } : text + + .got.plt : { + *(.got.plt) + } : text + . =3D ALIGN(POINTER_ALIGN); __init_end =3D .; =20 @@ -156,3 +166,6 @@ SECTIONS =20 ELF_DETAILS_SECTIONS } + +ASSERT(!SIZEOF(.got), ".got non-empty") +ASSERT(!SIZEOF(.got.plt), ".got.plt non-empty") --=20 2.39.2