[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <127f95b84355e8c08f314a0db56e958ed8ef0636.camel@intel.com>
Date: Thu, 8 Jun 2023 10:18:31 +0000
From: "Huang, Kai" <kai.huang@...el.com>
To: "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"Hansen, Dave" <dave.hansen@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: "Luck, Tony" <tony.luck@...el.com>,
"david@...hat.com" <david@...hat.com>,
"bagasdotme@...il.com" <bagasdotme@...il.com>,
"ak@...ux.intel.com" <ak@...ux.intel.com>,
"Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"Chatre, Reinette" <reinette.chatre@...el.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"Yamahata, Isaku" <isaku.yamahata@...el.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"peterz@...radead.org" <peterz@...radead.org>,
"Shahar, Sagi" <sagis@...gle.com>,
"imammedo@...hat.com" <imammedo@...hat.com>,
"Gao, Chao" <chao.gao@...el.com>,
"Brown, Len" <len.brown@...el.com>,
"sathyanarayanan.kuppuswamy@...ux.intel.com"
<sathyanarayanan.kuppuswamy@...ux.intel.com>,
"Huang, Ying" <ying.huang@...el.com>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH v11 10/20] x86/virt/tdx: Add placeholder to construct
TDMRs to cover all TDX memory regions
On Wed, 2023-06-07 at 08:57 -0700, Dave Hansen wrote:
> On 6/4/23 07:27, Kai Huang wrote:
> > +struct tdmr_info_list {
> > + void *tdmrs; /* Flexible array to hold 'tdmr_info's */
> > + int nr_consumed_tdmrs; /* How many 'tdmr_info's are in use */
>
> I'm looking back here after seeing the weird cast in the next patch.
>
> Why is this a void* instead of a _real_ type?
I followed your suggestion in v8:
https://lore.kernel.org/linux-mm/725de6e9-e468-48ef-3bae-1e8a1b7ef0f7@intel.com/
I quoted the relevant part here:
> +/* Get the TDMR from the list at the given index. */
> +static struct tdmr_info *tdmr_entry(struct tdmr_info_list *tdmr_list,
> + int idx)
> +{
> + return (struct tdmr_info *)((unsigned long)tdmr_list->first_tdmr +
> + tdmr_list->tdmr_sz * idx);
> +}
I think that's more complicated and has more casting than necessary.
This looks nicer:
int tdmr_info_offset = tdmr_list->tdmr_sz * idx;
return (void *)tdmr_list->first_tdmr + tdmr_info_offset;
Also, it might even be worth keeping ->first_tdmr as a void*. It isn't
a real C array and keeping it as void* would keep anyone from doing:
tdmr_foo = tdmr_list->first_tdmr[foo];
Powered by blists - more mailing lists