Commit graph

40144 commits

Author SHA1 Message Date
Elliott Hughes
a9ca959498 Merge "sysconf(): implement cache queries." into main am: a71a15fe34 am: 3996bbe901
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721536

Change-Id: I42a469ff24cd418c0825a33b1345ebafd3dda04f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-28 15:50:33 +00:00
Elliott Hughes
3996bbe901 Merge "sysconf(): implement cache queries." into main am: a71a15fe34
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721536

Change-Id: Ied0b13efd8a25f1b185226d3ff430d93b4fac31a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-28 15:05:59 +00:00
Elliott Hughes
a71a15fe34 Merge "sysconf(): implement cache queries." into main 2023-08-28 14:48:20 +00:00
Elliott Hughes
02df7388f1 sysconf(): implement cache queries.
This is a bit disappointing. I'd not implemented this in the past
because it wasn't available on all platforms, and -- although the
riscv64 implementation was just a cool optimization -- I thought that
the /sys stuff was actually portable, until I ran it on arm64 hardware.
So here we have getauxval() for riscv64, /sys for x86-64, and our best
guess based on ctr_el0 for arm64.

Bug: http://b/294034962
Test: ran tests on the host, an arm64 device, and riscv64 host and qemu
Change-Id: I420b69b976d30668d4d2ac548c4229e2a4eafb20
2023-08-28 14:48:12 +00:00
Elliott Hughes
925b5f482f Merge "Add %b/%B to async-safe logging." into main am: bf4d3a95c1 am: 5abfd88813
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721534

Change-Id: I089499ab936e4b46603b0364e9188ad94121458d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-24 16:07:56 +00:00
Elliott Hughes
5abfd88813 Merge "Add %b/%B to async-safe logging." into main am: bf4d3a95c1
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721534

Change-Id: I2c8f318874f9c2fc674041a10d36f7082f9a5d43
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-24 15:26:08 +00:00
Elliott Hughes
bf4d3a95c1 Merge "Add %b/%B to async-safe logging." into main 2023-08-24 14:34:45 +00:00
Elliott Hughes
f5b4e3ce58 Add %b/%B to async-safe logging.
Missed this when we added the new C23 binary output to the printf()
family.

Also fix %X to use "0X" instead of "0x" and add missing tests.

Test: used by new LD_SHOW_AUXV functionality
Change-Id: I6623b92acec7daf534536697de0f87352a2653ad
2023-08-23 14:08:40 -07:00
Treehugger Robot
2f031ba684 Merge "linker: add LD_SHOW_AUXV support." into main am: 0398f8ab3a am: c08ab40d9c
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721918

Change-Id: Id362805712b98eb446de69e521720965a24b7084
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 16:05:05 +00:00
Treehugger Robot
c08ab40d9c Merge "linker: add LD_SHOW_AUXV support." into main am: 0398f8ab3a
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2721918

Change-Id: I68dd793cd66d062986c4750a1ae097b9d2e8a335
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-08-23 15:24:33 +00:00
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