-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jose Martins <[email protected]> Signed-off-by: Jose Martins <[email protected]>
- Loading branch information
Showing
7 changed files
with
156 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) Bao Project and Contributors. All rights reserved. | ||
*/ | ||
|
||
#ifndef VIMSIC_H | ||
#define VIMSIC_H | ||
|
||
#include <bao.h> | ||
|
||
/** | ||
* @brief Maps the guest IMSIC addresses into the physical IMSIC adresses | ||
* | ||
* Guest's VCPUs assume no indexation order, e.g., VCPU 0 can map to CPU 2. This mapping | ||
* occurs at run-time (during bao initialization), therefore, also the IMSIC mapping needs to | ||
* be done at initialization time. | ||
* The vimsic_init function needs to be executed by every VM's virtual CPU. Then, it will | ||
* calculate the physical IMSIC address based on the physical CPU into which the VCPU is | ||
* mapped. Finally, it adds a new entry in the MMU. | ||
* | ||
* @param vm Virtual Machine | ||
* @param vm_irqc_dscrp Virtual Machine Description | ||
*/ | ||
void vimsic_init(struct vm* vm, const union vm_irqc_dscrp* vm_irqc_dscrp); | ||
|
||
#endif // VIMSIC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) Bao Project and Contributors. All rights reserved. | ||
*/ | ||
|
||
#include <vm.h> | ||
#include <arch/platform.h> | ||
#include <mem.h> | ||
#include <imsic.h> | ||
|
||
/** We only support 1 guest per hart at the moment */ | ||
#define VS_FILE_IDX 1 | ||
|
||
void vimsic_init(struct vm* vm, const union vm_irqc_dscrp* vm_irqc_dscrp) | ||
{ | ||
struct vcpu* vcpu = cpu()->vcpu; | ||
cpuid_t pcpu_id = vcpu->phys_id; | ||
vcpuid_t vcpu_id = vcpu->id; | ||
paddr_t imsic_paddr; | ||
vaddr_t imsic_vaddr; | ||
|
||
imsic_vaddr = vm_irqc_dscrp->aia.imsic.base + (PAGE_SIZE * vcpu_id); | ||
|
||
imsic_paddr = platform.arch.irqc.aia.imsic.base + | ||
(PAGE_SIZE * ((IMSIC_NUM_FILES * pcpu_id) + VS_FILE_IDX)); | ||
|
||
if (imsic_vaddr != INVALID_VA) { | ||
mem_alloc_map_dev(&vm->as, SEC_VM_ANY, imsic_vaddr, imsic_paddr, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters