Linux virtualization list
 help / color / mirror / Atom feed
From: Kiryl Shutsemau <kas@kernel.org>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>
Cc: marcandre.lureau@redhat.com, david@kernel.org,
	 rick.p.edgecombe@intel.com, prsampat@amd.com,
	pbonzini@redhat.com, mst@redhat.com,  peterx@redhat.com,
	chenyi.qiang@intel.com, elena.reshetova@intel.com,
	 michael.roth@amd.com, ackerleytng@google.com,
	linux-kernel@vger.kernel.org,  linux-coco@lists.linux.dev,
	virtualization@lists.linux.dev, x86@kernel.org,
	 yilun.xu@intel.com, xiaoyao.li@intel.com, chao.p.peng@intel.com
Subject: Re: [RFCv2 PATCH 2/6] efi/unaccepted: Set unaccepted bits for all hotplug memory
Date: Wed, 24 Jun 2026 13:29:17 +0100	[thread overview]
Message-ID: <ajvNXyYwb7FXAJhP@thinkstation> (raw)
In-Reply-To: <20260623101739.79695-3-zhenzhong.duan@intel.com>

On Tue, Jun 23, 2026 at 06:17:33AM -0400, Zhenzhong Duan wrote:
> In coco guests, hotpluggable memory ranges are initially unaccepted.
> While a previous change expanded the unaccepted memory bitmap boundaries
> to include these hotplug spaces, the actual bits inside the bitmap are
> not yet marked as unaccepted.
> 
> Walks SRAT a second time after the bitmap is allocated and sets the bits
> corresponding to hotpluggable ranges.
> 
> This ensures the bitmap state accurately reflects all static and hotplug
> memory ranges before booting kernel.
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>  .../firmware/efi/libstub/unaccepted_memory.c   | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/firmware/efi/libstub/unaccepted_memory.c b/drivers/firmware/efi/libstub/unaccepted_memory.c
> index bfbb78bd7b8a..01bed8e751ca 100644
> --- a/drivers/firmware/efi/libstub/unaccepted_memory.c
> +++ b/drivers/firmware/efi/libstub/unaccepted_memory.c
> @@ -92,6 +92,23 @@ static void update_mem_boundaries(struct acpi_srat_mem_affinity *mem, struct sra
>  		*(ctx->mem_end) = range_end;
>  }
>  
> +static void mark_hotplug_memory_unaccepted(struct acpi_srat_mem_affinity *mem,
> +					   struct srat_parse_ctx *ctx)
> +{
> +	u64 unit_size = unaccepted_table->unit_size;
> +	u64 start, end;
> +
> +	start = round_up(mem->base_address, unit_size);
> +	end = round_down(mem->base_address + mem->length, unit_size);

We can get here with start > end if srat range is less then unit_size.

> +
> +	/* Translate to offsets from the beginning of the bitmap */
> +	start -= unaccepted_table->phys_base;
> +	end -= unaccepted_table->phys_base;
> +
> +	bitmap_set(unaccepted_table->bitmap,
> +		   start / unit_size, (end - start) / unit_size);
> +}
> +
>  efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc,
>  					struct efi_boot_memmap *map)
>  {
> @@ -169,6 +186,7 @@ efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc,
>  	unaccepted_table->phys_base = unaccepted_start;
>  	unaccepted_table->size = bitmap_size;
>  	memset(unaccepted_table->bitmap, 0, bitmap_size);
> +	parse_acpi_srat_regions(mark_hotplug_memory_unaccepted, &ctx);
>  
>  	status = efi_bs_call(install_configuration_table,
>  			     &unaccepted_table_guid, unaccepted_table);
> -- 
> 2.52.0
> 

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

  reply	other threads:[~2026-06-24 12:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-23 10:17 [RFCv2 PATCH 0/6] Support memory hotplug/unplug for TDX CoCo guests Zhenzhong Duan
2026-06-23 10:17 ` [RFCv2 PATCH 1/6] efi/unaccepted: Support hotplug memory in unaccepted bitmap via SRAT Zhenzhong Duan
2026-06-24 12:25   ` Kiryl Shutsemau
2026-06-24 14:23     ` Pratik R. Sampat
2026-06-23 10:17 ` [RFCv2 PATCH 2/6] efi/unaccepted: Set unaccepted bits for all hotplug memory Zhenzhong Duan
2026-06-24 12:29   ` Kiryl Shutsemau [this message]
2026-06-23 10:17 ` [RFCv2 PATCH 3/6] efi/unaccepted: Create plugged bitmap to support hotplug memory in coco guest Zhenzhong Duan
2026-06-23 10:17 ` [RFCv2 PATCH 4/6] x86/tdx: Implement arch_unaccept_memory() Zhenzhong Duan
2026-06-23 10:17 ` [RFCv2 PATCH 5/6] mm/memory_hotplug: Support ACPI hotplug/unplug for coco guest Zhenzhong Duan
2026-06-24 12:33   ` Kiryl Shutsemau
2026-06-23 10:17 ` [RFCv2 PATCH 6/6] virtio-mem: Support memory " Zhenzhong Duan

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=ajvNXyYwb7FXAJhP@thinkstation \
    --to=kas@kernel.org \
    --cc=ackerleytng@google.com \
    --cc=chao.p.peng@intel.com \
    --cc=chenyi.qiang@intel.com \
    --cc=david@kernel.org \
    --cc=elena.reshetova@intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=michael.roth@amd.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=prsampat@amd.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=virtualization@lists.linux.dev \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    --cc=yilun.xu@intel.com \
    --cc=zhenzhong.duan@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