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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 BC970C4361B for ; Thu, 17 Dec 2020 11:27:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D2552389F for ; Thu, 17 Dec 2020 11:27:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726503AbgLQL0u (ORCPT ); Thu, 17 Dec 2020 06:26:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:53266 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbgLQL0t (ORCPT ); Thu, 17 Dec 2020 06:26:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608204322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lxpRQsHZQY7Zhu3tHDp4QojWc4yaEKZVUewR/UonSok=; b=htDZB9NlajgA4XWKifDKQl+3SJ8LvvJd9KFOfbDC5JfEHyblbCNtN8TcMcKXPyPkDsIn1q CcKzxAjTVr13a1sUDCwPNz+JjH+9cja/POgMiBGDS51h0ZwAzHcQ+IVqnxXXRy2o4TPRLw 5fiBHy3NVEV+ZtkDFvqoFW11dSMrijM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-0m8KPQnMPVORYFAcIXnkGw-1; Thu, 17 Dec 2020 06:25:18 -0500 X-MC-Unique: 0m8KPQnMPVORYFAcIXnkGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3FC4809DCD; Thu, 17 Dec 2020 11:25:16 +0000 (UTC) Received: from gondolin (ovpn-113-176.ams2.redhat.com [10.36.113.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75A36100164C; Thu, 17 Dec 2020 11:25:03 +0000 (UTC) Date: Thu, 17 Dec 2020 12:24:35 +0100 From: Cornelia Huck To: David Gibson Cc: pair@us.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, brijesh.singh@amd.com, dgilbert@redhat.com, qemu-devel@nongnu.org, Eduardo Habkost , qemu-ppc@nongnu.org, rth@twiddle.net, thuth@redhat.com, berrange@redhat.com, mdroth@linux.vnet.ibm.com, Marcelo Tosatti , "Michael S. Tsirkin" , Marcel Apfelbaum , david@redhat.com, Richard Henderson , borntraeger@de.ibm.com, kvm@vger.kernel.org, qemu-s390x@nongnu.org, pasic@linux.ibm.com Subject: Re: [for-6.0 v5 08/13] securable guest memory: Introduce sgm "ready" flag Message-ID: <20201217122435.5d7513fe.cohuck@redhat.com> In-Reply-To: <20201217053820.GG310465@yekko.fritz.box> References: <20201204054415.579042-1-david@gibson.dropbear.id.au> <20201204054415.579042-9-david@gibson.dropbear.id.au> <20201214180036.3837693e.cohuck@redhat.com> <20201217053820.GG310465@yekko.fritz.box> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/wsLjr2rTq1uwHIhjnWRYsmX"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org --Sig_/wsLjr2rTq1uwHIhjnWRYsmX Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 17 Dec 2020 16:38:20 +1100 David Gibson wrote: > On Mon, Dec 14, 2020 at 06:00:36PM +0100, Cornelia Huck wrote: > > On Fri, 4 Dec 2020 16:44:10 +1100 > > David Gibson wrote: > > =20 > > > The platform specific details of mechanisms for implementing securable > > > guest memory may require setup at various points during initializatio= n. > > > Thus, it's not really feasible to have a single sgm initialization ho= ok, > > > but instead each mechanism needs its own initialization calls in arch= or > > > machine specific code. > > >=20 > > > However, to make it harder to have a bug where a mechanism isn't prop= erly > > > initialized under some circumstances, we want to have a common place, > > > relatively late in boot, where we verify that sgm has been initialize= d if > > > it was requested. > > >=20 > > > This patch introduces a ready flag to the SecurableGuestMemory base t= ype > > > to accomplish this, which we verify just before the machine specific > > > initialization function. > > >=20 > > > Signed-off-by: David Gibson > > > --- > > > hw/core/machine.c | 8 ++++++++ > > > include/exec/securable-guest-memory.h | 2 ++ > > > target/i386/sev.c | 2 ++ > > > 3 files changed, 12 insertions(+) > > >=20 > > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > > index 816ea3ae3e..a67a27d03c 100644 > > > --- a/hw/core/machine.c > > > +++ b/hw/core/machine.c > > > @@ -1155,6 +1155,14 @@ void machine_run_board_init(MachineState *mach= ine) > > > } > > > =20 > > > if (machine->sgm) { > > > + /* > > > + * Where securable guest memory is initialized depends on the > > > + * specific mechanism in use. But, we need to make sure it's > > > + * ready by now. If it isn't, that's a bug in the > > > + * implementation of that sgm mechanism. > > > + */ > > > + assert(machine->sgm->ready); =20 > >=20 > > Under which circumstances might we arrive here with 'ready' not set? > >=20 > > - programming error, setup is happening too late -> assert() seems > > appropriate =20 >=20 > Yes, this is designed to catch programming errors. In particular I'm > concerned about: > * Re-arranging the init code, and either entirely forgetting the sgm > setup, or accidentally moving it too late > * The sgm setup is buried in the machine setup code, conditional on > various things, and changes mean we no longer either call it or > (correctly) fail > * User has specified an sgm scheme designed for a machine type other > than the one they selected. The arch/machine init code hasn't > correctly accounted for that possibility and ignores it, instead > of correctly throwing an error > =20 > > - we tried to set it up, but some error happened -> should we rely on > > the setup code to error out first? (i.e. we won't end up here, unless > > there's a programming error, in which case the assert() looks > > fine) =20 >=20 > Yes, that's my intention. >=20 > > Is there a possible use case for "we could not set it up, but we > > support an unsecured guest (as long as it is clear what happens)"? =20 >=20 > I don't think so. My feeling is that if you specify that you want the > feature, qemu needs to either give it to you, or fail, not silently > degrade the features presented to the guest. Yes, that should align with what QEMU is doing elsewhere. >=20 > > Likely only for guests that transition themselves, but one could > > argue that QEMU should simply be invoked a second time without the > > sgm stuff being specified in the error case. =20 >=20 > Right - I think whatever error we give here is likely to be easier to > diagnose than the guest itself throwing an error when it fails to > transition to secure mode (plus we should catch it always, rather than > only if we run a guest which tries to go secure). Yes, that makes sense. --Sig_/wsLjr2rTq1uwHIhjnWRYsmX Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAl/bP/MACgkQ3s9rk8bw L6/uTw//S3IbdBwx0BYRCbCnGHnICuCmlQmt5o41nd86PMCiN1dQ6egtoQf6j2RY fkRrd0AmD/5QtfO7KYUJnaIy9W3uSDgFQTIfGey0J7SvoY0BIxEW5gSMl31othxI jAkxrC6JRc4/SgpuvdWUTTf1NBph+v5LycOTjLfih6UvVrSLCsrAtt+X4opPx1ti reDAsF1qmeCaIUll9JgF3seJzsjl794hmW69DycTv9qLcLOdBHjwDhUnfh5Ttd0Y 3Tf9wPBJDs3Wpdmxx5G6un+4n79MCZ+13QnFcrPObo21jn4+Tm2lVViPJrjKGhxc XQ8nJlaGRMaqtfpi9HEI1bxi7+2Js6oHudpWavXMKjOydtbmT5kI9/NjIKasnXLK tRN2ropRKxYUmSA8L2sStv1zUig1yp2A8Ih6r2CCnaCBJK7ls2o7vXF6ytwI7m7u +Rh+Xg871P0b+vtFW+TCSzcNBT2K9yFM4BDkWn3vsnJi72Z2bPku2o7wZJQx5GJJ DpBmroXYVLpwrgjjYmZHYpXKRNZIdfsGDkH1xj9hYoAqUFp0lwjvqmKRPjAIT92E ip6ejIcl4+rPUzn7b0tYH7EtNebYV2yzKvlDi7POdWoidFpmUzPCG9b8tmGpz+Os 2N84KaCwSFn2PBDqUnR1uKXlViE1qitO+mUozNgyafFaaTmZpR8= =L1lU -----END PGP SIGNATURE----- --Sig_/wsLjr2rTq1uwHIhjnWRYsmX-- 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=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 100F9C4361B for ; Thu, 17 Dec 2020 11:27:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 4D3E82389F for ; Thu, 17 Dec 2020 11:27:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D3E82389F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kprRL-0008Qc-1t for qemu-devel@archiver.kernel.org; Thu, 17 Dec 2020 06:27:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kprPT-0007fo-4F for qemu-devel@nongnu.org; Thu, 17 Dec 2020 06:25:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kprPP-0002tm-OS for qemu-devel@nongnu.org; Thu, 17 Dec 2020 06:25:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608204322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=lxpRQsHZQY7Zhu3tHDp4QojWc4yaEKZVUewR/UonSok=; b=htDZB9NlajgA4XWKifDKQl+3SJ8LvvJd9KFOfbDC5JfEHyblbCNtN8TcMcKXPyPkDsIn1q CcKzxAjTVr13a1sUDCwPNz+JjH+9cja/POgMiBGDS51h0ZwAzHcQ+IVqnxXXRy2o4TPRLw 5fiBHy3NVEV+ZtkDFvqoFW11dSMrijM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-466-0m8KPQnMPVORYFAcIXnkGw-1; Thu, 17 Dec 2020 06:25:18 -0500 X-MC-Unique: 0m8KPQnMPVORYFAcIXnkGw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3FC4809DCD; Thu, 17 Dec 2020 11:25:16 +0000 (UTC) Received: from gondolin (ovpn-113-176.ams2.redhat.com [10.36.113.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75A36100164C; Thu, 17 Dec 2020 11:25:03 +0000 (UTC) Date: Thu, 17 Dec 2020 12:24:35 +0100 From: Cornelia Huck To: David Gibson Subject: Re: [for-6.0 v5 08/13] securable guest memory: Introduce sgm "ready" flag Message-ID: <20201217122435.5d7513fe.cohuck@redhat.com> In-Reply-To: <20201217053820.GG310465@yekko.fritz.box> References: <20201204054415.579042-1-david@gibson.dropbear.id.au> <20201204054415.579042-9-david@gibson.dropbear.id.au> <20201214180036.3837693e.cohuck@redhat.com> <20201217053820.GG310465@yekko.fritz.box> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/wsLjr2rTq1uwHIhjnWRYsmX"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Received-SPF: pass client-ip=63.128.21.124; envelope-from=cohuck@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pair@us.ibm.com, brijesh.singh@amd.com, frankja@linux.ibm.com, kvm@vger.kernel.org, "Michael S. Tsirkin" , Richard Henderson , Marcelo Tosatti , david@redhat.com, qemu-devel@nongnu.org, dgilbert@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com, thuth@redhat.com, pbonzini@redhat.com, rth@twiddle.net, mdroth@linux.vnet.ibm.com, Eduardo Habkost Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --Sig_/wsLjr2rTq1uwHIhjnWRYsmX Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 17 Dec 2020 16:38:20 +1100 David Gibson wrote: > On Mon, Dec 14, 2020 at 06:00:36PM +0100, Cornelia Huck wrote: > > On Fri, 4 Dec 2020 16:44:10 +1100 > > David Gibson wrote: > > =20 > > > The platform specific details of mechanisms for implementing securable > > > guest memory may require setup at various points during initializatio= n. > > > Thus, it's not really feasible to have a single sgm initialization ho= ok, > > > but instead each mechanism needs its own initialization calls in arch= or > > > machine specific code. > > >=20 > > > However, to make it harder to have a bug where a mechanism isn't prop= erly > > > initialized under some circumstances, we want to have a common place, > > > relatively late in boot, where we verify that sgm has been initialize= d if > > > it was requested. > > >=20 > > > This patch introduces a ready flag to the SecurableGuestMemory base t= ype > > > to accomplish this, which we verify just before the machine specific > > > initialization function. > > >=20 > > > Signed-off-by: David Gibson > > > --- > > > hw/core/machine.c | 8 ++++++++ > > > include/exec/securable-guest-memory.h | 2 ++ > > > target/i386/sev.c | 2 ++ > > > 3 files changed, 12 insertions(+) > > >=20 > > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > > index 816ea3ae3e..a67a27d03c 100644 > > > --- a/hw/core/machine.c > > > +++ b/hw/core/machine.c > > > @@ -1155,6 +1155,14 @@ void machine_run_board_init(MachineState *mach= ine) > > > } > > > =20 > > > if (machine->sgm) { > > > + /* > > > + * Where securable guest memory is initialized depends on the > > > + * specific mechanism in use. But, we need to make sure it's > > > + * ready by now. If it isn't, that's a bug in the > > > + * implementation of that sgm mechanism. > > > + */ > > > + assert(machine->sgm->ready); =20 > >=20 > > Under which circumstances might we arrive here with 'ready' not set? > >=20 > > - programming error, setup is happening too late -> assert() seems > > appropriate =20 >=20 > Yes, this is designed to catch programming errors. In particular I'm > concerned about: > * Re-arranging the init code, and either entirely forgetting the sgm > setup, or accidentally moving it too late > * The sgm setup is buried in the machine setup code, conditional on > various things, and changes mean we no longer either call it or > (correctly) fail > * User has specified an sgm scheme designed for a machine type other > than the one they selected. The arch/machine init code hasn't > correctly accounted for that possibility and ignores it, instead > of correctly throwing an error > =20 > > - we tried to set it up, but some error happened -> should we rely on > > the setup code to error out first? (i.e. we won't end up here, unless > > there's a programming error, in which case the assert() looks > > fine) =20 >=20 > Yes, that's my intention. >=20 > > Is there a possible use case for "we could not set it up, but we > > support an unsecured guest (as long as it is clear what happens)"? =20 >=20 > I don't think so. My feeling is that if you specify that you want the > feature, qemu needs to either give it to you, or fail, not silently > degrade the features presented to the guest. Yes, that should align with what QEMU is doing elsewhere. >=20 > > Likely only for guests that transition themselves, but one could > > argue that QEMU should simply be invoked a second time without the > > sgm stuff being specified in the error case. =20 >=20 > Right - I think whatever error we give here is likely to be easier to > diagnose than the guest itself throwing an error when it fails to > transition to secure mode (plus we should catch it always, rather than > only if we run a guest which tries to go secure). Yes, that makes sense. --Sig_/wsLjr2rTq1uwHIhjnWRYsmX Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEw9DWbcNiT/aowBjO3s9rk8bwL68FAl/bP/MACgkQ3s9rk8bw L6/uTw//S3IbdBwx0BYRCbCnGHnICuCmlQmt5o41nd86PMCiN1dQ6egtoQf6j2RY fkRrd0AmD/5QtfO7KYUJnaIy9W3uSDgFQTIfGey0J7SvoY0BIxEW5gSMl31othxI jAkxrC6JRc4/SgpuvdWUTTf1NBph+v5LycOTjLfih6UvVrSLCsrAtt+X4opPx1ti reDAsF1qmeCaIUll9JgF3seJzsjl794hmW69DycTv9qLcLOdBHjwDhUnfh5Ttd0Y 3Tf9wPBJDs3Wpdmxx5G6un+4n79MCZ+13QnFcrPObo21jn4+Tm2lVViPJrjKGhxc XQ8nJlaGRMaqtfpi9HEI1bxi7+2Js6oHudpWavXMKjOydtbmT5kI9/NjIKasnXLK tRN2ropRKxYUmSA8L2sStv1zUig1yp2A8Ih6r2CCnaCBJK7ls2o7vXF6ytwI7m7u +Rh+Xg871P0b+vtFW+TCSzcNBT2K9yFM4BDkWn3vsnJi72Z2bPku2o7wZJQx5GJJ DpBmroXYVLpwrgjjYmZHYpXKRNZIdfsGDkH1xj9hYoAqUFp0lwjvqmKRPjAIT92E ip6ejIcl4+rPUzn7b0tYH7EtNebYV2yzKvlDi7POdWoidFpmUzPCG9b8tmGpz+Os 2N84KaCwSFn2PBDqUnR1uKXlViE1qitO+mUozNgyafFaaTmZpR8= =L1lU -----END PGP SIGNATURE----- --Sig_/wsLjr2rTq1uwHIhjnWRYsmX--