diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md index a638d1e3..854fbc1c 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/01-catching-exceptions/index.md @@ -15,7 +15,10 @@ As always, the complete source code is on [Github]. Please file [issues] for any [Github]: https://github.com/phil-opp/blog_os/tree/catching_exceptions [issues]: https://github.com/phil-opp/blog_os/issues -> **Note**: This post describes how to handle exceptions using naked functions (see “Handling Exceptions with Naked Functions” for an overview). Our new way of handling exceptions can be found in the “Handling Exceptions” post. +> **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. + +[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Exceptions An exception signals that something is wrong with the current instruction. For example, the CPU issues an exception if the current instruction tries to divide by 0. When an exception occurs, the CPU interrupts its current work and immediately calls a specific exception handler function, depending on the exception type. diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md index 66d6f606..ab9bda0c 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/02-better-exception-messages/index.md @@ -10,14 +10,16 @@ In this post, we explore exceptions in more detail. Our goal is to print additio -As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. +As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a comment section at the end of this page. [Github]: https://github.com/phil-opp/blog_os/tree/better_exception_messages [issues]: https://github.com/phil-opp/blog_os/issues [gitter chat]: https://gitter.im/phil-opp/blog_os -[comment section]: #disqus_thread -> **Note**: This post describes how to handle exceptions using naked functions (see “Handling Exceptions with Naked Functions” for an overview). Our new way of handling exceptions can be found in the “Handling Exceptions” post. +> **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. + +[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Exceptions in Detail An exception signals that something is wrong with the currently-executed instruction. Whenever an exception occurs, the CPU interrupts its current work and starts an internal exception routine. diff --git a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md b/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md index 98c72900..37720ebb 100644 --- a/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md +++ b/blog/content/extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md @@ -10,14 +10,16 @@ In this post, we learn how to return from exceptions correctly. In the course of -As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. +As always, the complete source code is on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a comment section at the end of this page. [Github]: https://github.com/phil-opp/blog_os/tree/returning_from_exceptions [issues]: https://github.com/phil-opp/blog_os/issues [gitter chat]: https://gitter.im/phil-opp/blog_os -[comment section]: #disqus_thread -> **Note**: This post describes how to handle exceptions using naked functions (see “Handling Exceptions with Naked Functions” for an overview). Our new way of handling exceptions can be found in the “Handling Exceptions” post. +> **Note**: This post describes how to handle exceptions using naked functions (see [“Handling Exceptions with Naked Functions”] for an overview). Our new way of handling exceptions can be found in the [“Handling Exceptions”] post. + +[“Handling Exceptions with Naked Functions”]: ./extra/handling-exceptions-with-naked-fns/_index.md +[“Handling Exceptions”]: ./posts/09-handling-exceptions/index.md ## Introduction Most exceptions are fatal and can't be resolved. For example, we can't return from a divide-by-zero exception in a reasonable way. However, there are some exceptions that we can resolve: diff --git a/blog/content/posts/02-entering-longmode/index.md b/blog/content/posts/02-entering-longmode/index.md index 008c7605..d07462c1 100644 --- a/blog/content/posts/02-entering-longmode/index.md +++ b/blog/content/posts/02-entering-longmode/index.md @@ -494,7 +494,7 @@ _Congratulations_! You have successfully wrestled through this CPU configuration #### One Last Thing Above, we reloaded the code segment register `cs` with the new GDT offset. However, the data segment registers `ss`, `ds`, `es`, `fs`, and `gs` still contain the data segment offsets of the old GDT. This isn't necessarily bad, since they're ignored by almost all instructions in 64-bit mode. However, there are a few instructions that expect a valid data segment descriptor _or the null descriptor_ in those registers. An example is the the [iretq] instruction that we'll need in the [_Returning from Exceptions_] post. -[iretq]: ./extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md#the-iretq-instruction +[iretq]: ./extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md#the [_Returning from Exceptions_]: ./extra/handling-exceptions-with-naked-fns/03-returning-from-exceptions/index.md To avoid future problems, we reload all data segment registers with null: diff --git a/blog/content/posts/10-double-faults/index.md b/blog/content/posts/10-double-faults/index.md index 8067ba80..1226c18a 100644 --- a/blog/content/posts/10-double-faults/index.md +++ b/blog/content/posts/10-double-faults/index.md @@ -9,12 +9,11 @@ In this post we explore double faults in detail. We also set up an _Interrupt St -As always, the complete source code is available on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a [comment section] at the end of this page. +As always, the complete source code is available on [Github]. Please file [issues] for any problems, questions, or improvement suggestions. There is also a [gitter chat] and a comment section at the end of this page. [Github]: https://github.com/phil-opp/blog_os/tree/post_10 [issues]: https://github.com/phil-opp/blog_os/issues [gitter chat]: https://gitter.im/phil-opp/blog_os -[comment section]: #disqus_thread ## What is a Double Fault? In simplified terms, a double fault is a special exception that occurs when the CPU fails to invoke an exception handler. For example, it occurs when a page fault is triggered but there is no page fault handler registered in the [Interrupt Descriptor Table][IDT] (IDT). So it's kind of similar to catch-all blocks in programming languages with exceptions, e.g. `catch(...)` in C++ or `catch(Exception e)` in Java or C#. diff --git a/blog/templates/base.html b/blog/templates/base.html index acb7fdb9..f20491d0 100644 --- a/blog/templates/base.html +++ b/blog/templates/base.html @@ -32,7 +32,7 @@
These posts explain how to handle CPU exceptions using naked functions. Historically, these posts were the main exception handling posts before the x86-interrupt calling convention and the x86_64 crate existed. Our new way of handling exceptions can be found in the “Handling Exceptions” post.
These posts explain how to handle CPU exceptions using naked functions. Historically, these posts were the main exception handling posts before the x86-interrupt calling convention and the x86_64 crate existed. Our new way of handling exceptions can be found in the “Handling Exceptions” post.