Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1189103rwb; Tue, 29 Nov 2022 10:03:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf7FMkqvEeWtp4EJzDENDq08Gisx8S2O7SKV63kincvhWbsnkKXklkBuntJC+Wgd2Aq4V527 X-Received: by 2002:a17:903:cc:b0:189:7100:bbd1 with SMTP id x12-20020a17090300cc00b001897100bbd1mr19868905plc.115.1669745028954; Tue, 29 Nov 2022 10:03:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669745028; cv=none; d=google.com; s=arc-20160816; b=qaMFvsQQPIDq0Ud88GhKdKxtfyPO9As7mYSkkHvYosRcdeDYs2fQ8+4gNfxxcBcqzU HhmH219wCzMsWX2VXmMsICpkjvZaEneD5E48073DBvpdpQ2ePRTM6dGHcbndHt31E5d/ P6fMekFJmIPqHnvm1koTF35s010+KfTiF3DM4pkfTv6MzZhf0J6TjB9jHTnxfP7ZuO8R qDNHnsospV2tWXbNUcl8QlpOhyDPhocNbie+VlkK47+HEUMy2BgC2EogMjOM5DF+zMA2 GhsQq3Nu/sixdZXIzIlRINEks86+LyyfDCaSKTeDZhkAqk05tS6Jh7fP9xxsgnDSLA2g F+dA== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=JYhgRUKR3FJNpFBq84Sg5nW8vU15kq68SWoPzofwG0Q=; b=1EilFnLEuyB2ezdInjMURdXpHRh+B5Xuetn2LgK5+/fPpIOmfARstSdeOxG2C9xyVC tlqtTm84q+JV/RGv3j/yUkbfTfs5X8txoSFeb2FEa1McrZOiUDoK78ZKdGK5nao+SqzY NDEKxiCnAFHX6sw3aRU+yhs7HdYtQsCZoc69aPF1l9E718dk+sObWm/daDzogFtUPbKs MXJKJkABp+BiU5EcprhuoEgEYhp+yUCeX5kErH3M/JSDQZUN8rafb2R3jDdPs0wVuVCp rqalzRSehxXEI1hmp3wGwqn9H+g7+dQ+f4xen2KB4Si94RJaR8LtFIgo30IfNAWItjB1 Lv4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=C9yhgsGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d18-20020a170902ced200b0018946b0b641si17249289plg.371.2022.11.29.10.03.27; Tue, 29 Nov 2022 10:03:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=C9yhgsGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S235589AbiK2RrQ (ORCPT + 85 others); Tue, 29 Nov 2022 12:47:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235857AbiK2RrM (ORCPT ); Tue, 29 Nov 2022 12:47:12 -0500 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B239754B1B; Tue, 29 Nov 2022 09:47:11 -0800 (PST) Received: from zn.tnic (p200300ea9733e724329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:9733:e724:329c:23ff:fea6:a903]) (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 DDD711EC04CB; Tue, 29 Nov 2022 18:47:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1669744029; 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:in-reply-to:in-reply-to: references:references; bh=JYhgRUKR3FJNpFBq84Sg5nW8vU15kq68SWoPzofwG0Q=; b=C9yhgsGHLVsG8saaLstTe4dmxJhjJrBTCPd3mxTbQfv/ZNKgNmjwaJFRkyIDeReJdY8oJp ijIxUTdRKklOYNwQC8739rCLHnOBfPiMOPxKOA45aWsUni+NS12zAui7+VMmWL4BjXL+IF GJdt2hcUVZySzvYGVvQ2SxFp4+cFRpM= Date: Tue, 29 Nov 2022 18:47:06 +0100 From: Borislav Petkov To: "Michael Kelley (LINUX)" Cc: "thomas.lendacky@amd.com" , "hpa@zytor.com" , KY Srinivasan , Haiyang Zhang , "wei.liu@kernel.org" , Dexuan Cui , "luto@kernel.org" , "peterz@infradead.org" , "davem@davemloft.net" , "edumazet@google.com" , "kuba@kernel.org" , "pabeni@redhat.com" , "lpieralisi@kernel.org" , "robh@kernel.org" , "kw@linux.com" , "bhelgaas@google.com" , "arnd@arndb.de" , "hch@infradead.org" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" , "brijesh.singh@amd.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "dave.hansen@linux.intel.com" , Tianyu Lan , "kirill.shutemov@linux.intel.com" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "ak@linux.intel.com" , "isaku.yamahata@intel.com" , "Williams, Dan J" , "jane.chu@oracle.com" , "seanjc@google.com" , "tony.luck@intel.com" , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-arch@vger.kernel.org" , "iommu@lists.linux.dev" Subject: Re: [Patch v3 07/14] x86/hyperv: Change vTOM handling to use standard coco mechanisms Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 29, 2022 at 03:49:06PM +0000, Michael Kelley (LINUX) wrote: > But it turns out that AMD really has two fairly different schemes: > the C-bit scheme and the vTOM scheme. Except it doesn't: "In the VMSA of an SNP-active guest, the VIRTUAL_TOM field designates a 2MB aligned guest physical address called the virtual top of memory. When bit 1 (vTOM) of SEV_FEATURES is set in the VMSA of an SNP-active VM, the VIRTUAL_TOM..." So SEV_FEATURES[1] is vTOM and it is part of SNP. Why do you keep harping on this being something else is beyond me... I already pointed you to the patch which adds this along with the other SEV_FEATURES. > The details of these two AMD schemes are pretty different. vTOM is > *not* just a minor option on the C-bit scheme. It's an either/or -- a > guest VM is either doing the C-bit scheme or the vTOM scheme, not some > combination. Linux code in coco/core.c could choose to treat C-bit and > vTOM as two sub-schemes under CC_VENDOR_AMD, but that makes the code a > bit messy because we end up with "if" statements to figure out whether > to do things the C-bit way or the vTOM way. Are you saying that that: if (cc_vendor == CC_VENDOR_AMD && sev_features & MSR_AMD64_SNP_VTOM_ENABLED) is messy? Why? We will have to support vTOM sooner or later. > Or we could model the two AMD schemes as two different vendors, > which is what I'm suggesting. Doing so recognizes that the two schemes > are fairly disjoint, and it makes the code cleaner. How is that any different from the above check? You *need* some sort of a check to differentiate between the two anyway. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette