From patchwork Tue Jun 5 09:33:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Yao X-Patchwork-Id: 10447945 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 46C706053F for ; Tue, 5 Jun 2018 09:34:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41EA228DDD for ; Tue, 5 Jun 2018 09:34:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36ACE28E3B; Tue, 5 Jun 2018 09:34:35 +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 6594128DDD for ; Tue, 5 Jun 2018 09:34:34 +0000 (UTC) Received: (qmail 11552 invoked by uid 550); 5 Jun 2018 09:34:24 -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 11327 invoked from network); 5 Jun 2018 09:34:20 -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=iOQ2dYDfdxEv6TDgcJXmn4niB06Yxp/l5v42XyaI/wI=; b=nxN5PYZ1woesDj+POxp3DYTeIz5G9bXdXNPiFSlGPQMG6Gtw/+iy8hEvsJ6BHtEVZt JwuGxKg/yzzOUn62ZDYNsjRbq9z8HpUlI+r+NXEsrCol+LlSSa8NCAiYc1Z+fl/7HGEC H6BfgwUko62lGDxF0nAy1FQxU+taPym6WVg/H5f0yXLwFfRHsIEYBfYxvmJ/v4frLB2P 2EVOwvIEc6SnyOwX2NGvLu3v1h0QT3ui7SUo3/9Xi8IHc8cVveTAgGb3deNk9okWs5NU LPJ8zbuFXz+bYqdO/1WFafh0oc2lzjxtTUipPQXGg/GOnJSvKAhrjbf+k9ch+Apf+hoU MG7g== 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=iOQ2dYDfdxEv6TDgcJXmn4niB06Yxp/l5v42XyaI/wI=; b=JsXkUQVbsKSZ4esOXAf2xS54/6EJbIed+thVo+jG8EH/awuOPX9pju6mKT/NdI89zQ ufeFMOhycvzeaKEEL3XKjIGjizhoQc6lGIykbzy7WD6RIpyl9vZ83v1FDoTNlrad20+M Usui+6SFclimMlv5ojCiGfq7gpTqC6t3AJHadMSqAzkYkENjx/2S3o5vDFIEtTRdw08L qKNR3Dw3vOEr9ZYd9hCWCeznVgLxl8FEBlgriomoVHf5Igf9RR2zAEcKQyLcptpS+AUx OreRmnq776iEdYuVn9UMBx7ZH2FdpDsj5SMGz4Ztc3FTeGHLhq8hqyPIYbXBuRAOvqf8 X2mw== X-Gm-Message-State: ALKqPweEjas05JZaxTyDKg9YzM5bgMgfwOzajxCoGe1eHoMwanbBaghA TI6PG4GnWQibr/0xn7Gx8RY= X-Google-Smtp-Source: ADUXVKIPtw689reDN8aMxuFgR/evEzNKptskQP1rEsnD2ulg/Yok6VY29ZqtuCGm8OqDniKZgB1Nzg== X-Received: by 2002:a63:448:: with SMTP id 69-v6mr19499352pge.395.1528191248916; Tue, 05 Jun 2018 02:34:08 -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, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 2/3] arm64/mm: introduce variable to save new swapper_pg_dir address Date: Tue, 5 Jun 2018 17:33:49 +0800 Message-Id: <20180605093350.24504-3-yaojun8558363@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180605093350.24504-1-yaojun8558363@gmail.com> References: <20180605093350.24504-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 | 1 + 4 files changed, 4 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 c7df2f0d2e85..fcb425b0fcab 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -57,6 +57,7 @@ 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