Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp676929imm; Tue, 5 Jun 2018 02:35:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ8QRMk50UFXiiiNMAcAXUxNzl7muIpYxSnkQ5D48EI1wD8HYlnaTdzYqfzvnMFiAOBZ6Gj X-Received: by 2002:a63:4384:: with SMTP id q126-v6mr19896246pga.294.1528191315025; Tue, 05 Jun 2018 02:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528191315; cv=none; d=google.com; s=arc-20160816; b=apjDhEVzOzNyc665KJH2T0AcFYsCgPSfHO/zXFqha4YSuaItBTbpUyUrELKeqz1yOF l6X48AgQY65ovFEuk+11YLf9WQdxAIGYIVTTT4XGgSBg+tK5J/Qn9VJYOl1XFnzWLUeW lcBwcTIuzVwTm5HkqpQUnc3q2VFh64Tl1Qy0bVK/IQNyMAG7AUKJZS9f2CZkJHyNw4bj PosMaJcRN6z+kT2j2bhghYUOaWeSVHnOYKHRZgTAZ6Nj6waxEEtV/JSg3FN5x5z8WbhV lsD7VUJn2A75p1pXH8/eMwsOtFaqsNnYY1XvwCuD6MclFT9tU5X415l1rMAW8MQgC+Hh AarA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iOQ2dYDfdxEv6TDgcJXmn4niB06Yxp/l5v42XyaI/wI=; b=OEVsLN2BKOJKirQMPyd4cHJOX8IM+jW2jKdarcc5+XqEn1/F1rtNR89b5jaFI1pTtQ Ha86d56pfM6k85Qs805t9OezUXXaqDENoRc7AcMwnoss6eJEa7zOk3TzTJU/S1Yu68/r SACdFiA1qjRtX3MnEAByikszjY1Jt/BT3fD9G2u0qyNEazWE5rpLF8mgy4V2xRsYedES Ua0GO/MeCgBYelfJoVHjiIvz0odQmShe/f1Rhs4TfbsZ+Wlr4E4Du4cTM60ux5m8IOE5 EOdekBvlL1i8c5nk8CrPGRhkQn1P7z9o4rbqcpVbNOJ5EtA/GoLvOabpGkp2VQwLJZOB nN2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nxN5PYZ1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32-v6si25145715ple.447.2018.06.05.02.35.00; Tue, 05 Jun 2018 02:35:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nxN5PYZ1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbeFEJeM (ORCPT + 99 others); Tue, 5 Jun 2018 05:34:12 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:40290 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751732AbeFEJeJ (ORCPT ); Tue, 5 Jun 2018 05:34:09 -0400 Received: by mail-pg0-f68.google.com with SMTP id l2-v6so906216pgc.7 for ; Tue, 05 Jun 2018 02:34:09 -0700 (PDT) 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=h3CDRIsNP9vm4ld6dR6hAuGQiAgg8KzfyxvIPWesviUbivbXhMY+/If653DBw3NZn0 I/BbxqLJxFWAUuJgX93GxeDQItdOoK70dcFwp3ohKyAtWYQp0QCBsSdl/SQqtD4VYeo+ QMvzAPwZkJwkg7iB4XtDB8DtoKQi2eHjGfB3hU7es+ebsp2hhlULRIwtInyhD6geksD6 2r/GVo4clqsz/2ajPZ/ISfuzJw4I7A5YBvdeg2fc6ig4UG2k+6GfdTziy/84aATjpUct HvQfmPJJzntCvIXflJlMfe1ts9T4fgiU86gmCSCqKtlZw76+L/+cA/s/jTgqfxyMiBN8 mNPw== X-Gm-Message-State: ALKqPwcvebJGUVhOOK3FjGgWa6Qw6wC5VnyJVJ7t1IPc0MGdoiyUzjFB icsNvrhW44mDb3L6j+FxmcI= X-Received: by 2002:a63:448:: with SMTP id 69-v6mr19499352pge.395.1528191248916; Tue, 05 Jun 2018 02:34:08 -0700 (PDT) Received: from toy.corp.qihoo.net ([104.192.108.10]) by smtp.gmail.com with ESMTPSA id a10-v6sm41594477pfg.107.2018.06.05.02.34.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.17.0