Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #1 from xen-project/staging #5

Open
wants to merge 9 commits into
base: staging
Choose a base branch
from
Open
257 changes: 257 additions & 0 deletions docs/man/xl-static-shm-configuration.pod.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
=head1 NAME

xl-static-shm-configuration - XL Static Shared Memeory Configuration Syntax


(B<NOTE>: This is currently only available to ARM guests.)

=head1 DESCRIPTION

The static_shm option allows users to statically setup shared memory regions
among a group of VMs, enabling guests without grant table support to do
shm-based communication.

Every shared region is:

=over 4

* Uniquely identified by a string that is no longer than 128 characters, which
is called an B<identifier> in this document.

* Backed by exactely one domain, which is called a B<master> domain, and all
the other domains who are also sharing this region are called B<slave>s.

=back

=head1 SYNTAX

This document specifies syntax of the static shared memory configuration in
the xl config file. It has the following form:

static_shm = [ "SSHM_SPEC", "SSHM_SPEC", ... ]

where each C<SSHM_SPEC> is in this form:

[<key>=<value>,]*

Valid examples of C<SSHM_SPEC> are:

id=ID1, begin=0x100000, end=0x200000, role=master, cache_policy=x86_normal
id=ID1, offset = 0, begin=0x500000, end=0x600000, role=slave, prot=rw
id=ID2, begin=0x300000, end=0x400000, role=master
id=ID2, offset = 0x10000, begin=0x690000, end=0x800000, role=slave
id=ID2, offset = 0x10000, begin=0x690000, end=0x800000, role=slave

These might be specified in the domain config file like this:

