OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Double fault after initialize local apic
PostPosted: Fri Nov 19, 2021 1:57 pm 
Offline

Joined: Fri Nov 12, 2021 1:09 am
Posts: 12
I've met a double fault after I initialized local apic and execute sti() instruction. What I did to initialize local apic is:

1. enable xapic and x2apic
2. enable local apic
3. mask all LVT registers (since my CPU platform is Pentium 4, it only has 6 LVT registers)

here is my code to mask all LVT register:
Code:
__asm__ __volatile__(
      "movq $0x832,%%rcx   \n\t"//mask LVT Timer register
      "wrmsr            \n\t"
      "movq $0x833,%%rcx   \n\t"//mask LVT Thermal Sensor register
      "wrmsr            \n\t"
      "movq $0x834,%%rcx   \n\t"//mask LVT Performance Monitoring register
      "wrmsr            \n\t"
      "movq $0x835,%%rcx   \n\t"//mask LVT LINT0 register
      "wrmsr            \n\t"
      "movq $0x836,%%rcx   \n\t"//mask LVT LINT1 register
      "wrmsr            \n\t"
      "movq $0x837,%%rcx   \n\t"//mask LVT Error register
      "wrmsr            \n\t"
      :
      :"a"(0x10000),"d"(0x00)
      :
      );

(I know it looks a little bit silly to use a lot of embedded assembly, but I just want to take a test over local apic)

After that, I execute sti() to set IF eflags to 1 and got a double fault. I suppose all the interrupt received by local apic was masked through LVT, but where did the first interrupt of double fault come from?


Top
 Profile  
 
 Post subject: Re: Double fault after initialize local apic
PostPosted: Fri Nov 19, 2021 2:22 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Have you initialized (and disabled) the 8259 PIC pair? In the BIOS compatible configuration, the timer interrupt happens to be on INT 8, which is the double fault exception.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Double fault after initialize local apic
PostPosted: Fri Nov 19, 2021 4:14 pm 
Offline

Joined: Fri Nov 12, 2021 1:09 am
Posts: 12
nullplan wrote:
Have you initialized (and disabled) the 8259 PIC pair? In the BIOS compatible configuration, the timer interrupt happens to be on INT 8, which is the double fault exception.

Yes, I've already disabled 8259 pic before setup my apic. And also, I've set the idt entries with vector numbers 0-20 to default exception and 32-55 with the interrupt handler, but it still turns out a double fault.


Top
 Profile  
 
 Post subject: Re: Double fault after initialize local apic
PostPosted: Fri Nov 19, 2021 6:39 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
michael wrote:
here is my code to mask all LVT register:

Your inline assembly clobbers RCX. This can cause other code to misbehave for no apparent reason.

Add RCX to the clobber list or write a wrmsr() function.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 58 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