Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4124966yba; Tue, 23 Apr 2019 15:50:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2r3m0ORGBodJ5rVBa+q4pCUL+pWvSPAqL5LxmUDJmKo2LXijNzv2lGwYHvjhzFF9pUnjp X-Received: by 2002:a65:51c5:: with SMTP id i5mr5377345pgq.189.1556059851904; Tue, 23 Apr 2019 15:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556059851; cv=none; d=google.com; s=arc-20160816; b=Nwy1IMscsHq2eudVhczTmICkFZ1+daYD5B0Uv2vm/pPPJSxalQ3uov3vig9XG+1ec0 5e82MDvPBI7z0UwKmz2irkhEJRtGRc5u5RnHRZasoSck8ckaQRLJ+phfxtGsFDWRwOtZ H7y1q87cFGof22hY14Bsuz+5lnZ/B/e3KP55o7EqrOhRnq0VPtpCLkU368en+P0PiEEN ajow8f9xR38mkTiE18UGEpcGN2U4klULYtvjvg4awoGtBJ6qe9kH+N9MpMIWg+8stU/V aVson3TXd8FIZX5G9qcH2/AMmnehZ1YFLwP/mh3dzPq7lj0DXZcX3YJ/eB02ppFSOymk W4EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HJRvj8BujR+p5SOja4FAemkZIFG1n37I1t4IGxaN5rI=; b=KfScPjisC4IYIhpTAvDzMsMaZ2PLaI42D/1RgBtkxRcH2UL2i5BqeMiH6zKAYPBwfB 12nr4LIWUY5mRQcZRNLIEJF4XkS5Q98hyXCHSLuWyD9a66FjmhdKN3FciAaWZnv3uNdv JLXoNUFZA8ByrpTTPXiPwHxoirUddFtzNvOOoFIJXA4LNKzWLqa/bhJXRaJQHXoFFg1N ckotaUaSSpwMY6OqPZ3R4bl9YTRo2POMtT4DgsGrG/jpVFcv1L4JDazfX6CVBiaz6y+T DuM19Kuh5bzqiycwvTpoe9rwKkaUoEQafG1+5Ee8OJjhbikfiN74/oNk374ti2OcwxjI NgNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VHY48LhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si3554456pgp.433.2019.04.23.15.50.36; Tue, 23 Apr 2019 15:50:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VHY48LhM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728746AbfDWWti (ORCPT + 99 others); Tue, 23 Apr 2019 18:49:38 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46696 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728647AbfDWWtf (ORCPT ); Tue, 23 Apr 2019 18:49:35 -0400 Received: by mail-lf1-f68.google.com with SMTP id k18so12985303lfj.13; Tue, 23 Apr 2019 15:49:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HJRvj8BujR+p5SOja4FAemkZIFG1n37I1t4IGxaN5rI=; b=VHY48LhM8TNgdZneoiW3y8NkrZcdRSFuXgtVdkM2iPWLaxjrMRw4rE96YnsFQ07M4J AWYVCKEDNcEFOXjLZ2j7PtdunmbuhnwdaIXS9tdwv5rWB3iL0mXJMm481chlaFJ+QLmG x9wyok20vv7GlzltLfYRx4BhrZXJcjE0SI5nuvVJHENzkQ8D2VNZfQaH7RbrTEF7/JVR L6qlMVv5rcKbyVck7ddB6unYKfdZz02Zl6ujqiC35edvcsESnuXql+zbAAe2RNee1Iu8 Z7wBsMUcxy6d6IwRwvjc/0KXt/LrphI3gSBGOpG++jjcdnWbQ9Vxzsh89tJ3kW71MoYX mQtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HJRvj8BujR+p5SOja4FAemkZIFG1n37I1t4IGxaN5rI=; b=R3oWy11YLH80dvMmwF5HcrdEpe+rp4qmuC6gp22lnIdnjUHtYN1QqATBeA6z5qzcsh GTuOH/H4nfxzffmK4DJ2vDu4/ZFD3Mq5+9BjHdWPHXoqwrWvGS/xYu1Fi9ENDLqKCqpC nOPqQd9XEagVXdKTkbl6wZ/ZmrAKnaophyNSjuWrMxE5cbat0Tmtc2pLxoIwJ98nNKBk TVBkJtToOXck/6Q49UrJDXjAOa1ekfR83rcCe22Vty2LVVo4w642eiiUt990e7h1z9Ny dM1FRkIlblt8/fvK3uM6PO8JnsORnk4reuFI8KT6l+bVr0s1Ua1HY1rRzXClcRJqxO5A jy1g== X-Gm-Message-State: APjAAAUP7CGvQyL8bGNxcNCWQMj3nm/fgsxfJIhnDfOQvMAR9IOXkA8C XqfoxQdKJtlKPIX0R0Yhr/A= X-Received: by 2002:a19:7014:: with SMTP id h20mr15944340lfc.158.1556059772953; Tue, 23 Apr 2019 15:49:32 -0700 (PDT) Received: from localhost.localdomain ([5.164.240.123]) by smtp.gmail.com with ESMTPSA id w2sm4904722lfa.63.2019.04.23.15.49.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Apr 2019 15:49:32 -0700 (PDT) From: Serge Semin To: Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Mike Rapoport , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH 07/12] mips: Add reserve-nomap memory type support Date: Wed, 24 Apr 2019 01:47:43 +0300 Message-Id: <20190423224748.3765-8-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190423224748.3765-1-fancer.lancer@gmail.com> References: <20190423224748.3765-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It might be necessary to prevent the virtual mapping creation for a requested memory region. For instance there is a "no-map" property indicating exactly this feature. In this case we need to not only reserve the specified region by pretending it doesn't exist in the memory space, but completely remove the range from system just by removing it from memblock. The same way it's done in default early_init_dt_reserve_memory_arch() method. Signed-off-by: Serge Semin --- arch/mips/include/asm/bootinfo.h | 1 + arch/mips/kernel/prom.c | 4 +++- arch/mips/kernel/setup.c | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/mips/include/asm/bootinfo.h b/arch/mips/include/asm/bootinfo.h index a301a8f4bc66..235bc2f52113 100644 --- a/arch/mips/include/asm/bootinfo.h +++ b/arch/mips/include/asm/bootinfo.h @@ -92,6 +92,7 @@ extern unsigned long mips_machtype; #define BOOT_MEM_ROM_DATA 2 #define BOOT_MEM_RESERVED 3 #define BOOT_MEM_INIT_RAM 4 +#define BOOT_MEM_NOMAP 5 /* * A memory map that's built upon what was determined diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 93b8e0b4332f..437a174e3ef9 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -47,7 +47,9 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) int __init early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size, bool nomap) { - add_memory_region(base, size, BOOT_MEM_RESERVED); + add_memory_region(base, size, + nomap ? BOOT_MEM_NOMAP : BOOT_MEM_RESERVED); + return 0; } diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 3a5140943f54..2a1b2e7a1bc9 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -178,6 +178,7 @@ static bool __init __maybe_unused memory_region_available(phys_addr_t start, in_ram = true; break; case BOOT_MEM_RESERVED: + case BOOT_MEM_NOMAP: if ((start >= start_ && start < end_) || (start < start_ && start + size >= start_)) free = false; @@ -213,6 +214,9 @@ static void __init print_memory_map(void) case BOOT_MEM_RESERVED: printk(KERN_CONT "(reserved)\n"); break; + case BOOT_MEM_NOMAP: + printk(KERN_CONT "(nomap)\n"); + break; default: printk(KERN_CONT "type %lu\n", boot_mem_map.map[i].type); break; @@ -487,6 +491,9 @@ static void __init bootmem_init(void) switch (boot_mem_map.map[i].type) { case BOOT_MEM_RAM: break; + case BOOT_MEM_NOMAP: /* Discard the range from the system. */ + memblock_remove(PFN_PHYS(start), PFN_PHYS(end - start)); + continue; default: /* Reserve the rest of the memory types at boot time */ memblock_reserve(PFN_PHYS(start), PFN_PHYS(end - start)); break; @@ -861,6 +868,7 @@ static void __init resource_init(void) res->flags |= IORESOURCE_SYSRAM; break; case BOOT_MEM_RESERVED: + case BOOT_MEM_NOMAP: default: res->name = "reserved"; } -- 2.21.0