Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00983C4363D for ; Fri, 2 Oct 2020 08:18:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 859CD20708 for ; Fri, 2 Oct 2020 08:18:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xen.org header.i=@xen.org header.b="ksH7FnUK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 859CD20708 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.1737.5280 (Exim 4.92) (envelope-from ) id 1kOGGi-0007HG-GZ; Fri, 02 Oct 2020 08:18:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1737.5280; Fri, 02 Oct 2020 08:18:20 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOGGi-0007H9-Cr; Fri, 02 Oct 2020 08:18:20 +0000 Received: by outflank-mailman (input) for mailman id 1737; Fri, 02 Oct 2020 08:18:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOGGh-0007H3-34 for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 08:18:19 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 725f5fcb-cdd3-42de-b267-2f279bb9d6dc; Fri, 02 Oct 2020 08:18:16 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOGGe-0001Yu-5p; Fri, 02 Oct 2020 08:18:16 +0000 Received: from [54.239.6.187] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kOGGd-0002CI-Tw; Fri, 02 Oct 2020 08:18:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOGGh-0007H3-34 for xen-devel@lists.xenproject.org; Fri, 02 Oct 2020 08:18:19 +0000 X-Inumbo-ID: 725f5fcb-cdd3-42de-b267-2f279bb9d6dc Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 725f5fcb-cdd3-42de-b267-2f279bb9d6dc; Fri, 02 Oct 2020 08:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=Vgixw/CeBnwxRzcUqOB3iBR+0hSx4I1dY4tAddWw+3A=; b=ksH7FnUKdAOJJ8UA5vc0NvWUYc gwQXCP9nqQskafeVdiw1jpBDkrfBx+xvYk+RpKpJ06omQV+3xilWsPwLEDbUIayhOjLarVSCNnnFO aS9o5QGABGyZptp8uGekzQ48x2HsHAZniSLrJEe+nlhZdKUopibA5g5OQ8EilfRJB+Sk=; Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOGGe-0001Yu-5p; Fri, 02 Oct 2020 08:18:16 +0000 Received: from [54.239.6.187] (helo=a483e7b01a66.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kOGGd-0002CI-Tw; Fri, 02 Oct 2020 08:18:16 +0000 Subject: Re: [PATCH] arm,smmu: match start level of page table walk with P2M To: Stefano Stabellini , Laurentiu Tudor Cc: xen-devel@lists.xenproject.org, Volodymyr_Babchuk@epam.com, will@kernel.org, diana.craciun@nxp.com, anda-alexandra.dorneanu@nxp.com References: <20200928135157.3170-1-laurentiu.tudor@nxp.com> From: Julien Grall Message-ID: <41f7c87b-0db9-5366-b25f-775bf3d6e3ce@xen.org> Date: Fri, 2 Oct 2020 09:18:14 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Hi, On 02/10/2020 00:52, Stefano Stabellini wrote: > On Mon, 28 Sep 2020, laurentiu.tudor@nxp.com wrote: >> From: Laurentiu Tudor >> >> 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 > > 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 Cheers, -- Julien Grall