Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1710888rdb; Mon, 8 Jan 2024 07:56:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ76/ozsyFWQNWnhyvf1v3yAolQn2WGQwlNM/RJ6LQtruR0SF2VDnE2xRfpNeQ3TgaZdD7 X-Received: by 2002:a05:6a20:144b:b0:199:e5d2:4d7c with SMTP id a11-20020a056a20144b00b00199e5d24d7cmr38313pzi.102.1704729377371; Mon, 08 Jan 2024 07:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704729377; cv=none; d=google.com; s=arc-20160816; b=td6GRPWIZNQ8t7rastQqS75LR6pNNBBgQ76ZyAOP2JQdMYWnJzbZ/Rv8iR3KW1VMJK ynBYVdZQaCF5LeoV+aK0Ej94LpWwZagwbuJ6qAR9L8i7C2YxCF3nQl2XeJa6D3vbMBIF aT2gPHftbxuTytqLl24Dcjf1WpluR84z4k4E1yXevLybL3mMQ21lRcll9ZQWHIfKmJPY MAnXdT7Y2fZaSjqm0juMevB/812YKwle1un31wm2vr46GuPODi1wYh8QtJDxcWen8eCD ikzi1vrYTtcHjI2vLZXknE3PJnYhiHKTBzVtawQypd1gepEiwoVBzFp31R+MgBB1gyrT ls4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=wlmMDXt4WNqwXyUOMOsSVKmwhytcWcHiBZ+ufp5oGhE=; fh=j1jAentV55xHhMh3jFeTCXtgI7tCf3Zcsm4lnzFbqME=; b=IwsLfDG8XBb9qwO5HumdtLMIunkCNhJqkrY0+9aUtgGBJyuva23gTffZMYy++T43Ry 2FqEGXj2U0FqisSaNyJPQuFOG/oCXEZ+qYf/q/iar9+MQRf3lTZTUSHQ47mSFeS9MMUA tP+1Nl0UwV/siqs6AXoArZr0Zff5adZ5DyLDo1fd2mxDu+d0LNAJlLprG6FbESNStfM/ Wi7Ke+BXnPOjtwmO2gnl2cv9PGrfpck+V85Qp9C3z3saEwKSfM5cLsM5tkoOfbT/06TZ aDGEHWaM6YfC5zUcFLAXvBaZtlfxxc+5H9ohX/VMRqdxo0Ud07Ledkqm1uvVTxFaADVD gMew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19807-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19807-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y16-20020a634b10000000b005c6cc61ff0csi37581pga.152.2024.01.08.07.56.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 07:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19807-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19807-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19807-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 70DB6B21EAD for ; Mon, 8 Jan 2024 15:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8479451C2B; Mon, 8 Jan 2024 15:55:05 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9EA451C36 for ; Mon, 8 Jan 2024 15:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 087B6C15; Mon, 8 Jan 2024 07:55:48 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.89.149]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1DF453F64C; Mon, 8 Jan 2024 07:55:00 -0800 (PST) Date: Mon, 8 Jan 2024 15:54:58 +0000 From: Mark Rutland To: "Brandt, Oliver - Lenze" Cc: "linux-arm-kernel@lists.infradead.org" , "will@kernel.org" , "catalin.marinas@arm.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] arm64: mm: disable PAN during caches_clean_inval_user_pou Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Oliver, On Mon, Jan 08, 2024 at 01:00:39PM +0000, Brandt, Oliver - Lenze wrote: > Using the cacheflush() syscall from an 32-bit user-space fails when > ARM64_PAN is used. We 'll get an endless loop: > > 1. executing "dc cvau, x2" results in raising an abort > 2. abort handler does not fix the reason for the abort and > returns to 1. > > Disabling PAN for the time of the cache maintenance fixes this. Hmm... the ARM ARM says PSTATE.PAN is not supposed to affect DC CVAU. Looking at the latest ARM ARM (ARM DDI 0487J.a), R_PMTWB states: | The PSTATE.PAN bit has no effect on all of the following: | | o Instruction fetches. | o Data cache instructions, except DC ZVA. | o If FEAT_PAN2 is not implemented, then address translation instructions. | o If FEAT_PAN2 is implemented, then the address translation instructions | other than AT S1E1RP and AT S1E1WP. So IIUC, DC CVAU shouldn't be affected by PAN. This could be a CPU bug; which CPU are you seeing this with? Mark. > Fixes: 338d4f49d6f7 ("arm64: kernel: Add support for Privileged Access Never") > Cc: stable@vger.kernel.org > Signed-off-by: Oliver Brandt > --- > arch/arm64/mm/cache.S | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/arch/arm64/mm/cache.S b/arch/arm64/mm/cache.S > index 503567c864fde..333c4c2baa568 100644 > --- a/arch/arm64/mm/cache.S > +++ b/arch/arm64/mm/cache.S > @@ -70,10 +70,12 @@ SYM_FUNC_ALIAS(__pi_caches_clean_inval_pou, caches_clean_inval_pou) > */ > SYM_FUNC_START(caches_clean_inval_user_pou) > uaccess_ttbr0_enable x2, x3, x4 > + ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN, CONFIG_ARM64_PAN) > > caches_clean_inval_pou_macro 2f > mov x0, xzr > 1: > + ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, CONFIG_ARM64_PAN) > uaccess_ttbr0_disable x1, x2 > ret > 2: > -- > 2.43.0