From patchwork Wed Jun 6 04:39:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Yao X-Patchwork-Id: 10449593 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF98860146 for ; Wed, 6 Jun 2018 04:40:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE6B529957 for ; Wed, 6 Jun 2018 04:40:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B05EA29969; Wed, 6 Jun 2018 04:40:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id D8FDF29957 for ; Wed, 6 Jun 2018 04:40:02 +0000 (UTC) Received: (qmail 25705 invoked by uid 550); 6 Jun 2018 04:39:55 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 25608 invoked from network); 6 Jun 2018 04:39:54 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hmO4aR2OVza1GEveZql0h0XRH2ahOLEQRZ/vGjIoFEA=; b=dJ1LxOzFamZa2mAs9w74keUb4YzwsT8bhUrRYUiI9uj4FEvRxBQuqSMfxnv6sxyyOe 0ucIru1O4A3L/I+P0bIggjVVco70g8ZvOwXpu29QmCX3bpFI07wCDPn+AvtqQE2LIBQr oM9d21S5/ms/p+Mx6ZiEc4RPu7MOHJg9hJZjmsLwdH5rzEwnwQ+emR23AZDlsJh5k02y KWWuZuSp+IqL8W+zLGTdAzKtl8elBve40idcs7UR5sEJ3SWF01mwNFbnYGnFpq8evop6 gz4eMuCeSELQDSFDd0AySE+z71AZ3QMdJjysDyBIKzsH8Ag2qP0FEMqEBnZVK2/k8/d0 YFog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hmO4aR2OVza1GEveZql0h0XRH2ahOLEQRZ/vGjIoFEA=; b=OIwaZpA+NNXwQo+jl49coYdXmEQEfWTQz0Z6/jewwyXmn13K9ChkG6p650wupr8UXD 7rebQxxrwcm3SZ0NhI3xTIqvqYsSs5u/pZazHuOQtwipSvvsva9ELlDkJjUOIVq61Qsw +Zele9Pn+PkcW5XFzkij8nMKgcTvsnWnexv/CbBmiMCOTgXTNeYS+a0CA3p+1ZDBM48A lpn/WvgjZdWO8PBXQ4N8SB7O5ztgyf5Dx8NB6Glhw2kxVGaDetR2bvkYLTK/ERJCBLWr qV62OIVC5EUIVZPmgTeoszkGPjxLWv+uQIYtrrvmCXlMF1z3DmFdbaiPYMlYX1oZSJuJ IXxg== X-Gm-Message-State: APt69E1j6F5Pg74YlQ46kIKj/xlhMHUYScI0JQxfwn0BxK2y9dMSaYAv 4kPU0A06KO6UCRnARN+/sgk= X-Google-Smtp-Source: ADUXVKKUXIMfOb4Qj0Ah0fhEFbIvAU/+dK1Bw2MH73G6LAHXVxP93KsJokQZbZZXn4ku+L1G/XZRCg== X-Received: by 2002:a62:3994:: with SMTP id u20-v6mr920418pfj.95.1528259982506; Tue, 05 Jun 2018 21:39:42 -0700 (PDT) From: Jun Yao To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, james.morse@arm.com, robin.murphy@arm.com, labbott@redhat.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v3 2/3] arm64/mm: introduce variable to save new swapper_pg_dir address Date: Wed, 6 Jun 2018 12:39:20 +0800 Message-Id: <20180606043921.19851-3-yaojun8558363@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180606043921.19851-1-yaojun8558363@gmail.com> References: <20180606043921.19851-1-yaojun8558363@gmail.com> X-Virus-Scanned: ClamAV using ClamSMTP Prepare for migrating swapper_pg_dir, introduce new_swapper_pg_dir to save virtual address of swapper_pg_dir. Signed-off-by: Jun Yao --- arch/arm64/include/asm/mmu_context.h | 2 +- arch/arm64/include/asm/pgtable.h | 1 + arch/arm64/mm/kasan_init.c | 2 +- arch/arm64/mm/mmu.c | 2 ++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 3eddb871f251..481c2d16adeb 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -57,7 +57,7 @@ static inline void cpu_set_reserved_ttbr0(void) static inline void cpu_switch_mm(pgd_t *pgd, struct mm_struct *mm) { - BUG_ON(pgd == swapper_pg_dir); + BUG_ON(pgd == new_swapper_pg_dir); cpu_set_reserved_ttbr0(); cpu_do_switch_mm(virt_to_phys(pgd),mm); } diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 519ab5581b08..2bda899dcf22 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -723,6 +723,7 @@ extern pgd_t swapper_pg_end[]; extern pgd_t idmap_pg_dir[PTRS_PER_PGD]; extern pgd_t tramp_pg_dir[PTRS_PER_PGD]; extern volatile phys_addr_t __pa_swapper_pg_dir; +extern pgd_t *new_swapper_pg_dir; /* * Encode and decode a swap entry: diff --git a/arch/arm64/mm/kasan_init.c b/arch/arm64/mm/kasan_init.c index dd4f28c19165..08bcaae4725e 100644 --- a/arch/arm64/mm/kasan_init.c +++ b/arch/arm64/mm/kasan_init.c @@ -197,7 +197,7 @@ void __init kasan_init(void) * tmp_pg_dir used to keep early shadow mapped until full shadow * setup will be finished. */ - memcpy(tmp_pg_dir, swapper_pg_dir, sizeof(tmp_pg_dir)); + memcpy(tmp_pg_dir, new_swapper_pg_dir, sizeof(tmp_pg_dir)); dsb(ishst); cpu_replace_ttbr1(__pa_symbol(tmp_pg_dir)); diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index d518e27792ef..94056e064c6f 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -62,6 +62,8 @@ EXPORT_SYMBOL(kimage_voffset); volatile phys_addr_t __section(".mmuoff.data.read") __pa_swapper_pg_dir; +pgd_t *new_swapper_pg_dir = swapper_pg_dir; + /* * Empty_zero_page is a special page that is used for zero-initialized data * and COW.