From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812905; cv=none; d=zohomail.com; s=zohoarc; b=CG4F39xIFd1iu8UnMf5CystNxezh3huEKQ0FaucqjWBqaZV6Lg2f+NAuVUmF3cBrVgSjED4Rcmky1MAKm+RYFVGri1zIA9FxVjGP6bMwHr63iPW/EACFgZ+t7/W+clrM2HWnv2keTLo2i45BugXvT8jNHK0fpp5nc0VBnqm0LIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812905; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=n+a9yOVUI+xS4AJamh0RTQNrcJQmW3VHc9oZb3bl7Og=; b=KTsQJfmsTLIF3B75tbB1mlPITDANCkfJrLhicgAPTFmJFcPH9dUdExJw9MGvOqO521GLcckMlSDlWLhCDLLDHMZ9P6XWnIXMSdR8tkjwYb8gS5kCif2YubI1HUH7l3CREapxJUqLfdnAJCH5xEbkzS+6z57+Yhv3sWgcwuw4OSs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605812905786834.9826375332588; Thu, 19 Nov 2020 11:08:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31362.61693 (Exim 4.92) (envelope-from ) id 1kfpHh-0005XI-PO; Thu, 19 Nov 2020 19:07:57 +0000 Received: by outflank-mailman (output) from mailman id 31362.61693; Thu, 19 Nov 2020 19:07:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0005XB-MD; Thu, 19 Nov 2020 19:07:57 +0000 Received: by outflank-mailman (input) for mailman id 31362; Thu, 19 Nov 2020 19:07:56 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHg-0005X0-36 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:56 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHf-0003Sd-Hx; Thu, 19 Nov 2020 19:07:55 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHf-0000TE-7B; Thu, 19 Nov 2020 19:07:55 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHg-0005X0-36 for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:56 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHf-0003Sd-Hx; Thu, 19 Nov 2020 19:07:55 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHf-0000TE-7B; Thu, 19 Nov 2020 19:07:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=n+a9yOVUI+xS4AJamh0RTQNrcJQmW3VHc9oZb3bl7Og=; b=obXqYpSTe3KR4qspumZnA7LdO XskxTBDOrMLk8fcuIB3bI/01mQ7lrNeckM5L35jFgoBYHQyNC4w+kXXPFR7Qg/oLuXAxdsFNGIYMN L5Eafa5pMWhEBkU7tP2bA73RmECaelgz8BthzRWpcc52VXS769fL+gz1+eRKXeIqRm05A=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Stefano Stabellini , Julien Grall Subject: [PATCH RFC 1/6] xen/arm: mm: Remove special case for CPU0 in dump_hyp_walk() Date: Thu, 19 Nov 2020 19:07:46 +0000 Message-Id: <20201119190751.22345-2-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Stefano Stabellini There is no need to have a special case for CPU0 when converting the page-table virtual address into a physical address. The helper virt_to_maddr() is able to translate any address as long as the root page-tables is mapped in the virtual address. This is the case for all the CPUs at the moment. So use the same BUG_ON() regardless the CPU. Signed-off-by: Stefano Stabellini [julien: Rework the commit message] Signed-off-by: Julien Grall Reviewed-by: Bertrand Marquis --- I went back through the conversation in [1] regarding the issue when loading Xen below 2MB on Arm32. The example provided is wrong because to find the physical address, we need to add 'phys_offset', not substract. So I removed the comment regarding the code was buggy. [1] https://marc.info/?l=3Dxen-devel&m=3D157081398022401 --- xen/arch/arm/mm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 9c4b26bf079b..4dd886f7c80d 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -284,10 +284,7 @@ void dump_hyp_walk(vaddr_t addr) "on CPU%d via TTBR 0x%016"PRIx64"\n", addr, smp_processor_id(), ttbr); =20 - if ( smp_processor_id() =3D=3D 0 ) - BUG_ON( (lpae_t *)(unsigned long)(ttbr - phys_offset) !=3D pgtable= ); - else - BUG_ON( virt_to_maddr(pgtable) !=3D ttbr ); + BUG_ON( virt_to_maddr(pgtable) !=3D ttbr ); dump_pt_walk(ttbr, addr, HYP_PT_ROOT_LEVEL, 1); } =20 --=20 2.17.1 From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812906; cv=none; d=zohomail.com; s=zohoarc; b=D5HpH/4FBS2NIOxSXOyuNlBLAA5TKdG6sYptvReKCgBIaxiv+SSAwPAObt86TGtKgkacMVc83ocqP/7qoEf4ocQM8yu9ZC7z8tzFctL0Y3A+T2y/m9ROrRihwTjwrZ2Eo71Fp92Wsrb/UoQz4HnkXUHo13ZW09bZWi9zxrjZXZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812906; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=cmOxqGi+9sZD6PnyoF8KEWd7i5yr+UWn5KmlxEDs9uo=; b=cKYo34y8s09m5Fw36r2ctMneQLnF360pKvkDkiqTCmG8PgVsGMBAWsvL29XLQCxezZEK/DjDvGSyZC68bzuZIqIaSbuS3r7XpNeppNaI1wHmqkWww1xITvCc95EzbIFEXi5MBvEsLbCyV6gm6KAtYVPbex2HFGyyOKIwHlL7Lvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 160581290644756.056270479649015; Thu, 19 Nov 2020 11:08:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31363.61698 (Exim 4.92) (envelope-from ) id 1kfpHi-0005Xj-25; Thu, 19 Nov 2020 19:07:58 +0000 Received: by outflank-mailman (output) from mailman id 31363.61698; Thu, 19 Nov 2020 19:07:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0005Xc-UF; Thu, 19 Nov 2020 19:07:57 +0000 Received: by outflank-mailman (input) for mailman id 31363; Thu, 19 Nov 2020 19:07:57 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0005X6-0z for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:57 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHg-0003Sl-LJ; Thu, 19 Nov 2020 19:07:56 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHg-0000TE-Ct; Thu, 19 Nov 2020 19:07:56 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0005X6-0z for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:57 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHg-0003Sl-LJ; Thu, 19 Nov 2020 19:07:56 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHg-0000TE-Ct; Thu, 19 Nov 2020 19:07:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=cmOxqGi+9sZD6PnyoF8KEWd7i5yr+UWn5KmlxEDs9uo=; b=Lb5VWktyWuxQbfI5AHpyAtvVK HPNbZUKsS1qxJyI+SzqO232NQnYpoo09mDrz5bqngnpw/B/4vG56k9gTPj51G+9kzsruNO0zzrElP Zg2FaikhScAI3HIQd8larppXIcOCHy2junX6L536ItQ1xhACDfGt8R432A9pFvCPJve7k=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH RFC 2/6] xen/arm: mm: Remove ; at the end of mm_printk() Date: Thu, 19 Nov 2020 19:07:47 +0000 Message-Id: <20201119190751.22345-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall The ; at the end of mm_printk() means the following code will not build correctly: if ( ... ) mm_printk(...); else ... As we treat the macro as a function, we want to remove the ; at the end of it. Signed-off-by: Julien Grall Reviewed-by: Bertrand Marquis Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 4dd886f7c80d..59f8a3f15fd1 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -59,7 +59,7 @@ mm_printk(const char *fmt, ...) {} { \ dprintk(XENLOG_ERR, fmt, ## args); \ WARN(); \ - } while (0); + } while (0) #endif =20 /* --=20 2.17.1 From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812905; cv=none; d=zohomail.com; s=zohoarc; b=hIYil0Tqgip7b8NXdPCHZpiyKYuLZlI6FRgIj4HWJbgaPb76pxmg5sLHl4h67ceS6J+gXZkYeBOqkQ41ytkFF7wC+pbhe4QihkmZewW4Eilyliweqwt/JTX/IHxkSW75OMn30iA6GOXSKrCUv1BwscYoE3rpyORSeV8rax25cbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812905; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=OboHhEHEvSZ64fH4mO7AsxamLOG7CeMXAAQmTYLPwD0=; b=nAxNQ+Wa37LEx16mermW/PnOeNLS3cWfSgVAMI6Kuq7fM5H7QlAi9rygzT2O+0J7JLWc7L9cAmabxjqS92IZ3xY86FCCHIQwC7psZ+zK+Gxys++sv9k2fbf3FKA9DuQak7HW8z5PBHGZblTp8FgztFum6lik1IRM9qVc0fyZ0xY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605812905752545.6045753641034; Thu, 19 Nov 2020 11:08:25 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31364.61717 (Exim 4.92) (envelope-from ) id 1kfpHk-0005aV-Bg; Thu, 19 Nov 2020 19:08:00 +0000 Received: by outflank-mailman (output) from mailman id 31364.61717; Thu, 19 Nov 2020 19:08:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0005aN-7Y; Thu, 19 Nov 2020 19:08:00 +0000 Received: by outflank-mailman (input) for mailman id 31364; Thu, 19 Nov 2020 19:07:58 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHi-0005Y6-3U for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:58 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0003Ss-Qi; Thu, 19 Nov 2020 19:07:57 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHh-0000TE-Ia; Thu, 19 Nov 2020 19:07:57 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHi-0005Y6-3U for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:58 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHh-0003Ss-Qi; Thu, 19 Nov 2020 19:07:57 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHh-0000TE-Ia; Thu, 19 Nov 2020 19:07:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=OboHhEHEvSZ64fH4mO7AsxamLOG7CeMXAAQmTYLPwD0=; b=nxMldoX8fo6JIFDoFUq3JXAQZ IirT47R30UvlFUhhaYsFHvyUpOZfY8QNrNlbch3PqDjSe/IyEhNkZrV6yMbjtarBnjdiPawRBKqL0 DeqnHdJXGjt3NvT11mgBXw/dw3+S1x2I8oRis0OguvPO90nfTbP60ojmlWm2Psdr8fvFw=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH RFC 3/6] xen/arm: setup: Call unregister_init_virtual_region() after the last init function Date: Thu, 19 Nov 2020 19:07:48 +0000 Message-Id: <20201119190751.22345-4-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall discard_init_modules() is an init function, if the path contains a BUG() or WARN() we still want to get the full stack trace. The init virtual region is now kept after the last init function has been called. Signed-off-by: Julien Grall Reviewed-by: Bertrand Marquis --- xen/arch/arm/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 7fcff9af2a7e..2532ec973913 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -72,10 +72,11 @@ domid_t __read_mostly max_init_domid; =20 static __used void init_done(void) { + discard_initial_modules(); + /* Must be done past setting system_state. */ unregister_init_virtual_region(); =20 - discard_initial_modules(); free_init_memory(); startup_cpu_idle_loop(); } --=20 2.17.1 From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812908; cv=none; d=zohomail.com; s=zohoarc; b=RB04ZoAP1FrkABGD1UfzPB9dmvw4Py3M94UdHIkRcg0p5QVd0gfSx1LFw38bgnaQVFYeetKOiiSZFp+wW4T7FotgfB4PI855rjjq7pTrxdY6oqw0FIDJca7WMK3OWKM1CxrECMf8+tujaabvFMw8pzbSYP4587qT6+Mq8YyRys4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812908; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=JVCtMkS3vhD4oIjsLKCddPmn6X/R7AsIbb0WSv2njxY=; b=lxFBI2/qkD+Si2kW0aNIji4kU0zerq/guqRrt1e/PLXw1XT9M3SczYpBYgaxnEitWA9D6ujBTlpsLbQFvljDX9igOR590ndQGoXk2Nkj4nP3bc0DUNwkKr/IHb70eHkkskjPvswmf1xiZD1xNWg/rdX3Dcm5nv+6OJx551cnCBs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605812908520975.4466861974037; Thu, 19 Nov 2020 11:08:28 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31365.61725 (Exim 4.92) (envelope-from ) id 1kfpHk-0005bN-R3; Thu, 19 Nov 2020 19:08:00 +0000 Received: by outflank-mailman (output) from mailman id 31365.61725; Thu, 19 Nov 2020 19:08:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0005b1-IG; Thu, 19 Nov 2020 19:08:00 +0000 Received: by outflank-mailman (input) for mailman id 31365; Thu, 19 Nov 2020 19:07:59 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHj-0005ZJ-4f for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:59 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHi-0003T0-VT; Thu, 19 Nov 2020 19:07:58 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHi-0000TE-OH; Thu, 19 Nov 2020 19:07:58 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHj-0005ZJ-4f for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:07:59 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHi-0003T0-VT; Thu, 19 Nov 2020 19:07:58 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHi-0000TE-OH; Thu, 19 Nov 2020 19:07:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=JVCtMkS3vhD4oIjsLKCddPmn6X/R7AsIbb0WSv2njxY=; b=eUfW4TcRvPrmP4Ulje9fZClxy 3cLEFCVtKsnHLTT9zFmGK5ZsU3AAiuw5tKfLFGZYSr+vzUnvX6eGkqpsh4av2NavyKJz7o43/hHqc QGDWkDNI18910ne9fTRfcWcGOiHPsOBkQwAE71wMAkBXg5hNCMF+qtkXn4jAGlypMJjYM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH RFC 4/6] xen/arm: mm: Allow other mapping size in xen_pt_update_entry() Date: Thu, 19 Nov 2020 19:07:49 +0000 Message-Id: <20201119190751.22345-5-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall At the moment, xen_pt_update_entry() only supports mapping at level 3 (i.e 4KB mapping). While this is fine for most of the runtime helper, the boot code will require to use superpage mapping. We don't want to allow superpage mapping by default as some of the callers may expect small mappings (i.e populate_pt_range()) or even expect to unmap only a part of a superpage. To keep the code simple, a new flag _PAGE_BLOCK is introduced to allow the caller to enable superpage mapping. As the code doesn't support all the combinations, xen_pt_check_entry() is extended to take into account the cases we don't support when using block mapping: - Replacing a table with a mapping. This may happen if region was first mapped with 4KB mapping and then later on replaced with a 2MB (or 1GB mapping) - Removing/modify a table. This may happen if a caller try to remove a region with _PAGE_BLOCK set when it was created without it Note that the current restriction mean that the caller must ensure that _PAGE_BLOCK is consistently set/cleared across all the updates on a given virtual region. This ought to be fine with the expected use-cases. More rework will be necessary if we wanted to remove the restrictions. Note that nr_mfns is now marked const as it is used for flushing the TLBs and we don't want it to be modified. Signed-off-by: Julien Grall --- This patch is necessary for upcoming changes in the MM code. I would like to remove most of the open-coding update of the page-tables as they are not easy to properly fix/extend. For instance, always mapping xenheap mapping with 1GB superpage is plain wrong because: - RAM regions are not always 1GB aligned (such as on RPI 4) and we may end up to map MMIO with cacheable attributes - RAM may contain reserved regions should either not be mapped --- xen/arch/arm/mm.c | 87 ++++++++++++++++++++++++++++++-------- xen/include/asm-arm/page.h | 4 ++ 2 files changed, 73 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 59f8a3f15fd1..af0f12b6e6d3 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1060,9 +1060,10 @@ static int xen_pt_next_level(bool read_only, unsigne= d int level, } =20 /* Sanity check of the entry */ -static bool xen_pt_check_entry(lpae_t entry, mfn_t mfn, unsigned int flags) +static bool xen_pt_check_entry(lpae_t entry, mfn_t mfn, unsigned int level, + unsigned int flags) { - /* Sanity check when modifying a page. */ + /* Sanity check when modifying an entry. */ if ( (flags & _PAGE_PRESENT) && mfn_eq(mfn, INVALID_MFN) ) { /* We don't allow modifying an invalid entry. */ @@ -1072,6 +1073,13 @@ static bool xen_pt_check_entry(lpae_t entry, mfn_t m= fn, unsigned int flags) return false; } =20 + /* We don't allow modifying a table entry */ + if ( !lpae_is_mapping(entry, level) ) + { + mm_printk("Modifying a table entry is not allowed.\n"); + return false; + } + /* We don't allow changing memory attributes. */ if ( entry.pt.ai !=3D PAGE_AI_MASK(flags) ) { @@ -1087,7 +1095,7 @@ static bool xen_pt_check_entry(lpae_t entry, mfn_t mf= n, unsigned int flags) return false; } } - /* Sanity check when inserting a page */ + /* Sanity check when inserting a mapping */ else if ( flags & _PAGE_PRESENT ) { /* We should be here with a valid MFN. */ @@ -1096,18 +1104,28 @@ static bool xen_pt_check_entry(lpae_t entry, mfn_t = mfn, unsigned int flags) /* We don't allow replacing any valid entry. */ if ( lpae_is_valid(entry) ) { - mm_printk("Changing MFN for a valid entry is not allowed (%#"P= RI_mfn" -> %#"PRI_mfn").\n", - mfn_x(lpae_get_mfn(entry)), mfn_x(mfn)); + if ( lpae_is_mapping(entry, level) ) + mm_printk("Changing MFN for a valid entry is not allowed (= %#"PRI_mfn" -> %#"PRI_mfn").\n", + mfn_x(lpae_get_mfn(entry)), mfn_x(mfn)); + else + mm_printk("Trying to replace a table with a mapping.\n"); return false; } } - /* Sanity check when removing a page. */ + /* Sanity check when removing a mapping. */ else if ( (flags & (_PAGE_PRESENT|_PAGE_POPULATE)) =3D=3D 0 ) { /* We should be here with an invalid MFN. */ ASSERT(mfn_eq(mfn, INVALID_MFN)); =20 - /* We don't allow removing page with contiguous bit set. */ + /* We don't allow removing a table */ + if ( lpae_is_table(entry, level) ) + { + mm_printk("Removing a table is not allowed.\n"); + return false; + } + + /* We don't allow removing a mapping with contiguous bit set. */ if ( entry.pt.contig ) { mm_printk("Removing entry with contiguous bit set is not allow= ed.\n"); @@ -1126,12 +1144,12 @@ static bool xen_pt_check_entry(lpae_t entry, mfn_t = mfn, unsigned int flags) } =20 static int xen_pt_update_entry(mfn_t root, unsigned long virt, - mfn_t mfn, unsigned int flags) + mfn_t mfn, unsigned int page_order, + unsigned int flags) { int rc; unsigned int level; - /* We only support 4KB mapping (i.e level 3) for now */ - unsigned int target =3D 3; + unsigned int target =3D 3 - (page_order / LPAE_SHIFT); lpae_t *table; /* * The intermediate page tables are read-only when the MFN is not valid @@ -1186,7 +1204,7 @@ static int xen_pt_update_entry(mfn_t root, unsigned l= ong virt, entry =3D table + offsets[level]; =20 rc =3D -EINVAL; - if ( !xen_pt_check_entry(*entry, mfn, flags) ) + if ( !xen_pt_check_entry(*entry, mfn, level, flags) ) goto out; =20 /* If we are only populating page-table, then we are done. */ @@ -1204,8 +1222,11 @@ static int xen_pt_update_entry(mfn_t root, unsigned = long virt, { pte =3D mfn_to_xen_entry(mfn, PAGE_AI_MASK(flags)); =20 - /* Third level entries set pte.pt.table =3D 1 */ - pte.pt.table =3D 1; + /* + * First and second level pages set pte.pt.table =3D 0, but + * third level entries set pte.pt.table =3D 1. + */ + pte.pt.table =3D (level =3D=3D 3); } else /* We are updating the permission =3D> Copy the current pte. = */ pte =3D *entry; @@ -1229,11 +1250,12 @@ static DEFINE_SPINLOCK(xen_pt_lock); =20 static int xen_pt_update(unsigned long virt, mfn_t mfn, - unsigned long nr_mfns, + const unsigned long nr_mfns, unsigned int flags) { int rc =3D 0; - unsigned long addr =3D virt, addr_end =3D addr + nr_mfns * PAGE_SIZE; + unsigned long vfn =3D paddr_to_pfn(virt); + unsigned long left =3D nr_mfns; =20 /* * For arm32, page-tables are different on each CPUs. Yet, they share @@ -1265,14 +1287,43 @@ static int xen_pt_update(unsigned long virt, =20 spin_lock(&xen_pt_lock); =20 - for ( ; addr < addr_end; addr +=3D PAGE_SIZE ) + while ( left ) { - rc =3D xen_pt_update_entry(root, addr, mfn, flags); + unsigned int order; + unsigned long mask; + + /* + * Don't take into account the MFN when removing mapping (i.e + * MFN_INVALID) to calculate the correct target order. + * + * XXX: Support superpage mappings if nr is not aligned to a + * superpage size. + */ + mask =3D !mfn_eq(mfn, INVALID_MFN) ? mfn_x(mfn) : 0; + mask |=3D vfn | left; + + /* + * Always use level 3 mapping unless the caller request block + * mapping. + */ + if ( likely(!(flags & _PAGE_BLOCK)) ) + order =3D THIRD_ORDER; + else if ( !(mask & (BIT(FIRST_ORDER, UL) - 1)) ) + order =3D FIRST_ORDER; + else if ( !(mask & (BIT(SECOND_ORDER, UL) - 1)) ) + order =3D SECOND_ORDER; + else + order =3D THIRD_ORDER; + + rc =3D xen_pt_update_entry(root, pfn_to_paddr(vfn), mfn, order, fl= ags); if ( rc ) break; =20 + vfn +=3D 1U << order; if ( !mfn_eq(mfn, INVALID_MFN) ) - mfn =3D mfn_add(mfn, 1); + mfn =3D mfn_add(mfn, 1U << order); + + left -=3D (1U << order); } =20 /* diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 4ea8e97247c8..de096b0968e3 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -79,6 +79,7 @@ * [3:4] Permission flags * [5] Page present * [6] Only populate page tables + * [7] Use any level mapping only (i.e. superpages is allowed) */ #define PAGE_AI_MASK(x) ((x) & 0x7U) =20 @@ -92,6 +93,9 @@ #define _PAGE_PRESENT (1U << 5) #define _PAGE_POPULATE (1U << 6) =20 +#define _PAGE_BLOCK_BIT 7 +#define _PAGE_BLOCK (1U << _PAGE_BLOCK_BIT) + /* * _PAGE_DEVICE and _PAGE_NORMAL are convenience defines. They are not * meant to be used outside of this header. --=20 2.17.1 From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812909; cv=none; d=zohomail.com; s=zohoarc; b=MCyJLcJI1uZsuCWEH9wC6vqEzGA+Vdoc0KQtdo724wJaiul37I8vjPPLt+xVvaw7uI8gm2gjx6POKOS2/m2p94EF6YiQe98r7t1nIRWB31sM/Vebusj9dcoMXjw0JLCkDKO9fgxU+lJTM06Y6YytEil70ukxQiTwsIy5W85wd1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812909; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=OFTW7+XoUzoZJqOmYFJ6tvN5l1t/e5UfO6wPacf/RUI=; b=fXQhLefubXz2vzdgqy+aeLQQPn0dDx9oq4PJTbGLYBHWIxAgAb+AM8bJ9qpqJcqzacj0ZQ9kaPKvUOAUa7GXaPoIMUZ5+vExbe57fidUGvhh7hMpQXGq2joUP7RGdDTjKt/AbDw5/kUlsCSY534BpzCFeGW5xsK58Qoz8FH+jZs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605812909145535.0791537313439; Thu, 19 Nov 2020 11:08:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31366.61741 (Exim 4.92) (envelope-from ) id 1kfpHm-0005e6-4M; Thu, 19 Nov 2020 19:08:02 +0000 Received: by outflank-mailman (output) from mailman id 31366.61741; Thu, 19 Nov 2020 19:08:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHl-0005dw-Va; Thu, 19 Nov 2020 19:08:01 +0000 Received: by outflank-mailman (input) for mailman id 31366; Thu, 19 Nov 2020 19:08:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0005bQ-KF for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:08:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0003TA-8e; Thu, 19 Nov 2020 19:08:00 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHk-0000TE-1g; Thu, 19 Nov 2020 19:08:00 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0005bQ-KF for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:08:00 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHk-0003TA-8e; Thu, 19 Nov 2020 19:08:00 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHk-0000TE-1g; Thu, 19 Nov 2020 19:08:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=OFTW7+XoUzoZJqOmYFJ6tvN5l1t/e5UfO6wPacf/RUI=; b=0DpbZfK/HWJzMuVRx7orNGkBS 57IMf9WdvCWoIx4VzwZG/bZ5zb5qDQcM9bGlX879p6AbGFSr4LwnZmTi3N/dMVnEjY4jCb2snnRNi oMoZTEdFPbvcYBmp5RP4oj+GnnwCVDZrA/coXE5hrf28LGh+cd99Okc1sMszTev8e7HB4=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Julien Grall Subject: [PATCH RFC 5/6] xen/arm: mm: Don't open-code Xen PT update in remove_early_mappings Date: Thu, 19 Nov 2020 19:07:50 +0000 Message-Id: <20201119190751.22345-6-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Now that xen_pt_update_entry() is able to deal with different mapping size, we can replace the open-coding of the page-tables update by a call to modify_xen_mappings(). As the function is not meant to fail, a BUG_ON is added to check the return. Signed-off-by: Julien Grall Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/mm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index af0f12b6e6d3..aee6d410ac4f 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -598,11 +598,11 @@ void * __init early_fdt_map(paddr_t fdt_paddr) =20 void __init remove_early_mappings(void) { - lpae_t pte =3D {0}; - write_pte(xen_second + second_table_offset(BOOT_FDT_VIRT_START), pte); - write_pte(xen_second + second_table_offset(BOOT_FDT_VIRT_START + SZ_2M= ), - pte); - flush_xen_tlb_range_va(BOOT_FDT_VIRT_START, BOOT_FDT_SLOT_SIZE); + int rc; + + rc =3D modify_xen_mappings(BOOT_FDT_VIRT_START, BOOT_FDT_VIRT_END, + _PAGE_BLOCK); + BUG_ON(rc); } =20 /* --=20 2.17.1 From nobody Sat Apr 20 14:20:07 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1605812909; cv=none; d=zohomail.com; s=zohoarc; b=iGKeuoKcfyYwG193crR4hmrqM1p41eDp1KQLmYEq69wXFqphMOgyZtV9YJkwLsSvygbL764lUQy0RBrStIQTZUR1WmqcboRNaqFO/FbGcTaCa3N+CrYT3ZQycpq8bnhb81da1NdGn155DnwFWLInriN0VeIGFSSJtqjtuuTa3iM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605812909; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=qv0miUVBKz6uIh+FSZC0kOfLNz+frFcB+3hoEnxh+9s=; b=FyuH4KsOnZCVg3dolaEUqHR4n/Bd3Z7qbhUjfb+W/ICplxL9yzgSE6dtFoLYyTlxMrodMVILETAIvngAwCaT87UrZQe2j5RHh7hSMdCUh9sfoMdhAns+ieBiHPNXWB9CzSOL/g/Ob2lgzLVXUvDEe8mxQ7FaW1lP3kmsdxBhgGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1605812909448837.7360313946708; Thu, 19 Nov 2020 11:08:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.31367.61753 (Exim 4.92) (envelope-from ) id 1kfpHn-0005gi-HA; Thu, 19 Nov 2020 19:08:03 +0000 Received: by outflank-mailman (output) from mailman id 31367.61753; Thu, 19 Nov 2020 19:08:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHn-0005gX-Bv; Thu, 19 Nov 2020 19:08:03 +0000 Received: by outflank-mailman (input) for mailman id 31367; Thu, 19 Nov 2020 19:08:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHl-0005de-Nl for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:08:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHl-0003TU-Ep; Thu, 19 Nov 2020 19:08:01 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHl-0000TE-7K; Thu, 19 Nov 2020 19:08:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHl-0005de-Nl for xen-devel@lists.xenproject.org; Thu, 19 Nov 2020 19:08:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kfpHl-0003TU-Ep; Thu, 19 Nov 2020 19:08:01 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfpHl-0000TE-7K; Thu, 19 Nov 2020 19:08:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=qv0miUVBKz6uIh+FSZC0kOfLNz+frFcB+3hoEnxh+9s=; b=zL91chzf8hZBUIw5w4SKJJCD1 W/X7Rm/ungjPoPdwz8RLEZO8sUiZWA7VPaYJjnzH1tDtMwldOMDVQ7vxl8g14t32Vh6GS1ZF8E0s6 piSb7LB0PqXXVptGpcTy159/CJZiKSLrcG4O7QFfpFifsZrcDgxk4XWSvPv/A/gPKu7xs=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: bertrand.marquis@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH RFC 6/6] xen/arm: mm: Re-implement early_fdt_map() using map_pages_to_xen() Date: Thu, 19 Nov 2020 19:07:51 +0000 Message-Id: <20201119190751.22345-7-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201119190751.22345-1-julien@xen.org> References: <20201119190751.22345-1-julien@xen.org> X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Now that map_pages_to_xen() has been extended to support 2MB mappings, we can replace the create_mappings() calls by map_pages_to_xen() calls. The mapping can also be marked read-only as Xen as no business to modify the host Device Tree. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/mm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index aee6d410ac4f..37ea9d5ce20a 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -558,6 +558,7 @@ void * __init early_fdt_map(paddr_t fdt_paddr) paddr_t offset; void *fdt_virt; uint32_t size; + int rc; =20 /* * Check whether the physical FDT address is set and meets the minimum @@ -573,8 +574,12 @@ void * __init early_fdt_map(paddr_t fdt_paddr) /* The FDT is mapped using 2MB superpage */ BUILD_BUG_ON(BOOT_FDT_VIRT_START % SZ_2M); =20 - create_mappings(xen_second, BOOT_FDT_VIRT_START, paddr_to_pfn(base_pad= dr), - SZ_2M >> PAGE_SHIFT, SZ_2M); + rc =3D map_pages_to_xen(BOOT_FDT_VIRT_START, maddr_to_mfn(base_paddr), + SZ_2M >> PAGE_SHIFT, + PAGE_HYPERVISOR_RO | _PAGE_BLOCK); + if ( rc ) + panic("Unable to map the device-tree.\n"); + =20 offset =3D fdt_paddr % SECOND_SIZE; fdt_virt =3D (void *)BOOT_FDT_VIRT_START + offset; @@ -588,9 +593,12 @@ void * __init early_fdt_map(paddr_t fdt_paddr) =20 if ( (offset + size) > SZ_2M ) { - create_mappings(xen_second, BOOT_FDT_VIRT_START + SZ_2M, - paddr_to_pfn(base_paddr + SZ_2M), - SZ_2M >> PAGE_SHIFT, SZ_2M); + rc =3D map_pages_to_xen(BOOT_FDT_VIRT_START + SZ_2M, + maddr_to_mfn(base_paddr + SZ_2M), + SZ_2M >> PAGE_SHIFT, + PAGE_HYPERVISOR_RO | _PAGE_BLOCK); + if ( rc ) + panic("Unable to map the device-tree\n"); } =20 return fdt_virt; --=20 2.17.1