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 X-Spam-Level: X-Spam-Status: No, score=-14.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 240FFC07E94 for ; Fri, 4 Jun 2021 14:23:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DA79461406 for ; Fri, 4 Jun 2021 14:23:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA79461406 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EEmhtNc6KW/jqEMcaj8rBKZGuRdJYGcVhP6NP74LffY=; b=O7Oz7usDM7/9L0 0BIqxCZUGvqp6MtRpwRyHhDOsLDr7CCMqQ87R8sRiP+Y+a/nwbKxkMe6FcJL17HSNY8CxlPEtwwYc lUmVQ2mijlnGArg8YSB75KPb3JDKLHGXHrnTlVou8koEbL45S0VlqVsrPcYJYgG9/XcxhumA7vpq6 HhTV215h4kXWphAU3QUfg6UwUvJ8a0dhbryx+8vHVoBEAao2WHvrJiIw9rzXEV35fmzLgTZN/HS2x bJ13fU0Ibux872hC9mcdmgAhEEElZQwi/FjFjgRd4lsfqkWLUDYeD8Vtydi3s5QHuwVlkz+mlJOZW HFXDeMoN7GtoEN7Kg49Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpAht-00Dw7Q-PT; Fri, 04 Jun 2021 14:21:53 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lpAhp-00Dw6Y-8F for linux-arm-kernel@lists.infradead.org; Fri, 04 Jun 2021 14:21:51 +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 A0BB72B; Fri, 4 Jun 2021 07:21:47 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.6.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6F4AF3F774; Fri, 4 Jun 2021 07:21:44 -0700 (PDT) Date: Fri, 4 Jun 2021 15:21:41 +0100 From: Mark Rutland To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Christoffer Dall , Paolo Bonzini , Fuad Tabba , Quentin Perret , Sean Christopherson , David Brazdil , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 3/4] KVM: arm64: Parse reserved-memory node for pkvm guest firmware region Message-ID: <20210604142141.GC69333@C02TD0UTHF1T.local> References: <20210603183347.1695-1-will@kernel.org> <20210603183347.1695-4-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210603183347.1695-4-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210604_072149_422616_3BD597AA X-CRM114-Status: GOOD ( 23.06 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 03, 2021 at 07:33:46PM +0100, Will Deacon wrote: > Add support for a "linux,pkvm-guest-firmware-memory" reserved memory > region, which can be used to identify a firmware image for protected > VMs. The idea that the guest's FW comes from the host's FW strikes me as unusual; what's the rationale for this coming from the host FW? IIUC other confidential compute VM environments allow you to load up whatever virtual FW you want, but this is measured such that the virtual FW used can be attested. Thanks, Mark. > > Signed-off-by: Will Deacon > --- > arch/arm64/kvm/Makefile | 2 +- > arch/arm64/kvm/pkvm.c | 52 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 53 insertions(+), 1 deletion(-) > create mode 100644 arch/arm64/kvm/pkvm.c > > diff --git a/arch/arm64/kvm/Makefile b/arch/arm64/kvm/Makefile > index 589921392cb1..61e054411831 100644 > --- a/arch/arm64/kvm/Makefile > +++ b/arch/arm64/kvm/Makefile > @@ -14,7 +14,7 @@ kvm-y := $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o \ > $(KVM)/vfio.o $(KVM)/irqchip.o \ > arm.o mmu.o mmio.o psci.o perf.o hypercalls.o pvtime.o \ > inject_fault.o va_layout.o handle_exit.o \ > - guest.o debug.o reset.o sys_regs.o \ > + guest.o debug.o pkvm.o reset.o sys_regs.o \ > vgic-sys-reg-v3.o fpsimd.o pmu.o \ > arch_timer.o trng.o\ > vgic/vgic.o vgic/vgic-init.o \ > diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c > new file mode 100644 > index 000000000000..7af5d03a3941 > --- /dev/null > +++ b/arch/arm64/kvm/pkvm.c > @@ -0,0 +1,52 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * KVM host (EL1) interface to Protected KVM (pkvm) code at EL2. > + * > + * Copyright (C) 2021 Google LLC > + * Author: Will Deacon > + */ > + > +#include > +#include > +#include > +#include > + > +static struct reserved_mem *pkvm_firmware_mem; > + > +static int __init pkvm_firmware_rmem_err(struct reserved_mem *rmem, > + const char *reason) > +{ > + phys_addr_t end = rmem->base + rmem->size; > + > + kvm_err("Ignoring pkvm guest firmware memory reservation [%pa - %pa]: %s\n", > + &rmem->base, &end, reason); > + return -EINVAL; > +} > + > +static int __init pkvm_firmware_rmem_init(struct reserved_mem *rmem) > +{ > + unsigned long node = rmem->fdt_node; > + > + if (kvm_get_mode() != KVM_MODE_PROTECTED) > + return pkvm_firmware_rmem_err(rmem, "protected mode not enabled"); > + > + if (pkvm_firmware_mem) > + return pkvm_firmware_rmem_err(rmem, "duplicate reservation"); > + > + if (!of_get_flat_dt_prop(node, "no-map", NULL)) > + return pkvm_firmware_rmem_err(rmem, "missing \"no-map\" property"); > + > + if (of_get_flat_dt_prop(node, "reusable", NULL)) > + return pkvm_firmware_rmem_err(rmem, "\"reusable\" property unsupported"); > + > + if (!PAGE_ALIGNED(rmem->base)) > + return pkvm_firmware_rmem_err(rmem, "base is not page-aligned"); > + > + if (!PAGE_ALIGNED(rmem->size)) > + return pkvm_firmware_rmem_err(rmem, "size is not page-aligned"); > + > + pkvm_firmware_mem = rmem; > + return 0; > +} > +RESERVEDMEM_OF_DECLARE(pkvm_firmware, "linux,pkvm-guest-firmware-memory", > + pkvm_firmware_rmem_init); > -- > 2.32.0.rc0.204.g9fa02ecfa5-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel