Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4110592imu; Mon, 10 Dec 2018 13:19:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/UfJvXgkxI1pnPXc+fZW9MbV/DzPz810imb9zlKwYBJIsM1Y2OrXhw4moa21HT5orheXB7m X-Received: by 2002:a63:6483:: with SMTP id y125mr12127390pgb.91.1544476766672; Mon, 10 Dec 2018 13:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544476766; cv=none; d=google.com; s=arc-20160816; b=hZmvzXVVmGOsddgb6BUJN6JGb9ZrnxVCYLtebUpWxvVGrpKGkzhuumQJCjmbo4HPTd cEW/ffC1NEh4h7j40MV4i9YYaXXP2O7kvYNW606rERPrGnEmjlSS5V2d3i5VK0p7HmNs ySH+Bc3E9HqIbsPdoNaol1TmhRoPfMKdVlabWB2tq1NvEv1WAARsGmltlGmGDFgyRIzG XlWKOU4mrPIUJbsnYD7LwVlrXQ693OZpT/q1dHBCmE4U8z99pRPJqk9Lq+kOk6LMlGrD Axu/wP2bLN1lS6KBURs4IU9wqO+nPnk2zccy4F1HsEA51Arwc59ycIYfi7jIL5h8hauZ Pu1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=2KK4DyxCFqvuBhLTZRLxVOGLLo0wGS6RJFjzILw/5dQ=; b=JEvgp7s7JISg70zw7nzGFTeJGVRQ5NjByp4c1jv8WB+yPsH/cJxHUsVsm5u1rx1cIG g/0ZLAYVUsItqW2DqLPxi/ULNcuO+4TQcJeHi4c8/KS60kYICvfJ7C1AYMsobphaYhiL zqy3Ake0Jw9p5rRCbYtT/3QgsEYcEhKMrr7WM6hMZ/N9la7oGqsr+E3qBRaf4Hibcs7I s+n0uzrCBKWSKGwkcEpCReUPczOdITmSoxLmLCW+lMOxQCs+p1ek4lInL0sEoJtviZeK lYafyqp9mw76kirvxRGVxmtQxDPn16BJ0Db68KcibHqU5LNhSTvdjNOjkbcBdrOclWGD pQkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=pPZBi0zY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h33si11040212plh.119.2018.12.10.13.19.11; Mon, 10 Dec 2018 13:19:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=pPZBi0zY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728131AbeLJTH5 (ORCPT + 99 others); Mon, 10 Dec 2018 14:07:57 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56710 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbeLJTH5 (ORCPT ); Mon, 10 Dec 2018 14:07:57 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wBAIwvCa107260; Mon, 10 Dec 2018 19:05:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=2KK4DyxCFqvuBhLTZRLxVOGLLo0wGS6RJFjzILw/5dQ=; b=pPZBi0zYRWkV+Fjf2Z5X8MTmHBghQGIUP1vzodQC4tcW5LErkr3ArJ0n7ztwizukcCzq glrkCOn7dTXUYmRBrrJzhFb01n6JYLh/20IhBKT4X8pnHkABUmej1hhUIy8BvpKiaoQb 6h6tE8jYOBn+E/4jb3ImJVBs4rSU+bABpt7b/YcFmzurMJ7t9xi0L8rxNVIK7WMtLm1T uTyHXYves6HKXbDuCBQoOm3hPQwbERREgX16oR0jxLF7MmTgHnmFk3WSKv3BZkdENQw5 +rrFmm+uQh8GA7JcE23dncsl73x7T6mSfD+aO8LeNDOAvy/ny54rymt5uE2GbTLA1mNv og== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2p83fe00vf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 19:05:48 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wBAJ5fsp025518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Dec 2018 19:05:42 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wBAJ5fBj022703; Mon, 10 Dec 2018 19:05:41 GMT Received: from marawils-linux.us.oracle.com (/10.141.196.37) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 10 Dec 2018 11:05:41 -0800 From: Maran Wilson To: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, jgross@suse.com Cc: boris.ostrovsky@oracle.com, bp@suse.de, dave.hansen@linux.intel.com, davem@davemloft.net, gregkh@linuxfoundation.org, hpa@zytor.com, jpoimboe@redhat.com, kirill.shutemov@linux.intel.com, luto@kernel.org, mchehab@kernel.org, mingo@redhat.com, rdunlap@infradead.org, tglx@linutronix.de, thomas.lendacky@amd.com, hch@infradead.org, roger.pau@citrix.com, rkrcmar@redhat.com, maran.wilson@oracle.com Subject: [PATCH v9 0/7] KVM: x86: Allow Qemu/KVM to use PVH entry point Date: Mon, 10 Dec 2018 11:05:34 -0800 Message-Id: <1544468734-32763-1-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9103 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812100169 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For certain applications it is desirable to rapidly boot a KVM virtual machine. In cases where legacy hardware and software support within the guest is not needed, Qemu should be able to boot directly into the uncompressed Linux kernel binary without the need to run firmware. There already exists an ABI to allow this for Xen PVH guests and the ABI is supported by Linux and FreeBSD: https://xenbits.xen.org/docs/unstable/misc/pvh.html This patch series would enable Qemu to use that same entry point for booting KVM guests. Changes from v8: * Removed unused KVM_GUEST_PVH symbol. Changes from v7: (No functional changes from v7 other than rebasing to latest upstream) * Added Review-by tags as provided by Juergen Gross (1,2,3,6,7) * Rebasing to upstream 4.18 caused a minor conflict in patch 4 that had to be hand merged due to this patch: 1fe8388 xen: share start flags between PV and PVH I just had to make sure we were accounting for the xen_start_flags in the new code path. * Rebasing to upstream 4.20-rc4 caused a few minor conflicts in patches 2,3,5,7 that needed to be resolved by hand. The conflicts were due to upstream non-functional code cleanup changes in arch/x86/xen/Makefile and arch/x86/platform/pvh/enlighten.c due to these patches: 28c11b0 x86/xen: Move pv irq related functions under CONFIG_XEN_PV umbrella 357d291 x86/xen: Fix boot loader version reported for PVH guests 3cfa210 xen: don't include from and * Qemu and qboot RFC patches have been posted to show one example of how this functionality can be used. Some preliminary numbers are available in those cover letters showing the KVM guest boot time improvement. Qemu: http://lists.nongnu.org/archive/html/qemu-devel/2018-12/msg00957.html qboot: http://lists.nongnu.org/archive/html/qemu-devel/2018-12/msg00953.html Changes from v6: * Addressed issues caught by the kbuild test robot: - Restored an #include line that had been dropped by mistake (patch 4) - Removed a pair of #include lines that were no longer needed in a common code file and causing problems for certain 32-bit configs (patchs 4 and 7) Changes from v5: * The interface changes to the x86/HVM start info layout have now been accepted into the Xen tree. * Rebase and merge upstream PVH file changes. * (Patch 6) Synced up to the final version of the header file that was acked and pulled into the Xen tree. * (Patch 1) Fixed typo and removed redundant "def_bool n" line. Changes from v4: Note: I've withheld Juergen's earlier "Reviewed-by" tags from patches 1 and 7 since there were minor changes (mostly just addition of CONFIG_KVM_GUEST_PVH as requested) that came afterwards. * Changed subject prefix from RFC to PATCH * Added CONFIG_KVM_GUEST_PVH as suggested * Relocated the PVH common files to arch/x86/platform/pvh/{enlighten.c,head.S} * Realized I also needed to move the objtool override for those files * Updated a few code comments per reviewer feedback * Sent out a patch of the hvm_start_info struct changes against the Xen tree since that is the canonical copy of the header. Discussions on that thread have resulted in some (non-functional) updates to start_info.h (patch 6/7) and those changes are reflected here as well in order to keep the files in sync. The header file has since been ack'ed for the Xen tree by Jan Beulich. Changes from v3: * Implemented Juergen's suggestion for refactoring and moving the PVH code so that CONFIG_XEN is no longer required for booting KVM guests via the PVH entry point. Functionally, nothing has changed from V3 really, but the patches look completely different now because of all the code movement and refactoring. Some of these patches can be combined, but I've left them very small in some cases to make the refactoring and code movement easier to review. My approach for refactoring has been to create a PVH entry layer that still has understanding and knowledge about Xen vs non-Xen guest types so that it can make run time decisions to handle either case, as opposed to going all the way and re-writing it to be a completely hypervisor agnostic and architecturally pure layer that is separate from guest type details. The latter seemed a bit overkill in this situation. And I've handled the complexity of having to support Qemu/KVM boot of kernels compiled with or without CONFIG_XEN via a pair of xen specific __weak routines that can be overridden in kernels that support Xen guests. Importantly, the __weak routines are for xen specific code only (not generic "guest type" specific code) so there is no clashing between xen version of the strong routine and, say, a KVM version of the same routine. But I'm sure there are many ways to skin this cat, so I'm open to alternate suggestions if there is a compelling reason for not using __weak in this situation. Changes from v2: * All structures (including memory map table entries) are padded and aligned to an 8 byte boundary. * Removed the "packed" attributes and made changes to comments as suggested by Jan. Changes from v1: * Adopted Paolo's suggestion for defining a v2 PVH ABI that includes the e820 map instead of using the second module entry to pass the table. * Cleaned things up a bit to reduce the number of xen vs non-xen special cases. Maran Wilson (7): xen/pvh: Split CONFIG_XEN_PVH into CONFIG_PVH and CONFIG_XEN_PVH xen/pvh: Move PVH entry code out of Xen specific tree xen/pvh: Create a new file for Xen specific PVH code xen/pvh: Move Xen specific PVH VM initialization out of common file xen/pvh: Move Xen code for getting mem map via hcall out of common file xen/pvh: Add memory map pointer to hvm_start_info struct KVM: x86: Allow Qemu/KVM to use PVH entry point MAINTAINERS | 1 + arch/x86/Kbuild | 2 + arch/x86/Kconfig | 6 ++ arch/x86/kernel/head_64.S | 2 +- arch/x86/platform/pvh/Makefile | 5 + arch/x86/platform/pvh/enlighten.c | 137 ++++++++++++++++++++++++ arch/x86/{xen/xen-pvh.S => platform/pvh/head.S} | 0 arch/x86/xen/Kconfig | 3 +- arch/x86/xen/Makefile | 2 - arch/x86/xen/enlighten_pvh.c | 94 ++++------------ include/xen/interface/hvm/start_info.h | 63 ++++++++++- include/xen/xen.h | 3 + 12 files changed, 237 insertions(+), 81 deletions(-) create mode 100644 arch/x86/platform/pvh/Makefile create mode 100644 arch/x86/platform/pvh/enlighten.c rename arch/x86/{xen/xen-pvh.S => platform/pvh/head.S} (100%) -- 2.16.1