Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp401643pxv; Thu, 22 Jul 2021 03:06:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCFZMK1z/u9mPOSceFS8ROXKI82IpFm4ZG41EW2DpH5aZY/h/IkspItFn+tnQNRZ4oMlj6 X-Received: by 2002:a02:c9c2:: with SMTP id c2mr34658984jap.98.1626948372137; Thu, 22 Jul 2021 03:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626948372; cv=none; d=google.com; s=arc-20160816; b=TgdEHr8OtqFthDE/ZzUduQzdXiIVpM4hJl/d7Hp/SvezZe7gBlGikT3MeCzBzYIyWD r30yHyxaWko9W/tWw6j04n/64Z2Xd+LGl9EPjj/yevKMZr7O7gk0lXzdVgFmJv6p0adf B3JGdoj8ucL7RGOlaXVnb92lyDYMKVLh48VSIwfxX0fkGMNTCyA/H+7bvFRaQ9LBumD/ eHTy18/C5VVycVbzJjP4KmR6CIuN8pHYwchWYnnmEAbgsBXYNtBLDcjRmCHvk1cK4GzI S+63D0q3VEvonn69ckxbYs6qMn4A6M0hh6LFO+lNbVEW19YImxGj0OfA/O8aNqLv0XL2 MVfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=AaYmqrJ3+FCG4kxPk6bFtBY926goVBPqF7MEHGozzCg=; b=jEp+etvkCCoybxTcT9HAieDY6t8RxxxPqinHpReHVAYzR4it1aH65n1Q8W1sKciPdA uNXf2yp3PDqLylsyxRNEBOIYi1IPxrw7wqqqLpa3vmBPdsoRzelfRfXLs9xxRJXAp+wZ tNNqSQGnVlyVT9i37B82QY6zjaTUwkrqhYk5OLlsa7rDQp+KIwd473SUYzEBdTI/YkqK Q7BanVZqVSKUvVHhTYpOsgziY/oR21ii4TemFc6H3Vm7hw0eUyWeTekRTdMdBeaPCM05 e0jp1jIW8kaO5X7NNDk8CoG86HcxFIDSPMMZrMp2P4JrGSg3BLh0TtwXkY5dPMcUoca9 GT7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si18529831jat.45.2021.07.22.03.06.00; Thu, 22 Jul 2021 03:06:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbhGVJYB (ORCPT + 99 others); Thu, 22 Jul 2021 05:24:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbhGVJTx (ORCPT ); Thu, 22 Jul 2021 05:19:53 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E1D2361241; Thu, 22 Jul 2021 10:00:28 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1m6VVC-000F18-PY; Thu, 22 Jul 2021 11:00:26 +0100 Date: Thu, 22 Jul 2021 11:00:26 +0100 Message-ID: <874kcm3byd.wl-maz@kernel.org> From: Marc Zyngier To: Andrew Jones Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, Srivatsa Vaddagiri , Shanker R Donthineni , will@kernel.org Subject: Re: [PATCH 00/16] KVM: arm64: MMIO guard PV services In-Reply-To: <20210721214243.dy6d644yznuopuqx@gator> References: <20210715163159.1480168-1-maz@kernel.org> <20210721214243.dy6d644yznuopuqx@gator> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: drjones@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vatsa@codeaurora.org, sdonthineni@nvidia.com, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Jul 2021 22:42:43 +0100, Andrew Jones wrote: > > On Thu, Jul 15, 2021 at 05:31:43PM +0100, Marc Zyngier wrote: > > KVM/arm64 currently considers that any memory access outside of a > > memslot is a MMIO access. This so far has served us very well, but > > obviously relies on the guest trusting the host, and especially > > userspace to do the right thing. > > > > As we keep on hacking away at pKVM, it becomes obvious that this trust > > model is not really fit for a confidential computing environment, and > > that the guest would require some guarantees that emulation only > > occurs on portions of the address space that have clearly been > > identified for this purpose. > > This trust model is hard for me to reason about. userspace is trusted to > control the life cycle of the VM, to prepare the memslots for the VM, > and [presumably] identify what MMIO ranges are valid, yet it's not > trusted to handle invalid MMIO accesses. I'd like to learn more about > this model and the userspace involved. Imagine the following scenario: On top of the normal memory described as memslots (which pKVM will ensure that userspace cannot access), a malicious userspace describes to the guest another memory region in a firmware table and does not back it with a memslot. The hypervisor cannot validate this firmware description (imagine doing ACPI and DT parsing at EL2...), so the guest starts using this "memory" for something, and data slowly trickles all the way to EL0. Not what you wanted. To ensure that this doesn't happen, we reverse the problem: userspace (and ultimately the EL1 kernel) doesn't get involved on a translation fault outside of a memslot *unless* the guest has explicitly asked for that page to be handled as a MMIO. With that, we have a full description of the IPA space contained in the S2 page tables: - memory described via a memslot, - directly mapped device (GICv2, for exmaple), - MMIO exposed for emulation and anything else is an invalid access that results in an abort. Does this make sense to you? Thanks, M. -- Without deviation from the norm, progress is not possible.