From: Cam Macdonell Subject: Re: [PATCH] Inter-VM shared memory PCI device Date: Mon, 8 Mar 2010 10:57:08 -0700 Message-ID: <8286e4ee1003080957v9bb4837x187cebb8477348c2@mail.gmail.com> References: <1267833161-25267-1-git-send-email-cam@cs.ualberta.ca> <1267833161-25267-2-git-send-email-cam@cs.ualberta.ca> <4B94C9B3.1060904@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mail-iw0-f202.google.com ([209.85.223.202]:40672 "EHLO mail-iw0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752565Ab0CHR5L convert rfc822-to-8bit (ORCPT ); Mon, 8 Mar 2010 12:57:11 -0500 Received: by iwn40 with SMTP id 40so1267417iwn.1 for ; Mon, 08 Mar 2010 09:57:09 -0800 (PST) In-Reply-To: <4B94C9B3.1060904@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Mar 8, 2010 at 2:56 AM, Avi Kivity wrote: > On 03/06/2010 01:52 AM, Cam Macdonell wrote: >> >> Support an inter-vm shared memory device that maps a shared-memory o= bject >> as a PCI device in the guest. =A0This patch also supports interrupts= between >> guest by communicating over a unix domain socket. =A0This patch appl= ies to >> the >> qemu-kvm repository. >> >> This device now creates a qemu character device and sends 1-bytes me= ssages >> to >> trigger interrupts. =A0Writes are trigger by writing to the "Doorbel= l" >> register >> on the shared memory PCI device. =A0The lower 8-bits of the value wr= itten to >> this >> register are sent as the 1-byte message so different meanings of >> interrupts can >> be supported. >> >> Interrupts are supported between multiple VMs by using a shared memo= ry >> server >> >> -ivshmem,[unix:][file] >> >> Interrupts can also be used between host and guest as well by implem= enting >> a >> listener on the host that talks to shared memory server. =A0The shar= ed >> memory >> server passes file descriptors for the shared memory object and even= tfds >> (our >> interrupt mechanism) to the respective qemu instances. >> >> > > Can you provide a spec that describes the device? =A0This would be us= eful for > maintaining the code, writing guest drivers, and as a framework for r= eview. I'm not sure if you want the Qemu command-line part as part of the spec here, but I've included for completeness. Device Specification for Inter-VM shared memory device -----------------------------------------------------------------------= ------------ Qemu Command-line ------------------------------- The command-line for inter-vm shared memory is as follows -ivshmem ,[unix:]name the argument specifies the size of the shared memory object. Th= e second option specifies either a unix domain socket (when using the unix: pref= ix) or a name for the shared memory object. If a unix domain socket is specified, the guest will receive the shared= object from the shared memory server listening on that socket and will support interrupts with the other guests using that server. Each server only s= erves one memory object. If a name is specified on the command line (without 'unix:'), then the = guest will open the POSIX shared memory object with that name (in /dev/shm) a= nd the specified size. The guest will NOT support interrupts but the shared m= emory object can be shared between multiple guests. The Inter-VM Shared Memory PCI device ----------------------------------------------------------- BARs The device supports two BARs. BAR0 is a 256-byte MMIO region to support registers and BAR1 is used to map the shared memory object from the host. The si= ze of BAR1 is specified on the command-line and must be a power of 2 in size. Registers BAR0 currently supports 5 registers of 16-bits each. Registers are use= d for synchronization between guests sharing the same memory object when interrupts are supported (this requires using the shared memory server)= =2E When using interrupts, VMs communicate with a shared memory server that= passes the shared memory object file descriptor using SCM_RIGHTS. The server = assigns each VM an ID number and sends this ID number to the Qemu process along= with a series of eventfd file descriptors, one per guest using the shared memo= ry server. These eventfds will be used to send interrupts between guests.= Each guest listens on the eventfd corresponding to their ID and may use the = others for sending interrupts to other guests. enum ivshmem_registers { IntrMask =3D 0, IntrStatus =3D 2, Doorbell =3D 4, IVPosition =3D 6, IVLiveList =3D 8 }; The first two registers are the interrupt mask and status registers. Interrupts are triggered when a message is received on the guest's even= tfd from another VM. Writing to the 'Doorbell' register is how synchronization = messages are sent to other VMs. The IVPosition register is read-only and reports the guest's ID number.= The IVLiveList register is also read-only and reports a bit vector of curre= ntly live VM IDs. The Doorbell register is 16-bits, but is treated as two 8-bit values. = The upper 8-bits are used for the destination VM ID. The lower 8-bits are = the value which will be written to the destination VM and what the guest st= atus register will be set to when the interrupt is trigger is the destinatio= n guest. A value of 255 in the upper 8-bits will trigger a broadcast where the m= essage will be sent to all other guests. Cheers, Cam > > -- > error compiling committee.c: too many arguments to function > >