Skip to content

Commit f81585e

Browse files
yliu80acrnsi
authored andcommitted
HV: Add flush_address_space API.
flush_address_space is used to flush address space by clflushopt instruction. Signed-off-by: Jack Ren <jack.ren@intel.com> Signed-off-by: Yuan Liu <yuan1.liu@intel.com> Reviewed-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 6fd397e commit f81585e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

hypervisor/arch/x86/mmu.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,16 @@ void init_paging(void)
294294
/* set ptep in sanitized_page point to itself */
295295
sanitize_pte((uint64_t *)sanitized_page);
296296
}
297+
298+
/*
299+
* @pre: addr != NULL && size != 0
300+
*/
301+
void flush_address_space(void *addr, uint64_t size)
302+
{
303+
uint64_t n = 0UL;
304+
305+
while (n < size) {
306+
clflushopt((char *)addr + n);
307+
n += CACHE_LINE_SIZE;
308+
}
309+
}

hypervisor/include/arch/x86/mmu.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,18 @@ void flush_vpid_single(uint16_t vpid);
150150
* @return None
151151
*/
152152
void flush_vpid_global(void);
153+
154+
/**
155+
* @brief Flush address space
156+
*
157+
* @param[in] addr the specified virtual address
158+
*
159+
* @param[in] size the specified size to flush
160+
*
161+
* @return None
162+
*/
163+
void flush_address_space(void *addr, uint64_t size);
164+
153165
/**
154166
* @brief Guest-physical mappings and combined mappings invalidation
155167
*

0 commit comments

Comments
 (0)