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

Re: [Xen-devel] [PATCH V7 2/4] x86/altp2m: Add hypercall to set a range of sve bits


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Alexandru Stefan ISAILA <aisaila@xxxxxxxxxxxxxxx>
  • Date: Mon, 13 Jan 2020 10:32:22 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=bitdefender.com; dmarc=pass action=none header.from=bitdefender.com; dkim=pass header.d=bitdefender.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=pOCi+kCgUpjGyNYkjzdExNJfeMKHt9wT8uNMjcM56z8=; b=OeD2G5YCXNHjlvplU/i095pQKlAK39f7h2bw6+lvMFT5fja+G/R82GPwtzxAR6dMfbbVgJ8bb7a4QDQEbmCNDqKPL9wQ/QtGpY7jaHkS3GBRu/poqwFnZRy+ETlajWQlIPw+IflZjA9OTDPGgMErJpa0rAqSPRQMfDBwrfG4Wa0rwhE+veK4uIAK9QC54CNzy9asHLS/E0wQuAqxchBAyyxk60nx0yF2rMfg2QDf61QYDXeUmA5Tn57oarZRLs9rp6zaven+B9ETuYpZwv/iXiBEfVAN8e6ywemguEFsoifH219FbgXPYDEivTzluLJyZCXCgjexI1zUPrr7EKlSPg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A6M5fSMoo6SPzCdX63dt0Scel7K/s9+BBxjzXLXxc5j5Nhzs64wZg+AR0YEKrhKThIs5mTIOi0wOjyktMWf3pbOaOjQVAqf5fwWrkWgtXmAr2knBvwQlB1fg84yLuydIuNqkJs3zeqPx9LSzG61yx2gXphNx2IY02WHOi8EAO6abRu05Tu0Cd05rqz2NapFMHxbQaWycQTwLdtC9nEN61nT8QUzkNWcR+sOXcWVBhYRiAzYqe1Vi29siFxT0WdpEanKNCfa7eB8+IdK7f0eLjz13MJA2Dhh71Z5Hc4NsumPq/1NMi25poTjJtjZCsx5uIol7c4LixStHmnYpMbiOkg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=aisaila@xxxxxxxxxxxxxxx;
  • Cc: Petre Ovidiu PIRCALABU <ppircalabu@xxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Razvan COJOCARU <rcojocaru@xxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 13 Jan 2020 10:32:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVxi0eW7mND/zIzUWDdK2ePPvUVqfkF1AAgARVogA=
  • Thread-topic: [Xen-devel] [PATCH V7 2/4] x86/altp2m: Add hypercall to set a range of sve bits


On 10.01.2020 18:20, Jan Beulich wrote:
> On 08.01.2020 15:08, Alexandru Stefan ISAILA wrote:
>> By default the sve bits are not set.
>> This patch adds a new hypercall, xc_altp2m_set_supress_ve_multi(),
>> to set a range of sve bits.
>> The core function, p2m_set_suppress_ve_multi(), does not break in case
>> of a error and it is doing a best effort for setting the bits in the
>> given range. A check for continuation is made in order to have
>> preemption on large ranges.
>> The gfn of the first error is stored in
>> xen_hvm_altp2m_suppress_ve_multi.first_error and the error code is
>> stored in xen_hvm_altp2m_suppress_ve_multi.first_error_code.
>> If no error occurred the values will be 0.
> 
> These last two sentences must have been stale for a while. IOW ...

I just saw that now, yes you are right, from when I changed the field names.

> 
>> Changes since V6:
>>      - Fix commit message
> 
> ... has this really happened?

This was done for the "braek" typo and for large/big ranges but I will 
fix the field names as well, thanks for pointing that out.

