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 E80E9C3DA7F for ; Wed, 31 Jul 2024 15:53:57 +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-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lW4AkSunhYri0RFvu4iY6ycM/XhRonbHDjFId8N/Stg=; b=bnbod40gABwg2O99Q0HPKNa/bZ b3YUxi5lIqAj545+3FkPXTUuRcXC7WoDo9OPMGChAf+toYdYo7+jRIK2h1XVUhpW3qv2ooy1XznLO rawvdH6OHZJf3qHV1k9QsmHOHKOJwquc72uBYcbwx0TspajyYROk7SiD/ZP+h71/I3YBCc2GNQsX2 CEYV8bVhZm6MSuHIyK9WCjskHMtbi+MsN2cdH0+ybu6a0fF7OO8SXRayVvcxFIt7d6ZDuh691eXbg fovJ017swdmBBJZPNJWQ1Tp06TczPTwjRlF/w6udMoxjakh7kq1WUT8iZtqmHZ2umuAs2H+WMv6FE oB/ZYwnA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZBe8-00000001mwu-0KBv; Wed, 31 Jul 2024 15:53:48 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZBdd-00000001mop-3Npk for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2024 15:53:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 4C6A2CE1759; Wed, 31 Jul 2024 15:53:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83A6FC4AF09; Wed, 31 Jul 2024 15:53:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722441194; bh=GiWuXJHUEoAKmVL2TSM7QKFuD/UvLsAiKfix5ofjpGo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=NDEL5s+HOh5f2IKq6KZPwRDZImjyHYYttwer3GYbirMSM8UyZYUbCaOjK8KyoX3Ob ALn83luZ+VtzoQRR0JxZW0gAH6WcSzKNDvW+0wbJSP5iugX6z+w9HreE9xAiogFCEU raoF8d376fVD/pN3/QIvo5FCS0obgTk4aNSI1RFw7CUgFZqrWH0TM8DwkQ6LTfJmaU lsXvf073Z/miZ9s0Z2jw5WOQKqHa/sGPjDu3oC3MRdet0LYNqsADAjpPlYCvCzraWx sjiBK0wUerhD9/6rql80N6W/iaDWYtfRkgzb+vrWkIWhqQrEFhTENkmIe+8Lu3zVTm oNk8fjr3ncGQA== X-Mailer: emacs 31.0.50 (via feedmail 11-beta-1 I) From: Aneesh Kumar K.V To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Sudeep Holla , Catalin Marinas , Lorenzo Pieralisi , Suzuki Poulose , Steven Price , Oliver Upton , Marc Zyngier , linux-coco@lists.linux.dev Subject: Re: [PATCH 1/6] firmware/smccc: Call arch-specific hook on discovering KVM services In-Reply-To: <20240731155045.GA3296@willie-the-truck> References: <20240730151113.1497-1-will@kernel.org> <20240730151113.1497-2-will@kernel.org> <20240731155045.GA3296@willie-the-truck> Date: Wed, 31 Jul 2024 21:23:04 +0530 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240731_085318_310789_4BBE477A X-CRM114-Status: GOOD ( 21.10 ) 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 Will Deacon writes: > On Wed, Jul 31, 2024 at 08:11:16PM +0530, Aneesh Kumar K.V wrote: >> Will Deacon writes: >> >> > From: Marc Zyngier >> > >> > arm64 will soon require its own callback to initialise services >> > that are only available on this architecture. Introduce a hook >> > that can be overloaded by the architecture. >> > >> > Signed-off-by: Marc Zyngier >> > Signed-off-by: Will Deacon >> > --- >> > arch/arm/include/asm/hypervisor.h | 2 ++ >> > arch/arm64/include/asm/hypervisor.h | 4 ++++ >> > drivers/firmware/smccc/kvm_guest.c | 2 ++ >> > 3 files changed, 8 insertions(+) >> > >> > diff --git a/arch/arm/include/asm/hypervisor.h b/arch/arm/include/asm/hypervisor.h >> > index bd61502b9715..8a648e506540 100644 >> > --- a/arch/arm/include/asm/hypervisor.h >> > +++ b/arch/arm/include/asm/hypervisor.h >> > @@ -7,4 +7,6 @@ >> > void kvm_init_hyp_services(void); >> > bool kvm_arm_hyp_service_available(u32 func_id); >> > >> > +static inline void kvm_arch_init_hyp_services(void) { }; >> > + >> > #endif >> > diff --git a/arch/arm64/include/asm/hypervisor.h b/arch/arm64/include/asm/hypervisor.h >> > index 0ae427f352c8..8cab2ab535b7 100644 >> > --- a/arch/arm64/include/asm/hypervisor.h >> > +++ b/arch/arm64/include/asm/hypervisor.h >> > @@ -7,4 +7,8 @@ >> > void kvm_init_hyp_services(void); >> > bool kvm_arm_hyp_service_available(u32 func_id); >> > >> > +static inline void kvm_arch_init_hyp_services(void) >> > +{ >> > +}; >> > + >> > #endif >> > diff --git a/drivers/firmware/smccc/kvm_guest.c b/drivers/firmware/smccc/kvm_guest.c >> > index 89a68e7eeaa6..f3319be20b36 100644 >> > --- a/drivers/firmware/smccc/kvm_guest.c >> > +++ b/drivers/firmware/smccc/kvm_guest.c >> > @@ -39,6 +39,8 @@ void __init kvm_init_hyp_services(void) >> > >> > pr_info("hypervisor services detected (0x%08lx 0x%08lx 0x%08lx 0x%08lx)\n", >> > res.a3, res.a2, res.a1, res.a0); >> > + >> > + kvm_arch_init_hyp_services(); >> > } >> > >> >> That is a bit late to detect RMM? One of the requirements is to >> figure out the pgprot_t flags for early_ioremap so that "earlycon" will >> work (by mapping the address as shared alias). To do that we need to >> make an RSI call to detect PROT_NS_SHARED mask as below. >> >> if (rsi_get_realm_config(&config)) >> return; >> prot_ns_shared = BIT(config.ipa_bits - 1); > > Why can't the earlycon MMIO address just have that high bit set? > > I think it's horribly fragile to try detecting all of this stuff before > we're allowed to touch the console. We don't even bother with pKVM -- > it's the guest firmware's responsibility to MMIO_GUARD the UART if it > detects a debuggable payload. > To mark something shared, we need to know the mask value which is returned via rsi_get_realm_config() call. -aneesh