Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp867497imp; Thu, 21 Feb 2019 12:57:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IZfQdTBuuAAB5zFXHOtUGQEGaf3oHbH3XddtXpy7l4iwDqcjqN1s5waBn/S5beCCvvWTg+k X-Received: by 2002:a17:902:8bc6:: with SMTP id r6mr486047plo.235.1550782632339; Thu, 21 Feb 2019 12:57:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550782632; cv=none; d=google.com; s=arc-20160816; b=ospbGVF1N7R3mA9asFFJDN3aFZ4NLpfTtsYpTTruPNWtD2WW6VF8u8gee3gEG6WxxR qVbKd5gds3uQjCj1lxmRb2KQW9A9nTW3/2ebIbYlBvrYBGC/1KtNCAW2kb+OejhBkAl/ FBJiUfdecMEsNbj37lWXt9+o2Bv/oULAPWEUGDT1+2a26Ij85dQESE6NGgQ+v/p1Pvnq 80fhoSHJ5xdPSjVriiGU1aBjQ/WDCD+hRzA8yP4I90+xw40Em/8UG4+vVqGPYvFeDE+o W0aVgvxn5Df2FK7/QiWBX7APRGtgwMDYTx7FHqQHV89zKTp4dA6kjt6nV2a0p5AuPAgD G9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:date:message-id:from :references:cc:to:subject:dkim-signature; bh=GAYiQfikElUCJ+tuWkFXEkJ6hrDbvTfboL2Nu7/SVhc=; b=dTePiATsXo78U8xgP/ke6N0WXdojBn/SOn98JFBBqx/IPYUKEMS4s+HLdPAsw5bCbj s1eBjM+6fS88LbeBEUb2c9zfpHGqD9gtj0DY/DYJqAeazXIvoD7k8xca1ZYBd7yoM++/ MIjIf1eVRXftijkeOV6Id73iRhlXF4KEzpuoDUwVfBkCa0PvMcE+S+9w7rCsTE4dVGgY PTvFo0kgFUP6FRnvo3Hbrv0PXMWSAmFRaJIfT80nduiGrsRuco3Z16/3mPgOL8smi1hC Si6Tn2xD+11tA2s65cJSaagV53tX9g2h4U440YQKOpasGd7Sn6e6yke3pFhHSiZckv3U I+QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="v/yujilo"; 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 l184si18654610pgd.50.2019.02.21.12.56.56; Thu, 21 Feb 2019 12:57:12 -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="v/yujilo"; 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 S1726409AbfBUU4c (ORCPT + 99 others); Thu, 21 Feb 2019 15:56:32 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:58312 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbfBUU4c (ORCPT ); Thu, 21 Feb 2019 15:56:32 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1LKnT8X135715; Thu, 21 Feb 2019 20:56:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=GAYiQfikElUCJ+tuWkFXEkJ6hrDbvTfboL2Nu7/SVhc=; b=v/yujilo7snk1Be2I1C9UILAih/OlP/3MKYxyf/2q5jQThMki2RcaMMZr17Hxx330IiQ jfZq3rhaEH4peE23dwDeRssxouCT9zFS2FF4fo3X9zpjem+rJv6gYB8wlGJ5nhCpCHKa uR5QJdwobT2nEwqTvHmKXzD6a1dYW6KyVX7uErsfS1AG8ZDyK7HZAXPjMTFoPSCka0vE r/Yl/zThQRC/tVUJzvFbbFGJXSOR7GWG27ol/CZmaBh2kEL9XVH1+7OGlPY1FXZdXqof hudCCnwFjaZToVPqRLZyRqYM21wHKx7HtGEm3rbJA4b3E9J8mwubikF+9mpJcFFQCnY5 VQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qp9xuatdk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Feb 2019 20:56:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x1LKuDNp022479 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Feb 2019 20:56:13 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x1LKuCTj004016; Thu, 21 Feb 2019 20:56:12 GMT Received: from [10.175.213.26] (/10.175.213.26) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 21 Feb 2019 12:56:11 -0800 Subject: Re: [PATCH RFC 02/39] KVM: x86/xen: intercept xen hypercalls if enabled To: Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ankur Arora , Boris Ostrovsky , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org References: <20190220201609.28290-1-joao.m.martins@oracle.com> <20190220201609.28290-3-joao.m.martins@oracle.com> <20190221182910.GC7224@linux.intel.com> From: Joao Martins Message-ID: <1f6a2410-f9da-15ed-327c-7d8c1255368b@oracle.com> Date: Thu, 21 Feb 2019 20:56:06 +0000 MIME-Version: 1.0 In-Reply-To: <20190221182910.GC7224@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9174 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902210142 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/21/19 6:29 PM, Sean Christopherson wrote: > On Wed, Feb 20, 2019 at 08:15:32PM +0000, Joao Martins wrote: >> Add a new exit reason for emulator to handle Xen hypercalls. >> Albeit these are injected only if guest has initialized the Xen >> hypercall page - the hypercall is just a convenience but one >> that is done by pretty much all guests. Hence if the guest >> sets the hypercall page, we assume a Xen guest is going to >> be set up. >> >> Emulator will then panic with: >> >> KVM: unknown exit reason 28 >> RAX=0000000000000011 RBX=ffffffff81e03e94 RCX=0000000040000000 >> RDX=0000000000000000 >> RSI=ffffffff81e03e70 RDI=0000000000000006 RBP=ffffffff81e03e90 >> RSP=ffffffff81e03e68 >> R8 =73726576206e6558 R9 =ffffffff81e03e90 R10=ffffffff81e03e94 >> R11=2e362e34206e6f69 >> R12=0000000040000004 R13=ffffffff81e03e8c R14=ffffffff81e03e88 >> R15=0000000000000000 >> RIP=ffffffff81001228 RFL=00000082 [--S----] CPL=0 II=0 A20=1 SMM=0 HLT=0 >> ES =0000 0000000000000000 ffffffff 00c00000 >> CS =0010 0000000000000000 ffffffff 00a09b00 DPL=0 CS64 [-RA] >> SS =0000 0000000000000000 ffffffff 00c00000 >> DS =0000 0000000000000000 ffffffff 00c00000 >> FS =0000 0000000000000000 ffffffff 00c00000 >> GS =0000 ffffffff81f34000 ffffffff 00c00000 >> LDT=0000 0000000000000000 ffffffff 00c00000 >> TR =0020 0000000000000000 00000fff 00808b00 DPL=0 TSS64-busy >> GDT= ffffffff81f3c000 0000007f >> IDT= ffffffff83265000 00000fff >> CR0=80050033 CR2=ffff880001fa6ff8 CR3=0000000001fa6000 CR4=000406a0 >> DR0=0000000000000000 DR1=0000000000000000 DR2=0000000000000000 >> DR3=0000000000000000 >> DR6=00000000ffff0ff0 DR7=0000000000000400 >> EFER=0000000000000d01 >> Code=cc cc cc cc cc cc cc cc cc cc cc cc b8 11 00 00 00 0f 01 c1 cc >> cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc b8 12 >> 00 00 00 0f >> >> Signed-off-by: Joao Martins >> --- >> arch/x86/include/asm/kvm_host.h | 13 +++++++ >> arch/x86/kvm/Makefile | 2 +- >> arch/x86/kvm/trace.h | 33 +++++++++++++++++ >> arch/x86/kvm/x86.c | 12 +++++++ >> arch/x86/kvm/xen.c | 79 +++++++++++++++++++++++++++++++++++++++++ >> arch/x86/kvm/xen.h | 10 ++++++ >> include/uapi/linux/kvm.h | 17 ++++++++- >> 7 files changed, 164 insertions(+), 2 deletions(-) >> create mode 100644 arch/x86/kvm/xen.c >> create mode 100644 arch/x86/kvm/xen.h > > ... > >> diff --git a/arch/x86/kvm/Makefile b/arch/x86/kvm/Makefile >> index 31ecf7a76d5a..2b46c93c9380 100644 >> --- a/arch/x86/kvm/Makefile >> +++ b/arch/x86/kvm/Makefile >> @@ -10,7 +10,7 @@ kvm-$(CONFIG_KVM_ASYNC_PF) += $(KVM)/async_pf.o >> >> kvm-y += x86.o mmu.o emulate.o i8259.o irq.o lapic.o \ >> i8254.o ioapic.o irq_comm.o cpuid.o pmu.o mtrr.o \ >> - hyperv.o page_track.o debugfs.o >> + hyperv.o xen.o page_track.o debugfs.o > > Can this be wrapped in a config? Or even better, as a loadable module? Turning that into a loadable module might be a little trickier, but I think it is doable if that's what folks/maintainers would prefer. The Xen addition follows the same structure as Hyper-V in kvm (what you suggest here is probably applicable for both). i.e. there's some Xen specific routines for vm/vcpu init/teardown, and timer handling. We would have to place some of those functions into a struct that gets registered at modinit. > 2k+ lines of code is a non-trival amount of baggage for folks that don't > care about running Xen guests. I've only glanced through the series, so > I've no idea if the resulting code would be an abomination. > >> >> kvm-intel-y += vmx/vmx.o vmx/vmenter.o vmx/pmu_intel.o vmx/vmcs12.o vmx/evmcs.o vmx/nested.o >> kvm-amd-y += svm.o pmu_amd.o