> 
>> --- a/xen/arch/x86/mm/p2m.c
>> +++ b/xen/arch/x86/mm/p2m.c
>> @@ -3030,45 +3030,87 @@ out:
>>    */
>>   int p2m_set_suppress_ve(struct domain *d, gfn_t gfn, bool suppress_ve,
>>                           unsigned int altp2m_idx)
>> +{
>> +    int rc;
>> +    struct xen_hvm_altp2m_suppress_ve_multi sve = {0};
>> +
>> +    sve.view = altp2m_idx;
>> +    sve.suppress_ve = suppress_ve;
>> +    sve.first_gfn = gfn_x(gfn);
>> +    sve.last_gfn = gfn_x(gfn);
> 
> Can't all of these move into the initializer, instead of the
> somewhat odd 0?

Sure, it's no trouble.

> 
>> +    if ( !(rc = p2m_set_suppress_ve_multi(d, &sve)) && sve.first_error )
>> +        rc = sve.first_error;
> 
> Why the right side of the && ?

This is intended to have p2m_set_suppress_ve() call 
p2m_set_suppress_ve_multi(). So here first I call the _multi version and 
the check if there was any error from the set/get (that is what 
p2m_set_suppress_ve did before). I don't know why git made the patch so 
ugly.

> 
>> +/*
>> + * Set/clear the #VE suppress bit for multiple pages.  Only available on 
>> VMX.
>> + */
>> +int p2m_set_suppress_ve_multi(struct domain *d,
>> +                              struct xen_hvm_altp2m_suppress_ve_multi *sve)
>>   {
>>       struct p2m_domain *host_p2m = p2m_get_hostp2m(d);
>>       struct p2m_domain *ap2m = NULL;
>> -    struct p2m_domain *p2m;
>> -    mfn_t mfn;
>> -    p2m_access_t a;
>> -    p2m_type_t t;
>> -    int rc;
>> +    struct p2m_domain *p2m = host_p2m;
>> +    uint64_t start = sve->first_gfn;
>> +    int rc = 0;
>>   
>> -    if ( altp2m_idx > 0 )
>> +    if ( sve->view > 0 )
>>       {
>> -        if ( altp2m_idx >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ||
>> -             d->arch.altp2m_eptp[array_index_nospec(altp2m_idx, MAX_EPTP)] 
>> ==
>> +        if ( sve->view >= min(ARRAY_SIZE(d->arch.altp2m_p2m), MAX_EPTP) ||
>> +             d->arch.altp2m_eptp[array_index_nospec(sve->view, MAX_EPTP)] ==
>>                mfn_x(INVALID_MFN) )
>>               return -EINVAL;
>>   
>> -        p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(altp2m_idx,
>> +        p2m = ap2m = d->arch.altp2m_p2m[array_index_nospec(sve->view,
>>                                           ARRAY_SIZE(d->arch.altp2m_p2m))];
>>       }
>> -    else
>> -        p2m = host_p2m;
>>   
>> -    gfn_lock(host_p2m, gfn, 0);
>> +    p2m_lock(host_p2m);
>>   
>>       if ( ap2m )
>>           p2m_lock(ap2m);
>>   
>> -    rc = altp2m_get_effective_entry(p2m, gfn, &mfn, &t, &a, AP2MGET_query);
>> +    while ( sve->last_gfn >= start )
>> +    {
>> +        p2m_access_t a;
>> +        p2m_type_t t;
>> +        mfn_t mfn;
>> +        int err = 0;
>>   
>> -    if ( rc )
>> -        goto out;
>> +        if ( (err = altp2m_get_effective_entry(p2m, _gfn(start), &mfn, &t, 
>> &a,
>> +                                               AP2MGET_query)) &&
>> +             !sve->first_error )
>> +        {
>> +            sve->first_error_gfn = start; /* Save the gfn of the first 
>> error */
>> +            sve->first_error = err; /* Save the first error code */
>> +        }
>>   
>> -    rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, suppress_ve);
>> +        if ( !err && (err = p2m->set_entry(p2m, _gfn(start), mfn,
>> +                                           PAGE_ORDER_4K, t, a,
>> +                                           sve->suppress_ve)) &&
>> +             !sve->first_error )
>> +        {
>> +            sve->first_error_gfn = start; /* Save the gfn of the first 
>> error */
>> +            sve->first_error = err; /* Save the first error code */
>> +        }
> 
> I think it would help readability if you didn't do this error
> saving twice.
> 


George requested this as well as having the single version call the 
_multi version.

Alex
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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