summaryrefslogtreecommitdiff
path: root/lexxer.l
diff options
context:
space:
mode:
authorLuca Dariz <luca@orpolo.org>2022-04-03 17:00:19 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-27 22:26:59 +0200
commit01bfa1fc30bd5715918c44a1b226d43c9491a0ae (patch)
tree44aa573d98583e29bb2d53fde0453e4d61a4b246 /lexxer.l
parent2ad84d9d271c4e323b065815c05d6c7eaaeb7817 (diff)
add separate port_size and mach_port_name_size definitions
* cpu.sym: retrieve size of vm_offset_t and mach_port_name_t from gnumach headers at compile type. * global.{c,h}: add port size as a variable and initialize it to the port name size. * lexxer.l: apply port or port name size to the corresponding types, instead of using the word size. * parser.y: update port size if we're generating for kernel-space (server or client). Also re-initialize default port types to account for this change. * type.c: use port size instead of word size in default port types and runtime checks. There are many assumptions about mach_port_t: - on kernel side, its size is the same as a pointer. This allows to replace the port name with the address of the corresponding data structure during copyin in mach_msg() - in mig, this is also the "word size", which is derived from gnumach headers as the size of integer_t - its size is also the same as natural_t, so it's possible to model structures like mach_port_status_t as an array of integer_t in mig. This is convenient since arrays and structures can't have mixed types. - its size is always the same as the port name size This patch does not change the current behaviour on 32-bit kernels, but allows for some of these assumptions to be broken on 64-bit kernels. This is needed to have 32-bit port names on 64-bit kernels and be able to support a 32-bit userspace. It still leaves the choice for a 64-bit userspace, if all integer_t and natural_t are to be extended to 64 bit. However keeping 32-bit port names seems to be the right thing, based on previous discussions [1], even for a 64-bit kernel. The only assumption kept is that in kernel-space ports are always the size of a pointer, as they refer to a data structure and not to a specific port name. To ensure this is true for various user/kernel combinations, we dynamically change the port size if we're generating code for kernel-space server or clients, and keep the size of a port the same of a port name for user-space servers and clients. [1] https://lists.gnu.org/archive/html/bug-hurd/2012-04/msg00000.html Signed-off-by: Luca Dariz <luca@orpolo.org> Message-Id: <20220403150020.120799-2-luca@orpolo.org>
Diffstat (limited to 'lexxer.l')
-rw-r--r--lexxer.l24
1 files changed, 12 insertions, 12 deletions
diff --git a/lexxer.l b/lexxer.l
index 48dda4a..71f43b2 100644
--- a/lexxer.l
+++ b/lexxer.l
@@ -160,7 +160,7 @@ static void doSharp(const char *body); /* process body of # directives */
<Normal>(?i:countinout) FRETURN(flCountInOut);
<Normal>(?i:retcode) FRETURN(flNone);
-<Normal>(?i:polymorphic) TRETURN(MACH_MSG_TYPE_POLYMORPHIC,word_size_in_bits);
+<Normal>(?i:polymorphic) TRETURN(MACH_MSG_TYPE_POLYMORPHIC,port_size_in_bits);
<Normal>"MACH_MSG_TYPE_UNSTRUCTURED" TRETURN(MACH_MSG_TYPE_UNSTRUCTURED,0);
<Normal>"MACH_MSG_TYPE_BIT" TRETURN(MACH_MSG_TYPE_BIT,1);
@@ -175,17 +175,17 @@ static void doSharp(const char *body); /* process body of # directives */
<Normal>"MACH_MSG_TYPE_STRING" TRETURN(MACH_MSG_TYPE_STRING,0);
<Normal>"MACH_MSG_TYPE_STRING_C" TRETURN(MACH_MSG_TYPE_STRING_C,0);
-<Normal>"MACH_MSG_TYPE_MOVE_RECEIVE" TPRETURN(MACH_MSG_TYPE_MOVE_RECEIVE,MACH_MSG_TYPE_PORT_RECEIVE,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_COPY_SEND" TPRETURN(MACH_MSG_TYPE_COPY_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_MAKE_SEND" TPRETURN(MACH_MSG_TYPE_MAKE_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_MOVE_SEND" TPRETURN(MACH_MSG_TYPE_MOVE_SEND,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_MAKE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MAKE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_MOVE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MOVE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits);
-
-<Normal>"MACH_MSG_TYPE_PORT_NAME" TRETURN(MACH_MSG_TYPE_PORT_NAME,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_PORT_RECEIVE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_RECEIVE,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_PORT_SEND" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND,word_size_in_bits);
-<Normal>"MACH_MSG_TYPE_PORT_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND_ONCE,word_size_in_bits);
+<Normal>"MACH_MSG_TYPE_MOVE_RECEIVE" TPRETURN(MACH_MSG_TYPE_MOVE_RECEIVE,MACH_MSG_TYPE_PORT_RECEIVE,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_COPY_SEND" TPRETURN(MACH_MSG_TYPE_COPY_SEND,MACH_MSG_TYPE_PORT_SEND,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_MAKE_SEND" TPRETURN(MACH_MSG_TYPE_MAKE_SEND,MACH_MSG_TYPE_PORT_SEND,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_MOVE_SEND" TPRETURN(MACH_MSG_TYPE_MOVE_SEND,MACH_MSG_TYPE_PORT_SEND,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_MAKE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MAKE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_MOVE_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_MOVE_SEND_ONCE,MACH_MSG_TYPE_PORT_SEND_ONCE,port_size_in_bits);
+
+<Normal>"MACH_MSG_TYPE_PORT_NAME" TRETURN(MACH_MSG_TYPE_PORT_NAME,port_name_size_in_bits);
+<Normal>"MACH_MSG_TYPE_PORT_RECEIVE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_RECEIVE,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_PORT_SEND" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND,port_size_in_bits);
+<Normal>"MACH_MSG_TYPE_PORT_SEND_ONCE" TPRETURN(MACH_MSG_TYPE_POLYMORPHIC,MACH_MSG_TYPE_PORT_SEND_ONCE,port_size_in_bits);
<Normal>"MACH_MSG_TYPE_POLYMORPHIC" TRETURN(MACH_MSG_TYPE_POLYMORPHIC,0);
<Normal>":" RETURN(syColon);