From owner-freebsd-virtualization@FreeBSD.ORG Wed Aug 20 18:09:27 2014 Return-Path: Delivered-To: freebsd-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 6FF9652D; Wed, 20 Aug 2014 18:09:27 +0000 (UTC) Received: from mail-qc0-x233.google.com (mail-qc0-x233.google.com [IPv6:2607:f8b0:400d:c01::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F25C232CD; Wed, 20 Aug 2014 18:09:26 +0000 (UTC) Received: by mail-qc0-f179.google.com with SMTP id m20so8043244qcx.38 for ; Wed, 20 Aug 2014 11:09:26 -0700 (PDT) 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:content-transfer-encoding; bh=rpfhyTrWXSaDNoQ0vRyWpYIV3ZMpB7tCNjjy9foBTGQ=; b=LL64HgwQQUN3SJPjch3PF2jk1uVZebx8Lc1EIu7j8pW0uqfYb1WVYhAPyS6oicHSR4 TcaMszQOB/7D0e+ud5DrfJ/JuRgaAn0YZzPKJYDmQJ2TXaDhRBFZsc2J7ZnXZ/xuQ4JC VCzV2DwjmJ/t3eKk+6tPi59e6rPS5juuqbD/m/1m9a6ooUrkpzYeAwmozLUnXS+eeWdL BjdKpAG1RHWXRXyctGYtQXWwBUW6FvsrRX2RSn8K/AsE2D4tq/Q1o78i9OCLbJNh4kej FEHOKZLXDywNjbdeKaQYeX6kZ3fXfLPLOqjFvljP4SzQxGQNSWpVfi0OL1cE5oEuWgVZ Yyyw== MIME-Version: 1.0 X-Received: by 10.140.83.242 with SMTP id j105mr69306093qgd.38.1408558164957; Wed, 20 Aug 2014 11:09:24 -0700 (PDT) Received: by 10.140.84.80 with HTTP; Wed, 20 Aug 2014 11:09:24 -0700 (PDT) In-Reply-To: <201408201131.29399.jhb@freebsd.org> References: <3defccd56bc0407c88bdda139b2462ac@BY1PR0301MB0902.namprd03.prod.outlook.com> <53F4A34A.4010807@citrix.com> <201408201131.29399.jhb@freebsd.org> Date: Wed, 20 Aug 2014 11:09:24 -0700 Message-ID: Subject: Re: Directly reserve an interrupt IDT entry for Hyper-V From: Neel Natu To: John Baldwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "freebsd-xen@freebsd.org" , freebsd-drivers@freebsd.org, "freebsd-virtualization@freebsd.org" X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.18-1 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: Wed, 20 Aug 2014 18:09:27 -0000 Hi John, On Wed, Aug 20, 2014 at 8:31 AM, John Baldwin wrote: > On Wednesday, August 20, 2014 9:31:54 am Roger Pau Monn=C3=A9 wrote: >> On 20/08/14 11:19, Wei Hu wrote: >> > Hello, >> > >> > Sending to Xen, drivers and virtualization mailing lists since this mi= ght > be of interest to the folks on these aliases. >> > >> > I am working for Microsoft to improve the performance of FreeBSD runni= ng > on Hyper-V. Right now I am adding a feature in the vmbus driver which cou= ld > handle the host-guest channel communications on all vCPUs simultaneously.= In > order to achieve this, the hypervisor will send same interrupt concurrent= ly on > all the vCPUs. The traditional way on FreeBSD to set up interrupt handlin= g for > devicse, such as calling bus_alloc_resource() to reserve an IRQ line, and= then > calling bus_setup_intr() to create a vector, doesn't seem to work in this > case. It seems if the interrupt is routed via legacy IRQ, it can only be > active on one vCPU at a time. In order to allow the same interrupt to be > handled on all vCPUs concurrently, all I need is an IDT entry, not an IRQ > line. >> > >> > I checked current FreeBSD code. It looks to me Xen directly uses the > vector number IDT_EVTCHN (0x93) to achieve the same purpose. I am proposi= ng > both Xen and Hyper-V share this same vector. Following is a little bit de= tail > of my proposal for the changes in the current kernel. >> > >> > >> > 1. In machdep.c: >> > >> > #ifdef XENHVM >> > >> > setidt(IDT_EVTCHN, &IDTVEC(xen_intr_upcall), SDT_SYSIGT, SEL_U= PL, > 0); >> > >> > #else >> > >> > setidt(IDT_EVTCHN, &IDTVEC(hv_vmbus_intr), SDT_SYSIGT, SEL_UPL= , > 0); >> > >> > #endif >> > >> > 2. Apic_vector.S >> > >> > Add IDTVEC(hv_vmbus_intr) to call Hyper-V vmbus interrupt service rout= ine. >> > >> > Any thoughts, objections and feedbacks are all welcome. >> >> Hello, >> >> I don't think using the same IDT vector is the right approach, I would >> just pick a different IDT vector and use that for Hyper-V. Using the >> same IDT vector (like your suggestion above) would prevent shipping a >> kernel with with both Hyper-V and Xen support (like it's done now in >> GENERIC). >> >> Roger. > > Hmm, can't you make this a runtime check to only call setidt() if you det= ect > you are under the appropriate hypervisor? > > Also, bhyve currently has a hackish way of requesting a free IDT slot. > Perhaps it would be best if I added little API to reserve an IDT slot ass= uming > that callers could accept a dynamic IDT vector rather than a static one. > Yup, it'll be good to get rid of vmm_ipi.c. best Neel > -- > John Baldwin > _______________________________________________ > freebsd-virtualization@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization > To unsubscribe, send any mail to "freebsd-virtualization-unsubscribe@free= bsd.org"