[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZtGGYmE3rE7d1wiu@tlindgre-MOBL1>
Date: Fri, 30 Aug 2024 11:44:18 +0300
From: Tony Lindgren <tony.lindgren@...ux.intel.com>
To: "Huang, Kai" <kai.huang@...el.com>
Cc: "Gao, Chao" <chao.gao@...el.com>,
"Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
"Li, Xiaoyao" <xiaoyao.li@...el.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"isaku.yamahata@...il.com" <isaku.yamahata@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 10/25] KVM: TDX: Initialize KVM supported capabilities
when module setup
On Tue, Aug 13, 2024 at 05:26:06AM +0000, Huang, Kai wrote:
> On Tue, 2024-08-13 at 11:25 +0800, Chao Gao wrote:
> > > + for (i = 0; i < td_conf->num_cpuid_config; i++) {
> > > + struct kvm_tdx_cpuid_config source = {
> > > + .leaf = (u32)td_conf->cpuid_config_leaves[i],
> > > + .sub_leaf = td_conf->cpuid_config_leaves[i] >> 32,
> > > + .eax = (u32)td_conf->cpuid_config_values[i].eax_ebx,
> > > + .ebx = td_conf->cpuid_config_values[i].eax_ebx >> 32,
> > > + .ecx = (u32)td_conf->cpuid_config_values[i].ecx_edx,
> > > + .edx = td_conf->cpuid_config_values[i].ecx_edx >> 32,
> > > + };
> > > + struct kvm_tdx_cpuid_config *dest =
> > > + &kvm_tdx_caps->cpuid_configs[i];
> > > +
> > > + memcpy(dest, &source, sizeof(struct kvm_tdx_cpuid_config));
> >
> > this memcpy() looks superfluous. does this work?
> >
> > kvm_tdx_caps->cpuid_configs[i] = {
> > .leaf = (u32)td_conf->cpuid_config_leaves[i],
> > .sub_leaf = td_conf->cpuid_config_leaves[i] >> 32,
> > .eax = (u32)td_conf->cpuid_config_values[i].eax_ebx,
> > .ebx = td_conf->cpuid_config_values[i].eax_ebx >> 32,
> > .ecx = (u32)td_conf->cpuid_config_values[i].ecx_edx,
> > .edx = td_conf->cpuid_config_values[i].ecx_edx >> 32,
> > };
>
> This looks good to me. I didn't try to optimize because it's done in the
> module loading time.
I'll do a patch to initialize dest directly without a memcpy().
Tony
Powered by blists - more mailing lists