OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:42 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Spurious interrupt in Bochs?
PostPosted: Sat Nov 27, 2021 3:55 pm 
Offline

Joined: Fri Apr 10, 2009 7:04 am
Posts: 15
Location: The Netherlands
Hi everyone,

I am writing a kernel and when testing things on Bochs my IRQ7 handler started to fire.
I was wondering why, since i don't have written any drivers except for the PIT and PIC. On the PIC i have masked out all the IRQ lines except IRQ0, so i wonder why i get IRQ7 interrupts.
After some research i found out about spurious interrupts, but i don't really understand what is going on and what is causing this to happen.
It only seems to happen on Bochs, not on Qemu or real hardware.

After initialising my kernel, i set up some tasks, schedule the first task, switch the stack and start executing the task via an iret instruction. This also enables interrupts via the EFLAGS value on the stack. After this instruction, the task gets to execute a single instruction and then the IRQ7 fires.

Using the bochs debugger i can check the internal registers of the PIC (see image). The values are the same before and just after the interrupt, all interrupts lines are masked out except IRQ0.

Can anybody explain to me what is going on?


Attachments:
Screenshot from 2021-11-27 22-24-43.png
Screenshot from 2021-11-27 22-24-43.png [ 32.33 KiB | Viewed 1030 times ]
Top
 Profile  
 
 Post subject: Re: Spurious interrupt in Bochs?
PostPosted: Sat Nov 27, 2021 6:58 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
If a device attached to the PIC raises an IRQ and then withdraws the IRQ before the PIC can interrupt the CPU, some chipsets will give you a spurious IRQ instead of ignoring the withdrawn IRQ.

If you've programmed the PIT to keep ticking without waiting for the CPU, it will periodically raise and then withdraw the IRQ. If there's enough time between initializing the PIC and the IRET into the first task, the PIT could raise and then withdraw its IRQ, resulting in an immediate spurious IRQ.

When you enable interrupts via EFLAGS.IF, the CPU executes at least one instruction before responding to any pending interrupts.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Amazonbot [bot], Majestic-12 [Bot], SemrushBot [Bot] and 52 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group