Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: Ralf Baechle <ralf@uni-koblenz.de>,
	Harald Koerfgen <hkoerfg@web.de>,
	linux-mips@fnet.fr, linux-mips@oss.sgi.com
Subject: Re: [patch] modutils 2.4.6: Make __dbe_table available to modules
Date: Tue, 14 Aug 2001 00:19:17 +1000	[thread overview]
Message-ID: <15497.997712357@ocs3.ocs-net> (raw)
In-Reply-To: Your message of "Mon, 13 Aug 2001 15:43:56 +0200." <Pine.GSO.3.96.1010813153841.18279H-100000@delta.ds2.pg.gda.pl>

On Mon, 13 Aug 2001 15:43:56 +0200 (MET DST), 
"Maciej W. Rozycki" <macro@ds2.pg.gda.pl> wrote:
> The following patch is needed for modutils to initialize __dbe_table
>table pointers appropriately for modules that want to handle bus error
>exceptions on MIPS.  A separate patch is needed for the kernel.
>
>modutils-2.4.6-mips-dbe.patch
>diff -up --recursive --new-file modutils-2.4.6.macro/include/module.h modutils-2.4.6/include/module.h
>--- modutils-2.4.6.macro/include/module.h	Fri Jan  5 01:45:19 2001
>+++ modutils-2.4.6/include/module.h	Sun Aug 12 13:16:13 2001
>@@ -153,6 +153,10 @@ struct module
>   unsigned tgt_long cleanup;
>   unsigned tgt_long ex_table_start;
>   unsigned tgt_long ex_table_end;
>+#ifdef __mips__
>+  unsigned tgt_long dbe_table_start;
>+  unsigned tgt_long dbe_table_end;
>+#endif
> #ifdef __alpha__
>   unsigned tgt_long gp;
> #endif

Checking dbe table is fine but where you placed the table in struct
modules is wrong.  You must not insert fields in the middle of struct
module, it introduces version skew between kernel and user space.  At
the very least you have moved the can_unload which will break IPv6 plus
a few other modules.

I understand why you placed it before gp, it looks like the place for
arch dependent code.  The alpha specific data is a hangover that should
never have been there.  modutils 2.3.16 added the archdata_start and
archdata_end fields specifically so each architecture did not have to
keep adding fields and causing size mismatch between kernel and
modutils.  IA64 uses those fields for its unwind data, MIPS can use
archdata for whatever it needs in a module.

In modutils, there is an arch_archdata routine for each architecture.
Most just return but obj/obj_ia64.c::arch_archdata actually does
something.  Copy that routine and create a structure containing two
fields, the start and end of the dbe table.  insmod then sets
archdata_start and archdata_end to point to the structure that points
to the dbe table.  Do not put the dbe table directly in
archdata_{start,end} in case you want to add more mips data later.

In the kernel, module.c verifies that archdata_{start,end} are valid,
if present.  It later calls module_arch_init to handle archdata.
include/asm-$(ARCH)/module.h defines macros module_map, module_unmap
and module_arch_init.  MIPS needs to define the last two.
module_arch_init is passed the struct module so it can find the arch
specific data, decode it and do what it likes with the contents.
module_unmap does any arch specific cleanup, such as removing extra
tables.

For dbe tables, define a mips module_arch_init that validates the
format of the arch specific data.  Probably all you need to do is check
that dbe start and end are inside the module.  Unless you copy the dbe
data elsewhere, module_unmap can be left as vfree.

When you want to verify the dbe table, you run the module list.  If
archdata_end >= archdata_start+2*sizeof(struct exception_table_entry *)
then archdata contains the dbe data.  If dbe_table_end > dbe_table_start
then run the table.  Checking > ignores NULL pointers.

The only other change you have to make is to init_modules().  For mips
you create pointers to the kernel dbe tables and fill in archdata start
and end in kernel_module.  Since init_module is called before kmalloc
is ready, make the kernel dbe table a static variable.

  reply	other threads:[~2001-08-13 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-13 13:43 [patch] modutils 2.4.6: Make __dbe_table available to modules Maciej W. Rozycki
2001-08-13 14:19 ` Keith Owens [this message]
2001-08-13 14:49   ` Maciej W. Rozycki
2001-08-13 15:14     ` Keith Owens
2001-08-20 14:04 ` [patch] modutils 2.4.6: __dbe_table iteration #2 Maciej W. Rozycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15497.997712357@ocs3.ocs-net \
    --to=kaos@ocs.com.au \
    --cc=hkoerfg@web.de \
    --cc=linux-mips@fnet.fr \
    --cc=linux-mips@oss.sgi.com \
    --cc=macro@ds2.pg.gda.pl \
    --cc=ralf@uni-koblenz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox