From patchwork Tue Sep 13 12:55:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9328977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A2ED6077F for ; Tue, 13 Sep 2016 12:58:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E5F6292C4 for ; Tue, 13 Sep 2016 12:58:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52FB329409; Tue, 13 Sep 2016 12:58:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9E36429416 for ; Tue, 13 Sep 2016 12:58:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjnFp-0000kY-8I; Tue, 13 Sep 2016 12:56:01 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjnFn-0000kL-Am for xen-devel@lists.xen.org; Tue, 13 Sep 2016 12:55:59 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 86/25-27438-E57F7D75; Tue, 13 Sep 2016 12:55:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJIsWRWlGSWpSXmKPExsVyMfSOs27s9+v hBvMe6lgs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBl/G3azFLyTr5i49Dx7A+MqyS5GLg4hgX5G iUmn3rOAOCwCl1gkrvxbzQriSAi8Y5FYvHcmUxcjJ5ATI/F98wZmCLtEovt9BxuILSSgIjF3U w8jxKhpTBKLJp4DK2ITUJM48n4mUIIDqMFY4vnNHJCwiIChxORVf1lBbGYBS4nzGz6yg9jCAi 4Sl6Y9ArNZBFQl1pxvYQNp5RVwkFhwuhhirZzE9ZnTmSYw8i9gZFjFqFGcWlSWWqRrZK6XVJS ZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iREYQAxAsINx8drAQ4ySHExKorzz11wPF+JL yk+pzEgszogvKs1JLT7EKMPBoSTB6/kNKCdYlJqeWpGWmQMMZZi0BAePkghvBEiat7ggMbc4M x0idYrRmGPL72trmTi2Tb23lkmIJS8/L1VKnNcGpFQApDSjNA9uECzGLjHKSgnzMgKdJsRTkF qUm1mCKv+KUZyDUUmYdwHIFJ7MvBK4fa+ATmECOmXLGrBTShIRUlINjCEh6mvZxDffNzQPFIg 2fJwe+bGspFd6Xey3srdB3NNl4jefmCue9+99SbO7GtNd3qss1w1uNQq+WsflMFl8R5ulDNe9 M7dzO1Y7LnwqWLHqWu/mymnbn0akXlk+9e0VtU/nvtx8+LVrYsFvK2GfmfsnTZlf9ynklvfEi TKXF88XiVXpSNij3KTEUpyRaKjFXFScCACUO03GrAIAAA== X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-13.tower-21.messagelabs.com!1473771356!33031965!1 X-Originating-IP: [209.85.220.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54146 invoked from network); 13 Sep 2016 12:55:57 -0000 Received: from mail-pa0-f67.google.com (HELO mail-pa0-f67.google.com) (209.85.220.67) by server-13.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 13 Sep 2016 12:55:57 -0000 Received: by mail-pa0-f67.google.com with SMTP id h5so9209573pao.0 for ; Tue, 13 Sep 2016 05:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=elUQIdkSVmHlm0xBIk0CUmH/A+Mf0uqXqlpwxEeQ5RU=; b=kVe5kQzXa8g8mUDwvjIJdYAgpQDRq2fegB6QjCvKiS9i6KNBkjY+W28AfDC2o4rY1Q 0TvViumnt5NvfyA+Qfewdz81L9YtbFH7Emncu9g8ff11yQZSxEPzvtGdsG2yTrfR2zgi +c8LIZHYz97Ky6hVfPSLqpug3FmHCLBhq4nS0OVROSD+q8pYA4pi771TSiJbhq1Nu9WK elaCk5FuNlNcmbMPdtt4VybyAX2HRLY0qUyHBfYtu0ALdK6cs6d9Tj2WLaZYzSDxG/JN 6xKDXcrEt5qgHAQEWLCNEDFhvfFpiMZtA38D2r2RgG3Pezecpx6kJ/iG1pIJs1qKkl0b 4MpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=elUQIdkSVmHlm0xBIk0CUmH/A+Mf0uqXqlpwxEeQ5RU=; b=OXAZVU6inJjcqGa23h9DSkLzcSVL26cqEqo+PHmYX53iWTbYzDxKPwj3sHoQryz71z Pr5xxvwUxMq7TMz2mocg5IZQQehy+xT36u8h5UcRFy3e8AEdDOAwy3ZzvtOsAbqncLvG CpaeOWKR2zbHV+0wRGZku+/jRBahPQ+vCAGdzE42IeiMPXkPoJpfTWQvO3hH9FabMhf3 oizKtjvd9B1Cscml5kwBpqrUuNjWIlEKMmvHXI14n/5BySFi2s1Qnu+ndIypRVZqAjO4 I3aU57BGRKZrwyujA+LROE5Edk7J56VgXAlTZKhcvDOnBtHUyQYJohIZSaZEW/61BLKo 5dDQ== X-Gm-Message-State: AE9vXwPYpIRZMkBQzUnb7OFOhlSMXRikTdpLoBUkL9fYRGCfItAwyLJuhHbisoQtptI8uA== X-Received: by 10.66.5.5 with SMTP id o5mr1120781pao.38.1473771341130; Tue, 13 Sep 2016 05:55:41 -0700 (PDT) Received: from linux-u7w5.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id 12sm31206963pfu.28.2016.09.13.05.55.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 05:55:40 -0700 (PDT) From: Peng Fan X-Google-Original-From: Peng Fan To: sstabellini@kernel.org, julien.grall@arm.com Date: Tue, 13 Sep 2016 20:55:25 +0800 Message-Id: <1473771325-13232-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.6 Cc: Peng Fan , xen-devel@lists.xen.org Subject: [Xen-devel] [RFC] xen/arm: domain_build: introduce dom0_lowmem bootargs X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On AArch64 SoCs, some IPs may only have the capability to access 32bits address space. The physical memory assigned for Dom0 maybe not in 4GB address space, then the IPs will not work properly. Introduce dom0_lowmem bootargs, user could pass "dom0_lowmem=xx" to xen. It means how much memory user would like to be allocated in lower 4GB memory space. If there is not enough memory for dom0_lowmem, higher memory will be allocated. Thinking such a memory layout on an AArch64 SoC: Region 0: 2GB(0x80000000 - 0xffffffff) Region 1: 4GB(0x880000000 - 0x97fffffff) If user would like to assign 2GB for Dom0 and 1GB of the 2GB memory in Region 0, user could pass "dom0=2048M dom0_lowmem=1024M" to xen. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall --- This patch is to resolve the issue mentioned in https://lists.xen.org/archives/html/xen-devel/2016-09/msg00235.html This patch not tested on latest 4.8-unstable, I only tested similar patch on xen 4.7 on AArch64 platform. The idea of patch is that user could specify the lowmem that user would like to use. I rethought the ideas in https://lists.xen.org/archives/html/xen-devel/2016-09/msg00487.html, but that is not good. lowmem is precise, it maybe used for some IPs that maybe passthrough to DomU, so we only allocate the needed memory for Dom0. xen/arch/arm/domain_build.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 35ab08d..0f53bba 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -33,6 +33,8 @@ int dom0_11_mapping = 1; #define DOM0_MEM_DEFAULT 0x8000000 /* 128 MiB */ static u64 __initdata dom0_mem = DOM0_MEM_DEFAULT; +/* Only for AArch64 */ +static u64 __initdata dom0_lowmem; static void __init parse_dom0_mem(const char *s) { @@ -42,6 +44,12 @@ static void __init parse_dom0_mem(const char *s) } custom_param("dom0_mem", parse_dom0_mem); +static void __init parse_dom0_lowmem(const char *s) +{ + dom0_lowmem = parse_size_and_unit(s, &s); +} +custom_param("dom0_lowmem", parse_dom0_lowmem); + //#define DEBUG_11_ALLOCATION #ifdef DEBUG_11_ALLOCATION # define D11PRINT(fmt, args...) printk(XENLOG_DEBUG fmt, ##args) @@ -244,7 +252,7 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) unsigned int order = get_11_allocation_size(kinfo->unassigned_mem); int i; - bool_t lowmem = is_32bit_domain(d); + bool_t lowmem = is_32bit_domain(d) || !!dom0_lowmem; unsigned int bits; /* @@ -263,6 +271,9 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) * First try and allocate the largest thing we can as low as * possible to be bank 0. */ + if ( dom0_lowmem ) + order = get_order_from_bytes(dom0_lowmem); + while ( order >= min_low_order ) { for ( bits = order ; bits <= (lowmem ? 32 : PADDR_BITS); bits++ ) @@ -278,6 +289,11 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) got_bank0: + if ( dom0_lowmem ) { + dom0_lowmem -= pfn_to_paddr((1 << order)); + lowmem = is_32bit_domain(d) || !!dom0_lowmem; + } + if ( !insert_11_bank(d, kinfo, pg, order) ) BUG(); /* Cannot fail for first bank */ @@ -325,6 +341,16 @@ static void allocate_memory(struct domain *d, struct kernel_info *kinfo) } } + if ( dom0_lowmem && lowmem ) + { + dom0_lowmem -= pfn_to_paddr((1 << order)); + lowmem = is_32bit_domain(d) || !!dom0_lowmem; + } + else + { + lowmem = false; + } + /* * Success, next time around try again to get the largest order * allocation possible. @@ -2098,6 +2124,8 @@ int construct_dom0(struct domain *d) d->max_pages = ~0U; + BUG_ON(dom0_mem < dom0_lowmem); + kinfo.unassigned_mem = dom0_mem; rc = kernel_probe(&kinfo);