From nobody Thu Nov 28 05:45:44 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03B0821F431; Fri, 4 Oct 2024 14:43:48 +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=1728053030; cv=none; b=hciszmcLs9X+aXl1OCdJ9doVuAjqQzJ1poFzDSk1gY1/55cWqzf/PhCypM2rnPLYnPVBbPH+f3ha4tx/bmRtkYsZLqMY2Igfm70M04PYlIYIeuotYAX7nl8w59ZrHS62ZdntwjKPoFV7J8GyzgQc611oDqoEk7yEb5fRGRh7xQg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728053030; c=relaxed/simple; bh=ODJvRYmJGJNMTpJGPR+NNS8Px3aQ57wX3mDurAsVaaA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z0oNw4K83dllxGQq20bGYUGgYYhx372ivmR3oeB793oJ3tDEHXAAKDHjvj0llWQOMShemA5PPbIaSpeM1mDqEnu0XR0BxFcFWfJAs1C7ejB649y7HFC9w6Bs5gkseBnytLmBb+wJjz5vXAlgGMkQIido7S949kAezzQzk0JqiK4= 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 F100C339; Fri, 4 Oct 2024 07:44:17 -0700 (PDT) Received: from e122027.cambridge.arm.com (unknown [10.1.25.25]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED6403F58B; Fri, 4 Oct 2024 07:43:44 -0700 (PDT) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Suzuki K Poulose , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , 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 , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Steven Price Subject: [PATCH v6 05/11] arm64: rsi: Map unprotected MMIO as decrypted Date: Fri, 4 Oct 2024 15:43:00 +0100 Message-Id: <20241004144307.66199-6-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241004144307.66199-1-steven.price@arm.com> References: <20241004144307.66199-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: quoted-printable Content-Type: text/plain; charset="utf-8" From: Suzuki K Poulose Instead of marking every MMIO as shared, check if the given region is "Protected" and apply the permissions accordingly. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price Reviewed-by: Catalin Marinas Reviewed-by: Gavin Shan --- New patch for v5 --- arch/arm64/kernel/rsi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c index d7bba4cee627..f1add76f89ce 100644 --- a/arch/arm64/kernel/rsi.c +++ b/arch/arm64/kernel/rsi.c @@ -6,6 +6,8 @@ #include #include #include + +#include #include =20 struct realm_config config; @@ -92,6 +94,16 @@ bool arm64_is_protected_mmio(phys_addr_t base, size_t si= ze) } EXPORT_SYMBOL(arm64_is_protected_mmio); =20 +static int realm_ioremap_hook(phys_addr_t phys, size_t size, pgprot_t *pro= t) +{ + if (arm64_is_protected_mmio(phys, size)) + *prot =3D pgprot_encrypted(*prot); + else + *prot =3D pgprot_decrypted(*prot); + + return 0; +} + void __init arm64_rsi_init(void) { if (arm_smccc_1_1_get_conduit() !=3D SMCCC_CONDUIT_SMC) @@ -102,6 +114,9 @@ void __init arm64_rsi_init(void) return; prot_ns_shared =3D BIT(config.ipa_bits - 1); =20 + if (arm64_ioremap_prot_hook_register(realm_ioremap_hook)) + return; + arm64_rsi_setup_memory(); =20 static_branch_enable(&rsi_present); --=20 2.34.1