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 <stefanos@xilinx.com>
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
Status: Experimental
-### ARM/Non-PCI device passthrough
+### ARM/Non-PCI device passthrough and other iomem configurations
Status: Supported, not security supported
It is recommended to only use this option for trusted VMs under
administrator's control.
-=item B<iomem=[ "IOMEM_START,NUM_PAGES[@GFN]", "IOMEM_START,NUM_PAGES[@GFN]", ...]>
+=item B<iomem=[ "IOMEM_START,NUM_PAGES[@GFN],MEMORY_POLICY", "IOMEM_START,NUM_PAGES[@GFN][,MEMORY_POLICY]", ...]>
Allow auto-translated domains to access specific hardware I/O memory pages.
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<MEMORY_POLICY> for ARM platforms:
+ - "arm_devmem" for Device nGRE, the default on ARM
+ - "arm_memory" for Outer Shareable Write-Back Cacheable Memory
+B<MEMORY_POLICY> can be for x86 platforms:
+ - "x86_uc" for Uncachable Memory, the default on x86
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
#define LIBXL_HAVE_BUILDINFO_BOOTLOADER 1
#define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
+/*
+ * 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 fields:
* - unique_id;
Only 'channels' when mapped to consoles have a string name. */
}
+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,
ret = ERROR_FAIL;
goto error_out;
}
- ret = xc_domain_memory_mapping(CTX->xch, domid,
+ ret = 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
("number", uint32),
])
+libxl_memory_policy = Enumeration("memory_policy", [
+ (0, "default"),
+ (1, "ARM_Dev_nGRE"),
+ (2, "ARM_Mem_WB"),
+ (3, "x86_UC"),
+ ], init_val = "LIBXL_MEMORY_POLICY_DEFAULT")
+
libxl_iomem_range = Struct("iomem_range", [
# start host frame number to be mapped to the guest
("start", uint64),
("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),
])
libxl_vga_interface_info = Struct("vga_interface_info", [
}
for (i = 0; i < num_iomem; i++) {
int used;
+ const char *mempolicy;
buf = xlu_cfg_get_listitem (iomem, i);
if (!buf) {
&b_info->iomem[i].start,
&b_info->iomem[i].number, &used,
&b_info->iomem[i].gfn, &used);
- if (ret < 2 || buf[used] != '\0') {
+ if (ret < 2) {
fprintf(stderr,
"xl: Invalid argument parsing iomem: %s\n", buf);
exit(1);
}
+ mempolicy = &buf[used];
+ if (strlen(mempolicy) > 1) {
+ mempolicy++;
+ if (!strcmp(mempolicy, "arm_devmem"))
+ b_info->iomem[i].memory_policy =
+ LIBXL_MEMORY_POLICY_ARM_DEV_NGRE;
+ else if (!strcmp(mempolicy, "x86_uc"))
+ b_info->iomem[i].memory_policy =
+ LIBXL_MEMORY_POLICY_X86_UC;
+ else if (!strcmp(mempolicy, "arm_memory"))
+ b_info->iomem[i].memory_policy =
+ LIBXL_MEMORY_POLICY_ARM_MEM_WB;
+ else {
+ fprintf(stderr,
+ "xl: Invalid iomem memory policy parameter: %s\n",
+ mempolicy);
+ exit(1);
+ }
+ }
}
}