From patchwork Wed Aug 7 00:23:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11079729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5491A17E0 for ; Wed, 7 Aug 2019 00:25:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42E3628837 for ; Wed, 7 Aug 2019 00:25:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 378A22883B; Wed, 7 Aug 2019 00:25:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C448D2883F for ; Wed, 7 Aug 2019 00:25:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hv9jZ-0004fb-Ev; Wed, 07 Aug 2019 00:23:17 +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.89) (envelope-from ) id 1hv9jX-0004eP-Qd for xen-devel@lists.xenproject.org; Wed, 07 Aug 2019 00:23:15 +0000 X-Inumbo-ID: 8b8ae1c4-b8a9-11e9-aefc-7bf671acb327 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8b8ae1c4-b8a9-11e9-aefc-7bf671acb327; Wed, 07 Aug 2019 00:23:14 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C65E217D9; Wed, 7 Aug 2019 00:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565137393; bh=5eP0DKuxjfEdCn97uh85DOCUFSUK8uBbkDIIzaLhY08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BLk9XRYkkjlY9YxkYDDeLLT+Z0tPXF42P3z830Up6uyGzG3CIYzXaeK7BdHRXu2Qh rASRX1orE+0AQoVByORaAKDz4KpNPTyyUs7aegRrnTJDv1PhvrGh3VmGHlYOkJEq+0 9Saiu9NDafH+f8XcigfkWBZP8UfhxQX1ISaVICXw= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 6 Aug 2019 17:23:09 -0700 Message-Id: <20190807002311.9906-4-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v4 4/6] libxc: introduce xc_domain_mem_map_policy X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , julien.grall@arm.com, sstabellini@kernel.org, ian.jackson@eu.citrix.com, wei.liu2@citrix.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Introduce a new libxc function that makes use of the new memory_policy parameter added to the XEN_DOMCTL_memory_mapping hypercall. The parameter values are the same for the XEN_DOMCTL_memory_mapping hypercall (0 is MEMORY_POLICY_DEFAULT). Pass MEMORY_POLICY_DEFAULT by default -- no changes in behavior. We could extend xc_domain_memory_mapping, but QEMU makes use of it, so it is easier and less disruptive to introduce a new libxc function and change the implementation of xc_domain_memory_mapping to call into it. Signed-off-by: Stefano Stabellini CC: ian.jackson@eu.citrix.com CC: wei.liu2@citrix.com --- Changes in v2: - rename cache_policy to memory policy - rename MEMORY_POLICY_DEVMEM to MEMORY_POLICY_ARM_DEV_nGRE - rename MEMORY_POLICY_MEMORY to MEMORY_POLICY_ARM_MEM_WB - introduce xc_domain_mem_map_policy --- tools/libxc/include/xenctrl.h | 8 ++++++++ tools/libxc/xc_domain.c | 25 ++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 0ff6ed9e70..2396929960 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1714,6 +1714,14 @@ int xc_deassign_dt_device(xc_interface *xch, uint32_t domid, char *path); +int xc_domain_mem_map_policy(xc_interface *xch, + uint32_t domid, + unsigned long first_gfn, + unsigned long first_mfn, + unsigned long nr_mfns, + uint32_t add_mapping, + uint32_t memory_policy); + int xc_domain_memory_mapping(xc_interface *xch, uint32_t domid, unsigned long first_gfn, diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 075ffb9ed1..02f5778212 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -2042,13 +2042,14 @@ failed: return -1; } -int xc_domain_memory_mapping( +int xc_domain_mem_map_policy( xc_interface *xch, uint32_t domid, unsigned long first_gfn, unsigned long first_mfn, unsigned long nr_mfns, - uint32_t add_mapping) + uint32_t add_mapping, + uint32_t memory_policy) { DECLARE_DOMCTL; xc_dominfo_t info; @@ -2070,7 +2071,7 @@ int xc_domain_memory_mapping( domctl.cmd = XEN_DOMCTL_memory_mapping; domctl.domain = domid; domctl.u.memory_mapping.add_mapping = add_mapping; - domctl.u.memory_mapping.memory_policy = MEMORY_POLICY_DEFAULT; + domctl.u.memory_mapping.memory_policy = memory_policy; max_batch_sz = nr_mfns; do { @@ -2106,8 +2107,9 @@ int xc_domain_memory_mapping( * Errors here are ignored. */ if ( ret && add_mapping != DPCI_REMOVE_MAPPING ) - xc_domain_memory_mapping(xch, domid, first_gfn, first_mfn, nr_mfns, - DPCI_REMOVE_MAPPING); + xc_domain_mem_map_policy(xch, domid, first_gfn, first_mfn, nr_mfns, + DPCI_REMOVE_MAPPING, + MEMORY_POLICY_DEFAULT); /* We might get E2BIG so many times that we never advance. */ if ( !done && !ret ) @@ -2116,6 +2118,19 @@ int xc_domain_memory_mapping( return ret; } +int xc_domain_memory_mapping( + xc_interface *xch, + uint32_t domid, + unsigned long first_gfn, + unsigned long first_mfn, + unsigned long nr_mfns, + uint32_t add_mapping) +{ + return xc_domain_mem_map_policy(xch, domid, first_gfn, first_mfn, + nr_mfns, add_mapping, + MEMORY_POLICY_DEFAULT); +} + int xc_domain_ioport_mapping( xc_interface *xch, uint32_t domid,