Commit Graph

9030 Commits

Author SHA1 Message Date
joerg
456d311f26 Try to reserve space in a way that results in the same allocation for
both LLVM and GNU as.
2014-01-12 20:31:50 +00:00
tsutsui
8c436a9898 Add empty LIBCRTI= as LIBCRT0 to build sa programs without installed DESTDIR.
XXX: probabry we should have bsd.saprog.mk or something.
2014-01-12 15:26:28 +00:00
christos
09f4588963 stop ddb backtrace at Xsoftintr() (Richard Hansen)
Stop unwinding frames when db_stack_trace_print() encouters
Xsoftintr().  This avoids a recursive panic() due to an invalid
pointer dereference when a software interrupt panic()s.

Here's what happens without this change:

When db_stack_trace_print() runs during a panic() and db_nextframe()
encounters the Xsoftintr() frame, db_nextframe() does the following at
db_machdep.c:292:

  1. checks to see if there's a Xsoftintr() symbol (there is)
  2. checks to see if the frame corresponds to an interrupt (the
     symbol name begins with "Xsoft" so it does)

If both of the above are true (they are), db_nextframe() at
db_machdep.c:303 tries to get a pointer to a struct intrframe.
According to the comment at line 300, the second argument passed to
Xsoftintr() is a pointer to a struct intrframe.  However, the comment
and the corresponding code are not correct -- Xsoftintr() doesn't take
any arguments[1].  Attempting to fetch the second argument only yields
stack garbage, not a struct intrframe.  This causes db_machdep.c:307
to dereference a bad pointer, triggering the recursive panic().

