Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3866010imw; Mon, 11 Jul 2022 18:13:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tGPk3JtSbJWiwP06RIgapvVshJ0xosfeyfz8oUlV3PXcWn7wuATn1HhpMn5m0ViyWVI4f8 X-Received: by 2002:a17:907:75ef:b0:72b:2fd:1a92 with SMTP id jz15-20020a17090775ef00b0072b02fd1a92mr21394437ejc.745.1657588385186; Mon, 11 Jul 2022 18:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657588385; cv=none; d=google.com; s=arc-20160816; b=j2VXdWqYlEU6CdbW/1v/4lmCr94E6tEgGN8tMGbxobYRjKZoLqZmaE2dRM05Awk1UT Kg3lcT7vJ6Lf4yH6o6jH+oS4+JGMLmVuQLbntQjzYcqW1yLYtD0QDEehQZO4nHe6b55S VVccDwrcVm761JO8mcns18sG87WV0jQ7nM7XfAqXHM9BsKn0ogNpfBMwLkwnsx85ZKkJ SMJOyS4YG5ub2oDeNNl0WpQLBIEdBNd0Fo5BcbZ/v2vPHfXWlh0wJ/XooHB0o4BbjvFL ykjbj9j2t9NyPgNTRgqXnjtXKux3vMXYzc4rLig/QUMergOJagnRA7kodvKkmKxC6FJ7 XgYw== 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=PmFaKZIjci33tQMvV6r2y1+5A3/n4Qt8XlR0JqP9Soo=; b=Ik9Q7ABrSwB1wpt6kMIKvPtlutuyk3Exx83DbtMUoCGdczO/UecwSo86EVsxHT+aBr Fyt6eSNBG/sS+ThZwMYMo3+G4bCTwkMMgRQRUcrCgGjG510wxvzYQuGpC6OOOulffBUf 3mWo99OLpTy2XbHjF4Q9m091nIvD8tj7IDJS2rLGfIif/LS9sxbiqh42LS+UBkHe3NN8 nor8VHTHo3bmxR2w82x5IWJMPJOPYOb++mNczWDnQeeUl7HCVrlAZt7FXvCxnrdPKkyU sh8s9RFrGsErkZvhC6235A1AwDBKk6dpvCDksqDAAGZM97cD4DJOuUU/d+PwudZJvvla 7TAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=em5Aoywg; 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 dn11-20020a17090794cb00b0072aebd63c02si14035183ejc.623.2022.07.11.18.12.36; Mon, 11 Jul 2022 18:13:05 -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=em5Aoywg; 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 S231952AbiGLAqp (ORCPT + 99 others); Mon, 11 Jul 2022 20:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231906AbiGLAqo (ORCPT ); Mon, 11 Jul 2022 20:46:44 -0400 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 28A584C638; Mon, 11 Jul 2022 17:46:43 -0700 (PDT) Received: by mail-pg1-x52b.google.com with SMTP id bf13so6153208pgb.11; Mon, 11 Jul 2022 17:46:43 -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=PmFaKZIjci33tQMvV6r2y1+5A3/n4Qt8XlR0JqP9Soo=; b=em5AoywgWgeV/BIPYdR55C7ss6CjjZ57gc78SzsmuWvB5XPZwoG9lxaVWSgSjGXN1k P1p5Pedj8X4hXsxpvn/z1SfqxrUEg3o6mUStujpg2s6whJ8vzOBg00hKYtMPas/hxz8z Wz3FI9QBvoQNwtHMTOIv5uAt4lOAza5awDc95CMGVUbiL5GYLtB7Hr039IhW6OTmhg7f bR/fFGqsX710vfz5Su0iqN9vfFa7YKLooz/n1S/FTEf7IK5t1veZUHIT4slGMxfOVCaR l4sbAKtaqRqHcUJJb806Q9l/6lqIUHmSr9Uke3stDIcw0Fn1PZ8qPHmob1ITZBSNTnRo 6RCg== 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=PmFaKZIjci33tQMvV6r2y1+5A3/n4Qt8XlR0JqP9Soo=; b=fBCwyzjeqcoWIjlWXyZko9J4htaM195YtKjk8VGT6YUjvJQR8RkDsFeQmB37Hthvu4 370jZ8gQCvJ92Q4XvQ2/GBj06Hw87NVasDB2+g+a9hLgcL5GyW+Yv0fxIYwehR+1FQ16 7o2NFe+0fMjuUSUp3TxDWI5TTAs44s/eh9JeliO6TkXaxWNW55Iv+OqDiq4EuLzqrns5 zGOC+oEFhv1GSejo5HeyZKqWovsOQA45STtjX2T4rmXT6618GJOk5zaHUsvALvtwypLn A7TSGEVINPkAIHpoIz616iN7WgiSV0ZYOOBIEgdyeoYYVsc4WZ+UiEX1nVw8ws+Q3mPf kC4g== X-Gm-Message-State: AJIora9PDKg3xgSXFK4hqGpVOpbM5wsXHk5+0i4OsMPXES1wtHUVHLP2 Qa4TdocWEykRG7Osaj3dhjg= X-Received: by 2002:a05:6a00:1592:b0:525:7809:42c6 with SMTP id u18-20020a056a00159200b00525780942c6mr21461491pfk.64.1657586802386; Mon, 11 Jul 2022 17:46:42 -0700 (PDT) Received: from localhost (fmdmzpr02-ext.fm.intel.com. [192.55.54.37]) by smtp.gmail.com with ESMTPSA id ml5-20020a17090b360500b001ef82d23125sm7597781pjb.25.2022.07.11.17.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 17:46:41 -0700 (PDT) Date: Mon, 11 Jul 2022 17:46:40 -0700 From: Isaku Yamahata To: Kai Huang Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , Sean Christopherson Subject: Re: [PATCH v7 011/102] KVM: TDX: Initialize TDX module when loading kvm_intel.ko Message-ID: <20220712004640.GD1379820@ls.amr.corp.intel.com> References: <81ea5068b890400ca4064781f7d2221826701020.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <81ea5068b890400ca4064781f7d2221826701020.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,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 Tue, Jun 28, 2022 at 04:31:35PM +1200, Kai Huang wrote: > On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > > > To use TDX functionality, TDX module needs to be loaded and initialized. > > A TDX host patch series[1] implements the detection of the TDX module, > > tdx_detect() and its initialization, tdx_init(). > > "A TDX host patch series[1]" really isn't a commit message material. You can > put it to the cover letter, but not here. > > Also tdx_detect() is removed in latest code. How about the followings? KVM: TDX: Initialize TDX module when loading kvm_intel.ko To use TDX functionality, TDX module needs to be loaded and initialized. This patch is to call a function, tdx_init(), when loading kvm_intel.ko. Add a hook, kvm_arch_post_hardware_enable_setup, to module initialization while hardware is enabled, i.e. after hardware_enable_all() and before hardware_disable_all(). Because TDX requires all present CPUs to enable VMX (VMXON). > > 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; > > } > > > > +int kvm_arch_post_hardware_enable_setup(void *opaque) > > +{ > > + struct kvm_x86_init_ops *ops = opaque; > > + if (ops->post_hardware_enable_setup) > > + return ops->post_hardware_enable_setup(); > > + return 0; > > +} > > + > > Where is this kvm_arch_post_hardware_enable_setup() called? > > Shouldn't the code change which calls it be part of this patch? 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. -- Isaku Yamahata