Discussion:
Shared library in Genode must be position-independent?
Vincent Stone
2016-02-29 02:36:29 UTC
Permalink
Hi all:
I am using Genode to do some SSL encryption stuff. My dev-board is
i.MX6Quad running Genode 15.02. The OpenSSL version is 1.0.1i. I test the
Crypto speed of OpenSSL in Genode. It's very slow( 7MB/s for aes-128-gcm)
comparing to OpenSSL in Linux (16MB/s for aes-128-gcm). Genode's OpenSSL
doesn't use the assembly code version of some critical crypto function. It
disable this option in libcrypto.mk. If I do the same to Linux OpenSSL, the
performance goes down to 9MB/s. So I enable this option in libcrypto.mk.
use Genode compiler to compile it. Everything seems ok. No compiler/linker
errors. But the program can not run. MMU exception occurs before the main
program start. It seems that something goes wrong during the library
loading. I am really confused.
Why does Genode disable this assembly code option? ( I can only find a
1-sentence explaination on Genode release notes 12.08
<http://genode.org/documentation/release-notes/12.08>

Because libcrypto provides certain optimized assembler functions, which
unfortunately are not expressed with position-independent code, we removed
this assembler code and build libcrypto with -DOPENSSL_NO_ASM
I guess the loader of Genode can not handle load-time relocation for shared
library so all shared library must be position independent. Am I right?

Thank you.

--
Best wishes
Vincent
Stefan Kalkowski
2016-02-29 09:39:19 UTC
Permalink
Hi Vincent,

just a short remark: when you do performance measurements on top of
Genode's i.MX6 base-hw platform, you should definitely upgrade to our
recent release 16.02. The initial contribution that enabled i.MX6 for
Genode did not encounter the L2 cache of this platform. So your
measurement comparisons will be misleading anyway as far as you did not
enabled the L2 cache yourself.
The recent release enables all four cores and the L2 cache for the
Wandboard target platform.

Regards
Stefan
Post by Vincent Stone
I am using Genode to do some SSL encryption stuff. My dev-board is
i.MX6Quad running Genode 15.02. The OpenSSL version is 1.0.1i. I test the
Crypto speed of OpenSSL in Genode. It's very slow( 7MB/s for aes-128-gcm)
comparing to OpenSSL in Linux (16MB/s for aes-128-gcm). Genode's OpenSSL
doesn't use the assembly code version of some critical crypto function. It
disable this option in libcrypto.mk. If I do the same to Linux OpenSSL, the
performance goes down to 9MB/s. So I enable this option in libcrypto.mk.
use Genode compiler to compile it. Everything seems ok. No compiler/linker
errors. But the program can not run. MMU exception occurs before the main
program start. It seems that something goes wrong during the library
loading. I am really confused.
Why does Genode disable this assembly code option? ( I can only find a
1-sentence explaination on Genode release notes 12.08
<http://genode.org/documentation/release-notes/12.08>
Because libcrypto provides certain optimized assembler functions, which
unfortunately are not expressed with position-independent code, we removed
this assembler code and build libcrypto with -DOPENSSL_NO_ASM
I guess the loader of Genode can not handle load-time relocation for shared
library so all shared library must be position independent. Am I right?
Thank you.
--
Best wishes
Vincent
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
--
Stefan Kalkowski
Genode Labs

http://www.genode-labs.com/ · http://genode.org/
Josef Söntgen
2016-02-29 10:28:43 UTC
Permalink
Hello Vincent,
Post by Vincent Stone
Why does Genode disable this assembly code option? ( I can only find a
1-sentence explaination on Genode release notes 12.08
<http://genode.org/documentation/release-notes/12.08>
Because libcrypto provides certain optimized assembler functions, which
unfortunately are not expressed with position-independent code, we removed
this assembler code and build libcrypto with -DOPENSSL_NO_ASM
Only specific assembler implementations for x86 were enabled when we
did the initial libcrypto port. When the port was updated to a newer
version the generated asm files did contain text relocations, which did
not work when compiling with -fpic, IIRC. Since potential performance
gains from using the asm implementation were not important I decided
to remove the files and to use the generic C implementation instead.
We never tested or used the asm implementations on other platforms,
e.g. ARM.
Post by Vincent Stone
I guess the loader of Genode can not handle load-time relocation for shared
library so all shared library must be position independent. Am I right?
The dynamic loader does support load-time relocations for data but code
relocations, e.g. function calls, are not supported [1].

[1] see repos/base/src/lib/ldso/spec/*/relocation.h


Regards,
Josef
Vincent Stone
2016-02-29 10:54:06 UTC
Permalink
Thanks for answering my question. Yeah. These assembly file containing text relocation will cause the MMU exception, which leave me 2 choices:
1. rewrite the assembly code to be position independent.
2. add load-time relocations for code in Genode dynamic loader for arm.

And based on my test, the performance of the latest OpenSSL (1.0.2f) is way more better than 1.0.1i(Genode currently using) due to more optimized assembly code.
26 MB/s vs 16 MB/s. But if we disable the assembly code. The performance is almost identical(7~8 MB/s).
Post by Josef Söntgen
Hello Vincent,
Post by Vincent Stone
Why does Genode disable this assembly code option? ( I can only find a
1-sentence explaination on Genode release notes 12.08
<http://genode.org/documentation/release-notes/12.08>
Because libcrypto provides certain optimized assembler functions, which
unfortunately are not expressed with position-independent code, we removed
this assembler code and build libcrypto with -DOPENSSL_NO_ASM
Only specific assembler implementations for x86 were enabled when we
did the initial libcrypto port. When the port was updated to a newer
version the generated asm files did contain text relocations, which did
not work when compiling with -fpic, IIRC. Since potential performance
gains from using the asm implementation were not important I decided
to remove the files and to use the generic C implementation instead.
We never tested or used the asm implementations on other platforms,
e.g. ARM.
Post by Vincent Stone
I guess the loader of Genode can not handle load-time relocation for shared
library so all shared library must be position independent. Am I right?
The dynamic loader does support load-time relocations for data but code
relocations, e.g. function calls, are not supported [1].
[1] see repos/base/src/lib/ldso/spec/*/relocation.h
Regards,
Josef
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
genode-main mailing list
https://lists.sourceforge.net/lists/listinfo/genode-main
Loading...