From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id A4B143858CDB for ; Sun, 2 Apr 2023 22:45:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4B143858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj6SV-0005a5-7Z; Sun, 02 Apr 2023 18:45:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=QRklYzLrw6XBJ0o+qXjleD7NaxsW3CosKJbkGDemM9g=; b=nSPKOmtoJCedxlTTb5DN ZzBQbESRKNhI5KGVVpIQGQl+GJ6ENOsqx3TOiAKAlXfs067iulArdaxlre11AnbnwBtXfL3ii7PE4 HxtLzHR6GT2NKXF6ZDe4YZlg5LSUFz6KPI+36IDtD+rTBAiVFWADLwd6igEs5nabcN8o2sIgOxyYV A3O70pTABGwO0jL7EUErT5vQIwIjz+/WRDBd/ewvyjvESGZYujTdAZHcluO7v0GeDDpN2ird3ryOf SAmS2AO2OfOwB2vSsAJcJF+37o+JkwvqPIh9UPmTbPsXR+4Rj7VzO9vNqvKamHI8aAWNIxdHl2dHj RkQpN1Nlo2oc4w==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pj6SU-0007rV-L8; Sun, 02 Apr 2023 18:45:58 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1pj6ST-00ArIi-2A; Mon, 03 Apr 2023 00:45:57 +0200 Date: Mon, 3 Apr 2023 00:45:57 +0200 From: Samuel Thibault To: Sergey Bugaev Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: Re: [RFC PATCH gnumach 03/34] Make exception subcode a long Message-ID: <20230402224557.3cmvy5ztbxr2n7fm@begin> Mail-Followup-To: Sergey Bugaev , libc-alpha@sourceware.org, bug-hurd@gnu.org References: <20230319151017.531737-1-bugaevc@gmail.com> <20230319151017.531737-4-bugaevc@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230319151017.531737-4-bugaevc@gmail.com> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Applied, thanks! Sergey Bugaev, le dim. 19 mars 2023 18:09:46 +0300, a ecrit: > On EXC_BAD_ACCESS, exception subcode is used to pass the faulting memory > address, so it needs to be (at least) pointer-sized. Thus, make it into > a long. > > This requires matching changes in glibc and the Hurd. But the change doesn't affect 32bit glibc and hurd since rpc_long_integer_t is really like integer_t there, right? > --- > > NOTE: Most of this was a pretty mechanical change, but I'm not very sure > I got the exc_subcode_proto right; please do check. > > doc/mach.texi | 4 ++-- > i386/i386/trap.c | 2 +- > i386/i386/trap.h | 2 +- > include/mach/exc.defs | 2 +- > kern/exception.c | 40 ++++++++++++++++++++++++++++------------ > kern/exception.h | 6 +++--- > kern/thread.h | 2 +- > 7 files changed, 37 insertions(+), 21 deletions(-) > > diff --git a/doc/mach.texi b/doc/mach.texi > index 2c22fa38..fdc36d45 100644 > --- a/doc/mach.texi > +++ b/doc/mach.texi > @@ -4830,11 +4830,11 @@ argument set to @code{THREAD_EXCEPTION_PORT}. > @node Exceptions > @subsection Exceptions > > -@deftypefun kern_return_t catch_exception_raise (@w{mach_port_t @var{exception_port}}, @w{thread_t @var{thread}}, @w{task_t @var{task}}, @w{int @var{exception}}, @w{int @var{code}}, @w{int @var{subcode}}) > +@deftypefun kern_return_t catch_exception_raise (@w{mach_port_t @var{exception_port}}, @w{thread_t @var{thread}}, @w{task_t @var{task}}, @w{int @var{exception}}, @w{int @var{code}}, @w{long @var{subcode}}) > XXX Fixme > @end deftypefun > > -@deftypefun kern_return_t exception_raise (@w{mach_port_t @var{exception_port}}, @w{mach_port_t @var{thread}}, @w{mach_port_t @var{task}}, @w{integer_t @var{exception}}, @w{integer_t @var{code}}, @w{integer_t @var{subcode}}) > +@deftypefun kern_return_t exception_raise (@w{mach_port_t @var{exception_port}}, @w{mach_port_t @var{thread}}, @w{mach_port_t @var{task}}, @w{integer_t @var{exception}}, @w{integer_t @var{code}}, @w{long_integer_t @var{subcode}}) > XXX Fixme > @end deftypefun > > diff --git a/i386/i386/trap.c b/i386/i386/trap.c > index 34ccb6a5..f7bd8e38 100644 > --- a/i386/i386/trap.c > +++ b/i386/i386/trap.c > @@ -628,7 +628,7 @@ void > i386_exception( > int exc, > int code, > - int subcode) > + long subcode) > { > spl_t s; > > diff --git a/i386/i386/trap.h b/i386/i386/trap.h > index d9df7afa..e82164d0 100644 > --- a/i386/i386/trap.h > +++ b/i386/i386/trap.h > @@ -40,7 +40,7 @@ void > i386_exception( > int exc, > int code, > - int subcode) __attribute__ ((noreturn)); > + long subcode) __attribute__ ((noreturn)); > > extern void > thread_kdb_return(void); > diff --git a/include/mach/exc.defs b/include/mach/exc.defs > index 94af828c..28638e2f 100644 > --- a/include/mach/exc.defs > +++ b/include/mach/exc.defs > @@ -44,4 +44,4 @@ routine exception_raise( > task : mach_port_t; > exception : integer_t; > code : integer_t; > - subcode : integer_t); > + subcode : rpc_long_integer_t); > diff --git a/kern/exception.c b/kern/exception.c > index 1014b3ed..10435b5c 100644 > --- a/kern/exception.c > +++ b/kern/exception.c > @@ -85,9 +85,9 @@ boolean_t debug_user_with_kdb = FALSE; > > void > exception( > - integer_t _exception, > - integer_t code, > - integer_t subcode) > + integer_t _exception, > + integer_t code, > + long_integer_t subcode) > { > ipc_thread_t self = current_thread(); > ipc_port_t exc_port; > @@ -157,9 +157,9 @@ exception( > > void > exception_try_task( > - integer_t _exception, > - integer_t code, > - integer_t subcode) > + integer_t _exception, > + integer_t code, > + long_integer_t subcode) > { > ipc_thread_t self = current_thread(); > task_t task = self->task; > @@ -277,11 +277,17 @@ struct mach_exception { > mach_msg_type_t codeType; > integer_t code; > mach_msg_type_t subcodeType; > - integer_t subcode; > + rpc_long_integer_t subcode; > }; > > #define INTEGER_T_SIZE_IN_BITS (8 * sizeof(integer_t)) > #define INTEGER_T_TYPE MACH_MSG_TYPE_INTEGER_T > +#define RPC_LONG_INTEGER_T_SIZE_IN_BITS (8 * sizeof(rpc_long_integer_t)) > +#if defined(__x86_64__) && !defined(USER32) > +#define RPC_LONG_INTEGER_T_TYPE MACH_MSG_TYPE_INTEGER_64 > +#else > +#define RPC_LONG_INTEGER_T_TYPE MACH_MSG_TYPE_INTEGER_32 > +#endif > /* in mach/machine/vm_types.h */ > > mach_msg_type_t exc_port_proto = { > @@ -304,6 +310,16 @@ mach_msg_type_t exc_code_proto = { > /* msgt_unused = */ 0 > }; > > +mach_msg_type_t exc_subcode_proto = { > + /* msgt_name = */ RPC_LONG_INTEGER_T_TYPE, > + /* msgt_size = */ RPC_LONG_INTEGER_T_SIZE_IN_BITS, > + /* msgt_number = */ 1, > + /* msgt_inline = */ TRUE, > + /* msgt_longform = */ FALSE, > + /* msgt_deallocate = */ FALSE, > + /* msgt_unused = */ 0 > +}; > + > /* > * Routine: exception_raise > * Purpose: > @@ -329,9 +345,9 @@ exception_raise( > ipc_port_t dest_port, > ipc_port_t thread_port, > ipc_port_t task_port, > - integer_t _exception, > - integer_t code, > - integer_t subcode) > + integer_t _exception, > + integer_t code, > + long_integer_t subcode) > { > ipc_thread_t self = current_thread(); > ipc_thread_t receiver; > @@ -521,7 +537,7 @@ exception_raise( > exc->exception = _exception; > exc->codeType = exc_code_proto; > exc->code = code; > - exc->subcodeType = exc_code_proto; > + exc->subcodeType = exc_subcode_proto; > exc->subcode = subcode; > > /* > @@ -725,7 +741,7 @@ exception_raise( > exc->exception = _exception; > exc->codeType = exc_code_proto; > exc->code = code; > - exc->subcodeType = exc_code_proto; > + exc->subcodeType = exc_subcode_proto; > exc->subcode = subcode; > > ipc_mqueue_send_always(kmsg); > diff --git a/kern/exception.h b/kern/exception.h > index 55902dd1..36138da8 100644 > --- a/kern/exception.h > +++ b/kern/exception.h > @@ -26,13 +26,13 @@ extern void > exception( > integer_t _exception, > integer_t code, > - integer_t subcode) __attribute__ ((noreturn)); > + long_integer_t subcode) __attribute__ ((noreturn)); > > extern void > exception_try_task( > integer_t _exception, > integer_t code, > - integer_t subcode) __attribute__ ((noreturn)); > + long_integer_t subcode) __attribute__ ((noreturn)); > > extern void > exception_no_server(void) __attribute__ ((noreturn)); > @@ -44,7 +44,7 @@ exception_raise( > ipc_port_t task_port, > integer_t _exception, > integer_t code, > - integer_t subcode) __attribute__ ((noreturn)); > + long_integer_t subcode) __attribute__ ((noreturn)); > > extern kern_return_t > exception_parse_reply(ipc_kmsg_t kmsg); > diff --git a/kern/thread.h b/kern/thread.h > index f8989f45..3485f6af 100644 > --- a/kern/thread.h > +++ b/kern/thread.h > @@ -190,7 +190,7 @@ struct thread { > struct ipc_port *port; > int exc; > int code; > - int subcode; > + long subcode; > } exception; > void *other; /* catch-all for other state */ > } saved; > -- > 2.39.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.