mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: Chao Gao <chao.gao@intel.com>
Cc: <pbonzini@redhat.com>, <seanjc@google.com>, <kvm@vger.kernel.org>,
	<rick.p.edgecombe@intel.com>, <isaku.yamahata@intel.com>,
	<reinette.chatre@intel.com>, <binbin.wu@linux.intel.com>,
	<xiaoyao.li@intel.com>, <yan.y.zhao@intel.com>,
	<adrian.hunter@intel.com>, <tony.lindgren@intel.com>,
	<kristen@linux.intel.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] KVM: VMX: Initialize TDX during KVM module load
Date: Thu, 21 Nov 2024 08:28:50 +0800	[thread overview]
Message-ID: <5927eaf9-d9ac-4056-85af-39bb90eabed3@intel.com> (raw)
In-Reply-To: <eb37d3fc-7d19-4dc2-bac4-6e0cb5c8aa1e@intel.com>


>> Shouldn't we make enable_tdx dependent on enable_virt_at_load? 
>> Otherwise, if
>> someone sets enable_tdx=1 and enable_virt_at_load=0, they will get 
>> hardware
>> virtualization enabled at load time while enable_virt_at_load still 
>> shows 0.
>> This behavior is a bit confusing to me.

Forgot to reply this ...

>>
>> I think a check against enable_virt_at_load in kvm_can_support_tdx() 
>> will work.
>>
>> The call of kvm_enable_virtualization() here effectively moves
>> kvm_init_virtualization() out of kvm_init() when enable_tdx=1. I 
>> wonder if it
>> makes more sense to refactor out kvm_init_virtualization() for non-TDX 
>> cases
>> as well, i.e.,
>>
>>    vmx_init();
>>    kvm_init_virtualization();
>>    tdx_init();
>>    kvm_init();
>>
>> I'm not sure if this was ever discussed. To me, this approach is 
>> better because
>> TDX code needn't handle virtualization enabling stuff. It can simply 
>> check that
>> enable_virt_at_load=1, assume virtualization is enabled and needn't 
>> disable
>> virtualization on errors.
> 
> I think this was briefly discussed here:
> 
> https://lore.kernel.org/all/ZrrFgBmoywk7eZYC@google.com/
> 
> The disadvantage of splitting out kvm_init_virtualization() is all other 
> ARCHs (all non-TDX cases actually) will need to explicitly call 
> kvm_init_virtualization() separately.
> 
>>
>> A bonus is that on non-TDX-capable systems, hardware virtualization 
>> won't be
>> toggled twice at KVM load time for no good reason.
> 
> I am fine with either way.
> 
> Sean, do you have any comments?
> 

... and yes I think we should make TDX depend on 'enable_virt_at_load'.

And by doing this, I think we can still do kvm_init_virtualization() 
inside kvm_init():

'enable_virt_at_load' still reflects its behaviour -- TDX just enables 
virt earlier than other cases, but it is still "enable virt at load".

It's perhaps not perfect, but it saves unneeded separate call of 
kvm_init_virtualization() for other ARCHs.




      reply	other threads:[~2024-11-21  0:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15  9:52 [PATCH v2 0/3] KVM: VMX: Initialize TDX when loading KVM module Kai Huang
2024-11-15  9:52 ` [PATCH v2 1/3] KVM: VMX: Refactor VMX module init/exit functions Kai Huang
2024-11-15  9:52 ` [PATCH v2 2/3] KVM: Export hardware virtualization enabling/disabling functions Kai Huang
2024-11-15  9:52 ` [PATCH v2 3/3] KVM: VMX: Initialize TDX during KVM module load Kai Huang
2024-11-18  6:22   ` Chao Gao
2024-11-20 23:38     ` Huang, Kai
2024-11-21  0:28       ` Huang, Kai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5927eaf9-d9ac-4056-85af-39bb90eabed3@intel.com \
    --to=kai.huang@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=binbin.wu@linux.intel.com \
    --cc=chao.gao@intel.com \
    --cc=isaku.yamahata@intel.com \
    --cc=kristen@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=reinette.chatre@intel.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=tony.lindgren@intel.com \
    --cc=xiaoyao.li@intel.com \
    --cc=yan.y.zhao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®