From patchwork Wed Apr 27 17:12:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12829261 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 855B6C433EF for ; Wed, 27 Apr 2022 17:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=fjp7CSb6M+w10rdKw3sW1sTFbEvfcASa/CzLt9E2NQM=; b=nVxvtNMqszmqPY q7mpz5199iuqnTW4hjAY7wgmdufDroYybM0/G82RnUGloR8w2tMh9GZVcFqN8K0MFhTvIxqYiIeWG 4HzifhCGY7Cq862yHysjCr7QL69bzh8lFPVaL8R1kGG8RrUes521f0a+3OGtShryFSoBtD0j+dKBU PABj0MfC4UHjUVBNJH4uSVJIgB+QWbT3Al6TnSJVNVpjN+DqBZxyUsWS9TZkGQcbxI3vDfa37oqBU Ib0HErYPP/+cuGtWUZeVBfjREGbUxPs0WEOSbKOEVY4I14eIPOcwKot7FHsxUf/xlT8gFo+5MYNUy Cmz172QFAB4oRBhmtyjw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1njlQp-002eYT-3S; Wed, 27 Apr 2022 17:26:28 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1njlDp-002ZEe-Gl for linux-arm-kernel@lists.infradead.org; Wed, 27 Apr 2022 17:13:08 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 10BD561E1D; Wed, 27 Apr 2022 17:13:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F425C385A7; Wed, 27 Apr 2022 17:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651079580; bh=2+uVIDbxqseM+0bbq3rihBPe2pfIP/XzY2te3lRHOCY=; h=From:To:Cc:Subject:Date:From; b=esWlZmCugxqSyt+aP8vnqrkkLzL72aY9qZ63N+V/lY22zYJ8KosoBA5dzagXHvsKF OPI4S33Ov5x9SGpXFCQnH0A8ipKnuWzXGH5DEWjNgxNB8p/thsDE2dZVDcYjp0Wmrq STVw+0f+w3g8b8QZU+Ay5mlC9wJkOKS+l1iaTpCC9r6l0kjiHMB6TycAE2Hn00HtGR UJdFYpvRCi0RUoByR7q7Ni3kxWzQfH/g/BIPZTYMKktJO9U+OHcPaNfxNUToyzrJ3+ oSxSzW2R5Yq49dRcJJA87tPxgjBgEmvcoGh9vtqgwTfZhWBBBj0ENNVHPSmrDXosGD MdYkD7USPJ5Ug== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: clang-built-linux@googlegroups.com, will@kernel.org, catalin.marinas@arm.com, keescook@chromium.org, mark.rutland@arm.com, nathan@kernel.org, Ard Biesheuvel , Sami Tolvanen , Nick Desaulniers Subject: [RFC PATCH 0/2] arm64: use PIE code generation for KASLR kernel Date: Wed, 27 Apr 2022 19:12:39 +0200 Message-Id: <20220427171241.2426592-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1407; h=from:subject; bh=2+uVIDbxqseM+0bbq3rihBPe2pfIP/XzY2te3lRHOCY=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBiaXmEk7/gpTXe+HObrOm3yWT/Ws2wSrRK5dgpW2lx p/JW3RyJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYml5hAAKCRDDTyI5ktmPJNtWC/ 9gTv/uu7k3cSNZuQVX37dkdm/XZ+Blrx39Zt6l8pb4hMnFnZlduPdW/VmabMb4tA4sKOVZKocR/XTx in9SuZ22t4kedmZJuq0EsQqygPP+1uzIvJcpVPQAX4b/2eF6+kOuguvkFh/MLWUsObpjbYXpYVEB4U N0oKzFQ7xEg2n6Y0bYB7ERszdFHBUGTDCL+NOTIHLL7CC95Z6W4xfzkvVCZmGGSQxvz5tbUGHTjMz2 xm47HwdVcTu3uwWHPFaacD2MqHQpYWRMl46I5Qo9zgJowtTqUEk32xJIRuEPnKLhX5fvDfhziy0wN6 p2z+onOQv7oCZAtm/1dfaqkTFqQEpw0YUGGEoI1U0QsN6N1+Er9cSZqBL55i/EC1ICYoWmhyuac/9p shEl3lfwJi3JB4+jPSsblrImqzil1DLTpuGlH5DKuSEvKdQJ9lXs6wT1Y2EpVpljCzEwRmOXVHwYat AtVMhGHHLqSIXexHq4/H5JpfXDYWbSUgF1fNIKpCytMmk= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220427_101301_647399_555B91C4 X-CRM114-Status: GOOD ( 13.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Building the KASLR kernel without -fpie but linking it with -pie works in practice, but it is not something that is explicitly supported by the toolchains - it happens to work because the default 'small' code model used by both GCC and Clang relies mostly on ADRP+ADD/LDR to generate symbol references. Code generation with -fpie used to result in unnecessary overhead, as all references to symbols with external visibility use emitted via entries in the GOT, resulting in an additional load from memory for each global variable access. However, we can now manage this my using 'hidden' visibility (which is already used in places such as the decompressor or the EFI stub), so we can enable -fpie code generation without the overhead. This series is RFC given that, beyond switching to a better supported combination of compiler and linker options, I am not aware of any advantages or disadvantages of making this change. Cc: Sami Tolvanen Cc: Nick Desaulniers Ard Biesheuvel (2): arm64: jump_label: use more precise asm constraints arm64: kernel: switch to PIE code generation for relocatable kernels arch/arm64/Makefile | 4 ++++ arch/arm64/include/asm/jump_label.h | 8 ++++---- arch/arm64/kernel/vmlinux.lds.S | 9 ++++----- 3 files changed, 12 insertions(+), 9 deletions(-)