From patchwork Mon Jan 7 18:43:12 2019 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: 1021518 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 43YPrr5wxPz9s7T for ; Tue, 8 Jan 2019 06:02:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbfAGTCC (ORCPT ); Mon, 7 Jan 2019 14:02:02 -0500 Received: from 10.mo4.mail-out.ovh.net ([188.165.33.109]:56460 "EHLO 10.mo4.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728233AbfAGTCB (ORCPT ); Mon, 7 Jan 2019 14:02:01 -0500 X-Greylist: delayed 962 seconds by postgrey-1.27 at vger.kernel.org; Mon, 07 Jan 2019 14:01:59 EST Received: from player737.ha.ovh.net (unknown [10.109.146.175]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id 53DD01C7FE4 for ; Mon, 7 Jan 2019 19:43:53 +0100 (CET) Received: from kaod.org (lfbn-1-10605-110.w90-89.abo.wanadoo.fr [90.89.196.110]) (Authenticated sender: clg@kaod.org) by player737.ha.ovh.net (Postfix) with ESMTPSA id 3489C18662F9; Mon, 7 Jan 2019 18:43:39 +0000 (UTC) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: kvm-ppc@vger.kernel.org Cc: Paul Mackerras , David Gibson , Benjamin Herrenschmidt , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH 00/19] KVM: PPC: Book3S HV: add XIVE native exploitation mode Date: Mon, 7 Jan 2019 19:43:12 +0100 Message-Id: <20190107184331.8429-1-clg@kaod.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Ovh-Tracer-Id: 11378625935612546007 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrvdejgdduudegucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm 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. 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 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 attempt to solve that problem. Migration has its own specific needs. The patchset provides the necessary routines to quiesce XIVE, to capture and restore the state of the different structures used by KVM, OPAL and HW. Extra OPAL support is required for these. GitHub trees available here : QEMU sPAPR: https://github.com/legoater/qemu/commits/xive-next Linux/KVM: https://github.com/legoater/linux/commits/xive-5.0 OPAL: https://github.com/legoater/skiboot/commits/xive Best wishes for 2019 ! C. Cédric Le Goater (19): 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 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 SET_SOURCE 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 KVM: PPC: Book3S HV: record guest queue page address KVM: PPC: Book3S HV: add a SYNC control for the XIVE native migration KVM: PPC: Book3S HV: add a control to make the XIVE EQ pages dirty KVM: PPC: Book3S HV: add get/set accessors for the source configuration KVM: PPC: Book3S HV: add get/set accessors for the EQ configuration KVM: PPC: Book3S HV: add get/set accessors for the VP XIVE state KVM: PPC: Book3S HV: add passthrough support KVM: introduce a KVM_DELETE_DEVICE ioctl arch/powerpc/include/asm/kvm_host.h | 2 + arch/powerpc/include/asm/kvm_ppc.h | 69 + arch/powerpc/include/asm/opal-api.h | 11 +- arch/powerpc/include/asm/opal.h | 7 + arch/powerpc/include/asm/xive.h | 40 + arch/powerpc/include/uapi/asm/kvm.h | 47 + arch/powerpc/kvm/book3s_xive.h | 82 + include/linux/kvm_host.h | 2 + include/uapi/linux/kvm.h | 5 + arch/powerpc/kvm/book3s.c | 31 +- arch/powerpc/kvm/book3s_hv.c | 29 + arch/powerpc/kvm/book3s_hv_builtin.c | 196 +++ arch/powerpc/kvm/book3s_hv_rm_xive_native.c | 47 + arch/powerpc/kvm/book3s_xive.c | 149 +- arch/powerpc/kvm/book3s_xive_native.c | 1406 +++++++++++++++++ .../powerpc/kvm/book3s_xive_native_template.c | 398 +++++ arch/powerpc/kvm/powerpc.c | 30 + arch/powerpc/sysdev/xive/native.c | 110 ++ arch/powerpc/sysdev/xive/spapr.c | 28 +- virt/kvm/kvm_main.c | 39 + arch/powerpc/kvm/Makefile | 4 +- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 52 + .../powerpc/platforms/powernv/opal-wrappers.S | 3 + 23 files changed, 2722 insertions(+), 65 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