hv: multiarch: replace memset with sanitize_pte

for x86, when using a new page to set up page table,
sanitize to specific hpa page address is needed, however,
for other arch, sanitized to 0 is fine. To avoid duplicate memory
setting at the time of alloc_page and sanitize pte, replace
memset in alloc_page with sanitized pte operation.

Tracked-On: #8831
Signed-off-by: hangliu1 <hang1.liu@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
hangliu1
2025-10-13 17:02:11 +08:00
committed by acrnsi-robot
parent 8ba4890677
commit 1ec40cd62f
2 changed files with 3 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ struct page *alloc_page(struct page_pool *pool)
*/
panic("no dummy aviable!");
}
(void)memset(page, 0U, PAGE_SIZE);
sanitize_pte((uint64_t *)page, NULL);
return page;
}
@@ -621,7 +621,6 @@ void pgtable_add_map(uint64_t *pgtl3_page, uint64_t paddr_base, uint64_t vaddr_b
void *pgtable_create_root(const struct pgtable *table)
{
uint64_t *page = (uint64_t *)alloc_page(table->pool);
sanitize_pte(page, table);
return page;
}

View File

@@ -92,6 +92,7 @@ static inline uint64_t get_pgentry(const uint64_t *pte)
static inline void set_pgentry(uint64_t *ptep, uint64_t pte, const struct pgtable *table)
{
*ptep = pte;
if (table && table->flush_cache_pagewalk)
table->flush_cache_pagewalk(ptep);
}