Commit graph

40554 commits

Author SHA1 Message Date
Treehugger Robot
0398f8ab3a Merge "linker: add LD_SHOW_AUXV support." into main 2023-08-23 14:46:29 +00:00
Juan Yescas
81fffa2108 Merge "bionic: Set PTHREAD_STACK_MIN for page agnostic targets" into main am: fe690875d5 am: 6ffba3ea18
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719582

Change-Id: I5fdf2faf162c8398b80749fc1e8c39a5a8ddb138
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 04:06:32 +00:00
Juan Yescas
6ffba3ea18 Merge "bionic: Set PTHREAD_STACK_MIN for page agnostic targets" into main am: fe690875d5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719582

Change-Id: Ia6a079dc076482a42756b69b962984aba9f7a173
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 03:26:18 +00:00
Juan Yescas
fe690875d5 Merge "bionic: Set PTHREAD_STACK_MIN for page agnostic targets" into main 2023-08-23 02:44:58 +00:00
Kalesh Singh
9ac016c5df Merge "bionic: libc_init_static: Use page_size()" into main am: 8cd1ddcbf0 am: 5c7512474e
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719578

Change-Id: I5fc54937038715daa694b06b9b92edfc8cbd168c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 01:36:17 +00:00
Kalesh Singh
5c7512474e Merge "bionic: libc_init_static: Use page_size()" into main am: 8cd1ddcbf0
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719578

Change-Id: Id6d3f0cd81258f4b0b1e351addaf8cc664fd65eb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 00:56:50 +00:00
Kalesh Singh
8cd1ddcbf0 Merge "bionic: libc_init_static: Use page_size()" into main 2023-08-23 00:16:26 +00:00
Elliott Hughes
838dbacbfd linker: add LD_SHOW_AUXV support.
Yes, `od -t d8 /proc/self/auxv` is clever:
```
$ adb shell od -t d8 /proc/self/auxv
0000000                      33            488593047552
0000020                      51                    4720
0000040                      16                 1155071
0000060                       6                    4096
0000100                      17                     100
0000120                       3            375971917888
0000140                       4                      56
0000160                       5                      12
0000200                       7            488593051648
0000220                       8                       0
0000240                       9            375972184064
0000260                      11                       0
0000300                      12                       0
0000320                      13                       0
0000340                      14                       0
0000360                      23                       0
0000400                      25            549220780840
0000420                      26                       0
0000440                      31            549220786153
0000460                      15            549220780856
0000500                       0                       0
0000520
$
```
But this is a lot easier to read:
```
$ adb shell LD_SHOW_AUXV=1 date
AT_SYSINFO_EHDR      0x7065010000
AT_MINSIGSTKSZ       4720
AT_HWCAP             0b100011001111111111111
AT_PAGESZ            4096
AT_CLKTCK            100
AT_PHDR              0x5c79d60040
AT_PHENT             56
AT_PHNUM             12
AT_BASE              0x7065011000
AT_FLAGS             0
AT_ENTRY             0x5c79da1000
AT_UID               0
AT_EUID              0
AT_GID               0
AT_EGID              0
AT_SECURE            0
AT_RANDOM            0x7ff814eb98
AT_HWCAP2            0
AT_EXECFN            "/system/bin/date"
AT_PLATFORM          "aarch64"
Tue Aug 22 20:43:22 GMT 2023
```

Test: adb shell LD_SHOW_AUXV=1 date
Change-Id: I51c4e8cbb799eb1dc360c9417cc6f82bebdcda73
2023-08-22 14:25:01 -07:00
Juan Yescas
8d3866bacb bionic: Set PTHREAD_STACK_MIN for page agnostic targets
Page size agnostic targets will have a pthread stack equals
to 65536. Page size agnostic targets will only support ARM64 arch.

For not agnostic builds, PTHREAD_STACK_MIN will remain the same.

Bug: 296907948
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
      m

      source build/envsetup.sh
      aosp_cf_x86_64_phone-userdebug
      m

Change-Id: Ifcc04a9d924501f686cdfec34428d3f29154fdf0
2023-08-22 20:04:13 +00:00
Treehugger Robot
ca3bdafdd4 Merge "<sys/user.h>: factor PAGE_SIZE out into <bits/page_size.h>." into main am: 9fd0f4b90d am: 1882061f69
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721533

Change-Id: I1988355fdcb36019a49cb1f2236f79ab8e50bcd2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 19:23:53 +00:00
Treehugger Robot
1882061f69 Merge "<sys/user.h>: factor PAGE_SIZE out into <bits/page_size.h>." into main am: 9fd0f4b90d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721533

