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 37F03C4332F for ; Thu, 19 May 2022 13:46:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E81024B473; Thu, 19 May 2022 09:46:50 -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=@kernel.org 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 KnC2vOmVJ5vF; Thu, 19 May 2022 09:46:49 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id CB6064B46E; Thu, 19 May 2022 09:46:49 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 9986B4B413 for ; Thu, 19 May 2022 09:46:48 -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 PogaxUzVfv70 for ; Thu, 19 May 2022 09:46:47 -0400 (EDT) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id A12694B3B3 for ; Thu, 19 May 2022 09:46:47 -0400 (EDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3945E617D1; Thu, 19 May 2022 13:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FF2AC385B8; Thu, 19 May 2022 13:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652968007; bh=E1015Uo5m9qQ+l/7YYTJwJcecYTkXjzWrhDPUZbkvqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sa8MhUqPbbEtNQoduO6nqD4n1geAIXj03Okw2MLZAGzVD/WXwb6+clOJIYjK7za3A ruFghhtE3LF4KCXFu2TGRDLKMaro1wB6ba+np+GNntmB80SCIhCXvfvP7PAANFTE7m hM0remAoSSBf/B3FkCUzY9cmJpCaDqGRhGoQss7jBh7Z0/D/zEs37i8+htwQWZK8I3 1lXl53f3OFKaX7MutdoTvi2ugXs60KRKdsXOvCl74EIw6yNdVFbMgn2GgX/tZUiv1l dYkuVqY5DAui1d5BcNgkQE7kNmD5z7903UeQvOq332FxoM2WfIu3qHupCv5spkBdS4 cxWvD4Kdli7Aw== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Subject: [PATCH 66/89] KVM: arm64: Donate memory to protected guests Date: Thu, 19 May 2022 14:41:41 +0100 Message-Id: <20220519134204.5379-67-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220519134204.5379-1-will@kernel.org> References: <20220519134204.5379-1-will@kernel.org> MIME-Version: 1.0 Cc: Marc Zyngier , kernel-team@android.com, kvm@vger.kernel.org, Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Michael Roth , Catalin Marinas , Chao Peng , Will Deacon 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 From: Marc Zyngier Instead of sharing memory with protected guests, which still leaves the host with r/w access, donate the underlying pages so that they are unmapped from the host stage-2. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index c1939dd2294f..e987f34641dd 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -465,7 +465,10 @@ static void handle___pkvm_host_map_guest(struct kvm_cpu_context *host_ctxt) if (ret) goto out; - ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); + if (shadow_state_is_protected(shadow_state)) + ret = __pkvm_host_donate_guest(pfn, gfn, shadow_vcpu); + else + ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); out: cpu_reg(host_ctxt, 1) = ret; } -- 2.36.1.124.g0e6072fb45-goog _______________________________________________ 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 014B0C433F5 for ; Thu, 19 May 2022 13:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239122AbiESNrw (ORCPT ); Thu, 19 May 2022 09:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238946AbiESNrF (ORCPT ); Thu, 19 May 2022 09:47:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8357820BCA for ; Thu, 19 May 2022 06:46:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9A8F9617D4 for ; Thu, 19 May 2022 13:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FF2AC385B8; Thu, 19 May 2022 13:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652968007; bh=E1015Uo5m9qQ+l/7YYTJwJcecYTkXjzWrhDPUZbkvqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sa8MhUqPbbEtNQoduO6nqD4n1geAIXj03Okw2MLZAGzVD/WXwb6+clOJIYjK7za3A ruFghhtE3LF4KCXFu2TGRDLKMaro1wB6ba+np+GNntmB80SCIhCXvfvP7PAANFTE7m hM0remAoSSBf/B3FkCUzY9cmJpCaDqGRhGoQss7jBh7Z0/D/zEs37i8+htwQWZK8I3 1lXl53f3OFKaX7MutdoTvi2ugXs60KRKdsXOvCl74EIw6yNdVFbMgn2GgX/tZUiv1l dYkuVqY5DAui1d5BcNgkQE7kNmD5z7903UeQvOq332FxoM2WfIu3qHupCv5spkBdS4 cxWvD4Kdli7Aw== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: Will Deacon , Ard Biesheuvel , Sean Christopherson , 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: [PATCH 66/89] KVM: arm64: Donate memory to protected guests Date: Thu, 19 May 2022 14:41:41 +0100 Message-Id: <20220519134204.5379-67-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220519134204.5379-1-will@kernel.org> References: <20220519134204.5379-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Marc Zyngier Instead of sharing memory with protected guests, which still leaves the host with r/w access, donate the underlying pages so that they are unmapped from the host stage-2. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index c1939dd2294f..e987f34641dd 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -465,7 +465,10 @@ static void handle___pkvm_host_map_guest(struct kvm_cpu_context *host_ctxt) if (ret) goto out; - ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); + if (shadow_state_is_protected(shadow_state)) + ret = __pkvm_host_donate_guest(pfn, gfn, shadow_vcpu); + else + ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); out: cpu_reg(host_ctxt, 1) = ret; } -- 2.36.1.124.g0e6072fb45-goog 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 182CDC433F5 for ; Thu, 19 May 2022 14:34:08 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UFUB+WfKdEhtl+6BBS8oOENdNTEWzlXFVq4KpHBFcR0=; b=gNVCmqqYbm0J70 e7GCxZDJckkkQHxNerLL8Ci2EalSnalo6fI6UvvGBFna2jvW9JB3Lq1Tx7+rfX6ClCMHh797WlBap r8jVBUUt72QQWxZJ8iSjNI8PG2I0qdDI3YjoUBEfc8+akc5PDolBfSIzTJrZUmkz9X5EUTpfJU7D+ 4U2LsDMbnppbZC8RdlczzFKSPzqtErdjRfwsMtGuuFF86MbwYXJwAAnGnZ+nju8buP3+mbatiSEUG qDtEO2GcwJWBKnrrlldScmk/Us5o0DyoHZmxIlsJUwzMGE2xz+w9l1vdGozVDiXvxtwh29yQmsXcn G766kB8lUuH6Otabm2Ww==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrhCp-007SU4-18; Thu, 19 May 2022 14:32:48 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nrgUJ-0076zX-NT for linux-arm-kernel@lists.infradead.org; Thu, 19 May 2022 13:46:49 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3945E617D1; Thu, 19 May 2022 13:46:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FF2AC385B8; Thu, 19 May 2022 13:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1652968007; bh=E1015Uo5m9qQ+l/7YYTJwJcecYTkXjzWrhDPUZbkvqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sa8MhUqPbbEtNQoduO6nqD4n1geAIXj03Okw2MLZAGzVD/WXwb6+clOJIYjK7za3A ruFghhtE3LF4KCXFu2TGRDLKMaro1wB6ba+np+GNntmB80SCIhCXvfvP7PAANFTE7m hM0remAoSSBf/B3FkCUzY9cmJpCaDqGRhGoQss7jBh7Z0/D/zEs37i8+htwQWZK8I3 1lXl53f3OFKaX7MutdoTvi2ugXs60KRKdsXOvCl74EIw6yNdVFbMgn2GgX/tZUiv1l dYkuVqY5DAui1d5BcNgkQE7kNmD5z7903UeQvOq332FxoM2WfIu3qHupCv5spkBdS4 cxWvD4Kdli7Aw== From: Will Deacon To: kvmarm@lists.cs.columbia.edu Cc: Will Deacon , Ard Biesheuvel , Sean Christopherson , 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: [PATCH 66/89] KVM: arm64: Donate memory to protected guests Date: Thu, 19 May 2022 14:41:41 +0100 Message-Id: <20220519134204.5379-67-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220519134204.5379-1-will@kernel.org> References: <20220519134204.5379-1-will@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220519_064647_922186_FCAD65A1 X-CRM114-Status: GOOD ( 14.25 ) 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 From: Marc Zyngier Instead of sharing memory with protected guests, which still leaves the host with r/w access, donate the underlying pages so that they are unmapped from the host stage-2. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index c1939dd2294f..e987f34641dd 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -465,7 +465,10 @@ static void handle___pkvm_host_map_guest(struct kvm_cpu_context *host_ctxt) if (ret) goto out; - ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); + if (shadow_state_is_protected(shadow_state)) + ret = __pkvm_host_donate_guest(pfn, gfn, shadow_vcpu); + else + ret = __pkvm_host_share_guest(pfn, gfn, shadow_vcpu); out: cpu_reg(host_ctxt, 1) = ret; } -- 2.36.1.124.g0e6072fb45-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel