Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Feb 2008 18:43:31 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        nox@FreeBSD.org
Cc:        emulation@FreeBSD.org
Subject:   qemu-system-amd64 and freebsd guest
Message-ID:  <20080216164331.GJ57756@deviant.kiev.zoral.com.ua>

next in thread | raw e-mail | index | archive | help

--ctqliX8Ws5lO4mqI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

My recent attempts to boot CURRENT amd64 on QEMU 0.9.1 resulted in the
consistent kernel panic in the first instruction of the root_bus_ocnfigure()
function. Looking around, I noted that this instruction is the second one
executed after "sti" in the amd64/amd64/autoconf.c:configure().
CPU executes
	sti
	call root_bus_configure
	pushq %rbp <- General Protection Fault there

It makes me suspect that fault happen when hardware interrupt is delivered.
Indeed, looking around qemu source code and setting breakpoints in QEMU,
I noted that hw interrupt is delivered, with into = -1. Calculation of
the IDT index in the QEMU' target-i386/helper.c:do_interrupt64() as
intno*16 and comparision with unsigned limit looked as overflow and GPF
was delivered instead.

Then, it appears that -1 comes from cpu_get_pic_interrupt() when
apic_accept_pic_intr() returns false. This happen, in particular, when
corresponding lapic vector is masked. The situation is legitimate, and
I think that QEMU shall not deliver an interrupt in this case.

The following patch allows me to boot the amd64 freebsd on qemu 0.9.1
from ports.

--- cpu-exec.c.orig	2008-02-16 18:23:53.134009488 +0200
+++ cpu-exec.c	2008-02-16 18:24:47.127662872 +0200
@@ -452,13 +452,15 @@
                         svm_check_intercept(SVM_EXIT_INTR);
                         env->interrupt_request &= ~(CPU_INTERRUPT_HARD | CPU_INTERRUPT_VIRQ);
                         intno = cpu_get_pic_interrupt(env);
-                        if (loglevel & CPU_LOG_TB_IN_ASM) {
-                            fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
-                        }
-                        do_interrupt(intno, 0, 0, 0, 1);
-                        /* ensure that no TB jump will be modified as
-                           the program flow was changed */
-                        BREAK_CHAIN;
+			if (intno != -1) {
+				if (loglevel & CPU_LOG_TB_IN_ASM) {
+				    fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
+				}
+				do_interrupt(intno, 0, 0, 0, 1);
+				/* ensure that no TB jump will be modified as
+				   the program flow was changed */
+				BREAK_CHAIN;
+			}
 #if !defined(CONFIG_USER_ONLY)
                     } else if ((interrupt_request & CPU_INTERRUPT_VIRQ) &&
                         (env->eflags & IF_MASK) && !(env->hflags & HF_INHIBIT_IRQ_MASK)) {

--ctqliX8Ws5lO4mqI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (FreeBSD)

iEYEARECAAYFAke3ErIACgkQC3+MBN1Mb4gpuQCgmBq7+oidQ1y/xc7zKb03buAZ
5qcAoK9omowlhSqA62BIupYolaHvE+ic
=9oJa
-----END PGP SIGNATURE-----

--ctqliX8Ws5lO4mqI--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080216164331.GJ57756>