From 3e1702a65fb3caf50c8d09a1b383b0056a5efc82 Mon Sep 17 00:00:00 2001 From: Luca Dariz Date: Sun, 3 Apr 2022 16:59:55 +0200 Subject: add rpc_versions for vm types * vm_types.h: add new types and conversion functions * mach_types.defs: adapt vm types depending on kernel user/server * vm_info.h: adapt rpc structure to have uniformly-sized members also on 64-bit * x86_64/configfrag.c: add new option to select the user-space variant. Note that with this change the user-space interface is somehow fixed, i.e. it can't support 32-bit and 64-bit tasks at the same time. If this would be needed at some point, this change needs to be reworked. Signed-off-by: Luca Dariz Message-Id: <20220403145955.120742-3-luca@orpolo.org> --- i386/include/mach/i386/vm_types.h | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'i386') diff --git a/i386/include/mach/i386/vm_types.h b/i386/include/mach/i386/vm_types.h index f49a95a1..16aedc44 100644 --- a/i386/include/mach/i386/vm_types.h +++ b/i386/include/mach/i386/vm_types.h @@ -37,6 +37,12 @@ #ifdef __ASSEMBLER__ #else /* __ASSEMBLER__ */ +#include + +#ifdef MACH_KERNEL +#include +#endif + /* * A natural_t is the type for the native * integer type, e.g. 32 or 64 or.. whatever @@ -88,13 +94,36 @@ typedef unsigned long long rpc_phys_addr_t; * expressing the difference between two * vm_offset_t entities. */ -#ifdef __x86_64__ typedef unsigned long vm_size_t; -#else -typedef natural_t vm_size_t; -#endif typedef vm_size_t * vm_size_array_t; +/* + * rpc_types are for user/kernel interfaces. On kernel side they may differ from + * the native types, while on user space they shall be the same. + * These three types are always of the same size, so we can reuse the conversion + * functions. + */ +#if defined(MACH_KERNEL) && defined(USER32) +typedef uint32_t rpc_vm_address_t; +typedef uint32_t rpc_vm_offset_t; +typedef uint32_t rpc_vm_size_t; +static inline uint64_t convert_vm_from_user(uint32_t uaddr) +{ + return (uint64_t)uaddr; +} +static inline uint32_t convert_vm_to_user(uint64_t kaddr) +{ + assert(kaddr <= 0xFFFFFFFF); + return (uint32_t)kaddr; +} +#else /* MACH_KERNEL */ +typedef vm_offset_t rpc_vm_address_t; +typedef vm_offset_t rpc_vm_offset_t; +typedef vm_size_t rpc_vm_size_t; +#define convert_vm_to_user null_conversion +#define convert_vm_from_user null_conversion +#endif /* MACH_KERNEL */ + #endif /* __ASSEMBLER__ */ /* -- cgit v1.2.3