From patchwork Wed Aug 19 16:51:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724665 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 110EC618 for ; Wed, 19 Aug 2020 16:53:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DFD5E207FF for ; Wed, 19 Aug 2020 16:53:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="or7mw6CE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFD5E207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RK1-0003ke-CI; Wed, 19 Aug 2020 16:52:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RK0-0003kZ-LG for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:20 +0000 X-Inumbo-ID: 7fe40239-f4b7-49b4-9c41-a29fe5a3a1f3 Received: from mail-qk1-x744.google.com (unknown [2607:f8b0:4864:20::744]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7fe40239-f4b7-49b4-9c41-a29fe5a3a1f3; Wed, 19 Aug 2020 16:52:19 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id g26so22234013qka.3 for ; Wed, 19 Aug 2020 09:52:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=o8NsCKzA6WRTBrSnDhC70WmZpWrA7tMMr87qsIxTF40=; b=or7mw6CE7ZHJHTWLAA6az4SyS7RVqBPInRmZK8ZHWu3vO1uHeLX/S0uMydfzMh+kcd 61SUhJMTUBrjxAlLWs1Q3b3i6ubUTt3HieM9LcY/iPIhDVDEE/Q4oX9VOd72QOB+J4C8 8dwNcbPalbBDTwreaVrhasg3D74OdKzq1tT7PuhhLTCXpHBv3lKKGxht02ov19IE6x+O SedYMSnsR9wYID9j52cVn40ms/ujJLmJXJx2uixjy3Q6ui4de0ZT+08ORPSvNGTcvJuO orwV7NPVWK0iGWFeEJ1mXHk90lmEjqEbZGsiqg2NgTg7W1/6oUNGqcOnZi2NbnCbzWX3 OsUA== 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:in-reply-to :references:in-reply-to:references; bh=o8NsCKzA6WRTBrSnDhC70WmZpWrA7tMMr87qsIxTF40=; b=cANjJX/b10vplHg+5u6tlJzZY3jj4GPrqC/cxJ2SbBRg/6SHtvPLgcyxz+ciNN+qqG 4LCzdvjvcCQObx2/dih3+LmQTNSmWcyt1AL3HAlk1vd/7rM2GW22LrjNHSLluaZ7mWhL 8HK82pA4vZFgx4CAf4EIj378e8Ns5i4RM+ItSs/zfHaYyzemscmG6c8FUkKi8DmZjgBY rbAK0C4OYBat3BOdmfDefkKnVNH9GbDscur8YIqM/oTS5U/aJ3FarWFL2gJPPHEq5Rd0 7LwzGonCt4x6aezvlgr26gnB6DHK9rNLGLngOP4egq0HTsDceL2Oqc6jZDciGEaDqhhS Ds1Q== X-Gm-Message-State: AOAM531MVRwb2blQ9IFqeDed0tRbMwSk4V4phUzuhqeTvXAzfHrcMUs0 07eX18bRQv25qV0TdArdtzJOULyR5FoFu4JE X-Google-Smtp-Source: ABdhPJyFJtKozsnnsbOOoPYSGupD2wNujEjLeKexbnZ0L7bSO4PguO/vorL+e12kdCtmqli1SHtZcw== X-Received: by 2002:a37:84c:: with SMTP id 73mr22337947qki.464.1597855939132; Wed, 19 Aug 2020 09:52:19 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:18 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 1/8] tools: Add vga=vmware Date: Wed, 19 Aug 2020 12:51:55 -0400 Message-Id: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This allows use of QEMU's VMware emulated video card NOTE: vga=vmware is not supported by device_model_version=qemu-xen-traditional Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Ian Campbell Reviewed-by: Konrad Rzeszutek Wilk v14: Reworked to current code. Added below --- Reviewed-by: Konrad Rzeszutek v13: Added Acked-by: Ian Campbell v12: Dropped LIBXL_HAVE_LIBXL_VGA_INTERFACE_TYPE_VMWARE This means that the later patch that defines LIBXL_HAVE_VMWARE is now also required. v11: Dropped support for Qemu-trad. Also changed later patchs to not need this one. v10: New at v10. Was part of "tools: Add vmware_hwver support" docs/man/xl.cfg.5.pod.in | 4 +++- tools/libxl/libxl_dm.c | 9 +++++++++ tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 2 ++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 0532739..a9eae96 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2396,7 +2396,7 @@ B. =item B Selects the emulated video card. -Options are: B, B, B and B. +Options are: B, B, B, B and B. The default is B. In general, QXL should work with the Spice remote display protocol @@ -2404,6 +2404,8 @@ for acceleration, and a QXL driver is necessary in the guest in that case. QXL can also work with the VNC protocol, but it will be like a standard VGA card without acceleration. +NOTE: B is not supported on B + =item B Allow access to the display via the VNC protocol. This enables the diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index f2dc569..415c12e 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -808,6 +808,10 @@ static int libxl__build_device_model_args_old(libxl__gc *gc, case LIBXL_VGA_INTERFACE_TYPE_NONE: flexarray_append_pair(dm_args, "-vga", "none"); break; + case LIBXL_VGA_INTERFACE_TYPE_VMWARE: + LOG(ERROR, "vga=vmware is not supported by " + "qemu-xen-traditional"); + return ERROR_INVAL; case LIBXL_VGA_INTERFACE_TYPE_QXL: break; default: @@ -1446,6 +1450,11 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, GCSPRINTF("qxl-vga,vram_size_mb=%"PRIu64",ram_size_mb=%"PRIu64, (b_info->video_memkb/2/1024), (b_info->video_memkb/2/1024) ) ); break; + case LIBXL_VGA_INTERFACE_TYPE_VMWARE: + flexarray_append_pair(dm_args, "-device", + GCSPRINTF("vmware-svga,vgamem_mb=%d", + libxl__sizekb_to_mb(b_info->video_memkb))); + break; default: LOGD(ERROR, guest_domid, "Invalid emulated video card specified"); return ERROR_INVAL; diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9d3f05f..36350d2 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -220,6 +220,7 @@ libxl_vga_interface_type = Enumeration("vga_interface_type", [ (2, "STD"), (3, "NONE"), (4, "QXL"), + (5, "VMWARE"), ], init_val = "LIBXL_VGA_INTERFACE_TYPE_UNKNOWN") libxl_vendor_device = Enumeration("vendor_device", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 61b4ef7..c74a9e3 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -2590,6 +2590,8 @@ skip_usbdev: b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_NONE; } else if (!strcmp(buf, "qxl")) { b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_QXL; + } else if (!strcmp(buf, "vmware")) { + b_info->u.hvm.vga.kind = LIBXL_VGA_INTERFACE_TYPE_VMWARE; } else { fprintf(stderr, "Unknown vga \"%s\" specified\n", buf); exit(1); From patchwork Wed Aug 19 16:51:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724681 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A20A514F6 for ; Wed, 19 Aug 2020 16:54:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 73B8820885 for ; Wed, 19 Aug 2020 16:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YdvE7fnE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73B8820885 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKB-0003nb-7d; Wed, 19 Aug 2020 16:52:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKA-0003kZ-KY for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:30 +0000 X-Inumbo-ID: 4e0e270c-728b-40c8-b4a1-e30d4472be23 Received: from mail-qt1-x843.google.com (unknown [2607:f8b0:4864:20::843]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4e0e270c-728b-40c8-b4a1-e30d4472be23; Wed, 19 Aug 2020 16:52:21 +0000 (UTC) Received: by mail-qt1-x843.google.com with SMTP id x12so18308891qtp.1 for ; Wed, 19 Aug 2020 09:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=8SYC8sEnMQTsHzsw/bx/BLngdPeGac6jdXJvvh92/2k=; b=YdvE7fnE4fXmnC+AL4dirmXy6rFjNOVTUiQZ0fVL5Z5J9b3Cje8Zcg4vr4CHYuYhb1 7uq0Aje58DADmqsa3WZDdSTCR9WM636LghCWxGCfMda04/yVa/yhIwBzXZMc+JCQ8g5m nqEW9kUjt7p9AhUnMtITqBboj/0nXoteYItDpZxNe1WfVSVjaPAoeYm8U4GEeI0yJxmC hSM4p9EsrN73/E/LmkGwIao3X0OSoSNUauiC+NJucGWuaKhZAHDauFhXIUo/gkT2HpTB b9Q7Z1sQUgRinCp3id3CHt7UVFt/kIg868oQmh4NdJGaCTKXUZMWvsJsoIj0mPyGiGPy QIbQ== 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:in-reply-to :references:in-reply-to:references; bh=8SYC8sEnMQTsHzsw/bx/BLngdPeGac6jdXJvvh92/2k=; b=WyKtfn7mhLzb1J/vHHlQ4Qg5Rgh9ig0h2NpOQyOtKlBvM4tbUmVFpr/nvxbEL6ZUIX v8Cc5eJWk4maYAKnGrAqDGq2Amt6z59rcpnhE5qanBvSvn8NzJn2fuCIlAor1x2PqA87 bEH7Weuu0uCRCckRy7iPWa+rNBIWv/gXtVj5xonx+NUcFwLHR818idcToT9xQuFv+I5I AtwlRco1aSuvzPe0rohjWIzreIiBTtBgpDGzxvVug78StZixDPRdZZQfYkwFv9DNXj0d k+hnt/9uWVSDQmTfsEPifKQI/f6cipOqhudK1CBq4qP8pWVwx5X1u8lz3VsCUbjlEiHW z+lg== X-Gm-Message-State: AOAM5308+YZQxuG8Mh2SHvIjARyLz1zu76r+UrHHfufH+qQcsSkj9NHw Sy/yZZaE51yu9BDc4LKpuQI+obnpIm7QUu3u X-Google-Smtp-Source: ABdhPJzlcFdccey/j/56pBX2TIswRx3uE9pXL3vzRNKKZGunQfi0TvE2d80UfVZ32hTKuYIVyWUs9w== X-Received: by 2002:ac8:4514:: with SMTP id q20mr23701170qtn.122.1597855940174; Wed, 19 Aug 2020 09:52:20 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:19 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 2/8] xen: Add support for VMware cpuid leaves Date: Wed, 19 Aug 2020 12:51:56 -0400 Message-Id: <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This is done by adding xen_arch_domainconfig vmware_hw. It is set to the VMware virtual hardware version. Currently 0, 3-4, 6-11 are good values. However the code only checks for == 0 or != 0 or >= 7. If non-zero then Return VMware's cpuid leaves. If >= 7 return data, else return 0. The support of hypervisor cpuid leaves has not been agreed to. MicroSoft Hyper-V (AKA viridian) currently must be at 0x40000000. VMware currently must be at 0x40000000. KVM currently must be at 0x40000000 (from Seabios). Xen can be found at the first otherwise unused 0x100 aligned offset between 0x40000000 and 0x40010000. http://download.microsoft.com/download/F/B/0/FB0D01A3-8E3A-4F5F-AA59-08C8026D3B8A/requirements-for-implementing-microsoft-hypervisor-interface.docx http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 http://lwn.net/Articles/301888/ Attempted to get this cleaned up. So based on this, I picked the order: Xen at 0x40000000 or Viridian or VMware at 0x40000000 and Xen at 0x40000100 If both Viridian and VMware selected, report an error. Since I need to change xen/arch/x86/hvm/Makefile; also add a newline at end of file. Signed-off-by: Don Slutz CC: Don Slutz --- Reviewed-by: Andrew Cooper Tools side only: Acked-by: Ian Campbell v14: Reworked to current code. Changed vmware_hwver to 32 bits v13: Adjust temporary comment to include which patch. Adjust copyright year to 2012-2015 v12: No change v11: Adjust /* Disallow if vmware_hwver */ Newline after break; Added Reviewed-by: Andrew Cooper. It would be worth to add an explicit vmware_hwver = 0 in the libxl__arch_domain_prepare_config. Note: Adds a tool change to this patch. v10: Did not add "Reviewed-by: Andrew Cooper " because of changes here to do things the new way. Reword comment message to reflect new way. v9: s/vmware_hw/vmware_hwver/i Change -EXDEV to EOPNOTSUPP. Done. adding another subdirectory: xen/arch/x86/hvm/vmware Much will depend on the discussion of the subsequent patches. TBD. So for versions < 7 there's effectively no CPUID support at all? Changed to check at entry. The comment /* Params for VMware */ seems wrong... Changed to /* emulated VMware Hardware Version */ Also please use d, not _d in #define is_vmware_domain() Changed. Line is now > 80 characters, so split into 2. v7: Prevent setting of HVM_PARAM_VIRIDIAN if HVM_PARAM_VMWARE_HW set. v5: Given how is_viridian and is_vmware are defined I think '||' is more appropriate. Fixed. The names of all three functions are bogus. removed static support routines. This hunk is unrelated, but is perhaps something better fixed. Added to commit message. include (IIRC) please. Done. At least 1 pair of brackets please, especially as the placement of brackets affects the result of this particular calculation. Switch to "1000000ull / APIC_BUS_CYCLE_NS" tools/libxl/libxl_x86.c | 2 + xen/arch/x86/cpuid.c | 4 ++ xen/arch/x86/domain.c | 5 +++ xen/arch/x86/hvm/Makefile | 1 + xen/arch/x86/hvm/hvm.c | 8 ++++ xen/arch/x86/hvm/vmware/Makefile | 1 + xen/arch/x86/hvm/vmware/vmware.c | 82 +++++++++++++++++++++++++++++++++++++++ xen/arch/x86/traps.c | 21 ++++++---- xen/include/asm-x86/hvm/domain.h | 3 ++ xen/include/asm-x86/hvm/hvm.h | 15 +++++++ xen/include/asm-x86/hvm/vmware.h | 33 ++++++++++++++++ xen/include/public/arch-x86/xen.h | 1 + 12 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 xen/arch/x86/hvm/vmware/Makefile create mode 100644 xen/arch/x86/hvm/vmware/vmware.c create mode 100644 xen/include/asm-x86/hvm/vmware.h diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index e57f632..3418a81 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -21,6 +21,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, abort(); } + /* Note: will be changed in next patch (tools: Add ...). */ + config->arch.vmware_hwver = 0; return 0; } diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 63a03ef..6cd3670 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -791,6 +792,9 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf, if ( is_viridian_domain(d) ) return cpuid_viridian_leaves(v, leaf, subleaf, res); + if ( has_vmware_cpuid(d) ) + return cpuid_vmware_leaves(v, leaf, subleaf, res); + /* * Fallthrough. * diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d1ecc7b..a317907 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -597,6 +597,11 @@ int arch_domain_create(struct domain *d, } d->arch.emulation_flags = emflags; + if ( is_hvm_domain(d) ) + { + d->arch.hvm.vmware_hwver = config->arch.vmware_hwver; + } + HYPERVISOR_COMPAT_VIRT_START(d) = is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u; diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index 3464191..58de573 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -1,6 +1,7 @@ obj-y += svm/ obj-y += vmx/ obj-y += viridian/ +obj-y += vmware/ obj-y += asid.o obj-y += dm.o diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index a9d1685..e91169f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -4109,6 +4110,13 @@ static int hvm_allow_set_param(struct domain *d, { /* The following parameters should only be changed once. */ case HVM_PARAM_VIRIDIAN: + /* Disallow if vmware_hwver is in use */ + if ( d->arch.hvm.vmware_hwver ) + { + rc = -EOPNOTSUPP; + break; + } + /* Fall through */ case HVM_PARAM_IOREQ_PFN: case HVM_PARAM_BUFIOREQ_PFN: case HVM_PARAM_IOREQ_SERVER_PFN: diff --git a/xen/arch/x86/hvm/vmware/Makefile b/xen/arch/x86/hvm/vmware/Makefile new file mode 100644 index 0000000..f864486 --- /dev/null +++ b/xen/arch/x86/hvm/vmware/Makefile @@ -0,0 +1 @@ +obj-y += vmware.o diff --git a/xen/arch/x86/hvm/vmware/vmware.c b/xen/arch/x86/hvm/vmware/vmware.c new file mode 100644 index 0000000..19e52c1 --- /dev/null +++ b/xen/arch/x86/hvm/vmware/vmware.c @@ -0,0 +1,82 @@ +/* + * arch/x86/hvm/vmware/cpuid.c + * + * Copyright (C) 2012-2015 Verizon Corporation + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License Version 2 (GPLv2) + * as published by the Free Software Foundation. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * VMware hardware version 7 defines some of these cpuid levels, + * below is a brief description about those. + * + * Leaf 0x40000000, Hypervisor CPUID information + * # EAX: The maximum input value for hypervisor CPUID info (0x40000010). + * # EBX, ECX, EDX: Hypervisor vendor ID signature. E.g. "VMwareVMware" + * + * Leaf 0x40000010, Timing information. + * # EAX: (Virtual) TSC frequency in kHz. + * # EBX: (Virtual) Bus (local apic timer) frequency in kHz. + * # ECX, EDX: RESERVED + */ + +void cpuid_vmware_leaves(const struct vcpu *v, uint32_t leaf, + uint32_t subleaf, struct cpuid_leaf *res) +{ + struct domain *d = current->domain; + + ASSERT(has_vmware_cpuid(d)); + ASSERT(leaf >= 0x40000000 && leaf < 0x40000100); + + leaf -= 0x40000000; + + switch ( leaf ) + { + case 0x0: + res->a = 0x40000010; /* Maximum leaf */ + memcpy(&res->b, "VMwa", 4); + memcpy(&res->c, "reVM", 4); + memcpy(&res->d, "ware", 4); + break; + + case 0x10: + /* (Virtual) TSC frequency in kHz. */ + res->a = d->arch.tsc_khz; + /* (Virtual) Bus (local apic timer) frequency in kHz. */ + res->b = 1000000ull / APIC_BUS_CYCLE_NS; + res->c = 0; /* Reserved */ + res->d = 0; /* Reserved */ + break; + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index bc5b8f8..b1e93bb 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -885,8 +885,11 @@ static void do_trap(struct cpu_user_regs *regs) int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val) { const struct domain *d = v->domain; - /* Optionally shift out of the way of Viridian architectural MSRs. */ - uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; + /* + * Optionally shift out of the way of Viridian or VMware + * architectural leaves. + */ + uint32_t base = is_viridian_or_vmware_cpuid(d) ? 0x40000200 : 0x40000000; switch ( idx - base ) { @@ -901,8 +904,11 @@ int guest_rdmsr_xen(const struct vcpu *v, uint32_t idx, uint64_t *val) int guest_wrmsr_xen(struct vcpu *v, uint32_t idx, uint64_t val) { struct domain *d = v->domain; - /* Optionally shift out of the way of Viridian architectural MSRs. */ - uint32_t base = is_viridian_domain(d) ? 0x40000200 : 0x40000000; + /* + * Optionally shift out of the way of Viridian or VMware + * architectural leaves. + */ + uint32_t base = is_viridian_or_vmware_cpuid(d) ? 0x40000200 : 0x40000000; switch ( idx - base ) { @@ -959,9 +965,10 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf, { const struct domain *d = v->domain; const struct cpuid_policy *p = d->arch.cpuid; - uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000; + uint32_t base = is_viridian_or_vmware_cpuid(d) ? 0x40000100 : 0x40000000; uint32_t idx = leaf - base; - unsigned int limit = is_viridian_domain(d) ? p->hv2_limit : p->hv_limit; + unsigned int limit = is_viridian_or_vmware_cpuid(d) ? + p->hv2_limit : p->hv_limit; if ( limit == 0 ) /* Default number of leaves */ @@ -989,7 +996,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf, case 2: res->a = 1; /* Number of hypercall-transfer pages */ /* MSR base address */ - res->b = is_viridian_domain(d) ? 0x40000200 : 0x40000000; + res->b = is_viridian_or_vmware_cpuid(d) ? 0x40000200 : 0x40000000; if ( is_pv_domain(d) ) /* Features */ res->c |= XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD; break; diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index 9d247ba..0f64a4b 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -147,6 +147,9 @@ struct hvm_domain { uint64_t *params; + /* emulated VMware Hardware Version */ + uint32_t vmware_hwver; + /* Memory ranges with pinned cache attributes. */ struct list_head pinned_cacheattr_ranges; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index be0d8b0..cb55dfb 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -474,6 +474,18 @@ static inline bool hvm_get_guest_bndcfgs(struct vcpu *v, u64 *val) #define has_viridian_synic(d) \ (is_viridian_domain(d) && (viridian_feature_mask(d) & HVMPV_synic)) +#define vmware_feature_mask(d) \ + ((d)->arch.hvm.vmware_hwver) + +#define is_vmware_domain(d) \ + (is_hvm_domain(d) && vmware_feature_mask(d)) + +#define has_vmware_cpuid(d) \ + (is_hvm_domain(d) && (vmware_feature_mask(d) >= 7)) + +#define is_viridian_or_vmware_cpuid(d) \ + (is_viridian_domain(d) || has_vmware_cpuid(d)) + static inline void hvm_inject_exception( unsigned int vector, unsigned int type, unsigned int insn_len, int error_code) @@ -754,6 +766,9 @@ static inline bool hvm_has_set_descriptor_access_exiting(void) #define is_viridian_domain(d) ((void)(d), false) #define is_viridian_vcpu(v) ((void)(v), false) #define has_viridian_time_ref_count(d) ((void)(d), false) +#define is_vmware_domain(d) ((void)(d), false) +#define has_vmware_cpuid(d) ((void)(d), false) +#define is_viridian_or_vmware_cpuid(d) ((void)(d), false) #define hvm_long_mode_active(v) ((void)(v), false) #define hvm_get_guest_time(v) ((void)(v), 0) diff --git a/xen/include/asm-x86/hvm/vmware.h b/xen/include/asm-x86/hvm/vmware.h new file mode 100644 index 0000000..98248e7 --- /dev/null +++ b/xen/include/asm-x86/hvm/vmware.h @@ -0,0 +1,33 @@ +/* + * asm-x86/hvm/vmware.h + * + * Copyright (C) 2012-2015 Verizon Corporation + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License Version 2 (GPLv2) + * as published by the Free Software Foundation. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. . + */ + +#ifndef ASM_X86_HVM_VMWARE_H__ +#define ASM_X86_HVM_VMWARE_H__ + +#include + +void cpuid_vmware_leaves(const struct vcpu *v, uint32_t leaf, + uint32_t subleaf, struct cpuid_leaf *res); + +#endif /* ASM_X86_HVM_VMWARE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index 629cb2b..54b1c4d 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -304,6 +304,7 @@ struct xen_arch_domainconfig { XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIRQ |\ XEN_X86_EMU_VPCI) uint32_t emulation_flags; + uint32_t vmware_hwver; }; /* Location of online VCPU bitmap. */ From patchwork Wed Aug 19 16:51:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AD46618 for ; Wed, 19 Aug 2020 16:53:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 412B4207FF for ; Wed, 19 Aug 2020 16:53:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nt34M22L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 412B4207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKG-0003oW-GX; Wed, 19 Aug 2020 16:52:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKF-0003kZ-KZ for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:35 +0000 X-Inumbo-ID: 701a3ca8-835e-4475-a585-f8387a64ef99 Received: from mail-qt1-x844.google.com (unknown [2607:f8b0:4864:20::844]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 701a3ca8-835e-4475-a585-f8387a64ef99; Wed, 19 Aug 2020 16:52:21 +0000 (UTC) Received: by mail-qt1-x844.google.com with SMTP id h21so18273845qtp.11 for ; Wed, 19 Aug 2020 09:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=cWulFsHkNsMNGC2uvEY33xRgo78iJDptDGbhfvQXNSY=; b=nt34M22LhQ1cPr4+nW9rwrLB32z5vE3SvLB0ziE3HRWakRRfJKH3MoxzP8nCtY1+XN cTbINjuAKiky9/Nwa3dPldHvY5ITG3DnEmwteyijN6RB1NK6IZ4uDyoTvmrClSeWlWEK CKAa5wI1mtlRKgYoC+7GjvsVMKNpx0dyQDCpJRVXLum7rwGgQvAH78k1+S5AwxCnCunW x34sfJfjlUnA4bschugwDTCpLP99IPl1IdvXzOHGBI8Rq5T8GMPdyALA0KH316urzWt6 qHMzrPMYAmKnbQ/j+jWTpJuQlOZ6sDFCe7nK8tVoiqYYqBQcIjf/Qtwck0aizipMcx3V M3yg== 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:in-reply-to :references:in-reply-to:references; bh=cWulFsHkNsMNGC2uvEY33xRgo78iJDptDGbhfvQXNSY=; b=iAxrzDkarXqXJf8sQ0MRVkvImdtrsBkIyVVmpNK7r9X/3+TP7ptgN8VXl+X5p2KLrs zpLdWMCVoeO31Ql5kd+DcJqezl2SLGWbybYFd4BrV9mAA/6q3Pah6ke40LD8OKDupc1Z JA9ynGa5pakxu1z7ep2pP+2uMMnQaJvb0Uh6RtxcEBNvBK11zF5zh1jJBd2tk4j67DvZ RhZezLRgj+58tFYStDTFnXmqenzgPN21QZfyOqig7Tw5/KCKBDflhZNua9b2x9iSiPE/ uy/2RsS1VqIZ6JZN9a/IUDKyPkBSo4EPK21u/5dQywtsXwCgJxyjpyG9wrUDJx+GFmaq /oVQ== X-Gm-Message-State: AOAM533JYwL/U7QdHDkCZzJKgayAixcPXmj1pRv0+6uChBEr269dqNe0 3HDjRUMtym3wwY72sHzNvLN3mLg3yvPHwmPZ X-Google-Smtp-Source: ABdhPJyREnuFIxcunzazKQW44dQPm0Jfaa9gruk7tvcOZ9HQbKF2VbFaQdLSNdDsZ5SvI8HHCiXFfA== X-Received: by 2002:ac8:1788:: with SMTP id o8mr22064948qtj.330.1597855941268; Wed, 19 Aug 2020 09:52:21 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:20 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 3/8] tools: Add vmware_hwver support Date: Wed, 19 Aug 2020 12:51:57 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This is used to set xen_arch_domainconfig vmware_hw. It is set to the emulated VMware virtual hardware version. Currently 0, 3-4, 6-11 are good values. However the code only checks for == 0, != 0, or < 7. Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Ian Campbell v14: Reworked to current code. v13: Added: Acked-by: Ian Campbell v12: I'm not sure this hunk has anything to do with this patch, nor what the semantic difference between the old and new text is supposed to be. Dropped comment change. v11: Dropped "If non-zero then default VGA to VMware's VGA" v10: LIBXL_HAVE_LIBXL_VGA_INTERFACE_TYPE_VMWARE & LIBXL_HAVE_BUILDINFO_HVM_VMWARE_HWVER are arriving together a single umbrella could be used. Since I split the LIBXL_VGA_INTERFACE_TYPE_VMWARE into it's own patch, this is not longer true. But I did use 1 for the 2 c_info changes. Please use GCSPRINTF. Remove vga=vmware from here. v9: I assumed that s/vmware_hw/vmware_hwver/ is not a big enough change to drop the Reviewed-by. Did a minor edit to the commit message to add 7 to the list of values checked. v7: Default handling of hvm.vga.kind bad. Fixed. Default of vmware_port should be based on vmware_hw. Done. v5: Anything looking for Xen according to the Xen cpuid instructions... Adjusted doc to new wording. docs/man/xl.cfg.5.pod.in | 17 +++++++++++++++++ tools/libxl/libxl_create.c | 4 +++- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_x86.c | 3 +-- tools/xl/xl_parse.c | 3 +++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index a9eae96..10eac33 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2353,6 +2353,23 @@ The viridian option can be specified as a boolean. A value of true (1) is equivalent to the list [ "defaults" ], and a value of false (0) is equivalent to an empty list. +=item B + +Turns on or off the exposure of VMware cpuid. The number is +VMware's hardware version number, where 0 is off. A number >= 7 +is needed to enable exposure of VMware cpuid. + +The hardware version number (vmware_hwver) comes from VMware config files. + +=over 4 + +In a .vmx it is virtualHW.version + +In a .ovf it is part of the value of vssd:VirtualSystemType. +For vssd:VirtualSystemType == vmx-07, vmware_hwver = 7. + +=back + =back =head3 Emulated VGA Graphics Device diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 2814818..e28d175 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -499,7 +499,7 @@ int libxl__domain_build(libxl__gc *gc, vments[4] = "start_time"; vments[5] = GCSPRINTF("%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000); - localents = libxl__calloc(gc, 13, sizeof(char *)); + localents = libxl__calloc(gc, 15, sizeof(char *)); i = 0; localents[i++] = "platform/acpi"; localents[i++] = libxl__acpi_defbool_val(info) ? "1" : "0"; @@ -509,6 +509,8 @@ int libxl__domain_build(libxl__gc *gc, localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0"; localents[i++] = "platform/acpi_laptop_slate"; localents[i++] = libxl_defbool_val(info->u.hvm.acpi_laptop_slate) ? "1" : "0"; + localents[i++] = "platform/vmware_hwver"; + localents[i++] = GCSPRINTF("%d", d_config->c_info.vmware_hwver); if (info->u.hvm.mmio_hole_memkb) { uint64_t max_ram_below_4g = (1ULL << 32) - (info->u.hvm.mmio_hole_memkb << 10); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 36350d2..89a9ee7 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -420,6 +420,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ ("driver_domain",libxl_defbool), ("passthrough", libxl_passthrough), ("xend_suspend_evtchn_compat",libxl_defbool), + ("vmware_hwver", uint32), ], dir=DIR_IN) libxl_domain_restore_params = Struct("domain_restore_params", [ diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index 3418a81..0ee7418 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -21,8 +21,7 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, abort(); } - /* Note: will be changed in next patch (tools: Add ...). */ - config->arch.vmware_hwver = 0; + config->arch.vmware_hwver = d_config->c_info.vmware_hwver; return 0; } diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index c74a9e3..4794398 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1573,6 +1573,9 @@ void parse_config_data(const char *config_source, b_info->cmdline = parse_cmdline(config); xlu_cfg_get_defbool(config, "driver_domain", &c_info->driver_domain, 0); + if (!xlu_cfg_get_long(config, "vmware_hwver", &l, 1)) + c_info->vmware_hwver = l; + xlu_cfg_get_defbool(config, "acpi", &b_info->acpi, 0); xlu_cfg_replace_string (config, "bootloader", &b_info->bootloader, 0); From patchwork Wed Aug 19 16:51:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 993BC618 for ; Wed, 19 Aug 2020 16:54:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 75086207FF for ; Wed, 19 Aug 2020 16:54:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n0kFbvpw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75086207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKL-0003qq-Qf; Wed, 19 Aug 2020 16:52:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKK-0003kZ-Kn for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:40 +0000 X-Inumbo-ID: 2bf223f3-0ce9-4e2a-9b85-eb2b6b95b286 Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2bf223f3-0ce9-4e2a-9b85-eb2b6b95b286; Wed, 19 Aug 2020 16:52:23 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id b14so22211524qkn.4 for ; Wed, 19 Aug 2020 09:52:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6C+ZIJoI1PsBZMJzrNzQwCmQ7sAP4OyoP8B6cjIdktU=; b=n0kFbvpwyM1iYynN6VtyJen+8NqgKEWhuNT3yBk7aQOsUiMYqmBNjsVARL6HtUps+y Ge74397hH7J6pU4OXb+LJSWPWTBR3il9BchBTgfOb4RP+PIodWJVT9Al6x3MY5I549nh f5a1Y088uEMWBgqw6hssX7nCqTWPE0jICg+VVXCKY6NmlMGjnTiDsAD3yWBY3F7BIYy4 +DG9X3iLDtuamxhbhqdA7IcDUFMd9Wt1H28AMGZxXkDs5tk1JHD3SEZDyTD5NMvVvcaT yECip05DA6ECwyiOLJ7fO0zy6OI2vAnBPReyN7tZ0b9LGL1R0W1tEuFgJFgh067BbPx0 HOjQ== 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:in-reply-to :references:in-reply-to:references; bh=6C+ZIJoI1PsBZMJzrNzQwCmQ7sAP4OyoP8B6cjIdktU=; b=LtFYqR3lJZzqqw3QBaGZhwt1COTOt7iK6jJmMBrqiBg7wpA7Lwm6bHzwCNncwGFV1I 97h0XSttaVN5jEvbUrgB2F1fZa9ZgUgRo/Vf5YMt/OCYCieH1yEDNPRdK6m1B1zcqoN6 ymRRB1C5BfKyHPNLcBZLuvVQvH7VgJxqfiM9s4uOSa+psns5qj7gWBofmMfMVSeDoywt 2/r9cTOv1c7iPp6wLmJ2Ls2Md6RfWLvdncUyz35mOkDQWVh/PPMKO6IrGv6UMi17KjEY oc3dP1fMRKgJ1km/HXHqsrbg8U+QdKN3loM+mCb6o27FQL11zUORxg5Dp6fXqXgtzDSR fR6A== X-Gm-Message-State: AOAM531hqi9agLU9JBaLa8XkrEgVgfn0T8azUSo43Lp4eUYk0K31C7Bg 77+lHvHw+vver5Z5xaYb2Gf0+NUXx6GFGiCc X-Google-Smtp-Source: ABdhPJwS8r/9078r661P22XKgOEaRtXY0xrQBs1NCKEuestB5XCPV/oE+kw5qFqW14sOBnTgk7lRjA== X-Received: by 2002:a37:a655:: with SMTP id p82mr21987290qke.92.1597855943108; Wed, 19 Aug 2020 09:52:23 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:22 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 4/8] vmware: Add VMware provided include file. Date: Wed, 19 Aug 2020 12:51:58 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This file: backdoor_def.h comes from: http://packages.vmware.com/tools/esx/3.5latest/rhel4/SRPMS/index.html open-vm-tools-kmod-7.4.8-396269.423167.src.rpm open-vm-tools-kmod-7.4.8.tar.gz vmhgfs/backdoor_def.h and is unchanged. Added the badly named include file includeCheck.h also. It only has a comment and is provided so that backdoor_def.h can be used without change. Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Andrew Cooper v11,v12,v13,v14: No change v10: Add Acked-by: Andrew Cooper v9: Either the description is wrong, or the patch is stale. stale commit message -- fixed. I'd say a file with a single comment line in it would suffice. Done. xen/arch/x86/hvm/vmware/backdoor_def.h | 167 +++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/vmware/includeCheck.h | 1 + 2 files changed, 168 insertions(+) create mode 100644 xen/arch/x86/hvm/vmware/backdoor_def.h create mode 100644 xen/arch/x86/hvm/vmware/includeCheck.h diff --git a/xen/arch/x86/hvm/vmware/backdoor_def.h b/xen/arch/x86/hvm/vmware/backdoor_def.h new file mode 100644 index 0000000..e76795f --- /dev/null +++ b/xen/arch/x86/hvm/vmware/backdoor_def.h @@ -0,0 +1,167 @@ +/* ********************************************************** + * Copyright 1998 VMware, Inc. All rights reserved. + * ********************************************************** + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation version 2 and no later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + * backdoor_def.h -- + * + * This contains backdoor defines that can be included from + * an assembly language file. + */ + + + +#ifndef _BACKDOOR_DEF_H_ +#define _BACKDOOR_DEF_H_ + +#define INCLUDE_ALLOW_MODULE +#define INCLUDE_ALLOW_USERLEVEL +#define INCLUDE_ALLOW_VMMEXT +#define INCLUDE_ALLOW_VMCORE +#define INCLUDE_ALLOW_VMKERNEL +#include "includeCheck.h" + +/* + * If you want to add a new low-level backdoor call for a guest userland + * application, please consider using the GuestRpc mechanism instead. --hpreg + */ + +#define BDOOR_MAGIC 0x564D5868 + +/* Low-bandwidth backdoor port. --hpreg */ + +#define BDOOR_PORT 0x5658 + +#define BDOOR_CMD_GETMHZ 1 +/* + * BDOOR_CMD_APMFUNCTION is used by: + * + * o The FrobOS code, which instead should either program the virtual chipset + * (like the new BIOS code does, matthias offered to implement that), or not + * use any VM-specific code (which requires that we correctly implement + * "power off on CLI HLT" for SMP VMs, boris offered to implement that) + * + * o The old BIOS code, which will soon be jettisoned + * + * --hpreg + */ +#define BDOOR_CMD_APMFUNCTION 2 +#define BDOOR_CMD_GETDISKGEO 3 +#define BDOOR_CMD_GETPTRLOCATION 4 +#define BDOOR_CMD_SETPTRLOCATION 5 +#define BDOOR_CMD_GETSELLENGTH 6 +#define BDOOR_CMD_GETNEXTPIECE 7 +#define BDOOR_CMD_SETSELLENGTH 8 +#define BDOOR_CMD_SETNEXTPIECE 9 +#define BDOOR_CMD_GETVERSION 10 +#define BDOOR_CMD_GETDEVICELISTELEMENT 11 +#define BDOOR_CMD_TOGGLEDEVICE 12 +#define BDOOR_CMD_GETGUIOPTIONS 13 +#define BDOOR_CMD_SETGUIOPTIONS 14 +#define BDOOR_CMD_GETSCREENSIZE 15 +#define BDOOR_CMD_MONITOR_CONTROL 16 +#define BDOOR_CMD_GETHWVERSION 17 +#define BDOOR_CMD_OSNOTFOUND 18 +#define BDOOR_CMD_GETUUID 19 +#define BDOOR_CMD_GETMEMSIZE 20 +#define BDOOR_CMD_HOSTCOPY 21 /* Devel only */ +/* BDOOR_CMD_GETOS2INTCURSOR, 22, is very old and defunct. Reuse. */ +#define BDOOR_CMD_GETTIME 23 /* Deprecated. Use GETTIMEFULL. */ +#define BDOOR_CMD_STOPCATCHUP 24 +#define BDOOR_CMD_PUTCHR 25 /* Devel only */ +#define BDOOR_CMD_ENABLE_MSG 26 /* Devel only */ +#define BDOOR_CMD_GOTO_TCL 27 /* Devel only */ +#define BDOOR_CMD_INITPCIOPROM 28 +#define BDOOR_CMD_INT13 29 +#define BDOOR_CMD_MESSAGE 30 +#define BDOOR_CMD_RSVD0 31 +#define BDOOR_CMD_RSVD1 32 +#define BDOOR_CMD_RSVD2 33 +#define BDOOR_CMD_ISACPIDISABLED 34 +#define BDOOR_CMD_TOE 35 /* Not in use */ +/* BDOOR_CMD_INITLSIOPROM, 36, was merged with 28. Reuse. */ +#define BDOOR_CMD_PATCH_SMBIOS_STRUCTS 37 +#define BDOOR_CMD_MAPMEM 38 /* Devel only */ +#define BDOOR_CMD_ABSPOINTER_DATA 39 +#define BDOOR_CMD_ABSPOINTER_STATUS 40 +#define BDOOR_CMD_ABSPOINTER_COMMAND 41 +#define BDOOR_CMD_TIMER_SPONGE 42 +#define BDOOR_CMD_PATCH_ACPI_TABLES 43 +/* Catch-all to allow synchronous tests */ +#define BDOOR_CMD_DEVEL_FAKEHARDWARE 44 /* Debug only - needed in beta */ +#define BDOOR_CMD_GETHZ 45 +#define BDOOR_CMD_GETTIMEFULL 46 +#define BDOOR_CMD_STATELOGGER 47 +#define BDOOR_CMD_CHECKFORCEBIOSSETUP 48 +#define BDOOR_CMD_LAZYTIMEREMULATION 49 +#define BDOOR_CMD_BIOSBBS 50 +#define BDOOR_CMD_MAX 51 + +/* + * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command, + * you must adhere to the semantics expected by the oldest Tools who use that + * command. Specifically, do not alter the way in which the command modifies + * the registers. Otherwise backwards compatibility will suffer. + */ + +/* High-bandwidth backdoor port. --hpreg */ + +#define BDOORHB_PORT 0x5659 + +#define BDOORHB_CMD_MESSAGE 0 +#define BDOORHB_CMD_MAX 1 + +/* + * There is another backdoor which allows access to certain TSC-related + * values using otherwise illegal PMC indices when the pseudo_perfctr + * control flag is set. + */ + +#define BDOOR_PMC_HW_TSC 0x10000 +#define BDOOR_PMC_REAL_NS 0x10001 +#define BDOOR_PMC_APPARENT_NS 0x10002 + +#define IS_BDOOR_PMC(index) (((index) | 3) == 0x10003) +#define BDOOR_CMD(ecx) ((ecx) & 0xffff) + + +#ifdef VMM +/* + *---------------------------------------------------------------------- + * + * Backdoor_CmdRequiresFullyValidVCPU -- + * + * A few backdoor commands require the full VCPU to be valid + * (including GDTR, IDTR, TR and LDTR). The rest get read/write + * access to GPRs and read access to Segment registers (selectors). + * + * Result: + * True iff VECX contains a command that require the full VCPU to + * be valid. + * + *---------------------------------------------------------------------- + */ +static INLINE Bool +Backdoor_CmdRequiresFullyValidVCPU(unsigned cmd) +{ + return cmd == BDOOR_CMD_RSVD0 || + cmd == BDOOR_CMD_RSVD1 || + cmd == BDOOR_CMD_RSVD2; +} +#endif + +#endif diff --git a/xen/arch/x86/hvm/vmware/includeCheck.h b/xen/arch/x86/hvm/vmware/includeCheck.h new file mode 100644 index 0000000..3b63fa4 --- /dev/null +++ b/xen/arch/x86/hvm/vmware/includeCheck.h @@ -0,0 +1 @@ +/* Nothing here. Just to use backdoor_def.h without change. */ From patchwork Wed Aug 19 16:51:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724675 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96FE0618 for ; Wed, 19 Aug 2020 16:54:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 68262207FF for ; Wed, 19 Aug 2020 16:54:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CbLvWNpv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68262207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKR-0003tr-9v; Wed, 19 Aug 2020 16:52:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKP-0003kZ-Kt for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:45 +0000 X-Inumbo-ID: 7a440347-f763-4d42-ba2f-9bfd17d2a484 Received: from mail-qk1-x744.google.com (unknown [2607:f8b0:4864:20::744]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a440347-f763-4d42-ba2f-9bfd17d2a484; Wed, 19 Aug 2020 16:52:24 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id d14so22197009qke.13 for ; Wed, 19 Aug 2020 09:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=tr8ETHyk66gli0Zs0a+x97izMEXltG1WJae06N0roAU=; b=CbLvWNpvPqhn3VjusMp1+/de+9zSLTgYwFU1GZeKVrnf8kn5fMlx+A224iVQZTsv9n jYqr/mP+V29NmRyAMu/fBSKzuFKW5qsPAez63iyV5Nr1EcljZu/+PLpI+ZshTBGmnAgD IEDPatqPOJpXlnfXYWHKpFutVGWzGCN7WekpJ0xX72DGnir7s8IH69BRcZtbf5FLjNHD OsvOko17uUEXd4+BvH/7neI851/5o/7xRDw2KcMl1OsGywNVFzYRL1yQxTmh7pVHbEcZ 1hHcexFUeUvfFMDYVfYWVY15D4sW74CQbaKHRDRZN7YXenhnMSev0FGfSmcyhW6Oa28D jl0A== 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:in-reply-to :references:in-reply-to:references; bh=tr8ETHyk66gli0Zs0a+x97izMEXltG1WJae06N0roAU=; b=f2FybRUjpXOa7tLx7GVFtCj37npJe6hgnTKusTYBe1TljkS4D5Ov9cs4Ek5pz8FLDu UoRkF5HNp5Rwnc79RqqxEajNpnXhztDjEBKgBuqx06BmwJyYMGx6LpP+IRplFNO0qNVo 82E9Sj4BRi4s8zs287mu3SmiogbQbXRu1HrAoke+R/hVnS6gInOE57j+u7e7DF9iaX07 SJpAR+Jq1+ZrJPpD23RZyCxaNgm0/BK5YPOhdLJzcrht16dlo8uOc9iRv3yv7p4NAvd6 q7N4TxHQZTpEvkt/pawlXA6Rq3Uih3AyQjgz+0xlQsRRpPgHUHYBdg07mxNcrBPhy/Bt BGAA== X-Gm-Message-State: AOAM5301H47bZJP+zqNWZhwXCbaYxv9B8S79/zbMuM237qP+rAsh01kl pQoNhiV2z1e0w2sRJyrKk/qelMVMI8SFazfP X-Google-Smtp-Source: ABdhPJwuUvKu9Gs03eick4zQO79sPn0/g0zNWlBgsDydJbkTyGo/Cu+nO3obuSX4gRUyoKET28oKdA== X-Received: by 2002:ae9:e505:: with SMTP id w5mr22040124qkf.282.1597855944154; Wed, 19 Aug 2020 09:52:24 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:23 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 5/8] xen: Add vmware_port support Date: Wed, 19 Aug 2020 12:51:59 -0400 Message-Id: <5d2e424a19ea4934be3be962cdbe6a0ec8db9a6c.1597854907.git.don.slutz@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This includes adding is_vmware_port_enabled This is a new xen_arch_domainconfig flag, XEN_DOMCTL_CONFIG_VMWARE_PORT_MASK. This enables limited support of VMware's hyper-call. This is both a more complete support then in currently provided by QEMU and/or KVM and less. The missing part requires QEMU changes and has been left out until the QEMU patches are accepted upstream. VMware's hyper-call is also known as VMware Backdoor I/O Port. Note: this support does not depend on vmware_hw being non-zero. Summary is that VMware treats "in (%dx),%eax" (or "out %eax,(%dx)") to port 0x5658 specially. Note: since many operations return data in EAX, "in (%dx),%eax" is the one to use. The other lengths like "in (%dx),%al" will still do things, only AL part of EAX will be changed. For "out %eax,(%dx)" of all lengths, EAX will remain unchanged. An open source example of using this is: http://open-vm-tools.sourceforge.net/ Which only uses "inl (%dx)". Also http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458 Some of the best info is at: https://sites.google.com/site/chitchatvmback/backdoor Signed-off-by: Don Slutz CC: Don Slutz --- Reviewed-by: Andrew Cooper v14: Reworked to current code. Drop arch_flags and use XEN_X86_EMU_VMWARE_PORT which will not be added to "all". v13: Changed to uint32_t arch_flags, since the emulation_flags is this. v12: Surrounding code avoiding the use of "break" makes the result look rather inconsistent. Please move this up immediately after the XSM check, or drop the "break". Moved it up. v11: Dropped ASSERT(is_hvm_domain(currd)) Newline after break; v10: Probably better as EOPNOTSUPP, as it is a configuration problem. This function looks as if it should be static. I would suggest putting vmport_register declaration in hvm.h ... As indicated before, I don't think this is a good use case for a domain creation flag. Switch to the new config way. struct domain *d => struct domain *currd Are you sure you don't want to zero the high halves of 64-bit ... Comment added. Then just have this handled into the default case. Reworked new_eax handling. is_hvm_domain(currd) And - why here rather than before the switch() or even right at the start of the function? Moved to start. With that, is it really correct that OUT updates the other registers just like IN? If so, this deserves a comment, so that readers won't think this is in error. All done in comment at start. v9: Switch to x86_emulator to handle #GP code moved to next patch. Can you explain why a HVM param isn't suitable here? Issue with changing QEMU on the fly. Andrew Cooper: My recommendation is still to use a creation flag So no change. Please move SVM's identical definition into ... Did this as #1. No longer needed, but since the patch was ready I have included it. --Lots of questions about code that no long is part of this patch. -- With this, is handling other than 32-bit in/out really meaningful/correct? Added comment about this. Since you can't get here for PV, I can't see what you need this. Changed to an ASSERT. Why version 4? Added comment about this. -- Several questions about register changes. Re-coded to use new_eax and set *val to this. Change to generealy use reg->_e.. These ei1/ei2 checks belong in the callers imo - Moved. the "port" function parameter isn't even checked Add check for exact match. If dropping the code is safe without also forbidding the combination of nested and VMware emulation. Added the forbidding the combination of nested and VMware. Mostly do to the cases of the nested virtual code is the one to handle VMware stuff if needed, not the root one. Also I am having issues testing xen nested in xen and using hvm. v7: More on AMD in the commit message. Switch to only change 32bit part of registers, what VMware does. Too much logging and tracing. Dropped a lot of it. This includes vmport_debug= v6: Dropped the attempt to use svm_nextrip_insn_length via __get_instruction_length (added in v2). Just always look at upto 15 bytes on AMD. v5: we should make sure that svm_vmexit_gp_intercept is not executed for any other guest. Added an ASSERT on is_vmware_port_enabled. magic integers? Added #define for them. I am fairly certain that you need some brackets here. Added brackets. xen/arch/x86/domain.c | 15 ++-- xen/arch/x86/hvm/hvm.c | 9 +++ xen/arch/x86/hvm/vmware/Makefile | 1 + xen/arch/x86/hvm/vmware/vmport.c | 148 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/hvm/domain.h | 3 + xen/include/asm-x86/hvm/hvm.h | 2 + xen/include/public/arch-x86/xen.h | 4 ++ 7 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 xen/arch/x86/hvm/vmware/vmport.c diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a317907..0cf73ef 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -504,6 +504,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) { + uint32_t all_emflags = emflags & XEN_X86_EMU_ALL; + #ifdef CONFIG_HVM /* This doesn't catch !CONFIG_HVM case but it is better than nothing */ BUILD_BUG_ON(X86_EMU_ALL != XEN_X86_EMU_ALL); @@ -512,14 +514,15 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags) if ( is_hvm_domain(d) ) { if ( is_hardware_domain(d) && - emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) + all_emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) return false; if ( !is_hardware_domain(d) && - emflags != (X86_EMU_ALL & ~X86_EMU_VPCI) && - emflags != X86_EMU_LAPIC ) + all_emflags != (X86_EMU_ALL & ~X86_EMU_VPCI) && + all_emflags != X86_EMU_LAPIC ) return false; } - else if ( emflags != 0 && emflags != X86_EMU_PIT ) + else if ( emflags & XEN_X86_EMU_VMWARE_PORT || + (all_emflags != 0 && all_emflags != X86_EMU_PIT) ) { /* PV or classic PVH. */ return false; @@ -581,7 +584,7 @@ int arch_domain_create(struct domain *d, if ( is_hardware_domain(d) && is_pv_domain(d) ) emflags |= XEN_X86_EMU_PIT; - if ( emflags & ~XEN_X86_EMU_ALL ) + if ( emflags & ~(XEN_X86_EMU_ALL | XEN_X86_EMU_VMWARE_PORT) ) { printk(XENLOG_G_ERR "d%d: Invalid emulation bitmap: %#x\n", d->domain_id, emflags); @@ -600,6 +603,8 @@ int arch_domain_create(struct domain *d, if ( is_hvm_domain(d) ) { d->arch.hvm.vmware_hwver = config->arch.vmware_hwver; + d->arch.hvm.is_vmware_port_enabled = + !!(emflags & XEN_X86_EMU_VMWARE_PORT); } HYPERVISOR_COMPAT_VIRT_START(d) = diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index e91169f..42d96b1 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -697,6 +697,9 @@ int hvm_domain_initialise(struct domain *d) if ( hvm_tsc_scaling_supported ) d->arch.hvm.tsc_scaling_ratio = hvm_default_tsc_scaling_ratio; + if ( d->arch.hvm.is_vmware_port_enabled ) + vmport_register(d); + rc = viridian_domain_init(d); if ( rc ) goto fail2; @@ -4214,6 +4217,12 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value) rc = xsm_hvm_param_nested(XSM_PRIV, d); if ( rc ) break; + /* Prevent nestedhvm enable with vmport */ + if ( value && d->arch.hvm.is_vmware_port_enabled ) + { + rc = -EOPNOTSUPP; + break; + } if ( value > 1 ) rc = -EINVAL; /* diff --git a/xen/arch/x86/hvm/vmware/Makefile b/xen/arch/x86/hvm/vmware/Makefile index f864486..74aea16 100644 --- a/xen/arch/x86/hvm/vmware/Makefile +++ b/xen/arch/x86/hvm/vmware/Makefile @@ -1 +1,2 @@ obj-y += vmware.o +obj-y += vmport.o diff --git a/xen/arch/x86/hvm/vmware/vmport.c b/xen/arch/x86/hvm/vmware/vmport.c new file mode 100644 index 0000000..863ec50 --- /dev/null +++ b/xen/arch/x86/hvm/vmware/vmport.c @@ -0,0 +1,148 @@ +/* + * HVM VMPORT emulation + * + * Copyright (C) 2012 Verizon Corporation + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License Version 2 (GPLv2) + * as published by the Free Software Foundation. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. . + */ + +#include +#include +#include + +#include "backdoor_def.h" + +static int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) +{ + struct cpu_user_regs *regs = guest_cpu_user_regs(); + + /* + * While VMware expects only 32-bit in, they do support using + * other sizes and out. However they do require only the 1 port + * and the correct value in eax. Since some of the data + * returned in eax is smaller the 32 bits and/or you only need + * the other registers the dir and bytes do not need any + * checking. The caller will handle the bytes, and dir is + * handled below for eax. + */ + if ( port == BDOOR_PORT && regs->eax == BDOOR_MAGIC ) + { + uint32_t new_eax = ~0u; + uint64_t value; + struct vcpu *curr = current; + struct domain *currd = curr->domain; + + /* + * VMware changes the other (non eax) registers ignoring dir + * (IN vs OUT). It also changes only the 32-bit part + * leaving the high 32-bits unchanged, unlike what one would + * expect to happen. + */ + switch ( regs->ecx & 0xffff ) + { + case BDOOR_CMD_GETMHZ: + new_eax = currd->arch.tsc_khz / 1000; + break; + + case BDOOR_CMD_GETVERSION: + /* MAGIC */ + regs->ebx = BDOOR_MAGIC; + /* VERSION_MAGIC */ + new_eax = 6; + /* Claim we are an ESX. VMX_TYPE_SCALABLE_SERVER */ + regs->ecx = 2; + break; + + case BDOOR_CMD_GETHWVERSION: + /* vmware_hw */ + new_eax = currd->arch.hvm.vmware_hwver; + /* + * Returning zero is not the best. VMware was not at + * all consistent in the handling of this command until + * VMware hardware version 4. So it is better to claim + * 4 then 0. This should only happen in strange configs. + */ + if ( !new_eax ) + new_eax = 4; + break; + + case BDOOR_CMD_GETHZ: + { + struct segment_register sreg; + + hvm_get_segment_register(curr, x86_seg_ss, &sreg); + if ( sreg.dpl == 0 ) + { + value = currd->arch.tsc_khz * 1000; + /* apic-frequency (bus speed) */ + regs->ecx = 1000000000ULL / APIC_BUS_CYCLE_NS; + /* High part of tsc-frequency */ + regs->ebx = value >> 32; + /* Low part of tsc-frequency */ + new_eax = value; + } + break; + + } + case BDOOR_CMD_GETTIME: + value = get_localtime_us(currd) - + currd->time_offset.seconds * 1000000ULL; + /* hostUsecs */ + regs->ebx = value % 1000000UL; + /* hostSecs */ + new_eax = value / 1000000ULL; + /* maxTimeLag */ + regs->ecx = 1000000; + /* offset to GMT in minutes */ + regs->edx = currd->time_offset.seconds / 60; + break; + + case BDOOR_CMD_GETTIMEFULL: + /* BDOOR_MAGIC */ + new_eax = BDOOR_MAGIC; + value = get_localtime_us(currd) - + currd->time_offset.seconds * 1000000ULL; + /* hostUsecs */ + regs->ebx = value % 1000000UL; + /* hostSecs low 32 bits */ + regs->edx = value / 1000000ULL; + /* hostSecs high 32 bits */ + regs->esi = (value / 1000000ULL) >> 32; + /* maxTimeLag */ + regs->ecx = 1000000; + break; + + default: + /* Let backing DM handle */ + return X86EMUL_UNHANDLEABLE; + } + if ( dir == IOREQ_READ ) + *val = new_eax; + } + else if ( dir == IOREQ_READ ) + *val = ~0u; + + return X86EMUL_OKAY; +} + +void vmport_register(struct domain *d) +{ + register_portio_handler(d, BDOOR_PORT, 4, vmport_ioport); +} + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index 0f64a4b..355777c 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -162,6 +162,9 @@ struct hvm_domain { spinlock_t uc_lock; bool_t is_in_uc_mode; + /* VMware backdoor port available */ + bool_t is_vmware_port_enabled; + /* hypervisor intercepted msix table */ struct list_head msixtbl_list; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index cb55dfb..74a9590 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -789,6 +789,8 @@ static inline bool hvm_has_set_descriptor_access_exiting(void) #endif /* CONFIG_HVM */ +void vmport_register(struct domain *d); + #endif /* __ASM_X86_HVM_HVM_H__ */ /* diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h index 54b1c4d..105c6a3 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -296,6 +296,10 @@ struct xen_arch_domainconfig { #define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ) #define _XEN_X86_EMU_VPCI 10 #define XEN_X86_EMU_VPCI (1U<<_XEN_X86_EMU_VPCI) +/* Enable use of vmware backdoor port. + * Not part of XEN_X86_EMU_ALL */ +#define _XEN_X86_EMU_VMWARE_PORT 11 +#define XEN_X86_EMU_VMWARE_PORT (1U<<_XEN_X86_EMU_VMWARE_PORT) #define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET | \ XEN_X86_EMU_PM | XEN_X86_EMU_RTC | \ From patchwork Wed Aug 19 16:52:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24F07618 for ; Wed, 19 Aug 2020 16:54:16 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 010F1207FF for ; Wed, 19 Aug 2020 16:54:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OO1JkZ2G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 010F1207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKV-0003vb-KR; Wed, 19 Aug 2020 16:52:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKU-0003kZ-Kz for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:50 +0000 X-Inumbo-ID: 8d9f3e11-7a99-4f01-a346-8ef0fadff7fb Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8d9f3e11-7a99-4f01-a346-8ef0fadff7fb; Wed, 19 Aug 2020 16:52:26 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id 77so22205427qkm.5 for ; Wed, 19 Aug 2020 09:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=jZijM2ydIAX1ShIOsC2gPV47fryOmcc2JmO97Kfe7LY=; b=OO1JkZ2Gchr4DVF5qVUN29stIRb4h+6OZDeWgaK9+oVHn0j3lMJuskVmVVrxnSzdLl un0nbB8n/dl5jteLLfhh+FBD7HWF+z9JwD94Y4AgPpOCwL0fHr7VDKkiAUOUeT+GpFte 7sRWsd+Xwf9iqsnii3u6z6bFpjVbcWJdebWmYFOTEY/o1ehGSnujMRZd9SQg9h6kbKVN Zkpd6Hm9AF0LGMVaQbi3Exryz676b+RAeX8xhHkk8E/iBdeJLvcpCt+IUVFc/K1cXg06 dKSlUdqRboblMBI2zHWgs56ODsJ47unoKt/mdYFRQ3yH3i9nD9u7OZMCSEdrTYjU+sWg pImA== 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:in-reply-to :references:in-reply-to:references; bh=jZijM2ydIAX1ShIOsC2gPV47fryOmcc2JmO97Kfe7LY=; b=sSkJYDfQXUgDWP26+XSF/0K0wUIz1D5I1r3zsRi/bcr/I9Y6pdurt79FPL/m4SNKa3 VAie2hW6kGb1NC5cR0eeGkSZ2TSouJt1dkZygzRF3Bb1rXghHk9nAqwaL/pmtCR8yVt2 X0D69q8IUq664MMTvzuXMffkFvL/AyrNAS1zOpv1/toV9tKy3TQSB5kOMW0MZndWmEhR 4JNls3LaqBalbLJJ28aX5weq3O+GA2bt01PtEO++1KPSM3Es/A0WvYhdANdSiGVMUNwD rpfqa78v1k9aLo2H/FiACI1eaZSpN3KzZ32KKBja+ZjZw0FXrB6wNwZzwybIR5gXzpQJ L6Iw== X-Gm-Message-State: AOAM531t9D6W/ock4cszQ7FONBiiRns2HUK7+NA9h7Fhz6hdryDPwISe dQh3og60wOm0cKACh/TWn2A5+9A5rLXYVsg4 X-Google-Smtp-Source: ABdhPJzYnGB/7HHTOm9L5j1Ev22Cr1Ka+T02F2CLeULNpa3lQO4GBFw9zAi5FvQISQVHJp6bQx0otg== X-Received: by 2002:a37:a09:: with SMTP id 9mr21999640qkk.290.1597855945546; Wed, 19 Aug 2020 09:52:25 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:24 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 6/8] tools: Add vmware_port support Date: Wed, 19 Aug 2020 12:52:00 -0400 Message-Id: <4780b5be94be7820861f29fb618a2420effe26f5.1597854907.git.don.slutz@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <5d2e424a19ea4934be3be962cdbe6a0ec8db9a6c.1597854907.git.don.slutz@gmail.com> References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> <5d2e424a19ea4934be3be962cdbe6a0ec8db9a6c.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This new libxl_domain_create_info field is used to set XEN_DOMCTL_CONFIG_VMWARE_PORT_MASK in the xc_domain_configuration_t for x86. In xen it is is_vmware_port_enabled. If is_vmware_port_enabled then enable a limited support of VMware's hyper-call. VMware's hyper-call is also known as VMware Backdoor I/O Port. if vmware_port is not specified in the config file, let "vmware_hwver != 0" be the default value. This means that only vmware_hwver = 7 needs to be specified to enable both features. vmware_hwver = 7 is special because that is what controls the enable of CPUID leaves for VMware (vmware_hwver >= 7). Note: vmware_port and nestedhvm cannot be specified at the same time. Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Ian Campbell v14: Reworked to current code. v13: Added Acked-by: Ian Campbell v12: s/come/comes/ In v11 this seems to have morphed into only LIBXL_HAVE_LIBXL_VGA_INTERFACE_TYPE_VMWARE being provided, which is clearly not an appropriate umbrella #define. "#define LIBXL_HAVE_CREATEINFO_VMWARE 1" Lets just have a single one of these indicating support for vmware, it should be added at the end of the series after all the baseline vmware functionality is in place. I think that means hwver, vga=vmware and this port stuff. Make (tools: Add vga=vmware) no longer independent. Change the #define to "LIBXL_HAVE_VMWARE" v11: Dropped "If non-zero then default VGA to VMware's VGA" v10: If..." at the start of the sentence ... Also, why is 7 special? docs/man/xl.cfg.5.pod.in | 15 +++++++++++++++ tools/libxl/libxl.h | 5 +++++ tools/libxl/libxl_create.c | 10 ++++++++++ tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_x86.c | 2 ++ tools/xl/xl_parse.c | 1 + 6 files changed, 34 insertions(+) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 10eac33..3c73985 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -2359,6 +2359,8 @@ Turns on or off the exposure of VMware cpuid. The number is VMware's hardware version number, where 0 is off. A number >= 7 is needed to enable exposure of VMware cpuid. +If not zero it changes the default for vmware_port to on. + The hardware version number (vmware_hwver) comes from VMware config files. =over 4 @@ -2370,6 +2372,19 @@ For vssd:VirtualSystemType == vmx-07, vmware_hwver = 7. =back +=item B + +Turns on or off the exposure of VMware port. This is known as +vmport in QEMU. Also called VMware Backdoor I/O Port. Not all +defined VMware backdoor commands are implemented. All of the +ones that Linux kernel uses are defined. + +Defaults to enabled if vmware_hwver is non-zero (i.e. enabled) +otherwise defaults to disabled. + +Note: vmware_port and nestedhvm cannot be specified at the +same time. + =back =head3 Emulated VGA Graphics Device diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 1cd6c38..48ab231 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -439,6 +439,11 @@ #define LIBXL_HAVE_CREATEINFO_PASSTHROUGH 1 /* + * libxl has VMware changes. + */ +#define LIBXL_HAVE_VMWARE 1 + +/* * libxl ABI compatibility * * The only guarantee which libxl makes regarding ABI compatibility diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index e28d175..6689443 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -51,6 +51,7 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&c_info->oos, true); } + libxl_defbool_setdefault(&c_info->vmware_port, c_info->vmware_hwver != 0); libxl_defbool_setdefault(&c_info->run_hotplug_scripts, true); libxl_defbool_setdefault(&c_info->driver_domain, false); @@ -1185,6 +1186,15 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } + if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && + libxl_defbool_val(d_config->b_info.nested_hvm) && + libxl_defbool_val(d_config->c_info.vmware_port)) { + ret = ERROR_INVAL; + LOGD(ERROR, domid, + "vmware_port and nestedhvm cannot be enabled simultaneously\n"); + goto error_out; + } + if (d_config->c_info.type != LIBXL_DOMAIN_TYPE_PV && (libxl_defbool_val(d_config->b_info.nested_hvm) && ((d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM && diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 89a9ee7..f563980 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -421,6 +421,7 @@ libxl_domain_create_info = Struct("domain_create_info",[ ("passthrough", libxl_passthrough), ("xend_suspend_evtchn_compat",libxl_defbool), ("vmware_hwver", uint32), + ("vmware_port", libxl_defbool), ], dir=DIR_IN) libxl_domain_restore_params = Struct("domain_restore_params", [ diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index 0ee7418..8da9913 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -22,6 +22,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, } config->arch.vmware_hwver = d_config->c_info.vmware_hwver; + if (libxl_defbool_val(d_config->c_info.vmware_port)) + config->arch.emulation_flags |= XEN_X86_EMU_VMWARE_PORT; return 0; } diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 4794398..b655e25 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1321,6 +1321,7 @@ void parse_config_data(const char *config_source, } xlu_cfg_get_defbool(config, "oos", &c_info->oos, 0); + xlu_cfg_get_defbool(config, "vmware_port", &c_info->vmware_port, 0); if (!xlu_cfg_get_string (config, "pool", &buf, 0)) xlu_cfg_replace_string(config, "pool", &c_info->pool_name, 0); From patchwork Wed Aug 19 16:52:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724677 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 83AE0618 for ; Wed, 19 Aug 2020 16:54:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49532207FF for ; Wed, 19 Aug 2020 16:54:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H4FHGEeu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49532207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKg-00041b-DY; Wed, 19 Aug 2020 16:53:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKe-0003kZ-LE for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:53:00 +0000 X-Inumbo-ID: adb23fae-59a4-45f4-812f-5d87e5c9493c Received: from mail-qk1-x744.google.com (unknown [2607:f8b0:4864:20::744]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id adb23fae-59a4-45f4-812f-5d87e5c9493c; Wed, 19 Aug 2020 16:52:28 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id x69so22225330qkb.1 for ; Wed, 19 Aug 2020 09:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=NIouuXsEYi+wgGn1WivUNRyxwAiupX8YGmukK2Jhtjw=; b=H4FHGEeuU9lG/gYhGJ9hpvXj4f2Ah9dPVKPwiPbj24CBd+SUEwGDjgmhMBxtOu+Tb5 IbRyeRwNFPBtxZDTyJ73Cocm9NVoEm/hHImRU0217LDXZULGNVspX02qixRgAOfdAYED 8GJz9Aa0MbUDr29n/gq+Uly6HqOeR7PsIODjWZyRwpLLSrwmgNcnS3Esz9bFJ5teE+2L y5Ex2D+IjteUHmTqRnWYcEN1eo3ks6yFAbMFxNh/BDhfr3o7n6KeJWLUq6r1r6hNq3ov WuoIfijIrN4ssopL5BlCZ9utegm4ezFzFYQ/ujJnoytGX4McW0H93wwTVXPv63m0YX8q 9GQA== 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:in-reply-to :references:in-reply-to:references; bh=NIouuXsEYi+wgGn1WivUNRyxwAiupX8YGmukK2Jhtjw=; b=PV22COOmnwew7wQB/HIr3mBku50uPNgfmb6r43ZIxHGOchWMmIFJUW1k8qJ0AjpqRu ST7B1BP+j1ngWo1Ia3qO4xI19BKyP7dA8FWlyat11D9FTOx7xMoSxcwpDkWiEYTRzkzC zaionzLAgG7W2dF2A8UWmMXjzq5NYPjYRUe8QN8K2g0fI89BCE8dFzj0NmJSS36W6qtn jWx2Lp/Y9yLczz0Eq1iRzq9RdIwJrmvK0VAdBawELTYqdl+YIwNz+Yi+yS88ffE7hk0v FFnspD/mYUDfnEwRJo6YlRXZz34eBRZM6zX0TRxUTPAEuxCnOXsNbFvVYhnTIabY4+nt h2nA== X-Gm-Message-State: AOAM532gdQASBcnkUKyglNj+lhqO941rB5siQlPfHSHbMqSVf1NxFqyS k3ffIIg1O808x5WSeKwaimE5fbMI6SEjN9XO X-Google-Smtp-Source: ABdhPJxrbMGH+O9islqVuzLlu6lGJF+Mb2N3CkY53ilGfxVJi3XL54yeT/ADxYLwiDBoh1c7yLcDHA== X-Received: by 2002:a05:620a:11a6:: with SMTP id c6mr18688471qkk.209.1597855946681; Wed, 19 Aug 2020 09:52:26 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.25 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:26 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 7/8] Add IOREQ_TYPE_VMWARE_PORT Date: Wed, 19 Aug 2020 12:52:01 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <4780b5be94be7820861f29fb618a2420effe26f5.1597854907.git.don.slutz@gmail.com> References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> <5d2e424a19ea4934be3be962cdbe6a0ec8db9a6c.1597854907.git.don.slutz@gmail.com> <4780b5be94be7820861f29fb618a2420effe26f5.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz This adds synchronization of the 6 vcpu registers (only 32bits of them) that QEMU's vmport.c and vmmouse.c needs between Xen and QEMU. This is how VMware defined the use of these registers. This is to avoid a 2nd and 3rd exchange between QEMU and Xen to fetch and put these 6 vcpu registers used by the code in QEMU's vmport.c and vmmouse.c In the tools, enable usage of QEMU's vmport code. The currently most useful VMware port support that QEMU has is the VMware mouse support. Xorg included a VMware mouse support that uses absolute mode. This make using a mouse in X11 much nicer. Also added HVM_IOREQSRV_DISABLE_VMPORT to allow ioreq server(s) to not get the mapping to the 6 vcpu registers. Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Ian Campbell v14: Paul Durrant: is_vmware already incorporated !is_mmio... Reworked the "Verify the emulation request has been correctly re-issued" to have a pre if. Paul Durrant: This could be done in a single statement. Made a single statement. Paul Durrant: Is every ioreq server going to have one of these? Code no longer exists. But, there is a way to not have it. See HVM_IOREQSRV_DISABLE_VMPORT Jan Beulich: Long line needs breaking up. Fixed Jan Beulich: The parameter should no longer be named "buf". Changed to pt. Jan Beulich: Do you really need to set up a (dummy) range set for this Last version did not finsh on this. Here is what I think now: hvm_select_ioreq_server() uses this "dummy" range to see if a given IOREQ Server should be picked. XEN_DMOP_map_io_range_to_ioreq_server and XEN_DMOP_unmap_io_range_from_ioreq_server can be used to enable or disable vmport usage at any time. Jan Beulich: Several comments on vmport_check_port All changed. Jan Beulich: Lower case please (and ... Changed to lower case in the enum. Jan Beulich: Was left off in the middle I think haveing the current state of the code posted will help. Jan Beulich: don't think having something prefixed vmware_ in the Xen public headers is a good idea. Also did not reach a clear resolution. Last statement: All of this may be true and fine, but none of this is - to me - a reason to introduce new unclean names into the Xen public interface. In no event do I see qemu dictating naming to us. My current answer: My take on this is that you want me to use a different name, is vmport_regs a name you can live with? Jan Beulich: Also throughout the series I didn't find any code addition to guarantee (perhaps at build time) that BDOOR_PORT doesn't collide with any other use ports Added BUILD_BUG_ON for all that can be checked at build time, which I think answers this. Jan Beulich: But accessing BDOOR_PORT + 1 with a 4-byte operation ought to be undefined (or properly split up). After all you don't know what is on BDOOR_PORT + 4. Changed to only allow BDOOR_PORT with a 4-byte operation. Fixed bug in hvm_alloc_legacy_ioreq_gfn: the if is always false. v13: Rebased on staging (not a simple rebase, needed rework to function with changes). I would have made this !vmport_check_port ... Changed to !is_vmware, and invert vmport_check_port's return value. Use 1 one for "list_for_each_entry ( sv, ..." Added full stop in comments. v12: Rebase changes. Pass size to vmport_check_port() -- required if overlap I.E. inl on port 0x5657, 0x5656, 0x5655, 0x5659, 0x565a, and 0x565b. Move define of vmport_check_port() into this patch from ring3 patch. v11: No change v10: These literals should become an enum. I don't think the invalidate type is needed. Code handling "case X86EMUL_UNHANDLEABLE:" in emulate.c is unclear. Comment about "special' range of 1" is not clear. v9: New code was presented as an RFC before this. Paul Durrant sugested I add support for other IOREQ types to HVMOP_map_io_range_to_ioreq_server. I have done this. tools/libs/devicemodel/core.c | 4 +- tools/libxc/include/xc_dom.h | 2 +- tools/libxc/xc_dom_x86.c | 3 + tools/libxl/libxl_dm.c | 2 + xen/arch/x86/hvm/dm.c | 3 +- xen/arch/x86/hvm/emulate.c | 57 ++++++- xen/arch/x86/hvm/hvm.c | 4 + xen/arch/x86/hvm/ioreq.c | 348 +++++++++++++++++++++++++++++++++------ xen/arch/x86/hvm/vmware/vmport.c | 36 ++++ xen/include/asm-x86/hvm/domain.h | 4 +- xen/include/asm-x86/hvm/hvm.h | 1 + xen/include/public/hvm/dm_op.h | 21 ++- xen/include/public/hvm/ioreq.h | 17 ++ xen/include/public/hvm/params.h | 2 +- 14 files changed, 443 insertions(+), 61 deletions(-) diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 4d40639..72702d7 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -166,7 +166,7 @@ static int xendevicemodel_op( } int xendevicemodel_create_ioreq_server( - xendevicemodel_handle *dmod, domid_t domid, int handle_bufioreq, + xendevicemodel_handle *dmod, domid_t domid, int flags, ioservid_t *id) { struct xen_dm_op op; @@ -178,7 +178,7 @@ int xendevicemodel_create_ioreq_server( op.op = XEN_DMOP_create_ioreq_server; data = &op.u.create_ioreq_server; - data->handle_bufioreq = handle_bufioreq; + data->flags = flags; rc = xendevicemodel_op(dmod, domid, 1, &op, sizeof(op)); if (rc) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index 52a4d6c..7413917 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -20,7 +20,7 @@ #include #define INVALID_PFN ((xen_pfn_t)-1) -#define X86_HVM_NR_SPECIAL_PAGES 8 +#define X86_HVM_NR_SPECIAL_PAGES 9 #define X86_HVM_END_SPECIAL_REGION 0xff000u #define XG_MAX_MODULES 2 diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index 9439805..bd42f42 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -67,6 +67,7 @@ #define SPECIALPAGE_IOREQ 5 #define SPECIALPAGE_IDENT_PT 6 #define SPECIALPAGE_CONSOLE 7 +#define SPECIALPAGE_VMPORT_REGS 8 #define special_pfn(x) \ (X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES + (x)) @@ -657,6 +658,8 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom) special_pfn(SPECIALPAGE_BUFIOREQ)); xc_hvm_param_set(xch, domid, HVM_PARAM_IOREQ_PFN, special_pfn(SPECIALPAGE_IOREQ)); + xc_hvm_param_set(xch, domid, HVM_PARAM_VMPORT_REGS_PFN, + special_pfn(SPECIALPAGE_VMPORT_REGS)); xc_hvm_param_set(xch, domid, HVM_PARAM_CONSOLE_PFN, special_pfn(SPECIALPAGE_CONSOLE)); xc_hvm_param_set(xch, domid, HVM_PARAM_PAGING_RING_PFN, diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 415c12e..9be4548 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1822,6 +1822,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, } } + if (libxl_defbool_val(c_info->vmware_port)) + machinearg = GCSPRINTF("%s,vmport=on", machinearg); flexarray_append(dm_args, machinearg); for (i = 0; b_info->extra_hvm && b_info->extra_hvm[i] != NULL; i++) flexarray_append(dm_args, b_info->extra_hvm[i]); diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c index 9930d68..087ad05 100644 --- a/xen/arch/x86/hvm/dm.c +++ b/xen/arch/x86/hvm/dm.c @@ -419,8 +419,7 @@ static int dm_op(const struct dmop_args *op_args) if ( data->pad[0] || data->pad[1] || data->pad[2] ) break; - rc = hvm_create_ioreq_server(d, data->handle_bufioreq, - &data->id); + rc = hvm_create_ioreq_server(d, data->flags, &data->id); break; } diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 8b4e73a..befa55e 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -28,6 +28,8 @@ #include #include +vmware_regs_t *get_vmport_regs_any(struct hvm_ioreq_server *s, struct vcpu *v); + struct hvmemul_cache { /* The cache is disabled as long as num_ents > max_ents. */ @@ -173,6 +175,8 @@ static int hvmemul_do_io( }; void *p_data = (void *)data; int rc; + bool_t is_vmware = !is_mmio && !data_is_addr && + vmport_check_port(p.addr, p.size); /* * Weird-sized accesses have undefined behaviour: we discard writes @@ -189,11 +193,17 @@ static int hvmemul_do_io( case STATE_IOREQ_NONE: break; case STATE_IORESP_READY: + { + uint8_t calc_type = is_mmio ? IOREQ_TYPE_COPY : IOREQ_TYPE_PIO; + + if ( is_vmware ) + calc_type = IOREQ_TYPE_VMWARE_PORT; + vio->io_req.state = STATE_IOREQ_NONE; p = vio->io_req; /* Verify the emulation request has been correctly re-issued */ - if ( (p.type != (is_mmio ? IOREQ_TYPE_COPY : IOREQ_TYPE_PIO)) || + if ( (p.type != calc_type) || (p.addr != addr) || (p.size != size) || (p.count > *reps) || @@ -202,7 +212,7 @@ static int hvmemul_do_io( (p.data_is_ptr != data_is_addr) || (data_is_addr && (p.data != data)) ) domain_crash(currd); - + } if ( data_is_addr ) return X86EMUL_UNHANDLEABLE; @@ -322,6 +332,49 @@ static int hvmemul_do_io( } } + if ( unlikely(is_vmware) ) + { + vmware_regs_t *vr; + + BUILD_BUG_ON(sizeof(ioreq_t) < sizeof(vmware_regs_t)); + + p.type = vio->io_req.type = IOREQ_TYPE_VMWARE_PORT; + s = hvm_select_ioreq_server(currd, &p); + vr = get_vmport_regs_any(s, curr); + + /* + * If there is no suitable backing DM, just ignore accesses. If + * we do not have access to registers to pass to QEMU, just + * ignore access. + */ + if ( !s || !vr ) + { + rc = hvm_process_io_intercept(&null_handler, &p); + vio->io_req.state = STATE_IOREQ_NONE; + } + else + { + const struct cpu_user_regs *regs = guest_cpu_user_regs(); + + p.data = regs->rax; + /* The code in QEMU that uses these registers, + * vmport.c and vmmouse.c, only uses the 32bit part + * of the register. This is how VMware defined the + * use of these registers. + */ + vr->ebx = regs->ebx; + vr->ecx = regs->ecx; + vr->edx = regs->edx; + vr->esi = regs->esi; + vr->edi = regs->edi; + + rc = hvm_send_ioreq(s, &p, 0); + if ( rc != X86EMUL_RETRY || currd->is_shutting_down ) + vio->io_req.state = STATE_IOREQ_NONE; + } + break; + } + if ( !s ) s = hvm_select_ioreq_server(currd, &p); diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 42d96b1..03d2ad5 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4122,6 +4122,7 @@ static int hvm_allow_set_param(struct domain *d, /* Fall through */ case HVM_PARAM_IOREQ_PFN: case HVM_PARAM_BUFIOREQ_PFN: + case HVM_PARAM_VMPORT_REGS_PFN: case HVM_PARAM_IOREQ_SERVER_PFN: case HVM_PARAM_NR_IOREQ_SERVER_PAGES: case HVM_PARAM_ALTP2M: @@ -4279,10 +4280,13 @@ static int hvm_set_param(struct domain *d, uint32_t index, uint64_t value) case HVM_PARAM_IOREQ_PFN: case HVM_PARAM_BUFIOREQ_PFN: + case HVM_PARAM_VMPORT_REGS_PFN: BUILD_BUG_ON(HVM_PARAM_IOREQ_PFN > sizeof(d->arch.hvm.ioreq_gfn.legacy_mask) * 8); BUILD_BUG_ON(HVM_PARAM_BUFIOREQ_PFN > sizeof(d->arch.hvm.ioreq_gfn.legacy_mask) * 8); + BUILD_BUG_ON(HVM_PARAM_VMPORT_REGS_PFN > + sizeof(d->arch.hvm.ioreq_gfn.legacy_mask) * 8); if ( value ) set_bit(index, &d->arch.hvm.ioreq_gfn.legacy_mask); break; diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index 1cc27df..a5d124e 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -108,6 +108,44 @@ static struct hvm_ioreq_vcpu *get_pending_vcpu(const struct vcpu *v, return NULL; } +static vmware_regs_t *get_vmport_regs_one(struct hvm_ioreq_server *s, + struct vcpu *v) +{ + struct hvm_ioreq_vcpu *sv; + + list_for_each_entry ( sv, &s->ioreq_vcpu_list, list_entry ) + { + if ( sv->vcpu == v ) + { + shared_vmport_iopage_t *p = s->vmport_ioreq.va; + if ( !p ) + return NULL; + return &p->vcpu_vmport_regs[v->vcpu_id]; + } + } + return NULL; +} + +vmware_regs_t *get_vmport_regs_any(struct hvm_ioreq_server *s, struct vcpu *v) +{ + struct domain *d = v->domain; + unsigned int id; + + ASSERT((v == current) || !vcpu_runnable(v)); + + if ( s ) + return get_vmport_regs_one(s, v); + + FOR_EACH_IOREQ_SERVER(d, id, s) + { + vmware_regs_t *ret = get_vmport_regs_one(s, v); + + if ( ret ) + return ret; + } + return NULL; +} + bool hvm_io_pending(struct vcpu *v) { return get_pending_vcpu(v, NULL); @@ -206,6 +244,26 @@ bool handle_hvm_io_completion(struct vcpu *v) return handle_mmio(); case HVMIO_pio_completion: + if ( vio->io_req.type == IOREQ_TYPE_VMWARE_PORT ) + { + vmware_regs_t *vr = get_vmport_regs_any(NULL, v); + + if ( vr ) + { + struct cpu_user_regs *regs = guest_cpu_user_regs(); + + /* The code in QEMU that uses these registers, + * vmport.c and vmmouse.c, only uses the 32bit part + * of the register. This is how VMware defined the + * use of these registers. + */ + regs->ebx = vr->ebx; + regs->ecx = vr->ecx; + regs->edx = vr->edx; + regs->esi = vr->esi; + regs->edi = vr->edi; + } + } return handle_pio(vio->io_req.addr, vio->io_req.size, vio->io_req.dir); @@ -233,16 +291,28 @@ static gfn_t hvm_alloc_legacy_ioreq_gfn(struct hvm_ioreq_server *s) unsigned int i; BUILD_BUG_ON(HVM_PARAM_BUFIOREQ_PFN != HVM_PARAM_IOREQ_PFN + 1); + BUILD_BUG_ON(HVM_PARAM_VMPORT_REGS_PFN != HVM_PARAM_BUFIOREQ_PFN + 1); for ( i = HVM_PARAM_IOREQ_PFN; i <= HVM_PARAM_BUFIOREQ_PFN; i++ ) { - if ( !test_and_clear_bit(i, &d->arch.hvm.ioreq_gfn.legacy_mask) ) + if ( test_and_clear_bit(i, &d->arch.hvm.ioreq_gfn.legacy_mask) ) return _gfn(d->arch.hvm.params[i]); } return INVALID_GFN; } +static gfn_t hvm_alloc_legacy_vmport_gfn(struct hvm_ioreq_server *s) +{ + struct domain *d = s->target; + unsigned int i = HVM_PARAM_VMPORT_REGS_PFN; + + if ( test_and_clear_bit(i, &d->arch.hvm.ioreq_gfn.legacy_mask) ) + return _gfn(d->arch.hvm.params[i]); + + return INVALID_GFN; +} + static gfn_t hvm_alloc_ioreq_gfn(struct hvm_ioreq_server *s) { struct domain *d = s->target; @@ -267,12 +337,12 @@ static bool hvm_free_legacy_ioreq_gfn(struct hvm_ioreq_server *s, struct domain *d = s->target; unsigned int i; - for ( i = HVM_PARAM_IOREQ_PFN; i <= HVM_PARAM_BUFIOREQ_PFN; i++ ) + for ( i = HVM_PARAM_IOREQ_PFN; i <= HVM_PARAM_VMPORT_REGS_PFN; i++ ) { if ( gfn_eq(gfn, _gfn(d->arch.hvm.params[i])) ) break; } - if ( i > HVM_PARAM_BUFIOREQ_PFN ) + if ( i > HVM_PARAM_VMPORT_REGS_PFN ) return false; set_bit(i, &d->arch.hvm.ioreq_gfn.legacy_mask); @@ -293,9 +363,29 @@ static void hvm_free_ioreq_gfn(struct hvm_ioreq_server *s, gfn_t gfn) } } -static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) +typedef enum { + ioreq_pt_ioreq, + ioreq_pt_bufioreq, + ioreq_pt_vmport, +} ioreq_pt_; + +static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; + struct hvm_ioreq_page *iorp = NULL; + + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); if ( gfn_eq(iorp->gfn, INVALID_GFN) ) return; @@ -307,12 +397,26 @@ static void hvm_unmap_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) iorp->gfn = INVALID_GFN; } -static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) +static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { struct domain *d = s->target; - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; + struct hvm_ioreq_page *iorp = NULL; int rc; + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); + if ( iorp->page ) { /* @@ -329,7 +433,10 @@ static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) if ( d->is_dying ) return -EINVAL; - iorp->gfn = hvm_alloc_ioreq_gfn(s); + if ( pt == ioreq_pt_vmport ) + iorp->gfn = hvm_alloc_legacy_vmport_gfn(s); + else + iorp->gfn = hvm_alloc_ioreq_gfn(s); if ( gfn_eq(iorp->gfn, INVALID_GFN) ) return -ENOMEM; @@ -338,16 +445,30 @@ static int hvm_map_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) &iorp->va); if ( rc ) - hvm_unmap_ioreq_gfn(s, buf); + hvm_unmap_ioreq_gfn(s, pt); return rc; } -static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf) +static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; + struct hvm_ioreq_page *iorp = NULL; struct page_info *page; + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); + if ( iorp->page ) { /* @@ -391,10 +512,25 @@ static int hvm_alloc_ioreq_mfn(struct hvm_ioreq_server *s, bool buf) return -ENOMEM; } -static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, bool buf) +static void hvm_free_ioreq_mfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; - struct page_info *page = iorp->page; + struct hvm_ioreq_page *iorp = NULL; + struct page_info *page = NULL; + + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); + page = iorp->page; if ( !page ) return; @@ -418,7 +554,9 @@ bool is_ioreq_server_page(struct domain *d, const struct page_info *page) FOR_EACH_IOREQ_SERVER(d, id, s) { - if ( (s->ioreq.page == page) || (s->bufioreq.page == page) ) + if ( (s->ioreq.page == page) || + (s->bufioreq.page == page) || + (s->vmport_ioreq.page == page) ) { found = true; break; @@ -430,11 +568,25 @@ bool is_ioreq_server_page(struct domain *d, const struct page_info *page) return found; } -static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) +static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { struct domain *d = s->target; - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; + struct hvm_ioreq_page *iorp = NULL; + + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); if ( gfn_eq(iorp->gfn, INVALID_GFN) ) return; @@ -445,12 +597,26 @@ static void hvm_remove_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) clear_page(iorp->va); } -static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, bool buf) +static int hvm_add_ioreq_gfn(struct hvm_ioreq_server *s, ioreq_pt_ pt) { struct domain *d = s->target; - struct hvm_ioreq_page *iorp = buf ? &s->bufioreq : &s->ioreq; + struct hvm_ioreq_page *iorp = NULL; int rc; + switch ( pt ) + { + case ioreq_pt_ioreq: + iorp = &s->ioreq; + break; + case ioreq_pt_bufioreq: + iorp = &s->bufioreq; + break; + case ioreq_pt_vmport: + iorp = &s->vmport_ioreq; + break; + } + ASSERT(iorp); + if ( gfn_eq(iorp->gfn, INVALID_GFN) ) return 0; @@ -480,6 +646,9 @@ static void hvm_update_ioreq_evtchn(struct hvm_ioreq_server *s, #define HANDLE_BUFIOREQ(s) \ ((s)->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) +#define HANDLE_VMPORT_IOREQ(s) \ + ((s)->target->arch.hvm.is_vmware_port_enabled) + static int hvm_ioreq_server_add_vcpu(struct hvm_ioreq_server *s, struct vcpu *v) { @@ -590,42 +759,72 @@ static int hvm_ioreq_server_map_pages(struct hvm_ioreq_server *s) { int rc; - rc = hvm_map_ioreq_gfn(s, false); + rc = hvm_map_ioreq_gfn(s, ioreq_pt_ioreq); if ( !rc && HANDLE_BUFIOREQ(s) ) - rc = hvm_map_ioreq_gfn(s, true); + rc = hvm_map_ioreq_gfn(s, ioreq_pt_bufioreq); if ( rc ) - hvm_unmap_ioreq_gfn(s, false); + { + hvm_unmap_ioreq_gfn(s, ioreq_pt_ioreq); + return rc; + } + + if ( HANDLE_VMPORT_IOREQ(s) ) + { + rc = hvm_map_ioreq_gfn(s, ioreq_pt_vmport); + + if ( rc ) + { + hvm_unmap_ioreq_gfn(s, ioreq_pt_bufioreq); + hvm_unmap_ioreq_gfn(s, ioreq_pt_ioreq); + } + } return rc; } static void hvm_ioreq_server_unmap_pages(struct hvm_ioreq_server *s) { - hvm_unmap_ioreq_gfn(s, true); - hvm_unmap_ioreq_gfn(s, false); + hvm_unmap_ioreq_gfn(s, ioreq_pt_vmport); + hvm_unmap_ioreq_gfn(s, ioreq_pt_bufioreq); + hvm_unmap_ioreq_gfn(s, ioreq_pt_ioreq); } static int hvm_ioreq_server_alloc_pages(struct hvm_ioreq_server *s) { int rc; - rc = hvm_alloc_ioreq_mfn(s, false); + rc = hvm_alloc_ioreq_mfn(s, ioreq_pt_ioreq); - if ( !rc && (s->bufioreq_handling != HVM_IOREQSRV_BUFIOREQ_OFF) ) - rc = hvm_alloc_ioreq_mfn(s, true); + if ( !rc && HANDLE_BUFIOREQ(s) ) + rc = hvm_alloc_ioreq_mfn(s, ioreq_pt_bufioreq); if ( rc ) - hvm_free_ioreq_mfn(s, false); + { + hvm_free_ioreq_mfn(s, ioreq_pt_ioreq); + return rc; + } + + if ( HANDLE_VMPORT_IOREQ(s) ) + { + rc = hvm_alloc_ioreq_mfn(s, ioreq_pt_vmport); + + if ( rc ) + { + hvm_free_ioreq_mfn(s, ioreq_pt_bufioreq); + hvm_free_ioreq_mfn(s, ioreq_pt_ioreq); + } + } return rc; } static void hvm_ioreq_server_free_pages(struct hvm_ioreq_server *s) { - hvm_free_ioreq_mfn(s, true); - hvm_free_ioreq_mfn(s, false); + hvm_free_ioreq_mfn(s, ioreq_pt_vmport); + hvm_free_ioreq_mfn(s, ioreq_pt_bufioreq); + hvm_free_ioreq_mfn(s, ioreq_pt_ioreq); } static void hvm_ioreq_server_free_rangesets(struct hvm_ioreq_server *s) @@ -645,12 +844,38 @@ static int hvm_ioreq_server_alloc_rangesets(struct hvm_ioreq_server *s, for ( i = 0; i < NR_IO_RANGE_TYPES; i++ ) { char *name; + char *type_name = NULL; + unsigned int limit; - rc = asprintf(&name, "ioreq_server %d %s", id, - (i == XEN_DMOP_IO_RANGE_PORT) ? "port" : - (i == XEN_DMOP_IO_RANGE_MEMORY) ? "memory" : - (i == XEN_DMOP_IO_RANGE_PCI) ? "pci" : - ""); + switch ( i ) + { + case XEN_DMOP_IO_RANGE_PORT: + type_name = "port"; + limit = MAX_NR_IO_RANGES; + break; + case XEN_DMOP_IO_RANGE_MEMORY: + type_name = "memory"; + limit = MAX_NR_IO_RANGES; + break; + case XEN_DMOP_IO_RANGE_PCI: + type_name = "pci"; + limit = MAX_NR_IO_RANGES; + break; + case XEN_DMOP_IO_RANGE_VMWARE_PORT: + type_name = "VMware port"; + limit = 1; + break; + case XEN_DMOP_IO_RANGE_TIMEOFFSET: + type_name = "timeoffset"; + limit = 1; + break; + default: + break; + } + if ( !type_name ) + continue; + + rc = asprintf(&name, "ioreq_server %d %s", id, type_name); if ( rc ) goto fail; @@ -663,7 +888,11 @@ static int hvm_ioreq_server_alloc_rangesets(struct hvm_ioreq_server *s, if ( !s->range[i] ) goto fail; - rangeset_limit(s->range[i], MAX_NR_IO_RANGES); + rangeset_limit(s->range[i], limit); + + /* VMware port */ + if ( i == XEN_DMOP_IO_RANGE_VMWARE_PORT && s->vmport_enabled ) + rc = rangeset_add_range(s->range[i], 1, 1); } return 0; @@ -683,8 +912,9 @@ static void hvm_ioreq_server_enable(struct hvm_ioreq_server *s) if ( s->enabled ) goto done; - hvm_remove_ioreq_gfn(s, false); - hvm_remove_ioreq_gfn(s, true); + hvm_remove_ioreq_gfn(s, ioreq_pt_vmport); + hvm_remove_ioreq_gfn(s, ioreq_pt_bufioreq); + hvm_remove_ioreq_gfn(s, ioreq_pt_ioreq); s->enabled = true; @@ -704,8 +934,9 @@ static void hvm_ioreq_server_disable(struct hvm_ioreq_server *s) if ( !s->enabled ) goto done; - hvm_add_ioreq_gfn(s, true); - hvm_add_ioreq_gfn(s, false); + hvm_add_ioreq_gfn(s, ioreq_pt_vmport); + hvm_add_ioreq_gfn(s, ioreq_pt_bufioreq); + hvm_add_ioreq_gfn(s, ioreq_pt_ioreq); s->enabled = false; @@ -714,7 +945,7 @@ static void hvm_ioreq_server_disable(struct hvm_ioreq_server *s) } static int hvm_ioreq_server_init(struct hvm_ioreq_server *s, - struct domain *d, int bufioreq_handling, + struct domain *d, int flags, ioservid_t id) { struct domain *currd = current->domain; @@ -730,14 +961,18 @@ static int hvm_ioreq_server_init(struct hvm_ioreq_server *s, INIT_LIST_HEAD(&s->ioreq_vcpu_list); spin_lock_init(&s->bufioreq_lock); + s->vmport_enabled = d->arch.hvm.is_vmware_port_enabled && + !(flags & HVM_IOREQSRV_DISABLE_VMPORT); + s->ioreq.gfn = INVALID_GFN; s->bufioreq.gfn = INVALID_GFN; + s->vmport_ioreq.gfn = INVALID_GFN; rc = hvm_ioreq_server_alloc_rangesets(s, id); if ( rc ) return rc; - s->bufioreq_handling = bufioreq_handling; + s->bufioreq_handling = flags & HVM_IOREQSRV_BUFIOREQ_MASK; for_each_vcpu ( d, v ) { @@ -780,14 +1015,15 @@ static void hvm_ioreq_server_deinit(struct hvm_ioreq_server *s) put_domain(s->emulator); } -int hvm_create_ioreq_server(struct domain *d, int bufioreq_handling, +int hvm_create_ioreq_server(struct domain *d, int flags, ioservid_t *id) { struct hvm_ioreq_server *s; unsigned int i; int rc; - if ( bufioreq_handling > HVM_IOREQSRV_BUFIOREQ_ATOMIC ) + if ( flags & ~HVM_IOREQSRV_FLAGS_MASK || + (flags & HVM_IOREQSRV_BUFIOREQ_MASK) > HVM_IOREQSRV_BUFIOREQ_ATOMIC ) return -EINVAL; s = xzalloc(struct hvm_ioreq_server); @@ -813,7 +1049,7 @@ int hvm_create_ioreq_server(struct domain *d, int bufioreq_handling, */ set_ioreq_server(d, i, s); - rc = hvm_ioreq_server_init(s, d, bufioreq_handling, i); + rc = hvm_ioreq_server_init(s, d, flags, i); if ( rc ) { set_ioreq_server(d, i, NULL); @@ -1004,6 +1240,8 @@ int hvm_map_io_range_to_ioreq_server(struct domain *d, ioservid_t id, case XEN_DMOP_IO_RANGE_PORT: case XEN_DMOP_IO_RANGE_MEMORY: case XEN_DMOP_IO_RANGE_PCI: + case XEN_DMOP_IO_RANGE_TIMEOFFSET: + case XEN_DMOP_IO_RANGE_VMWARE_PORT: r = s->range[type]; break; @@ -1056,6 +1294,8 @@ int hvm_unmap_io_range_from_ioreq_server(struct domain *d, ioservid_t id, case XEN_DMOP_IO_RANGE_PORT: case XEN_DMOP_IO_RANGE_MEMORY: case XEN_DMOP_IO_RANGE_PCI: + case XEN_DMOP_IO_RANGE_TIMEOFFSET: + case XEN_DMOP_IO_RANGE_VMWARE_PORT: r = s->range[type]; break; @@ -1248,7 +1488,10 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, uint64_t addr; unsigned int id; - if ( p->type != IOREQ_TYPE_COPY && p->type != IOREQ_TYPE_PIO ) + if ( p->type != IOREQ_TYPE_COPY && + p->type != IOREQ_TYPE_PIO && + p->type != IOREQ_TYPE_VMWARE_PORT && + p->type != IOREQ_TYPE_TIMEOFFSET ) return NULL; cf8 = d->arch.hvm.pci_cf8; @@ -1282,8 +1525,9 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, } else { - type = (p->type == IOREQ_TYPE_PIO) ? - XEN_DMOP_IO_RANGE_PORT : XEN_DMOP_IO_RANGE_MEMORY; + type = (p->type == IOREQ_TYPE_PIO) ? XEN_DMOP_IO_RANGE_PORT : + (p->type == IOREQ_TYPE_VMWARE_PORT) ? XEN_DMOP_IO_RANGE_VMWARE_PORT : + XEN_DMOP_IO_RANGE_MEMORY; addr = p->addr; } @@ -1326,6 +1570,14 @@ struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d, } break; + + case XEN_DMOP_IO_RANGE_VMWARE_PORT: + case XEN_DMOP_IO_RANGE_TIMEOFFSET: + /* The 'special' range of [1,1] is checked for being enabled. */ + if ( rangeset_contains_singleton(r, 1) ) + return s; + + break; } } diff --git a/xen/arch/x86/hvm/vmware/vmport.c b/xen/arch/x86/hvm/vmware/vmport.c index 863ec50..3c2e7d5 100644 --- a/xen/arch/x86/hvm/vmware/vmport.c +++ b/xen/arch/x86/hvm/vmware/vmport.c @@ -14,6 +14,7 @@ */ #include +#include #include #include @@ -23,6 +24,32 @@ static int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) { struct cpu_user_regs *regs = guest_cpu_user_regs(); +#define port_overlap(p, n) \ + ((p + n > BDOOR_PORT) && (p + n <= BDOOR_PORT + 4) ? 1 : \ + (BDOOR_PORT + 4 > p) && (BDOOR_PORT + 4 <= p + n) ? 1 : 0) + + BUILD_BUG_ON(port_overlap(PIT_BASE, 4)); + BUILD_BUG_ON(port_overlap(0x61, 1)); + BUILD_BUG_ON(port_overlap(XEN_HVM_DEBUGCONS_IOPORT, 1)); + BUILD_BUG_ON(port_overlap(0xcf8, 4)); +/* #define TMR_VAL_ADDR_V0 (ACPI_PM_TMR_BLK_ADDRESS_V0) */ + BUILD_BUG_ON(port_overlap(ACPI_PM_TMR_BLK_ADDRESS_V0, 4)); +/* #define PM1a_STS_ADDR_V0 (ACPI_PM1A_EVT_BLK_ADDRESS_V0) */ + BUILD_BUG_ON(port_overlap(ACPI_PM1A_EVT_BLK_ADDRESS_V0, 4)); + BUILD_BUG_ON(port_overlap(RTC_PORT(0), 2)); + BUILD_BUG_ON(port_overlap(0x3c4, 2)); + BUILD_BUG_ON(port_overlap(0x3ce, 2)); +/* + * acpi_smi_cmd can not be checked at build time: + * xen/include/asm-x86/acpi.h:extern u32 acpi_smi_cmd; + * xen/arch/x86/acpi/boot.c: acpi_smi_cmd = fadt->smi_command; + BUILD_BUG_ON(port_overlap(acpi_smi_cmd, 1)); +*/ + BUILD_BUG_ON(port_overlap(0x20, 2)); + BUILD_BUG_ON(port_overlap(0xa0, 2)); + BUILD_BUG_ON(port_overlap(0x4d0, 1)); + BUILD_BUG_ON(port_overlap(0x4d1, 1)); + /* * While VMware expects only 32-bit in, they do support using * other sizes and out. However they do require only the 1 port @@ -137,6 +164,15 @@ void vmport_register(struct domain *d) register_portio_handler(d, BDOOR_PORT, 4, vmport_ioport); } +bool_t vmport_check_port(unsigned int port, unsigned int bytes) +{ + struct domain *currd = current->domain; + + return is_hvm_domain(currd) && + currd->arch.hvm.is_vmware_port_enabled && + (port >= BDOOR_PORT) && ((port + bytes) <= (BDOOR_PORT + 4)); +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index 355777c..cdfa62e 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -43,7 +43,7 @@ struct hvm_ioreq_vcpu { bool pending; }; -#define NR_IO_RANGE_TYPES (XEN_DMOP_IO_RANGE_PCI + 1) +#define NR_IO_RANGE_TYPES (XEN_DMOP_IO_RANGE_VMWARE_PORT + 1) #define MAX_NR_IO_RANGES 256 struct hvm_ioreq_server { @@ -54,6 +54,7 @@ struct hvm_ioreq_server { struct hvm_ioreq_page ioreq; struct list_head ioreq_vcpu_list; + struct hvm_ioreq_page vmport_ioreq; struct hvm_ioreq_page bufioreq; /* Lock to serialize access to buffered ioreq ring */ @@ -62,6 +63,7 @@ struct hvm_ioreq_server { struct rangeset *range[NR_IO_RANGE_TYPES]; bool enabled; uint8_t bufioreq_handling; + bool_t vmport_enabled; }; #ifdef CONFIG_MEM_SHARING diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 74a9590..48bcc98 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -790,6 +790,7 @@ static inline bool hvm_has_set_descriptor_access_exiting(void) #endif /* CONFIG_HVM */ void vmport_register(struct domain *d); +bool_t vmport_check_port(unsigned int port, unsigned int bytes); #endif /* __ASM_X86_HVM_HVM_H__ */ diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h index fd00e9d..039b9e4 100644 --- a/xen/include/public/hvm/dm_op.h +++ b/xen/include/public/hvm/dm_op.h @@ -60,16 +60,24 @@ typedef uint16_t ioservid_t; * secondary emulator. * * The handed back is unique for target domain. The valur of - * should be one of HVM_IOREQSRV_BUFIOREQ_* defined in - * hvm_op.h. If the value is HVM_IOREQSRV_BUFIOREQ_OFF then the buffered + * should be one of HVM_IOREQSRV_BUFIOREQ_* defined in + * hvm_op.h and ored with HVM_IOREQSRV_DISABLE_VMPORT defined below + * if not the 1st IOREQ Server that supports VMware port operation. + * If the value is HVM_IOREQSRV_BUFIOREQ_OFF then the buffered * ioreq ring will not be allocated and hence all emulation requests to * this server will be synchronous. */ #define XEN_DMOP_create_ioreq_server 1 struct xen_dm_op_create_ioreq_server { - /* IN - should server handle buffered ioreqs */ - uint8_t handle_bufioreq; + /* IN - should server handle buffered ioreqs and/or vmport regs */ +#define HVM_IOREQSRV_BUFIOREQ_MASK 3 +/* + * Disable vmport regs mapping. + */ +#define HVM_IOREQSRV_DISABLE_VMPORT 4 +#define HVM_IOREQSRV_FLAGS_MASK 7 + uint8_t flags; uint8_t pad[3]; /* OUT - server id */ ioservid_t id; @@ -132,6 +140,9 @@ struct xen_dm_op_get_ioreq_server_info { * * NOTE: unless an emulation request falls entirely within a range mapped * by a secondary emulator, it will not be passed to that emulator. + * + * NOTE: The 'special' range of [1,1] is what is checked for on + * TIMEOFFSET and VMWARE_PORT. */ #define XEN_DMOP_map_io_range_to_ioreq_server 3 #define XEN_DMOP_unmap_io_range_from_ioreq_server 4 @@ -145,6 +156,8 @@ struct xen_dm_op_ioreq_server_range { # define XEN_DMOP_IO_RANGE_PORT 0 /* I/O port range */ # define XEN_DMOP_IO_RANGE_MEMORY 1 /* MMIO range */ # define XEN_DMOP_IO_RANGE_PCI 2 /* PCI segment/bus/dev/func range */ +# define XEN_DMOP_IO_RANGE_TIMEOFFSET 7 /* TIMEOFFSET special range */ +# define XEN_DMOP_IO_RANGE_VMWARE_PORT 9 /* VMware port special range */ /* IN - inclusive start and end of range */ uint64_aligned_t start, end; }; diff --git a/xen/include/public/hvm/ioreq.h b/xen/include/public/hvm/ioreq.h index c511fae..19a17ac 100644 --- a/xen/include/public/hvm/ioreq.h +++ b/xen/include/public/hvm/ioreq.h @@ -37,6 +37,7 @@ #define IOREQ_TYPE_PCI_CONFIG 2 #define IOREQ_TYPE_TIMEOFFSET 7 #define IOREQ_TYPE_INVALIDATE 8 /* mapcache */ +#define IOREQ_TYPE_VMWARE_PORT 9 /* pio + vmport registers */ /* * VMExit dispatcher should cooperate with instruction decoder to @@ -48,6 +49,8 @@ * * 63....48|47..40|39..35|34..32|31........0 * SEGMENT |BUS |DEV |FN |OFFSET + * + * For I/O type IOREQ_TYPE_VMWARE_PORT also use the vmware_regs. */ struct ioreq { uint64_t addr; /* physical address */ @@ -66,11 +69,25 @@ struct ioreq { }; typedef struct ioreq ioreq_t; +struct vmware_regs { + uint32_t esi; + uint32_t edi; + uint32_t ebx; + uint32_t ecx; + uint32_t edx; +}; +typedef struct vmware_regs vmware_regs_t; + struct shared_iopage { struct ioreq vcpu_ioreq[1]; }; typedef struct shared_iopage shared_iopage_t; +struct shared_vmport_iopage { + struct vmware_regs vcpu_vmport_regs[1]; +}; +typedef struct shared_vmport_iopage shared_vmport_iopage_t; + struct buf_ioreq { uint8_t type; /* I/O type */ uint8_t pad:1; diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h index 0a91bfa..d300fae 100644 --- a/xen/include/public/hvm/params.h +++ b/xen/include/public/hvm/params.h @@ -94,8 +94,8 @@ #define HVM_PARAM_STORE_EVTCHN 2 #define HVM_PARAM_IOREQ_PFN 5 - #define HVM_PARAM_BUFIOREQ_PFN 6 +#define HVM_PARAM_VMPORT_REGS_PFN 7 #if defined(__i386__) || defined(__x86_64__) From patchwork Wed Aug 19 16:52:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Slutz X-Patchwork-Id: 11724679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 816EF618 for ; Wed, 19 Aug 2020 16:54:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52B34207FF for ; Wed, 19 Aug 2020 16:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YE6Jjt1J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52B34207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKa-0003yD-Tp; Wed, 19 Aug 2020 16:52:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k8RKZ-0003kZ-LA for xen-devel@lists.xen.org; Wed, 19 Aug 2020 16:52:55 +0000 X-Inumbo-ID: 8d5413bf-f60f-4661-a088-a6f4955accda Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 8d5413bf-f60f-4661-a088-a6f4955accda; Wed, 19 Aug 2020 16:52:28 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id d14so22197212qke.13 for ; Wed, 19 Aug 2020 09:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=UOZwC4Sr72TsLIpeWc9kglyixuN4WULXzUwKP2kaYAQ=; b=YE6Jjt1JsB5r8GESgFnMrZyy6LmwKAdGskg760FQtdpjBLOwr82fwOfPFs6hfk9Ox9 21Wmtu3PySlcuMDrsachk0TUZHmt5p8QhYkzOvf5wNscH/iq1TyoJh7mZtIs7bPMdEG1 YazrZ0daATMkJx0OJ2GFri1tPdcnRWCR0WhA3Pp/l82bLUVaBzidzGcQePG9iKERtgbI 8aXqHBzdVMiFH8YFp7zOK+e4xTqQrEisw3MRKb2Jziy/mB4IuITs4mWmN/lcDpBFzo++ f380IdllcpCYPIp1qyz0M/rCwSShPkk5pxHU4geoa2i588IF690opttCrvgyX0Ym+u4j DQOA== 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:in-reply-to :references:in-reply-to:references; bh=UOZwC4Sr72TsLIpeWc9kglyixuN4WULXzUwKP2kaYAQ=; b=tCKU5JTVp+qEdUxdpSBbFCdaea7XbDJ3CVU8H9qgfNslcXH/zYJLsItSO530ltRysK ZMaBrVyKF8TJxucIgsO3drYtrOXVKkhMaJwZdvpETFN0NoRClY8R4sjgUT+uMik0M3pr nX21xXEv1BoyEfWsErzjodnjlmjR2to2xKdCc6GH96GiyPivRfixiWATwZLYrUGKv+j+ iI+1KdlGZmgCvzI4F513snvFVm0qvKjp7/hrK81dp3RmJeS6GW9m4f4IRbo9r2d5I9ri iOWtA0yZrBTvp9V71GPcez7cTqY9k/ZcLuuorIQgWxWXS2EbX3NgwuH9rfFK09J73ozi PGlA== X-Gm-Message-State: AOAM532aSNP1tao/Mv9329xIkClDyxlCVGvtaJfDqGcaKfpNhn0mN4h2 RB2Ykdc31RugcCEQHwtDJxKZuX/UrpvraZxB X-Google-Smtp-Source: ABdhPJwXNKLrXid2Qv0hgCR00yyNfNwl5CZfuvD2a0A06Ta58hRZG6JMEOyJxrajfGKem6rlWUsZ8A== X-Received: by 2002:a37:9d53:: with SMTP id g80mr21774186qke.17.1597855947858; Wed, 19 Aug 2020 09:52:27 -0700 (PDT) Received: from TestCloud1.don.dslutz.org.zatium.us (pool-96-230-225-98.bstnma.fios.verizon.net. [96.230.225.98]) by smtp.googlemail.com with ESMTPSA id 128sm25105832qkk.101.2020.08.19.09.52.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2020 09:52:27 -0700 (PDT) From: Don Slutz X-Google-Original-From: Don Slutz , Boris Ostrovsky , Eddie Dong , Ian Campbell , Ian Jackson , Jan Beulich , Jun Nakajima , Keir Fraser , Kevin Tian , Stefano Stabellini , Suravee Suthikulpanit , Tim Deegan , Andrew Cooper , Konrad Rzeszutek Wilk , George Dunlap , Don Slutz , Don Slutz Subject: [Xen-devel] [XEN PATCH v14 8/8] Add xentrace to vmware_port Date: Wed, 19 Aug 2020 12:52:02 -0400 Message-Id: <1bfc92ee47f425235821c3655564a5a4b3d34593.1597854908.git.don.slutz@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: <34a50dc69e4c5722597e02a4df4e3da6d6586ec7.1597854907.git.don.slutz@gmail.com> <67b90d11eae2c88faab22d458e7e38db0f5aada4.1597854907.git.don.slutz@gmail.com> <5d2e424a19ea4934be3be962cdbe6a0ec8db9a6c.1597854907.git.don.slutz@gmail.com> <4780b5be94be7820861f29fb618a2420effe26f5.1597854907.git.don.slutz@gmail.com> In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Don Slutz Also added missing TRAP_DEBUG & VLAPIC. Signed-off-by: Don Slutz CC: Don Slutz --- Acked-by: Ian Campbell v14: Reworked to current code. Added VMPORT_SEND because I wanted to see it during testing. v13: Please do this by extending the existing infrastructure rather than special-casing 7 on the side. (i.e. extend ND to take 7 parameters, and introduce HVMTRACE_7D) = { d1, d2, d3, d4, d5, d6, d7 } will be far shorter, linewise. v12: Switch VMPORT_IGNORED to port, regs->_eax. v11: No change v10: Added Acked-by: Ian Campbell Added back in the trace point calls. Why is cmd in this patch? Because the trace points use it. v9: Dropped unneed VMPORT_UNHANDLED, VMPORT_DECODE. v7: Dropped some of the new traces. Added HVMTRACE_ND7. v6: Dropped the attempt to use svm_nextrip_insn_length via __get_instruction_length (added in v2). Just always look at upto 15 bytes on AMD. v5: exitinfo1 is used twice. Fixed. tools/xentrace/formats | 6 ++++ xen/arch/x86/hvm/ioreq.c | 3 ++ xen/arch/x86/hvm/svm/svm.c | 6 ++-- xen/arch/x86/hvm/vmware/vmport.c | 16 +++++++++-- xen/arch/x86/hvm/vmx/vmx.c | 6 ++-- xen/include/asm-x86/hvm/trace.h | 60 ++++++++++++++++++++-------------------- xen/include/public/trace.h | 4 +++ 7 files changed, 62 insertions(+), 39 deletions(-) diff --git a/tools/xentrace/formats b/tools/xentrace/formats index deac4d8..9e7056c 100644 --- a/tools/xentrace/formats +++ b/tools/xentrace/formats @@ -132,6 +132,12 @@ 0x00082020 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) INTR_WINDOW [ value = 0x%(1)08x ] 0x00082021 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) NPF [ gpa = 0x%(2)08x%(1)08x mfn = 0x%(4)08x%(3)08x qual = 0x%(5)04x p2mt = 0x%(6)04x ] 0x00082023 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) TRAP [ vector = 0x%(1)02x ] +0x00082024 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) TRAP_DEBUG [ exit_qualification = 0x%(1)08x ] +0x00082025 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) VLAPIC +0x00082028 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) VMPORT_HANDLED [ cmd = %(1)d eax = 0x%(2)08x ebx = 0x%(3)08x ecx = 0x%(4)08x edx = 0x%(5)08x esi = 0x%(6)08x edi = 0x%(7)08x ] +0x00082029 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) VMPORT_IGNORED [ port = %(1)d eax = 0x%(2)08x ] +0x0008202a CPU%(cpu)d %(tsc)d (+%(reltsc)8d) VMPORT_QEMU [ eax = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ] +0x0008202b CPU%(cpu)d %(tsc)d (+%(reltsc)8d) VMPORT_SEND [ cmd = 0x%(1)08x ebx = 0x%(2)08x ecx = 0x%(3)08x edx = 0x%(4)08x esi = 0x%(5)08x edi = 0x%(6)08x ] 0x0010f001 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_map [ domid = %(1)d ] 0x0010f002 CPU%(cpu)d %(tsc)d (+%(reltsc)8d) page_grant_unmap [ domid = %(1)d ] diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index a5d124e..c64fda8 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -262,6 +262,9 @@ bool handle_hvm_io_completion(struct vcpu *v) regs->edx = vr->edx; regs->esi = vr->esi; regs->edi = vr->edi; + HVMTRACE_ND(VMPORT_QEMU, 0, 1/*cycles*/, 6, + vio->io_req.data, regs->ebx, regs->ecx, + regs->edx, regs->esi, regs->edi, 0); } } return handle_pio(vio->io_req.addr, vio->io_req.size, diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index ca3bbfc..60c030a 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1052,7 +1052,7 @@ void svm_vmenter_helper(const struct cpu_user_regs *regs) if ( unlikely(tb_init_done) ) HVMTRACE_ND(VMENTRY, nestedhvm_vcpu_in_guestmode(curr) ? TRC_HVM_NESTEDFLAG : 0, - 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0); + 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0, 0); svm_sync_vmcb(curr, vmcb_needs_vmsave); @@ -2531,11 +2531,11 @@ void svm_vmexit_handler(struct cpu_user_regs *regs) if ( hvm_long_mode_active(v) ) HVMTRACE_ND(VMEXIT64, vcpu_guestmode ? TRC_HVM_NESTEDFLAG : 0, 1/*cycles*/, 3, exit_reason, - regs->eip, regs->rip >> 32, 0, 0, 0); + regs->eip, regs->rip >> 32, 0, 0, 0, 0); else HVMTRACE_ND(VMEXIT, vcpu_guestmode ? TRC_HVM_NESTEDFLAG : 0, 1/*cycles*/, 2, exit_reason, - regs->eip, 0, 0, 0, 0); + regs->eip, 0, 0, 0, 0, 0); if ( vcpu_guestmode ) { diff --git a/xen/arch/x86/hvm/vmware/vmport.c b/xen/arch/x86/hvm/vmware/vmport.c index 3c2e7d5..0467aff 100644 --- a/xen/arch/x86/hvm/vmware/vmport.c +++ b/xen/arch/x86/hvm/vmware/vmport.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "backdoor_def.h" @@ -62,6 +63,7 @@ static int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) if ( port == BDOOR_PORT && regs->eax == BDOOR_MAGIC ) { uint32_t new_eax = ~0u; + uint16_t cmd = regs->ecx; uint64_t value; struct vcpu *curr = current; struct domain *currd = curr->domain; @@ -72,7 +74,7 @@ static int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) * leaving the high 32-bits unchanged, unlike what one would * expect to happen. */ - switch ( regs->ecx & 0xffff ) + switch ( cmd ) { case BDOOR_CMD_GETMHZ: new_eax = currd->arch.tsc_khz / 1000; @@ -147,14 +149,22 @@ static int vmport_ioport(int dir, uint32_t port, uint32_t bytes, uint32_t *val) break; default: + HVMTRACE_6D(VMPORT_SEND, cmd, regs->ebx, regs->ecx, + regs->edx, regs->esi, regs->edi); /* Let backing DM handle */ return X86EMUL_UNHANDLEABLE; } + HVMTRACE_7D(VMPORT_HANDLED, cmd, new_eax, regs->ebx, regs->ecx, + regs->edx, regs->esi, regs->edi); if ( dir == IOREQ_READ ) *val = new_eax; } - else if ( dir == IOREQ_READ ) - *val = ~0u; + else + { + HVMTRACE_2D(VMPORT_IGNORED, port, regs->eax); + if ( dir == IOREQ_READ ) + *val = ~0u; + } return X86EMUL_OKAY; } diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index a0d58ff..8cba2a3 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3683,10 +3683,10 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) if ( hvm_long_mode_active(v) ) HVMTRACE_ND(VMEXIT64, 0, 1/*cycles*/, 3, exit_reason, - regs->eip, regs->rip >> 32, 0, 0, 0); + regs->eip, regs->rip >> 32, 0, 0, 0, 0); else HVMTRACE_ND(VMEXIT, 0, 1/*cycles*/, 2, exit_reason, - regs->eip, 0, 0, 0, 0); + regs->eip, 0, 0, 0, 0, 0); perfc_incra(vmexits, exit_reason); @@ -4463,7 +4463,7 @@ bool vmx_vmenter_helper(const struct cpu_user_regs *regs) if ( unlikely(curr->arch.hvm.vmx.lbr_flags & LBR_FIXUP_MASK) ) lbr_fixup(); - HVMTRACE_ND(VMENTRY, 0, 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0); + HVMTRACE_ND(VMENTRY, 0, 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0, 0); __vmwrite(GUEST_RIP, regs->rip); __vmwrite(GUEST_RSP, regs->rsp); diff --git a/xen/include/asm-x86/hvm/trace.h b/xen/include/asm-x86/hvm/trace.h index 5cd459b..9d7f04e 100644 --- a/xen/include/asm-x86/hvm/trace.h +++ b/xen/include/asm-x86/hvm/trace.h @@ -56,6 +56,10 @@ #define DO_TRC_HVM_TRAP DEFAULT_HVM_MISC #define DO_TRC_HVM_TRAP_DEBUG DEFAULT_HVM_MISC #define DO_TRC_HVM_VLAPIC DEFAULT_HVM_MISC +#define DO_TRC_HVM_VMPORT_HANDLED DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_IGNORED DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_QEMU DEFAULT_HVM_IO +#define DO_TRC_HVM_VMPORT_SEND DEFAULT_HVM_IO #define TRC_PAR_LONG(par) ((par)&0xFFFFFFFF),((par)>>32) @@ -67,38 +71,34 @@ #define TRACE_2_LONG_4D(_e, d1, d2, d3, d4, ...) \ TRACE_6D(_e, d1, d2, d3, d4) -#define HVMTRACE_ND(evt, modifier, cycles, count, d1, d2, d3, d4, d5, d6) \ - do { \ - if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt ) \ - { \ - struct { \ - u32 d[6]; \ - } _d; \ - _d.d[0]=(d1); \ - _d.d[1]=(d2); \ - _d.d[2]=(d3); \ - _d.d[3]=(d4); \ - _d.d[4]=(d5); \ - _d.d[5]=(d6); \ - __trace_var(TRC_HVM_ ## evt | (modifier), cycles, \ - sizeof(*_d.d) * count, &_d); \ - } \ +#define HVMTRACE_ND(evt, modifier, cycles, count, d1, d2, d3, d4, d5, d6, d7) \ + do { \ + if ( unlikely(tb_init_done) && DO_TRC_HVM_ ## evt ) \ + { \ + struct { \ + u32 d[7]; \ + } _d = { { d1, d2, d3, d4, d5, d6, d7 } }; \ + __trace_var(TRC_HVM_ ## evt | (modifier), cycles, \ + sizeof(*_d.d) * count, &_d); \ + } \ } while(0) -#define HVMTRACE_6D(evt, d1, d2, d3, d4, d5, d6) \ - HVMTRACE_ND(evt, 0, 0, 6, d1, d2, d3, d4, d5, d6) -#define HVMTRACE_5D(evt, d1, d2, d3, d4, d5) \ - HVMTRACE_ND(evt, 0, 0, 5, d1, d2, d3, d4, d5, 0) -#define HVMTRACE_4D(evt, d1, d2, d3, d4) \ - HVMTRACE_ND(evt, 0, 0, 4, d1, d2, d3, d4, 0, 0) -#define HVMTRACE_3D(evt, d1, d2, d3) \ - HVMTRACE_ND(evt, 0, 0, 3, d1, d2, d3, 0, 0, 0) -#define HVMTRACE_2D(evt, d1, d2) \ - HVMTRACE_ND(evt, 0, 0, 2, d1, d2, 0, 0, 0, 0) -#define HVMTRACE_1D(evt, d1) \ - HVMTRACE_ND(evt, 0, 0, 1, d1, 0, 0, 0, 0, 0) -#define HVMTRACE_0D(evt) \ - HVMTRACE_ND(evt, 0, 0, 0, 0, 0, 0, 0, 0, 0) +#define HVMTRACE_7D(evt, d1, d2, d3, d4, d5, d6, d7) \ + HVMTRACE_ND(evt, 0, 0, 7, d1, d2, d3, d4, d5, d6, d7) +#define HVMTRACE_6D(evt, d1, d2, d3, d4, d5, d6) \ + HVMTRACE_ND(evt, 0, 0, 6, d1, d2, d3, d4, d5, d6, 0) +#define HVMTRACE_5D(evt, d1, d2, d3, d4, d5) \ + HVMTRACE_ND(evt, 0, 0, 5, d1, d2, d3, d4, d5, 0, 0) +#define HVMTRACE_4D(evt, d1, d2, d3, d4) \ + HVMTRACE_ND(evt, 0, 0, 4, d1, d2, d3, d4, 0, 0, 0) +#define HVMTRACE_3D(evt, d1, d2, d3) \ + HVMTRACE_ND(evt, 0, 0, 3, d1, d2, d3, 0, 0, 0, 0) +#define HVMTRACE_2D(evt, d1, d2) \ + HVMTRACE_ND(evt, 0, 0, 2, d1, d2, 0, 0, 0, 0, 0) +#define HVMTRACE_1D(evt, d1) \ + HVMTRACE_ND(evt, 0, 0, 1, d1, 0, 0, 0, 0, 0, 0) +#define HVMTRACE_0D(evt) \ + HVMTRACE_ND(evt, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) #define HVMTRACE_LONG_1D(evt, d1) \ HVMTRACE_2D(evt ## 64, (d1) & 0xFFFFFFFF, (d1) >> 32) diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index d5fa4ae..6b93f62 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -237,6 +237,10 @@ #define TRC_HVM_VLAPIC (TRC_HVM_HANDLER + 0x25) #define TRC_HVM_XCR_READ64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x26) #define TRC_HVM_XCR_WRITE64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x27) +#define TRC_HVM_VMPORT_HANDLED (TRC_HVM_HANDLER + 0x28) +#define TRC_HVM_VMPORT_IGNORED (TRC_HVM_HANDLER + 0x29) +#define TRC_HVM_VMPORT_QEMU (TRC_HVM_HANDLER + 0x2a) +#define TRC_HVM_VMPORT_SEND (TRC_HVM_HANDLER + 0x2b) #define TRC_HVM_IOPORT_WRITE (TRC_HVM_HANDLER + 0x216) #define TRC_HVM_IOMEM_WRITE (TRC_HVM_HANDLER + 0x217)