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

Re: [PATCH v2 02/18] VT-d: have callers specify the target level for page table walks


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 30 Nov 2021 15:38:11 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fbla6r+kB9qZGOZaj6QZrwnmYPaJKjFJqfffD203A4I=; b=MmkQetRa04AXmdYa6hbm8SoFcrzN6qmOCVOSKDqf7qeG2KASZjvefpfygcdQAUV9zt4dcfAQwriXwodzDHRc/k4JFH2USIEt/j5Z1A3Ij8VZOtXpUwy+vvVelZRK54+1GV7Py8eGd3lwJ1nuzAoSlBbxK8xbcRITTk2e3T0Y0EXXFCAFOQbLoS5OSIhbBRWq7+bkiijXuYrwjkZagdqK07S2aQaS4xNrqnBsDMdYp5VBDVGyWX+QckQcQf4dKWaRJBHv5diwNpOWU0VYz53OMw6zfi52IN9IDilK7jkK99xTEg1JSDgY5alUZd5Qx7mJRJp+Azz8xN+rISf3p/qmZQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yw1J0NKQx/PSTz0IfGUmY1T/VGuKGZeCwyVYqwkzKR0My9CqwERCsFMIgAImv6lcbEB4+tJXALisLH3K/trMSfqj8xwoKfNYMSqxPE0vwNko48u+POzK4Ye0pEYDoKqrgfd+EjMZz+LtaD4+0uf7gFzAj8cz9YeEXkTpXHdNd1bV4iPTAUrFXDTN7EB8dZShQVbY76j5/Jd3MhaeEXfSiT2yYBPEYcj8NI9/HKxTqiV5PW03wvMOzIffOBzL5GqjQT7C/wugAtNvZXZOrotDz3PDND0gPL3ePa2Z6698pAteELLyyDpdtgLTSeX21I8aKVJ8W6vbTwg/Yay3A8z6IQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Kevin Tian <kevin.tian@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Tue, 30 Nov 2021 14:38:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30.11.2021 12:56, Roger Pau Monné wrote:
> On Mon, Sep 27, 2021 at 11:04:26AM +0200, Jan Beulich wrote:
>> On 24.09.2021 16:45, Roger Pau Monné wrote:
>>> On Fri, Sep 24, 2021 at 11:42:13AM +0200, Jan Beulich wrote:
>>>> -    parent = (struct dma_pte 
>>>> *)map_vtd_domain_page(hd->arch.vtd.pgd_maddr);
>>>> -    while ( level > 1 )
>>>> +    pte_maddr = hd->arch.vtd.pgd_maddr;
>>>> +    parent = map_vtd_domain_page(pte_maddr);
>>>> +    while ( level > target )
>>>>      {
>>>>          offset = address_level_offset(addr, level);
>>>>          pte = &parent[offset];
>>>>  
>>>>          pte_maddr = dma_pte_addr(*pte);
>>>> -        if ( !pte_maddr )
>>>> +        if ( !dma_pte_present(*pte) || (level > 1 && 
>>>> dma_pte_superpage(*pte)) )
>>>>          {
>>>>              struct page_info *pg;
>>>> +            /*
>>>> +             * Higher level tables always set r/w, last level page table
>>>> +             * controls read/write.
>>>> +             */
>>>> +            struct dma_pte new_pte = { DMA_PTE_PROT };
>>>>  
>>>>              if ( !alloc )
>>>> -                break;
>>>> +            {
>>>> +                pte_maddr = 0;
>>>> +                if ( !dma_pte_present(*pte) )
>>>> +                    break;
>>>> +
>>>> +                /*
>>>> +                 * When the leaf entry was requested, pass back the full 
>>>> PTE,
>>>> +                 * with the address adjusted to account for the residual 
>>>> of
>>>> +                 * the walk.
>>>> +                 */
>>>> +                pte_maddr = pte->val +
>>>
>>> Wouldn't it be better to use dma_pte_addr(*pte) rather than accessing
>>> pte->val, and then you could drop the PAGE_MASK?
>>>
>>> Or is the addr parameter not guaranteed to be page aligned?
>>
>> addr is page aligned, but may not be superpage aligned. Yet that's not
>> the point here. As per the comment at the top of the function (and as
>> per the needs of intel_iommu_lookup_page()) we want to return a proper
>> (even if fake) PTE here, i.e. in particular including the access
>> control bits. Is "full" in the comment not sufficient to express this?
> 
> I see. I guess I got confused by the function name. It would be better
> called addr_to_dma_pte?

That wouldn't match its new purpose either. It can return an address
_or_ a full PTE, as per - as said - the comment being added at the
top of the function.

Jan




 


Rackspace

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