[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH mig] Make MIG work for pure 64 bit kernel and userland.

From: Luca
Subject: Re: [PATCH mig] Make MIG work for pure 64 bit kernel and userland.
Date: Sun, 12 Feb 2023 17:01:27 +0100


Il 12/02/23 14:37, Luca ha scritto:
Il 12/02/23 07:15, Flavio Cruz ha scritto:
For the 64 bit / 32 bit configuration, we can pass --enable-user32 when
targeting x86_64, and MIG will generate stubs as before. I am unsure
whether there exists undefined behavior in that particular configuration
since most of the structures used by the kernel do not seem to use 8
byte scalars so potentially we should be OK there.

As mentioned in the article, using memcpy() to a correctly aligned pointer seems to avoid the possible alignment issues. Since in the kernel we need to use copyin/copyout anyway, wouldn't this be enough?

As for the mig stubs, if I understand correctly the issue stems from the fact that they use a struct to create the message fields in memory, so the binary format of a message needs to have the same alignment requirements. Would using memcpy here avoid the alignment issue? I think it would even simplify the stub code, e.g. for array types, and I'm not sure it would decrease performance.

In addition to this, wouldn't it be a kind of a risk to rely on the C memory layout for packing message fields? What if in the future this breaks because of some new optimization, or some other cpu architecture?

I'm referring mainly to the generic message processing in the kernel, e.g. in ipc/kmsg.c and similar, which should then have some architecture-specific parts, or depend on compiler features, but the same applies to the mig-generated code.

It seems XNU's mig [0] always sets the alignment to natural_t (=4) with a #pragma... I still have to understand how they handle these issues.


[0] I found https://github.com/markmentovai/bootstrap_cmds which is easy to compile outside Apple systems, and it doesn't seem too different from the official version here https://github.com/apple-oss-distributions/bootstrap_cmds

reply via email to

[Prev in Thread] Current Thread [Next in Thread]