From mboxrd@z Thu Jan 1 00:00:00 1970 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 A797CCA1007 for ; Fri, 30 Aug 2024 15:57:26 +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: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wa4ZaOnMERlB71vefomTE17oBsg8VNg+VtUNrNAdX8c=; b=XDHnXm5xxh8XXgncZx6IYO6ygB NjHSYrNIBxgyl2vTijJK33ehv8nLjCneulwWp3/tTxzEgk7CMwHZiGwTL1rhspA0x9wQY7SD20vc7 XT5HK8dysRkvqQ230sfynNTQARhsVA473GzbPUllOu0zVH4vSPDS4zDhwSh8jbmNTdu0dm01pxCEf 1SNXGovp/Sj/Ea69TlxSq5nKN0eov/bNMch37H1qmESwjQKinEYXsbm5mt3b4aN7C2+gvPYTv+e8d G+rwajJh9pGqWxXtDnc+UHR6HhIT6zMWjWc6KCofcw+N8HGjpV4/hmHPrBIjNvVnuJhNgQ3gTSQ6A DkIb5yKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3zx-00000006uau-2U5A; Fri, 30 Aug 2024 15:57:17 +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 1sk3xe-00000006tpE-0XtZ for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 15:54:55 +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 18A4D1477; Fri, 30 Aug 2024 08:55:19 -0700 (PDT) Received: from [10.1.30.22] (e122027.cambridge.arm.com [10.1.30.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB3A13F762; Fri, 30 Aug 2024 08:54:48 -0700 (PDT) Message-ID: Date: Fri, 30 Aug 2024 16:54:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 10/19] arm64: Override set_fixmap_io To: Suzuki K Poulose , kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: 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 References: <20240819131924.372366-1-steven.price@arm.com> <20240819131924.372366-11-steven.price@arm.com> <13bc77b7-5f68-44ca-93ce-578ffe029437@arm.com> From: Steven Price Content-Language: en-GB In-Reply-To: <13bc77b7-5f68-44ca-93ce-578ffe029437@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_085454_281420_E1E7D7C5 X-CRM114-Status: GOOD ( 18.69 ) 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 On 19/08/2024 15:13, Suzuki K Poulose wrote: > On 19/08/2024 14:19, Steven Price wrote: >> 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); > > With the ioremap_prot_hook introduction, this one looks like should use > that, instead of open coding the same thing. Thoughts ? I can see the logic, but it's not quite that simple to implement. Either the ioremap_prot_hook needs moving out (and presumably) renaming to be a more generic "override device pgprot" mechanism, we it would be a horrid hack to put ioremap code in arch/arm64/mm/ioremap.c to handle this. Given that we're not even sure that the set_fixmap hack is a good idea, I'll leave this alone for now - the open coding is clear even if it's a duplicate. Thanks, Steve