Change-Id: Ia6249f73cbc0072fd93e4527b15ed7737675b5ea
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 18:44:57 +00:00
Treehugger Robot
9fd0f4b90d Merge "<sys/user.h>: factor PAGE_SIZE out into <bits/page_size.h>." into main 2023-08-22 18:21:22 +00:00
Treehugger Robot
fdbfa3c887 Merge "riscv64: increase jmp_buf size." into main am: d4c9419441 am: 0fee718de7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719577

Change-Id: Ifd98e695b6aa7ce9a91601b04cf260d1d5284973
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 16:18:25 +00:00
Juan Yescas
94f8520923 Merge "bionic: Use max_page_size() instead of PAGE_SIZE" into main am: ac587f827c am: c48775c9fa
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719394

Change-Id: I5335fae1d3d91b6e5d57d9f6f1db3a81281564e6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 16:18:14 +00:00
Elliott Hughes
96591865e3 Merge "riscv64: fix ifuncs, improve the ifunc tests." into main am: d53ad05e38 am: c512636d31
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2695693

Change-Id: I7d756e7da09eb504c00d722c2804896c24c730be
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 16:18:01 +00:00
Treehugger Robot
0fee718de7 Merge "riscv64: increase jmp_buf size." into main am: d4c9419441
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719577

Change-Id: I1b994a05c71f8c1e0d7931dd7da44b94afa51664
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 15:40:35 +00:00
Juan Yescas
c48775c9fa Merge "bionic: Use max_page_size() instead of PAGE_SIZE" into main am: ac587f827c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719394

Change-Id: I9aabd3e94563154d1fd1ccb04a66f8f8e5ec3c46
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 15:40:22 +00:00
Elliott Hughes
c512636d31 Merge "riscv64: fix ifuncs, improve the ifunc tests." into main am: d53ad05e38
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2695693

Change-Id: I8db701b3fefd4bbe79918864aa83de5556dab000
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-22 15:38:36 +00:00
Elliott Hughes
1245abf7e3 <sys/user.h>: factor PAGE_SIZE out into <bits/page_size.h>.
If we're going to need PAGE_SIZE in other places, we don't want the
namespace pollution of pulling in all of <sys/user.h>. (The experimental
support for non-4KiB pages found an existing place -- <pthread.h> --
where we were assuming PAGE_SIZE is already available, as if
<sys/user.h> has already been included, so that was actually an existing
bug.)

Test: treehugger
Change-Id: Icd90ffbca1f2cf3645fadb2e432f6f45a4d63eb6
2023-08-22 15:31:51 +00:00
Treehugger Robot
d4c9419441 Merge "riscv64: increase jmp_buf size." into main 2023-08-22 15:23:43 +00:00
Juan Yescas
ac587f827c Merge "bionic: Use max_page_size() instead of PAGE_SIZE" into main 2023-08-22 15:22:44 +00:00
Elliott Hughes
d53ad05e38 Merge "riscv64: fix ifuncs, improve the ifunc tests." into main 2023-08-22 14:55:28 +00:00
Juan Yescas
3649db34a1 bionic: Use max_page_size() instead of PAGE_SIZE
Android V will support page size agnostic targets. The bionic macro
PAGE_SIZE won't be defined for the agnostic targets.

The PAGE_SIZE macro will be replaced by max_page_size() instead.

- For not agnostic builds, max_page_size() will be replaced by 4096.
- For agnostic builds, it will  be replaced by 16384

Bug: 296907948
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
      m

      source build/envsetup.sh
      aosp_cf_x86_64_phone-userdebug
      m

Change-Id: I81731a2ec59decd19ab9fd714d4f2ac20df873b7
2023-08-22 05:34:55 +00:00
Kalesh Singh
183f58bb2a bionic: libc_init_static: Use page_size()
Use the real page size from getauxval() for memtag stack
MTE protection.

Bug: 296275298
Test: atest -c bionic-unit-tests
Change-Id: I1711291b918b09e5464f1d15358dd1ff7fa2f371
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-21 16:55:41 -07:00
Elliott Hughes
620a72252e riscv64: fix ifuncs, improve the ifunc tests.
Talking futher to the person doing the glibc risc-v ifunc work, they
clarified that glibc _is_ passing hwcap as the first argument, and the
null pointer is actually the second argument.

https://sourceware.org/pipermail/libc-alpha/2023-August/150967.html

