Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1427811rwd; Wed, 31 May 2023 13:55:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4I+7mema4NfdF0GaAEXuzDpgt1PNqLpBxY8g2CVp8nBk9GrL+GolMSfIYl0WxNVNv0+ooH X-Received: by 2002:a17:90a:560a:b0:256:cbe9:83c2 with SMTP id r10-20020a17090a560a00b00256cbe983c2mr5521078pjf.38.1685566550969; Wed, 31 May 2023 13:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685566550; cv=none; d=google.com; s=arc-20160816; b=bIYe6LH98/y50uR6Mom7cGSwQtzbeWycE8qOJ+FLaP+orXZ6v+L395oCtIB9bOy7b9 l12w1Mu0u0rg8TdrwxBPB6SugndGm2aKtx+bPBRZen9V5w0yBMEeVCZg0xY/Gi0hoBk8 7oMA4wpyuxPLmZBIhYSbxrAt4dc27/R5JviCAvUT2Lafygown9oDvV81UkfHwtsN01S4 StV/BAro868FelrXnYA/cwrALFzjnpaLKs0iOy90/uaqbSNEApF4PuJKzvasTkghp2Bl h2eknxpvxMMj7qhisMnBcwHKClqUqCKurovNmZdMAGLXM9CWyCTKzHk/kuPOOQ6EjmCo 11JA== 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=TkKYKkqHcR+9f2etlgEJShv7Ao181m9IUBoJvwooid4=; b=gINI6185lTxJl3ENHVZwyP92PTgwovayL2VWpwYh82thza7W9DU7irbMjx6rEd4IqC Y1bHsjiwsWEeVGBCMScfPcjJIOo1y1u7YoNC/1z28OrDgWl+H7MHPqi+Qa22mHmJbgIw uEquGG4wJqJWfRDnS/TToKCdRaxnoLin+1omYU3/h8tuVBsbGNNbNVr6fNPlyXiU7hyK 1pPK+A1WrLvZjx5kZI8ktLNSXpzEcXg4Kw06mMYEFFneFELJy2DixqfIpVCUoKP1BZih PxA6ABtmGY7dhDXox8a9ktTCaRc8Eu7+1uB/ysxaHjE2SLyEux73gNry/tr4PpzEkf2E 5q5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=q3UJCkng; 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 79-20020a630052000000b0053f3d04e671si1661737pga.691.2023.05.31.13.55.38; Wed, 31 May 2023 13:55:50 -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=20221208 header.b=q3UJCkng; 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 S230230AbjEaUaT (ORCPT + 99 others); Wed, 31 May 2023 16:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229633AbjEaUaR (ORCPT ); Wed, 31 May 2023 16:30:17 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4763D101; Wed, 31 May 2023 13:30:16 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6af6db17a27so116022a34.2; Wed, 31 May 2023 13:30:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685565015; x=1688157015; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TkKYKkqHcR+9f2etlgEJShv7Ao181m9IUBoJvwooid4=; b=q3UJCkngDungWbExd8FMG+IqZ3el7slhuQ5k459Pj7t1aQWnHBfrXnV/O2nlhHW4NA yVmr2WMTtFmRTpvV5Lg6y5Dssam9eGm4yLiPNjhP4QreDp8iy4EjF111Tt0UBB1+4wrh INzptlB6b80GLLZ42TVeQ38KGWHkgu3cyIUIjHHZiyu289/jaGgLfLnPSqhvMYXpViE7 IjpHh4iTut9MBSTtyMsh3RWoTrtHX2lIWNlEcD/EURrceCLf9XihEsMLPhrGt81yi0As S6r0t1UWQEt4YMZM/oqWk0Ocks2p9RdTaXIcj5i8nMGVmdYLaiM+jhFjaGJcz+snLL7+ 4/Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685565015; x=1688157015; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TkKYKkqHcR+9f2etlgEJShv7Ao181m9IUBoJvwooid4=; b=W602xVON+ILY0s+Qf9xAT4fpNuwChW7WdhNP4XAy9wxn1aoazexR5iRrS/Dfe/VRv8 LMMloYVUESMq7sDNtSwAb8zN7AYKXgRZN1P4nY34bo/SU5IWCCHtXgrw4OXJ4XQy5EX+ OkDWSIfSyaqkyvROAcyeGjYqO5UDEGyu6QQO3C0ox7t/847EITtv+hdIvlh8ohthw2yD z/08JRZHHzPfiwoXsmlNEg8dBrqt09fVoLEilVd6+BmKXtMeLxLen+0SlOxrn13I682d Gbc1/vz5Sh/FDCT0eQlzWqG9hmXD34XbVko3etM6J71uPqvnvaXtCl5VThbERA5BgT+9 1XFA== X-Gm-Message-State: AC+VfDyUZbVQDEFDmWYTmUCaoE+3bavdBGWGTNH4B1BEYd1+hHfbmFqE Mvf3GNQj/Swb4bQdKLf+f3E= X-Received: by 2002:a05:6358:714:b0:123:36a2:7936 with SMTP id e20-20020a056358071400b0012336a27936mr865081rwj.27.1685565015312; Wed, 31 May 2023 13:30:15 -0700 (PDT) Received: from localhost ([192.55.54.50]) by smtp.gmail.com with ESMTPSA id i8-20020a654848000000b0050f85ef50d1sm1585890pgs.26.2023.05.31.13.30.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 13:30:14 -0700 (PDT) Date: Wed, 31 May 2023 13:30:12 -0700 From: Isaku Yamahata To: Zhi Wang Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , chen.bo@intel.com Subject: Re: [PATCH v14 003/113] KVM: x86/vmx: Refactor KVM VMX module init/exit functions Message-ID: <20230531203012.GG1234772@ls.amr.corp.intel.com> References: <4ef61085333e97e0ae48c3d7603042b9801e3608.1685333727.git.isaku.yamahata@intel.com> <20230531093950.00007e7d.zhi.wang.linux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230531093950.00007e7d.zhi.wang.linux@gmail.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 Wed, May 31, 2023 at 09:57:18AM +0800, Zhi Wang wrote: > > +static int __init vt_init(void) > > +{ > > + unsigned int vcpu_size, vcpu_align; > > + int r; > > + > > + if (!kvm_is_vmx_supported()) > > + return -EOPNOTSUPP; > > + > > + /* > > + * Note, hv_init_evmcs() touches only VMX knobs, i.e. there's nothing > > + * to unwind if a later step fails. > > + */ > > + hv_init_evmcs(); > > + > > + r = kvm_x86_vendor_init(&vt_init_ops); > > + if (r) > > + return r; > > + > > + r = vmx_init(); > > + if (r) > > + goto err_vmx_init; > > + > > + /* > > + * Common KVM initialization _must_ come last, after this, /dev/kvm is > > + * exposed to userspace! > > + */ > > + vcpu_size = sizeof(struct vcpu_vmx); > > + vcpu_align = __alignof__(struct vcpu_vmx); > > + r = kvm_init(vcpu_size, vcpu_align, THIS_MODULE); > > + if (r) > > + goto err_kvm_init; > > + > > + return 0; > > + > --------------------------------- > > +err_kvm_init: > > + vmx_exit(); > > +err_vmx_init: > > + kvm_x86_vendor_exit(); > > + return r; > > +} > > +module_init(vt_init); > > + > ---------------------------------- > > +static void vt_exit(void) > > +{ > > + kvm_exit(); > > + kvm_x86_vendor_exit(); > > + vmx_exit(); > ---------------------------------- > > It seems the exiting sequences above are a little bit different with > each other (PS: It is not a prob introduced in this patch): > > vmx_exit() > kvm_x86_vendor_exit() > .... > > and > > ... > kvm_x86_vnedor_exit() > vmx_exit() > > I was wondering which one should be correct. Literally, the exiting > sequence would be in reversing order of the initialization sequence. In theory, I think kvm_x86_vendor_exit() => vmx_exit() and vmx_init() => kvm_x86_vendor_exit() should be the right order. But in practice, it doesn't matter and I didn't want to touch the order with this patch series. -- Isaku Yamahata