From patchwork Tue Feb 2 12:36:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12061467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DA2BC433DB for ; Tue, 2 Feb 2021 12:38:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3217C64F45 for ; Tue, 2 Feb 2021 12:38:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3217C64F45 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0fR9rEttdVKPUuGbL9UdrTk2qHbd0ecTivs0w1fSEFo=; b=GVnl11aBZstcEEvEYx3bFFuh0 494Qc4S2gnKYCXzC/XFM6WNiRT60nZZJWmUXz1+AAR2ILaDyggCsOl40xvnKLQnUM7y7woeaeDzO4 tiu+dmw/P6kIItj0/1w140r6rPCWhzJrFyjmpXGzvJJ29Wr+2jaL1h+mUxgba3Ms0FapLZKr3NKi4 6JarlTo22LLc3C+2vvN/6nriv+e2Pm+Kw5P0tmBuIwKwi6xyukT2qKC8BjgGhR63SGQXPeHENSdn6 d/p2snQfEmPS/RfewKOpcyOoWFlrBjSwyi/7689vS5/j7H8TvT1Z+pouDprUIEf23yAuPe2NjVk9l shLM6MYNg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6uwE-0002PL-PK; Tue, 02 Feb 2021 12:37:46 +0000 Received: from mail-eopbgr130058.outbound.protection.outlook.com ([40.107.13.58] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6uwB-0002OQ-PM for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2021 12:37:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2DUF+V0+XGgg8LtiSQKy4ENL7+eJrCysQUcuCDoy02I=; b=Ojzhfc1u9WnjMz0+S1s1P79/EybZy5fZyz2DNVzYvOAZvPo0KMb0RP/930iuKkO7+iRw4Ath3je0BrVRt6QqnmRvamgIRI0ZAjfqVSwCYCcPp3hKOv4gZNxnYlhVLbGEjvc1fsGCRB601iVlYULKjRXmJCnDQHqAHhuhNnEI4vE= Received: from DB6PR0301CA0099.eurprd03.prod.outlook.com (2603:10a6:6:30::46) by DBBPR08MB4887.eurprd08.prod.outlook.com (2603:10a6:10:d7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Tue, 2 Feb 2021 12:37:41 +0000 Received: from DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::bd) by DB6PR0301CA0099.outlook.office365.com (2603:10a6:6:30::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.17 via Frontend Transport; Tue, 2 Feb 2021 12:37:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; lists.infradead.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;lists.infradead.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT022.mail.protection.outlook.com (10.152.20.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 2 Feb 2021 12:37:40 +0000 Received: ("Tessian outbound f362b81824dc:v71"); Tue, 02 Feb 2021 12:37:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fbc7aab0906263e1 X-CR-MTA-TID: 64aa7808 Received: from 4cdeae0ebcb0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D9C7D89B-D126-48EA-B3AC-F34BBCF1717A.1; Tue, 02 Feb 2021 12:37:30 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4cdeae0ebcb0.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 02 Feb 2021 12:37:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XVAJXOnzbyRPDi19qCqLjKu6gg3RZYIeXpB6vhtX6uunMGWOeHpekus14yqgouvzBsmfmeMEPEW9d+B0ONgWj8LoYe99MO/MXyNjarTNYikG1hdX8z0oQjOL0EKyuFZcyjd7o9q3Tj4MtSZIzf42yBV5c5x2n9XADEg7PlM6k1hQ3A3/2QkQ4WqgXmyAmRQLqjIH/C2YjAUP4BJSnhrD/4gzZ1e8SxgloPC8fH1ScDNgwbeVu5Q+u5oswhVzjR8es/8rLwLfF5pYNRsqR+2JDeDoMDfl+XuWwI843gOBdE20YFegqFF07spY7Z7Zk1DVnhiU8yWjollNeCgCpM9n6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2DUF+V0+XGgg8LtiSQKy4ENL7+eJrCysQUcuCDoy02I=; b=k7rhqbsxZx/5jHVqInstvFaHPVHBQDngjz6r3sLhj94+fLHSi9389nCTB3ht6zykMtThQW2gc+RQ/fMQZkzYYZllPDsgANT1c7/DBQrLKco8dcckpewcQc15htKvBBU9A8glQORiUdDXdtHTw6wDWptEW1QLMM29qABFLu+9VKZuFXRG/dx1kWl36CRAXQohKxA/Ow7wxggXCsjAO6vIhwgo5hXJWX4GLMeobtOPv+wOwJXsrYwd+ggPH9y/8sBS6saJS7OwZJdVk1huqjrKa9kF3f30BmIB965ZORqdOfDMjYAC5TXfk/eBXXT+TzSB1zgg4BVr7dlDDLWlY9zGdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2DUF+V0+XGgg8LtiSQKy4ENL7+eJrCysQUcuCDoy02I=; b=Ojzhfc1u9WnjMz0+S1s1P79/EybZy5fZyz2DNVzYvOAZvPo0KMb0RP/930iuKkO7+iRw4Ath3je0BrVRt6QqnmRvamgIRI0ZAjfqVSwCYCcPp3hKOv4gZNxnYlhVLbGEjvc1fsGCRB601iVlYULKjRXmJCnDQHqAHhuhNnEI4vE= Received: from MR2P264CA0061.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::25) by AM8PR08MB6386.eurprd08.prod.outlook.com (2603:10a6:20b:362::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Tue, 2 Feb 2021 12:37:27 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::29) by MR2P264CA0061.outlook.office365.com (2603:10a6:500:31::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.18 via Frontend Transport; Tue, 2 Feb 2021 12:37:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3784.11 via Frontend Transport; Tue, 2 Feb 2021 12:37:27 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Tue, 2 Feb 2021 12:37:11 +0000 Received: from e124191.cambridge.arm.com (10.11.7.12) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Tue, 2 Feb 2021 12:37:11 +0000 From: Joey Gouly To: Subject: [PATCH 2/2] arm64: vmlinux.ld.S: add assertion for tramp_pg_dir offset Date: Tue, 2 Feb 2021 12:36:58 +0000 Message-ID: <20210202123658.22308-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210202123658.22308-1-joey.gouly@arm.com> References: <20210202123658.22308-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 881193aa-bf1b-4b9e-6379-08d8c77754c2 X-MS-TrafficTypeDiagnostic: AM8PR08MB6386:|DBBPR08MB4887: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4303;OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7fuFGLiditYhNiexpz/KZqIToGdEtrheS0wE40XuOlvJr85/GLsRCeJ9jejRqBPO9w/4WeVuQwj47o/t/FIK7zSwXfDgyqm5PsSW8WOsdLSiUxLtU9VKARBBRyAyyWbJzO9EDLWXAF5AqToBnE6PW/1iYHGPDclg9jtXCxUIcs0WIBiyrDuo3AG6Lu9bQMZ0OO2qnqS6FyqAklCfu8vR1Y3xdxW/jU+OyI1G5JirZuELyum2HkEned10nY4C7lKnAhn+Mqa6KeCqv/49Wn+3hZ4AIfvvVYMam+y/CXwUsrQKpuKqkybuusKdfab4mlbLUYGIAFiBhUj9O4dPV9TRJMu2URKiw0FJcc+Av8te0DIdaVUCaGyiFq+BHBuNf7Ctw8PVrUW4FT1qfrOFzcIE06za8ZUXR7M7g2zJRmx+OHBjAhVUJaB5zK5LCFbgIyEHOd/KIBJ3Z0SYJR748xXqiTPNmyIcIZgtAO2DXKIDDI/tJ5eclAMVpHXamXYCr0J//Yr9tATj6+aG+jeOJeN0MdWlqGvhJvIWFqxr28KADv6fdYnRxQhxJATJD+KcZQRqLaIVMEbfFHUEZoBqcIuPrCT4n+TFPv7tcPE4ip1/riEELTHOgW7JhEDP/j8MhEw90ZuRWaEOIAcgC1RGfRMvzbWdA7l2rgeBPcDqko0vhZs= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(39860400002)(396003)(136003)(346002)(376002)(36840700001)(46966006)(54906003)(426003)(36756003)(86362001)(336012)(186003)(4326008)(44832011)(316002)(8936002)(2616005)(5660300002)(26005)(7696005)(47076005)(2906002)(83380400001)(6916009)(356005)(82740400003)(82310400003)(8676002)(70586007)(70206006)(478600001)(6666004)(1076003)(36860700001)(81166007); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6386 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 5a949529-4824-4219-9301-08d8c7774cce X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eNvAASWNGIXrpUzAQtFk+Td4EnEywH3D3S7lkI7xieIrSrhbFfNd93jHvPZE2p10nV59e8BsFPjal6cXZBK0TVeYEErVCvYJQ2IySsRBzdJyfQspT6JiRTmRVhMrQ9TRdxWWDGa1+NjGoPm1p/TLXFYfd4qBhUirG1ws3dsMK/439aQA6zjE2m+8bNHzb75n5cICYBln4IncaeI7S08BerKnzdAVCtQQV3NjSjyPixv2H/vJjVpI4qfFQto9OFWZ1OzD3kh8tyf/GWDvxU/iw2r7FFMtBjbfAW7OZy/mREBpIZgUlVAhepCO0T5TEHM7vpyLyFagwJBzgr8g+17zdVjNSWkMNko8I46ALmmFfzLmOUjoRTc+e1wTOmdV1/j2sWIKJmGJL8XCUZlT3tv18lYii/B1roK1NZIUzCK97FIyDf7XNUe+0Ryo/sAmteyp/QSmVmwv21ju9hf0FXHV8dC2+Bps2fuayDZwTjKGhdECH5p4HRbXSNOAZJwC6XtSPjvLMbSkrhSTNn8QyMMGeBbTaqPbTvsv4xImKRr0KspLw2h2Xdu76CzlLaNAh1otuXlSxDlKCNkJ1mnwit4zxi+uRluAwozy0iEdvdPUDeoy3vicVlKMznsiWRc3WBdLyarXhO63peif9+5Fma/mkhxnIEvdzNO2MA0Br5e8x7Q= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(346002)(396003)(136003)(39860400002)(376002)(36840700001)(46966006)(44832011)(1076003)(478600001)(8676002)(5660300002)(54906003)(4326008)(82310400003)(316002)(81166007)(426003)(6666004)(6916009)(82740400003)(36860700001)(336012)(26005)(86362001)(186003)(36756003)(83380400001)(70206006)(47076005)(70586007)(2616005)(7696005)(8936002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 12:37:40.9896 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 881193aa-bf1b-4b9e-6379-08d8c77754c2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4887 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210202_073743_850641_B55364C5 X-CRM114-Status: GOOD ( 12.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , nd@arm.com, Will Deacon , Joey Gouly Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add TRAMP_SWAPPER_OFFSET and use that instead of hardcoding the offset between swapper_pg_dir and tramp_pg_dir. Then use TRAMP_SWAPPER_OFFSET to assert that the offset is correct at link time. Signed-off-by: Joey Gouly --- arch/arm64/include/asm/memory.h | 6 ++++++ arch/arm64/kernel/entry.S | 4 ++-- arch/arm64/kernel/vmlinux.lds.S | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 300f728fa288..f9aa9fa8806e 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -165,6 +165,12 @@ */ #define RESERVED_SWAPPER_OFFSET (PAGE_SIZE) +/* + * Open-coded (swapper_pg_dir - tramp_pg_dir) as this cannot be calculated + * until link time. + */ +#define TRAMP_SWAPPER_OFFSET (2 * PAGE_SIZE) + #ifndef __ASSEMBLY__ #include diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index c9bae73f2621..c6aee646eb6b 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -805,7 +805,7 @@ SYM_CODE_END(ret_to_user) // Move from tramp_pg_dir to swapper_pg_dir .macro tramp_map_kernel, tmp mrs \tmp, ttbr1_el1 - add \tmp, \tmp, #(2 * PAGE_SIZE) + add \tmp, \tmp, #TRAMP_SWAPPER_OFFSET bic \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp #ifdef CONFIG_QCOM_FALKOR_ERRATUM_1003 @@ -825,7 +825,7 @@ alternative_else_nop_endif // Move from swapper_pg_dir to tramp_pg_dir .macro tramp_unmap_kernel, tmp mrs \tmp, ttbr1_el1 - sub \tmp, \tmp, #(2 * PAGE_SIZE) + sub \tmp, \tmp, #TRAMP_SWAPPER_OFFSET orr \tmp, \tmp, #USER_ASID_FLAG msr ttbr1_el1, \tmp /* diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index a03a5300bce9..68f76a96c60b 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -319,3 +319,8 @@ ASSERT(_text == KIMAGE_VADDR, "HEAD is misaligned") ASSERT(swapper_pg_dir - reserved_pg_dir == RESERVED_SWAPPER_OFFSET, "RESERVED_SWAPPER_OFFSET is wrong!") + +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 +ASSERT(swapper_pg_dir - tramp_pg_dir == TRAMP_SWAPPER_OFFSET, + "TRAMP_SWAPPER_OFFSET is wrong!") +#endif