From nobody Mon Feb 9 16:19:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1611976978; cv=none; d=zohomail.com; s=zohoarc; b=N0kooBrBo272XgbIbctmHv7i53/ZoMhulGfM9Ffl4oVgKpLM7RvxuRhBgTeI1V625s0td7FJ5PlbAOv6wZBzywr+ByVAbFxaZjAJRWfMIzgFeox/7aby5RlVib37UGD8mfMUFx7k0sX65Ex7YIDhI1BHRj8DD6xHecjpexMl310= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611976978; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Nt6E5JJR324KoMH4EN/uUCckRwz0YAQ+VrcLJEOtHU=; b=Uak0iaJ4GJMJeLuW3TiqAdimRzJtp6WrBpbXXseT+laim3kACv37O2M3sUq0jx5HBjBwp1TlsznZCc5+6cBw6OA94n+PEPCVtArGpsp6LD0cDl/PVABqNBCiR84xBM8g+UcUR8H5NciSJpUtPeJCKc3EgPG+x/jtGnNt7Ccd5tM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1611976978399347.87515873697544; Fri, 29 Jan 2021 19:22:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.78684.143267 (Exim 4.92) (envelope-from ) id 1l5gqK-0004Z3-GS; Sat, 30 Jan 2021 03:22:36 +0000 Received: by outflank-mailman (output) from mailman id 78684.143267; Sat, 30 Jan 2021 03:22:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5gqK-0004Yw-Db; Sat, 30 Jan 2021 03:22:36 +0000 Received: by outflank-mailman (input) for mailman id 78684; Sat, 30 Jan 2021 03:22:35 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l5gqJ-0004Yr-71 for xen-devel@lists.xenproject.org; Sat, 30 Jan 2021 03:22:35 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2d5896f1-1604-4ab2-8101-c882369adbd0; Sat, 30 Jan 2021 03:22:34 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2d5896f1-1604-4ab2-8101-c882369adbd0 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1611976953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SJRgavZh5UboqFIes1Vgd8L9o/aFp0WpSJ+Ons+P7bw=; b=hGSMAZLUWcAnFrRYckALD9pfONhwoWRR1pkRwnQg+gOvaNbsYqGnwSlK fn91qFoDFkpUQPEBZb54x5u2Ri7YgwPj2NfUn2WN8KQ/xXEa/hggOYSsd RGNFkfINMOjjbFrAoDyTA7uea7TTvEt1KKlksTC1LbYAo63NEVSPgH6Gh E=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: YWoLTu4+8tyCcrWEER8FvlB/APsXKRKMpM+RB9eR0PmgQ1FyrDrngcnDUFIQInCq7MkCg5zbBa L4gSgoca9loNhVxlMyoKwKAXPfAWICcC16bHs64s0O21UqUiQEivs6AG7jCJdkG/YpZ/1YbY0B Wfhsvfl1SCkoLzjGfe/R4czrTm/hcDIG6HazhKB2lVJGwjlUUWhX1AAm1Flir4wh+8ngB8ZpHo KJcxX8O/gMtOJlVXKhoPh8x3FLzVtIbRywknWvTzGmfmMzd1oe8+7CU8rlMWxHzRyxKcpzPNZ3 Ytc= X-SBRS: 5.1 X-MesageID: 36237570 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.79,387,1602561600"; d="scan'208";a="36237570" From: Andrew Cooper To: Xen-devel CC: =?UTF-8?q?Micha=C5=82=20Leszczy=C5=84ski?= , Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Tamas K Lengyel Subject: [PATCH v8 10/16] xen/memory: Add a vmtrace_buf resource type Date: Sat, 30 Jan 2021 02:58:46 +0000 Message-ID: <20210130025852.12430-11-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210130025852.12430-1-andrew.cooper3@citrix.com> References: <20210130025852.12430-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) From: Micha=C5=82 Leszczy=C5=84ski Allow to map processor trace buffer using acquire_resource(). Signed-off-by: Micha=C5=82 Leszczy=C5=84ski Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Micha=C5=82 Leszczy=C5=84ski CC: Tamas K Lengyel v8: * Rebase over 'fault' and ARM/IOREQ series. v7: * Rebase over changes elsewhere in the series --- xen/common/memory.c | 29 +++++++++++++++++++++++++++++ xen/include/public/memory.h | 1 + 2 files changed, 30 insertions(+) diff --git a/xen/common/memory.c b/xen/common/memory.c index 128718b31c..fada97a79f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1085,6 +1085,9 @@ static unsigned int resource_max_frames(const struct = domain *d, case XENMEM_resource_ioreq_server: return ioreq_server_max_frames(d); =20 + case XENMEM_resource_vmtrace_buf: + return d->vmtrace_size >> PAGE_SHIFT; + default: return -EOPNOTSUPP; } @@ -1125,6 +1128,29 @@ static int acquire_ioreq_server(struct domain *d, #endif } =20 +static int acquire_vmtrace_buf( + struct domain *d, unsigned int id, unsigned int frame, + unsigned int nr_frames, xen_pfn_t mfn_list[]) +{ + const struct vcpu *v =3D domain_vcpu(d, id); + unsigned int i; + mfn_t mfn; + + if ( !v ) + return -ENOENT; + + if ( !v->vmtrace.pg || + (frame + nr_frames) > (d->vmtrace_size >> PAGE_SHIFT) ) + return -EINVAL; + + mfn =3D page_to_mfn(v->vmtrace.pg); + + for ( i =3D 0; i < nr_frames; i++ ) + mfn_list[i] =3D mfn_x(mfn) + frame + i; + + return nr_frames; +} + /* * Returns -errno on error, or positive in the range [1, nr_frames] on * success. Returning less than nr_frames contitutes a request for a @@ -1142,6 +1168,9 @@ static int _acquire_resource( case XENMEM_resource_ioreq_server: return acquire_ioreq_server(d, id, frame, nr_frames, mfn_list); =20 + case XENMEM_resource_vmtrace_buf: + return acquire_vmtrace_buf(d, id, frame, nr_frames, mfn_list); + default: return -EOPNOTSUPP; } diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 020c79d757..50e73eef98 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -625,6 +625,7 @@ struct xen_mem_acquire_resource { =20 #define XENMEM_resource_ioreq_server 0 #define XENMEM_resource_grant_table 1 +#define XENMEM_resource_vmtrace_buf 2 =20 /* * IN - a type-specific resource identifier, which must be zero --=20 2.11.0