From patchwork Fri Jun 24 15:06:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 12894756 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 B9417C433EF for ; Fri, 24 Jun 2022 15:14:26 +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:References:In-Reply-To: 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: List-Owner; bh=inx209NZYnYDSwxFm8Cir88ldlWH8lHPZGV9+0PSPpw=; b=PO8VxDH0fOSswP 87sM5zt4HjrPpG430oNf1vRQNMDTRGaE9Tlgm0e0VpzF60gDdidRTBdQU43L4TIjPqKlVFYUkHg2B EwxBPL8D+xlYtCfDsWfW7cNIpGGvVNoV+jGyt/LrJ5I30Pwlax0dAZp06Gc7q3MZC+pIE4taEhvoa xQLFj6pUsx+h7o8Mm5gwivw8My/GvDXADDQRfb7ljikvbjXi/or42+qSQeaJ/y0Nn6+N/qo0Q5Mxd CsmslXDiCZeFPkHw5EA8swEU0mHX1XcHsYjWUviyqeLdR0+wOwbyjMLd3yvnOrXEyPHVlGSXSww7k 1pJqiIyYdE29MiEsEncw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kzq-002lNy-Se; Fri, 24 Jun 2022 15:13:23 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4kuR-002iVv-Fd for linux-arm-kernel@lists.infradead.org; Fri, 24 Jun 2022 15:07:48 +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 0D336621D1; Fri, 24 Jun 2022 15:07:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95CE5C36AE2; Fri, 24 Jun 2022 15:07:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1656083266; bh=oLenfBhi8fKcOgGl+2bnK+Q39DnuPeJE3ucoNT8wFLc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpsT1CPikBQlsvStPKUCqYT12xKy6XrDElO0aYbm0MsecaOsTUuGpAM5G+SiGcNeY 25odBS4BA+iImjy8lMVgXdzaEWvLz7GPUV+CKmZxWi3M7rZtLPdT1FegHfrHuhcBjr 2679y21RswxEt6aH/p8Lvsbzgn3ml1ARiYED0z7XIZ/7M2lmylGDx21xpvqKpa39IE 5ESz+GktnXR1iRLCoN0a5SxPgxsb/+1vXTZiFuQKvFfRr85aoyzUOOKG7eRjz5xkuC +vEoZoHlpLcbrcf7ZBSygsHah1DV5snbWaZquBDj6MVyCWoMr9bw05DbCoiWduTLVz eoDVmMvH9+Pwg== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Marc Zyngier , Will Deacon , Mark Rutland , Kees Cook , Catalin Marinas , Mark Brown , Anshuman Khandual Subject: [PATCH v5 16/21] arm64: head: factor out TTBR1 assignment into a macro Date: Fri, 24 Jun 2022 17:06:46 +0200 Message-Id: <20220624150651.1358849-17-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220624150651.1358849-1-ardb@kernel.org> References: <20220624150651.1358849-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1896; h=from:subject; bh=oLenfBhi8fKcOgGl+2bnK+Q39DnuPeJE3ucoNT8wFLc=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBitdMCtHm4noxpzj7kvLJx1+gjXpQDDGgcKIYdEYsq sJU+MaGJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYrXTAgAKCRDDTyI5ktmPJKYKC/ 0RKzQWUENJSiPltWWCbvP64JYHo0d5iI/dqw6maKCSgi1VhhvYvBzn1jWI6UMjt+sfbcTzJ1erdZEO UyUmi5yMYicl8Rfv6J5n1XpI2BFlZgeYHayolozJc2yv0aqlIgeq96wB2C7hMugD9dKAWaxOqmW0WK RuqtGUfSREmGdZJRlGwUjgIJhLqtXJUIK5CnxALMm9Li6QEpt6ChPU5P8HPX9Vavt3V7Maripvp4O6 aVnc0pKjkfaptSNOO6TF3dTW3cs8z5QTGKTLwkohBM4Wv8nXeD2UIJEr9zeLxVOuQQbgSgu7kVEaoo p9osl0qV9955oKV7v6v1egIT069ms6NuT4DcVVjJA7RrtQYXtqAKdDQn+y2Ldtf+zgUKAKqT7irCtE 4Mu+V9dXfJvap2ES8Wgd+2NdeXqd1pkeEi4m32ueaatiBz+6DIbbQ/DDOKccWSLlSM4ZcUV/Ix2Puy RPOzrlcboU3BlvPK7cS3fo9C+anJiIl4WwzIkQKihKZik= 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-20220624_080747_635592_AFC72AD7 X-CRM114-Status: GOOD ( 12.93 ) 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 Create a macro load_ttbr1 to avoid having to repeat the same instruction sequence 3 times in a subsequent patch. No functional change intended. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/assembler.h | 17 +++++++++++++---- arch/arm64/kernel/head.S | 5 +---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 9468f45c07a6..b2584709c332 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -479,6 +479,18 @@ alternative_endif _cond_extable .Licache_op\@, \fixup .endm +/* + * load_ttbr1 - install @pgtbl as a TTBR1 page table + * pgtbl preserved + * tmp1/tmp2 clobbered, either may overlap with pgtbl + */ + .macro load_ttbr1, pgtbl, tmp1, tmp2 + phys_to_ttbr \tmp1, \pgtbl + offset_ttbr1 \tmp1, \tmp2 + msr ttbr1_el1, \tmp1 + isb + .endm + /* * To prevent the possibility of old and new partial table walks being visible * in the tlb, switch the ttbr to a zero page when we invalidate the old @@ -492,10 +504,7 @@ alternative_endif isb tlbi vmalle1 dsb nsh - phys_to_ttbr \tmp, \page_table - offset_ttbr1 \tmp, \tmp2 - msr ttbr1_el1, \tmp - isb + load_ttbr1 \page_table, \tmp, \tmp2 .endm /* diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index 64ebff634b83..d704d0bd8ffc 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -722,12 +722,9 @@ SYM_FUNC_START(__enable_mmu) cmp x3, #ID_AA64MMFR0_TGRAN_SUPPORTED_MAX b.gt __no_granule_support update_early_cpu_boot_status 0, x3, x4 - phys_to_ttbr x1, x1 phys_to_ttbr x2, x2 msr ttbr0_el1, x2 // load TTBR0 - offset_ttbr1 x1, x3 - msr ttbr1_el1, x1 // load TTBR1 - isb + load_ttbr1 x1, x1, x3 set_sctlr_el1 x0