Skip to content

Commit

Permalink
rmode: add spin lock protecting long_to_real CS
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Feb 12, 2021
1 parent 2fa7b76 commit 7d57dde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/x86/boot/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ GLOBAL(_start)
ljmp $__KERN_CS64, $.Llong_mode

ENTRY(prot_to_real)
/* FIXME: Add spinlock */

lea (boot_gdt_ptr), %eax
push %eax
lea (boot_idt_ptr), %eax
Expand Down
5 changes: 5 additions & 0 deletions arch/x86/real_mode_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,22 @@
#include <lib.h>
#include <percpu.h>
#include <smp/smp.h>
#include <spinlock.h>
#include <traps.h>

extern void _long_to_real(const void *gdt_ptr, const void *idt_ptr);

static spinlock_t lock = SPINLOCK_INIT;

/* FIXME: add real mode calling functionality */
void long_to_real(void) {
spin_lock(&lock);
percpu_t *percpu = get_percpu_page(smp_processor_id());

dprintk("%s: Before call\n", __func__);
_long_to_real(&percpu->gdt_ptr, &percpu->idt_ptr);
dprintk("%s: After call\n", __func__);
spin_unlock(&lock);
}

void init_real_mode(void) { init_rmode_traps(); }

0 comments on commit 7d57dde

Please sign in to comment.