Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp8848lql; Fri, 12 Apr 2024 01:43:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXdQkLC7nY8LCYjxFz7NC7uqLyaEWl9DoC5m4mvo13IpZ5T1oH+w9p7TDMmVhKdrSkbQbMuDbesWTtMjlHKMTa6LgPeVwmMgM1YYsGQxg== X-Google-Smtp-Source: AGHT+IG9t+MakAeHG2urBdlcvj+Y8FUUceet4PQ6eg9NF0sDu3uveCbm7BtSgkW6Wuj/drCGi5Fr X-Received: by 2002:a17:902:c94b:b0:1e4:54d1:a159 with SMTP id i11-20020a170902c94b00b001e454d1a159mr2010317pla.47.1712911408540; Fri, 12 Apr 2024 01:43:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712911408; cv=pass; d=google.com; s=arc-20160816; b=bFrJKzagrl1fRJYGrvqSIqqoDUAoL5BLNxKuL10b8rf7HRJAaIULOFGuwYHaD3sO9F N7JdBCI09OZZnqfXIVKUXy46xu3JPEXM6g3/qWcUHC2xyKOACLhKPWNJ8V/k3jDHgW5K HL0KuGIyK4tsQ9du+c+qv0Zmnus+fv1CH741ww5r2YvktrzVVHfvObvWE/P8IP2FQFrJ mfZuapeccjMr4/yWklzGOiUIwAbZvJArLgCL4vQQVe0iTIXkNctxHXNC6ZBnV1zDrEgE b7RYeA6fI9XmJzxRWBT0r2aqJLdVX+2LMOlMS7ofNyQ+lxHS20J0A/g2od7qLwNdWHet QNwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pVnklfY+H6BdFjUvQGx6E8jOGdUxTm1RBojP0gl4+E4=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=IJB5pf5gi2FHSnB3dbi42IVlDk1SvcI3cEx3ibDqgXCXCtf3pVXXo5KG2X9dzNK0Pz pb7DPIAZIFUNdr/ezGA3xw1AAI0O3XE1KqJqRJwijZ+o0C1KNv3f6ZEJc+4QYSffyvfL QYgaTVax9bP5lYwiZNqpXFY2QHwRU8eRjnWSQdJleyUjsIAmos0zptxG6fe1aaZtOTQ4 tESxyZDzKYgClZ/hFYFpqbAiiQfZwMvxR9p6CGEobuyu877hTh3kIazjfOca9cy4IC+j 9Vty8bW0M0z9X2+1K4fXq18UK1ewYSzZ03xyg3R1U98YrqulWfdtQbQo+NMOF3fJk7/P DwGg==; 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-142255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142255-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u7-20020a170902e80700b001e2a41d265esi2837303plg.324.2024.04.12.01.43.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 01:43:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-142255-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142255-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 1DB842848C1 for ; Fri, 12 Apr 2024 08:43:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FFAA53384; Fri, 12 Apr 2024 08:42:31 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C74A481C2; Fri, 12 Apr 2024 08:42:29 +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=1712911350; cv=none; b=DxfhaoXwLpXP4GuwdmB7IOx9a/r/bP3JZsQWptZJBjvrZxZU4D5sy7FDWVEkPflbg/MwdEb7MllVxGKKDw8pCTKwdmimtJs8H/YrCow89NI8SaCuZ5CMlBb75jkg6Hvd/7iFi0RoarkAkDn32sfJdAM+SUP5f4m+ifY3XyPJoW4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712911350; c=relaxed/simple; bh=ljVVIaZArN/KM8bOfapl64lZF2OQzxkvoi0541n+v0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W/tW6lENETJQZetvHc5FNXedcL38zjHtsGe+/Zv/TjgFyioRbFJHOk2YeEFANs72vv0MLnhdflOS9XIkP/LQ0L6Nw2+ZR6AohRragP5nXCPSaAJNKUQKOzuFpMHUE3n6Jvk6xbdPpNH5HFne/egY8fgXDA8CBwW/z7yMm8nvTFs= 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 1D779339; Fri, 12 Apr 2024 01:42:58 -0700 (PDT) Received: from e112269-lin.cambridge.arm.com (e112269-lin.cambridge.arm.com [10.1.194.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BA4E83F6C4; Fri, 12 Apr 2024 01:42:26 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , Catalin Marinas , 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: [PATCH v2 03/14] arm64: realm: Query IPA size from the RMM Date: Fri, 12 Apr 2024 09:42:02 +0100 Message-Id: <20240412084213.1733764-4-steven.price@arm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412084213.1733764-1-steven.price@arm.com> References: <20240412084056.1733704-1-steven.price@arm.com> <20240412084213.1733764-1-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-Transfer-Encoding: 8bit The top bit of the configured IPA size is used as an attribute to control whether the address is protected or shared. Query the configuration from the RMM to assertain which bit this is. Co-developed-by: Suzuki K Poulose Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- arch/arm64/include/asm/pgtable-prot.h | 3 +++ arch/arm64/kernel/rsi.c | 8 ++++++++ 2 files changed, 11 insertions(+) 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)) #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; + +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); } -- 2.34.1