Re: [Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-20 Thread Peter Maydell
On Tue, 20 Aug 2019 at 16:59, Richard Henderson
 wrote:
>
> On 8/20/19 8:39 AM, Peter Maydell wrote:
> > On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> >  wrote:
> >>
> >> These are all of the defines required to parse
> >> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> >> Other missing defines related to other GNU program headers
> >> and notes are elided for now.
> >>
> >> Signed-off-by: Richard Henderson 
> >
> > What's the authoritative source for these definitions? I
> > tried looking in glibc, binutils and the kernel without
> > any luck.
>
> Presumably the true "authoritative" source is an ARM document, but I don't 
> have
> that handy.
>
> For binutils, the defines are in include/elf/common.h:
>
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD

Thanks.

Reviewed-by: Peter Maydell 

-- PMM



Re: [Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-20 Thread Dave Martin
On Tue, Aug 20, 2019 at 04:59:50PM +0100, Richard Henderson wrote:
> On 8/20/19 8:39 AM, Peter Maydell wrote:
> > On Sat, 3 Aug 2019 at 22:08, Richard Henderson
> >  wrote:
> >>
> >> These are all of the defines required to parse
> >> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> >> Other missing defines related to other GNU program headers
> >> and notes are elided for now.
> >>
> >> Signed-off-by: Richard Henderson 
> > 
> > What's the authoritative source for these definitions? I
> > tried looking in glibc, binutils and the kernel without
> > any luck.
> 
> Presumably the true "authoritative" source is an ARM document, but I don't 
> have
> that handy.
> 
> For binutils, the defines are in include/elf/common.h:
> 
> https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD
> 
> The upstream kernel is also lacking the defines, as they're part of the ARM
> patch set that is still in flight.  The defines are still not present in glibc
> as of today.


The AArch64 spec is here:

https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2019q2-documentation

Cheers
---Dave



Re: [Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-20 Thread Dave P Martin
On Tue, Aug 20, 2019 at 04:39:01PM +0100, Peter Maydell wrote:
> On Sat, 3 Aug 2019 at 22:08, Richard Henderson
>  wrote:
> >
> > These are all of the defines required to parse
> > GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> > Other missing defines related to other GNU program headers
> > and notes are elided for now.
> >
> > Signed-off-by: Richard Henderson 
>
> What's the authoritative source for these definitions? I
> tried looking in glibc, binutils and the kernel without
> any luck.

For the kernel, additions to the user elf.h are still under
discussion. [3]

For the relevant draft ELF/ABI specs, see [1], [2].

Cheers
---Dave


[1] https://github.com/hjl-tools/linux-abi/wiki/linux-abi-draft.pdf
[2] https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-draft.pdf

[3] [PATCH v8 22/27] binfmt_elf: Extract .note.gnu.property from an ELF file
https://lore.kernel.org/lkml/20190813205225.12032-23-yu-cheng...@intel.com/
IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.



Re: [Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-20 Thread Richard Henderson
On 8/20/19 8:39 AM, Peter Maydell wrote:
> On Sat, 3 Aug 2019 at 22:08, Richard Henderson
>  wrote:
>>
>> These are all of the defines required to parse
>> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
>> Other missing defines related to other GNU program headers
>> and notes are elided for now.
>>
>> Signed-off-by: Richard Henderson 
> 
> What's the authoritative source for these definitions? I
> tried looking in glibc, binutils and the kernel without
> any luck.

Presumably the true "authoritative" source is an ARM document, but I don't have
that handy.

For binutils, the defines are in include/elf/common.h:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob_plain;f=include/elf/common.h;hb=HEAD

The upstream kernel is also lacking the defines, as they're part of the ARM
patch set that is still in flight.  The defines are still not present in glibc
as of today.


r~



Re: [Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-20 Thread Peter Maydell
On Sat, 3 Aug 2019 at 22:08, Richard Henderson
 wrote:
>
> These are all of the defines required to parse
> GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
> Other missing defines related to other GNU program headers
> and notes are elided for now.
>
> Signed-off-by: Richard Henderson 

What's the authoritative source for these definitions? I
tried looking in glibc, binutils and the kernel without
any luck.

thanks
-- PMM



[Qemu-devel] [PATCH v7 4/6] include/elf: Add defines related to GNU property notes for AArch64

2019-08-03 Thread Richard Henderson
These are all of the defines required to parse
GNU_PROPERTY_AARCH64_FEATURE_1_AND, copied from binutils.
Other missing defines related to other GNU program headers
and notes are elided for now.

Signed-off-by: Richard Henderson 
---
 include/elf.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/include/elf.h b/include/elf.h
index 3501e0c8d0..7c4dc4b2cc 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -26,9 +26,13 @@ typedef int64_t  Elf64_Sxword;
 #define PT_NOTE4
 #define PT_SHLIB   5
 #define PT_PHDR6
+#define PT_LOOS0x6000
+#define PT_HIOS0x6fff
 #define PT_LOPROC  0x7000
 #define PT_HIPROC  0x7fff
 
+#define PT_GNU_PROPERTY   (PT_LOOS + 0x474e553)
+
 #define PT_MIPS_REGINFO   0x7000
 #define PT_MIPS_RTPROC0x7001
 #define PT_MIPS_OPTIONS   0x7002
@@ -1651,6 +1655,24 @@ typedef struct elf64_shdr {
 #define NT_ARM_HW_WATCH 0x403   /* ARM hardware watchpoint registers */
 #define NT_ARM_SYSTEM_CALL  0x404   /* ARM system call number */
 
+/* Defined note types for GNU systems.  */
+
+#define NT_GNU_PROPERTY_TYPE_0  5   /* Program property */
+
+/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0).  */
+
+#define GNU_PROPERTY_STACK_SIZE 1
+#define GNU_PROPERTY_NO_COPY_ON_PROTECTED   2
+
+#define GNU_PROPERTY_LOPROC 0xc000
+#define GNU_PROPERTY_HIPROC 0xdfff
+#define GNU_PROPERTY_LOUSER 0xe000
+#define GNU_PROPERTY_HIUSER 0x
+
+#define GNU_PROPERTY_AARCH64_FEATURE_1_AND  0xc000
+#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI  (1u << 0)
+#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC  (1u << 1)
+
 /*
  * Physical entry point into the kernel.
  *
-- 
2.17.1