xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Chen, Tiejun" <tiejun.chen@intel.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: kevin.tian@intel.com, ian.campbell@citrix.com,
	andrew.cooper3@citrix.com, tim@xen.org, xen-devel@lists.xen.org,
	stefano.stabellini@citrix.com, JBeulich@suse.com,
	yang.z.zhang@intel.com, Ian.Jackson@eu.citrix.com
Subject: Re: [RFC][v2][PATCH 10/14] tools: extend XENMEM_set_memory_map
Date: Wed, 03 Jun 2015 11:06:24 +0800	[thread overview]
Message-ID: <556E6F30.1080201@intel.com> (raw)
In-Reply-To: <20150602164238.GW19403@zion.uk.xensource.com>

On 2015/6/3 0:42, Wei Liu wrote:
> On Fri, May 22, 2015 at 05:35:10PM +0800, Tiejun Chen wrote:
>> Here we'll construct a basic guest e820 table via
>> XENMEM_set_memory_map. This table includes lowmem, highmem
>> and RDMs if they exist. And hvmloader would need this info
>> later.
>>
>> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>
>> ---
>>   tools/libxl/libxl_dom.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 87 insertions(+)
>>
>> diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
>> index 84d5465..cc4b1a6 100644
>> --- a/tools/libxl/libxl_dom.c
>> +++ b/tools/libxl/libxl_dom.c
>> @@ -913,6 +913,87 @@ out:
>>       return rc;
>>   }
>>
>> +/*
>> + * Here we're just trying to set these kinds of e820 mappings:
>> + *
>> + * #1. Low memory region
>> + *
>> + * Low RAM starts at least from 1M to make sure all standard regions
>> + * of the PC memory map, like BIOS, VGA memory-mapped I/O and vgabios,
>> + * have enough space.
>> + * Note: Those stuffs below 1M are still constructed with multiple
>> + * e820 entries by hvmloader. At this point we don't change anything.
>> + *
>> + * #2. RDM region if it exists
>> + *
>> + * #3. High memory region if it exists
>> + *
>> + * Note: these regions are not overlapping since we already check
>> + * to adjust them. Please refer to libxl__domain_device_construct_rdm().
>> + */
>> +#define GUEST_LOW_MEM_START_DEFAULT 0x100000
>> +static int libxl__domain_construct_memmap(libxl__gc *gc,
>> +                                          libxl_domain_config *d_config,
>> +                                          uint32_t domid,
>> +                                          struct xc_hvm_build_args *args)
>
> This is x86 specific. I think libxl__domain_construct_e820 is better
> name.

Okay.

>
>> +{
>> +    libxl_ctx *ctx = libxl__gc_owner(gc);
>
> Use CTX.

Sure.

>
>> +    unsigned int nr = 0, i;
>> +    /* We always own at least one lowmem entry. */
>> +    unsigned int e820_entries = 1;
>> +    uint64_t highmem_end = 0, highmem_size = args->mem_size - args->lowmem_size;
>> +    struct e820entry *e820 = NULL;
>> +
>> +    /* Add all rdm entries. */
>> +    e820_entries += d_config->num_rdms;
>> +
>> +    /* If we should have a highmem range. */
>> +    if (highmem_size)
>> +    {
>> +        highmem_end = (1ull<<32) + highmem_size;
>> +        e820_entries++;
>> +    }
>> +
>> +    if (e820_entries >= E820MAX) {
>> +        LOG(ERROR, "Ooops! Too many entries in the memory map!\n");
>> +        return -1;
>> +    }
>> +
>> +    e820 = libxl__malloc(gc, sizeof(struct e820entry) * e820_entries);
>> +
>> +    /* Low memory */
>> +    e820[nr].addr = GUEST_LOW_MEM_START_DEFAULT;
>> +    e820[nr].size = args->lowmem_size - GUEST_LOW_MEM_START_DEFAULT;
>> +    e820[nr].type = E820_RAM;
>> +    nr++;
>> +
>> +    /* RDM mapping */
>> +    for (i = 0; i < d_config->num_rdms; i++) {
>> +        /*
>> +         * We should drop this kind of rdm entry.
>> +         */
>
> This comment is not useful.

Okay.

>
>> +        if (d_config->rdms[i].flag == LIBXL_RDM_RESERVE_FLAG_INVALID)
>> +            continue;
>> +
>> +        e820[nr].addr = d_config->rdms[i].start;
>> +        e820[nr].size = d_config->rdms[i].size;
>> +        e820[nr].type = E820_RESERVED;
>> +        nr++;
>> +    }
>> +
>> +    /* High memory */
>> +    if (highmem_size) {
>> +        e820[nr].addr = ((uint64_t)1 << 32);
>> +        e820[nr].size = highmem_size;
>> +        e820[nr].type = E820_RAM;
>> +    }
>> +
>> +    if (xc_domain_set_memory_map(ctx->xch, domid, e820, e820_entries) != 0)
>> +        return -1;
>> +
>> +    return 0;
>> +}
>> +
>>   int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
>>                 libxl_domain_config *d_config,
>>                 libxl__domain_build_state *state)
>> @@ -1016,6 +1097,12 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
>>           ret = set_vnuma_info(gc, domid, info, state);
>>           if (ret) goto out;
>>       }
>> +
>> +    if (libxl__domain_construct_memmap(gc, d_config, domid, &args)) {
>> +        LOG(ERROR, "setting domain rdm memory map failed");
>
> The error message should not be RDM specific.

Maybe we can just remove "rdm" simply.

Thanks
Tiejun

>
> Wei.
>
>> +        goto out;
>> +    }
>> +
>>       ret = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
>>                                  &state->store_mfn, state->console_port,
>>                                  &state->console_mfn, state->store_domid,
>> --
>> 1.9.1
>

  reply	other threads:[~2015-06-03  3:06 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22  9:35 [RFC][v2][PATCH 00/14] Fix RMRR Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 01/14] tools: introduce some new parameters to set rdm policy Tiejun Chen
