@copyright Copyright (C) 2020 Assured Information Security, Inc. @copyright Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Sof
(
gs: &crate::GsT,
tls: &mut crate::TlsT,
sys: &mut syscall::BfSyscallT,
intrinsic: &crate::IntrinsicT,
vp_pool: &mut crate::VpPoolT,
vs_pool: &mut crate::VsPoolT,
ppid: bs
| 39 | /// and friends otherwise |
| 40 | /// |
| 41 | pub fn dispatch_bootstrap( |
| 42 | gs: &crate::GsT, |
| 43 | tls: &mut crate::TlsT, |
| 44 | sys: &mut syscall::BfSyscallT, |
| 45 | intrinsic: &crate::IntrinsicT, |
| 46 | vp_pool: &mut crate::VpPoolT, |
| 47 | vs_pool: &mut crate::VsPoolT, |
| 48 | ppid: bsl::SafeU16, |
| 49 | ) -> bsl::ErrcType { |
| 50 | bsl::expects(ppid.is_valid_and_checked()); |
| 51 | bsl::expects(ppid != syscall::BF_INVALID_ID); |
| 52 | |
| 53 | let ret = crate::tls_initialize(tls, sys, intrinsic); |
| 54 | if !ret { |
| 55 | print_v!("{}", bsl::here()); |
| 56 | return bsl::errc_failure; |
| 57 | } |
| 58 | |
| 59 | // NOTE: |
| 60 | // - In order to execcute bf_vs_op_run, which is what executes |
| 61 | // the hypervisor, we must have a VM, VP and VS. |
| 62 | // - The root VM is already created for us, so we don't need to |
| 63 | // create this ourselves. You only need to create VM's if you |
| 64 | // plan to add guest support with your extensions. |
| 65 | // |
| 66 | |
| 67 | let vmid = syscall::BF_ROOT_VMID; |
| 68 | |
| 69 | // NOTE: |
| 70 | // - The VP in this simple example does nothing, but we still need |
| 71 | // to create one. The VP is used when you have more than one VS |
| 72 | // per VP (e.g., if you are implementing HyperV's VSM, or nested |
| 73 | // virtualization support). Otherwise, you will always have one |
| 74 | // VS for each VP, and they will appear as the same thing. |
| 75 | // - The VS is what stores the state associated with the VS. It |
| 76 | // is the thing that does most of the work, including storing |
| 77 | // the VMCS/VMCB and other CPU register state that is needed. |
| 78 | // |
| 79 | |
| 80 | let vpid = vp_pool.allocate(gs, tls, sys, intrinsic, vmid); |
| 81 | if vpid.is_invalid() { |
| 82 | print_v!("{}", bsl::here()); |
| 83 | return bsl::errc_failure; |
| 84 | } |
| 85 | |
| 86 | let vsid = vs_pool.allocate(gs, tls, sys, intrinsic, vpid, ppid); |
| 87 | if vsid.is_invalid() { |
| 88 | print_v!("{}", bsl::here()); |
| 89 | return bsl::errc_failure; |
| 90 | } |
| 91 | |
| 92 | // NOTE: |
| 93 | // - Run the newly created VP on behalf of the root VM using the |
| 94 | // newly created and initialized VS. Note that this version of |
| 95 | // the run function should only be used when starting the |
| 96 | // hypervisor, or switching the VM, VP or VS as it is slow. |
| 97 | // |
| 98 |
no test coverage detected