From patchwork Mon Apr 23 16:43:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 903039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=kvm-ppc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40VCPK1DS5z9s0R for ; Tue, 24 Apr 2018 02:59:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755549AbeDWQ7s (ORCPT ); Mon, 23 Apr 2018 12:59:48 -0400 Received: from 11.mo3.mail-out.ovh.net ([87.98.184.158]:56938 "EHLO 11.mo3.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754788AbeDWQ7r (ORCPT ); Mon, 23 Apr 2018 12:59:47 -0400 X-Greylist: delayed 862 seconds by postgrey-1.27 at vger.kernel.org; Mon, 23 Apr 2018 12:59:47 EDT Received: from player737.ha.ovh.net (unknown [10.109.108.50]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id F30741B3EEE for ; Mon, 23 Apr 2018 18:43:52 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-TOU-1-49-10.w86-201.abo.wanadoo.fr [86.201.141.10]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id B7B9BE0099; Mon, 23 Apr 2018 18:43:45 +0200 (CEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: kvm-ppc@vger.kernel.org, kvm@vger.kernel.org Cc: Paul Mackerras , David Gibson , Benjamin Herrenschmidt , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [RFC PATCH 00/16] KVM: PPC: Book3S HV: add XIVE native exploitation mode Date: Mon, 23 Apr 2018 18:43:25 +0200 Message-Id: <20180423164341.15767-1-clg@kaod.org> X-Mailer: git-send-email 2.13.6 MIME-Version: 1.0 X-Ovh-Tracer-Id: 956733448686373847 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtgedrkeeggddutdegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org Hello, On the POWER9 processor, the XIVE interrupt controller can control interrupt sources using MMIO to trigger events, to EOI or to turn off the sources. Priority management and interrupt acknowledgment is also controlled by MMIO in the CPU presenter subengine. PowerNV/baremetal Linux runs natively under XIVE but sPAPR guests need special support from the hypervisor to do the same. This is called the XIVE native exploitation mode and today, it can be activated under the PowerPC Hypervisor, pHyp. However, Linux/KVM lacks XIVE native support and still offers the old interrupt mode interface using a XICS-over-XIVE glue which implements the XICS hcalls. The following series is proposal to add the same support under KVM. * KVM XIVE for sPAPR A new KVM device is introduced for the XIVE native exploitation mode. It reuses most of the XICS-over-XIVE glue implementation structures which are internal to KVM but it has a completely different interface. A set of Hypervisor calls configures the sources and the event queues and from there, all control is done by the guest through MMIOs. These MMIO regions (ESB and TIMA) are exposed to guests in QEMU, similarly to VFIO, and the associated VMAs are populated dynamically with the appropriate pages using a fault handler. This is implemented with a couple of KVM device ioctls. On a POWER9 sPAPR machine, the Client Architecture Support (CAS) negotiation process determines whether the guest operates with a interrupt controller using the XICS legacy model, as found on POWER8, or in XIVE exploitation mode. Which means that the KVM interrupt device should be created at runtime, after the machine as started. This requires extra KVM support to create/destroy KVM devices. The last patches are an experimental attempt to solve that problem. Migration raises a couple of issues also. The patchset provide the necessary accessor routines to capture and restore the state of the different structures used by KVM, OPAL and HW. But as the migration is sequenced by QEMU, we might not have enough quiescence points to capture correctly all HW state. * Caveats - VMs migrate under load. work in progress. - reseting the KVM device has some bad consequences on the MMU. Needs more care. - not much attention given to pass-through * Github QEMU https://github.com/legoater/qemu/commits/xive Linux/KVM https://github.com/legoater/linux/commits/xive Thanks, C. Cédric Le Goater (16): powerpc/xive: export flags for the XIVE native exploitation mode hcalls powerpc/xive: add OPAL extensions for the XIVE native exploitation support KVM: PPC: Book3S HV: check the IRQ controller type KVM: PPC: Book3S HV: export services for the XIVE native exploitation device KVM: PPC: Book3S HV: add a new KVM device for the XIVE native exploitation mode KVM: PPC: Book3S HV: add a SET_SOURCE control to the XIVE native device KVM: PPC: Book3S HV: add a GET_ESB_FD control to the XIVE native device KVM: PPC: Book3S HV: add a GET_TIMA_FD control to XIVE native device KVM: PPC: Book3S HV: add a VC_BASE control to the XIVE native device KVM: PPC: Book3S HV: add a EISN attribute to kvmppc_xive_irq_state KVM: PPC: Book3S HV: add support for the XIVE native exploitation mode hcalls powerpc/xive: update HW definitions powerpc/xive: record guest queue page address KVM: PPC: Book3S HV: add support for XIVE native migration KVM: introduce a KVM_DESTROY_DEVICE ioctl KVM: PPC: Book3S HV: disconnect vCPU from IRQ device arch/powerpc/include/asm/kvm_host.h | 2 + arch/powerpc/include/asm/kvm_ppc.h | 78 +- arch/powerpc/include/asm/opal-api.h | 13 +- arch/powerpc/include/asm/opal.h | 12 + arch/powerpc/include/asm/xive-regs.h | 45 + arch/powerpc/include/asm/xive.h | 43 + arch/powerpc/include/uapi/asm/kvm.h | 22 + arch/powerpc/kvm/Makefile | 4 +- arch/powerpc/kvm/book3s.c | 53 +- arch/powerpc/kvm/book3s_hv.c | 31 + arch/powerpc/kvm/book3s_hv_builtin.c | 196 ++++ arch/powerpc/kvm/book3s_hv_rm_xive_native.c | 47 + arch/powerpc/kvm/book3s_hv_rmhandlers.S | 52 + arch/powerpc/kvm/book3s_xics.c | 5 +- arch/powerpc/kvm/book3s_xive.c | 106 +- arch/powerpc/kvm/book3s_xive.h | 74 ++ arch/powerpc/kvm/book3s_xive_native.c | 1257 ++++++++++++++++++++++++ arch/powerpc/kvm/book3s_xive_native_template.c | 381 +++++++ arch/powerpc/kvm/powerpc.c | 52 +- arch/powerpc/platforms/powernv/opal-wrappers.S | 4 + arch/powerpc/sysdev/xive/native.c | 107 ++ arch/powerpc/sysdev/xive/spapr.c | 28 +- include/uapi/linux/kvm.h | 5 + virt/kvm/kvm_main.c | 40 + 24 files changed, 2585 insertions(+), 72 deletions(-) create mode 100644 arch/powerpc/kvm/book3s_hv_rm_xive_native.c create mode 100644 arch/powerpc/kvm/book3s_xive_native.c create mode 100644 arch/powerpc/kvm/book3s_xive_native_template.c