2015-06-02 15:57   ` Wei Liu
2015-06-03  1:35     ` Chen, Tiejun
2015-06-07 11:06       ` Wei Liu
2015-06-08  1:42         ` Chen, Tiejun
2015-05-22  9:35 ` [RFC][v2][PATCH 02/14] introduce XENMEM_reserved_device_memory_map Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 03/14] tools/libxc: Expose new hypercall xc_reserved_device_memory_map Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 04/14] tools/libxl: detect and avoid conflicts with RDM Tiejun Chen
2015-06-02 16:29   ` Wei Liu
2015-06-03  2:25     ` Chen, Tiejun
2015-06-07 11:20       ` Wei Liu
2015-06-08  2:16         ` Chen, Tiejun
2015-05-22  9:35 ` [RFC][v2][PATCH 05/14] xen/x86/p2m: introduce set_identity_p2m_entry Tiejun Chen
2015-05-28 12:27   ` Jan Beulich
2015-05-29  1:19     ` Chen, Tiejun
2015-05-22  9:35 ` [RFC][v2][PATCH 06/14] xen:vtd: create RMRR mapping Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 07/14] xen/passthrough: extend hypercall to support rdm reservation policy Tiejun Chen
2015-05-22 10:33   ` Julien Grall
2015-05-25  2:09     ` Chen, Tiejun
2015-05-25 10:02       ` Julien Grall
2015-05-25 10:50         ` Chen, Tiejun
2015-05-25 11:42           ` Julien Grall
2015-05-26  0:42             ` Chen, Tiejun
2015-05-22  9:35 ` [RFC][v2][PATCH 08/14] tools: extend xc_assign_device() " Tiejun Chen
2015-06-02 16:36   ` Wei Liu
2015-06-03  2:58     ` Chen, Tiejun
2015-06-07 11:27       ` Wei Liu
2015-06-09  5:42         ` Chen, Tiejun
2015-05-22  9:35 ` [RFC][v2][PATCH 09/14] xen: enable XENMEM_memory_map in hvm Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 10/14] tools: extend XENMEM_set_memory_map Tiejun Chen
2015-05-22 10:25   ` Julien Grall
2015-05-25  2:00     ` Chen, Tiejun
2015-06-02 16:42   ` Wei Liu
2015-06-03  3:06     ` Chen, Tiejun [this message]
2015-05-22  9:35 ` [RFC][v2][PATCH 11/14] hvmloader: get guest memory map into memory_map[] Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 12/14] hvmloader/pci: skip reserved ranges Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 13/14] hvmloader/e820: construct guest e820 table Tiejun Chen
2015-05-22  9:35 ` [RFC][v2][PATCH 14/14] xen/vtd: enable USB device assignment Tiejun Chen
2015-05-22  9:46 ` [RFC][v2][PATCH 00/14] Fix RMRR Jan Beulich
2015-05-28  5:48   ` Chen, Tiejun
2015-05-28  7:55     ` Jan Beulich
2015-05-29  7:58       ` Chen, Tiejun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=556E6F30.1080201@intel.com \
    --to=tiejun.chen@intel.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=kevin.tian@intel.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yang.z.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).