[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/7] xen/gnttab: Rework resource acquisition


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 15 Jan 2021 16:03:57 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Oa6jF8TU3dgpq4dyO8YbQkf9qjm65eSiyvxfe3r9z+0=; b=C4WnKxsBjXMG96ja7DqfkS1ZJ60vVOfQPcDNyfJ7kgDgs6a+LkSaiLIMwYYBkDW4eFOqhV6Ir8fNC/h2CQbmkBzF0bQhjboIrWdElrOSXx0ka9HIcSnHj+uWd0MRUVEFTAIwNqAOQbF8J+Ujap4anWvW2faiz3V+FvhbNwlUzTijsG67ujtgbE652jkgh5ChARHX/E5hJdEEe7tCKtiIZ6LijEckzzDQDms1wyfHarwpUmyeieQQaoWkEYxVW3OQ7ac3hbczmCADUR3lL3rxe0rFCoZjy9rRcpfwL0RdEok5M3guewDKJNvtJFqaMwKoyBVZ9MqBwIIFJnei73hQfw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EYzEj0VI2mDBBP+gk9FPTs74tCBlzoyZlFkiJ9FOK1wog7r4UFTYOw23jBrHm9yikLUcon2NPSWeyA2lxrH057TIgLiJs6w6583sg2XCnSle4YfA9ZvZbSPBtkUxDvau3KnYVB65aoY7tzNKD+kg2qILANQwDPCNv1/7doGaSoFh5WzElAyooYBYVWDF+uSoFuOMMhhLpk7Q7KeAgPnyWZY2BSd/gFRRKuF82k4L6uHP7gIrAjvY8KWxz9NQx5xcC1xjKqMjd1eaJ0dkbKA3OYazTOFGBlnNNPjfLpbShldYAkgDbVHDDKiDdJwllBbOnmrBdwQ59isMm+0y8uz1rA==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Paul Durrant <paul@xxxxxxx>, Michał Leszczyński <michal.leszczynski@xxxxxxx>, Hubert Jasudowicz <hubert.jasudowicz@xxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 15 Jan 2021 16:04:09 +0000
  • Ironport-sdr: HbdBEcerxLvuRU/ir3ZW7okwRdCwnJ1olTnoMOhLaFN48O+jU+Vf1iKK9wHibKHCRR+G1KKlTO HFZrgSeCXRe6uMtg/3IqCjjpYnSSHX5xBNRoAhY1mWtYQpMewnm8zlS2qc3kZK6n96eBZOHm2e 6rqu6TlrheZQj4uwOOx3YFGz7bQsMSZKX5jUIAVYWhe3Zl3U3KXVcFD3LcksuMWdShe5LOrunJ e1c7EQ1zUM4ExqCxiMIirhIW00ngqB3BKqwWkTtPw7eDvYjbw6u4EAbOQl48PbBQz3gj6ntGAv QmQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15/01/2021 11:43, Jan Beulich wrote:
>> --- a/xen/common/grant_table.c
>> +++ b/xen/common/grant_table.c
>> @@ -4013,6 +4013,59 @@ static int gnttab_get_shared_frame_mfn(struct domain 
>> *d,
>>      return 0;
>>  }
>>  
>> +int gnttab_acquire_resource(
>> +    struct domain *d, unsigned int id, unsigned long frame,
>> +    unsigned int nr_frames, xen_pfn_t mfn_list[])
>> +{
>> +    struct grant_table *gt = d->grant_table;
>> +    unsigned int i = nr_frames, tot_frames;
> It doesn't look like this initializer was needed. The only
> use of i that I can spot is the loop near the end, which
> starts from 0.

Its possibly stale from v1.  I'll adjust.

>> +    mfn_t tmp;
>> +    void **vaddrs;
>> +    int rc;
>> +
>> +    /* Overflow checks */
>> +    if ( frame + nr_frames < frame )
>> +        return -EINVAL;
>> +
>> +    tot_frames = frame + nr_frames;
>> +    if ( tot_frames != frame + nr_frames )
>> +        return -EINVAL;
> Can't these two be folded into
>
>     unsigned int tot_frames = frame + nr_frames;
>
>     if ( tot_frames < frame )
>         return -EINVAL;
>
> ? Both truncation and wrapping look to be taken care of this
> way.

Not when frame is a multiple of 4G (or fractionally over, I think).

This ABI with mismatched widths really is obnoxious to work with.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.