Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3839773pxp; Tue, 15 Mar 2022 07:18:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5I6lMCxITOodlXxU1I1hgtC0ekLQ2DPfKl0BHHoOkOuP4Z5rR3yt3Q/4Keq4QkU/C9nOa X-Received: by 2002:a17:906:5d12:b0:6db:8b63:f17 with SMTP id g18-20020a1709065d1200b006db8b630f17mr21328925ejt.194.1647353889323; Tue, 15 Mar 2022 07:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647353889; cv=none; d=google.com; s=arc-20160816; b=unVStS5bqbOMz1w01ojzTXFuZ5thqRHa2m5KEsOtWHzpX83zhj10gyPflgXV4laMTq k5FP4dRRuIMUW49Xzs7iVJZTDksWt8zFtngeCOjS3AMppgKTpYPQGk7hFRvOHGrEZWbF 5ue4L/uzYDX0aOpCO7wWjAGBsC5xC2pAqVbv+2hWjXkE98wzTh95u8Qd66iQn1DsPZcy ySBTjhdb0CTAGSA4LheM0ddohPjYmKO9Xu6MfqrDAP43Z+6XS43iPrnSdqK7CoOtd0wt mL9ze5fok9TnZKB4mrFq+3NHNCn9+Gf9nw2XIvsJhla0u63bZmjAwvsPDopeF7MCzut5 YucQ== 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=f2mx1XUUlp12T6iVJ8ZfTCd5aF5zOWGaDksJ5HhBih0=; b=dkW/UMJ9hHM1s41IzfF+v33F7nuNWhMcOPIRtDtEzA/sg0RPRu499AmFjMiIxjIk6f zbGTklELy0eQjeHOifQZ7H32lfjL3lS0t1RNIktkh/j6N347zzsRaZoDDzvIaIRQy/3y VvSsmtJ0GU5ZJbbA+0WO53FwVnUObgWM6m+D2by8dkG494cJ5vc9ynnG0seKs8v9ApqH TwcsOKAwga1cJ8PCSDiwl0RIg4lE3yiufX5Ctym9NSPdw5YcW5F10CplX+zBiuxxST3+ MWZPf9qK5d1/6AzVcFtufkMKmiOQ6ARFNpF7v/Xs2rsIN+SnjooiU8pEafVRFZuKz01f JoCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PUGAWiWt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170906414700b006db4742dbebsi10074227ejk.626.2022.03.15.07.17.38; Tue, 15 Mar 2022 07:18:09 -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=@gmail.com header.s=20210112 header.b=PUGAWiWt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243828AbiCNTq1 (ORCPT + 99 others); Mon, 14 Mar 2022 15:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235483AbiCNTq0 (ORCPT ); Mon, 14 Mar 2022 15:46:26 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0193DA67; Mon, 14 Mar 2022 12:45:16 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id z3so14432415plg.8; Mon, 14 Mar 2022 12:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=f2mx1XUUlp12T6iVJ8ZfTCd5aF5zOWGaDksJ5HhBih0=; b=PUGAWiWtYQEI/LUdwRv6HXIubdu5SR1S/o23kfD/KnvlEQX6ZMpK2yoTcgoPbus2xT QckGUaxfeZr6pNQNNtQQfA+cOSOkGcsbjgQ+7XjISICFNcIxz62o1v/bDChAUmGvpbSU EnVJAMreRu7PYHGESfMx1GQ4aCDHRLFPMFNg31gtgE7HfZTGze6EbbwZnp7i6RdFSI3h V/MesHVQuVRbxRDwtF0JilFj2PrR2+JCPwUlvRrMTgpGQZuKJWHT3bzXgld7hPvLHryX t4Z66j3nmSjNuIPxGAS4qVAHj2N6sfc5VyNeHZz/ufJPDoqeBuzXKzMO3cUFbMlYKyrj u5ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=f2mx1XUUlp12T6iVJ8ZfTCd5aF5zOWGaDksJ5HhBih0=; b=t9qUunt5dx2zudSw+RY1yehcugI7rFh5auqDmqkirprbCWldNwVVtRVzctZiEyq3Ac fXJKslX49RIW3LnDHNNlEENVd6diFz+ASxZYQg8YJNNsuU2hrAe+74/Vpbdp+fcT+bZs fQI+Y/5+T0/kfgCvxkt277T4XeJlGZuASeM5PicBREoBoEHguKAr+nlOGKoZVjF12Ohq vy7BSbd+Rx5bFefchFqZ9etVwjrrNl9ZZ3Dj2F8GWhA/AgTR6B0hR3QPGDa3s7XYGsh1 pclP1ISNOjW7pORevRNBuhUeQwj1gxPsFaRcxQd5+XD207COOnxCGr1t93EzioUMygDE JQiQ== X-Gm-Message-State: AOAM533badiUmxUOxXLvNQgqc0k1zu8Kiu8Em1Y/W5q1BMH+7eijnB4Z dTrdTQcgFy0C+oZDVOHvkss= X-Received: by 2002:a17:90a:528b:b0:1bc:c5f9:82a with SMTP id w11-20020a17090a528b00b001bcc5f9082amr777771pjh.210.1647287115917; Mon, 14 Mar 2022 12:45:15 -0700 (PDT) Received: from localhost ([192.55.54.52]) by smtp.gmail.com with ESMTPSA id p186-20020a62d0c3000000b004f6fa49c4b9sm20134226pfg.218.2022.03.14.12.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 12:45:14 -0700 (PDT) Date: Mon, 14 Mar 2022 12:45:13 -0700 From: Isaku Yamahata To: Paolo Bonzini Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: Re: [RFC PATCH v5 008/104] KVM: TDX: Add a function to initialize TDX module Message-ID: <20220314194513.GD1964605@ls.amr.corp.intel.com> References: <05aecc5a-e8d2-b357-3bf1-3d0cb247c28d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <05aecc5a-e8d2-b357-3bf1-3d0cb247c28d@redhat.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Sun, Mar 13, 2022 at 03:03:40PM +0100, Paolo Bonzini wrote: > On 3/4/22 20:48, isaku.yamahata@intel.com wrote: > > + > > + if (!tdx_module_initialized) { > > + if (enable_tdx) { > > + ret = __tdx_module_setup(); > > + if (ret) > > + enable_tdx = false; > > "enable_tdx = false" isn't great to do only when a VM is created. Does it > make sense to anticipate this to the point when the kvm_intel.ko module is > loaded? It's possible. I have the following two reasons to chose to defer TDX module initialization until creating first TD. Given those reasons, do you still want the initialization at loading kvm_intel.ko module? If yes, I'll change it. - memory over head: The initialization of TDX module requires to allocate physically contiguous memory whose size is about 0.43% of the system memory. If user don't use TD, it will be wasted. - VMXON on all pCPUs: The TDX module initialization requires to enable VMX (VMXON) on all present pCPUs. vmx_hardware_enable() which is called on creating guest does it. It naturally fits with the TDX module initialization at creating first TD. I wanted to avoid code to enable VMXON on loading the kvm_intel.ko. -- Isaku Yamahata