mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen: introduce CDF_directmap
This commit introduces a new arm-specific flag CDF_directmap to specify that a domain should have its memory direct-map(guest physical address == host physical address) at domain creation. Also, add a directmap flag under struct arch_domain and use it to reimplement is_domain_direct_mapped. For now, direct-map is only available when statically allocated memory is used for the domain, that is, "xen,static-mem" must be also defined in the domain configuration. Signed-off-by: Stefano Stabellini <sstabellini@kernel.org> Signed-off-by: Penny Zheng <penny.zheng@arm.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Julien Grall <jgrall@amazon.com> Tested-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
6f815e86ef
commit
80e2005373
7 files changed
+34
-8
No files matched your search
@@ -182,6 +182,12 @@ with the following properties:
|
||||
Both #address-cells and #size-cells need to be specified because
|
||||
both sub-nodes (described shortly) have reg properties.
|
||||
|
||||
- direct-map
|
||||
|
||||
Only available when statically allocated memory is used for the domain.
|
||||
An empty property to request the memory of the domain to be
|
||||
direct-map (guest physical address == physical address).
|
||||
|
||||
Under the "xen,domain" compatible node, one or more sub-nodes are present
|
||||
for the DomU kernel and ramdisk.
|
||||
|
||||
|
||||
@@ -692,7 +692,8 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
|
||||
}
|
||||
|
||||
int arch_domain_create(struct domain *d,
|
||||
struct xen_domctl_createdomain *config)
|
||||
struct xen_domctl_createdomain *config,
|
||||
unsigned int flags)
|
||||
{
|
||||
int rc, count = 0;
|
||||
|
||||
@@ -708,6 +709,8 @@ int arch_domain_create(struct domain *d,
|
||||
ioreq_domain_init(d);
|
||||
#endif
|
||||
|
||||
d->arch.directmap = flags & CDF_directmap;
|
||||
|
||||
/* p2m_init relies on some value initialized by the IOMMU subsystem */
|
||||
if ( (rc = iommu_domain_init(d, config->iommu_opts)) != 0 )
|
||||
goto fail;
|
||||
|
||||
@@ -3029,10 +3029,20 @@ void __init create_domUs(void)
|
||||
.max_maptrack_frames = -1,
|
||||
.grant_opts = XEN_DOMCTL_GRANT_version(opt_gnttab_max_version),
|
||||
};
|
||||
unsigned int flags = 0U;
|
||||
|
||||
if ( !dt_device_is_compatible(node, "xen,domain") )
|
||||
continue;
|
||||
|
||||
if ( dt_property_read_bool(node, "direct-map") )
|
||||
{
|
||||
if ( !IS_ENABLED(CONFIG_STATIC_MEMORY) || !dt_find_property(node, "xen,static-mem", NULL) )
|
||||
panic("direct-map is not valid for domain %s without static allocation.\n",
|
||||
dt_node_name(node));
|
||||
|
||||
flags |= CDF_directmap;
|
||||
}
|
||||
|
||||
if ( !dt_property_read_u32(node, "cpus", &d_cfg.max_vcpus) )
|
||||
panic("Missing property 'cpus' for domain %s\n",
|
||||
dt_node_name(node));
|
||||
@@ -3058,7 +3068,7 @@ void __init create_domUs(void)
|
||||
* very important to use the pre-increment operator to call
|
||||
* domain_create() with a domid > 0. (domid == 0 is reserved for Dom0)
|
||||
*/
|
||||
d = domain_create(++max_init_domid, &d_cfg, 0);
|
||||
d = domain_create(++max_init_domid, &d_cfg, flags);
|
||||
if ( IS_ERR(d) )
|
||||
panic("Error creating domain %s\n", dt_node_name(node));
|
||||
|
||||
@@ -3160,7 +3170,7 @@ void __init create_dom0(void)
|
||||
if ( iommu_enabled )
|
||||
dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;
|
||||
|
||||
dom0 = domain_create(0, &dom0_cfg, CDF_privileged);
|
||||
dom0 = domain_create(0, &dom0_cfg, CDF_privileged | CDF_directmap);
|
||||
if ( IS_ERR(dom0) || (alloc_dom0_vcpu0(dom0) == NULL) )
|
||||
panic("Error creating domain 0\n");
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ enum domain_type {
|
||||
#define is_64bit_domain(d) (0)
|
||||
#endif
|
||||
|
||||
/* The hardware domain has always its memory direct mapped. */
|
||||
#define is_domain_direct_mapped(d) is_hardware_domain(d)
|
||||
#define is_domain_direct_mapped(d) (d)->arch.directmap
|
||||
|
||||
struct vtimer {
|
||||
struct vcpu *v;
|
||||
@@ -89,6 +88,8 @@ struct arch_domain
|
||||
#ifdef CONFIG_TEE
|
||||
void *tee;
|
||||
#endif
|
||||
|
||||
bool directmap;
|
||||
} __cacheline_aligned;
|
||||
|
||||
struct arch_vcpu
|
||||
|
||||
@@ -722,7 +722,8 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
|
||||
}
|
||||
|
||||
int arch_domain_create(struct domain *d,
|
||||
struct xen_domctl_createdomain *config)
|
||||
struct xen_domctl_createdomain *config,
|
||||
unsigned int flags)
|
||||
{
|
||||
bool paging_initialised = false;
|
||||
uint32_t emflags;
|
||||
|
||||
+1
-1
@@ -659,7 +659,7 @@ struct domain *domain_create(domid_t domid,
|
||||
radix_tree_init(&d->pirq_tree);
|
||||
}
|
||||
|
||||
if ( (err = arch_domain_create(d, config)) != 0 )
|
||||
if ( (err = arch_domain_create(d, config, flags)) != 0 )
|
||||
goto fail;
|
||||
init_status |= INIT_arch;
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ void arch_get_domain_info(const struct domain *d,
|
||||
/* CDF_* constant. Internal flags for domain creation. */
|
||||
/* Is this a privileged domain? */
|
||||
#define CDF_privileged (1U << 0)
|
||||
#ifdef CONFIG_ARM
|
||||
/* Should domain memory be directly mapped? */
|
||||
#define CDF_directmap (1U << 1)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Arch-specifics.
|
||||
@@ -65,7 +69,8 @@ int map_vcpu_info(struct vcpu *v, unsigned long gfn, unsigned offset);
|
||||
void unmap_vcpu_info(struct vcpu *v);
|
||||
|
||||
int arch_domain_create(struct domain *d,
|
||||
struct xen_domctl_createdomain *config);
|
||||
struct xen_domctl_createdomain *config,
|
||||
unsigned int flags);
|
||||
|
||||
void arch_domain_destroy(struct domain *d);
|
||||
|
||||
|
||||