From nobody Mon Feb 9 19:06:18 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=1611264485; cv=none; d=zohomail.com; s=zohoarc; b=gjGpWvUAYQAVn/ECRcFjLtocrPLGfaNHZ0yJgX1zSztTCkh5N/HIam2FDshyIc/c+B65JncGm1T23DD/FxPqTX0oDeetm7COOkqn9Rf+GMgeiVmT86i2qPzKRrOazD/7ZcvElRxQ/T0w+/JXkpdcFdlgN+Z0ibmutI5N7FEvXdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611264485; 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=gH4865WyS2hCcrLYVN7vEX2aCUCPiRk410z7xr7MffE=; b=mUKX/1aegbNR96tt2Ul4upzozZUZoXUvpb2bFUv93e0h/GrTwl/EuG9K6uibiNkal+RRZKMZupkcc7IGglAVKm2f1OBcUAE3mmncw/qGjbfVXfuK0Ta7KjV6g7LSaRMzQsnAa0p+v4W4RLjabi6+CIkpt/Jog9lKQFZ2xbI+920= 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 1611264485111504.83262758818137; Thu, 21 Jan 2021 13:28:05 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.72426.130424 (Exim 4.92) (envelope-from ) id 1l2hUc-0005B8-O8; Thu, 21 Jan 2021 21:27:50 +0000 Received: by outflank-mailman (output) from mailman id 72426.130424; Thu, 21 Jan 2021 21:27:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l2hUc-0005Av-Ip; Thu, 21 Jan 2021 21:27:50 +0000 Received: by outflank-mailman (input) for mailman id 72426; Thu, 21 Jan 2021 21:27:49 +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 1l2hUb-0004xj-DS for xen-devel@lists.xenproject.org; Thu, 21 Jan 2021 21:27:49 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 16cfb996-d4fd-4070-967c-4b157110cdd2; Thu, 21 Jan 2021 21:27:39 +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: 16cfb996-d4fd-4070-967c-4b157110cdd2 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1611264459; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r2BwqWd7NQ1mzdR8kM1P36wwz2HedhnLfyw+QNKXGLk=; b=TT+KlL9d549HqmUOYL54KqyoreABqNFyTQ0xkEXO8Zhi381f23Dz8WH8 4XHTBqtDvypKFV9ZCILd5vsnRS/BdgFLwiogNhzFCBM2q+Rbdwjxbcj+q UqF31vb0LApI0fXXtxCrYsxlKMquN0wAOVsGvb6uaE5XVyUlPaIp6iJeP g=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: rgTHx5nwswuWivY0m9MruSK+ZqPzFzwki2x7fihnbWKj1XiBOOjkjfF/9PaRER3ClVBodvFDKw H2Yi8JNq5TGHeGeANl2hIzHIirx+cox+DoLIoC+OM4ofK6s7AlA6RHNiP0tFjXNG98DuI8YQQx nTcm4Ck0AJPV3MThKebFhsnz9aYcNTRMHYqcPXBIAg9HHN2rWbWFfNgP/9Ow54QFbeGFy/czpR e8BnR2XXlYOc8TDGRWpvYl9sebMArpiHAB36ggFYIVfDw0VO1rNP77Qt//XPeRaNKf9o6+u3VG Ey0= X-SBRS: 5.1 X-MesageID: 35815974 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.79,365,1602561600"; d="scan'208";a="35815974" 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 v7 04/10] xen/memory: Add a vmtrace_buf resource type Date: Thu, 21 Jan 2021 21:27:12 +0000 Message-ID: <20210121212718.2441-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20210121212718.2441-1-andrew.cooper3@citrix.com> References: <20210121212718.2441-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 v7: * Rebase over changes elsewhere in the series --- xen/common/memory.c | 27 +++++++++++++++++++++++++++ xen/include/public/memory.h | 1 + 2 files changed, 28 insertions(+) diff --git a/xen/common/memory.c b/xen/common/memory.c index c89923d909..ec6a55172a 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1068,11 +1068,35 @@ static unsigned int resource_max_frames(const struc= t domain *d, case XENMEM_resource_grant_table: return gnttab_resource_max_frames(d, id); =20 + case XENMEM_resource_vmtrace_buf: + return d->vmtrace_frames; + default: return arch_resource_max_frames(d, type, id); } } =20 +static int acquire_vmtrace_buf( + struct domain *d, unsigned int id, unsigned long 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 || !v->vmtrace.buf || + nr_frames > d->vmtrace_frames || + (frame + nr_frames) > d->vmtrace_frames ) + return -EINVAL; + + mfn =3D page_to_mfn(v->vmtrace.buf); + + 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 @@ -1087,6 +1111,9 @@ static int _acquire_resource( case XENMEM_resource_grant_table: return gnttab_acquire_resource(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 arch_acquire_resource(d, type, id, frame, nr_frames, mfn_li= st); } diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index c4c47a0b38..b0378bb14b 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