Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759712Ab3DDMWO (ORCPT ); Thu, 4 Apr 2013 08:22:14 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38105 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759670Ab3DDMWM convert rfc822-to-8bit (ORCPT ); Thu, 4 Apr 2013 08:22:12 -0400 Subject: Re: [PATCH RFC] kvm: add PV MMIO EVENTFD Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=us-ascii From: Alexander Graf In-Reply-To: <20130404120825.GD17919@redhat.com> Date: Thu, 4 Apr 2013 14:22:09 +0200 Cc: "Michael S. Tsirkin" , Marcelo Tosatti , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Xiao Guangrong , Takuya Yoshikawa , Alex Williamson , Will Deacon , Christoffer Dall , Sasha Levin , Andrew Morton , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Content-Transfer-Encoding: 8BIT Message-Id: <194AE9A4-07C6-4597-B3AA-1EDF3DA97FA0@suse.de> References: <20130404104846.GA6227@redhat.com> <6D40C5F1-849E-4F32-B391-E1A1BFA8C59D@suse.de> <20130404120825.GD17919@redhat.com> To: Gleb Natapov X-Mailer: Apple Mail (2.1278) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2996 Lines: 68 On 04.04.2013, at 14:08, Gleb Natapov wrote: > On Thu, Apr 04, 2013 at 01:57:34PM +0200, Alexander Graf wrote: >> >> On 04.04.2013, at 12:50, Michael S. Tsirkin wrote: >> >>> With KVM, MMIO is much slower than PIO, due to the need to >>> do page walk and emulation. But with EPT, it does not have to be: we >>> know the address from the VMCS so if the address is unique, we can look >>> up the eventfd directly, bypassing emulation. >>> >>> Add an interface for userspace to specify this per-address, we can >>> use this e.g. for virtio. >>> >>> The implementation adds a separate bus internally. This serves two >>> purposes: >>> - minimize overhead for old userspace that does not use PV MMIO >>> - minimize disruption in other code (since we don't know the length, >>> devices on the MMIO bus only get a valid address in write, this >>> way we don't need to touch all devices to teach them handle >>> an dinvalid length) >>> >>> At the moment, this optimization is only supported for EPT on x86 and >>> silently ignored for NPT and MMU, so everything works correctly but >>> slowly. >>> >>> TODO: NPT, MMU and non x86 architectures. >>> >>> The idea was suggested by Peter Anvin. Lots of thanks to Gleb for >>> pre-review and suggestions. >>> >>> Signed-off-by: Michael S. Tsirkin >> >> This still uses page fault intercepts which are orders of magnitudes slower than hypercalls. Why don't you just create a PV MMIO hypercall that the guest can use to invoke MMIO accesses towards the host based on physical addresses with explicit length encodings? >> > It is slower, but not an order of magnitude slower. It become faster > with newer HW. > >> That way you simplify and speed up all code paths, exceeding the speed of PIO exits even. It should also be quite easily portable, as all other platforms have hypercalls available as well. >> > We are trying to avoid PV as much as possible (well this is also PV, > but not guest visible). We haven't replaced PIO with hypercall for the > same reason. My hope is that future HW will provide us with instruction > decode for basic mov instruction at which point this optimisation can be > dropped. The same applies to an MMIO hypercall. Once the PV interface becomes obsolete, we can drop the capability we expose to the guest. > And hypercall has its own set of problems with Windows guests. > When KVM runs in Hyper-V emulation mode it expects to get Hyper-V > hypercalls. Mixing KVM hypercalls and Hyper-V requires some tricks. It Can't we simply register a hypercall ID range with Microsoft? > may also affect WHQLing Windows drivers since driver will talk to HW > bypassing Windows interfaces. Then the WHQL'ed driver doesn't support the PV MMIO hcall? Alex -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/