Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp2125183pxb; Fri, 8 Oct 2021 01:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBtdrZpUnSEyCVB3ddD+TflIqwOJgO8iWHRHTFFLEo8wvlRZLn6DBX0dN6zwSYlBX3z52Q X-Received: by 2002:a17:90b:1105:: with SMTP id gi5mr11054185pjb.100.1633680288391; Fri, 08 Oct 2021 01:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633680288; cv=none; d=google.com; s=arc-20160816; b=KVfHwwtuoVkGCaK3Yp7WY9I+5ZZbHIGu3Lhf3ktbjivcY9007mUhbXWtaNTKQ7EqEe tXs8eDdM24+xYXsCcWdOLerA+TTxeL0Nc9Z3ij2vttXcXvZeE/OmYAcrvij4d6P/yd9V g063NBfAGFNOQB8faAIOVZjNtsZXdPxxiq2XiGbSyxZibQ58Zu29XBWRjFAWQes1ZxoM aNUDzPFW1lQKImBP40A3kjSK0eWGrI382WRfkBAg/bOvnL+4tE0Wbwmyjl6e/vcRVrKm KunWQdcz6M3l1zV8+eDrTi8Ok0QLTvGKndpthGatXuaoDp9L4qLFhgtbUGaEBR59M01q 8WNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5z6Zw25f7vuKsiv2bCYG85pzb55+XOGPbXQYruqhD+w=; b=Z9cCggfKjnnzNvj6YQT81Lnwm6Z+DC8QbxcVEHO+R1CRQRiJDvTTUVbSphpmAPBFLj /uKap4Nd/wGVjyW5CFcSVTAsCOGkCicK7Zna1bqSAfuOXsKVl+b7zvOhcKQ/XZlR1+iw m9ZVjHuAEWmgtzv1GFACoBoJ757NhXNlRApUUqR2monLwwLDBNfoKCAv0Y4cWrpgI5wr zIwwHreoIyZDLEY6KWH1xqOTsEwS+KcGpEpIImHxWN1t+YHDB0ebNzDSVW2gd6YI/H91 P5u9xjCQ+oMnrd8Cueq17fTXOXOc90M+rquBqW43q/mN+CeFqpYg+MPFfr0dPXYTdX2m UD6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bLEf2Qd3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si2688941pgk.560.2021.10.08.01.04.35; Fri, 08 Oct 2021 01:04:48 -0700 (PDT) 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=k20201202 header.b=bLEf2Qd3; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbhJHIFI (ORCPT + 99 others); Fri, 8 Oct 2021 04:05:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:60364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233532AbhJHIDT (ORCPT ); Fri, 8 Oct 2021 04:03:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB10661037; Fri, 8 Oct 2021 08:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633680080; bh=jBP5YiJelY1gFHbkIeJVER6Kc4RrNqrmg0M9IIt5CTE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bLEf2Qd3vCQd0wunvozQAOcFzTgr5ptD+soEtOINt59Vqj2rMFe6LV6JiHTWbCtve 8juOuaYIzuEwFyla0xtdk0D6BAXpxZG4r7ekbBeZ5N/R3rmkRsVzvfGx0UbsvSb6F4 B2RFw27JfS6boYJEofuBqUAzsmsbP40ciYauPfZtgpQ65UDCyh2hrMYjFb7ZKCWgCS wd4+hkSxIaKiOIK7OIeFh8cfo/UMyiwmkLp5rnZIABeKLUxQXLTTnAq/l4M1guFFYa iYR48lRMOz3NeUiW1sbYo6+9nTt6Q70t+rFlMWuOV+9rzU8oRaQ2cJzqIGO+YfD9RH 36JZyDm3sVHTw== Date: Fri, 8 Oct 2021 09:01:15 +0100 From: Will Deacon To: Huangzhaoyang Cc: Catalin Marinas , Mark Rutland , Suzuki K Poulose , Ionela Voinescu , Quentin Perret , Vladimir Murzin , linux-arm-kernel@lists.infradead.org, Zhaoyang Huang , linux-kernel@vger.kernel.org, ke.wang@unisoc.com Subject: Re: [RFC PATCH] arch: ARM64: add isb before enable pan Message-ID: <20211008080113.GA441@willie-the-truck> References: <1633673269-15048-1-git-send-email-huangzhaoyang@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1633673269-15048-1-git-send-email-huangzhaoyang@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Oct 08, 2021 at 02:07:49PM +0800, Huangzhaoyang wrote: > From: Zhaoyang Huang > > set_pstate_pan failure is observed in an ARM64 system occasionaly on a reboot > test, which can be work around by a msleep on the sw context. We assume > suspicious on disorder of previous instr of disabling SW_PAN and add an isb here. > > PS: > The bootup test failed with a invalid TTBR1_EL1 that equals 0x34000000, which is > alike racing between on chip PAN and SW_PAN. Sorry, but I'm struggling to understand the problem here. Please could you explain it in more detail? - Why does a TTBR1_EL1 value of `0x34000000` indicate a race? - Can you explain the race that you think might be occurring? - Why does an ISB prevent the race? > Signed-off-by: Zhaoyang Huang > --- > arch/arm64/kernel/cpufeature.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index efed283..3c0de0d 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1663,6 +1663,7 @@ static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) > WARN_ON_ONCE(in_interrupt()); > > sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0); > + isb(); > set_pstate_pan(1); SCTLR_EL1.SPAN only affects the PAN behaviour on taking an exception, which is itself a context-synchronizing event, so I can't see why the ISB makes any difference here (at least, for the purposes of PAN). Thanks, Will