static_shm = ["id=ID2, offset = 0x10000, begin=0x690000, end=0x800000,
role=slave"]


More formally, the string is a series of comma-separated keyword/value
pairs. Each parameter may be specified at most once. Default values apply if
the parameter is not specified.

=head1 Parameters

=over 4

=item B<id>

=over 4

=item Description

The unique identifier of the shared memory region.

Every identifier could appear only once in each xl config file.

=item Supported values

A string that contains alphanumerics and "_"s, and is no longer than 128
characters.

=item Default value

None, this parameter is mandatory.

=back

=item B<begin>/B<end>

=over 4

=item Description

The boundaries of the shared memory area.

=item Supported values

Same with B<offset>.

=item Default Value

None, this parameter is mandatory.

=back

=item B<offset>

=over 4

=item Description

Can only appear when B<role> = slave. If set, the address mapping will not
start from the beginning the backing memory region, but from the middle
(B<offet> bytes away from the beginning) of it. See the graph below:

With B<offset> = 0, the mapping will look like:

backing memory region: #########################################
| |
| |
| |
V V
slave's shared region: #########################

With B<offset> > 0:

backing memory region: #########################################
|<-- offset -->|| |
| |
| |
V V
slave's memory region: #########################

=item Supported values

Decimals or hexadecimals with a prefix "0x", and should be the multiple of the
hypervisor page granularity (currently 4K on both ARM and x86).

=item Default value

0x0

=back

=item B<role>

=over 4

=item Description

The backing area would be taken from one domain, which we will mark
as the "master domain", and this domain should be created prior to any
other slave domains that depend on it.

This arugment specifies the role of this domain.

=item Supported values

master, slave

=item Default value

slave

=back

=item B<prot>

=over 4

=item Description

When B<role> = master, this means the largest set of stage-2 permission flags
that can be granted to the slave domains. When B<role> = slave, this means the
stage-2 permission flags of the shared memory area.

=item Supported values

Currently only 'rw' is supported.

=item Default value

rw

=back

=item B<cache_policy>

=over 4

=item Description

The stage-2 cacheability/shareability attributes of the shared memory area.
This can only appear when B<role> = master.

=item Supported values

Currently, only the following policy is supported:

=over 4

=item B<ARM_normal>

Only applicable to ARM guests. This would mean Inner and Outer Write-Back
Cacheable, and Inner Shareable.

=back

=item Default value

ARM_normal

=back

=back

=head1 TYPICAL USAGE

A typical procedure of setting up a shared mem region among several VMs is:

=over 4

1. Add a static_shm option to the master domain's xl config file, assign an
B<ID> to it and mark it's B<role> as master, and set up the boundaries, prot
flag, and B<cache_policy> appropriately.

2. Add a static_shm option to every slave domain's xl config file, set
their B<ID> to the same value as the master's, and set up the B<offset>,
boundaries and prot flag appropriately.

3. Create the master domain.

4. Create the slaves.

=back

Remember that the master domain must be created before any slave domains could
be created, for the slaves depend on the memory pages backed by their master.

=head1 Example

Suppose that we have 3 domains: vm1~vm3. And we want to setup two shared
regions, say, ID1 and ID2, among the three domains, with the following address
mapping:

ID1: (vm1 : 0x100000~0x200000) <=====> (vm2 : 0x500000~0x600000)
ID2: (vm1 : 0x310000~0x400000) <=====> (vm3 : 0x690000~0x800000)

According to the syntax defined above, the xl config files of the three domains
should contains the following content:

In xl config file of vm1:
static_shm = [ "id=ID1, begin=0x100000, end=0x200000, role=master,
cache_policy=x86_normal, prot=rw",
"id=ID2, begin=0x300000, end=0x400000, role=master" ]

In xl config file of vm2:
static_shm = [ "id=ID1, offset=0, begin=0x500000, end=0x600000,
role=slave, prot=rw" ]

In xl config file of vm3:
static_shm = [ "id=ID2, offset=0x10000, begin=0x690000,
end=0x800000, role=slave" ]

After that, just create vm1 first, and then create vm2 and vm3 in any order.
8 changes: 8 additions & 0 deletions docs/man/xl.cfg.pod.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,14 @@ memory=8096 will report significantly less memory available for use
than a system with maxmem=8096 memory=8096 due to the memory overhead
of having to track the unused pages.

=item B<static_shm=[ "SSHM_SPEC", "SSHM_SPEC", ... ]>

Specifies the static shared memory regions of this guest. Static shared
memory regions enables guests to communicate with each other through
one or more shared memory regions, even without grant table support.
Currently, this only works on ARM guests.
See L<xl-static-shm-configuration(5)> for more details.

=back

=head3 Guest Virtual NUMA Configuration
Expand Down
47 changes: 47 additions & 0 deletions docs/misc/xenstore-paths.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ than this amount of RAM.

The size of the video RAM this domain is configured with.

#### ~/static_shm/[_a-zA-Z0-9]+/role = ("master"|"slave") []

(Note: Currently, this will only appear on ARM guests.)

The role of this domain in the static shared memory region whose id matches
the `[_a-zA-Z0-9]+` part in the path. (Described in the manpage
**xl-static-shm-configuration(5)**).

#### ~/device/suspend/event-channel = ""|EVTCHN [w]

The domain's suspend event channel. The toolstack will create this
Expand Down Expand Up @@ -610,6 +618,45 @@ for the toolstack to obtain e.g. the domain id of a xenstore domain.
Domain Id of the xenstore domain in case xenstore is provided via a
domain instead of a daemon in dom0.

#### /local/static_shm/[_a-zA-Z0-9]+/* []

(Note: Currently, this will only appear on ARM guests.)

The following paths contain backing memory parameters of a static shared memory
whose id matches the `[_a-zA-Z0-9]+` part in the path. Their formats and
meanings are the same as those in an xl config file, described in the manpage
**xl-static-shm-configuration(5)**.

* begin/end: the boundary of the backing memory region.
* prot: the largest set of stage-2 permission flags that can be granted to
the slave domains.
* cache_policy: the stage-2 cacheability/shareability attributes of the backing
memory region.

The following paths contain run-time information about the static shared memory
region.

* master: the domid of the backing domain.
* slaves: information about the slaves that are sharing the region, see
** /local/static_shm/[_a-zA-Z0-9]+/slaves/$DOMID/* ** below.
* users: An integer. This is the reference count of the backing memory region,
including the master domain itself. When this value reachies 0, the backing
memory region will be freed.

#### /local/staitc_shm/[_a-zA-Z0-9]+/slaves/$DOMID/* []

(Note: Currently, this will only appear on ARM guests.)

The following paths contain static shared memory region parameters of a slave
domain. Their formats and meanings are the same as those in xl config files,
described in the manpage **xl-static-shm-configuration(5)**.

* begin/end: the boundary of the shared memory region.
* prot: the stage-2 permission flags of the shared memory area.
* offset: when mapping the backing memory region to the slave's memory space,
the mapping will start from offset bytes after the beginning of the backing
memory region.

[BLKIF]: http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,io,blkif.h.html
[FBIF]: http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,io,fbif.h.html
[HVMPARAMS]: http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,hvm,params.h.html
Expand Down
2 changes: 2 additions & 0 deletions tools/flask/policy/modules/xen.if
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ define(`domain_comms', `
domain_event_comms($1, $2)
allow $1 $2:grant { map_read map_write copy unmap };
allow $2 $1:grant { map_read map_write copy unmap };
allow $1 $2:mmu share_mem;
allow $2 $1:mmu share_mem;
')

# domain_self_comms(domain)
Expand Down
4 changes: 4 additions & 0 deletions tools/libxc/include/xenctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,10 @@ int xc_domain_add_to_physmap_batch(xc_interface *xch,
xen_pfn_t *gfpns,
int *errs);

int xc_domain_remove_from_physmap(xc_interface *xch,
uint32_t domid,
xen_pfn_t gpfn);

int xc_domain_populate_physmap(xc_interface *xch,
uint32_t domid,
unsigned long nr_extents,
Expand Down
11 changes: 11 additions & 0 deletions tools/libxc/xc_domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,17 @@ int xc_domain_add_to_physmap_batch(xc_interface *xch,
return rc;
}

int xc_domain_remove_from_physmap(xc_interface *xch,
uint32_t domid,
xen_pfn_t gpfn)
{
struct xen_remove_from_physmap xrfp = {
.domid = domid,
.gpfn = gpfn,
};
return do_memory_op(xch, XENMEM_remove_from_physmap, &xrfp, sizeof(xrfp));
}

int xc_domain_claim_pages(xc_interface *xch,
uint32_t domid,
unsigned long nr_pages)
Expand Down
4 changes: 2 additions & 2 deletions tools/libxl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o libxl_sshm.o \
$(LIBXL_OBJS-y)
LIBXL_OBJS += libxl_genid.o
LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
Expand Down Expand Up @@ -176,7 +176,7 @@ AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h _libxl_list.h _paths.h \
AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
AUTOSRCS += _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c
LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o \
libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o
libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o libxlu_sshm.o
$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h

$(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore)
Expand Down
Loading