From patchwork Fri Dec 14 03:11:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 1013238 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=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IrMR+y56"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43GFtz5QVVz9sCV for ; Fri, 14 Dec 2018 14:11:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726465AbeLNDLW (ORCPT ); Thu, 13 Dec 2018 22:11:22 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38766 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbeLNDLW (ORCPT ); Thu, 13 Dec 2018 22:11:22 -0500 Received: by mail-pf1-f193.google.com with SMTP id q1so2105757pfi.5; Thu, 13 Dec 2018 19:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BtU9WFq7zymrfMmrShCyw7CX9Y5jVRxC1UMoDrEicPM=; b=IrMR+y563Nz4Gtj+Lomk2tGSmFrcAsVnGZIEJYExINzQKeOpzFG5jkJS2n2lAO1oCm 8Ix9jc4wDUeHiDwg6pi66zG/NRTbGpFLBg9P6kfpCHzEKFPg+8nNE0OiexKd4LoyOs0k +3K4XNCTwr4psJ5RFDp1WnbXs+yyQcJQJOikIA5DnSyr6g9ZtLrPqvH9Y4uglt1iwLyc +27HdP1BsI/vn4Kpy+43f3neARViIw7LR3KZ7QNXefcNSuLh9kobsCigUl60JtNWqvbt bagOvl9dbdxgUtJz/f8GNR19A6Bz4yLxr4RY3BgZAIkfgkOxjxvQQ/6qPd4RZG0AM/fe 1m3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BtU9WFq7zymrfMmrShCyw7CX9Y5jVRxC1UMoDrEicPM=; b=hmwVR0RoP1MP+Uei6xrP1LbrqS8T1NblWLduuTsEiC5p0xhsrgIGe838j49K+Okc// UfJqPVLuwcDFvUvlg2InMkH7Ltz16lmi28jHt2dvR+xMMBA+nD5WZQThzPtz4GlEIY6z 9b9WUjztJDTXllkD+QU+UvYkp6uHhHYCPjl1Dle0ehtyJcYfy690C/EBZO2c2NHmn3+t pSCFEoofedFDEyZN4We06Xz3ylmRJhKeLTlW6GjAb8NDj20PwOtCewcxTluLuTiW5XKn TEI/fvoBs41ahuDnp+yllbtS9JwmbjXnJpP52u3bo+dcw0rAH8cQYKKuPuPS3ibh66sG Syjw== X-Gm-Message-State: AA+aEWZGrpfwJMnZ3yKIhDs9ASUuHFB/8YWCtrt3F3ESWah8t8wUD08F Cow25XNOsh4TCDdK3N7p5nLq/fSV X-Google-Smtp-Source: AFSGD/Xgm/HfMtDhO3WayBWVls18JJuUjMHe9tcYoJ7BZDPVACw4hNGZjZ0KxTtt8HuLlsvr1rox0Q== X-Received: by 2002:a63:d846:: with SMTP id k6mr1267288pgj.251.1544757081128; Thu, 13 Dec 2018 19:11:21 -0800 (PST) Received: from surajjs2.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id e188sm4079326pfg.130.2018.12.13.19.11.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:11:20 -0800 (PST) From: Suraj Jitindar Singh To: kvm-ppc@vger.kernel.org Cc: kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, paulus@ozlabs.org, aik@ozlabs.ru, sjitindarsingh@gmail.com Subject: [PATCH V3 0/8] KVM: PPC: Implement passthrough of emulated devices for nested guests Date: Fri, 14 Dec 2018 14:11:01 +1100 Message-Id: <20181214031109.14464-1-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org This patch series allows for emulated devices to be passed through to nested guests, irrespective of at which level the device is being emulated. Note that the emulated device must be using dma, not virtio. For example, passing through an emulated e1000: 1. Emulate the device at L(n) for L(n+1) qemu-system-ppc64 -netdev type=user,id=net0 -device e1000,netdev=net0 2. Assign the VFIO-PCI driver at L(n+1) echo vfio-pci > /sys/bus/pci/devices/0000:00:00.0/driver_override echo 0000:00:00.0 > /sys/bus/pci/drivers/e1000/unbind echo 0000:00:00.0 > /sys/bus/pci/drivers/vfio-pci/bind chmod 666 /dev/vfio/0 3. Pass the device through from L(n+1) to L(n+2) qemu-system-ppc64 -device vfio-pci,host=0000:00:00.0 4. L(n+2) can now access the device which will be emulated at L(n) V2 -> V3: 1/8: None 2/8: None 3/8: None 4/8: None 5/8: None 6/8: None 7/8: Use guest physical address for the args in H_COPY_TOFROM_GUEST to match the comment. 8/8: None Suraj Jitindar Singh (8): KVM: PPC: Only report KVM_CAP_SPAPR_TCE_VFIO on powernv machines KVM: PPC: Book3S HV: Add function kvmhv_vcpu_is_radix() KVM: PPC: Book3S HV: Implement functions to access quadrants 1 & 2 KVM: PPC: Add load_from_eaddr and store_to_eaddr to the kvmppc_ops struct KVM: PPC: Update kvmppc_st and kvmppc_ld to use quadrants KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L2 guest KVM: PPC: Introduce new hcall H_COPY_TOFROM_GUEST to access quadrants 1 & 2 KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L3 guest arch/powerpc/include/asm/hvcall.h | 1 + arch/powerpc/include/asm/kvm_book3s.h | 10 ++- arch/powerpc/include/asm/kvm_book3s_64.h | 13 ++++ arch/powerpc/include/asm/kvm_host.h | 3 + arch/powerpc/include/asm/kvm_ppc.h | 4 ++ arch/powerpc/kernel/exceptions-64s.S | 9 +++ arch/powerpc/kvm/book3s_64_mmu_radix.c | 97 ++++++++++++++++++++++++++ arch/powerpc/kvm/book3s_hv.c | 58 ++++++++++++++-- arch/powerpc/kvm/book3s_hv_nested.c | 114 +++++++++++++++++++++++++++++-- arch/powerpc/kvm/powerpc.c | 30 +++++++- arch/powerpc/mm/fault.c | 1 + 11 files changed, 325 insertions(+), 15 deletions(-)