Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5478199iob; Mon, 9 May 2022 18:00:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqjMVLL//lkFDvcRaaAbQktgRob1T1pcuXB3iost+gKaklYKjIUuQBJQbFqs4o5ZbhUDZ4 X-Received: by 2002:a05:6808:20aa:b0:326:9a80:1f95 with SMTP id s42-20020a05680820aa00b003269a801f95mr7760726oiw.176.1652144432319; Mon, 09 May 2022 18:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652144432; cv=none; d=google.com; s=arc-20160816; b=YYNonwcS9wFPwNShVb5iEvEIL66k6s0hntKIPO1HHVa9ryfns0jttLXfil4RdDWjtJ o3tdeRZPnx3Xg2QQKPbNoHzGnIIjzY/CKi4CfeHeFmRjZh1PqS2nXlutA4cxBfpyTTuZ AI53FnwBA5fnVjcgGpCBHPYBrtqj5quUPEXL1JdiwgYTEmZAFyK5MIApcYAupe1XNpE9 lUpue5NC/KwSoAfuHukZ2xp5AS4D4zH1dEPPTn6ydb7L3H7OqZaxmOM7vCEqJi36+eqg cAaDXm+/lM8/hmM0O2eb3CjYRYVd/Hsv2i3HxDMTHhdRfReejEy6hI7LQu3I61NhPENt pUMA== 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=slKbUtc69p2KeempozzbAIxM3x91fFs20DNMuiQjL9s=; b=zL+BpQOiariTujiuZ0UUPTqEV1bf7yg8VuJGni2CD8tfD3+NNVqZNbsBFrpEKc9+UK s+9QA3QAkZQOo3yF18sXm5KUdWWFkO9VFKt89yNjuhZYbfO7z3EZ0y7qP9S+Gk3VhRSk /mY5eu0CzDeOb7rK2aEm6Ze/qtbA/nXvNTCiovtWn+E/LNLNvAMaCogx35y7XwM3y8/3 fvAMv5LG8iBRMwo1EoHHXm5cjGzbis74pYaMqU6F4RFbfOzd3zQni4bnTzl7goGHD66M DETCvdRjPrVb+acgJi3J0Sbs//7UfZTxDd4eUolAYSTP8Ilyx6lUr7nFo1HFhwsbQMXL tzSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=FctVuGuw; 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 q5-20020a9d6305000000b006062240a051si11705282otk.221.2022.05.09.18.00.18; Mon, 09 May 2022 18:00:32 -0700 (PDT) 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=FctVuGuw; 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 S231978AbiEIWwm (ORCPT + 99 others); Mon, 9 May 2022 18:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231935AbiEIWwl (ORCPT ); Mon, 9 May 2022 18:52:41 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACB9A2C4F44; Mon, 9 May 2022 15:48:43 -0700 (PDT) Received: from zn.tnic (p5de8eeb4.dip0.t-ipconnect.de [93.232.238.180]) (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 DCDE41EC0505; Tue, 10 May 2022 00:48:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1652136517; 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=slKbUtc69p2KeempozzbAIxM3x91fFs20DNMuiQjL9s=; b=FctVuGuw8dO9M2UMZWidY63HaTAL/Z6Wy2R/7wNB5j9cM7zG6mYf5CpKm17/Rg03+1ciJc ZfYk9YuM4qiOnENAKLJO73T3++amOiUAkxx3NGpQIXPm6QcQoVL90KViNeWNSgOXS4TdXN kJntPd637mwrgChYDiF8X7W8vIgibuk= Date: Tue, 10 May 2022 00:48:40 +0200 From: Borislav Petkov To: Tianyu Lan Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, brijesh.singh@amd.com, venu.busireddy@oracle.com, michael.roth@amd.com, Tianyu.Lan@microsoft.com, thomas.lendacky@amd.com, jroedel@suse.de, michael.h.kelley@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, vkuznets@redhat.com, parri.andrea@gmail.com Subject: Re: [PATCH] x86/Hyper-V: Add SEV negotiate protocol support in Isolation VM Message-ID: References: <20220505131502.402259-1-ltykernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220505131502.402259-1-ltykernel@gmail.com> 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, T_SCC_BODY_TEXT_LINE 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 Thu, May 05, 2022 at 09:15:02AM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > Hyper-V Isolation VM code uses sev_es_ghcb_hv_call() to read/write MSR > via GHCB page. The SEV-ES guest should negotiate GHCB version before > reading/writing MSR via GHCB page. Why is that? > Expose sev_es_negotiate_protocol() and sev_es_terminate() from AMD SEV > code Yeah, you keep wanting to expose random SEV-specific code and when we go and change it in the future, you'll come complaining that we broke hyperv. I think it might be a lot better if you implement your own functions: for example, looking at sev_es_negotiate_protocol() - it uses only primitives which you can use because, well, VMGEXIT() is simply a wrapper around the asm insn and sev_es_wr_ghcb_msr() is simply writing into the MSR. Ditto for sev_es_terminate(). And sev_es_ghcb_hv_call() too, for that matter. You can define your own. IOW, you're much better off using those primitives and creating your own functions than picking out random SEV-functions and then us breaking your isolation VM stuff. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette