Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1880198lqm; Fri, 3 May 2024 09:01:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVJ76/u9h4KUvs1+pZUCYC+qnP1J27TErToPlKznR58YSedemFMARisGP7+rzwWt3NJIuA0NGCBPor17kUdvxqlfHkEpW/8VZMHX5N/vA== X-Google-Smtp-Source: AGHT+IFfIPNITQZ215QxVNi8aRsN8f1ggKjZltdbeuw9RK21Ju5tey0aePh093QjLkDI1lHGCRXK X-Received: by 2002:a17:90a:4495:b0:2b2:7055:5a8b with SMTP id t21-20020a17090a449500b002b270555a8bmr3493214pjg.21.1714752073450; Fri, 03 May 2024 09:01:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714752068; cv=pass; d=google.com; s=arc-20160816; b=ugiOcthnnvse5NZERkRNE/ZaB7Mt4yW2kXo7KGsRxPizoIEnWWcvKRytPVVpcC64ty 2kkFJC26Fl3/VvYlqMN75Q6K853ax1829X3e/g4dNfxVjkpMm2mLHQQnn0u36+JjLKJ6 Us8kx9t1Nr005da1htaG1IjTGcdEPVr77rsEBYl7N0bqU2VU/ib8U0lYZnuHxKcjEyJM cTGrkKlc2xUirq1eMRbbiMxNx51H6+8K9gHz3vWBYlvYBAPv5QDmtd6P62FcSW31a+bP YD8lY6RSDMB4SIsxdPzcAaea3Wa4huJdM324YcWuPw7t2QAIAcDZKN2OdqeZ7/z6yrcA 7PKg== ARC-Message-Signature: i=2; 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=yBOnSiETHBNQTDOSOR3Ny3mlK8RrPEs3tW1dzCexG4s=; fh=XAyYhhPATWhivBAbfTkI4Ag2P6iDTzqToC5ojYe5b7M=; b=TkreuXBJ3tRMqDWQ2FbApDEIuDJuaT7RSyUDWvcV635EuL8pk/+vX7ocU/9OmYdcDH lvGNFtI1F0e1kq+wcD3LHFjaKMOtToJfCMm9u3buyu11pEjf2JxKalQWZo5pQcFkAvxu sbpRvoKn5MQZoQESGP6QXGq3KRG3GP+1S8dT9rzXx9Rj5p1+m5Q4sCLByhFpsl0UqZy9 g8YJfH/+i4Lo8w34lW0OOUEa2M8lRVQ2s74xpah0wJCmG3D60HCqONdjatk2Hugli60D iYUuAcgaAGrgNkvmccMD3cieZe83AgXUv0dVlC4KIyPEKPHCsTRDdNTsdK2FHdNLdhya 5FCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-167864-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167864-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id nl8-20020a17090b384800b002b1817dcd74si2115785pjb.142.2024.05.03.09.01.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 09:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167864-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-167864-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167864-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8820A281DA3 for ; Fri, 3 May 2024 16:01:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC964155328; Fri, 3 May 2024 16:01:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BDF026AF5 for ; Fri, 3 May 2024 16:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714752061; cv=none; b=O6d8d/8Zq4lPH0T0vzHF3XvU3fD40ay0FTxcU1uV3lEfubGlZvb9TkHVvBZ+P0K/bdlbrTc9CNNCWGezjWybMPVCH3e6czTMW1yGbCr5KaawJcppvgoTO08I52H647fdRHkCjdgvbtH8zBKf6P+N7bGqjeG76Sc9kkWZy4Ahstg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714752061; c=relaxed/simple; bh=AzrwmgjmsQOHBRTm2KCP6QAVQci1+KUTVkY25ZOI5G4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fUF9C3UM72BYbeEXYFTUCHDRBsGXcD89KAf2ywy68YQNmYQFlP9ETH435kHNa204U8r6Ty4PRwi7lpjBXKq9f/0Y2cWcc0EtvVIzgvtqQNEUUFYvQDsR4sOJ8gj5NrjOAgRKDoumVVpWbSVnGc1c7R5GMMZSobmQ/rziENqgOsw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 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 9C3BD13D5; Fri, 3 May 2024 09:01:23 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.34.156]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 41A513F793; Fri, 3 May 2024 09:00:52 -0700 (PDT) Date: Fri, 3 May 2024 17:00:49 +0100 From: Mark Rutland To: Liao Chang Cc: catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, tglx@linutronix.de, ardb@kernel.org, broonie@kernel.org, anshuman.khandual@arm.com, miguel.luis@oracle.com, joey.gouly@arm.com, ryan.roberts@arm.com, jeremy.linton@arm.com, ericchancf@google.com, kristina.martsenko@arm.com, robh@kernel.org, scott@os.amperecomputing.com, songshuaishuai@tinylab.org, shijie@os.amperecomputing.com, akpm@linux-foundation.org, bhe@redhat.com, horms@kernel.org, mhiramat@kernel.org, rmk+kernel@armlinux.org.uk, shahuang@redhat.com, takakura@valinux.co.jp, dianders@chromium.org, swboyd@chromium.org, sumit.garg@linaro.org, frederic@kernel.org, reijiw@google.com, akihiko.odaki@daynix.com, ruanjinjie@huawei.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v3 1/8] arm64/sysreg: Add definitions for immediate versions of MSR ALLINT Message-ID: References: <20240415064758.3250209-1-liaochang1@huawei.com> <20240415064758.3250209-2-liaochang1@huawei.com> 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: <20240415064758.3250209-2-liaochang1@huawei.com> On Mon, Apr 15, 2024 at 06:47:51AM +0000, Liao Chang wrote: > From: Mark Brown > > Encodings are provided for ALLINT which allow setting of ALLINT.ALLINT > using an immediate rather than requiring that a register be loaded with > the value to write. Since these don't currently fit within the scheme we > have for sysreg generation add manual encodings like we currently do for > other similar registers such as SVCR. > > Since it is required that these immediate versions be encoded with xzr > as the source register provide asm wrapper which ensure this is the > case. > > Signed-off-by: Mark Brown > Signed-off-by: Liao Chang > --- > arch/arm64/include/asm/nmi.h | 27 +++++++++++++++++++++++++++ > arch/arm64/include/asm/sysreg.h | 2 ++ > 2 files changed, 29 insertions(+) > create mode 100644 arch/arm64/include/asm/nmi.h We have helpers for manipulating PSTATE bits; AFAICT we only need the three lines below: ----8<---- diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 9e8999592f3af..5c209d07ae57e 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -94,18 +94,21 @@ #define PSTATE_PAN pstate_field(0, 4) #define PSTATE_UAO pstate_field(0, 3) +#define PSTATE_ALLINT pstate_field(1, 0) #define PSTATE_SSBS pstate_field(3, 1) #define PSTATE_DIT pstate_field(3, 2) #define PSTATE_TCO pstate_field(3, 4) #define SET_PSTATE_PAN(x) SET_PSTATE((x), PAN) #define SET_PSTATE_UAO(x) SET_PSTATE((x), UAO) +#define SET_PSTATE_ALLINT(x) SET_PSTATE((x), ALLINT) #define SET_PSTATE_SSBS(x) SET_PSTATE((x), SSBS) #define SET_PSTATE_DIT(x) SET_PSTATE((x), DIT) #define SET_PSTATE_TCO(x) SET_PSTATE((x), TCO) #define set_pstate_pan(x) asm volatile(SET_PSTATE_PAN(x)) #define set_pstate_uao(x) asm volatile(SET_PSTATE_UAO(x)) +#define set_pstate_allint(x) asm volatile(SET_PSTATE_ALLINT(x)) #define set_pstate_ssbs(x) asm volatile(SET_PSTATE_SSBS(x)) #define set_pstate_dit(x) asm volatile(SET_PSTATE_DIT(x)) ---->8---- The addition of and refrences to and arm64_supports_nmi() don't seem like they should be part of this patch. Mark. > > diff --git a/arch/arm64/include/asm/nmi.h b/arch/arm64/include/asm/nmi.h > new file mode 100644 > index 000000000000..0c566c649485 > --- /dev/null > +++ b/arch/arm64/include/asm/nmi.h > @@ -0,0 +1,27 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright (C) 2022 ARM Ltd. > + */ > +#ifndef __ASM_NMI_H > +#define __ASM_NMI_H > + > +#ifndef __ASSEMBLER__ > + > +#include > + > +extern bool arm64_supports_nmi(void); > + > +#endif /* !__ASSEMBLER__ */ > + > +static __always_inline void _allint_clear(void) > +{ > + asm volatile(__msr_s(SYS_ALLINT_CLR, "xzr")); > +} > + > +static __always_inline void _allint_set(void) > +{ > + asm volatile(__msr_s(SYS_ALLINT_SET, "xzr")); > +} > + > +#endif > + > diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h > index 9e8999592f3a..b105773c57ca 100644 > --- a/arch/arm64/include/asm/sysreg.h > +++ b/arch/arm64/include/asm/sysreg.h > @@ -167,6 +167,8 @@ > * System registers, organised loosely by encoding but grouped together > * where the architected name contains an index. e.g. ID_MMFR_EL1. > */ > +#define SYS_ALLINT_CLR sys_reg(0, 1, 4, 0, 0) > +#define SYS_ALLINT_SET sys_reg(0, 1, 4, 1, 0) > #define SYS_SVCR_SMSTOP_SM_EL0 sys_reg(0, 3, 4, 2, 3) > #define SYS_SVCR_SMSTART_SM_EL0 sys_reg(0, 3, 4, 3, 3) > #define SYS_SVCR_SMSTOP_SMZA_EL0 sys_reg(0, 3, 4, 6, 3) > -- > 2.34.1 >