summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2023-12-13 12:07:43 -0500
committerIan Moffett <ian@osmora.org>2023-12-13 12:07:43 -0500
commit951b20149d1cc4954863a76469ce152c1f453958 (patch)
treeb735f33d2f6736c3723fd120fb36364a5352c9c4
parentcbb1bccdeb98b8bdd80f5334f03bf45961d2a0f8 (diff)
kernel/amd64: tss: Fix broken TSS code
This commit fixes some horribly broken TSS code. It is unclear how it got this broken. Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/arch/amd64/tss.c8
-rw-r--r--sys/include/arch/amd64/tss.h4
2 files changed, 7 insertions, 5 deletions
diff --git a/sys/arch/amd64/tss.c b/sys/arch/amd64/tss.c
index 3463291..ba1b0f6 100644
--- a/sys/arch/amd64/tss.c
+++ b/sys/arch/amd64/tss.c
@@ -70,13 +70,15 @@ write_tss(struct cpu_info *cpu, struct tss_desc *desc)
* to decide how to use it... As of now, it is useless
* to us and shall remain 0.
*/
+ desc->seglimit = sizeof(struct tss_entry);
desc->p = 1; /* Must be present to be valid! */
desc->g = 0; /* Granularity -> 0 */
desc->avl = 0; /* Not used */
desc->dpl = 0; /* Descriptor Privilege Level -> 0 */
desc->type = 0x9; /* For TSS -> 0x9 (0b1001) */
- desc->base_lo16 = __SHIFTOUT(tss_base, __MASK(16));
- desc->base_mid24 = __SHIFTOUT(tss_base, __MASK(8) << 24);
- desc->base_mid32 = __SHIFTOUT(tss_base, __MASK(32) << 32);
+ desc->base_lo16 = __SHIFTOUT(tss_base, __MASK(16));
+ desc->base_mid8 = __SHIFTOUT(tss_base, __MASK(8) << 16);
+ desc->base_hi_mid8 = __SHIFTOUT(tss_base, __MASK(8) << 24);
+ desc->base_hi32 = __SHIFTOUT(tss_base, __MASK(32) << 32);
}
diff --git a/sys/include/arch/amd64/tss.h b/sys/include/arch/amd64/tss.h
index 502cf9e..90f6289 100644
--- a/sys/include/arch/amd64/tss.h
+++ b/sys/include/arch/amd64/tss.h
@@ -86,7 +86,7 @@ struct __packed tss_entry {
struct __packed tss_desc {
uint16_t seglimit;
uint16_t base_lo16;
- uint8_t base_mid24;
+ uint8_t base_mid8;
uint8_t type : 4;
uint8_t zero : 1;
uint8_t dpl : 2;
@@ -95,7 +95,7 @@ struct __packed tss_desc {
uint8_t avl : 1;
uint8_t unused : 2;
uint8_t g : 1;
- uint8_t base_mid32;
+ uint8_t base_hi_mid8;
uint32_t base_hi32;
uint32_t reserved;
};