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: 12044157 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=-17.0 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=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 6E418C433E0 for ; Mon, 25 Jan 2021 19:23:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 0DA5C21D79 for ; Mon, 25 Jan 2021 19:23:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0DA5C21D79 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=merlin.20170209; 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=Cb7lUtrdJEe0du49V3IcGM9L0UUL/aUMMHdq8ijt4t8=; b=Xle+lpI2RAxr3uRHyxih7akj3s o+eaUnLDLTjNktg4FQfGGSN20xilp7C74pujwU4HMgH30m08yYQ89tmJzFeI6VE3OViqVEyxChXsR zLXdiKZjnIt38TIh39dlLnUAd/c5WJpkvJoeWb7GY11m+mNzI5vfsCdJkbTloveyuNoE8pPk/65px bmZ4Y4PaYUk4iCzYnOckEtXTHuzM8xOwsfzZz8NUyV6iJzOLqv3R/x0Z4gt1ChlIkmStCUd4u6Vgv YmekzJX/i1DIZJz6sqXC6oiaBcAJEsjy9yuRB1LXTjtKWiDvuJtn4fHzTkWZP6wFc4SNDM2R2VPKt Xzasepeg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l47RC-00084Y-8c; Mon, 25 Jan 2021 19:22:10 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l47Ok-00078E-D4 for linux-arm-kernel@lists.infradead.org; Mon, 25 Jan 2021 19:19:56 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id n14so1953460qvg.5 for ; Mon, 25 Jan 2021 11:19:37 -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=iEc3YwQ2h+DmslPheE3zYa8UIkZWq4iGT1p0BevkKTuF2bainAgDnojwt/FSGhlYdf fqsfMM5lWNQ49RcRRMMRvasEVSnPnS5onHWI1TyXHZ8jub10NFBynio/6TkET5zzP9zT kdI1MNLW8aHLooC3DYWFb/newvuEggadExb3HrnvA3+/o7DAPYhhqDiI+PeSBnm18eTY Zo35pBXUyXfwXdtXURnYhPQENO9ZLwOmw0Qq+ZpXR4W+mY7iU9aP0QRfIfBucwtoIWu5 g/R7lKnOvDvA07gu3BefHB91QCwiQw62/x+nxGmfCei1FDAFMr86V3dLe8Ewq/1MQw4K brwg== X-Gm-Message-State: AOAM5305hUORTNoEI1kGU0nqEsnchFg0m4n52BXlxhwWl5b45SfkHvrf cf94Q70sQglpNo6bD6U2TYrLaA== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210125_141938_528786_A4A62EAD X-CRM114-Status: GOOD ( 13.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);