summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Dariz <luca@orpolo.org>2022-04-03 16:59:55 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-27 22:19:18 +0200
commit3e1702a65fb3caf50c8d09a1b383b0056a5efc82 (patch)
treea4f687afd3a455bd664daeddf947492fabd16745
parente2f1d502a5a5ab6a8885cc518ed254c79f7ab27c (diff)
add rpc_versions for vm typesv1.8+git20220827
* 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 <luca@orpolo.org> Message-Id: <20220403145955.120742-3-luca@orpolo.org>
-rw-r--r--i386/include/mach/i386/vm_types.h37
-rw-r--r--include/mach/mach_types.defs31
-rw-r--r--include/mach_debug/vm_info.h24
-rw-r--r--x86_64/configfrag.ac12
4 files changed, 84 insertions, 20 deletions
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 <stdint.h>
+
+#ifdef MACH_KERNEL
+#include <kern/assert.h>
+#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__ */
/*
diff --git a/include/mach/mach_types.defs b/include/mach/mach_types.defs
index a0e9241c..a271d597 100644
--- a/include/mach/mach_types.defs
+++ b/include/mach/mach_types.defs
@@ -110,9 +110,34 @@ type ipc_space_t = mach_port_t
#endif /* KERNEL_SERVER */
;
-type vm_address_t = natural_t;
-type vm_offset_t = natural_t;
-type vm_size_t = natural_t;
+#if defined(KERNEL_SERVER) && defined(USER32)
+type rpc_vm_size_t = uint32_t;
+#else /* KERNEL_SERVER and USER32 */
+#if defined(__x86_64__)
+type rpc_vm_size_t = uint64_t;
+#else /* __x86_64__ */
+type rpc_vm_size_t = uint32_t;
+#endif /* __x86_64__ */
+#endif /* KERNEL_SERVER and USER32 */
+
+type vm_address_t = rpc_vm_size_t
+#if defined(KERNEL_SERVER) || defined(KERNEL_USER)
+ intran: vm_address_t convert_vm_from_user(rpc_vm_address_t)
+ outtran: rpc_vm_address_t convert_vm_to_user(vm_address_t)
+#endif
+ ;
+type vm_offset_t = rpc_vm_size_t
+#if defined(KERNEL_SERVER) || defined(KERNEL_USER)
+ intran: vm_offset_t convert_vm_from_user(rpc_vm_offset_t)
+ outtran: rpc_vm_offset_t convert_vm_to_user(vm_offset_t)
+#endif
+ ;
+type vm_size_t = rpc_vm_size_t
+#if defined(KERNEL_SERVER) || defined(KERNEL_USER)
+ intran: vm_size_t convert_vm_from_user(rpc_vm_size_t)
+ outtran: rpc_vm_size_t convert_vm_to_user(vm_size_t)
+#endif
+;
type vm_prot_t = int;
type vm_inherit_t = int;
type vm_statistics_data_t = struct[13] of integer_t;
diff --git a/include/mach_debug/vm_info.h b/include/mach_debug/vm_info.h
index b50fb92d..e68bb1d5 100644
--- a/include/mach_debug/vm_info.h
+++ b/include/mach_debug/vm_info.h
@@ -46,8 +46,8 @@
*/
typedef struct vm_region_info {
- vm_offset_t vri_start; /* start of region */
- vm_offset_t vri_end; /* end of region */
+ rpc_vm_offset_t vri_start; /* start of region */
+ rpc_vm_offset_t vri_end; /* end of region */
/*vm_prot_t*/natural_t vri_protection; /* protection code */
/*vm_prot_t*/natural_t vri_max_protection; /* maximum protection */
@@ -55,8 +55,8 @@ typedef struct vm_region_info {
natural_t vri_wired_count; /* number of times wired */
natural_t vri_user_wired_count; /* number of times user has wired */
- vm_offset_t vri_object; /* the mapped object */
- vm_offset_t vri_offset; /* offset into object */
+ rpc_vm_offset_t vri_object; /* the mapped object */
+ rpc_vm_offset_t vri_offset; /* offset into object */
/*boolean_t*/integer_t vri_needs_copy; /* does object need to be copied? */
natural_t vri_sharing; /* share map references */
} vm_region_info_t;
@@ -77,19 +77,19 @@ typedef natural_t vm_object_info_state_t;
#define VOI_STATE_LOCK_RESTART 0x00000100
typedef struct vm_object_info {
- vm_offset_t voi_object; /* this object */
- vm_size_t voi_pagesize; /* object's page size */
- vm_size_t voi_size; /* object size (valid if internal) */
+ rpc_vm_offset_t voi_object; /* this object */
+ rpc_vm_size_t voi_pagesize; /* object's page size */
+ rpc_vm_size_t voi_size; /* object size (valid if internal) */
natural_t voi_ref_count; /* number of references */
natural_t voi_resident_page_count; /* number of resident pages */
natural_t voi_absent_count; /* number requested but not filled */
- vm_offset_t voi_copy; /* copy object */
- vm_offset_t voi_shadow; /* shadow object */
- vm_offset_t voi_shadow_offset; /* offset into shadow object */
- vm_offset_t voi_paging_offset; /* offset into memory object */
+ rpc_vm_offset_t voi_copy; /* copy object */
+ rpc_vm_offset_t voi_shadow; /* shadow object */
+ rpc_vm_offset_t voi_shadow_offset; /* offset into shadow object */
+ rpc_vm_offset_t voi_paging_offset; /* offset into memory object */
/*memory_object_copy_strategy_t*/integer_t voi_copy_strategy;
/* how to handle data copy */
- vm_offset_t voi_last_alloc; /* offset of last allocation */
+ rpc_vm_offset_t voi_last_alloc; /* offset of last allocation */
natural_t voi_paging_in_progress; /* paging references */
vm_object_info_state_t voi_state; /* random state bits */
} vm_object_info_t;
diff --git a/x86_64/configfrag.ac b/x86_64/configfrag.ac
index e455d31b..71f8d8c1 100644
--- a/x86_64/configfrag.ac
+++ b/x86_64/configfrag.ac
@@ -27,12 +27,22 @@ dnl USE OF THIS SOFTWARE.
# Determines the size of the CPU cache line.
AC_DEFINE([CPU_L1_SHIFT], [6], [CPU_L1_SHIFT])
+ AC_ARG_ENABLE([user32],
+ AS_HELP_STRING([--disable-user32], [disable 32-bit user on 64-bit kernel]))
+ [if [ x"$enable_user32" != xno ]; then]
+ AC_DEFINE([USER32], [], [enable 32-bit user on 64-bit kernel])
+ AM_CONDITIONAL([enable_user32], [true])
+ [else]
+ AM_CONDITIONAL([enable_user32], [false])
+ [fi]
+
[# Does the architecture provide machine-specific interfaces?
mach_machine_routines=1
enable_pae=yes;;
*)]
- AM_CONDITIONAL([HOST_x86_64], [false])[;;
+ AM_CONDITIONAL([HOST_x86_64], [false])
+ AM_CONDITIONAL([enable_user32], [true])[;;
esac
case $host_platform in