From nobody Tue Nov 11 15:42:15 2025 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1556658254; cv=none; d=zoho.com; s=zohoarc; b=TXaWOH6CiVoF9PwetEXOWqEOi70GoXyVSS0sIL9NMKnrIO0F1GdvsJzbu7VvG8LCIZ0oGXSZdWcM6foWSnzZhf0CTmHA1JQVPtuOlOxbcg2Yfb8PhsERgAUk9eKeqnn1wZpcfgZxxp9ztS/6cCdvhrOsd388WXJLltQ/H8sFKlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556658254; 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:ARC-Authentication-Results; bh=SMutVhPUwVc/SDNPn6pRxsvDeoyF25AAPT0KOqEpFMQ=; b=QGjb1If171UPCwbobZH/H9y3hBdRF55LnlpuAtLhteiEz+HAsTQfAdMZOx5x8Oqcs09PGif37rWWtvaCvUAINaLewXMAhKpNfbuEE43ypuj/QxnfFzFKsvIXetwXHwXDdrNsCSBeE8eKyJ91ilgX3diPZzq1t8w8cVY3hkYJGfs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1556658254852430.02823951379344; Tue, 30 Apr 2019 14:04:14 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hLZu0-0007gO-Bz; Tue, 30 Apr 2019 21:03:00 +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 1hLZtz-0007fA-40 for xen-devel@lists.xenproject.org; Tue, 30 Apr 2019 21:02:59 +0000 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5493ddf8-6b8b-11e9-864f-c3c12dfa35a3; Tue, 30 Apr 2019 21:02:57 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ED113217D4; Tue, 30 Apr 2019 21:02:56 +0000 (UTC) X-Inumbo-ID: 5493ddf8-6b8b-11e9-864f-c3c12dfa35a3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556658177; bh=/KzwmMHcUZr+ZQbrHigLZctPcmSGXv9IFLUWU57xvyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=olRoOH/AQOwS9u1+WbhXnyVa7DePykcS84+sV+HKX3SgMkGR3N5a/VM4VXSLbehuW jEVUkPPpueyl6CY7E5fM6uTdXKYfUQTI/gc7u835K+HgWH6RRWt4Fct257AN6VTj3V dpsofv4AqXoLDPMdx9EcjDIdfYmRA7DF2yQiz030= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 30 Apr 2019 14:02:47 -0700 Message-Id: <1556658172-8824-5-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v2 05/10] libxl/xl: add memory policy option to iomem 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Add a new memory policy option for the iomem parameter. Possible values are: - arm_devmem, device nGRE, the default on ARM - arm_memory, WB cachable memory - x86_uc: uncachable memory, the default on x86 Store the parameter in a new field in libxl_iomem_range. Pass the memory policy option to xc_domain_mem_map_policy. Signed-off-by: Stefano Stabellini CC: ian.jackson@eu.citrix.com CC: wei.liu2@citrix.com --- Changes in v2: - add #define LIBXL_HAVE_MEMORY_POLICY - ability to part the memory policy parameter even if gfn is not passed - 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 - rename memory to arm_memory and devmem to arm_devmem - expand the non-security support status to non device passthrough iomem configurations - rename iomem options - add x86 specific iomem option --- SUPPORT.md | 2 +- docs/man/xl.cfg.5.pod.in | 7 ++++++- tools/libxl/libxl.h | 5 +++++ tools/libxl/libxl_create.c | 21 +++++++++++++++++++-- tools/libxl/libxl_types.idl | 9 +++++++++ tools/xl/xl_parse.c | 22 +++++++++++++++++++++- 6 files changed, 61 insertions(+), 5 deletions(-) diff --git a/SUPPORT.md b/SUPPORT.md index e4fb15b..f29a299 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -649,7 +649,7 @@ to be used in addition to QEMU. =20 Status: Experimental =20 -### ARM/Non-PCI device passthrough +### ARM/Non-PCI device passthrough and other iomem configurations =20 Status: Supported, not security supported =20 diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index c7d70e6..c85857e 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1222,7 +1222,7 @@ is given in hexadecimal format and may either be a ra= nge, e.g. C<2f8-2ff> It is recommended to only use this option for trusted VMs under administrator's control. =20 -=3Ditem B +=3Ditem B =20 Allow auto-translated domains to access specific hardware I/O memory pages. =20 @@ -1233,6 +1233,11 @@ B is not specified, the mapping will be perform= ed using B as a start in the guest's address space, therefore performing a 1:1 mapping by default. All of these values must be given in hexadecimal format. +B for ARM platforms: + - "arm_devmem" for Device nGRE, the default on ARM + - "arm_memory" for Outer Shareable Write-Back Cacheable Memory +B can be for x86 platforms: + - "x86_uc" for Uncachable Memory, the default on x86 =20 Note that the IOMMU won't be updated with the mappings specified with this option. This option therefore should not be used to pass through any diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 482499a..2366331 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -379,6 +379,11 @@ #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1 =20 /* + * Support specifying memory policy information for memory mappings. + */ +#define LIBXL_HAVE_MEMORY_POLICY 1 + +/* * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fi= elds: * - unique_id; * - feature_disable_keyboard; diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 89fe80f..a6c5e30 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -415,6 +415,21 @@ static void init_console_info(libxl__gc *gc, Only 'channels' when mapped to consoles have a string name. */ } =20 +static uint32_t libxl__memory_policy_to_xc(libxl_memory_policy c) +{ + switch (c) { + case LIBXL_MEMORY_POLICY_ARM_MEM_WB: + return MEMORY_POLICY_ARM_MEM_WB; + case LIBXL_MEMORY_POLICY_ARM_DEV_NGRE: + return MEMORY_POLICY_ARM_DEV_nGRE; + case LIBXL_MEMORY_POLICY_X86_UC: + return MEMORY_POLICY_X86_UC; + case LIBXL_MEMORY_POLICY_DEFAULT: + default: + return MEMORY_POLICY_DEFAULT; + } +} + int libxl__domain_build(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid, @@ -1369,9 +1384,11 @@ static void domcreate_launch_dm(libxl__egc *egc, lib= xl__multidev *multidev, ret =3D ERROR_FAIL; goto error_out; } - ret =3D xc_domain_memory_mapping(CTX->xch, domid, + ret =3D xc_domain_mem_map_policy(CTX->xch, domid, io->gfn, io->start, - io->number, 1); + io->number, 1, + libxl__memory_policy_to_xc( + io->memory_policy)); if (ret < 0) { LOGED(ERROR, domid, "failed to map to domain iomem range %"PRIx64"-%"PRIx64 diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index cb4702f..4db8a62 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -272,6 +272,13 @@ libxl_ioport_range =3D Struct("ioport_range", [ ("number", uint32), ]) =20 +libxl_memory_policy =3D Enumeration("memory_policy", [ + (0, "default"), + (1, "ARM_Dev_nGRE"), + (2, "ARM_Mem_WB"), + (3, "x86_UC"), + ], init_val =3D "LIBXL_MEMORY_POLICY_DEFAULT") + libxl_iomem_range =3D Struct("iomem_range", [ # start host frame number to be mapped to the guest ("start", uint64), @@ -279,6 +286,8 @@ libxl_iomem_range =3D Struct("iomem_range", [ ("number", uint64), # guest frame number used as a start for the mapping ("gfn", uint64, {'init_val': "LIBXL_INVALID_GFN"}), + # memory_policy of the memory region + ("memory_policy", libxl_memory_policy), ]) =20 libxl_vga_interface_info =3D Struct("vga_interface_info", [ diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 352cd21..ed56931 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1883,6 +1883,7 @@ void parse_config_data(const char *config_source, } for (i =3D 0; i < num_iomem; i++) { int used; + const char *mempolicy; =20 buf =3D xlu_cfg_get_listitem (iomem, i); if (!buf) { @@ -1895,11 +1896,30 @@ void parse_config_data(const char *config_source, &b_info->iomem[i].start, &b_info->iomem[i].number, &used, &b_info->iomem[i].gfn, &used); - if (ret < 2 || buf[used] !=3D '\0') { + if (ret < 2) { fprintf(stderr, "xl: Invalid argument parsing iomem: %s\n", buf); exit(1); } + mempolicy =3D &buf[used]; + if (strlen(mempolicy) > 1) { + mempolicy++; + if (!strcmp(mempolicy, "arm_devmem")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_ARM_DEV_NGRE; + else if (!strcmp(mempolicy, "x86_uc")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_X86_UC; + else if (!strcmp(mempolicy, "arm_memory")) + b_info->iomem[i].memory_policy =3D + LIBXL_MEMORY_POLICY_ARM_MEM_WB; + else { + fprintf(stderr, + "xl: Invalid iomem memory policy parameter: %s= \n", + mempolicy); + exit(1); + } + } } } =20 --=20 1.9.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel