Return the API version and the size of a bts_struct in the PTRACE_BTS_STATUS command. This might be handy in case other archs want to use and extend the interface. It allows users to program against one version and continue to work for newer versions (they have to discard everything they don't understand, of course).
Signed-off-by: Markus Metzger <[email protected]>
---
Index: linux-2.6-x86/arch/x86/kernel/ptrace.c
===================================================================
--- linux-2.6-x86.orig/arch/x86/kernel/ptrace.c 2008-01-07 12:42:39.%N +0100
+++ linux-2.6-x86/arch/x86/kernel/ptrace.c 2008-01-07 13:09:07.%N +0100
@@ -787,6 +787,9 @@
cfg.flags |= PTRACE_BTS_O_SCHED;
}
+ cfg.bts_size = sizeof(struct bts_struct);
+ cfg.version = PTRACE_BTS_VERSION;
+
if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
return -EFAULT;
Index: linux-2.6-x86/include/asm-x86/ptrace-abi.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/ptrace-abi.h 2008-01-07 12:42:39.%N +0100
+++ linux-2.6-x86/include/asm-x86/ptrace-abi.h 2008-01-07 13:08:39.%N +0100
@@ -91,6 +91,10 @@
unsigned int flags;
/* buffer overflow signal */
unsigned int signal;
+ /* actual size of bts_struct in bytes */
+ unsigned short bts_size;
+ /* interface version */
+ unsigned short version;
};
#endif
Index: linux-2.6-x86/include/asm-x86/ptrace.h
===================================================================
--- linux-2.6-x86.orig/include/asm-x86/ptrace.h 2008-01-07 12:42:39.%N +0100
+++ linux-2.6-x86/include/asm-x86/ptrace.h 2008-01-07 13:08:39.%N +0100
@@ -9,6 +9,8 @@
#ifdef __KERNEL__
+#define PTRACE_BTS_VERSION 1
+
/* the DS BTS struct is used for ptrace as well */
#include <asm/ds.h>
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
* Markus Metzger <[email protected]> wrote:
> Return the API version and the size of a bts_struct in the
> PTRACE_BTS_STATUS command. This might be handy in case other archs
> want to use and extend the interface. It allows users to program
> against one version and continue to work for newer versions (they have
> to discard everything they don't understand, of course).
i think this will be quite handy. But:
+ /* actual size of bts_struct in bytes */
+ unsigned short bts_size;
+ /* interface version */
+ unsigned short version;
please dont use shorts. Lets just us bts_size and no version at all, ok?
Any change to the ABI will be extension and that can be done by changing
the size of the data structure. We try to avoid doing versioned APIs in
Linux syscalls.
and while at it, how about using u32/u64 for the fields (that's how we
expose ABIs, even if we know that 'unsigned int' is always 32-bit on
x86), and add support for COMPAT as well?
Ingo
>-----Original Message-----
>From: Ingo Molnar [mailto:[email protected]]
>Sent: Dienstag, 8. Januar 2008 10:50
>please dont use shorts. Lets just us bts_size and no version
>at all, ok?
OK.
We need to be careful to add the positive and negative flag for new
features. Otherwise, we cannot distinguish between the default and the
absence of that feature.
>and while at it, how about using u32/u64 for the fields (that's how we
OK.
>expose ABIs, even if we know that 'unsigned int' is always 32-bit on
>x86), and add support for COMPAT as well?
COMPAT should already work.
regards,
markus.
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.