Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2066697lqo; Mon, 13 May 2024 07:04:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEEsT/tSelxT0wKTuwygGTQVQC3RaFFrQn2BWaUrY4K2HgtQjIrVCnHhKQTectRn5UFEwIn4dUnfCvRUmB59jtPFhI6nGXe1U+2lBtkQ== X-Google-Smtp-Source: AGHT+IH8+h7RuWXlnUekUFoIsRHLXTBvvw9NbtTghcAoH1yjmXespbIb/x3WyLPQCvt6ZwCOVfpf X-Received: by 2002:a05:622a:11d1:b0:43e:ec0:c7a0 with SMTP id d75a77b69052e-43e0ec0d820mr57505721cf.62.1715609079765; Mon, 13 May 2024 07:04:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715609079; cv=pass; d=google.com; s=arc-20160816; b=MYI5lDee4Pwv6EBfhZrxSuZeODvmn0XfK5cI3+UeSH2/E1F/16MWcX7dnjahON6Py6 ppH+PZRp44grIUlVZ3KcjuUm6PTOPYX/0sxtYttFbskMVSOrUSqCh3rdB1U4sJyipwvk NF0TAsmCr5L2/RaaJmedrRRxOobAlOmFtubNPYD1TWuzzBoKER4rSvy4mdvuzh9t1/h5 worbdj33bR6nQhWfrvHMxE6x+UrwUul6P6frPrSebzFMJ3fj3yQ/oVo4QFlUv2OBzxku fNxPvXFMjGxNxF18dCIvhUvjklmQiU7qzX2IS4xWU53eTZMoav+dIWzTYO7KKHeNitn7 oWUw== 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=xHlwq0Ps2mV2kQZjMBMVwT6k1wJT3foJ0s3qsRmntng=; fh=0PvXTblvcOsrMPT3yEGqxR5sUU4n6OEeMAbaOpzry54=; b=ZExH3MsW7k+hYb8vf1dPWeratNIkE/vplF88ngZvyIJKDN6Dflgl2S5DY91Z2LdL+i k8LxDDwm/ZIDAh8RHOXo+XTnetnTApiDj5p8YnOnRhfv5N4gHe8MbzVm4qyLZn8gYaOB TSX6MXcMRlDTs98lH5PHcwCKdxbv2i2OzvnBkUNBFtkmzWnRPsoL+25CutLL2X2BR6rq ZO3knesMXmMnWqS4qJ7RCpDF/JPEs/ZsPjhY5ibLQvsNYfyeoyuGJa+KEBhO9kqtZwVY 1GU6JLWAUwhU1XNlmfO1A/XUkUBqiWD7UrKUXFL2jsHp9LLeag/BjK3WBgmvc76n3DoN UAcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43e1c96191esi13123631cf.539.2024.05.13.07.04.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 07:04:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-177665-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177665-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2EA1D1C23269 for ; Mon, 13 May 2024 14:03:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 207F3153815; Mon, 13 May 2024 14:03:29 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8ACF950279; Mon, 13 May 2024 14:03:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715609008; cv=none; b=IpbAy+saQTitQIJQl5aVxx5BImj9m7OZ0WiohZYdUyy1PxqwgYjverR8bTl0VMCOtkLoTivqST2BGLv2DQnh7uBD5ccD9QRgw95MQZn4nROJSICk+0WD5Q9nC3GI5/LCLDoPWvj5+ab63eJPP0jcruWPT5E4OZMLe5Q09cWHe1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715609008; c=relaxed/simple; bh=K7veTtApNyiwjmLaFO5BMobsj0TYJEd3cEVzL9mDR7w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=chahyhx/xePUlSqPPjz3XDo+WfwF4WT4o25UZL9qdId7ac17Q+Xje82Y7VOkb3y/hh7M34uSxdEIkNrH6GNYFjk3SJ8v+yyCPgm/4kqcmtGlIBLyQ4dBhi+WYyg6e4BNtWzSHfStdk+JC0PjjCK6/qqaQnSG/xf6GuuSFBiVV3Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBA00C4AF17; Mon, 13 May 2024 14:03:24 +0000 (UTC) Date: Mon, 13 May 2024 15:03:22 +0100 From: Catalin Marinas To: Steven Price Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni Subject: Re: [PATCH v2 03/14] arm64: realm: Query IPA size from the RMM Message-ID: References: <20240412084213.1733764-1-steven.price@arm.com> <20240412084213.1733764-4-steven.price@arm.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: <20240412084213.1733764-4-steven.price@arm.com> On Fri, Apr 12, 2024 at 09:42:02AM +0100, Steven Price wrote: > diff --git a/arch/arm64/include/asm/pgtable-prot.h b/arch/arm64/include/asm/pgtable-prot.h > index dd9ee67d1d87..15d8f0133af8 100644 > --- a/arch/arm64/include/asm/pgtable-prot.h > +++ b/arch/arm64/include/asm/pgtable-prot.h > @@ -63,6 +63,9 @@ > #include > > extern bool arm64_use_ng_mappings; > +extern unsigned long prot_ns_shared; > + > +#define PROT_NS_SHARED ((prot_ns_shared)) Nit: what's with the double parenthesis here? > #define PTE_MAYBE_NG (arm64_use_ng_mappings ? PTE_NG : 0) > #define PMD_MAYBE_NG (arm64_use_ng_mappings ? PMD_SECT_NG : 0) > diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c > index 1076649ac082..b93252ed6fc5 100644 > --- a/arch/arm64/kernel/rsi.c > +++ b/arch/arm64/kernel/rsi.c > @@ -7,6 +7,11 @@ > #include > #include > > +struct realm_config __attribute((aligned(PAGE_SIZE))) config; Another nit: use __aligned(PAGE_SIZE). However, does the spec require this to be page-size aligned? The spec says aligned to 0x1000 and that's not necessarily the kernel page size. It also states that the RsiRealmConfig structure is 4096 and I did not see this in the first patch, you only have 8 bytes in this structure. Some future spec may write more data here overriding your other variables in the data section. So that's the wrong place to force the alignment. Just do this when you define the actual structure in the first patch: struct realm_config { union { unsigned long ipa_bits; /* Width of IPA in bits */ u8 __pad[4096]; }; } __aligned(4096); and maybe with a comment on why the alignment and padding. You could also have an unnamed struct around ipa_bits in case you want to add more fields in the future (siginfo follows this pattern). > + > +unsigned long prot_ns_shared; > +EXPORT_SYMBOL(prot_ns_shared); > + > DEFINE_STATIC_KEY_FALSE_RO(rsi_present); > EXPORT_SYMBOL(rsi_present); > > @@ -53,6 +58,9 @@ void __init arm64_rsi_init(void) > { > if (!rsi_version_matches()) > return; > + if (rsi_get_realm_config(&config)) > + return; > + prot_ns_shared = BIT(config.ipa_bits - 1); > > static_branch_enable(&rsi_present); > } -- Catalin