Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp881814pxb; Fri, 13 Aug 2021 08:21:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF2l+dOK6w4bYDN6grilOyAY01zi5O0irE68hBzDbcvwh0Tk/IzyGLd8gssrO4ymgiMxfl X-Received: by 2002:a05:6402:5:: with SMTP id d5mr3719044edu.359.1628868080679; Fri, 13 Aug 2021 08:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628868080; cv=none; d=google.com; s=arc-20160816; b=aajxN7lKf05F8lv2xA+55gTaXdHsU1zS0bOxTYV7HjC6Eu4j/B6iawzUz2tP3huX1g JKVZgf2OPCOOlt7+FteOgfB2cs0bYdL5EzNwrjIfIuep2czI56Fh+lVsXMdKaeY0pibM fWwQFnT1QX8/UzlB0QN/bS0KxAcuDufvxQoov8GiBCDkyv2QjPFsKFfZgnRCl2wirTwG LDyfbyENU/E9v91UEvag9vb+2KnisikaXV0KNAFjxmIQVJZHXieHvT8zgqs2pYnIv4aP 50Wyy82mmLaEyS1455e/zM/DY854Rd2SjEdizfyInewXRIIEMqxbEGzH/pWmF9hkA4Lz 0F7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lcZRb7fN3hFtAKCXxg7x6SSxBo6yLJXq3dd1LH5J27A=; b=qs9Aj2qt5gCu82lTfk0NaC6eXXyzFwkkvFGWUkbetCIkqP3FLLBhHL8LUHZAD8Z7Pp wpEfA3m3FKgDIEElUAdq3ZpU8gmbx/qarQwV/KlsUK7fs2X5AEtYo8gabYZ8wwfjAgYa KuKMxYjucIeZ7nM49h+LAVs+4+WmnG82WRV1QbaMtCl+sxOxLATK4x0L6otsXTt3VY9T xxUxqVJ68218bO59SsAdbCD8/8oqQYUN/epvxeNgVTP1XJzTzhHfA9oy5/ALCWgAFbNk Th2M/faEw0PazqksQIwLTya/ZTYwatDmZwslyHPL6OeiHWgUbh3DOr/W5oJHJLt1Nv66 A1Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Clc8p7ko; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n23si1837804ejr.678.2021.08.13.08.20.47; Fri, 13 Aug 2021 08:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=Clc8p7ko; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242013AbhHMPSc (ORCPT + 99 others); Fri, 13 Aug 2021 11:18:32 -0400 Received: from mail.skyhub.de ([5.9.137.197]:45364 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241781AbhHMPQk (ORCPT ); Fri, 13 Aug 2021 11:16:40 -0400 Received: from zn.tnic (p200300ec2f0a0d0070a51027a6cfb94b.dip0.t-ipconnect.de [IPv6:2003:ec:2f0a:d00:70a5:1027:a6cf:b94b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 90F391EC01A8; Fri, 13 Aug 2021 17:16:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1628867765; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lcZRb7fN3hFtAKCXxg7x6SSxBo6yLJXq3dd1LH5J27A=; b=Clc8p7koFJ+GJJXpijQCzMHuLwybz/LyKXR0HDs+oqj3CwGY5tNTpH+j+U/fF+kI9y3oIf DLgkSPeZps+chyUHErsdpd71tlyGXnxpRP1mexeir7y8per+tlAF/7FEHY0maGC2sfT0nL jFaiheSWsQhftC/35TNt3MLwEerRIm4= Date: Fri, 13 Aug 2021 17:16:48 +0200 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com Subject: Re: [PATCH Part1 RFC v4 08/36] x86/sev: check the vmpl level Message-ID: References: <20210707181506.30489-1-brijesh.singh@amd.com> <20210707181506.30489-9-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Aug 13, 2021 at 08:13:20AM -0500, Brijesh Singh wrote: > During the firmware initialization the PSP requires that the VMPLEn is > set. See SNP firmware spec [1] section 8.6. To run the SNP guest you > *must* specify a VMPL level during the vCPU creation. Yes, that's why I said "implicit VMPL level 0"! When you don't specify it, it should implied as 0. Right now that "enable" bit is useless as it is *forced* to be enabled. I sincerely hope querying the VMPL level is going to be made straight-forwaed in future versions. > I should not say its optional when we know from the SEV-SNP spec that > VMPLEn must be set to launch SEV-SNP guest. I will fix the description. It probably wasn't required when that bit was invented - why would you call it "enable" otherwise - but some decision later made it required, I'd guess. > There is no easy way for a guest to query its VMPL level. Yes, and there should be. > The VMPL level is set during the vCPU creation. The boot cpu is > created by the HV and thus its VMPL level is set by the HV. If HV > chooses a lower VMPL level for the boot CPU then Linux guest will > not be able to validate its memory because the PVALIDATE instruction > will cause #GP when the vCPU is running at !VMPL0. The patch tries to > detect the boot CPU VMPL level and terminate the boot. I figured as much. All I don't like is the VMPL checking method. > If guest is not running at VMPL0 then step #2 will cause #GP.  The check > is prevent the #GP and terminate the boot early. Yah, Tom helped me understand the design of the permission masks in the RMP on IRC. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette