[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 07/70] physmem: Relax the alignment check of host_startaddr in
From: |
Xiaoyao Li |
Subject: |
[PATCH v3 07/70] physmem: Relax the alignment check of host_startaddr in ram_block_discard_range() |
Date: |
Wed, 15 Nov 2023 02:14:16 -0500 |
Commit d3a5038c461 ("exec: ram_block_discard_range") introduced
ram_block_discard_range() which grabs some code from
ram_discard_range(). However, during code movement, it changed alignment
check of host_startaddr from qemu_host_page_size to rb->page_size.
When ramblock is back'ed by hugepage, it requires the startaddr to be
huge page size aligned, which is a overkill. e.g., TDX's private-shared
page conversion is done at 4KB granularity. Shared page is discarded
when it gets converts to private and when shared page back'ed by
hugepage it is going to fail on this check.
So change to alignment check back to qemu_host_page_size.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
Changes in v3:
- Newly added in v3;
---
system/physmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/system/physmem.c b/system/physmem.c
index c56b17e44df6..8a4e42c7cf60 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3532,7 +3532,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t start,
size_t length)
uint8_t *host_startaddr = rb->host + start;
- if (!QEMU_PTR_IS_ALIGNED(host_startaddr, rb->page_size)) {
+ if (!QEMU_PTR_IS_ALIGNED(host_startaddr, qemu_host_page_size)) {
error_report("ram_block_discard_range: Unaligned start address: %p",
host_startaddr);
goto err;
--
2.34.1
[PATCH v3 05/70] kvm: Enable KVM_SET_USER_MEMORY_REGION2 for memslot, Xiaoyao Li, 2023/11/15
[PATCH v3 07/70] physmem: Relax the alignment check of host_startaddr in ram_block_discard_range(),
Xiaoyao Li <=
[PATCH v3 09/70] physmem: Introduce ram_block_convert_range() for page conversion, Xiaoyao Li, 2023/11/15
[PATCH v3 06/70] kvm: Introduce support for memory_attributes, Xiaoyao Li, 2023/11/15
[PATCH v3 08/70] physmem: replace function name with __func__ in ram_block_discard_range(), Xiaoyao Li, 2023/11/15