Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp173000lqr; Wed, 5 Jun 2024 02:32:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlH0cRcyH6Oh2xBPcUOtKFtDW0IviG/50+/Z/tRt9lVYv+m+MIp5r4y81mLJ69EsBsE6K9zikh0yphWDtJdeyg+ZfsigbXyi8E0zmTzg== X-Google-Smtp-Source: AGHT+IHEj2fZYlskviKF/IOFCqj87pzg2RMSyph/0pNea4T3CTm4tCgpgMrDn1lX+8X7jIPAZqRi X-Received: by 2002:a05:6a20:dda3:b0:1b2:ad1b:8982 with SMTP id adf61e73a8af0-1b2b714ab23mr1910308637.50.1717579948730; Wed, 05 Jun 2024 02:32:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717579948; cv=pass; d=google.com; s=arc-20160816; b=rI7wMYXBURAFXVAEvgl0bVbMD6wwnnz/dm7zdimFfGA7TPPY7VcA0tyirODJZJv3Rx ZKOUAGE9bJq4JaZ9fBJJU0Jv3BgMmgOfDI29t4Tc9l3WDUN0IrrrCU1bIm7rX1QR0Zx1 ycfj8u4+dIdd3xWq/K4auECqoa4+RTy36TrLRCpPXl7tXRIEhCZ8fKv8n5pbYwYy7jWm 6M0YKKw0o5bKKIzchQ/ikhxuRoCO4dzw6/yTTQPx4d7F4hYzh0PWS1T7LIQBvUcsdMAB 6dAWumIk4czIZermJwqVrU7eiDzWMUYwa9T2jzthQCumRpeMAqrAul73lzFlYCGQ5Fc7 s/6w== 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=oJRXYFLikGsBT2fsLU903UcNGiG42Kp+O5iAnZuqaRQ=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=Ns1jcgZIqcYMTTfvBYFVFhAkEwOxvBC8ZA8kQIEpIsIZQ6UQsa8h67OUP4sIx8i2d1 2Cb89hyBkNq9dPTuKx5Yooxh3jPvaXsRjheOIpNCyRabVXyFCqBd68IhAED71vOP9Z3T YodG7x78MOl3KUZqyfGpzkKKE87CNuHjxMbXSc2Y1JHPhx7h8smjVW6sOwN6GTFMA7w9 ezA5G0aT8rN8rw2iTgV0v/hxm6llLhzwjKMvaQ8QcQSR17+4YkJAqM0lX7UaRdLLOLUG zgU23TtwFu1P/KU/dpYZpSp1DF5S8uKQWcVKpWzMX6PJVo66ySLtbzoExp5XHqhYMGQ6 7UYA==; 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-202102-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202102-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 d2e1a72fcca58-70242e672a4si3396703b3a.387.2024.06.05.02.32.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 02:32:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202102-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-202102-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202102-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 57FC4281F12 for ; Wed, 5 Jun 2024 09:32:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5113D192B71; Wed, 5 Jun 2024 09:30:34 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 455751922C3; Wed, 5 Jun 2024 09:30:32 +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=1717579833; cv=none; b=bXoIHbTfX4trEvPw6U2jGZvw0mPdtOqfUNlvUlse20QWAPKbQwGuT6yGF6HjpomAemb8HnxFhI+uoOTd/4TJT8wfa/A7VwSPbmIFlKZbrUFr/5C3mD/qc7gLwtw3Ny7utgRIHpEAF7leLva9jlEJtmkMaPeWeRfIcuxxOhx5IWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717579833; c=relaxed/simple; bh=wza1+sttapH4jBfrntlsthBBKVE0WRMaK45u5krWryo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WBnOoCqGSDhrh2ASY+951oyRhy5ACN+utstGI8ghJQ/RMVTYJzI0iJpbWAndYbnta6ddmchHlR5JW9J9vU1XRdD5uf5i724e99L/LNzSbB/3wC5DpSZ4OJV3PWJovy5dijE1oFqxSkLEZwbrTM3GXfDbBW1OCKTiMQ+0otSEJY8= 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 35386DA7; Wed, 5 Jun 2024 02:30:56 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.39.129]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D0D763F792; Wed, 5 Jun 2024 02:30:27 -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 v3 03/14] arm64: realm: Query IPA size from the RMM Date: Wed, 5 Jun 2024 10:29:55 +0100 Message-Id: <20240605093006.145492-4-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240605093006.145492-1-steven.price@arm.com> References: <20240605093006.145492-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 --- Changes since v2: * Drop unneeded extra brackets from PROT_NS_SHARED. * Drop the explicit alignment from 'config' as struct realm_config now specifies the alignment. --- 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 b11cfb9fdd37..6c29f3b32eba 100644 --- a/arch/arm64/include/asm/pgtable-prot.h +++ b/arch/arm64/include/asm/pgtable-prot.h @@ -70,6 +70,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 3a992bdfd6bb..d34e05b339ae 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -7,6 +7,11 @@ #include #include +struct realm_config config; + +unsigned long prot_ns_shared; +EXPORT_SYMBOL(prot_ns_shared); + DEFINE_STATIC_KEY_FALSE_RO(rsi_present); EXPORT_SYMBOL(rsi_present); @@ -63,6 +68,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