Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/40496 )
Change subject: arch,sim: Add a UintPtr type to the ABI types for GuestABI.
......................................................................
arch,sim: Add a UintPtr type to the ABI types for GuestABI.
This type is primarily used to determine the size of a pointer when
using that ABI, similar to the uintptr_t type, but also less directly
to determine the "native" size of the ABI. For instance, for 32 bit ARM
ABIs, it should be defined as uint32_t since that's both the size of a
uintptr_t, and, less directly, the size of a 32 bit ARM register and
"naturally" sized types in that ABI.
This type can be used by the VPtr template to retrieve its actual value
from a simcall's parameters. In general, when accepting or returning a
pointer or address in a simcall, the VPtr template should be used so
that it's managed correctly by GuestABI. Addr will be treated as a
uint64_t allways which will be incorrect for 32 bit ABIs.
Change-Id: I3af046917387541d6faff96a21a1f1dbf7317e06
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40496
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Bobby R. Bruce <bbr...@ucdavis.edu>
---
M src/arch/arm/aapcs64.hh
M src/arch/arm/semihosting.hh
M src/sim/proxy_ptr.hh
M src/sim/proxy_ptr.test.cc
M src/sim/syscall_abi.hh
5 files changed, 17 insertions(+), 5 deletions(-)
Approvals:
Bobby R. Bruce: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/aapcs64.hh b/src/arch/arm/aapcs64.hh
index 8a5e437..fb7b8f8 100644
--- a/src/arch/arm/aapcs64.hh
+++ b/src/arch/arm/aapcs64.hh
@@ -44,6 +44,8 @@
struct Aapcs64
{
+ using UintPtr = uint64_t;
+
struct State
{
int ngrn=0; // Next general purpose register number.
diff --git a/src/arch/arm/semihosting.hh b/src/arch/arm/semihosting.hh
index 74697f4..7566887 100644
--- a/src/arch/arm/semihosting.hh
+++ b/src/arch/arm/semihosting.hh
@@ -133,6 +133,8 @@
struct Abi64 : public AbiBase
{
+ using UintPtr = uint64_t;
+
class State : public StateBase<uint64_t>
{
public:
@@ -145,6 +147,8 @@
struct Abi32 : public AbiBase
{
+ using UintPtr = uint32_t;
+
class State : public StateBase<uint64_t>
{
public:
diff --git a/src/sim/proxy_ptr.hh b/src/sim/proxy_ptr.hh
index 02263ba..968c156 100644
--- a/src/sim/proxy_ptr.hh
+++ b/src/sim/proxy_ptr.hh
@@ -338,7 +338,8 @@
static ProxyPtr<T, Proxy>
get(ThreadContext *tc, typename ABI::State &state)
{
- return ProxyPtr<T, Proxy>(Argument<ABI, Addr>::get(tc, state), tc);
+ return ProxyPtr<T, Proxy>(
+ Argument<ABI, typename ABI::UintPtr>::get(tc, state), tc);
}
};
@@ -349,7 +350,7 @@
get(ThreadContext *tc, typename ABI::State &state)
{
return ConstProxyPtr<T, Proxy>(
- Argument<ABI, Addr>::get(tc, state), tc);
+ Argument<ABI, typename ABI::UintPtr>::get(tc, state), tc);
}
};
diff --git a/src/sim/proxy_ptr.test.cc b/src/sim/proxy_ptr.test.cc
index b9f46e6..de0194d 100644
--- a/src/sim/proxy_ptr.test.cc
+++ b/src/sim/proxy_ptr.test.cc
@@ -465,6 +465,7 @@
struct TestABI
{
+ using UintPtr = uint64_t;
using State = int;
};
diff --git a/src/sim/syscall_abi.hh b/src/sim/syscall_abi.hh
index 984f0e0..9d55202 100644
--- a/src/sim/syscall_abi.hh
+++ b/src/sim/syscall_abi.hh
@@ -54,10 +54,14 @@
};
struct GenericSyscallABI64 : public GenericSyscallABI
-{};
+{
+ using UintPtr = uint64_t;
+};
struct GenericSyscallABI32 : public GenericSyscallABI
{
+ using UintPtr = uint32_t;
+
// Is this argument too big for a single register?
template <typename T, typename Enabled=void>
struct IsWide;
@@ -65,7 +69,7 @@
template <typename T>
struct IsWide<T, typename std::enable_if_t<
std::is_integral<T>::value &&
- (sizeof(T) < sizeof(uint64_t) ||
+ (sizeof(T) <= sizeof(UintPtr) ||
GuestABI::IsConforming<T>::value)>>
{
static const bool value = false;
@@ -74,7 +78,7 @@
template <typename T>
struct IsWide<T, typename std::enable_if_t<
std::is_integral<T>::value &&
- sizeof(T) == sizeof(uint64_t) &&
+ (sizeof(T) > sizeof(UintPtr)) &&
!GuestABI::IsConforming<T>::value>>
{
static const bool value = true;
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/40496
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I3af046917387541d6faff96a21a1f1dbf7317e06
Gerrit-Change-Number: 40496
Gerrit-PatchSet: 4
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jonathan Bohren <jonathan.boh...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s