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

Re: [Xen-devel] [PATCH 2/3] IOMMU/x86: make page type checks consistent when mapping pages



>>> On 13.05.19 at 15:44, <george.dunlap@xxxxxxxxxx> wrote:
> On 3/5/19 1:26 PM, Jan Beulich wrote:
>> --- a/xen/drivers/passthrough/iommu.c
>> +++ b/xen/drivers/passthrough/iommu.c
>> @@ -192,21 +192,27 @@ void __hwdom_init iommu_hwdom_init(struc
>>  
>>          page_list_for_each ( page, &d->page_list )
>>          {
>> -            unsigned long mfn = mfn_x(page_to_mfn(page));
>> -            unsigned long dfn = mfn_to_gmfn(d, mfn);
>> -            unsigned int mapping = IOMMUF_readable;
>> -            int ret;
>> +            if ( (page->u.inuse.type_info & PGT_type_mask) == PGT_none )
>> +            {
>> +                ASSERT(!(page->u.inuse.type_info & PGT_count_mask));
>> +                if ( get_page_and_type(page, d, PGT_writable_page) )
>> +                    put_page_and_type(page);
>> +                else if ( !rc )
>> +                    rc = -EBUSY;
>> +            }
>>  
>> -            if ( ((page->u.inuse.type_info & PGT_count_mask) == 0) ||
>> -                 ((page->u.inuse.type_info & PGT_type_mask)
>> -                  == PGT_writable_page) )
>> -                mapping |= IOMMUF_writable;
>> +            if ( ((page->u.inuse.type_info & PGT_type_mask) ==
>> +                  PGT_writable_page) )
>> +            {
>> +                unsigned long mfn = mfn_x(page_to_mfn(page));
>> +                unsigned long dfn = mfn_to_gmfn(d, mfn);
>> +                int ret = iommu_map(d, _dfn(dfn), _mfn(mfn), 0,
>> +                                    IOMMUF_readable | IOMMUF_writable,
>> +                                    &flush_flags);
> 
> What's the idea behind calling iommu_map() here, rather than relying on
> the one in _get_page_type()?  Does need_iommu_pt_sync() not work yet at
> this point, or do you expect there to be pages that have been marked
> PGT_writable without having gone through _get_page_type()?

No, I think I simply didn't realize that this could be deleted altogether
with the added get_page_and_type() invocation.

Jan



_______________________________________________
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®.