From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BBCFC25B74 for ; Thu, 16 May 2024 15:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8n62hETfDniThABOenvYt8HEnaiXkGYbYowOqHBUNXI=; b=rnN1HVicNenWzU gqIiYXr62rtIG+/iY7D+YNOhnNiTYkBsmgUzVvEPdn29Y++GWRxC6Dvpk5zRmXzLfhaOnm2sRob75 Vj3Lv4upXB+SUIy3XkRlDVNzYZ2YIOLZF3Z+cpmKlJZ7gHOAfLxF4dh+8d7WgU4XLew1BquqfZM2D 1//qNTaHo8m3xtXnYerK6CQaOm3gjcnVJdGaOp/L53uBF62m4yvDrCgJMTAEZ+j8bDHF2l1dyzgad nTLcACWzqjPFPWLXFEbRnn6N196V9rgAuGNjpsL193tmz+y51BKINfHlEiX+Px49HF23Etvz0q3Vl 1wMj7LpVWPXaoKGBhl6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cns-00000005H1w-3jfy; Thu, 16 May 2024 15:13:56 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s7cnp-00000005H1H-13VC for linux-arm-kernel@lists.infradead.org; Thu, 16 May 2024 15:13:54 +0000 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 5B7E8DA7; Thu, 16 May 2024 08:14:12 -0700 (PDT) Received: from [10.1.25.38] (e122027.cambridge.arm.com [10.1.25.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C64F3F7A6; Thu, 16 May 2024 08:13:45 -0700 (PDT) Message-ID: Date: Thu, 16 May 2024 16:13:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 03/14] arm64: realm: Query IPA size from the RMM To: Catalin Marinas 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 References: <20240412084213.1733764-1-steven.price@arm.com> <20240412084213.1733764-4-steven.price@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240516_081353_433911_3690F1A9 X-CRM114-Status: GOOD ( 18.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 13/05/2024 15:03, Catalin Marinas wrote: > 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? No idea - I'll remove a set! >> #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). Good suggestion - I'll update this. It turns out struct realm_config is already missing "hash_algo" (not that we use it yet), so I'll add that too. Thanks, Steve >> + >> +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); >> } > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel