From: Luis Machado Date: Tue, 5 Jan 2021 21:02:32 +0000 (-0300) Subject: Add PTRACE_POKECAP request and move things to a Morello-specific file X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a3eae5bec743f2e7159e5d91b0325d80f0626762;p=thirdparty%2Fbinutils-gdb.git Add PTRACE_POKECAP request and move things to a Morello-specific file gdb/ChangeLog: 2021-01-15 Luis Machado * Makefile.in (HFILES_NO_SRCDIR): Add nat/aarch64-cap-linux.h. * aarch64-linux-nat.c: Include nat/aarch64-cap-linux.h. * nat/aarch64-cap-linux.h: New file. * nat/aarch64-linux.h (struct user_morello_state): Move to nat/aarch64-cap-linux.h. gdbserver/ChangeLog: 2021-01-15 Luis Machado * linux-aarch64-low.cc: Include nat/aarch64-cap-linux.h. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 22beb9b8a6a..760765b6ff3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2021-01-15 Luis Machado + + * Makefile.in (HFILES_NO_SRCDIR): Add nat/aarch64-cap-linux.h. + * aarch64-linux-nat.c: Include nat/aarch64-cap-linux.h. + * nat/aarch64-cap-linux.h: New file. + * nat/aarch64-linux.h (struct user_morello_state): Move to + nat/aarch64-cap-linux.h. + 2021-01-15 Luis Machado * arch/aarch64-cap-linux.h: Fix define name. diff --git a/gdb/Makefile.in b/gdb/Makefile.in index c741ab2853a..48c27aaac39 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1492,6 +1492,7 @@ HFILES_NO_SRCDIR = \ mi/mi-main.h \ mi/mi-out.h \ mi/mi-parse.h \ + nat/aarch64-cap-linux.h \ nat/aarch64-linux.h \ nat/aarch64-linux-hw-point.h \ nat/aarch64-sve-linux-ptrace.h \ diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index d1859c89da4..91130520db8 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -33,6 +33,7 @@ #include "aarch32-tdep.h" #include "arch/arm.h" #include "arch/aarch64-cap-linux.h" +#include "nat/aarch64-cap-linux.h" /* For Morello */ #include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" #include "nat/aarch64-sve-linux-ptrace.h" diff --git a/gdb/nat/aarch64-cap-linux.h b/gdb/nat/aarch64-cap-linux.h new file mode 100644 index 00000000000..2b3c1dc5f3e --- /dev/null +++ b/gdb/nat/aarch64-cap-linux.h @@ -0,0 +1,61 @@ +/* Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef NAT_AARCH64_CAP_LINUX_H +#define NAT_AARCH64_CAP_LINUX_H + +/* Morello-specific requests. */ +#ifndef PTRACE_PEEKCAP +#define PTRACE_PEEKCAP 12 +#endif + +#ifndef PTRACE_POKECAP +#define PTRACE_POKECAP 13 +#endif + +/* Struct defining the layout of the capability register set. */ +struct user_morello_state { + /* General capability registers. */ + unsigned __int128 cregs[31]; + /* Capability program counter. */ + unsigned __int128 pcc; + /* Capability stack pointer. */ + unsigned __int128 csp; + /* Default data capability. */ + unsigned __int128 ddc; + unsigned __int128 ctpidr; + unsigned __int128 rcsp; + unsigned __int128 rddc; + unsigned __int128 rctpidr; + /* Compartment ID register. */ + unsigned __int128 cid; + /* Bitmap storing the tags of all the capability registers. + The tag for register is stored at bit index + MORELLO_PT_TAG_MAP_REG_BIT() in tag_map. */ + uint64_t tag_map; + /* Capability control register. */ + uint64_t cctlr; +}; + +/* Struct used to read/write capabilities using ptrace. */ +struct user_cap { + unsigned __int128 val; + uint8_t tag; + uint8_t __reserved[15]; +}; + +#endif /* NAT_AARCH64_CAP_LINUX_H */ diff --git a/gdb/nat/aarch64-linux.h b/gdb/nat/aarch64-linux.h index 3ac3ac350f4..3c4481a978d 100644 --- a/gdb/nat/aarch64-linux.h +++ b/gdb/nat/aarch64-linux.h @@ -24,30 +24,6 @@ /* Defines ps_err_e, struct ps_prochandle. */ #include "gdb_proc_service.h" -/* Struct defining the layout of the capability register set. */ -struct user_morello_state { - /* General capability registers. */ - unsigned __int128 cregs[31]; - /* Capability program counter. */ - unsigned __int128 pcc; - /* Capability stack pointer. */ - unsigned __int128 csp; - /* Default data capability. */ - unsigned __int128 ddc; - unsigned __int128 ctpidr; - unsigned __int128 rcsp; - unsigned __int128 rddc; - unsigned __int128 rctpidr; - /* Compartment ID register. */ - unsigned __int128 cid; - /* Bitmap storing the tags of all the capability registers. - The tag for register is stored at bit index - MORELLO_PT_TAG_MAP_REG_BIT() in tag_map. */ - uint64_t tag_map; - /* Capability control register. */ - uint64_t cctlr; -}; - typedef int compat_int_t; typedef unsigned int compat_uptr_t; diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog index a0b901b23dd..e4bccab0cd0 100644 --- a/gdbserver/ChangeLog +++ b/gdbserver/ChangeLog @@ -1,3 +1,7 @@ +2021-01-15 Luis Machado + + * linux-aarch64-low.cc: Include nat/aarch64-cap-linux.h. + 2020-11-11 Luis Machado * linux-aarch64-low.cc (aarch64_store_cregset): Invert pcc/csp. diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index d034e783cb2..4fe7e536d18 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -21,6 +21,7 @@ #include "server.h" #include "linux-low.h" +#include "nat/aarch64-cap-linux.h" /* For Morello */ #include "nat/aarch64-linux.h" #include "nat/aarch64-linux-hw-point.h" #include "arch/aarch64-cap-linux.h"