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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5DD3C43334 for ; Wed, 6 Jul 2022 19:17:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 161D84BEB5; Wed, 6 Jul 2022 15:17:40 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id z70qvfHttTDV; Wed, 6 Jul 2022 15:17:38 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B67544BE60; Wed, 6 Jul 2022 15:17:38 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CA6AC4BE4A for ; Wed, 6 Jul 2022 15:17:36 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zhnTwIMYxVMy for ; Wed, 6 Jul 2022 15:17:35 -0400 (EDT) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 56E9B4BE3B for ; Wed, 6 Jul 2022 15:17:35 -0400 (EDT) Received: by mail-pl1-f172.google.com with SMTP id 5so8548068plk.9 for ; Wed, 06 Jul 2022 12:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=JBmKOjwv6JurVrCp1jbxVixSqXLF0Sb1dFg8JNOdJ+fwNcPBzQlQn3tn4npjxXVIAV SMXfrIYC1s7mVn2dvjhB0eIRyJFsLPDfTeECp8Xoz9OOif2Tbx6LEY3/uV80I/w2EUfp 2PymuDBaHeeyOy65/N0JZu+CiLRMYUtd4Sv9WWbw3CeYIDJwm2kJS68xyNtkvt0wBEJV vbNNi60hCxI9Sc5sH3Wo2sGB4T2Rdw9dv/k+tl95h8UctppFSCBE4DP1IFA/qJ7WWw8W ASrzo6LZ49VRz1A3Vlp+dUXvviM466LA8jFo5XqC13HA8mIP7rD0HR1kq5kwUmKgaAaT AwaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=xMyaBA1O7xfySZmIRGBlH3uMbfrZErXDfOwWXWa6Z2ZoKvQ0Zw/aLK236KWDvd2i67 6p7jKo5TgMdljajOclzwCWOoxNjPJ8tgSiRpYME5kZs0CX+Kkyr/MBNqqmuhTZt5LxvR sdDPW185WtWMfWQBn9jzTplnLjI/XG3GLJ9ShQRyKfmQh+A3+57sVOEdxo9i37BfLvbb 6Q6WzSbBh8w9KJUgoWDiOMz/4SsfuXXtFBzXYFZKgohSLcin3vkoAxWZAa2ykKgRjLTK VPgCxpVQJJHSqXxhFfeC5+E8hEEp24Jiy3R1lUK9ZsKKL3Dx5OfpIqJLm0ffJ+qre1nO 2B3w== X-Gm-Message-State: AJIora/6cvpWNq+VA7ecNQaws24FVncpeN002QRksJT1GziVuApe0s+q SjBsHrNKuGU3SA2hYSUCOFKMPg== X-Google-Smtp-Source: AGRyM1vOOz2sO95rdkMXCWcipyRGk4AXIxqT4D+nvbdPOQ8Tgsc6ZH6eLd494oQu0sAcs8gpAmxTDg== X-Received: by 2002:a17:902:d292:b0:16b:e6a4:5768 with SMTP id t18-20020a170902d29200b0016be6a45768mr16270752plc.128.1657135054004; Wed, 06 Jul 2022 12:17:34 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id mz5-20020a17090b378500b001ef88c30fbbsm7163752pjb.49.2022.07.06.12.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 12:17:33 -0700 (PDT) Date: Wed, 6 Jul 2022 19:17:29 +0000 From: Sean Christopherson To: Will Deacon Subject: Re: [PATCH v2 00/24] KVM: arm64: Introduce pKVM shadow state at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220630135747.26983-1-will@kernel.org> Cc: Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, Catalin Marinas , Oliver Upton , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Michael Roth , Chao Peng , kvmarm@lists.cs.columbia.edu X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, Jun 30, 2022, Will Deacon wrote: > Hi everyone, > > This series has been extracted from the pKVM base support series (aka > "pKVM mega-patch") previously posted here: > > https://lore.kernel.org/kvmarm/20220519134204.5379-1-will@kernel.org/ > > Unlike that more comprehensive series, this one is fairly fundamental > and does not introduce any new ABI commitments, leaving questions > involving the management of guest private memory and the creation of > protected VMs for future work. Instead, this series extends the pKVM EL2 > code so that it can dynamically instantiate and manage VM shadow > structures without the host being able to access them directly. These > shadow structures consist of a shadow VM, a set of shadow vCPUs and the > stage-2 page-table and the pages used to hold them are returned to the > host when the VM is destroyed. > > The last patch is marked as RFC because, although it plumbs in the > shadow state, it is woefully inefficient and copies to/from the host > state on every vCPU run. Without the last patch, the new structures are > unused but we move considerably closer to isolating guests from the > host. ... > arch/arm64/include/asm/kvm_asm.h | 6 +- > arch/arm64/include/asm/kvm_host.h | 65 +++ > arch/arm64/include/asm/kvm_hyp.h | 3 + > arch/arm64/include/asm/kvm_pgtable.h | 8 + > arch/arm64/include/asm/kvm_pkvm.h | 38 ++ > arch/arm64/kernel/image-vars.h | 15 - > arch/arm64/kvm/arm.c | 40 +- > arch/arm64/kvm/hyp/hyp-constants.c | 3 + > arch/arm64/kvm/hyp/include/nvhe/gfp.h | 6 +- > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 19 +- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 26 +- > arch/arm64/kvm/hyp/include/nvhe/mm.h | 18 +- > arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 70 +++ > arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 10 +- > arch/arm64/kvm/hyp/nvhe/cache.S | 11 + > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 105 +++- > arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 2 + > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 456 +++++++++++++++++- > arch/arm64/kvm/hyp/nvhe/mm.c | 136 +++++- > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 42 +- > arch/arm64/kvm/hyp/nvhe/pkvm.c | 438 +++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/setup.c | 96 ++-- > arch/arm64/kvm/hyp/pgtable.c | 9 + > arch/arm64/kvm/mmu.c | 26 + > arch/arm64/kvm/pkvm.c | 121 ++++- > 25 files changed, 1625 insertions(+), 144 deletions(-) > create mode 100644 arch/arm64/kvm/hyp/include/nvhe/pkvm.h The lack of documentation and the rather terse changelogs make this really hard to review for folks that aren't intimately familiar with pKVM. I have a decent idea of the end goal of "shadowing", but that's mostly because of my involvement in similar x86 projects. Nothing in the changelogs ever explains _why_ pKVM uses shadows. I put "shadowing" in quotes because if the unstrusted host is aware that the VM and vCPU it is manipulating aren't the "real" VMs/vCPUs, and there is an explicit API between the untrusted host and pKVM for creating/destroying VMs/vCPUs, then I would argue that it's not truly shadowing, especially if pKVM uses data/values verbatim and only verifies correctness/safety. It's definitely a nit, but for future readers I think overloading "shadowing" could be confusing. And beyond the basics, IMO pKVM needs a more formal definition of exactly what guest state is protected/hidden from the untrusted host. Peeking at the mega series, there are a huge pile of patches that result in "gradual reduction of EL2 trust in host data", but I couldn't any documentation that defines what that end result is. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 5FF16C433EF for ; Wed, 6 Jul 2022 19:18: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: 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=iXbuiszBT/lJ3ZoIGODWOwHkNLjN1BWDKUkrSB83+eU=; b=XgOXFE7ka93gDP Kn4pOtyBCA1w+iZBYQhdG+a9dsfBEYEotbfg8biC5GPBxDq2N2D2bhSXCipd9MVc3Vi/+ErNYyYGh jwKWKdtlOWukarhR5gyDTXD7D5r0XIXphjsOD+xxVxu++M60aSDCy6SJH00Ou59LlPrlzYy0lURvI pmjf6HrwvbJdtqm5MtP9tVVeP45eQ1y7jS1pNbqo1E0E+jbUQyKL9E9FvjWfq2xIU3nN1Xo8bTpTx fjuREfzmXCMEYpkwsT4RB5v19dr2enTexSqRM8GKbmjdQQfM5x9yKfbSk8oZqMQkYSRk6KEbkZ8MO i1sZroYAqGYoYpWZYlXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9AWp-00CBSg-KJ; Wed, 06 Jul 2022 19:17:39 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9AWm-00CBRC-9j for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 19:17:37 +0000 Received: by mail-pl1-x62b.google.com with SMTP id z1so8633918plb.1 for ; Wed, 06 Jul 2022 12:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=JBmKOjwv6JurVrCp1jbxVixSqXLF0Sb1dFg8JNOdJ+fwNcPBzQlQn3tn4npjxXVIAV SMXfrIYC1s7mVn2dvjhB0eIRyJFsLPDfTeECp8Xoz9OOif2Tbx6LEY3/uV80I/w2EUfp 2PymuDBaHeeyOy65/N0JZu+CiLRMYUtd4Sv9WWbw3CeYIDJwm2kJS68xyNtkvt0wBEJV vbNNi60hCxI9Sc5sH3Wo2sGB4T2Rdw9dv/k+tl95h8UctppFSCBE4DP1IFA/qJ7WWw8W ASrzo6LZ49VRz1A3Vlp+dUXvviM466LA8jFo5XqC13HA8mIP7rD0HR1kq5kwUmKgaAaT AwaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=jkYE8F86sBNH6Q/rt/Xfs0pv+3q9JhAad2TRUKbcApKift9vtqDbfVNStysp/kyRj1 WYho2eSngGXIbF2JmTup4IWq1LjlE/H1P+OO7nCDyQAOuS50P0eeOtrkmBztdE/b2yER RXldK+w1h6yP3tOmtwrX57f4Z/XlNK5H7kqh2gQy0ks7AGw1VE/sbY45+xPuprdU66cb p9Ll26OgKoPgu0bYWapN2Rvr3vxFMkLfB6JaJLVvLvyjI9BaxJy67TB6Ro6x9S1AlFDN q5WQQzrv45KmNiid+3RFY40+T3LBj0kdr5DdvX0eU/0ql9L6UdbI59ABmt9ow9vZHonw jjQw== X-Gm-Message-State: AJIora+vH1Ew1Zbb80E2s1Uh5X+Wnnh0KE2ADjRUKilQHPyWKXoY9woX ARIQunoAcndE/FCo44a6a4wkLg== X-Google-Smtp-Source: AGRyM1vOOz2sO95rdkMXCWcipyRGk4AXIxqT4D+nvbdPOQ8Tgsc6ZH6eLd494oQu0sAcs8gpAmxTDg== X-Received: by 2002:a17:902:d292:b0:16b:e6a4:5768 with SMTP id t18-20020a170902d29200b0016be6a45768mr16270752plc.128.1657135054004; Wed, 06 Jul 2022 12:17:34 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id mz5-20020a17090b378500b001ef88c30fbbsm7163752pjb.49.2022.07.06.12.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 12:17:33 -0700 (PDT) Date: Wed, 6 Jul 2022 19:17:29 +0000 From: Sean Christopherson To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Oliver Upton , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 00/24] KVM: arm64: Introduce pKVM shadow state at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220630135747.26983-1-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_121736_362976_AD691F07 X-CRM114-Status: GOOD ( 25.18 ) 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 30, 2022, Will Deacon wrote: > Hi everyone, > > This series has been extracted from the pKVM base support series (aka > "pKVM mega-patch") previously posted here: > > https://lore.kernel.org/kvmarm/20220519134204.5379-1-will@kernel.org/ > > Unlike that more comprehensive series, this one is fairly fundamental > and does not introduce any new ABI commitments, leaving questions > involving the management of guest private memory and the creation of > protected VMs for future work. Instead, this series extends the pKVM EL2 > code so that it can dynamically instantiate and manage VM shadow > structures without the host being able to access them directly. These > shadow structures consist of a shadow VM, a set of shadow vCPUs and the > stage-2 page-table and the pages used to hold them are returned to the > host when the VM is destroyed. > > The last patch is marked as RFC because, although it plumbs in the > shadow state, it is woefully inefficient and copies to/from the host > state on every vCPU run. Without the last patch, the new structures are > unused but we move considerably closer to isolating guests from the > host. ... > arch/arm64/include/asm/kvm_asm.h | 6 +- > arch/arm64/include/asm/kvm_host.h | 65 +++ > arch/arm64/include/asm/kvm_hyp.h | 3 + > arch/arm64/include/asm/kvm_pgtable.h | 8 + > arch/arm64/include/asm/kvm_pkvm.h | 38 ++ > arch/arm64/kernel/image-vars.h | 15 - > arch/arm64/kvm/arm.c | 40 +- > arch/arm64/kvm/hyp/hyp-constants.c | 3 + > arch/arm64/kvm/hyp/include/nvhe/gfp.h | 6 +- > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 19 +- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 26 +- > arch/arm64/kvm/hyp/include/nvhe/mm.h | 18 +- > arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 70 +++ > arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 10 +- > arch/arm64/kvm/hyp/nvhe/cache.S | 11 + > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 105 +++- > arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 2 + > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 456 +++++++++++++++++- > arch/arm64/kvm/hyp/nvhe/mm.c | 136 +++++- > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 42 +- > arch/arm64/kvm/hyp/nvhe/pkvm.c | 438 +++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/setup.c | 96 ++-- > arch/arm64/kvm/hyp/pgtable.c | 9 + > arch/arm64/kvm/mmu.c | 26 + > arch/arm64/kvm/pkvm.c | 121 ++++- > 25 files changed, 1625 insertions(+), 144 deletions(-) > create mode 100644 arch/arm64/kvm/hyp/include/nvhe/pkvm.h The lack of documentation and the rather terse changelogs make this really hard to review for folks that aren't intimately familiar with pKVM. I have a decent idea of the end goal of "shadowing", but that's mostly because of my involvement in similar x86 projects. Nothing in the changelogs ever explains _why_ pKVM uses shadows. I put "shadowing" in quotes because if the unstrusted host is aware that the VM and vCPU it is manipulating aren't the "real" VMs/vCPUs, and there is an explicit API between the untrusted host and pKVM for creating/destroying VMs/vCPUs, then I would argue that it's not truly shadowing, especially if pKVM uses data/values verbatim and only verifies correctness/safety. It's definitely a nit, but for future readers I think overloading "shadowing" could be confusing. And beyond the basics, IMO pKVM needs a more formal definition of exactly what guest state is protected/hidden from the untrusted host. Peeking at the mega series, there are a huge pile of patches that result in "gradual reduction of EL2 trust in host data", but I couldn't any documentation that defines what that end result is. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D85DCC43334 for ; Wed, 6 Jul 2022 19:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234132AbiGFTRg (ORCPT ); Wed, 6 Jul 2022 15:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233534AbiGFTRf (ORCPT ); Wed, 6 Jul 2022 15:17:35 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8CFE248CD for ; Wed, 6 Jul 2022 12:17:34 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id p9so4282395plr.11 for ; Wed, 06 Jul 2022 12:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=JBmKOjwv6JurVrCp1jbxVixSqXLF0Sb1dFg8JNOdJ+fwNcPBzQlQn3tn4npjxXVIAV SMXfrIYC1s7mVn2dvjhB0eIRyJFsLPDfTeECp8Xoz9OOif2Tbx6LEY3/uV80I/w2EUfp 2PymuDBaHeeyOy65/N0JZu+CiLRMYUtd4Sv9WWbw3CeYIDJwm2kJS68xyNtkvt0wBEJV vbNNi60hCxI9Sc5sH3Wo2sGB4T2Rdw9dv/k+tl95h8UctppFSCBE4DP1IFA/qJ7WWw8W ASrzo6LZ49VRz1A3Vlp+dUXvviM466LA8jFo5XqC13HA8mIP7rD0HR1kq5kwUmKgaAaT AwaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZjEGOm6kee36npEJu+b6kQDUwPzHaM9d3/gdsO10A3o=; b=sL8E/TJwmQ+6ei5AE2q61ATLC4w0rmwGIdDBRM7Gk4SMUAAqSKrcNYi1myVMWp0jg4 LxTWbSvwfOcrxHQWhlceoXI9EjjRul6uc5DX/a74t05GZ2pC0YmdMapf8+QrrY1c1rE1 TmEgyojXRqUwCMNKlFdBwpblFr1P0KfLCn9HUA/AjHf96Qy2LkKpJFnV9r+YRLR0kBuO xMZWYKZUv01vcxeGtyVVzMtiXfTIndjmh0GnK3ok4SXpNrCcyZOpmLUd0LsqPW+FJLY9 ioIAZotBR4Wd43akb0bx7PtuuGgrsbStp3vS1TPBYoWEp5Mvp/U6FraeHNQEKWjX9s3/ DWMg== X-Gm-Message-State: AJIora/VwpeXmDx5BlS1yzwnqHoXKyGtvhzx2IMawFRUAqB/bmqei82o 2Q7pHsxfahjtxdVm4B+f2ED26Q== X-Google-Smtp-Source: AGRyM1vOOz2sO95rdkMXCWcipyRGk4AXIxqT4D+nvbdPOQ8Tgsc6ZH6eLd494oQu0sAcs8gpAmxTDg== X-Received: by 2002:a17:902:d292:b0:16b:e6a4:5768 with SMTP id t18-20020a170902d29200b0016be6a45768mr16270752plc.128.1657135054004; Wed, 06 Jul 2022 12:17:34 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id mz5-20020a17090b378500b001ef88c30fbbsm7163752pjb.49.2022.07.06.12.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jul 2022 12:17:33 -0700 (PDT) Date: Wed, 6 Jul 2022 19:17:29 +0000 From: Sean Christopherson To: Will Deacon Cc: kvmarm@lists.cs.columbia.edu, Ard Biesheuvel , Alexandru Elisei , Andy Lutomirski , Catalin Marinas , James Morse , Chao Peng , Quentin Perret , Suzuki K Poulose , Michael Roth , Mark Rutland , Fuad Tabba , Oliver Upton , Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 00/24] KVM: arm64: Introduce pKVM shadow state at EL2 Message-ID: References: <20220630135747.26983-1-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220630135747.26983-1-will@kernel.org> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jun 30, 2022, Will Deacon wrote: > Hi everyone, > > This series has been extracted from the pKVM base support series (aka > "pKVM mega-patch") previously posted here: > > https://lore.kernel.org/kvmarm/20220519134204.5379-1-will@kernel.org/ > > Unlike that more comprehensive series, this one is fairly fundamental > and does not introduce any new ABI commitments, leaving questions > involving the management of guest private memory and the creation of > protected VMs for future work. Instead, this series extends the pKVM EL2 > code so that it can dynamically instantiate and manage VM shadow > structures without the host being able to access them directly. These > shadow structures consist of a shadow VM, a set of shadow vCPUs and the > stage-2 page-table and the pages used to hold them are returned to the > host when the VM is destroyed. > > The last patch is marked as RFC because, although it plumbs in the > shadow state, it is woefully inefficient and copies to/from the host > state on every vCPU run. Without the last patch, the new structures are > unused but we move considerably closer to isolating guests from the > host. ... > arch/arm64/include/asm/kvm_asm.h | 6 +- > arch/arm64/include/asm/kvm_host.h | 65 +++ > arch/arm64/include/asm/kvm_hyp.h | 3 + > arch/arm64/include/asm/kvm_pgtable.h | 8 + > arch/arm64/include/asm/kvm_pkvm.h | 38 ++ > arch/arm64/kernel/image-vars.h | 15 - > arch/arm64/kvm/arm.c | 40 +- > arch/arm64/kvm/hyp/hyp-constants.c | 3 + > arch/arm64/kvm/hyp/include/nvhe/gfp.h | 6 +- > arch/arm64/kvm/hyp/include/nvhe/mem_protect.h | 19 +- > arch/arm64/kvm/hyp/include/nvhe/memory.h | 26 +- > arch/arm64/kvm/hyp/include/nvhe/mm.h | 18 +- > arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 70 +++ > arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 10 +- > arch/arm64/kvm/hyp/nvhe/cache.S | 11 + > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 105 +++- > arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 2 + > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 456 +++++++++++++++++- > arch/arm64/kvm/hyp/nvhe/mm.c | 136 +++++- > arch/arm64/kvm/hyp/nvhe/page_alloc.c | 42 +- > arch/arm64/kvm/hyp/nvhe/pkvm.c | 438 +++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/setup.c | 96 ++-- > arch/arm64/kvm/hyp/pgtable.c | 9 + > arch/arm64/kvm/mmu.c | 26 + > arch/arm64/kvm/pkvm.c | 121 ++++- > 25 files changed, 1625 insertions(+), 144 deletions(-) > create mode 100644 arch/arm64/kvm/hyp/include/nvhe/pkvm.h The lack of documentation and the rather terse changelogs make this really hard to review for folks that aren't intimately familiar with pKVM. I have a decent idea of the end goal of "shadowing", but that's mostly because of my involvement in similar x86 projects. Nothing in the changelogs ever explains _why_ pKVM uses shadows. I put "shadowing" in quotes because if the unstrusted host is aware that the VM and vCPU it is manipulating aren't the "real" VMs/vCPUs, and there is an explicit API between the untrusted host and pKVM for creating/destroying VMs/vCPUs, then I would argue that it's not truly shadowing, especially if pKVM uses data/values verbatim and only verifies correctness/safety. It's definitely a nit, but for future readers I think overloading "shadowing" could be confusing. And beyond the basics, IMO pKVM needs a more formal definition of exactly what guest state is protected/hidden from the untrusted host. Peeking at the mega series, there are a huge pile of patches that result in "gradual reduction of EL2 trust in host data", but I couldn't any documentation that defines what that end result is.