Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3197271pxb; Mon, 9 Nov 2020 05:22:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJywcxKZ3tUXQC4DDVHKRrMhh9QkWk1TQERMBcltxivYopkXXo14Yx2GouGTlqWIdb4fSQ/i X-Received: by 2002:a05:6402:1ca6:: with SMTP id cz6mr14991798edb.129.1604928156087; Mon, 09 Nov 2020 05:22:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928156; cv=none; d=google.com; s=arc-20160816; b=zEW8AquTWTaXz3YGMcr9Z/nfmfk8DrlnZQAHuIRVmBA3CT4pRJecTVpHpoaN204yvr 2OB6HxhyDTXeqvFprmmpOSvIUhnqAlIzuvuwCZbIObuHqm9jc1zQOHApMwNWxXqmO4qW CsgVsq7J3Ytt6MtjIdHybv5MJDPh8O3WtKURkzN6SOZppDt7dcI99CKwt6ytNIK0+M79 DUROB0+wEhQf/q/Wh7zXCVfbl+yy9RC3n0GM1skQF1IXUfHqnUU6LaI+58ktHTf50Cdb aHN3/Fw8Vq/j95Lr7V16H98/fLQ3TTl2UJD/4JPYKNl+yzuKTovrCXFZgWBk3qHALWxe vQBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/c5ehtsTDsyMEoFSjeNMlDIc9ZcdB5ZynwGVAsrM9kI=; b=l2yvr4gYV0J78rGcqOnCaqI1xYydkYSylPKmMDAqdDgL0IwfqAFwHgRKQcbbKtVY5d uynsUbReulboJs8MommnP8x5+ER75c70iB3TlTxk36LcLeREIwY3s9AAwxkBaeymwMBE OAT2aq0LvsQdCdY0KfzkAc909wkZ1Zi4UhJ5pa6WxnhWsidMHdZiMrfCH+vwxFoDPAMO Hpl6FT4mWgm+sSOvLJCX6WqyUx4QwgEWZgEjkaRe2JXoAK73x989k6uS0aYUAQZR1vU1 RzYgYdCMuBVIAXBWxls6ovMitAXkOvUsYwng2sYfjbTzMulHzn/6a+3fxUPvSufDgJEm woNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SpnDoRYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w25si7283975edt.600.2020.11.09.05.22.13; Mon, 09 Nov 2020 05:22:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SpnDoRYX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387997AbgKINU7 (ORCPT + 99 others); Mon, 9 Nov 2020 08:20:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:48656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387996AbgKINU5 (ORCPT ); Mon, 9 Nov 2020 08:20:57 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3037F20731; Mon, 9 Nov 2020 13:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604928056; bh=l6rLJ2xKo2E8WHeVuF6D2vzrvCCYOm7OQHvX5Un47q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SpnDoRYXzxXeR9KqVN3NYk4gCNWMUcH06TCMnJ215ZTOnrFGbus3Jli6Jq/XQ6c0T wTxhI3nzE1PpldAGiLZcbV0glvfM8lNLp47pKrOh5EKDmQGp2AOSK5pmpOiI965nHO 4fDz9pOa34L2iBwLOe6KYUgUi4hzYTUvcr0qs8HI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman Subject: [PATCH 5.9 113/133] powerpc/8xx: Always fault when _PAGE_ACCESSED is not set Date: Mon, 9 Nov 2020 13:56:15 +0100 Message-Id: <20201109125036.122282349@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy commit 29daf869cbab69088fe1755d9dd224e99ba78b56 upstream. The kernel expects pte_young() to work regardless of CONFIG_SWAP. Make sure a minor fault is taken to set _PAGE_ACCESSED when it is not already set, regardless of the selection of CONFIG_SWAP. This adds at least 3 instructions to the TLB miss exception handlers fast path. Following patch will reduce this overhead. Also update the rotation instruction to the correct number of bits to reflect all changes done to _PAGE_ACCESSED over time. Fixes: d069cb4373fe ("powerpc/8xx: Don't touch ACCESSED when no SWAP.") Fixes: 5f356497c384 ("powerpc/8xx: remove unused _PAGE_WRITETHRU") Fixes: e0a8e0d90a9f ("powerpc/8xx: Handle PAGE_USER via APG bits") Fixes: 5b2753fc3e8a ("powerpc/8xx: Implementation of PAGE_EXEC") Fixes: a891c43b97d3 ("powerpc/8xx: Prepare handlers for _PAGE_HUGE for 512k pages.") Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/af834e8a0f1fa97bfae65664950f0984a70c4750.1602492856.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/kernel/head_8xx.S | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) --- a/arch/powerpc/kernel/head_8xx.S +++ b/arch/powerpc/kernel/head_8xx.S @@ -202,9 +202,7 @@ SystemCall: InstructionTLBMiss: mtspr SPRN_SPRG_SCRATCH0, r10 -#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS) mtspr SPRN_SPRG_SCRATCH1, r11 -#endif /* If we are faulting a kernel address, we have to use the * kernel page tables. @@ -238,11 +236,9 @@ InstructionTLBMiss: rlwimi r11, r10, 32 - 9, _PMD_PAGE_512K mtspr SPRN_MI_TWC, r11 #endif -#ifdef CONFIG_SWAP - rlwinm r11, r10, 32-5, _PAGE_PRESENT + rlwinm r11, r10, 32-7, _PAGE_PRESENT and r11, r11, r10 rlwimi r10, r11, 0, _PAGE_PRESENT -#endif /* The Linux PTE won't go exactly into the MMU TLB. * Software indicator bits 20 and 23 must be clear. * Software indicator bits 22, 24, 25, 26, and 27 must be @@ -256,9 +252,7 @@ InstructionTLBMiss: /* Restore registers */ 0: mfspr r10, SPRN_SPRG_SCRATCH0 -#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) || defined(CONFIG_HUGETLBFS) mfspr r11, SPRN_SPRG_SCRATCH1 -#endif rfi patch_site 0b, patch__itlbmiss_exit_1 @@ -268,9 +262,7 @@ InstructionTLBMiss: addi r10, r10, 1 stw r10, (itlb_miss_counter - PAGE_OFFSET)@l(0) mfspr r10, SPRN_SPRG_SCRATCH0 -#if defined(ITLB_MISS_KERNEL) || defined(CONFIG_SWAP) mfspr r11, SPRN_SPRG_SCRATCH1 -#endif rfi #endif @@ -316,11 +308,9 @@ DataStoreTLBMiss: * r11 = ((r10 & PRESENT) & ((r10 & ACCESSED) >> 5)); * r10 = (r10 & ~PRESENT) | r11; */ -#ifdef CONFIG_SWAP - rlwinm r11, r10, 32-5, _PAGE_PRESENT + rlwinm r11, r10, 32-7, _PAGE_PRESENT and r11, r11, r10 rlwimi r10, r11, 0, _PAGE_PRESENT -#endif /* The Linux PTE won't go exactly into the MMU TLB. * Software indicator bits 24, 25, 26, and 27 must be * set. All other Linux PTE bits control the behavior