Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3890561imw; Mon, 11 Jul 2022 18:56:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tJaFCU0Z9T+scNZSEliiayiWz5ezTBQmjD8TyVA2f4daBjjlsezky2DXio/S7d3btOcIZh X-Received: by 2002:a17:906:1ca:b0:715:73f3:b50f with SMTP id 10-20020a17090601ca00b0071573f3b50fmr21162424ejj.374.1657590999616; Mon, 11 Jul 2022 18:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657590999; cv=none; d=google.com; s=arc-20160816; b=VC0lOyuWKmTz/FTY7QGVPKlIaYAuDqm+JW3sT7Knf14nQBHNjbcpWQt8yxgBrnWIK6 GTAq1yUYR6utzQL3FPa6CbHpa953gZctsN5o/fCbAkDjFen1G86y4pG+kkvGvx8uLzJW WPjSKH5kKjyjIvlaZmnF+bZ0NYUEqPfhwRCNiC7sIEDoQTq6mSOA7wEHFAfISfLYrri1 69UBxoTug4VaLdAKgYABjfCUxEsmjWXMzOpLgerFYkBfuu3CYA5At7d2fSDYlDaQuNPe ne5kfKpTLIX88Gm769SCAKixd+z0xWqtIL/LR5Qj6wWkoz20ugaO8yRD7TRiR6urjpOF Ie6A== 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 :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=KfJyiyXAfbbHDv/JPFRiHqrtqmewZPlQ/QtKFAIcUcI=; b=ZPUxVcuu8AWkTQzrdjhz0DNje1SIozmcZOJf3eiTjhpPpTuGRung8WQDZrif298kjO WqWeqdJnHA7iTsNCnBy9wayZoCB0Z47Aa6+4QAGZas1xpnzvgoU7QpGIhAFSGSfqyUxg jU9o2GyDH//dEMON3RWW0SQCcoRjA9KJfaS/9k8Jyb9S3cg0OBojGv2GhW/eznbOMGVE MIgeMeDXLSOu1RBjJrD/vbzziX99GZdcKM8o5OwZFPzGnEcZriVmREwDyqCzFlnRl16M eYUDcpGfOmGRszVqZsopCCq4VK7Cou3hDGew97L/PXMzdM3Q4wi5CmgIJA5LNtvy4gM0 0ptw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=O1klND3s; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz38-20020a1709077da600b0072b452b0fe4si12099435ejc.156.2022.07.11.18.56.07; Mon, 11 Jul 2022 18:56:39 -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=@intel.com header.s=Intel header.b=O1klND3s; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231591AbiGLBNT (ORCPT + 99 others); Mon, 11 Jul 2022 21:13:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231350AbiGLBNP (ORCPT ); Mon, 11 Jul 2022 21:13:15 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F07F9509E0; Mon, 11 Jul 2022 18:13:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657588394; x=1689124394; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=T2p2PDep+Jk58poJbivNq6gYM425mMNK9DXK1/lNMbk=; b=O1klND3sQ5G+JenV/YWfV4N6Zx0By/DRQn4SSIKsqguUwg0WAQhSasN6 SaBNilchfloBHcFUdd+Gm81FlzA2CifhTvcmdJ2TVDHSLn/HZdL82x/fI wckOX8y/0M38LTUJ0vQ/h4+rt+WVfU6jnQrr8EpkiJV2p4CT1cN5mbd4S 0Vdo9PDFd9KMc2rO6QRzZO3NntN+bfE+XIDnjSJPxluGZUtR6IBkH2OwK gz4VMNdfoMdq8IG4LLrP/XrfniYK50MtdFPsUG8kJg+3N2WBySAFd9zIH CWg4eU91E8u+Ieepa1Njwx+V8kWCYUkSvSxAVGzD58eq0/gaS9hHnKCNs Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10405"; a="267848276" X-IronPort-AV: E=Sophos;i="5.92,264,1650956400"; d="scan'208";a="267848276" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 18:13:14 -0700 X-IronPort-AV: E=Sophos;i="5.92,264,1650956400"; d="scan'208";a="595103198" Received: from snaskant-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.212.60.27]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 18:13:12 -0700 Message-ID: Subject: Re: [PATCH v7 011/102] KVM: TDX: Initialize TDX module when loading kvm_intel.ko From: Kai Huang To: Isaku Yamahata Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Sean Christopherson Date: Tue, 12 Jul 2022 13:13:10 +1200 In-Reply-To: <20220712004640.GD1379820@ls.amr.corp.intel.com> References: <81ea5068b890400ca4064781f7d2221826701020.camel@intel.com> <20220712004640.GD1379820@ls.amr.corp.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,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 Mon, 2022-07-11 at 17:46 -0700, Isaku Yamahata wrote: > On Tue, Jun 28, 2022 at 04:31:35PM +1200, > Kai Huang wrote: >=20 > > On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@intel.com wrote: > > > From: Isaku Yamahata > > >=20 > > > To use TDX functionality, TDX module needs to be loaded and initializ= ed. > > > A TDX host patch series[1] implements the detection of the TDX module= , > > > tdx_detect() and its initialization, tdx_init(). > >=20 > > "A TDX host patch series[1]" really isn't a commit message material. Y= ou can > > put it to the cover letter, but not here. > >=20 > > Also tdx_detect() is removed in latest code. >=20 > How about the followings? >=20 > KVM: TDX: Initialize TDX module when loading kvm_intel.ko Personally don't like kvm_intel.ko in title (or changelog), but will leave = to maintainers. > =20 > To use TDX functionality, TDX module needs to be loaded and initializ= ed. > This patch is to call a function, tdx_init(), when loading kvm_intel.= ko. Could you add explain why we need to init TDX module when loading KVM modul= e? You don't have to say "call a function, tdx_init()", which can be easily se= en in the code. =20 > =20 > Add a hook, kvm_arch_post_hardware_enable_setup, to module initializa= tion > while hardware is enabled, i.e. after hardware_enable_all() and befor= e > hardware_disable_all(). Because TDX requires all present CPUs to ena= ble > VMX (VMXON). Please explicitly say it is a replacement of the default __weak version, so people can know there's already a default one. Otherwise people may wonder= why this isn't called in this patch (i.e. I skipped patch 03 as it looks not directly related to TDX). That being said, why cannot you send out that patch separately but have to include it into TDX series? Looking at it, the only thing that is related to TDX is an empty kvm_arch_post_hardware_enable_setup() with a comment saying TDX needs to do something there. This logic has nothing to do with the actual job in that patch.=20 So why cannot we introduce that __weak version in this patch, so that the r= est of it can be non-TDX related at all and can be upstreamed separately? >=20 > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > > index 30af2bd0b4d5..fb7a33fbc136 100644 > > > --- a/arch/x86/kvm/x86.c > > > +++ b/arch/x86/kvm/x86.c > > > @@ -11792,6 +11792,14 @@ int kvm_arch_hardware_setup(void *opaque) > > > return 0; > > > } > > > =20 > > > +int kvm_arch_post_hardware_enable_setup(void *opaque) > > > +{ > > > + struct kvm_x86_init_ops *ops =3D opaque; > > > + if (ops->post_hardware_enable_setup) > > > + return ops->post_hardware_enable_setup(); > > > + return 0; > > > +} > > > + > >=20 > > Where is this kvm_arch_post_hardware_enable_setup() called? > >=20 > > Shouldn't the code change which calls it be part of this patch? >=20 > The patch of "4/102 KVM: Refactor CPU compatibility check on module > initialiization" introduces it. Because the patch affects multiple archs > (mips, x86, poerpc, s390, and arm), I deliberately put it in early. It's patch 03, but not 04. And see above.