Hello again,
I'm having some more interrupt trouble. I wrote some paging code (heavily based off of JamesM's tutorial yet again - I can always rewrite it later ) and set it up to initialize paging on kernel start before intentionally crashing and causing a page fault. However, I noticed that it wouldn't page fault. After some debugging, I noticed that it wouldn't even call interrupt 14 while page faulting. Furthermore, I noticed I recieved long strings of GPFs when I called an interrupt from the kernel. I don't have any idea where this issue lives - either in the paging code or the interrupt handling code.
If anyone wants to look over the code, you can check it out with Subversion:
"svn co svn://107.170.55.75/root/lilos-rep/v2".
It should be compilable, but you'll need an i686-elf C++ compiler and NASM.
Thanks in advance,
John
GPF while calling a software interrupt
- Mercury1964
- Posts: 13
- Joined: Fri Jul 04, 2014 6:24 pm
- Location: RI
- Contact:
GPF while calling a software interrupt
LilOS - a beautiful mess
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: GPF while calling a software interrupt
If your IDT has the wrong settings, calling an interrupt results in a GPF with the interrupt number in the error code. Invalid GDT entries trigger GPFs as well.Furthermore, I noticed I recieved long strings of GPFs when I called an interrupt from the kernel.
I suppose you haven't run your code in Bochs yet, as it will typically print messages with explanations for surprising errors. Bochs with debugger provides excellent facilities to see what's actually stored in the IDT and GDT, and allows you to single step through.
- Mercury1964
- Posts: 13
- Joined: Fri Jul 04, 2014 6:24 pm
- Location: RI
- Contact:
Re: GPF while calling a software interrupt
OK, I got Bochs working and have a logfile.
Code: Select all
========================================================================
Bochs x86 Emulator 2.4.6
Build from CVS snapshot, on February 22, 2011
Compiled at Jun 8 2013, 05:16:39
========================================================================
00000000000i[ ] LTDL_LIBRARY_PATH not set. using compile time default '/usr/lib/bochs/plugins'
00000000000i[ ] BXSHARE not set. using compile time default '/usr/share/bochs'
00000000000i[ ] reading configuration from bochsrc
00000000000i[ ] lt_dlhandle is 0xa066e90
00000000000i[PLGIN] loaded plugin libbx_sdl.so
00000000000i[ ] installing sdl module as the Bochs GUI
00000000000i[ ] Bochs x86 Emulator 2.4.6
00000000000i[ ] Build from CVS snapshot, on February 22, 2011
00000000000i[ ] Compiled at Jun 8 2013, 05:16:39
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: yes
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] 3dnow! support: no
00000000000i[ ] SEP support: yes
00000000000i[ ] SSE support: sse2
00000000000i[ ] XSAVE support: no
00000000000i[ ] AES support: no
00000000000i[ ] MOVBE support: no
00000000000i[ ] x86-64 support: yes
00000000000i[ ] 1G paging support: no
00000000000i[ ] VMX support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Trace cache support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[ ] Devices configuration
00000000000i[ ] ACPI support: yes
00000000000i[ ] NE2000 support: yes
00000000000i[ ] PCI support: yes, enabled=yes
00000000000i[ ] SB16 support: yes
00000000000i[ ] USB support: yes
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0xb42f4008. after alignment, vector=0xb42f5000
00000000000i[MEM0 ] 32.00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/41472 ('/usr/share/bochs/VGABIOS-lgpl-latest')
00000000000i[ ] lt_dlhandle is 0xa0a4228
00000000000i[PLGIN] loaded plugin libbx_cmos.so
00000000000i[ ] lt_dlhandle is 0xa0a4848
00000000000i[PLGIN] loaded plugin libbx_dma.so
00000000000i[ ] lt_dlhandle is 0xa0a4e88
00000000000i[PLGIN] loaded plugin libbx_pic.so
00000000000i[ ] lt_dlhandle is 0xa0a5388
00000000000i[PLGIN] loaded plugin libbx_pit.so
00000000000i[ ] lt_dlhandle is 0xa0a59d0
00000000000i[PLGIN] loaded plugin libbx_vga.so
00000000000i[ ] lt_dlhandle is 0xa0a5dd8
00000000000i[PLGIN] loaded plugin libbx_hdimage.so
00000000000i[ ] lt_dlhandle is 0xa0a6368
00000000000i[PLGIN] loaded plugin libbx_floppy.so
00000000000i[ ] lt_dlhandle is 0xa0a6b38
00000000000i[PLGIN] loaded plugin libbx_soundmod.so
00000000000i[ ] lt_dlhandle is 0xa0a70d0
00000000000i[PLGIN] loaded plugin libbx_pci.so
00000000000i[ ] lt_dlhandle is 0xa0a77e8
00000000000i[PLGIN] loaded plugin libbx_pci2isa.so
00000000000i[ ] lt_dlhandle is 0xa0a7e48
00000000000i[PLGIN] loaded plugin libbx_usb_common.so
00000000000i[ ] lt_dlhandle is 0xa0a83a0
00000000000i[PLGIN] loaded plugin libbx_unmapped.so
00000000000i[ ] lt_dlhandle is 0xa0a8838
00000000000i[PLGIN] loaded plugin libbx_biosdev.so
00000000000i[ ] lt_dlhandle is 0xa0a8e08
00000000000i[PLGIN] loaded plugin libbx_speaker.so
00000000000i[ ] lt_dlhandle is 0xa0a92f0
00000000000i[PLGIN] loaded plugin libbx_extfpuirq.so
00000000000i[ ] lt_dlhandle is 0xa0a9828
00000000000i[PLGIN] loaded plugin libbx_gameport.so
00000000000i[ ] lt_dlhandle is 0xa0a9d20
00000000000i[PLGIN] loaded plugin libbx_pci_ide.so
00000000000i[ ] lt_dlhandle is 0xa0aa360
00000000000i[PLGIN] loaded plugin libbx_acpi.so
00000000000i[ ] lt_dlhandle is 0xa0aa9a0
00000000000i[PLGIN] loaded plugin libbx_ioapic.so
00000000000i[ ] lt_dlhandle is 0xa0aaf60
00000000000i[PLGIN] loaded plugin libbx_keyboard.so
00000000000i[ ] lt_dlhandle is 0xa0ab578
00000000000i[PLGIN] loaded plugin libbx_harddrv.so
00000000000i[ ] lt_dlhandle is 0xa0bd1e0
00000000000i[PLGIN] loaded plugin libbx_serial.so
00000000000i[ ] lt_dlhandle is 0xa0bdd20
00000000000i[PLGIN] loaded plugin libbx_parallel.so
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Fri Jul 25 12:10:01 2014 (time0=1406304601)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[FDD ] fd0: 'lilos.img' ro=0, h=2,t=80,spt=18
00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[VGA ] interval=50000
00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x00000000000bffff
00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x00000000e0ffffff
00000000000i[VGA ] VBE Bochs Display Extension Enabled
00000000000i[PLGIN] init_dev of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Failed to open /dev/console: Resource temporarily unavailable
00000000000i[SPEAK] Deactivating beep on console
00000000000i[PLGIN] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'gameport' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[PLGIN] init_dev of 'acpi' plugin device by virtual method
00000000000i[PCI ] ACPI Controller present at device 1, function 3
00000000000i[PLGIN] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x00000000fec00fff
00000000000i[PLGIN] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[PLGIN] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] Using boot sequence floppy, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[PLGIN] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[PLGIN] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[PLGIN] register state of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] register state of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] register state of 'speaker' plugin device by virtual method
00000000000i[PLGIN] register state of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] register state of 'gameport' plugin device by virtual method
00000000000i[PLGIN] register state of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] register state of 'acpi' plugin device by virtual method
00000000000i[PLGIN] register state of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] register state of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] register state of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] register state of 'serial' plugin device by virtual method
00000000000i[PLGIN] register state of 'parallel' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 756e6547 6c65746e 49656e69
00000000000i[CPU0 ] CPUID[0x00000001]: 00000f23 00000800 00002000 07cbfbff
00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x00000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000001 2a100800
00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
00000000000i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
00000000000i[PLGIN] reset of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] reset of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] reset of 'speaker' plugin device by virtual method
00000000000i[PLGIN] reset of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] reset of 'gameport' plugin device by virtual method
00000000000i[PLGIN] reset of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] reset of 'acpi' plugin device by virtual method
00000000000i[PLGIN] reset of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] reset of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] reset of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] reset of 'serial' plugin device by virtual method
00000000000i[PLGIN] reset of 'parallel' plugin device by virtual method
00000003305i[BIOS ] $Revision: 1.257 $ $Date: 2011/01/26 09:52:02 $
00000318042i[KBD ] reset-disable command received
00000447872i[VBIOS] VGABios $Id: vgabios.c,v 1.75 2011/10/15 14:07:21 vruppert Exp $
00000447943i[VGA ] VBE known Display Interface b0c0
00000447975i[VGA ] VBE known Display Interface b0c5
00000450900i[VBIOS] VBE Bios $Id: vbe.c,v 1.64 2011/07/19 18:25:05 vruppert Exp $
00000771016i[BIOS ] Starting rombios32
00000771454i[BIOS ] Shutdown flag 0
00000772038i[BIOS ] ram_size=0x02000000
00000772459i[BIOS ] ram_end=32MB
00000813018i[BIOS ] Found 1 cpu(s)
00000828866i[BIOS ] bios_table_addr: 0x000fb928 end=0x000fcc00
00000828960i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001156657i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001484585i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
00001484604i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
00001484623i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
00001484642i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
00001484652i[P2I ] write: ELCR2 = 0x0a
00001485423i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00001493095i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
00001495370i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
00001497484i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
00001497708i[PIDE ] new BM-DMA address: 0xc000
00001498323i[BIOS ] region 4: 0x0000c000
00001500350i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
00001500579i[ACPI ] new irq line = 11
00001500591i[ACPI ] new irq line = 9
00001500616i[ACPI ] new PM base address: 0xb000
00001500630i[ACPI ] new SM base address: 0xb100
00001500658i[PCI ] setting SMRAM control register to 0x4a
00001664751i[CPU0 ] Enter to System Management Mode
00001664761i[CPU0 ] RSM: Resuming from System Management Mode
00001828782i[PCI ] setting SMRAM control register to 0x0a
00001837532i[BIOS ] MP table addr=0x000fba00 MPC table addr=0x000fb930 size=0xd0
00001839346i[BIOS ] SMBIOS table addr=0x000fba10
00001842501i[BIOS ] Firmware waking vector 0x1ff00cc
00001847425i[BIOS ] ACPI tables: RSDP addr=0x000fbb30 ACPI DATA addr=0x01ff0000 size=0x1f18
00001847461i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001848185i[BIOS ] bios_table_cur_addr: 0x000fbb54
00014041548i[BIOS ] Booting from 0000:7c00
00023709243i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
00023714020i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
00023718673i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
00061062059e[CPU0 ] load_seg_reg(DS, 0x1d84): invalid segment
00061223277i[CPU0 ] WARNING: HLT instruction with IF=0!
01273604000i[KBD ] internal keyboard buffer full, ignoring scancode.(9d)
/* a whole bunch of these as I try to exit mouse grab... */
03978200000i[KBD ] internal keyboard buffer full, ignoring scancode.(db)
04341200000p[SDL ] >>PANIC<< User requested shutdown.
04341200000i[CPU0 ] CPU is in protected mode (halted)
04341200000i[CPU0 ] CS.d_b = 32 bit
04341200000i[CPU0 ] SS.d_b = 32 bit
04341200000i[CPU0 ] EFER = 0x00000000
04341200000i[CPU0 ] | RAX=000000000000002e RBX=000000000000000a
04341200000i[CPU0 ] | RCX=000000000010042e RDX=0000000000000784
04341200000i[CPU0 ] | RSP=0000000000108c14 RBP=0000000000101ea7
04341200000i[CPU0 ] | RSI=0000000000000008 RDI=0000000000000010
04341200000i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
04341200000i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
04341200000i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
04341200000i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
04341200000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
04341200000i[CPU0 ] | SEG selector base limit G D
04341200000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
04341200000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
04341200000i[CPU0 ] | MSR_FS_BASE:0000000000000000
04341200000i[CPU0 ] | MSR_GS_BASE:0000000000000000
04341200000i[CPU0 ] | RIP=0000000000101aea (0000000000101aea)
04341200000i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
04341200000i[CPU0 ] | CR3=0x0010a000 CR4=0x00000000
04341200000i[CPU0 ] 0x0000000000101aea>> add esp, 0x0000002c : 83C42C
04341200000i[CMOS ] Last time is 1406305686 (Fri Jul 25 12:28:06 2014)
04341200000i[ ] restoring default signal behavior
04341200000i[CTRL ] quit_sim called with exit code 1
LilOS - a beautiful mess
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: GPF while calling a software interrupt
Oops?Build from CVS snapshot, on February 22, 2011
Code: Select all
00061062059e[CPU0 ] load_seg_reg(DS, 0x1d84): invalid segment
00061223277i[CPU0 ] WARNING: HLT instruction with IF=0!
Assuming you got that particular bochs instance from the (ubuntu?) repositories, it would be a good moment to grab the sources for the latest version, and build a version with the debugger enabled so you can do basic debugging as well.
- Mercury1964
- Posts: 13
- Joined: Fri Jul 04, 2014 6:24 pm
- Location: RI
- Contact:
Re: GPF while calling a software interrupt
I downloaded Bochs from the Ubuntu repos, so that would explain the old build date.
I'm not getting the GPFs anymore. As it would appear, I was doing a lot of unnecessary stack operations in the ISR handler which messed up the DS register. Thanks for pointing it out in the Bochs log.
Now that interrupts work, why doesn't paging? I'm testing it by accessing something way out of the kernel's address space, but it won't pagefault or even call int14. Any ideas?
I'm not getting the GPFs anymore. As it would appear, I was doing a lot of unnecessary stack operations in the ISR handler which messed up the DS register. Thanks for pointing it out in the Bochs log.
Now that interrupts work, why doesn't paging? I'm testing it by accessing something way out of the kernel's address space, but it won't pagefault or even call int14. Any ideas?
LilOS - a beautiful mess