From mboxrd@z Thu Jan 1 00:00:00 1970 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=-16.8 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,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 3A528C433B4 for ; Thu, 8 Apr 2021 04:09:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 BB677611BE for ; Thu, 8 Apr 2021 04:09:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB677611BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type: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:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3CQxR8o2l4l3dKHlUiIKRPzy2Fxr6iUPcYMSH2YYpWw=; b=K96hpSvYZcHFLjFl3tF/Ek0zn SZjzBXIu78Zo9PO4Dy3RZP+aP866QRI9yqtd5p87/2XQn1K4zQEipCp21KFA+uI5ANMnh5VqNN8yE ucbe3MZLbnCZ96Ak1iXTc1ilIsnDp+bRwV11LjB9KPc6a8YIPOH/a5vc7JMjbQQ6ka5vIJUfDExwC fQztUudBPy9dHxZBHyVawS1g3Y8NhCeLesBTqQtBWqzGKon9xoZXT+jw5MaG83qe0wUoGRwmBtJ8G pBAXmZ1hJfPSiVytZLogXROJUK5u0EMsO2qQmzpVml2MnMtf6Sf6T+/PyUMe4PRffF5VgX0S0SS4j qndf5tcIA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lULxX-006mPa-G1; Thu, 08 Apr 2021 04:08:00 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lULvQ-006lZZ-AZ for linux-arm-kernel@lists.infradead.org; Thu, 08 Apr 2021 04:05:52 +0000 Received: by mail-qt1-x82f.google.com with SMTP id l13so453169qtu.9 for ; Wed, 07 Apr 2021 21:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=3ttZQ3gfSf54pfSUBx1LDfQsXE0pAbLQUWMLzhdR74s=; b=WNp1gMdsw3Tm4wv5ofO098L7+rqsXN0+xuPMLvxyhfRqO2E2ZKhDEGaGLLpQQCVLp6 kRWKAxhxmJ30NKIqBld7gTpjAwpz32kIBNExJ2Et0HZWEE+ivhSVeMWtXqp7UcIZyBCs X/LNtk7ga4MpNqn+3v94T7MU9nnrxtlJ/zYiq0277ls+/aEP16FB1VizUFYUquLa7aw9 GiGHeJD31iKWwANH8mQHHBOHgqAlwmaUPPJC5gCo6msF/l+C4Y8nVRzmZMqDdNYh/mJM 69+TMIvHTm4pme+kPif1x+MlMxbSFgJaabSY0wDQ4Fxs8xJDRaaUL9ndnx4mfcqONRfT nELQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3ttZQ3gfSf54pfSUBx1LDfQsXE0pAbLQUWMLzhdR74s=; b=IsR8oNGw6WQ3Avd1f9GrnMgU7q1Uq/coLn1ouPSuJXs6LmykB4d3YJrIL2Rr0AF6ak UEmgvI56I666PhayKJq7m1Rd0dHtU0BghwGcj2mehImkipGWhEzkX5JO4VB7gxALM1tU Uh3JsVEzCe2CrhyeKQGzPNdT5azpX577XM9CvddcbxekNAN1RHmJl9sqt6vGwxCXKe15 jeoa89+rG1W428uQanFrPzE6g6N1wxtC/RZCo1srVQzk1z8fLLCZeox/wU01VZIxDIVS aENDt3UefhzSkfNToWmFFRDHLLs17xnnLQSvrhwtBJNBtb/pxVivlWY9/RK0PZuZx+F8 8N7A== X-Gm-Message-State: AOAM533xkZmhXbHdmJxgzCOPZk8XM+DJp6tf5uZkTo7McHPX0X2MM/3x eKGiEsFOQffIYA6s2Fymg5NXbw== X-Google-Smtp-Source: ABdhPJzXmtqxtUQTEJT0lxRGeT3Nceyt+CBZeKYInLcPaN+AnmjXc07TTgCf3AOXx1AjM6gvwPz9Hw== X-Received: by 2002:ac8:6684:: with SMTP id d4mr5596938qtp.34.1617854747044; Wed, 07 Apr 2021 21:05:47 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id 207sm18177874qkl.125.2021.04.07.21.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 21:05:46 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, corbet@lwn.net, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, maz@kernel.org, james.morse@arm.com, vladimir.murzin@arm.com, matthias.bgg@gmail.com, linux-mm@kvack.org, mark.rutland@arm.com, steve.capper@arm.com, rfontana@redhat.com, tglx@linutronix.de, selindag@gmail.com, tyhicks@linux.microsoft.com, kernelfans@gmail.com Subject: [PATCH v13 06/18] arm64: hibernate: abstract ttrb0 setup function Date: Thu, 8 Apr 2021 00:05:25 -0400 Message-Id: <20210408040537.2703241-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210408040537.2703241-1-pasha.tatashin@soleen.com> References: <20210408040537.2703241-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210408_050548_444109_5F5B413A X-CRM114-Status: GOOD ( 15.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, only hibernate sets custom ttbr0 with safe idmaped function. Kexec, is also going to be using this functinality when relocation code is going to be idmapped. Move the setup seqeuence to a dedicated cpu_install_ttbr0() for custom ttbr0. Suggested-by: James Morse Signed-off-by: Pavel Tatashin --- arch/arm64/include/asm/mmu_context.h | 24 ++++++++++++++++++++++++ arch/arm64/kernel/hibernate.c | 21 +-------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index bd02e99b1a4c..f64d0d5e1b1f 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -115,6 +115,30 @@ static inline void cpu_install_idmap(void) cpu_switch_mm(lm_alias(idmap_pg_dir), &init_mm); } +/* + * Load our new page tables. A strict BBM approach requires that we ensure that + * TLBs are free of any entries that may overlap with the global mappings we are + * about to install. + * + * For a real hibernate/resume/kexec cycle TTBR0 currently points to a zero + * page, but TLBs may contain stale ASID-tagged entries (e.g. for EFI runtime + * services), while for a userspace-driven test_resume cycle it points to + * userspace page tables (and we must point it at a zero page ourselves). + * + * We change T0SZ as part of installing the idmap. This is undone by + * cpu_uninstall_idmap() in __cpu_suspend_exit(). + */ +static inline void cpu_install_ttbr0(phys_addr_t ttbr0, unsigned long t0sz) +{ + cpu_set_reserved_ttbr0(); + local_flush_tlb_all(); + __cpu_set_tcr_t0sz(t0sz); + + /* avoid cpu_switch_mm() and its SW-PAN and CNP interactions */ + write_sysreg(ttbr0, ttbr0_el1); + isb(); +} + /* * Atomically replaces the active TTBR1_EL1 PGD with a new VA-compatible PGD, * avoiding the possibility of conflicting TLB entries being allocated. diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c index 0b8bad8bb6eb..ded5115bcb63 100644 --- a/arch/arm64/kernel/hibernate.c +++ b/arch/arm64/kernel/hibernate.c @@ -206,26 +206,7 @@ static int create_safe_exec_page(void *src_start, size_t length, if (rc) return rc; - /* - * Load our new page tables. A strict BBM approach requires that we - * ensure that TLBs are free of any entries that may overlap with the - * global mappings we are about to install. - * - * For a real hibernate/resume cycle TTBR0 currently points to a zero - * page, but TLBs may contain stale ASID-tagged entries (e.g. for EFI - * runtime services), while for a userspace-driven test_resume cycle it - * points to userspace page tables (and we must point it at a zero page - * ourselves). - * - * We change T0SZ as part of installing the idmap. This is undone by - * cpu_uninstall_idmap() in __cpu_suspend_exit(). - */ - cpu_set_reserved_ttbr0(); - local_flush_tlb_all(); - __cpu_set_tcr_t0sz(t0sz); - write_sysreg(trans_ttbr0, ttbr0_el1); - isb(); - + cpu_install_ttbr0(trans_ttbr0, t0sz); *phys_dst_addr = virt_to_phys(page); return 0; -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel