30template <
typename _Tp>
35 static_assert(std::is_pod_v<_Tp>,
"GuestAllocation types must be POD if not specialized");
80 template <
typename Tp = _Tp,
typename std::enable_if_t<std::is_array_v<Tp>>* dummy =
nullptr>
82 static_assert(
_is_array(),
"Only array types require a runtime length");
87 region_size_ =
sizeof(std::remove_all_extents_t<_Tp>) * length;
93 template <
typename... _Args,
typename Tp = _Tp,
94 typename std::enable_if_t<!std::is_array_v<Tp>>* dummy =
nullptr>
96 static_assert(!
_is_array(),
"Array types require a runtime length");
107 *
ptr_ = _Tp(std::forward<_Args>(__args)...);
122 src.region_size_ = 0;
126 ptr_ = std::move(src.ptr_);
129 src.region_size_ = 0;
133 static constexpr bool _is_array() {
return std::is_array_v<_Tp>; }
141template <
typename _Tp,
typename... _Args>
147template <
typename _Tp>
155 auto result = allocate<char[]>(str.length() + 1);
156 auto& ptr = result.ptr();
159 std::copy(str.begin(), str.end(), ptr.begin());
160 ptr[str.length()] =
'\0';
168 auto result = allocate<char16_t[]>(str.length() + 1);
169 auto& ptr = result.ptr();
172 std::copy(str.begin(), str.end(), ptr.begin());
173 ptr[str.length()] =
'\0';
178template <
typename _Tp>
180 static_assert(!std::is_array_v<_Tp>,
"Arrays of this type are not supported");
static Domain & thread_local_domain()
Get the domain for the current thread.
Base interface for a Guest.
Definition Guest.hh:35
virtual guest_ptr< void > allocate(size_t ®ion_size, bool executable=false)=0
Allocate a region of memory in the guest.
virtual void guest_free(const guest_ptr< void > &ptr, size_t region_size)=0
Free a region of memory in the guest.
Definition guest_ptr.hh:88
typename std::add_pointer_t< basic_type > pointer_type
Definition guest_ptr.hh:93
Definition GuestAllocation.hh:179
_Tp * operator->()
Definition GuestAllocation.hh:186
std::shared_ptr< _Tp > value_
Definition GuestAllocation.hh:199
uint64_t address() const
Definition GuestAllocation.hh:188
_Tp & operator*()
Definition GuestAllocation.hh:184
guest_ptr< void > ptr() const
Definition GuestAllocation.hh:190
GuestAllocationComplexBase(const GuestAllocationComplexBase &)=delete
GuestAllocationComplexBase()=default
_Tp * get()
Definition GuestAllocation.hh:185
std::optional< GuestAllocation< uint8_t[]> > allocation_
Definition GuestAllocation.hh:198
GuestAllocationComplexBase & operator=(const GuestAllocationComplexBase &)=delete
Definition GuestAllocation.hh:31
~GuestAllocation()
Definition GuestAllocation.hh:110
uint64_t address() const
Get the underlying address.
Definition GuestAllocation.hh:40
GuestAllocation(size_t length)
GuestAllocation array constructor.
Definition GuestAllocation.hh:81
guest_ptr< _Tp > release()
Release this memory from management.
Definition GuestAllocation.hh:68
GuestAllocation(const GuestAllocation &)=delete
GuestAllocation(GuestAllocation &&src) noexcept
Definition GuestAllocation.hh:119
GuestAllocation(_Args &&... __args)
Definition GuestAllocation.hh:95
GuestAllocation & operator=(const GuestAllocation &)=delete
guest_ptr< _Tp > ptr_
Definition GuestAllocation.hh:136
Guest * guest_
Definition GuestAllocation.hh:135
size_t region_size_
Definition GuestAllocation.hh:137
const guest_ptr< _Tp > & ptr() const
Get a copy of the underlying pointer.
Definition GuestAllocation.hh:57
GuestAllocation & operator=(GuestAllocation &&src) noexcept
Definition GuestAllocation.hh:124
static constexpr bool _is_array()
Definition GuestAllocation.hh:133
Type-safe guest virtual address pointer and guest_ptr template.
#define introvirt_assert(condition, msg)
Definition introvirt_assert.hh:32
GuestAllocation< _Tp > allocate(_Args &&... args)
Definition GuestAllocation.hh:142
Core IntroVirt classes.
Definition Cr0.hh:20
unique_ptr< Domain > domain
Definition vmcall_interface.cc:48