Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp524310lqm; Wed, 1 May 2024 07:54:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX4g6WsiD6/g/49i9YZvgLVb7NzBCeGEHMdm6eVcniW2B4lUKICILzkCVzdjRxoRLqssgDoTGR1tpwDhhu9ZDxE2WGFyYso1awFiruUYQ== X-Google-Smtp-Source: AGHT+IG8rcR6AzdnR1iPE+3IDofAtiu6r2PiJc7mXjUg4xD2sEzfRxcvBeZTOBtscs7U4EflDVzt X-Received: by 2002:a17:906:b14d:b0:a58:c277:345c with SMTP id bt13-20020a170906b14d00b00a58c277345cmr1815493ejb.7.1714575263075; Wed, 01 May 2024 07:54:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714575263; cv=pass; d=google.com; s=arc-20160816; b=Q13UyK7E5R3xRipBCGUrT/ATBLNZw1yx7Eq3yI98AI09WbgrG4j/dDkEm7Ak+CIjmT lUvRuHuT1URQh2c4/DNHEtJ0rPhZsf3DUYckvqHBmG8n6kjRAdjUPGLEJQrbZGRJgam7 iYK5mkBlMXeMyS8PT0wwI4ucYAmzpjmB2dI8N6+Bst/ZvhcZTjaFzaHRgfEFRdPn7xSM F/Zou1LCrm+fbuDFTwedRDziiMnK/azjC1N696RKpspdvctiGtW1qLu83OIDycv+E+mY zo8CgD1GXICp0lobdofkiqZDAk6/1RKOBfK8C3Q/0XEh59kP+KSpWp/uDfTUnxfXEJyW N7Qw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=YYiIHh1vkbrVczqW6F+I7b5XAIs7+3/gHcL/AsSCwYg=; fh=0Hoz004CVqkSauOcyGo6w+Nffyo2aMpqRBWyE8Xt3B8=; b=rSXrHhzuOvhA1bJAXThiiSQS0luiv69TEPeRpd6GgRQ3c3LgZGEgV3XRkt+cgBh2qy NndM63cTsENJ428+y8qUrjAk/NIm8k1uWFdTfMlfJm0iabdCUIyZYhO7uys6CowQczrB 60MwVYpi9BJW9ql4Delr4UCD3t8VK8SKE0MRnV7wh38Pa+Njm4wgv2ieateyD/9GMPf5 d/FMp4bkPK7JesfnuVyhNFQQJp2wjNf2h5A/KkPdUe/+1S5OpZr1wjBfu3zJPEJRPz1K hKw3uHRHr5T4wbg3uiMTqs3b++RODMEv1JwYemD7OsU49sy5h1sXBC0WvXfAZnoFIeaO A49w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-165391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165391-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i23-20020a170906251700b00a4745ab9cb1si15913727ejb.847.2024.05.01.07.54.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 07:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-165391-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165391-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BE57B1F22CBA for ; Wed, 1 May 2024 14:54:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D3F2B12EBEF; Wed, 1 May 2024 14:54:15 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53B2312E6A; Wed, 1 May 2024 14:54:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714575255; cv=none; b=T9+smeqho1vhoq/Na6f6EOPC5pdietggFKCDzFSLz7SB5rdyyTtIuJyOeqJfNolUBW0f+5xa1tJJSccK1H0LzuIAYV5KyotyA0NqBEbS696IFQ7MBlBDCdh+YKNQIVhEmhj99EtUigFvPuJlWXwuWrWIRc/C5Spp3G1FVXlFa5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714575255; c=relaxed/simple; bh=kh+wjNGTe3rkosFU5tIMQvZ6bZ/Ezmwl/V7rTuuidyU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PWhH+HRD0AAZVDgvTPZqmmn+ZgWpydlRgySV4ZEl6NuRNCtm0JybYp+axPeLcy5eZxwg02Lyjxx+9GE37JovOMTH6hWtBDwsw4ulo5KQYQfZfS8h5M0b/4XW8AgmLWjOOGPHkCQ4nsuhjJZxXRlyu1Wvec5MayUTDoZ0MmJkQh8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADE7DC072AA; Wed, 1 May 2024 14:54:11 +0000 (UTC) Date: Wed, 1 May 2024 10:54:55 -0400 From: Steven Rostedt To: Mike Rapoport Cc: "Guilherme G. Piccoli" , "Luck, Tony" , Kees Cook , Joel Fernandes , "linux-kernel@vger.kernel.org" , "linux-trace-kernel@vger.kernel.org" , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , "linux-mm@kvack.org" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "H. Peter Anvin" , Peter Zijlstra , "linux-hardening@vger.kernel.org" , Guenter Roeck , Ross Zwisler , "wklin@google.com" , Vineeth Remanan Pillai , Suleiman Souhlal , Linus Torvalds , Catalin Marinas , Will Deacon Subject: Re: [POC][RFC][PATCH 0/2] pstore/mm/x86: Add wildcard memmap to map pstore consistently Message-ID: <20240501105455.42b78a0b@gandalf.local.home> In-Reply-To: References: <20240409210254.660888920@goodmis.org> <20240409172358.34ea19f0@gandalf.local.home> <202404091519.B7B2221@keescook> <3391c693-cf54-526b-79a8-d565e7140947@igalia.com> <20240411154007.5bdf8d95@gandalf.local.home> <20240412132243.053ad096@gandalf.local.home> X-Mailer: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 1 May 2024 17:45:49 +0300 Mike Rapoport wrote: > > +static void __init memmap_copy(void) > > +{ > > + if (!early_mmap_size) > > + return; > > + > > + mmap_list = kcalloc(early_mmap_size + 1, sizeof(mmap_list), GFP_KERNEL); > > We can keep early_mmap_size after boot and then we don't need to allocate > an extra element in the mmap_list. No strong feeling here, though. > > > + if (!mmap_list) > > + return; > > + > > + for (int i = 0; i < early_mmap_size; i++) > > + mmap_list[i] = early_mmap_list[i]; > > +} > > With something like this > > /* > * Parse early_reserve_mem=nn:align:name > */ > static int __init early_reserve_mem(char *p) > { > phys_addr_t start, size, align; > char *oldp; > int err; > > if (!p) > return -EINVAL; > > oldp = p; > size = memparse(p, &p); > if (p == oldp) > return -EINVAL; > > if (*p != ':') > return -EINVAL; > > align = memparse(p+1, &p); > if (*p != ':') > return -EINVAL; > > start = memblock_phys_alloc(size, align); So this will allocate the same physical location for every boot, if booting the same kernel and having the same physical memory layout? -- Steve > if (!start) > return -ENOMEM; > > p++; > err = memmap_add(start, size, p); > if (err) { > memblock_phys_free(start, size); > return err; > } > > p += strlen(p); > > return *p == '\0' ? 0: -EINVAL; > } > __setup("early_reserve_mem=", early_reserve_mem); > > you don't need to touch e820 and it will work the same for all > architectures. > > We'd need a better naming, but I couldn't think of something better yet. > > > + > > +/** > > + * memmap_named - Find a wildcard region with a given name > > + * @name: The name that is attached to a wildcard region > > + * @start: If found, holds the start address > > + * @size: If found, holds the size of the address. > > + * > > + * Returns: 1 if found or 0 if not found. > > + */ > > +int memmap_named(const char *name, u64 *start, u64 *size) > > +{ > > + struct mmap_map *map; > > + > > + if (!mmap_list) > > + return 0; > > + > > + for (int i = 0; mmap_list[i].name[0]; i++) { > > + map = &mmap_list[i]; > > + if (!map->size) > > + continue; > > + if (strcmp(name, map->name) == 0) { > > + *start = map->start; > > + *size = map->size; > > + return 1; > > + } > > + } > > + return 0; > > +} > > + > > struct kobject *mm_kobj; > > > > #ifdef CONFIG_SMP > > @@ -2793,4 +2864,5 @@ void __init mm_core_init(void) > > pti_init(); > > kmsan_init_runtime(); > > mm_cache_init(); > > + memmap_copy(); > > } >