Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp1078831imn; Tue, 26 Jul 2022 18:03:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vPB/kNyAE5IFxjCIVeIQWfTqktBWKwl0hUOtuOBocOXgHyFiq1gS2oNRNC2XSEXQGLDjCa X-Received: by 2002:a17:907:2e0d:b0:72b:5cf4:464a with SMTP id ig13-20020a1709072e0d00b0072b5cf4464amr15490233ejc.87.1658883805961; Tue, 26 Jul 2022 18:03:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658883805; cv=none; d=google.com; s=arc-20160816; b=da6L7iYgYPf0ymgRU5K0PwDrGvqulvxmMkBjyAoQfVclX9C/G6y24yZxRtL/Dwn2ls XpJq7oeF4p6Xf+tt5bzE7V4iKk6d5K3z/mI3iPOii3yAcUwFzFEGUrK34VVv7VdiFEx2 A3f9KWBpM1ccH3nL75IDCNE0ZoSvKTUuU+EOi5ykCwF3STdcX+hU88TFMmMmdliPFKjA /8m70fHU0zEZp/ZB9Oxo/wAYKxxupwimEqMfKhMugCiWbz1gVldgVJoWFbzYTCJ1THkK tv7/UwxRZwYlee1PiSREcDPXCoyiVBQpT3pLM8joWMdsrem3LDRVak7xFU6sL1LoDc3L 7aug== 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=GN/As28NJTkt9K3MCXqEyETDJB3ZuY0ItHR0XOMDO20=; b=VXGCX78j1ea1vvmyMCEbNM0/dztvGXhzvTlYSikp1400z7fNWaVd9cnKPmi0Kt3MMR 60Wcn5Y6VdDQ49UDFGA6v/aTUJPSpBLMCJ8Rdsx5SofsgLn6kfvBGE6/vYG/8YyEbIZ0 ssskjOxaNrhAGSmRY1nmQvghFtPC3frZsyELSt7h9/5X6ohO2Uu6KRKB9VY/5yVKnxDR 1Loc6Xu6PhjRgF5g9kduajs0JPZJtlmpuL/Citbn/reAV4ikhYUo96ZHgmBAPotaOSSz ejVBlO89aNgYbIdIGEJG1yKUokAjT3hHBMgYo3jhuCevXqYjCsDjmiHqrIiSNQ8Igbw8 L3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eOVxX9sc; 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 h9-20020a170906828900b0072a6e7a054dsi14482997ejx.975.2022.07.26.18.02.55; Tue, 26 Jul 2022 18:03:25 -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=eOVxX9sc; 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 S240075AbiG0Ao5 (ORCPT + 99 others); Tue, 26 Jul 2022 20:44:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240111AbiG0Aoy (ORCPT ); Tue, 26 Jul 2022 20:44:54 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0618E3AE55; Tue, 26 Jul 2022 17:44:51 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id f11-20020a17090a4a8b00b001f2f7e32d03so2039086pjh.0; Tue, 26 Jul 2022 17:44:51 -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=GN/As28NJTkt9K3MCXqEyETDJB3ZuY0ItHR0XOMDO20=; b=eOVxX9scVmYCLsfd/EiwtUY7Pkh1pNA1M71bz18pHn7CC0EUA9SWx6ahknb9fYP7sO 9Z0a8WQrH+3Z6B17rqEwSJpF3u2OyazBRxsjy0MctCVTgJbiGNJ/+RFcQNoXStrNm3M9 iVOBChBS+ERR/yJOIUkKSvj6tvSe7F5FofEWxriVwbJcb85Z7acXFi7941ek6c0oeXyz q+5WI7HFaYTjrMueA9eyYkTB6dpFkunDo3Y0tE+zIHw3OpvGj0w1fFpxI2+/lt/8bhnU +WWpaKwG2l23r9FxduEWyRmmCCkrx7vDtFpX4gxEDsQ8uJLE50MOl04Y6z+WP22iIEJS UmRA== 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=GN/As28NJTkt9K3MCXqEyETDJB3ZuY0ItHR0XOMDO20=; b=Ed3iAc5zYogG76dYfqnC2kTa5qgu8Q6mXSOXMmXAL9cKHQPp15VSMp/ClJbSEUoQG9 FWjW4AhyNoHReMXuhvriWD43FYKUnnLX3b80mgwF65PXYodjvpWRWcAOKq2pbZRG5UHB 6kbM1xNbVw5NnMxhhr3lW70mzOTeEURJbi4Gen8NJ259+H1nMS1/Nks6cuJ058L3spgi mUj7SNxdt3+ZGFlBAvLxPMeSxURA5XScTwpO9iXRcLnWMycuKiyIGYPh7JHbGShXnmXf fQPJbnWW32lBtSa0ZRNrN43fnmrgql+upjV1s1dcctcilpdnnCnimWSAoVIuPwLwJQeB K/1w== X-Gm-Message-State: AJIora8CKkAaKxoFlb43I4qB9I3IwmzlJKSwtNliR7K7l0l5wh7pCtBK rul9cFWfsx2SuD2cKSgHAV8= X-Received: by 2002:a17:902:7612:b0:16d:2dbe:26f2 with SMTP id k18-20020a170902761200b0016d2dbe26f2mr19645136pll.94.1658882690413; Tue, 26 Jul 2022 17:44:50 -0700 (PDT) Received: from localhost ([192.55.54.49]) by smtp.gmail.com with ESMTPSA id b1-20020a621b01000000b005258df7615bsm12305050pfb.0.2022.07.26.17.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 17:44:49 -0700 (PDT) Date: Tue, 26 Jul 2022 17:44:48 -0700 From: Isaku Yamahata To: Kai Huang Cc: Isaku Yamahata , isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH v7 008/102] KVM: x86: Refactor KVM VMX module init/exit functions Message-ID: <20220727004448.GH1379820@ls.amr.corp.intel.com> References: <46acf87f3980a6f709e191cfc10ff4be78e23553.camel@intel.com> <20220712003811.GB1379820@ls.amr.corp.intel.com> <20f87d1f04f71bd2be63519ebf2a2447c07f7e7a.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20f87d1f04f71bd2be63519ebf2a2447c07f7e7a.camel@intel.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 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, Jul 12, 2022 at 01:30:34PM +1200, Kai Huang wrote: > On Mon, 2022-07-11 at 17:38 -0700, Isaku Yamahata wrote: > > On Tue, Jun 28, 2022 at 03:53:31PM +1200, > > Kai Huang wrote: > > > > > On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@intel.com wrote: > > > > From: Isaku Yamahata > > > > > > > > Currently, KVM VMX module initialization/exit functions are a single > > > > function each. Refactor KVM VMX module initialization functions into KVM > > > > common part and VMX part so that TDX specific part can be added cleanly. > > > > Opportunistically refactor module exit function as well. > > > > > > > > The current module initialization flow is, 1.) calculate the sizes of VMX > > > > kvm structure and VMX vcpu structure, 2.) hyper-v specific initialization > > > > 3.) report those sizes to the KVM common layer and KVM common > > > > initialization, and 4.) VMX specific system-wide initialization. > > > > > > > > Refactor the KVM VMX module initialization function into functions with a > > > > wrapper function to separate VMX logic in vmx.c from a file, main.c, common > > > > among VMX and TDX. We have a wrapper function, "vt_init() {vmx kvm/vcpu > > > > size calculation; hv_vp_assist_page_init(); kvm_init(); vmx_init(); }" in > > > > main.c, and hv_vp_assist_page_init() and vmx_init() in vmx.c. > > > > hv_vp_assist_page_init() initializes hyper-v specific assist pages, > > > > kvm_init() does system-wide initialization of the KVM common layer, and > > > > vmx_init() does system-wide VMX initialization. > > > > > > > > The KVM architecture common layer allocates struct kvm with reported size > > > > for architecture-specific code. The KVM VMX module defines its structure > > > > as struct vmx_kvm { struct kvm; VMX specific members;} and uses it as > > > > struct vmx kvm. Similar for vcpu structure. TDX KVM patches will define > > > > TDX specific kvm and vcpu structures, add tdx_pre_kvm_init() to report the > > > > sizes of them to the KVM common layer. > > > > > > > > The current module exit function is also a single function, a combination > > > > of VMX specific logic and common KVM logic. Refactor it into VMX specific > > > > logic and KVM common logic. This is just refactoring to keep the VMX > > > > specific logic in vmx.c from main.c. > > > > > > This patch, coupled with the patch: > > > > > > KVM: VMX: Move out vmx_x86_ops to 'main.c' to wrap VMX and TDX > > > > > > Basically provides an infrastructure to support both VMX and TDX. Why we cannot > > > merge them into one patch? What's the benefit of splitting them? > > > > > > At least, why the two patches cannot be put together closely? > > > > It is trivial for the change of "KVM: VMX: Move out vmx_x86_ops to 'main.c' to > > wrap VMX and TDX" to introduce no functional change. But it's not trivial > > for this patch to introduce no functional change. > > This doesn't sound right. If I understand correctly, this patch supposedly > shouldn't bring any functional change, right? Could you explain what functional > change does this patch bring? This patch doesn't bring functional change. This patch changes orders of some function calls. It doesn't matter actually. But I think it's non-trivial. -- Isaku Yamahata