From cc0d79dce6217be9166758f338e4679d8270ba9b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 2 Aug 2008 11:30:43 +0000 Subject: [PATCH] Fix asm constraints to avoid SI, DI for byte and word access. Thanks to Ed Lyle Karrels for reporting the problem. --- doc/userprog.texi | 2 +- solutions/p2.patch | 2 +- src/userprog/gdt.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/userprog.texi b/doc/userprog.texi index 5bd0bb2..612bb81 100644 --- a/doc/userprog.texi +++ b/doc/userprog.texi @@ -443,7 +443,7 @@ put_user (uint8_t *udst, uint8_t byte) { int error_code; asm ("movl $1f, %0; movb %b2, %1; 1:" - : "=&a" (error_code), "=m" (*udst) : "r" (byte)); + : "=&a" (error_code), "=m" (*udst) : "q" (byte)); return error_code != -1; } @end verbatim diff --git a/solutions/p2.patch b/solutions/p2.patch index 00711a2..4c2660e 100644 --- a/solutions/p2.patch +++ b/solutions/p2.patch @@ -620,7 +620,7 @@ diff -u src/userprog/syscall.c~ src/userprog/syscall.c +{ + int eax; + asm ("movl $1f, %%eax; movb %b2, %0; 1:" -+ : "=m" (*udst), "=&a" (eax) : "r" (byte)); ++ : "=m" (*udst), "=&a" (eax) : "q" (byte)); + return eax != 0; +} + diff --git a/src/userprog/gdt.c b/src/userprog/gdt.c index a7423b7..e866037 100644 --- a/src/userprog/gdt.c +++ b/src/userprog/gdt.c @@ -50,7 +50,7 @@ gdt_init (void) 6.2.4 "Task Register". */ gdtr_operand = make_gdtr_operand (sizeof gdt - 1, gdt); asm volatile ("lgdt %0" : : "m" (gdtr_operand)); - asm volatile ("ltr %w0" : : "r" (SEL_TSS)); + asm volatile ("ltr %w0" : : "q" (SEL_TSS)); } /* System segment or code/data segment? */ -- 2.30.2