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

Re: [Xen-devel] [PATCH V4 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: Wed, 18 Dec 2019 08:13:44 +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=MKlSo8t+n2s0aCpV5YMO2xuCxx6aqZ/xwAnef4PdXZg=; b=TH4LH4E4pE2klvyNKPLllFm/HyRmT9yaxWfKRD5ChgT16ptK0WGAD3ogHxiiJFw0snUNyjMk7NsGo/muVJ909lFXy6MBLLu1fTawqThBjil7hUKSDl73XbZt7ifq6saa8vNj6JyE2A2EoDplx3CqLbMxoAlQR8+limG/CBCDxk4isiDjwoLOtBNIymNp/QMHjOaz9aKmtiivhEhSNDHLAH6UKbizz/TqVa9FAGAc+6L+aVpYR+qRH1agVMpZ4pAnwSJdu+I39ghLsCR3whGL+b2Zyd0ffMcBzT/ai3G5kmzavmqW/NmXaWTv0tpWVuI+Hvb8fvH2JhWxq1eIGtbXhg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WyNYRVq4eU/H1UJJl8IWKCuYlXWoMJOVHWb/UYoO6rWoXGXFsBLANlZGb46B5WKRfiqNpu+yE0qymNN834x3+eP/IJ0r5rJlFdz9J6XKIDWLfJd/pzb6lmvuX4MWg6c3669MOhXaMiQLvxroMVPe8FhpGF99ccu8NG7Cy7j2huKmlbCbm/NGNbTJFB9prW98H/GHR7UWHfUbdOP1JC2QejS1lDkII0D09o68lzalKPD2ZbAFTh1vsTnAjFwoxeUlZp/9B8ZbcxhatnLmb1qFWQ+Q/zxfgNmCnx5Dw1n/HWGPAX5zShouLgPk8h3A4aEIXWXx2ZGTvfpqrYSxT/IxEQ==
  • 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>, Wei Liu <wl@xxxxxxx>, Razvan COJOCARU <rcojocaru@xxxxxxxxxxxxxxx>, 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: Wed, 18 Dec 2019 08:14:02 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVtOxnMZNvtoiQIE62yqEH5VgLvKe+jS4AgAD/GYA=
  • Thread-topic: [PATCH V4 2/4] x86/altp2m: Add hypercall to set a range of sve bits

>> +/*
>> + * 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 = host_p2m;
>> +    uint64_t start = sve->first_gfn;
>> +    int rc = 0;
>> +    uint64_t max_phys_addr = (1UL << d->arch.cpuid->extd.maxphysaddr) - 1;
>> +
>> +    if ( sve->view > 0 )
>> +    {
>> +        if ( sve->view >= MAX_ALTP2M ||
>> +             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(sve->view,
>> +                                                           MAX_ALTP2M)];
>> +    }
>> +
>> +    p2m_lock(host_p2m);
>> +
>> +    if ( ap2m )
>> +        p2m_lock(ap2m);
>> +
>> +    while ( sve->last_gfn >= start && start < max_phys_addr )
> 
> Why don't you clip ->last_gfn ahead of the loop, saving one
> comparison per iteration?

I've done this so it will have fewer lines but sure, I can have the 
->last_gfn check before the loop.

> 
>> +    {
>> +        p2m_access_t a;
>> +        p2m_type_t t;
>> +        mfn_t mfn;
>> +        int err = 0;
>> +
>> +        if ( altp2m_get_effective_entry(p2m, _gfn(start), &mfn, &t, &a, 
>> AP2MGET_query) )
>> +            a = p2m->default_access;
>> +
>> +        if ( (err = p2m->set_entry(p2m, _gfn(start), mfn, PAGE_ORDER_4K, t, 
>> a,
>> +                                   sve->suppress_ve)) && !sve->first_error )
>> +        {
>> +            sve->first_error = start; /* Save the gfn of the first error */
>> +            sve->first_error_code = err; /* Save the first error code */
>> +        }
> 
> What if the first error occurs on GFN 0? I guess you want to check
> ->first_error_code against zero in the condition.

That is right, I will change to check ->first_error_code instead of 
->first_error.

Thanks,
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®.