efl/src/lib/eo
Carsten Haitzler 74327ddbc8 eo - by default on 64bit only use 47 bits because of luajit
luajit wants to check the upper 17 bits of pointers and assume they
are all 0 if on a 64bit architecture. it will panic and barf if they
are used. we have been using them in our eoid's for a long time.

my take on this is that this is unportable. assuming how many bits are
or are not valid in an opaque pointer (void *) that is simply passed
to you and you cannot dereference or use (no size information even for
what amount of data it points to etc.), is just wrong. it's not
portable and it's trying to be too smart and creating such issues. my
take is that luajit needs a fix for this in the longer term. but for
now let's have a 47 bit mode and go with that. it does mean i have to
drop our generation counter to 10 bits on 64bit (from 27 bits) which
increases likelihood of eoid re-use being falsely detected as valid
(before on 64bit it was 1 in 130 million or so chance, with this 47
bit change it's 1 in 1000. but to be fair on 32bit it's 7 bits for gen
count so 1 in 127 ... so still more than 10x "safer" than on 32bit...
but still...). the relevant check in luajit is:

  (((uint64_t)(p) >> 47) ? (lj_err_msg(L, LJ_ERR_BADLU), NULL) : (p))

it ONLY does this on 64bit. on 32bit pointers are not checked for
validity at all.

as an aside, armv8.2 seemingly will bring 52bit addresses so luajit is
going to fall over flat on a newer rev of armv8. it may be x86 also
uses more bits. last i knew it was 48bits so the 47 bit check luajit
does i think is even wrong for x86-64. to be detailed i read:

amd64 arch == 48 bits (so luajit is wrong). even better In addition,
the AMD specification requires that the most significant 16 bits of
any virtual address, bits 48 through 63, must be copies of bit 47 (in
a manner akin to sign extension). so if the upper bit of 48 is set
THEN all the 16 upper bits must be 1... breaking luajit, even if it
were 47bit and this rule applied. I read the architecture allows for
up to 52bits of actual addresses so architecture-wise this is even
wrong...

So I smell a core bug here in luajit. Certainly in the number of bits
it insists must be 0 (the upper 17 bits where on amd64/x86-64 it
should be the upper 16 bits... and even then these may NOT be 0 if bit
47 (the upper bit of the lower 48 is 1).... so the whole check is
invalid... :(

at least the above is at a theoretical level. i believe that the
addresses divide the 48 bits into 2 chunks (thus 47)... but at the
PHYSICAL level with no mmu and virtual memory. arm64 has this:

https://www.kernel.org/doc/Documentation/arm64/memory.txt

note in all cases the 2nd chunk of memory has at leats some upper bits
of physical addresses beign 1 ... which makes luajit invalid tyo use
without virtual memory remapping these away from high bits.

@fix
2017-11-24 18:29:23 +09:00
..
CMakeLists.txt cmake/eo: add description (fills eo.pc file) 2017-01-23 19:34:39 -02:00
Eo.h Eo: be a bit more detailed in the docs 2017-11-17 16:08:14 +01:00
efl_class.eo docs: eo: finish up docs for eo 2016-11-10 15:14:42 +01:00
efl_future.c Efl_Future: class name (string) using "." for namespace. 2016-12-12 02:30:33 -02:00
efl_future.h eo: add missing since tags for functions added during 1.19 cycle 2017-02-14 21:47:15 +01:00
efl_interface.eo Eo: Rename most of Eo to the Efl prefix. 2016-08-11 17:04:43 +01:00
efl_object.eo eo files: convert various to use @cref 2017-11-02 16:41:01 +01:00
efl_object_override.eo Eo: Rename most of Eo to the Efl prefix. 2016-08-11 17:04:43 +01:00
eina_types.eot eo: Use any_value in eina_types.eot 2017-10-17 17:31:38 +09:00
eo.c eo: Make sure auto_unref only applies after finalize 2017-11-24 16:15:44 +09:00
eo_add_fallback.c all: use void if we really want to make sure we do not accept parameters 2016-12-06 17:16:24 +01:00
eo_add_fallback.h Eo: Finish the renaming of Eo to the EFL. 2016-08-15 15:07:42 +01:00
eo_base_class.c eo: Add beta API for auto_unref after a call 2017-10-18 11:02:16 +09:00
eo_class_class.c Eo: Rename most of Eo to the Efl prefix. 2016-08-11 17:04:43 +01:00
eo_private.h eo: Add beta API for auto_unref after a call 2017-10-18 11:02:16 +09:00
eo_ptr_indirection.c eo: Improve invalid EO ID error message 2017-06-22 13:19:23 +09:00
eo_ptr_indirection.h eo: Add debug_name read-only property to ease debugging 2017-08-04 10:24:03 +09:00
eo_ptr_indirection.x eo - by default on 64bit only use 47 bits because of luajit 2017-11-24 18:29:23 +09:00