Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2824534pxb; Tue, 21 Sep 2021 08:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEmmYP9fI1k61LTPeyjydxkeycCdN9kxyeq11BcdijwpH63OSUk2Lxj08DRpiKtJ5Fg6TE X-Received: by 2002:a17:906:a195:: with SMTP id s21mr34386244ejy.181.1632238006899; Tue, 21 Sep 2021 08:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632238006; cv=none; d=google.com; s=arc-20160816; b=ILcyff78wtGmkdklVGM+kOhaSOytBhBg3EI3DPq9vuOfGf+A8sjfsdHaEOXJPZYwro vx3jqQ/3RLW+HnZaFC5UpImhVth8BDfueV0YRo5K0m4NDO5CB3mqj1dY9faZjzkH47pL lIkPPQ8SdssGbl/VW2Lnup5yfNr0XDXI37uY7jTU9pHUroeLFVKZtAqy9tMgVJhm1P6k 0c6cB35sQ5veXoztxT2dstPul8mSk4UlPthB/1UXjqsfNbjZqdkveQsRqsX5ugU0IxU7 aT8cQDFRvTpcDEVPfEUTFiAixhn9lUK9Us5Vt/fiC8km9+L0VsjlNHIrbsc/670SGAFU ydLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vbgLIWaMCrSfJePdYrMiWleqXu+KBmaO6Qy51Cak5/w=; b=ErnaMK85x9gmJeQ6O0nd/wexvOzsTZBmdYqthO7D6tE102IlxQaw0Sq/q4cWE/59QN al7PxtPj9I7TWEmWq9/Cg9MTdBQWedLJpot8W68mJaJ4vxEUzvY8NOYIS1HbzM4MkUy8 cPi8fCumXQ6TVmIK8SpLnad68bfYvyDcxn2LMNiqIcG+qJdlgdOsxa7qx1gfo8PVAcCc GHrWk1OSr1B6iO8lNXaIKyKyHAg5UH+Uo/GQFW1ByVOXQ0ezVlp+oq0Tid7Y3f4XIH37 GSZWrv9GB1A0Zuh69dNU5LwV6dQJxO9qwGTIv4JjO+HKZ2bEC1t+x4nN99lpef/zxV6h zv2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eDgsRlqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o6si5956262edi.516.2021.09.21.08.26.18; Tue, 21 Sep 2021 08:26:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eDgsRlqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233821AbhIUPV4 (ORCPT + 99 others); Tue, 21 Sep 2021 11:21:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:53698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbhIUPV4 (ORCPT ); Tue, 21 Sep 2021 11:21:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3796061165; Tue, 21 Sep 2021 15:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632237627; bh=K9tYO1jmVq2LUM2bQC5dB72wuyvipiHa1/0bEGbnbeI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eDgsRlqSJmx87Wse4Be605BDRIx/qd8rceFANqA4PyYAEOB41sP34BA+uYPin5rVI CqJTHOZddviC44yWDJIVEHlHFQ2QkGPOKz+P0vjs7yzXsQCkNq+sc2mP8ZiJH2DZ70 GI9qVa0FEYpXhTgQYn6S98sMdzp1ZsQxB42Yati8= Date: Tue, 21 Sep 2021 17:20:23 +0200 From: Greg KH To: "Longpeng(Mike)" Cc: andraprs@amazon.com, lexnv@amazon.com, alcioa@amazon.com, linux-kernel@vger.kernel.org, arei.gonglei@huawei.com, kamal@canonical.com, pbonzini@redhat.com, sgarzare@redhat.com, stefanha@redhat.com, vkuznets@redhat.com, ne-devel-upstream@amazon.com Subject: Re: [PATCH v2 1/4] nitro_enclaves: merge contiguous physical memory regions Message-ID: References: <20210921151039.1502-1-longpeng2@huawei.com> <20210921151039.1502-2-longpeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210921151039.1502-2-longpeng2@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 11:10:36PM +0800, Longpeng(Mike) wrote: > There can be cases when there are more memory regions that need to be > set for an enclave than the maximum supported number of memory regions > per enclave. One example can be when the memory regions are backed by 2 > MiB hugepages (the minimum supported hugepage size). > > Let's merge the adjacent regions if they are physical contiguous. This > way the final number of memory regions is less than before merging and > could potentially avoid reaching maximum. > > Signed-off-by: Longpeng(Mike) I need a real (i.e. legal) name for a signed-off-by line please. > --- > drivers/virt/nitro_enclaves/ne_misc_dev.c | 87 ++++++++++++++++++++----------- > 1 file changed, 58 insertions(+), 29 deletions(-) > > diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c > index e21e1e8..a4776fc 100644 > --- a/drivers/virt/nitro_enclaves/ne_misc_dev.c > +++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c > @@ -126,6 +126,26 @@ struct ne_cpu_pool { > static struct ne_cpu_pool ne_cpu_pool; > > /** > + * struct phys_mem_region - Physical memory region > + * @paddr: The start physical address of the region. > + * @size: The sizeof of the region. > + */ > +struct phys_mem_region { > + u64 paddr; > + u64 size; > +}; > + > +/** > + * struct phys_contig_mem_region - Physical contiguous memory regions > + * @num: The number of regions that currently has. > + * @region: The array of physical memory regions. > + */ > +struct phys_contig_mem_region { > + unsigned long num; > + struct phys_mem_region region[0]; > +}; Why create your own structures and not use the in-kernel ones for stuff like this? What is wrong with the existing memory region or resource handling logic? thanks, greg k-h