Jan Kiszka wrote:
Avi Kivity wrote:
Jan Kiszka wrote:
...
@@ -2234,6 +2252,24 @@ static int handle_rmode_exception(struct
     if (((vec == GP_VECTOR) || (vec == SS_VECTOR)) && err_code == 0)
         if (emulate_instruction(vcpu, NULL, 0, 0, 0) == EMULATE_DONE)
             return 1;
+    /*
+     * Forward all other exceptions that are valid in real mode.
+     * FIXME: Breaks guest debugging in real mode, need to be fixed with
+     *        the required debugging infrastructure rework.
+     */
+    switch (vec) {
+    case DF_VECTOR:
+    case SS_VECTOR:
+    case GP_VECTOR:
+        kvm_queue_exception_e(vcpu, vec, err_code);
These don't actually queue an error code in real mode.  Compare the
'Real-Address Mode Exceptions' section with the 'Protected Mode
Exceptions' section  for most instructions in the Intel manual.

Unless you can points out a better reference, I prefer following chapter
5.15 of the System Programming Guide on this. And that one doesn't make
a difference when it says, e.g., "Exception Error Code: Zero. The
processor always pushes an error code of 0 onto the stack of the
doublefault handler."


Well, xen and bochs do not push an error code for real mode #GP. I tried running the attached test program but it doesn't work on real hardware (it does work on bochs).



--
error compiling committee.c: too many arguments to function

all: real-mode-exception.iso

real-mode-exception.o: real-mode-exception.S
        as -o $@ $^

real-mode-exception.boot:  real-mode-exception.o real-mode-exception.ld
        ld -T real-mode-exception.ld -o $@ real-mode-exception.o
        dd < /dev/zero >> $@ count=2879

real-mode-exception.iso: real-mode-exception.boot
        mkisofs -o $@ -b $^ $^
OUTPUT_FORMAT(binary)

SECTIONS
{
    . = 0x7c00;
    stext = .;
    .text : { *(.init) *(.text) }
    . = ALIGN(4K);
    .data : { *(.data) }
    . = ALIGN(16);
    .bss : { *(.bss) }
    . = ALIGN(4K);
    edata = .;
}

.code16

start:
        ljmp $0, $restart
restart:
        mov $0x39, %al
        mov $10, %ah
        mov $0, %bx
        mov $20, %cx
        int $0x10
        mov $0, %ax
        mov %ax, %ds
        movw $gp_handler, 13*4
        mov %cs, 13*4+2
        mov %sp, %dx
        addr32 testb $0, 0x100000
loop:   jmp loop

gp_handler:
        sub %sp, %dx
        shr $1, %dx
        add $48, %dl
        mov %dl, %al
        mov $10, %ah
        mov $0, %bx
        mov $10, %cx
        int $0x10
        jmp loop

. = 0x1fe

.byte 0x55, 0xaa

Reply via email to