From patchwork Tue Sep 12 14:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13381762 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 874E1CA0EEB for ; Tue, 12 Sep 2023 14:17:58 +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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=f+UWmta6XJTknlIiOB73F8xALFtUqNz9nnrqqqltlio=; b=ACtwreIuJ2ZwQ5mavmoXY6qGEO aGVz1P7vHYCP7VRK697zIhpQ8uMlENXJ6RF5SOk+c1pLklUgMvx3ANvrHR1mG9bbI7RAZg3oIEQ4y hHPim65KzmY8/xyUfMfRR12BHdNLsLuDzvLvhOnpEvJkvVP8/2kSBUbNy4fY4MWny+Z1Bv9K5d1iF Gtr1plcxCilEtYmnzJSjnb4ff/9wUC44aOYNht/kqZjy97QbOhCoIUm1MohU5kxB4dTRocYIdmU6o u2x2xN5ep0NUwwtImExj1hl+V+8bqYisqq2p9J1J2Lz1Unt3EoF2M0r5hThVsztvJmYbn3Ps0j2yA ZghDlc/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qg4Ck-003VrI-1g; Tue, 12 Sep 2023 14:17:26 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qg4Cf-003Voh-1v for linux-arm-kernel@lists.infradead.org; Tue, 12 Sep 2023 14:17:22 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-31f9186eb8dso2018717f8f.1 for ; Tue, 12 Sep 2023 07:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694528239; x=1695133039; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=eOb/FBDmij/2vNJpti6zX3gVXW4T8JnmlfG1c99rhJU=; b=vZiaj0PDn92YNgbXZKanQM7kW/EPsa3K+qN545vIQC9c17d1LQEqf7iuCwFqBVsg9t FXVgEbO4VUNU7do47jpoKaQdMFDOn3YBOCi1gDWyWGXfONZTB9dWmnsT22+SYR+lNz/F LgNS7Qdbfwxz8VdE2LjmEqbh+iKKWllpHDJ9dL6rmNYO/nI4gJNolcntC4mUpe0K2RJW iGZDjEKgMaWD9DfkmBbq5jeToyxAtfzR77UeLO36ImU0QkZNaKaVN4eTAnHkhzAW23U2 CzKHqfDlqbv+h54E7mw/pYgMXFEYO7TLCTFyEF8N3po/N37uX6w5yd1+HYoy9sTwyDP3 AXEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694528239; x=1695133039; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eOb/FBDmij/2vNJpti6zX3gVXW4T8JnmlfG1c99rhJU=; b=lrYB7je/fB9lecgmskM/YyVv0KC78gW/6c6fVXiH8ws+ujNtmVF5x4JZZ2iHJygY7t 881C+0ZspmV0rKvknewj9cmHyO/2n2frQaYcDLGGp8r68VNt0eEGDlTdKWNeQAeppVdu 0RJpsxP4vK50J028vjeVskEWUWqC1/bAqzEO6sbJ+KzIP8g+I+ESbPa4QSJfSnTaU0xp 4ictZ6+b6oQrpGxJtQ5TiMytc6f3Lp7rnbBtmsEZSCim8rb7gctF0vqy8ymPj0odHcn0 ZDvnXY3ku6wHpOmk3akhOeRyAACkf7kKb7B/cL+v0V7v4fAGP/0JMhczVJ2w4o2ZpFHa kznw== X-Gm-Message-State: AOJu0YwHo2MLlqSzHPvXN1SPu7wO6g7pJUga5rqG5m9NbdrO3RVBSNrZ qPFWpAv4Cd3Ww0aLoSxYo3ukuB0ltKSbaGQ6AAFZ1xAQUAj4giriwt8zVWFbbaa5DVt4u4VfmFL VAFij6iBlbMLRrDiT4dJ68q0fIkdgRufe7RLy4GAskvGu0mZwf8xxsSjlu4SpL1uW7uW2AHHqtZ Q= X-Google-Smtp-Source: AGHT+IH5Gjz1j9kZra4s09DIYfL/rr6h7oBCEP+Eg4GGTTg5wd80PLard/dGKqj6aPLuWyn6BXSKwlaV X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:adf:f64c:0:b0:31a:ed75:75d5 with SMTP id x12-20020adff64c000000b0031aed7575d5mr147849wrp.6.1694528238991; Tue, 12 Sep 2023 07:17:18 -0700 (PDT) Date: Tue, 12 Sep 2023 14:15:53 +0000 In-Reply-To: <20230912141549.278777-63-ardb@google.com> Mime-Version: 1.0 References: <20230912141549.278777-63-ardb@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2451; i=ardb@kernel.org; h=from:subject; bh=ROSXFKE0XZd48MC38Ki7uymklvK1Vn6RW508I4T87NY=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIZWhaOZEpX1qDuVTbbQ6Tp1cu71i/sXVa11DRINK3rT3T jronM/bUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACay4hrDX8Ga9z7bCmaumFt4 8kV1oV3+47VFThzNcbKuTQ+WtdWqMDEydE3TWZjH1vz3sLpU8BerlUy/GEte3U9Qb/723mTm+4s 97AA= X-Mailer: git-send-email 2.42.0.283.g2d96d420d3-goog Message-ID: <20230912141549.278777-66-ardb@google.com> Subject: [PATCH v4 03/61] arm64: mm: get rid of kimage_vaddr global variable From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook , Joey Gouly X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_071721_636895_C8DE6204 X-CRM114-Status: GOOD ( 16.48 ) 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 From: Ard Biesheuvel We store the address of _text in kimage_vaddr, but since commit 09e3c22a86f6889d ("arm64: Use a variable to store non-global mappings decision"), we no longer reference this variable from modules so we no longer need to export it. In fact, we don't need it at all so let's just get rid of it. Acked-by: Mark Rutland Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/memory.h | 6 ++---- arch/arm64/kernel/head.S | 2 +- arch/arm64/mm/mmu.c | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index fde4186cc387..b8d726f951ae 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -182,6 +182,7 @@ #include #include #include +#include #if VA_BITS > 48 extern u64 vabits_actual; @@ -193,15 +194,12 @@ extern s64 memstart_addr; /* PHYS_OFFSET - the physical address of the start of memory. */ #define PHYS_OFFSET ({ VM_BUG_ON(memstart_addr & 1); memstart_addr; }) -/* the virtual base of the kernel image */ -extern u64 kimage_vaddr; - /* the offset between the kernel virtual and physical mappings */ extern u64 kimage_voffset; static inline unsigned long kaslr_offset(void) { - return kimage_vaddr - KIMAGE_VADDR; + return (u64)&_text - KIMAGE_VADDR; } #ifdef CONFIG_RANDOMIZE_BASE diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 7b236994f0e1..cab7f91949d8 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -482,7 +482,7 @@ SYM_FUNC_START_LOCAL(__primary_switched) str_l x21, __fdt_pointer, x5 // Save FDT pointer - ldr_l x4, kimage_vaddr // Save the offset between + adrp x4, _text // Save the offset between sub x4, x4, x0 // the kernel virtual and str_l x4, kimage_voffset, x5 // physical mappings diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 47781bec6171..49a49b37580b 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -52,9 +52,6 @@ u64 vabits_actual __ro_after_init = VA_BITS_MIN; EXPORT_SYMBOL(vabits_actual); #endif -u64 kimage_vaddr __ro_after_init = (u64)&_text; -EXPORT_SYMBOL(kimage_vaddr); - u64 kimage_voffset __ro_after_init; EXPORT_SYMBOL(kimage_voffset);