From owner-freebsd-virtualization@FreeBSD.ORG Thu Dec 12 00:44:37 2013 Return-Path: Delivered-To: virtualization@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C641D89; Thu, 12 Dec 2013 00:44:37 +0000 (UTC) Received: from mail-qa0-x22b.google.com (mail-qa0-x22b.google.com [IPv6:2607:f8b0:400d:c00::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 9C5EF1924; Thu, 12 Dec 2013 00:44:36 +0000 (UTC) Received: by mail-qa0-f43.google.com with SMTP id ii20so5393374qab.9 for ; Wed, 11 Dec 2013 16:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=gS7I4s/VtRZtkOAWFR/SL0RwAvwG2RlEa/1Ouwwpq00=; b=tvk/+mr7GsNRc0+vg0sI0Ec3uwksMM2rf+0xNW3PtU0Dsr4pUIzTTyPN9eEv2hAc5q Dn3iDlW7+x6174DVIBj6pWskHT9hZDGVXICYi5pZpVIJpqx0jlNA1u1rmC3eN5Wzc+HA wjhepA1MqCmKk63mt3SbXkwqOd85k7pdfZHnetnoVU3QmBGrNUUVV9Ik2NmcknrQ4Aft +P5n3OHX/li3PhlQczt037WUZPvVKi2JEPi+dW+ltPqlcn5MMpmH64IDl5hsny6LpOmL 0Nrz5L6Zievbgc8K5PRFpbJykocW/yuvwZuMaR6RtHHDi0+xnbWYYfSH8NkolBsh6nB5 JGyQ== MIME-Version: 1.0 X-Received: by 10.224.120.71 with SMTP id c7mr820072qar.37.1386809075134; Wed, 11 Dec 2013 16:44:35 -0800 (PST) Received: by 10.140.34.17 with HTTP; Wed, 11 Dec 2013 16:44:35 -0800 (PST) In-Reply-To: <201312111238.12232.jhb@freebsd.org> References: <201312101527.47234.jhb@freebsd.org> <201312111238.12232.jhb@freebsd.org> Date: Wed, 11 Dec 2013 16:44:35 -0800 Message-ID: Subject: Re: [PATCH] Additional lapic support for bhyve From: Neel Natu To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Dec 2013 00:44:37 -0000 Hi John, On Wed, Dec 11, 2013 at 9:38 AM, John Baldwin wrote: > On Wednesday, December 11, 2013 2:19:14 am Neel Natu wrote: >> Hi John, >> >> On Tue, Dec 10, 2013 at 12:27 PM, John Baldwin wrote: >> > This patch extends the local APIC emulation a bit by adding the following >> > things: >> > - Add an ioctl and a bhyvectl command to trigger local interrupts on a >> > local APIC. The "fixed" and "NMI" delivery modes are enabled. >> > - Add support for the CMCI LVT entry. >> > - Add the ability to report local APIC errors and trigger errors for >> > invalid vectors when sending IPIs or firing an external interrupt that >> > references an invalid IDT vector. >> > - Silently force all reserved fields in LVT entries to zero when they >> > are written (removes the need for clearing those bits when triggering >> > an LVT interrupt). >> > - Add entries to the MP Table and MADT to advertise the typical x86 LINT >> > configuration (ExtINT on LINT0 and NMI on LINT1). >> > - Add a bhyvectl command to inject an NMI on an arbitrary CPU (this latter >> > should probably be a separate patch) >> > >> > In particular, while bhyectl --inject-nmi can inject an NMI on a single vcpu, >> > the more traditional way of signalling a system-wide error (such as SERR# >> > or PERR#) is to assert the LINT1 pins on all CPUs. This can now be done via >> > 'bhyectl --vm=foo --cpu=-1 --assert-lapic-lvt=1' (cpu of -1 is a broadcast >> > to all CPUs for the LVT ioctl). The patch is at >> > people.freebsd.org/~jhb/patches/bhyve_lapic.patch I'm certainly open to >> > suggestions on ways to make this be more consistent with the style/design/flow >> > of the existing code. >> > >> >> This looks good. >> >> vlapic_fire_lvt() and vlapic_set_error() can call each other >> recursively if guest has programmed the ERROR_LVT vector incorrectly. >> This can probably be fixed by passing the LVT index to >> vlapic_fire_lvt() and treating LVT_ERROR specially. > > Oh, cute, and very true. Another option might be to have set_error set > a per vlapic flag and avoid posting the interrupt if it detects recursion. > Yup, that would work as well. >> A couple of nits: >> - Could you add a /* fallthrough */ comment after setting the 'mask' >> for the LINT_LVT entries in vlapic_set_lvt()? > > Sure. > >> - Any reason that vlapic_set_error() and vlapic_fire_cmci() are not >> static to vlapic.c? Do you anticipate calling them from outside this >> file in the future? > > Yes. I imagine the machine check injection code I plan to work on would > be in a different file, and it would need to be able to trigger CMCI. > > For vlapic_set_error(), there is one error case we currently do not handle > which is access to an invalid register (right now we ignore those). For > x2APIC we should be generating general protection fault. For mmio access > an error is supposed to be asserted instead. I figured for the latter > that it would be done in lapic_mmio_read() and lapic_mmio_write(). > Sounds good. best Neel > -- > John Baldwin