From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 33F03C433EF for ; Sat, 26 Feb 2022 19:30:50 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.279853.477655 (Exim 4.92) (envelope-from ) id 1nO2lt-0002iv-0m; Sat, 26 Feb 2022 19:30:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 279853.477655; Sat, 26 Feb 2022 19:30:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nO2ls-0002io-SS; Sat, 26 Feb 2022 19:30:24 +0000 Received: by outflank-mailman (input) for mailman id 279853; Sat, 26 Feb 2022 19:30:23 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nO2lr-0002ii-Mp for xen-devel@lists.xenproject.org; Sat, 26 Feb 2022 19:30:23 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nO2lr-0003ze-AR; Sat, 26 Feb 2022 19:30:23 +0000 Received: from gw1.octic.net ([81.187.162.82] helo=[10.0.1.102]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nO2lr-0007Zh-4l; Sat, 26 Feb 2022 19:30:23 +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" 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:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=vy0KKzNV1cTLvO2UQfRSEyvB/FsMPs4v5L5ywHF+59w=; b=3a5jzQjQC6+wibDQg3P+J9WUZ+ anHmwb5XCfAJNPlcGLbGL0g8YDaLNivAYVMnd+uISuGn8cGPfa1iO6R4aqOLxw4UCECmAewCfzKfh YK/34iwo/OK/SVYK0M0bje3qW8ukzDj4ACSao3lL+7dw+3ZeMU9FIV47F2DuBnRyBVNI=; Message-ID: Date: Sat, 26 Feb 2022 19:30:21 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v3 05/19] xen/arm: mm: Add support for the contiguous bit To: xen-devel@lists.xenproject.org Cc: Julien Grall , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk References: <20220221102218.33785-1-julien@xen.org> <20220221102218.33785-6-julien@xen.org> From: Julien Grall In-Reply-To: <20220221102218.33785-6-julien@xen.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 21/02/2022 10:22, Julien Grall wrote: > @@ -1333,21 +1386,34 @@ static int xen_pt_update(unsigned long virt, > while ( left ) > { > unsigned int order, level; > + unsigned int nr_contig; > + unsigned int new_flags; > > level = xen_pt_mapping_level(vfn, mfn, left, flags); > order = XEN_PT_LEVEL_ORDER(level); > > ASSERT(left >= BIT(order, UL)); > > - rc = xen_pt_update_entry(root, pfn_to_paddr(vfn), mfn, level, flags); > - if ( rc ) > - break; > + /* > + * Check if we can set the contiguous mapping and update the > + * flags accordingly. > + */ > + nr_contig = xen_pt_check_contig(vfn, mfn, level, left, flags); > + new_flags = flags | ((nr_contig > 1) ? _PAGE_CONTIG : 0); > > - vfn += 1U << order; > - if ( !mfn_eq(mfn, INVALID_MFN) ) > - mfn = mfn_add(mfn, 1U << order); > + for ( ; nr_contig > 0; nr_contig-- ) > + { > + rc = xen_pt_update_entry(root, pfn_to_paddr(vfn), mfn, level, > + new_flags); > + if ( rc ) > + break; > > - left -= (1U << order); > + vfn += 1U << order; > + if ( !mfn_eq(mfn, INVALID_MFN) ) > + mfn = mfn_add(mfn, 1U << order); > + > + left -= (1U << order); > + } I forgot to add: if ( rc ) break; Without it, the outer loop will never exit in case of an error. Cheers, -- Julien Grall