All of lore.kernel.org
 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 04/14] tools/libxl: detect and avoid conflicts with RDM
Date: Mon, 08 Jun 2015 10:16:45 +0800	[thread overview]
Message-ID: <5574FB0D.8050003@intel.com> (raw)
In-Reply-To: <20150607112026.GP29102@zion.uk.xensource.com>

On 2015/6/7 19:20, Wei Liu wrote:
> On Wed, Jun 03, 2015 at 10:25:47AM +0800, Chen, Tiejun wrote:
> [...]
>>>> +static struct xen_reserved_device_memory
>>>> +*xc_device_get_rdm(libxl__gc *gc,
>>>> +                   uint32_t flag,
>>>> +                   uint16_t seg,
>>>> +                   uint8_t bus,
>>>> +                   uint8_t devfn,
>>>> +                   unsigned int *nr_entries)
>>>> +{
>>>> +    struct xen_reserved_device_memory *xrdm = NULL;
>>>> +    int rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn,
>>>> +                                           xrdm, nr_entries);
>>>> +
>>>
>>> Please separate declaration and function call. Also change xrdm to NULL
>>
>> Are you saying this?
>>
>>      struct xen_reserved_device_memory *xrdm = NULL;
>>      int rc;
>>
>>      rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn,
>>                                         xrdm, nr_entries);
>
> Yes, splitting "rc = " to a separate line. The other thing is:
>
>       rc = xc_reserved_device_memory_map(CTX->xch, flag, seg, bus, devfn,
>                                          NULL, nr_entries);
> 					^ here
>
> It's mostly cosmetic. IMHO it is clearer than passing xrdm which is
> always NULL in that function call.

Right.

>
>>
>>> in that function call.
>>
>> Sorry, what do you mean by this point? Or you let me to change xrdm to NULL
>> inside xc_reserved_device_memory_map()?
>>
>>>
>>>> +    assert( rc <= 0 );
>>>> +    /* "0" means we have no any rdm entry. */
>>>> +    if ( !rc )
>>>> +        goto out;
>>>
>>> Also set *nr_entries = 0; otherwise you can't distinguish error vs 0
>>> entries.
>>
>> *nr_entries is always updated by xc_reserved_device_memory_map() above.
>>
>
> Actually no. If xc_hypercall_bounce_pre fails in the function,
> nr_entries is untouched.

Sure.

>
>>>
>>>> +
>>>> +    if ( errno == ENOBUFS )
>>>> +    {
>>>> +        if ( (xrdm = malloc(*nr_entries *
>>>> +                            sizeof(xen_reserved_device_memory_t))) == NULL )
> [...]
>>>> +    return -1;
>>>
>>> Please return libxl error code.
>>
>> ERROR_FAIL?
>>
>
> Yes, that's fine.

Thanks
Tiejun

>
> [...]
>>>> +        args.mmio_size = HVM_BELOW_4G_MMIO_LENGTH;
>>>> +    mmio_start = (1ull << 32) - args.mmio_size;
>>>> +
>>>> +    if (args.lowmem_size > mmio_start)
>>>> +        args.lowmem_size = mmio_start;
>>>> +
>>>> +    /*
>>>> +     * We'd like to set a memory boundary to determine if we need to check
>>>> +     * any overlap with reserved device memory.
>>>> +     */
>>>> +    rdm_mem_boundary = 0x80000000;
>>>> +    if (info->rdm_mem_boundary_memkb)
>>>
>>
>> I'm going to update this chunk of codes as follows:
>>
>> #1. @@ -858,6 +858,12 @@ const char *libxl_defbool_to_string(libxl_defbool
>> b);
>>   #define LIBXL_TIMER_MODE_DEFAULT -1
>>   #define LIBXL_MEMKB_DEFAULT ~0ULL
>>
>> +/*
>> + * We'd like to set a memory boundary to determine if we need to check
>> + * any overlap with reserved device memory.
>> + */
>> +#define LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT (2048 * 1024)
>> +
>>   #define LIBXL_MS_VM_GENID_LEN 16
>>   typedef struct {
>>       uint8_t bytes[LIBXL_MS_VM_GENID_LEN];
>>
>>> I think you mean info->rdm_mem_boundary_memkb != LIBXL_MEMKB_DEFAULT?
>>>
>>
>> #2.
>>
>> @@ -109,6 +109,10 @@ void libxl__rdm_setdefault(libxl__gc *gc,
>> libxl_domain_build_info *b_info)
>>   {
>>       if (b_info->rdm.reserve == LIBXL_RDM_RESERVE_FLAG_INVALID)
>>           b_info->rdm.reserve = LIBXL_RDM_RESERVE_FLAG_RELAXED;
>> +
>> +    if (b_info->rdm_mem_boundary_memkb == LIBXL_MEMKB_DEFAULT)
>> +        b_info->rdm_mem_boundary_memkb =
>> +                            LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT;
>
> This looks plausible.
>
> Wei.
>

  reply	other threads:[~2015-06-08  2:16 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 [this message]
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
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=5574FB0D.8050003@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.