From patchwork Mon Jan 25 19:19:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12044117 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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 719A3C433DB for ; Mon, 25 Jan 2021 19:19:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 00FD02255F for ; Mon, 25 Jan 2021 19:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 00FD02255F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=soleen.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A6F758D0021; Mon, 25 Jan 2021 14:19:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A20C38D0001; Mon, 25 Jan 2021 14:19:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84B638D0021; Mon, 25 Jan 2021 14:19:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 6FB4D8D0001 for ; Mon, 25 Jan 2021 14:19:38 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 24BF4181AEF0B for ; Mon, 25 Jan 2021 19:19:38 +0000 (UTC) X-FDA: 77745261636.28.suit80_2607f0227588 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id D7BCA6D63 for ; Mon, 25 Jan 2021 19:19:37 +0000 (UTC) X-HE-Tag: suit80_2607f0227588 X-Filterd-Recvd-Size: 5344 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Jan 2021 19:19:36 +0000 (UTC) Received: by mail-qv1-f49.google.com with SMTP id 2so6730695qvd.0 for ; Mon, 25 Jan 2021 11:19:36 -0800 (PST) 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=I2bLiPX3VTIFYdlWvHrlv9bi90SZn0tAgsUExdtL3vw=; b=e7EeqPlQvWqFBbDxIS+wdmiqyKoOqI9OZZCgYolvZoI6Xiol0eFKvHPC1pWgm6Fiay k8gT8zBoIce+Xnc0+wfreyByeComQF0lOYUuI2FV338Zysdkz2m76fy7N3c+/gmDJcw9 Su+R42Mjqxnq0Z04YmcTRsTv2Dkqh0+vHQYSAzntfUfSzhuEiRsIZKtRGZNohQuoiMP1 37lX2zUf84XJ8SC5th4NIOoejS1ep2O1KTF5HUrMordiA0b/YGqqyz/FlLrRWNDMSTQ+ KGVrdwd2jN+Ly8WZH1xArA9m5WyRxE/jCVrqctcOR1sw8aXhiCqDGpRsGzUEBQZL0sci 0F2Q== 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=I2bLiPX3VTIFYdlWvHrlv9bi90SZn0tAgsUExdtL3vw=; b=pzm9pP3Lu0SPpCyW2JTrB1CSJ1nntAhXLY3gaZFZMZXJ1UUhRBIt4Vx2rawsKlJgaG PPKE3VV21dtsegFqpbRCxykvmzCHHbHgms89yULSoC/Mx45UzgR3ckqGZhCzBgIFxPv2 n/6PmSXninlQ/fL1xQ9RfGrmQ5kHzF7kI5RRrILdTHWn8LjiA00pfUssQOo2YnU5BVeQ +YuqfZoD1aj5/rNbkfVKbbkuc/lHWaz0CRdYpj7S9VfNBSBmeQZEOV3+ZXKlQJISIjCQ p2Has/20LnL65oTI3izU2Gpvv5oLSXY01TA2ZCBXusER8f5CBJ1GerVl8UuEJQgEQ6Zj 17DA== X-Gm-Message-State: AOAM533Yr7995icLpTJY3UwoCcvBUDVWMLC7EXg+2EF1PVFadxhVU95+ 3+kgSU36aX5HYKXjQ+541c0kxw== X-Google-Smtp-Source: ABdhPJzA63TTz10VNLj7mmheU/keqIHP7LOeLAzUTHMXQrqU9ZPOb8WN2VV8RoUDjNxuh0fZX6dq9g== X-Received: by 2002:a0c:d403:: with SMTP id t3mr2275554qvh.4.1611602376226; Mon, 25 Jan 2021 11:19:36 -0800 (PST) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id s6sm9047638qtx.63.2021.01.25.11.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 11:19:35 -0800 (PST) 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 Subject: [PATCH v10 07/18] arm64: mm: Always update TCR_EL1 from __cpu_set_tcr_t0sz() Date: Mon, 25 Jan 2021 14:19:12 -0500 Message-Id: <20210125191923.1060122-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210125191923.1060122-1-pasha.tatashin@soleen.com> References: <20210125191923.1060122-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: James Morse Because only the idmap sets a non-standard T0SZ, __cpu_set_tcr_t0sz() can check for platforms that need to do this using __cpu_uses_extended_idmap() before doing its work. The idmap is only built with enough levels, (and T0SZ bits) to map its single page. To allow hibernate, and then kexec to idmap their single page copy routines, __cpu_set_tcr_t0sz() needs to consider additional users, who may need a different number of levels/T0SZ-bits to the idmap. (i.e. VA_BITS may be enough for the idmap, but not hibernate/kexec) Always read TCR_EL1, and check whether any work needs doing for this request. __cpu_uses_extended_idmap() remains as it is used by KVM, whose idmap is also part of the kernel image. This mostly affects the cpuidle path, where we now get an extra system register read . CC: Lorenzo Pieralisi CC: Sudeep Holla Signed-off-by: James Morse Signed-off-by: Pavel Tatashin --- arch/arm64/include/asm/mmu_context.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 0b3079fd28eb..70ce8c1d2b07 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -81,16 +81,15 @@ static inline bool __cpu_uses_extended_idmap_level(void) } /* - * Set TCR.T0SZ to its default value (based on VA_BITS) + * Ensure TCR.T0SZ is set to the provided value. */ static inline void __cpu_set_tcr_t0sz(unsigned long t0sz) { - unsigned long tcr; + unsigned long tcr = read_sysreg(tcr_el1); - if (!__cpu_uses_extended_idmap()) + if ((tcr & TCR_T0SZ_MASK) >> TCR_T0SZ_OFFSET == t0sz) return; - tcr = read_sysreg(tcr_el1); tcr &= ~TCR_T0SZ_MASK; tcr |= t0sz << TCR_T0SZ_OFFSET; write_sysreg(tcr, tcr_el1);