Comments (7)
Hmm, what is the error code of the exception? It should be the selector of the present entry.
from x86_64.
The error code as given by the function argument is 0x802
.
from x86_64.
Ok, I think I found the problem. The IDT struct looks like this:
pub struct Idt {
pub divide_by_zero: IdtEntry<HandlerFunc>,
pub debug: IdtEntry<HandlerFunc>,
[…]
pub interrupts: [IdtEntry<HandlerFunc>; 224],
// some fields omitted
}
So we have special cases for the first 32 interrupts, which means that the interrupts
field starts at index 32. So try doing idt.interrupts[0x80 - 32].set_handler_fn(syscall::syscall_handler)
instead.
This seems like a huge pitfall, so I think we should look for a better solution, or at least document it explicitly.
from x86_64.
This works, thanks. Weird that this has to be done though. Maybe we could modify the Index implementations to account for this? As a side note: In my kernel I have remapped the PICs to 0x20
and 0x28
, and have no trouble thus registering the timer and keyboard IRQs to the first and second indices of the interrupts
field. I'm assuming this bug won't affect IRQs given that the PIC sends interrupts to the CPU separately.
from x86_64.
This works, thanks.
Great!
Weird that this has to be done though. Maybe we could modify the Index implementations to account for this?
The problem is that we want to special case interrupts 0-32, since they have fixed meaning and some of them have an additional error code (which means they have a different type). If we would change the index implementation of the interrupts
field, then we would have to issue a runtime panic for indices smaller than 32, which is not ideal either (but maybe better?).
As a side note: In my kernel I have remapped the PICs to 0x20 and 0x28, and have no trouble thus registering the timer and keyboard IRQs to the first and second indices of the interrupts field. I'm assuming this bug won't affect IRQs given that the PIC sends interrupts to the CPU separately.
This "affects" neither software nor hardware interrupts, it's just a different numbering convention. So your int 0x80
goes to the 0x80
s entry in the IDT, which is the 0x80-32
s entry in the interrupts
array. Equally, your timer interrupt goes to entry 0x20
(due to the PIC remapping), which is the 0x20-32=0
s entry in the interrupt array.
from x86_64.
Ah I see, makes sense. Thanks.
from x86_64.
Note to future readers:
The interrupts field on the Idt struct is no longer public, and an Index and IndexMut impl was added for Idt. This means idt.interrupts[0x80 - 32].set_handler_fn(syscall::syscall_handler)
should now be expressed as idt[0x80].set_handler_fn(syscall::syscall_handler)
.
from x86_64.
Related Issues (20)
- Set minimal scoped permissions to github workflow HOT 1
- Create a Security Policy
- Mutable references in page table implementation? HOT 1
- IDT and page table code causing trouble in Confidential Computing space HOT 1
- Hash pin workflow dependencies HOT 9
- `Descriptor::tss_segment` too restrictive? HOT 2
- recursive page table with recursive index 511 is unsound HOT 7
- How can I set 2MiB page frame in my Page Directory Table? HOT 1
- How do I map to a virtualized physical address? HOT 1
- Enable OpenSSF Scorecard Action HOT 2
- [Question] Is there a reason to not support pagemaps level 5 ? HOT 2
- Trait for Entry handler function types? HOT 2
- Should we add an register abstraction? How should it work with and ?
- `VirtAddr` arithmetic may panic HOT 2
- Returning FrameAlreadyMapped error when it shouldn't HOT 10
- Should have a way to construct an `InterruptStackFrameValue`? HOT 3
- A `VirtualAddr` panic is triggered when the page table called `clean_up` HOT 3
- `Sealed::DEBUG_STR` is publicly accessible HOT 10
- PageTable: Handling of pages without the present flag set HOT 2
- `Mapper::unmap` should be unsafe HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x86_64.