MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / get_phys

Function get_phys

kernel/src/dispatch_syscall_helpers.hpp:1010–1047  ·  view source on GitHub ↗

<!-- description --> @brief Given an input register, returns a physical address if the provided register contains a valid physical address. Otherwise, this function returns bsl::safe_umx::failure(). <!-- inputs/outputs --> @param reg the register to get the physical address from. @return Given an input register, returns a physical address if the provided register contains a valid physical address

Source from the content-addressed store, hash-verified

1008 /// this function returns bsl::safe_umx::failure().
1009 ///
1010 [[nodiscard]] constexpr auto
1011 // NOLINTNEXTLINE(bsl-non-safe-integral-types-are-forbidden)
1012 get_phys(bsl::uint64 const reg) noexcept -> bsl::safe_umx
1013 {
1014 auto const phys{bsl::to_umx(reg)};
1015 if (bsl::unlikely(phys.is_zero())) {
1016 bsl::error() << "the physical address " // --
1017 << bsl::hex(phys) // --
1018 << " is a NULL address and cannot be used" // --
1019 << bsl::endl // --
1020 << bsl::here(); // --
1021
1022 return bsl::safe_umx::failure();
1023 }
1024
1025 if (bsl::unlikely(phys >= HYPERVISOR_EXT_DIRECT_MAP_SIZE)) {
1026 bsl::error() << "the physical address " // --
1027 << bsl::hex(phys) // --
1028 << " is out of range and cannot be used" // --
1029 << bsl::endl // --
1030 << bsl::here(); // --
1031
1032 return bsl::safe_umx::failure();
1033 }
1034
1035 bool const aligned{syscall::bf_is_page_aligned(phys)};
1036 if (bsl::unlikely(!aligned)) {
1037 bsl::error() << "the physical address " // --
1038 << bsl::hex(phys) // --
1039 << " is not page aligned and cannot be used" // --
1040 << bsl::endl // --
1041 << bsl::here(); // --
1042
1043 return bsl::safe_umx::failure();
1044 }
1045
1046 return phys;
1047 }
1048
1049 /// <!-- description -->
1050 /// @brief Given an input register, returns a virtual address if the

Callers 1

Calls 1

bf_is_page_alignedFunction · 0.50

Tested by

no test coverage detected