mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 02:08:04 +00:00
hv: remove hardcoding of SW SRAM HPA base
Physical address to SW SRAM region maybe different on different platforms, this hardcoded address may result in address mismatch for SW SRAM operations. This patch removes above hardcoded address and uses the physical address parsed from native RTCT. Tracked-On: #5649 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Fei Li <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -174,48 +174,46 @@ void ept_flush_leaf_page(uint64_t *pge, uint64_t size)
|
||||
uint64_t flush_base_hpa = INVALID_HPA, flush_end_hpa;
|
||||
void *hva = NULL;
|
||||
uint64_t flush_size = size;
|
||||
uint64_t sw_sram_bottom, sw_sram_top;
|
||||
|
||||
if ((*pge & EPT_MT_MASK) != EPT_UNCACHED) {
|
||||
flush_base_hpa = (*pge & (~(size - 1UL)));
|
||||
flush_end_hpa = flush_base_hpa + size;
|
||||
|
||||
/* When Software SRAM is not initialized, both software_sram_area_bottom
|
||||
* and software_sram_area_top is 0,
|
||||
sw_sram_bottom = get_software_sram_base();
|
||||
sw_sram_top = sw_sram_bottom + get_software_sram_size();
|
||||
/* When Software SRAM is not initialized, both sw_sram_bottom and sw_sram_top is 0,
|
||||
* so the below if/else will have no use
|
||||
*/
|
||||
if (flush_base_hpa < software_sram_area_bottom) {
|
||||
/* Only flush [flush_base_hpa, software_sram_area_bottom)
|
||||
* and [software_sram_area_top, flush_base_hpa),
|
||||
* ignore [software_sram_area_bottom, software_sram_area_top)
|
||||
if (flush_base_hpa < sw_sram_bottom) {
|
||||
/* Only flush [flush_base_hpa, sw_sram_bottom) and [sw_sram_top, flush_base_hpa),
|
||||
* ignore [sw_sram_bottom, sw_sram_top)
|
||||
*/
|
||||
if (flush_end_hpa > software_sram_area_top) {
|
||||
/* Only flush [flush_base_hpa, software_sram_area_bottom)
|
||||
* and [software_sram_area_top, flush_base_hpa),
|
||||
* ignore [software_sram_area_bottom, software_sram_area_top)
|
||||
if (flush_end_hpa > sw_sram_top) {
|
||||
/* Only flush [flush_base_hpa, sw_sram_bottom) and [sw_sram_top, flush_base_hpa),
|
||||
* ignore [sw_sram_bottom, sw_sram_top)
|
||||
*/
|
||||
flush_size = software_sram_area_bottom - flush_base_hpa;
|
||||
flush_size = sw_sram_bottom - flush_base_hpa;
|
||||
hva = hpa2hva(flush_base_hpa);
|
||||
stac();
|
||||
flush_address_space(hva, flush_size);
|
||||
clac();
|
||||
|
||||
flush_size = flush_end_hpa - software_sram_area_top;
|
||||
flush_base_hpa = software_sram_area_top;
|
||||
} else if (flush_end_hpa > software_sram_area_bottom) {
|
||||
/* Only flush [flush_base_hpa, software_sram_area_bottom) and
|
||||
* ignore [software_sram_area_bottom, flush_end_hpa)
|
||||
flush_size = flush_end_hpa - sw_sram_top;
|
||||
flush_base_hpa = sw_sram_top;
|
||||
} else if (flush_end_hpa > sw_sram_bottom) {
|
||||
/* Only flush [flush_base_hpa, sw_sram_bottom)
|
||||
* and ignore [sw_sram_bottom, flush_end_hpa)
|
||||
*/
|
||||
flush_size = software_sram_area_bottom - flush_base_hpa;
|
||||
flush_size = sw_sram_bottom - flush_base_hpa;
|
||||
}
|
||||
} else if (flush_base_hpa < software_sram_area_top) {
|
||||
if (flush_end_hpa <= software_sram_area_top) {
|
||||
} else if (flush_base_hpa < sw_sram_top) {
|
||||
if (flush_end_hpa <= sw_sram_top) {
|
||||
flush_size = 0UL;
|
||||
} else {
|
||||
/* Only flush [software_sram_area_top, flush_end_hpa)
|
||||
* and ignore [flush_base_hpa, software_sram_area_top)
|
||||
*/
|
||||
flush_base_hpa = software_sram_area_top;
|
||||
flush_size = flush_end_hpa - software_sram_area_top;
|
||||
/* Only flush [sw_sram_top, flush_end_hpa) and ignore [flush_base_hpa, sw_sram_top) */
|
||||
flush_base_hpa = sw_sram_top;
|
||||
flush_size = flush_end_hpa - sw_sram_top;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -235,8 +235,8 @@ static void prepare_prelaunched_vm_memmap(struct acrn_vm *vm, const struct acrn_
|
||||
((vm_config->guest_flags & GUEST_FLAG_RT) != 0U)){
|
||||
/* pass through Software SRAM to pre-RTVM */
|
||||
ept_add_mr(vm, (uint64_t *)vm->arch_vm.nworld_eptp,
|
||||
SOFTWARE_SRAM_BASE_HPA, SOFTWARE_SRAM_BASE_GPA,
|
||||
SOFTWARE_SRAM_MAX_SIZE, EPT_RWX | EPT_WB);
|
||||
get_software_sram_base(), SOFTWARE_SRAM_BASE_GPA,
|
||||
get_software_sram_size(), EPT_RWX | EPT_WB);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user