So since our whole purpose here was source compatibility, let's do what
they're actually doing, and let's add some tests. I've also added a test
that __riscv_hwprobe() works from an ifunc resolver because that's one
place where it might well be used. That said, one other thing that came
out of the discussion is that I actually went away and looked at a
sample of top apps to see how many are using ifuncs currently. The
result? Zero. So although this _might_ be interesting long term
(especially if clang gets riscv64 FMV), I think we've done more than we
need to with riscv64 ifuncs for now!

Test: ran locally, both dynamic and static tests
Change-Id: Ie2044d9f4e47c32c00ad381f045c537f4df38b08
2023-08-21 16:17:35 -07:00
Ryan Prichard
f6da9dc129 Merge "linker_main: acquire loader lock earlier and release it later" into main am: e722c756a5 am: a11ce307e9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2717362

Change-Id: Ied96d10e0444627c367a59a2dbff76d1bf468fc8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 21:45:33 +00:00
Treehugger Robot
7af5650e81 Merge "sys_hwprobe_test.cpp: compare vdso to syscall." into main am: d8708ba8b6 am: 6e0fa4ae74
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2708293

Change-Id: I4f9a5706714ad4a6039522df49f93ae9c2b5d056
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 21:45:23 +00:00
Ryan Prichard
a11ce307e9 Merge "linker_main: acquire loader lock earlier and release it later" into main am: e722c756a5
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2717362

Change-Id: I7395de18aba9bfd6e6c7c14a865c08ed715dcec6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 21:08:50 +00:00
Ryan Prichard
e722c756a5 Merge "linker_main: acquire loader lock earlier and release it later" into main 2023-08-21 21:06:39 +00:00
Treehugger Robot
6e0fa4ae74 Merge "sys_hwprobe_test.cpp: compare vdso to syscall." into main am: d8708ba8b6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2708293

Change-Id: Ib941f151ba4eefcd3f72125f3531ae75b4ba38d0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 21:06:25 +00:00
Elliott Hughes
7c6c1f8b59 riscv64: increase jmp_buf size.
Today's risc-v psABI meeting brought up the topic of CFI-related ABI
changes, and FreeBSD wasn't worried about jmp_buf because they already
had twice the space we do (OpenBSD matches us, presumably because they
too just picked "the next power of two" over what they actually
required), and glibc wasn't worried because they have a hilariously
large sigset_t that they can steal space from (and apparently already
did to support the x86-64 CET shadow stack).

So rather than continue to assume that our minimal amount of free space
will suffice, let's just double it while our ABI isn't yet fixed, and
know we won't have to worry about it in a couple of years time when we
actually have riscv64 hardware shadow stack.

Test: treehugger
Change-Id: I2d4cb2f5db2ac8085a2c9e9ad4f910d0d4792005
2023-08-21 20:50:14 +00:00
Treehugger Robot
d8708ba8b6 Merge "sys_hwprobe_test.cpp: compare vdso to syscall." into main 2023-08-21 20:47:52 +00:00
Mitch Phillips
a247c91ac4 Merge "Move bionic test libraries to a default, for easy consumption in cts." into main am: e219a4179f am: c5f691b9a6
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719254

Change-Id: Ib1a2f7eb9a015c918ac08daa5fafe818dab2ffe7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 17:11:09 +00:00
Mitch Phillips
c5f691b9a6 Merge "Move bionic test libraries to a default, for easy consumption in cts." into main am: e219a4179f
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2719254

Change-Id: Ibcb2310d8d2b737dcbdf2adb8d372820ee59f010
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-21 16:36:40 +00:00
Mitch Phillips
e219a4179f Merge "Move bionic test libraries to a default, for easy consumption in cts." into main 2023-08-21 16:32:11 +00:00
Mitch Phillips
f5c9a65046 Move bionic test libraries to a default, for easy consumption in cts.
This list has diverged between cts/ and bionic/. Instead of having to
maintain the list, let's just make cts/ inherit the one from bionic.

Bug: 296832150
Test: atest bionic-unit-tests CtsBionicTestCases
Change-Id: I271668e83aed239107b9129dfb707f03bae47cfa
2023-08-21 13:55:10 +02:00
Juan Yescas
9806531ca3 Merge "bionic: Fix typo in the argument passed to getauxval()" into main am: 8ff3886ff7 am: e62e9330eb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2715851

Change-Id: I7864d401741dfdf74e5e53a629f596c466d43dc3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 18:15:26 +00:00
Juan Yescas
34f6fd1c44 Merge changes from topic "bionic_max_pgsize" into main am: 4c562594d9 am: 8acb8ccda7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2713655

