Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: [matt-nb5-mips64] src/sys

I think this broke core dumps on mips ...

On Sun, Aug 23, 2009 at 03:38:19AM +0000, Matt Thomas wrote:
> Module Name:  src
> Committed By: matt
> Date:         Sun Aug 23 03:38:19 UTC 2009
> Modified Files:
>       src/sys/arch/mips/include [matt-nb5-mips64]: types.h
>       src/sys/arch/mips/mips [matt-nb5-mips64]: mips_machdep.c
>           process_machdep.c
>       src/sys/kern [matt-nb5-mips64]: core_elf32.c sys_process.c
>       src/sys/sys [matt-nb5-mips64]: ptrace.h
> Log Message:
> Change lazy fp load/save is done.  fpcurlwp is never NULL.
> If no current lwp has the FP, then fpcurlwp is set to lwp0.
> this allows many check for NULL and avoids a few null-derefs.
> Since savefpregs clear COP1, loadfpregs can be called to reload
> fpregs.  If it notices that situation, it just sets COP1 and returns
> Save does not reset fpcurlwp, just clears COP1.  load does set fpcurlwp.
> If MIPS3_SR_FR is set, all 32 64-bit FP registers are saved/restored via Xdc1.
> If MIPS3_SR_FR is clear, only 32 32-bit FP register are saved/restore via 
> Xwc1.
> This preserves the existing ABI.
> To generate a diff of this commit:
> cvs rdiff -u -r1.43.36.2 -r1.43.36.3 src/sys/arch/mips/include/types.h
> cvs rdiff -u -r1. -r1. \
>     src/sys/arch/mips/mips/mips_machdep.c
> cvs rdiff -u -r1.29.62.1 -r1.29.62.2 src/sys/arch/mips/mips/process_machdep.c
> cvs rdiff -u -r1.32.16.1 -r1.32.16.2 src/sys/kern/core_elf32.c
> cvs rdiff -u -r1.143.4.1 -r1. src/sys/kern/sys_process.c
> cvs rdiff -u -r1.40 -r1.40.28.1 src/sys/sys/ptrace.h
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.

The change to core_elf32.c is mostly:

@@ -452,14 +456,19 @@ ELFNAMEEND(coredump_note)(struct proc *p
        notesize = sizeof(nhdr) + elfround(namesize) + elfround(sizeof(freg));
        if (iocookie) {
+               size_t freglen = sizeof(freg);
+               error = elf_process_read_xfpregs(l, &freg, &freglen);
                error = elf_process_read_fpregs(l, &freg);
                if (error)
                        return (error);
                nhdr.n_namesz = namesize;
-               nhdr.n_descsz = sizeof(freg);
+               nhdr.n_descsz = freglen;
                nhdr.n_type = PT_GETFPREGS;

                error = ELFNAMEEND(coredump_writenote)(p, iocookie, &nhdr,

However this code is called twice, once with iocookie == NULL in order
to find out how big everything will be, then again with iocookie != NULL
to actually do the writes.

So changing the size of the register area on the second pass is going to
lead to corrupt core files.


David Laight:

Home | Main Index | Thread Index | Old Index