From patchwork Tue Jul 7 19:39:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Leszczy=C5=84ski?= X-Patchwork-Id: 11649921 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 7B09814B7 for ; Tue, 7 Jul 2020 19:41:38 +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 6137F206BE for ; Tue, 7 Jul 2020 19:41:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6137F206BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cert.pl 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 1jstSj-0007oG-Ja; Tue, 07 Jul 2020 19:41:05 +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 1jstSj-0007no-23 for xen-devel@lists.xenproject.org; Tue, 07 Jul 2020 19:41:05 +0000 X-Inumbo-ID: c98e3e7e-c089-11ea-8de3-12813bfff9fa Received: from bagnar.nask.net.pl (unknown [195.187.242.196]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c98e3e7e-c089-11ea-8de3-12813bfff9fa; Tue, 07 Jul 2020 19:41:02 +0000 (UTC) Received: from bagnar.nask.net.pl (unknown [172.16.9.10]) by bagnar.nask.net.pl (Postfix) with ESMTP id E789EA26AF; Tue, 7 Jul 2020 21:41:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id E4FA5A2675; Tue, 7 Jul 2020 21:40:59 +0200 (CEST) X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tpwVciS3kWfD; Tue, 7 Jul 2020 21:40:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by bagnar.nask.net.pl (Postfix) with ESMTP id 79919A26A3; Tue, 7 Jul 2020 21:40:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at bagnar.nask.net.pl X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from bagnar.nask.net.pl ([127.0.0.1]) by localhost (bagnar.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id R9EPWexH40j8; Tue, 7 Jul 2020 21:40:59 +0200 (CEST) Received: from belindir.nask.net.pl (belindir-ext.nask.net.pl [195.187.242.210]) by bagnar.nask.net.pl (Postfix) with ESMTP id 4FFA3A261F; Tue, 7 Jul 2020 21:40:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id BEE562247F; Tue, 7 Jul 2020 21:40:04 +0200 (CEST) X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id fYEdaYTL948b; Tue, 7 Jul 2020 21:39:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by belindir.nask.net.pl (Postfix) with ESMTP id 0B00922456; Tue, 7 Jul 2020 21:39:54 +0200 (CEST) X-Quarantine-ID: X-Virus-Scanned: amavisd-new at belindir.nask.net.pl X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from belindir.nask.net.pl ([127.0.0.1]) by localhost (belindir.nask.net.pl [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hw4v3GfJxCBR; Tue, 7 Jul 2020 21:39:53 +0200 (CEST) Received: from mq-desktop.cert.pl (unknown [195.187.238.217]) by belindir.nask.net.pl (Postfix) with ESMTPSA id CD26022303; Tue, 7 Jul 2020 21:39:53 +0200 (CEST) From: =?utf-8?q?Micha=C5=82_Leszczy=C5=84ski?= To: xen-devel@lists.xenproject.org Subject: [PATCH v6 08/11] x86/mm: add vmtrace_buf resource type Date: Tue, 7 Jul 2020 21:39:47 +0200 Message-Id: <2129d21e7ef7e960951a8baafab01d9392dff8f3.1594150543.git.michal.leszczynski@cert.pl> X-Mailer: git-send-email 2.17.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: , Cc: Julien Grall , Stefano Stabellini , luwei.kang@intel.com, Wei Liu , Andrew Cooper , Michal Leszczynski , Ian Jackson , George Dunlap , Jan Beulich , tamas.lengyel@intel.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Michal Leszczynski Allow to map processor trace buffer using acquire_resource(). Signed-off-by: Michal Leszczynski --- xen/common/memory.c | 31 +++++++++++++++++++++++++++++++ xen/include/public/memory.h | 1 + 2 files changed, 32 insertions(+) diff --git a/xen/common/memory.c b/xen/common/memory.c index eb42f883df..c0a22eb60f 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -1007,6 +1007,32 @@ static long xatp_permission_check(struct domain *d, unsigned int space) return xsm_add_to_physmap(XSM_TARGET, current->domain, d); } +static int acquire_vmtrace_buf(struct domain *d, unsigned int id, + uint64_t frame, + uint64_t nr_frames, + xen_pfn_t mfn_list[]) +{ + mfn_t mfn; + unsigned int i; + uint64_t size; + struct vcpu *v = domain_vcpu(d, id); + + if ( !v || !v->vmtrace.pt_buf ) + return -EINVAL; + + mfn = page_to_mfn(v->vmtrace.pt_buf); + size = v->domain->processor_trace_buf_kb * KB(1); + + if ( (frame > (size >> PAGE_SHIFT)) || + (nr_frames > ((size >> PAGE_SHIFT) - frame)) ) + return -EINVAL; + + for ( i = 0; i < nr_frames; i++ ) + mfn_list[i] = mfn_x(mfn_add(mfn, frame + i)); + + return 0; +} + static int acquire_grant_table(struct domain *d, unsigned int id, unsigned long frame, unsigned int nr_frames, @@ -1117,6 +1143,11 @@ static int acquire_resource( mfn_list); break; + case XENMEM_resource_vmtrace_buf: + rc = acquire_vmtrace_buf(d, xmar.id, xmar.frame, xmar.nr_frames, + mfn_list); + break; + default: rc = arch_acquire_resource(d, xmar.type, xmar.id, xmar.frame, xmar.nr_frames, mfn_list); diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h index 21057ed78e..f4c905a10e 100644 --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -625,6 +625,7 @@ struct xen_mem_acquire_resource { #define XENMEM_resource_ioreq_server 0 #define XENMEM_resource_grant_table 1 +#define XENMEM_resource_vmtrace_buf 2 /* * IN - a type-specific resource identifier, which must be zero