From patchwork Mon Aug 19 13:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 13768354 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6C8DB1741F8; Mon, 19 Aug 2024 13:20:24 +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=1724073625; cv=none; b=mjM81N6Q4tI3E1JdIXqXX/eqES2K2ML83ECNyDTGQCPtjmCD7dkWss93gjwBLtEqUxvLWy4a9STvVBA9y534cs1GyNSY/sk4vq/MRr73Iesmh6ZvZCABDOROSgHGLxNGaSVgBSMUz8zWEtpZyneBH0DdEOU2+bpokn0z7Tsf8DY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724073625; c=relaxed/simple; bh=X9rSIQC9SH0+joSsR6x+uTW2R5jX6hBOUSDo1zmSjFk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dtyFHziGKLof1FSj3pd2Sf6U5/vb0WF/voyLfDC5cr1K2e26j8Z5MoJ279lK6Tpsnh/5gMbst++VqTgLE5kvd7mNrHHibIxvMzqheqqrq/TuoGZ5YhXAN1vtcn1JfGVH7MH3x8nUSk2teogVSDQRILgW+UQzWhr7vc20PagRfNA= 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 1229D339; Mon, 19 Aug 2024 06:20:50 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.85.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 69F013F73B; Mon, 19 Aug 2024 06:20:20 -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 , Gavin Shan , Shanker Donthineni , Alper Gun Subject: [PATCH v5 10/19] arm64: Override set_fixmap_io Date: Mon, 19 Aug 2024 14:19:15 +0100 Message-Id: <20240819131924.372366-11-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819131924.372366-1-steven.price@arm.com> References: <20240819131924.372366-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Suzuki K Poulose Override the set_fixmap_io to set shared permission for the host in case of a CC guest. For now we mark it shared unconditionally. If/when support for device assignment and device emulation in the realm is added in the future then this will need to filter the physical address and make the decision accordingly. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- New patch for v5 --- arch/arm64/include/asm/fixmap.h | 2 ++ arch/arm64/mm/mmu.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index 87e307804b99..2c20da3a468c 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -108,6 +108,8 @@ void __init early_fixmap_init(void); #define __late_clear_fixmap(idx) __set_fixmap((idx), 0, FIXMAP_PAGE_CLEAR) extern void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot); +#define set_fixmap_io set_fixmap_io +void set_fixmap_io(enum fixed_addresses idx, phys_addr_t phys); #include diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 353ea5dc32b8..06b66c23c124 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1193,6 +1193,23 @@ void vmemmap_free(unsigned long start, unsigned long end, } #endif /* CONFIG_MEMORY_HOTPLUG */ +void set_fixmap_io(enum fixed_addresses idx, phys_addr_t phys) +{ + pgprot_t prot = FIXMAP_PAGE_IO; + + /* + * The set_fixmap_io maps a single Page covering phys. + * To make better decision, we stick to the smallest page + * size supported (4K). + */ + if (!arm64_is_iomem_private(phys, SZ_4K)) + prot = pgprot_decrypted(prot); + else + prot = pgprot_encrypted(prot); + + __set_fixmap(idx, phys, prot); +} + int pud_set_huge(pud_t *pudp, phys_addr_t phys, pgprot_t prot) { pud_t new_pud = pfn_pud(__phys_to_pfn(phys), mk_pud_sect_prot(prot));