From patchwork Mon Aug 19 13:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Price X-Patchwork-Id: 13768380 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DB8FC3DA4A for ; Mon, 19 Aug 2024 13:26:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=owHoA9FH7okNGmuU7HDDQV9rpxscb9yOaFlMMn2gjA4=; b=LqK4DbbkfZHK2XyTqCcfy1E9pq 4GPbHGMugx/4bpXzFnLc3SCoGsBF2BHJ4jBlWs7iEYjQle68VdMZqwtmfulK1vF6/wM+VuBiJET5s gQ6ZF79FsTSAA+v/XAH9iwHrYG1cQSc0kV6ZOv6tJBS2knPhKYa5Mbr6vLWGegz6IeVWX/fvU2UFZ s4E2Lf6gdOo1EQSIqgYbXsa8g1l4EDL248jCns5a0BFKpFieY+gWKW4sYw+4qImullNsWHLedKF0V 1pOV1u3WHwesHlYYlTAD8SRnI1w9m2t84PgKupGGXm9Yu2MEEnab8OG+h3kYc1bfyqePqbjWwDGwY qNYv+www==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg2P2-00000001anv-2Q8F; Mon, 19 Aug 2024 13:26:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sg2J2-00000001Ywk-1pSJ for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 13:20:22 +0000 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 14792113E; Mon, 19 Aug 2024 06:20:46 -0700 (PDT) Received: from e122027.arm.com (unknown [10.57.85.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 361163F73B; Mon, 19 Aug 2024 06:20:16 -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 09/19] fixmap: Pass down the full phys address for set_fixmap_io Date: Mon, 19 Aug 2024 14:19:14 +0100 Message-Id: <20240819131924.372366-10-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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_062020_580599_CF6C6161 X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Suzuki K Poulose For early I/O mapping using fixmap, we mask the address by PAGE_MASK base and then map it to the FIXMAP slot. However, with confidential computing, the granularity at which "protections" (encrypted vs decrypted) are applied may be finer than the PAGE_SIZE. e.g., for Arm CCA it is 4K while an arm64 kernel could be using 64K pagesize. However we need to know the exact address being mapped in. Thus in-order to calculate the accurate protection, pass down the exact phys address to the helpers. This would be later used by arm64 to detect if the MMIO address is shared vs protected. The users of such drivers already cope with running the same code with "4K" page size, thus mapping a PAGE_SIZE covering the address range is considered acceptable. Signed-off-by: Suzuki K Poulose Signed-off-by: Steven Price --- New patch for v5 --- drivers/tty/serial/earlycon.c | 2 +- include/asm-generic/fixmap.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index a5fbb6ed38ae..c8414b648d47 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -40,7 +40,7 @@ static void __iomem * __init earlycon_map(resource_size_t paddr, size_t size) { void __iomem *base; #ifdef CONFIG_FIX_EARLYCON_MEM - set_fixmap_io(FIX_EARLYCON_MEM_BASE, paddr & PAGE_MASK); + set_fixmap_io(FIX_EARLYCON_MEM_BASE, paddr); base = (void __iomem *)__fix_to_virt(FIX_EARLYCON_MEM_BASE); base += paddr & ~PAGE_MASK; #else diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h index 9b75fe2bd8fd..8d2222035ed2 100644 --- a/include/asm-generic/fixmap.h +++ b/include/asm-generic/fixmap.h @@ -96,7 +96,7 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr) */ #ifndef set_fixmap_io #define set_fixmap_io(idx, phys) \ - __set_fixmap(idx, phys, FIXMAP_PAGE_IO) + __set_fixmap(idx, phys & PAGE_MASK, FIXMAP_PAGE_IO) #endif #endif /* __ASSEMBLY__ */