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

Re: [PATCH] arm,smmu: match start level of page table walk with P2M


  • To: Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
  • Date: Fri, 2 Oct 2020 12:29:44 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.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=42yWuh+1D2zPjR2QTr3Esq8M8tYvM4goIZALn7eda6I=; b=gNjMFPduUyapxEMYuR1HP2FrvpM0FmOPCxqMIohk5T/rBhezG2t3URF7oRgb0M76tiQzcKxt1G36oj25Lx9N0usUb5nxA4VRkZFMdJR7Ex8yRiW9hqZVSVTKO8YeDv1uEemDPsBgWLGntleG7OPfcj6nMosFoF8/sTM99Bezunta8aMlS8hnitpSgxhFAkJ4q8g1r++uiP+Z7ecIEr9qKjEwA8Be3rg1Ttjs3qZk/8X+p+pKQWsAFDXei3g8S+5VwPMItMUNEf1I+tOEZfDesCpGavJAxnlGi1TwRLjkdyqwqrPzcOnwKSZ7lDsRzvPMV/0ixR8d/An5bN+zVfwSgg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBquCoP/E0UeVVc/d07eVsdJjZ+vfGwYCdrySGIgbYyhXRMiV/aT9vFWf6I2qexaFIMxkvHDlyCFX6xUxEOEN3xMaVBV4fT/SFbJaBCyMyUi4oJYTdsQas5xmk4n+hJomIkC0xopA0RKLfORgUPXQ5NVooAtypO1qFX63lOb+zj8hsruvdURjBrwhTXxnKldpg9alOV56FTrtVlkLN0d70jhdvll7GOys3UtlWEfGVBlEfoiC7EkLq5s4oxkHa6vATodGzNdZ32PaNopFdqaLj1qkdg6R/HCgcxu9zwS2xDu3WRvcrRP6Nv3ckIA45XbKJFkLCx1n8/LK3k6AZKyxA==
  • Authentication-results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Volodymyr_Babchuk@xxxxxxxx, will@xxxxxxxxxx, diana.craciun@xxxxxxx, anda-alexandra.dorneanu@xxxxxxx
  • Delivery-date: Fri, 02 Oct 2020 09:30:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 10/2/2020 11:18 AM, Julien Grall wrote:
> Hi,
> 
> On 02/10/2020 00:52, Stefano Stabellini wrote:
>> On Mon, 28 Sep 2020, laurentiu.tudor@xxxxxxx wrote:
>>> From: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
>>>
>>> Don't hardcode the lookup start level of the page table walk to 1
>>> and instead match the one used in P2M. This should fix scenarios
>>> involving SMMU where the start level is different than 1.
>>>
>>> Signed-off-by: Laurentiu Tudor <laurentiu.tudor@xxxxxxx>
>>
>> Thank you for the patch, I think it is correct, except that smmu.c today
>> can be enabled even on arm32 builds, where p2m_root_level would be
>> uninitialized.
>>
>> We need to initialize p2m_root_level at the beginning of
>> setup_virt_paging under the #ifdef CONFIG_ARM_32. We can statically
>> initialize it to 1 in that case. Or...
>>
>>
>>> ---
>>>   xen/arch/arm/p2m.c                 | 2 +-
>>>   xen/drivers/passthrough/arm/smmu.c | 2 +-
>>>   xen/include/asm-arm/p2m.h          | 1 +
>>>   3 files changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>>> index ce59f2b503..0181b09dc0 100644
>>> --- a/xen/arch/arm/p2m.c
>>> +++ b/xen/arch/arm/p2m.c
>>> @@ -18,7 +18,6 @@
>>>     #ifdef CONFIG_ARM_64
>>>   static unsigned int __read_mostly p2m_root_order;
>>> -static unsigned int __read_mostly p2m_root_level;
>>>   #define P2M_ROOT_ORDER    p2m_root_order
>>>   #define P2M_ROOT_LEVEL p2m_root_level
>>>   static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
>>> @@ -39,6 +38,7 @@ static unsigned int __read_mostly max_vmid =
>>> MAX_VMID_8_BIT;
>>>    * restricted by external entity (e.g. IOMMU).
>>>    */
>>>   unsigned int __read_mostly p2m_ipa_bits = 64;
>>> +unsigned int __read_mostly p2m_root_level;
>>
>> ... we could p2m_root_level = 1; here
> 
> IMHO, this is going to make the code quite confusing given that only the
> SMMU would use this variable for arm32.
> 
> The P2M root level also cannot be changed by the SMMU (at least for
> now). So I would suggest to introduce a helper (maybe
> p2m_get_root_level()) and use it in the SMMU code.
> 
> An alternative would be to move the definition of P2M_ROOT_{ORDER,
> LEVEL} in p2m.h

Alright, I'll go with this second option if that's ok with you.

---
Thanks & Best Regards, Laurentiu



 


Rackspace

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