OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 6:44 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: (BOCHS) I/O apic write at unaligned address 0x0000fec00ffc
PostPosted: Sun Aug 20, 2017 4:50 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
calling int 0x80 to issue system call causes the following error message on Bochs:
Message: I/O apic write at unaligned address 0x0000fec00ffc

I've tracked it to the specific 0x80 command that causes the problem. what could be the issue ?

By the way, qemu doesn't output that message.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 5:11 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
What operating system is this happening in? And what system call number? The error message seems to be fairly clear.


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 5:15 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
iansjack wrote:
What operating system is this happening in? And what system call number? The error message seems to be fairly clear.


My operating system, the one that I'm writing :).
The system call number is irrelevant, this occurs even before it get's to the ISR handler.

My guess that it's something regarding TSS or something, because it never occurred when I was working in ring 0.
Now that I switch between ring 3 to ring 0 I encounter this error.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 6:00 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
It's very difficult to make a reasonable suggestion based on almost no information. Can you provide a link to your code repository.

And have you tried single-stepping the code to see exactly what is happening?


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 6:14 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
iansjack wrote:
It's very difficult to make a reasonable suggestion based on almost no information. Can you provide a link to your code repository.

And have you tried single-stepping the code to see exactly what is happening?


Yes. I'm single stepping at assembly level and I get the error immediately after it executes the int 0x80 instruction.

You can follow the code here:
https://github.com/mellowcandle/epOS

relevant parts:

APIC/IOAPIC init code:
https://github.com/mellowcandle/epOS/bl ... nel/apic.c
User space program:
https://github.com/mellowcandle/epOS/bl ... /program.c

Thanks.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 8:43 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
I'm lost. There is no system call in that user program.


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 8:45 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
iansjack wrote:
I'm lost. There is no system call in that user program.

syscall is implemented in libc.
Here's the code:
https://github.com/mellowcandle/epOS/bl ... syscalls.c

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 8:55 am 
Offline
Member
Member

Joined: Fri Aug 19, 2016 10:28 pm
Posts: 360
iansjack wrote:
I'm lost. There is no system call in that user program.
If you recall a few posts earlier, stdcall changed int 0x80 to int 0x40, due to gdb misbehaving :)

stdcall wrote:
calling int 0x80 to issue system call causes the following error message on Bochs:
Message: I/O apic write at unaligned address 0x0000fec00ffc

I've tracked it to the specific 0x80 command that causes the problem. what could be the issue ?
What is relevant is that something is trying to write to the physical address where the I/O APIC registers are located. However, the access is way off. Those registers are accessed indirectly through only like 80 MMIO bytes or so at 0xfec00000. Any access past that would have asserted a few lines later in Boschs's code, because the entire page belongs to the I/O APIC, but should not be accessed past that.

I hoped that it must be either something in your virtual to physical translation or something in your kmalloc. The only way in which this could be relevant to the processing of int 0x40 in and of itself, is if you have configured the kernel stack to that I/O APIC page. Which explains the address (descending from the top of the page, as the CPU tries to push the user context.)

I see that in mem_init total_memory is computed from the longest mmap->len from GRUB, but mmap->addr is not taken into account. It is assumed to coincide with the region where the kernel was loaded. At least to me this seems problematic. Another possible issue, which I have not investigated in detail, is what happens when the explicit memory mappings by mem_page_map overlap virtual memory already allocated by mem_page_map_kernel. But those are just things to look into.


Top
 Profile  
 
 Post subject: Re: (BOCHS) I/O apic write at unaligned address 0x0000fec00f
PostPosted: Sun Aug 20, 2017 9:19 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
simeonz wrote:
I hoped that it must be either something in your virtual to physical translation or something in your kmalloc. The only way in which this could be relevant to the processing of int 0x40 in and of itself, is if you have configured the kernel stack to that I/O APIC page. Which explains the address (descending from the top of the page, as the CPU tries to push the user context.)


You are a genius. by mistake I configured the TSS stack to the kernel stack page start and not to the end of it (stack grows downwards).
Thanks !!!!

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 731 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