Change-Id: I270e965f1bea4232e666a1004589a0c23854bfa3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 18:15:14 +00:00
Juan Yescas
e62e9330eb Merge "bionic: Fix typo in the argument passed to getauxval()" into main am: 8ff3886ff7
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2715851

Change-Id: If287e2ebb4278fa9afe201566378c610e2abc5bc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 17:41:46 +00:00
Juan Yescas
8acb8ccda7 Merge changes from topic "bionic_max_pgsize" into main am: 4c562594d9
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2713655

Change-Id: I292eb2f159327100c528bee081e6d67c8e8844e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 17:41:34 +00:00
Juan Yescas
8ff3886ff7 Merge "bionic: Fix typo in the argument passed to getauxval()" into main 2023-08-20 17:05:31 +00:00
Juan Yescas
4c562594d9 Merge changes from topic "bionic_max_pgsize" into main
* changes:
  bionic: libc: WriteProtected use max_page_size()
  bionic: Introduce max_page_size()
2023-08-20 17:05:07 +00:00
Treehugger Robot
9322f9611f Merge "Add some new risc-v ELF relocations." into main am: 0c56cbad11 am: 333099cedb
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2717354

Change-Id: Id6b5d23eb01263af02c6fec9dc7e9363d56dc104
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 10:31:05 +00:00
Treehugger Robot
333099cedb Merge "Add some new risc-v ELF relocations." into main am: 0c56cbad11
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2717354

Change-Id: I9c0c30a2b1d450a218f289f2b6c91796e85a88ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-20 09:21:55 +00:00
Treehugger Robot
0c56cbad11 Merge "Add some new risc-v ELF relocations." into main 2023-08-20 08:20:14 +00:00
Kalesh Singh
2bdf22e992 bionic: libc: WriteProtected use max_page_size()
In the 4k targets there is no fucntional difference since
max_page_size() == page_size() == 4096.

On a 16kb device max_page_size() == 65536 and page_size() == 16384.
However, aligning up does not incur any memory regressions
since the .bss section is still be backes in page-sizeed chunks.

See: go/16k-page-aligned-variables

Bug: 296275298
Test: mma
Change-Id: I41c3e410f3b84c24eeb969c9aeca4b33a8d6170a
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-19 00:05:12 +00:00
Kalesh Singh
307bae7afe bionic: Introduce max_page_size()
This can be used to "page-align" variables at build time -
__attribute__((aligned(max_pge_size()))), so it is a
preprocessor macro instead of an inline function.

There is no functional change to the 4kB-only build targets
(!defined(__BIONIC_NO_PAGE_SIZE_MACRO))

Bug: 296275298
Test: mma
Change-Id: I462e9f971a176b6b59e32e449a2e11f95c3f1b45
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-08-19 00:04:53 +00:00
Ryan Prichard
67e8f22cf5 linker_main: acquire loader lock earlier and release it later
__linker_init calls soinfo::~soinfo after __linker_init_post_relocation
has returned, and ~soinfo modifies global loader state
(g_soinfo_handles_map), so the loader lock must be held.

Use a variable with a destructor (~DlMutexUnlocker) to release the
loader lock after ~soinfo returns.

It's not clear to me when the mutex should be acquired.
pthread_mutex_lock in theory can use __bionic_tls (ScopedTrace), but
that should only happen if the mutex is contended, and it won't be.
The loader constructors shouldn't be spawning a thread, and the vdso
shouldn't really have a constructor. ifunc relocations presumably don't
spawn a thread either. It probably doesn't matter much as long as it's
held before calling constructors in the executable or shared objects.

Bug: http://b/290318196
Test: treehugger
Test: bionic-unit-tests
Change-Id: I544ad65db07e5fe83315ad4489d77536d463a0a4
2023-08-18 16:23:34 -07:00
Elliott Hughes
f517b68c82 Add some new risc-v ELF relocations.
Also add the link to the canonical source.

Test: treehugger
Change-Id: I06c5d1ded5e1b372630c6963c81947450946c29a
2023-08-18 17:51:53 +00:00
Juan Yescas
0bd4117f3f bionic: Fix typo in the argument passed to getauxval()
AT_PAGESZ is the correct argument for getauxval() to get the page size.

Bug: 277272383
Test: source build/envsetup.sh
      lunch aosp_cf_arm64_phone_pgagnostic
Change-Id: Ied2db77e9fda73b58f65b2f489ad7fab743c2fe7
2023-08-18 03:49:15 +00:00