Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp577087pxb; Fri, 22 Apr 2022 07:12:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtqh6lR/ItpZ6R25JCw8+p93X25EvYTGEmrWhPx+bYzOf5LD4e2emI1y3RwzFXSEsjoNbd X-Received: by 2002:a17:907:7252:b0:6df:75cc:615e with SMTP id ds18-20020a170907725200b006df75cc615emr4330189ejc.683.1650636753205; Fri, 22 Apr 2022 07:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650636753; cv=none; d=google.com; s=arc-20160816; b=M8uVG+ANk16JjBlIqNn7WT02AsiiUvyY+uvLtINq5Wrq5SlBNYbFwVWgpe9a6mQMOy dSGdsyVUXJtNjWLrsyKxaHGYpH1YyeqH0aBMOqT/ml3gZzo+CSoraKe17UkrDSMGwzfA sHO9z6/8fpviyZ5XNnvGpRGgizDEvicM0LF3CRVIhgcqkdlfV4RoFjrLA9W7ZMkDba+T NjbbeMNoXZ99Wan+lmnkmpO+70f5RXC8ufpNybkQVKQfvEeq9fePi3etOCztSs3FGEV9 OHJmQKLUvqVeVhnsXx3wg5Augxo/UjYLxUu9Qw1k/ss+KLAQ0qslxqf7H73Poh53NU87 KedQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=cZcLKp5pXoXYxQBVshhtG207i9zrRi8PnpCmks3d7G8=; b=PA3vmq3/uKdnUVPxpZNAsBDyMcYvo7hHR6+mN0uUEdaMABeuv+XKP5TbuIQS3G2+LG XdzR2ZytiIFBe7V45fHQAlCGwoJkWlm8bpAi71vilpDYSKt1oFg9NazGExbM6yT4lEvK PtpYl1BJHsNANjWkJbhodC18c9QPFojWPmZJuNz8i3pSPXnDz5bYwQ6hk32kNCEw1I2y +coSlWv1LDbLPzrPd9OnFuszbw9m3WjCNw/hRlo1mTqPe6YXeYrp+gzOAxMSp8Xxb52V nHbcIq2/zW16NPXrgyhRwPlzgJ9I+qoj82Cu/+H4geCwPvnRL+34syMiKeu1ShNKLXvP GLUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=oD+QQfkF; 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 k5-20020a170906578500b006dfb901bf65si6611672ejq.535.2022.04.22.07.12.08; Fri, 22 Apr 2022 07:12:33 -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=oD+QQfkF; 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 S1382856AbiDTWi1 (ORCPT + 99 others); Wed, 20 Apr 2022 18:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233746AbiDTWi0 (ORCPT ); Wed, 20 Apr 2022 18:38:26 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 164F6403EF; Wed, 20 Apr 2022 15:35:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650494139; x=1682030139; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=i1FV9ua/QKqRvQE28+dhqw9LbkWLdadta+7evj3sFmk=; b=oD+QQfkFtsDodvhhubmQLJVqUfV70VsMEINBKYKbBA+I31aAHwl8SKbS RP793G55btg8w/QdOlM32mc3VqOcITt+QyiSqtiQV16ZkCa1SlODicHk6 Nmt67d/c5TzUpSNqj0SsRs/xsWkS+zJoJJQlQRlWsH4kTF4rWvyS8wkPt mHztCWsgLHRTT0oxqDh8YocQ96Eugf6WzOTozmnW7//rxboF6uQlgJ5OV nVfyCdmAXkCeZCd7g8QakMqxpB6EM/+nBto2e1AuUqO9C7leudkYIDZYt bV6cFcxaHOhyyXnE453iaKn3G5joJLCniZpGOIN0wkKLDaFceKgZshFVe Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10323"; a="246056291" X-IronPort-AV: E=Sophos;i="5.90,276,1643702400"; d="scan'208";a="246056291" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 15:35:35 -0700 X-IronPort-AV: E=Sophos;i="5.90,276,1643702400"; d="scan'208";a="658249359" Received: from ssharm9-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.30.148]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 15:35:32 -0700 Message-ID: Subject: Re: [PATCH v3 04/21] x86/virt/tdx: Add skeleton for detecting and initializing TDX on demand From: Kai Huang To: Sathyanarayanan Kuppuswamy , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, isaku.yamahata@intel.com Date: Thu, 21 Apr 2022 10:35:30 +1200 In-Reply-To: <136845e1-fe43-fbb6-3a95-741c46c42156@linux.intel.com> References: <32dcf4c7acc95244a391458d79cd6907125c5c29.1649219184.git.kai.huang@intel.com> <136845e1-fe43-fbb6-3a95-741c46c42156@linux.intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 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 > > > > > + > > > > +/** > > > > + * tdx_detect - Detect whether the TDX module has been loaded > > > > + * > > > > + * Detect whether the TDX module has been loaded and ready for > > > > + * initialization. Only call this function when all cpus are > > > > + * already in VMX operation. > > > > + * > > > > + * This function can be called in parallel by multiple callers. > > > > + * > > > > + * Return: > > > > + * > > > > + * * -0: The TDX module has been loaded and ready for > > > > + * initialization. > > > > + * * -ENODEV: The TDX module is not loaded. > > > > + * * -EPERM: CPU is not in VMX operation. > > > > + * * -EFAULT: Other internal fatal errors. > > > > + */ > > > > +int tdx_detect(void) > > > > > > Will this function be used separately or always along with > > > tdx_init()? > > > > The caller should first use tdx_detect() and then use tdx_init(). If caller > > only uses tdx_detect(), then TDX module won't be initialized (unless other > > caller does this). If caller calls tdx_init() before tdx_detect(), it will get > > error. > > > > I just checked your patch set to understand where you are using > tdx_detect()/tdx_init(). But I did not find any callers. Did I miss it? > or it is not used in your patch set? > No you didn't. They are not called in this series. KVM series which is under upstream process by Isaku will call them. Dave once said w/o caller is fine as for this particular case people know KVM is going to use them. In cover letter I also mentioned KVM support is under development by another series. Next version in cover letter, I'll explicitly call out this series doesn't have caller of them but depends on KVM to call them. -- Thanks, -Kai