[v3,04/29] alpha: Add <bits/pagesize.h>

Message ID 4b9385fbcd4b2a93c27f8fb5b5d7e4bca120b190.1727624528.git.fweimer@redhat.com
State Under Review
Delegated to: Adhemerval Zanella Netto
Headers
Series Teach glibc about possible page sizes and handle gaps in ld.so |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer Sept. 29, 2024, 3:56 p.m. UTC
  According to arch/alpha/Kconfig, alpha always has a page size of
8 KiB (only HAVE_PAGE_SIZE_8KB is used).  However, the toolchain
defaults support a maximum page size of 64 KiB, so adjust the
maximum accordingly.

(Note: We could XFAIL the gaps test added later and fix the page size at
8 KiB, despite what binutils does today.)

---
 sysdeps/alpha/bits/pagesize.h | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 sysdeps/alpha/bits/pagesize.h
  

Comments

Richard Henderson Oct. 5, 2024, 12:53 a.m. UTC | #1
On 9/29/24 08:56, Florian Weimer wrote:
> According to arch/alpha/Kconfig, alpha always has a page size of
> 8 KiB (only HAVE_PAGE_SIZE_8KB is used).  However, the toolchain
> defaults support a maximum page size of 64 KiB, so adjust the
> maximum accordingly.

The ev6 hardware can support 8k, 64k, 512k, and 4G page sizes, but we never got around to 
supporting them within the kernel.  When doing the toolchain support, I always assumed 
we'd get around to at least 64k.  :-/


> (Note: We could XFAIL the gaps test added later and fix the page size at
> 8 KiB, despite what binutils does today.)
> 
> ---
>   sysdeps/alpha/bits/pagesize.h | 2 ++
>   1 file changed, 2 insertions(+)
>   create mode 100644 sysdeps/alpha/bits/pagesize.h
> 
> diff --git a/sysdeps/alpha/bits/pagesize.h b/sysdeps/alpha/bits/pagesize.h
> new file mode 100644
> index 0000000000..81824b5ab6
> --- /dev/null
> +++ b/sysdeps/alpha/bits/pagesize.h
> @@ -0,0 +1,2 @@
> +#define __GLIBC_PAGE_SHIFT_MIN 13
> +#define __GLIBC_PAGE_SHIFT_MAX 16

FWIW, qemu 9.1 supports aligning the guest page size to the host page size, for a subset 
of guests: alpha, aarch64, ppc*.  This fixes a number of edge cases with mmap that cannot 
be properly emulated otherwise (especially wrt SIGBUS within the final guest page beyond 
the end of a file).  I intend to extend this to other guests as and when I have time, but 
have not done the legwork you have done to identify which guests need attention.

We allow Alpha page size to float down to 4k to aid emulation on x86 hosts, despite this 
not being a page size supported by real hardware.  This works in practice because Alpha 
applications do not hard-code a particular page size.  As long as the program respects 
AT_PAGESIZE or getpagesize(2), all is well.

I only bring this up to let you know that the test case may fail when run on qemu-alpha.


r~
  
Florian Weimer Oct. 5, 2024, 6:22 p.m. UTC | #2
* Richard Henderson:

>> (Note: We could XFAIL the gaps test added later and fix the page size at
>> 8 KiB, despite what binutils does today.)
>> ---
>>   sysdeps/alpha/bits/pagesize.h | 2 ++
>>   1 file changed, 2 insertions(+)
>>   create mode 100644 sysdeps/alpha/bits/pagesize.h
>> diff --git a/sysdeps/alpha/bits/pagesize.h
>> b/sysdeps/alpha/bits/pagesize.h
>> new file mode 100644
>> index 0000000000..81824b5ab6
>> --- /dev/null
>> +++ b/sysdeps/alpha/bits/pagesize.h
>> @@ -0,0 +1,2 @@
>> +#define __GLIBC_PAGE_SHIFT_MIN 13
>> +#define __GLIBC_PAGE_SHIFT_MAX 16
>
> FWIW, qemu 9.1 supports aligning the guest page size to the host page
> size, for a subset of guests: alpha, aarch64, ppc*.  This fixes a
> number of edge cases with mmap that cannot be properly emulated
> otherwise (especially wrt SIGBUS within the final guest page beyond
> the end of a file).  I intend to extend this to other guests as and
> when I have time, but have not done the legwork you have done to
> identify which guests need attention.

Hmm, I'm surprised that a smaller page size isn't compatible.  I suppose
there could be an issue regarding the tail if the file is subsequently
resized.  The end of the tail might not be writable with 4K pages, but
is writable with 8K pages.

Do you suggest to lower PAGE_SIZE_MIN to 4096 for QEMU compatibility?
It's not clear to me based on your message.

I should probably update the documentation in the manual that
PAGE_SIZE_MIN is not a suitable boundary for over-reading because it's
incompatible with (future introduction of) pointer tagging.  The alpha
memchr in glibc uses cache line boundaries for overreading, so it's fine
with 4K pages at least.

Thanks,
Florian
  

Patch

diff --git a/sysdeps/alpha/bits/pagesize.h b/sysdeps/alpha/bits/pagesize.h
new file mode 100644
index 0000000000..81824b5ab6
--- /dev/null
+++ b/sysdeps/alpha/bits/pagesize.h
@@ -0,0 +1,2 @@ 
+#define __GLIBC_PAGE_SHIFT_MIN 13
+#define __GLIBC_PAGE_SHIFT_MAX 16