From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] VMX: Reinject real mode exception Date: Sun, 13 Jul 2008 18:28:38 +0300 Message-ID: <487A1F26.7060700@qumranet.com> References: <4879E9C8.2010208@web.de> <4879EFAE.3080805@qumranet.com> <4879F4C0.1090609@web.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------000506070701060700020308" Cc: kvm-devel , Mohammed Gamal , Anthony Liguori , Rik van Riel To: Jan Kiszka Return-path: Received: from il.qumranet.com ([212.179.150.194]:51357 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbYGMP2k (ORCPT ); Sun, 13 Jul 2008 11:28:40 -0400 In-Reply-To: <4879F4C0.1090609@web.de> Sender: kvm-owner@vger.kernel.org List-ID: This is a multi-part message in MIME format. --------------000506070701060700020308 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit 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 --------------000506070701060700020308 Content-Type: text/plain; name="Makefile" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Makefile" 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 $^ $^ --------------000506070701060700020308 Content-Type: text/plain; name="real-mode-exception.ld" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="real-mode-exception.ld" OUTPUT_FORMAT(binary) SECTIONS { . = 0x7c00; stext = .; .text : { *(.init) *(.text) } . = ALIGN(4K); .data : { *(.data) } . = ALIGN(16); .bss : { *(.bss) } . = ALIGN(4K); edata = .; } --------------000506070701060700020308 Content-Type: text/plain; name="real-mode-exception.S" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="real-mode-exception.S" .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 --------------000506070701060700020308--