Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-30 Thread Xiaoyao Li
On 5/30/2022 7:59 PM, Gerd Hoffmann wrote: Hi, tdx_add_ram_entry() increments tdx_guest->nr_ram_entries. I think it's worth for comments why this is safe regarding to this for-loop. The for-loop is to find the valid existing RAM entry (from E820 table). It will update the RAM entry and

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-30 Thread Gerd Hoffmann
Hi, > > tdx_add_ram_entry() increments tdx_guest->nr_ram_entries. I think it's > > worth > > for comments why this is safe regarding to this for-loop. > > The for-loop is to find the valid existing RAM entry (from E820 table). > It will update the RAM entry and increment

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-27 Thread Xiaoyao Li
On 5/27/2022 2:48 AM, Isaku Yamahata wrote: On Thu, May 26, 2022 at 03:33:10PM +0800, Xiaoyao Li wrote: On 5/24/2022 3:37 PM, Gerd Hoffmann wrote: I think all this can be simplified, by (1) Change the existing entry to cover the accepted ram range. (2) If there is room before the

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-27 Thread Xiaoyao Li
On 5/26/2022 3:33 PM, Xiaoyao Li wrote: On 5/24/2022 3:37 PM, Gerd Hoffmann wrote: +    if (e->address == address && e->length == length) { +    e->type = TDX_RAM_ADDED; +    } else if (e->address == address) { +    e->address += length; +    e->length -=

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-26 Thread Isaku Yamahata
On Thu, May 26, 2022 at 03:33:10PM +0800, Xiaoyao Li wrote: > On 5/24/2022 3:37 PM, Gerd Hoffmann wrote: > > I think all this can be simplified, by > >(1) Change the existing entry to cover the accepted ram range. > >(2) If there is room before the accepted ram range add a > >

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-26 Thread Xiaoyao Li
On 5/24/2022 3:37 PM, Gerd Hoffmann wrote: +static int tdx_accept_ram_range(uint64_t address, uint64_t length) +{ +TdxRamEntry *e; +int i; + +for (i = 0; i < tdx_guest->nr_ram_entries; i++) { +e = _guest->ram_entries[i]; + +if (address + length < e->address || +

Re: [RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-24 Thread Gerd Hoffmann
> +static int tdx_accept_ram_range(uint64_t address, uint64_t length) > +{ > +TdxRamEntry *e; > +int i; > + > +for (i = 0; i < tdx_guest->nr_ram_entries; i++) { > +e = _guest->ram_entries[i]; > + > +if (address + length < e->address || > +e->address +

[RFC PATCH v4 22/36] i386/tdx: Track RAM entries for TDX VM

2022-05-11 Thread Xiaoyao Li
The RAM of TDX VM can be classified into two types: - TDX_RAM_UNACCEPTED: default type of TDX memory, which needs to be accepted by TDX guest before it can be used and will be all-zeros after being accepted. - TDX_RAM_ADDED: the RAM that is ADD'ed to TD guest before running, and can