[1] Xsoftintr() is called by Xspllower() which is called by splx()
    a.k.a. spllower().  Neither Xspllower() nor Xsoftintr() set up a
    standard frame when called (they don't do 'pushl %ebp; movl %esp,
    %ebp'), so Xsoftintr()'s %ebp is the same as splx()'s %ebp.  This
    makes splx()'s arguments look like Xsoftintr()'s arguments, and
    splx() does not take any arguments.

You can reproduce the recursive panic by reverting this change and
adding a call to panic() inside ipintr().  The backtrace will look
like the following (the line numbers you see might differ from these
line numbers -- this backtrace was generated from a slightly modified
version of the NetBSD 6.1 kernel):

    #0  vpanic (fmt=0xc0ba995b "trap", ap=0xdaa51730) at /usr/src/sys/kern/subr_prf.c:211
    #1  0xc0790529 in panic (fmt=0xc0ba995b "trap") at /usr/src/sys/kern/subr_prf.c:205
    #2  0xc07decbc in trap (frame=0xdaa517c0) at /usr/src/sys/arch/i386/i386/trap.c:396
    #3  0xc010cf48 in ?? () at /usr/src/sys/arch/i386/i386/vector.S:983
    #4  0xc02857f0 in db_get_value (addr=56, size=4, is_signed=false) at /usr/src/sys/ddb/db_access.c:72
    #5  0xc028a09a in db_nextframe (nextframe=0xdaa51b40, retaddr=0xdaa51b3c, arg0=0xdaa51b38, ip=0xdaa51b34, argp=0xdaa51d88, is_trap=0, pr=0xc07901b5 <printf>) at /usr/src/sys/arch/i386/i386/db_machdep.c:308
    #6  0xc028be2b in db_stack_trace_print (addr=<optimized out>, have_addr=true, count=65533, modif=0xc0bb44bf "", pr=0xc07901b5 <printf>) at /usr/src/sys/arch/x86/x86/db_trace.c:275
    #7  0xc07903cb in vpanic (fmt=0xc0b6ba76 "testing", ap=0xdaa51d4c) at /usr/src/sys/kern/subr_prf.c:296
    #8  0xc0790529 in panic (fmt=0xc0b6ba76 "testing") at /usr/src/sys/kern/subr_prf.c:205
    #9  0xc04e3d4f in ipintr () at /usr/src/sys/netinet/ip_input.c:369
    #10 0xc054ac0d in softint_execute (s=<optimized out>, si=<optimized out>, l=<optimized out>) at /usr/src/sys/kern/kern_softint.c:543
    #11 softint_dispatch (pinned=0xc4085560, s=4) at /usr/src/sys/kern/kern_softint.c:825
    #12 0xc0100fdb in ?? () at /usr/src/sys/arch/i386/i386/spl.S:390
    #13 0xc07d2e11 in tcp_usrreq (so=0xc40b0534, req=4, m=0x0, nam=0xc317ba00, control=0x0, l=0xc4085560) at /usr/src/sys/netinet/tcp_usrreq.c:615
    #14 0xc04bb300 in tcp_usrreq_wrapper (a=0xc40b0534, b=4, c=0x0, d=0xc317ba00, e=0x0, f=0xc4085560) at /usr/src/sys/netinet/in_proto.c:164
    #15 0xc0839006 in soconnect (so=0xc40b0534, nam=0xc317ba00, l=0xc4085560) at /usr/src/sys/kern/uipc_socket.c:821
    #16 0xc083c4ce in do_sys_connect (l=0xc4085560, fd=4, nam=0xc317ba00) at /usr/src/sys/kern/uipc_syscalls.c:371
    #17 0xc083dbeb in sys_connect (l=0xc4085560, uap=0xdbc27d00, retval=0xdbc27d28) at /usr/src/sys/kern/uipc_syscalls.c:350
    #18 0xc07b1b4a in sy_call (rval=0xdbc27d28, uap=0xdbc27d00, l=0xc4085560, sy=0xc0c2f018) at /usr/src/sys/sys/syscallvar.h:61
    #19 syscall (frame=0xdbc27d48) at /usr/src/sys/arch/x86/x86/syscall.c:179
    #20 0xc010056d in ?? () at /usr/src/sys/arch/i386/i386/locore.S:1160
    Backtrace stopped: previous frame inner to this frame (corrupt stack?)
2014-01-11 17:11:50 +00:00
christos
bf0a60cb4a remove vestige from old call to printk()
This line was introduced with a call to printk() in CVS revision
1.22.4.3 and should have been removed when the call to printk() was
removed in CVS revision 1.22.4.6.  (Richard Hansen)
2014-01-11 17:06:15 +00:00
christos
fb4d88d5dd fix a comment (cpu_switch() -> cpu_switchto()) (Richard Hansen) 2014-01-11 17:05:17 +00:00
jakllsch
f5ce59053c fix style and whitespace nits 2014-01-10 17:40:51 +00:00
pedro
3089b1af6a Fix a comment describing the check performed by copyin(); the value
checked against VM_MAXUSER_ADDRESS is derived from the source address,
not the destination address. OK rmind@.
2014-01-10 16:47:07 +00:00
dholland
586505dce8 Make the amd64 post-halt-press-a-key code match i386, and introduce
into both a message for the case where cngetc() doesn't work. If
there's no console attached, this won't accomplish anything; but if
there's a screen but no keyboard, or the keyboard's wedged, or
whatever, it might provide useful information.

Suggested back in 2009 by some stuff in PR 37924 and has been hanging
about in one of my trees ever since.
2014-01-09 00:57:25 +00:00
jakllsch
3f412a1c4c Make name argument to module_add_common const; use this to allow the libsa
fsmod string to soon become const.
2014-01-05 21:36:50 +00:00
jakllsch
7cf250db21 No need to return a empty string literal of the wrong const-ness when we
already have a empty string of the correct const-ness.
2014-01-05 20:52:57 +00:00
jakllsch
327f70c7e1 don't shadow local variable 2014-01-05 20:49:20 +00:00
christos
ea7d4d717c undo the linker script hack now that the linker scripts do this. 2014-01-04 20:18:50 +00:00
dsl
95739e63cd Remove __HAVE_PROCESS_XFPREGS and add the extra parameter for the size
of the fp save area to all the process_read_fpregs() and
  process_write_fpregs() functions.
None of the functions have been modified to use the new parameters.
The size is set for all the writes, but some of the arch-specific reads
  just pass NULL.
The amd64 (and i386) need variable sized fp register save areas in order
  to support AVX and other enhanced register areas.
These functions are rarely called - so the extra argument won't matter.
2014-01-04 00:10:02 +00:00
christos
a791c1b86a remove commented out -fno-reorder-functions 2014-01-01 22:07:54 +00:00
christos
f211905aff Use a custom ldscript so that we can keep boot_start at 0. 2014-01-01 22:06:13 +00:00
christos
eb2d28f6ce Provide a boot ldscript that puts the text.unlikely section after the text
section so that boot_start gets placed first. We also set the entry and the
start address, although we still override them from the command line.
This is a copy of elf_i386.xbn
2014-01-01 22:05:48 +00:00
jakllsch
ba3004d138 Zero out on-stack 'marks' array before first use.
This is needed so the MARK_DATA index is properly filled in.
2013-12-30 21:45:51 +00:00
jakllsch
28bbad2d7d Obtain CR0_PE constant from <x86/specialreg.h> rather than a local #define. 2013-12-24 19:00:56 +00:00
dsl
63182a7c15 Include machine/npx.h here.
The only file that needs 'struct freebsd_save87' includes it already.
2013-12-09 17:39:53 +00:00
dsl
e3332f3a4a Rename the fields of 'struct envxmm' (itself badly named) so that they
are different from those used for the x87 fpu.
Use a union to describe the 64bit 'address' field so that it correctly
  spilt for 32bit binaries.
The freebsd emulation defined its own 'struct freebsd_env87' that the
  code just assumed matched the netbsd one.
  Since this is a hardware structure, just use the netbsd one.
This shouldn't change the binaries except that 'en_fos' used to be
  incorrectly a 32bit field.
2013-12-08 20:45:30 +00:00
christos
f0ceb57840 revert fpu/pcu changes until we figure out what's wrong; they cause random
freezes
2013-12-01 01:05:16 +00:00
jakllsch
638fb1b218 Use the size of what's at the bootinfo_userconf pointer, not the size
of the pointer itself.
2013-11-27 18:29:45 +00:00
jakllsch
9c656bb681 The x86 kernel entry point stack arguments are always 32-bit, even on amd64. 2013-11-24 17:20:00 +00:00
jakllsch
156a3d4cd5 use <i386/multiboot.h> instead of <machine/multiboot.h> so this can be
compiled for amd64
2013-11-24 17:17:48 +00:00
jakllsch
960017fd29 cast from 32-bit integer to void * though uintptr_t to avoid warnings
when compiling for x86_64.
2013-11-24 17:16:28 +00:00
riz
7549ebb3be Add RAID_DIAGNOSTIC so that code gets built.
ok oster@
2013-11-23 23:36:34 +00:00
riz
30ecc3610e Comment out npf for now, as we can't have both NPF and PF in the
same kernel - rmind has said he'll address this eventually,
and for now PF is more likely to have unnoticed breakage.  ALL now
builds again!
2013-11-22 18:58:01 +00:00
riz
bad09cf5aa Include i386_trap_ipkdb.S so the ALL kernel links. 2013-11-22 01:09:11 +00:00
riz
21d7553eda Remove stray #ifdef leftover from file split. 2013-11-22 01:07:20 +00:00
riz
202195d3c2 CPUID2FAMILY was renamed to CPUID_TO_FAMILY, apparently this usage was
missed.
2013-11-21 22:04:40 +00:00
jakllsch
aa37094d90 Bring arch/i386/stand bootinfo structure in line with the kernel's
fixed-layout understanding of it.
2013-11-18 03:52:45 +00:00
alnsn
988b97e4aa Always define SLJIT_CACHE_FLUSH(), start include guards with '_' and use _LP64 guard. 2013-11-17 12:01:58 +00:00
joerg
70f0cfa164 NetBSD 6.99.26: Switch i386 and amd64 to the x87 default control word
as initial value for new processes. This means that long double
computations get the expected 63bit mantissa. Binaries tagged as
compiled for 6.99.25 and older get the old value.

Add a simple test case to ensure that double and long double computation
are working correctly.
2013-11-11 11:10:45 +00:00
christos
8b0b2b2c69 fix unused variable warnings 2013-11-08 03:12:17 +00:00
christos
7d82f49661 Fix unused variable warnings 2013-11-08 02:24:11 +00:00
christos
6de650fa02 provide an ldscript for booters that strips the unwind sections.
XXX: untested
2013-11-01 00:19:04 +00:00
christos
89392a8d06 provide an ldscript to strip the unwind sections
XXX: untested
2013-11-01 00:18:24 +00:00
christos
c4b3b5ae3a avoid pointer aliasing problems. 2013-10-31 20:31:04 +00:00
nonaka
87abaea977 Add driver for ASIX AX88178a and AX88179 Ethernet interface.
Ported from OpenBSD.
2013-10-26 09:16:19 +00:00
drochner
23780ff8df Use the MI "pcu" framework for bookkeeping of npx/fpu states on x86.
This reduces the amount of MD code enormously, and makes it easier
to implement support for newer CPU features which require more fpu
state, or for fpu usage by the kernel.
For access to FPU state across CPUs, an xcall kthread is used now
rather than a dedicated IPI.
No user visible changes intended.
2013-10-23 20:18:50 +00:00
matt
ab590461f8 Add xhci device 2013-10-23 17:22:49 +00:00
christos
9b0681b6d3 remove unused variable 2013-10-20 21:06:37 +00:00
christos
98d16a5918 Revert previous code move to accommodate relocation that does not fit.
Move pxe_command_buf declaration next to the code so
that it fits on the 16 bit relocation. It is in the text segment, but
it does not matter since it is mapped read-write.
2013-10-20 19:47:28 +00:00
christos
9f1223fca3 Move an instruction above .code16 so that it produces an R_386_32 instead
of an R_386_16 relocation, which is truncated to fit. XXX: untested.
2013-10-20 00:16:16 +00:00
riz
6ec333eb37 Catch up to recent changes in config_pending_{incr,decr}(). 2013-10-13 06:55:34 +00:00
jakllsch
e32de526f8 Use the universal pciide_detach() for detach function of all remaining
pciide-core drivers, except pciide at pnpbios which isn't actually PCI.
2013-10-07 19:51:55 +00:00
jakllsch
711bc88750 Add xhci(4). 2013-09-14 00:42:21 +00:00
joerg
4d12bfcd15 Pass PICFLAGS down to cc-as-as and use __PIC__ to decide if it is small
vs big PIC mode. Retire -DPIC and -DBIGPIC.
2013-09-12 15:36:14 +00:00
joerg
9b315b031e Overwrite PIE_*, otherwise bootxx_cd9660 is not recognized by
installboot in MKPIE=yes builds.
2013-09-12 05:54:38 +00:00
jmcneill
fef2fc66c9 Bump bootloader version for memory disk image changes. 2013-08-30 16:43:33 +00:00