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

Re: [PATCH v2 01/18] AMD/IOMMU: have callers specify the target level for page table walks


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 24 Sep 2021 14:02:46 +0200
  • 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; bh=tZ2JJ0qf38l3SeHPkotDBqFhOnZimuvD4duLlByCEDk=; b=J0P2LaSyyhgf2lAHD6ItuVqRutRly1JpDbVqQ+I0LEHswLmG8zOn1+lWZ0gQCP2Vk0Yq2dLtHio3mG1/e2mHR80QG2poNRBkxA782cLhpb/YvZ8F0W9Ho3HUCkRWiydXBEgG5oKPr7iPdslAkrsBjRtgk0BOtGHxlsUezDCHr3ZMnn6ugr/GcQ5LnnDuXfnJ95XcYsI7IJ9ZTSlp/pHXmNE6mIKWRr+KmwwcKoM522ufk2/F79YutACKZt6iOrjMc3cdjToveY+Ct4myunQHE858W78uW4hef4AseHlCtHlh752bn+d3dYF6XKruPL/XY2+bnWjYn4wISrnA0oho4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kN0WhsvxHeKGOu05cCwFSYp6HJQ3kdfS8g8TiiabnP4SEXCNSKpYmaAR/pX+3VQz7PfEagciEvcvlS2E2XClM3+xiyacm60xiOrp5w3l4xi7NnhfhQJsOFcnSZ4Cc3V7psZDi6WJYdEAJctdyvWxCIyyfj5t0/VizJehqkZ77ZvfYnbjm8q8ggLzQQRIrhqpJwdhchYBoXbBEh3tdUtmZwJ8fudNIP8q1CIaHHMFXWP2ksXlUv0gYlc3/tYj8MKLWE4Hwd4wck5nmZByHAYRxIZeOxac5ereSkACJl3q2Y66+e4NGkAssOgKVHG84QoES5kukRk2EGTZVbT50LjHmg==
  • Authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Fri, 24 Sep 2021 12:03:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.09.2021 12:58, Roger Pau Monné wrote:
> On Fri, Sep 24, 2021 at 11:41:14AM +0200, Jan Beulich wrote:
>> --- a/xen/drivers/passthrough/amd/iommu_map.c
>> +++ b/xen/drivers/passthrough/amd/iommu_map.c
>> @@ -178,7 +178,8 @@ void __init iommu_dte_add_device_entry(s
>>   * page tables.
>>   */
>>  static int iommu_pde_from_dfn(struct domain *d, unsigned long dfn,
>> -                              unsigned long *pt_mfn, bool map)
>> +                              unsigned int target, unsigned long *pt_mfn,
>> +                              bool map)
>>  {
>>      union amd_iommu_pte *pde, *next_table_vaddr;
>>      unsigned long  next_table_mfn;
>> @@ -189,7 +190,8 @@ static int iommu_pde_from_dfn(struct dom
>>      table = hd->arch.amd.root_table;
>>      level = hd->arch.amd.paging_mode;
>>  
>> -    BUG_ON( table == NULL || level < 1 || level > 6 );
>> +    if ( !table || target < 1 || level < target || level > 6 )
>> +        return 1;
> 
> I would consider adding an ASSERT_UNREACHABLE here, since there should
> be no callers passing those parameters, and we shouldn't be
> introducing new ones. Unless you believe there could be valid callers
> passing level < target parameter.

Ah yes - added.

>> @@ -200,7 +202,7 @@ static int iommu_pde_from_dfn(struct dom
>>  
>>      next_table_mfn = mfn_x(page_to_mfn(table));
>>  
>> -    while ( level > 1 )
>> +    while ( level > target )
>>      {
>>          unsigned int next_level = level - 1;
> 
> There's a comment at the bottom of iommu_pde_from_dfn that needs to be
> adjusted to no longer explicitly mention level 1.

Oh, thanks for noticing. I recall spotting that comment as in
need of updating before starting any of this work. And then I
forgot ...

> With that adjusted:
> 
> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>

Thanks.

> FWIW, I always get confused with AMD and shadow code using level 1 to
> denote the smaller page size level while Intel uses 0.

Wait - with "Intel" you mean just EPT here, don't you? VT-d
code is using 1-based numbering again from all I can tell.

Jan




 


Rackspace

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