From patchwork Fri Jun 1 08:08:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Yao X-Patchwork-Id: 10442663 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 C6406603D7 for ; Fri, 1 Jun 2018 08:09:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB4E428D2E for ; Fri, 1 Jun 2018 08:09:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF8E828FD9; Fri, 1 Jun 2018 08:09:11 +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 DA3ED28D2E for ; Fri, 1 Jun 2018 08:09:10 +0000 (UTC) Received: (qmail 17789 invoked by uid 550); 1 Jun 2018 08:09:09 -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 17754 invoked from network); 1 Jun 2018 08:09:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Z6ArzBwf30vCYSuHOTg7J5OGmFxFAnK7TGxIaoiqe5Q=; b=QJAM79l62L6JPq7TcDujke5TCs7JtY3fcpjsmEOxrRBlQCVbfuL0LbSypfv/ss6IHy ovAV7zeTLkuV4TTvGp3ZgqyLG81UrVmAWOeUBUtnnnwP3UNYUHMx7t5SZ8/790EAEFa4 Ektr+o/S3PFiTUZiSn5P6ai5CoTp6Q4yDGhTa4ramT/Xv+H7t4K4NAIDDlJDnkaktH3j zxSe+CRC+rQN8qQPHdjISRxLvju4IJFUNQ4+RdOf9QD61ZsEUqilHTe7uHygpi8DUime IfBjMAj64/1PF9zSMT0V16r4e/oF/gHRmm3IkfaGMCgm/sg7Dnk7VfYTg+34Tw1d4tBH Tq6Q== 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; bh=Z6ArzBwf30vCYSuHOTg7J5OGmFxFAnK7TGxIaoiqe5Q=; b=TWwqk6RvZxbAuiG547UdSGYk8BlcU5rmoIUo+VE0to7XXYP2MQc8vZ/a+giHtyZSe9 sOaC5HNHodHaOoy/trW6sI3VR5c+Z+/chh3wGC6Ir5qmV89x5ughRUXDgtq/5E7aVl4Z GUtepPxum7dA0uZvAn5OetpF7odpMUvJxal6tB439cjKH/cMfMANbtFaMFjaWfa4wKiV TS+NiKKXRl6hdeKE3+Q4FBqtcYlGZILOGvABATKbq36rMXpxvtLL2LNdWYQuzg8FOYvz 4ByljRrvLq9EnNGsayIUH3tPS0JsTgb1Lv0vHsjeMg8ieVR/Tjkvy+seGqLZnv7ABo9w JBjw== X-Gm-Message-State: ALKqPwcOtjpfDBf3g3h3j/Hby4rFYm2BXRne4JjhCg6jOXoTX4bBk+N+ wArttSICe4zdb9mk8ECAyKQ= X-Google-Smtp-Source: ADUXVKJFjc7cDaaa5ryM6VsvNkv5+McHEswYuBjeycH9ntl6xmTNypGOLkymLaGtoj+Zdom+yX7++Q== X-Received: by 2002:a65:608c:: with SMTP id t12-v6mr7861373pgu.182.1527840536811; Fri, 01 Jun 2018 01:08:56 -0700 (PDT) From: Jun Yao To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, greg@kroah.com Subject: [PATCH 2/4] arm64/mm: introduce variable to save new swapper_pg_dir address Date: Fri, 1 Jun 2018 16:08:48 +0800 Message-Id: <20180601080848.11813-1-yaojun8558363@gmail.com> X-Mailer: git-send-email 2.17.0 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 14ba344b1af7..7abec25cedd2 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 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 41eee333f91a..26ba3e70a91c 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -56,6 +56,7 @@ u64 kimage_voffset __ro_after_init; EXPORT_SYMBOL(kimage_voffset); phys_addr_t __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