Gabe Black has uploaded this change for review. (
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
---
M src/arch/arm/aapcs64.hh
M src/arch/arm/reg_abi.hh
M src/arch/arm/semihosting.hh
M src/arch/sparc/se_workload.hh
M src/arch/x86/linux/se_workload.hh
M src/sim/proxy_ptr.hh
M src/sim/proxy_ptr.test.cc
M src/sim/syscall_abi.hh
8 files changed, 22 insertions(+), 8 deletions(-)
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/reg_abi.hh b/src/arch/arm/reg_abi.hh
index eb87eff..94dea18 100644
--- a/src/arch/arm/reg_abi.hh
+++ b/src/arch/arm/reg_abi.hh
@@ -55,6 +55,7 @@
struct Argument<ABI, Arg,
typename std::enable_if_t<
std::is_base_of<ArmISA::RegABI32, ABI>::value &&
+ std::is_integral<Arg>::value &&
ABI::template IsWide<Arg>::value>>
{
static Arg
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/arch/sparc/se_workload.hh b/src/arch/sparc/se_workload.hh
index e39261d..7303010 100644
--- a/src/arch/sparc/se_workload.hh
+++ b/src/arch/sparc/se_workload.hh
@@ -105,6 +105,7 @@
template <typename Arg>
struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
typename std::enable_if_t<
+ std::is_integral<Arg>::value &&
SparcISA::SEWorkload::SyscallABI32::IsWide<Arg>::value>>
{
using ABI = SparcISA::SEWorkload::SyscallABI32;
diff --git a/src/arch/x86/linux/se_workload.hh
b/src/arch/x86/linux/se_workload.hh
index c1cd234..cd26e04 100644
--- a/src/arch/x86/linux/se_workload.hh
+++ b/src/arch/x86/linux/se_workload.hh
@@ -93,7 +93,7 @@
template <typename Arg>
struct Argument<X86ISA::EmuLinux::SyscallABI32, Arg,
- typename std::enable_if_t<
+ typename std::enable_if_t<std::is_integral<Arg>::value &&
X86ISA::EmuLinux::SyscallABI32::IsWide<Arg>::value>>
{
using ABI = X86ISA::EmuLinux::SyscallABI32;
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 021e7b0..a60af42 100644
--- a/src/sim/syscall_abi.hh
+++ b/src/sim/syscall_abi.hh
@@ -42,18 +42,21 @@
};
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 : public std::false_type {};
template <typename T>
- struct IsWide<T> : public typename std::enable_if_t<
- std::is_integral<T>::value && sizeof(T) > sizeof(uint32_t),
- std::true_type>
+ struct IsWide<T, std::enable_if_t<(sizeof(T) > sizeof(UintPtr))>> :
+ public std::true_type
{};
// Read two registers and merge them into one value.
@@ -89,7 +92,8 @@
// arguments aren't handled generically.
template <typename ABI, typename Arg>
struct Argument<ABI, Arg,
- typename std::enable_if_t<!ABI::template IsWide<Arg>::value>>
+ typename std::enable_if_t<std::is_integral<Arg>::value &&
+ !ABI::template IsWide<Arg>::value>>
{
static Arg
get(ThreadContext *tc, typename ABI::State &state)
--
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: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
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