Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F3C8C433E0 for ; Thu, 18 Jun 2020 13:40:55 +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 D3543207D8 for ; Thu, 18 Jun 2020 13:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3543207D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.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 1jlumS-0005Ec-8f; Thu, 18 Jun 2020 13:40: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 1jlumQ-0005EX-CB for xen-devel@lists.xenproject.org; Thu, 18 Jun 2020 13:40:34 +0000 X-Inumbo-ID: 47ff4ae4-b169-11ea-bca7-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 47ff4ae4-b169-11ea-bca7-bc764e2007e4; Thu, 18 Jun 2020 13:40:33 +0000 (UTC) Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: yN3UFB3VzsZR+28uTtTftXIBNXMfN1rGaIT6HroeD/cbj2HC4NKoRzn5wXPyHvBNJT6eJRHF9w z6QlPbhrRxpkItIXVRdPrBHf6PjvWDXEoWGPq2X46h7jtI15H7k2nJOiCFjInhBjNhizKxJO+v X9q4sfBA2EfOuBNQPadI6vH7GY5O2Su4XUCd5PIWkd1UXRaqYyhQD7HCC8a9Hy0e0heqwdz+4z S+kbaWbfYHBugtHnPEayn+XzhxufkscS/JHoMT5l24KkoyDLcLEOhJmOPr88Un5hPRNH5+Hpk3 Gj4= X-SBRS: 2.7 X-MesageID: 20717356 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,526,1583211600"; d="scan'208";a="20717356" Date: Thu, 18 Jun 2020 15:40:23 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: =?utf-8?Q?Micha=C5=82_Leszczy=C5=84ski?= Subject: Re: [PATCH v1 4/7] x86/vmx: add do_vmtrace_op Message-ID: <20200618134023.GP735@Air-de-Roger> References: <1548605014.8764792.1592320576239.JavaMail.zimbra@cert.pl> <34833328.8766172.1592320926648.JavaMail.zimbra@cert.pl> <20200616172352.GT735@Air-de-Roger> <998292451.9258672.1592421185726.JavaMail.zimbra@cert.pl> <832789003.9534743.1592478099057.JavaMail.zimbra@cert.pl> <20200618115519.GL735@Air-de-Roger> <9924a5d9-b851-257a-9a6a-7a5712898a71@suse.com> <1226758073.9662727.1592485797234.JavaMail.zimbra@cert.pl> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1226758073.9662727.1592485797234.JavaMail.zimbra@cert.pl> X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) 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: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Tamas K Lengyel , Ian Jackson , George Dunlap , Jan Beulich , Andrew Cooper , Xen-devel Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On Thu, Jun 18, 2020 at 03:09:57PM +0200, Michał Leszczyński wrote: > ----- 18 cze 2020 o 14:51, Jan Beulich jbeulich@suse.com napisał(a): > > > On 18.06.2020 13:55, Roger Pau Monné wrote: > >> On Thu, Jun 18, 2020 at 01:01:39PM +0200, Michał Leszczyński wrote: > >>> It was previously stated that: > >>> > >>>> PVH or HVM domain > >>>> won't be able to use this interface since it has no way to request the > >>>> mapping of a specific mfn into it's physmap. > >>> > >>> but however, taking LibVMI as an example: > >>> > >>> https://github.com/libvmi/libvmi/blob/c461e20ae88bc62c08c27f50fcead23c27a30f9e/libvmi/driver/xen/xen.c#L51 > >>> > >>> An essential abstraction xen_get_memory() relies on xc_map_foreign_range(). > >>> Doesn't this mean that it's not usable from PVH or HVM domains, or did I got it > >>> all wrong? > >> > >> That was my fault, so the buffer mfns are assigned to Xen, and then > >> the Xen domain ID is used to map those, which should work on both PV > >> and HVM (or PVH). > >> > >> I still think using XENMEM_acquire_resource might be better, but I > >> would let others comment. > > > > +1 > > > > Jan > > > I'm trying to implement this right now. I've added some very simple code to mm.c just for testing: > > --- > > diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c > index e376fc7e8f..aaaefe6d23 100644 > --- a/xen/arch/x86/mm.c > +++ b/xen/arch/x86/mm.c > @@ -4624,6 +4624,26 @@ int arch_acquire_resource(struct domain *d, unsigned int type, > } > break; > } > + > + case XENMEM_resource_vmtrace_buf: > + { > + uint64_t output_base; > + mfn_t mfn; > + unsigned int i; > + > + printk("vmtrace buf acquire\n"); > + output_base = d->vcpu[id]->arch.hvm.vmx.ipt_state->output_base; > + mfn = mfn_x(output_base >> PAGE_SHIFT); > + > + rc = 0; > + for ( i = 0; i < nr_frames; i++ ) > + { > + __map_domain_page_global(mfn_to_page(mfn + i)); I don't think you need the __map_domain_page_global? > + mfn_list[i] = mfn + i; I think you need mfn_add here, or else this won't build? > + } > + > + break; > + } > #endif > > default: > > --- > > > and then in my "proctrace" tool I'm trying to acquire it like this: > > fres = xenforeignmemory_map_resource( > fmem, domid, XENMEM_resource_vmtrace_buf, > /* vcpu: */ 0, /* frame: */ 0, /* num_frames: */ 128, (void **)&buf, > PROT_READ, 0); > > > ioctl fails with "Argument list too long". It works fine when I provide some small number of frames (e.g. num_frames: 1 or 32), but doesn't work for any larger quantity. > > How should I proceed with this? The PT buffer could be large, even up to 4 GB. I think adding a loop and hypercall continuation support could make this work without having to expand the size of mfn_list and gfn_list? Thanks, Roger.