Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp358863lqo; Thu, 16 May 2024 08:16:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7IoAUL7jXjUGEIbEkTGnT7H7qflhI54ZWIyPnriBNKJGgXRk/dwaXxNqdpX1n/6qY+n4UsXiTKAVxKnVW9+tcJDDl/ybVZsyAKUhjhA== X-Google-Smtp-Source: AGHT+IEIolbB374Rd2xL6DmaibN5Nh1h2AKIsgf6UzJhg3SOZh/sVHRuAZKLR1LV0u+zknCS9G4X X-Received: by 2002:a17:90b:11cc:b0:2b5:fce8:59f6 with SMTP id 98e67ed59e1d1-2b6cc14b924mr18235958a91.1.1715872609449; Thu, 16 May 2024 08:16:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715872609; cv=pass; d=google.com; s=arc-20160816; b=xFgTUgTKtMTAYuvcr1cvO+GsQy3Uv/OBzRVlhVuEQpYBR53KZXrZ1tRed2wgAGkJ+H PbUnVBuA/LJLVMgmRfkn4vLA3+ZVa8nFwahyfjMtxz42XDc7V4kyDhlMB+wE6J0uotg2 iOr9c5DORJO6sbUb24Xxd+2D2e1ENS6YSWxYZkXvyd5WAxoFGhu/uWspebI5UWUMiYlW p8qUXDi98QLmnlHvFr9z0I32VgGH7bB1OQUW/UM/ouohV6IaCMjPivbC1PHhwR+GTRom JjmFRmcTg6PrheT6sSwl5KIPQAgN4Sk3lDuK4yza6UNJHwbsw9YpaLMVQ0W3nvtYutUy we0g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=6A/bdHf3jLBRmHVD8bb4DG/L8JPgDOuVh9OiFMjfvtc=; fh=gr72O3brLFpZhr6FeDvPNeeFNEUnAC3Wruy9APIou2g=; b=GYL9ygUVh00g8zZirAHVDczEbPkfXRs7Fl78dIdX2Mjj236V0Q3VheV8Vz3OtGUnno cdp8nfuFJUngIr94klHt1ZnR1oj6UgnvuOvIKAgHMGZWDlbUQOsqJAnf3JKXSv/1I2rO D6hO2aAlqKHdec53aXkLMrmMAmX+Ib9zi/p71h5QNo7wdCHaq88nHlck4S0OPK4jwyz1 nsPiL3EmgLcmnW+zEpRwp+zqoWla4Kq+2QDMxEYCQdXB2wtW9xWP2W8wFCJCIV07zcQl Z2O8exUZr6ofYCpx1cCzgQAF7LenNmCh20njkFsNtSeLjMfYvAb/587wZxWDx/4wt36m T9Vg==; 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-181216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181216-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 98e67ed59e1d1-2b670e35661si791516a91.26.2024.05.16.08.16.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:16:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181216-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-181216-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181216-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 BA6DBB22CD1 for ; Thu, 16 May 2024 15:14:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5C6814D435; Thu, 16 May 2024 15:13:53 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF17F14B973; Thu, 16 May 2024 15:13:50 +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=1715872433; cv=none; b=UOeFhINK4Kc1V0OL0XevBaYCnW0nGjcjV4YinYzweiiY/tGccN+VmZZ/Mz5tqablrcAbVvQrUX1HeetuLoLYqedMPvhx7uCswwz5Moyo8J5QcSW6s9T1cqG3uoc7Ie2Li2o/Nw5CyPhDsBHymWKSiDSJxJf9/kV/k5PM9NsIquw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715872433; c=relaxed/simple; bh=XfgR26NvsXa0WA/2rJqxXL9YCkCSEKI2m8bMfsvqjog=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hKHg9cqxoquAgBLBB8jzbfygXBgubCZRZ0e4BpXYdjgWUZrIrPGt1z1nmzuxcW3TkoKfcV72xHaVJwPfNz1BQu5sZfa+sD7BmJmzU/f8977Y+1VtvPAROkIWc1Wmedxw6VYFW6a9kZynbTgpWsGjbMoDIgoshAutZflu+PAZs+c= 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 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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); >> } >