Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp555636lqm; Wed, 1 May 2024 08:42:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXM5Yhz31MGKH5e+B1PmKtkG48/buexNwqwLOXecIB3z19mTwaHTJOkM/fN9lhUPjh4M1a5JUt40NI2xZKsUylDFjureoPVBHnaAhgRGQ== X-Google-Smtp-Source: AGHT+IHjZtVqovOyXlxVDX59frsiYEUw75vKCb/vBof8SNGpc73CxnLwM60C7OORho/R6UJQuK0Q X-Received: by 2002:a05:6a21:33a8:b0:1af:5d8e:c6c with SMTP id yy40-20020a056a2133a800b001af5d8e0c6cmr3735280pzb.18.1714578121251; Wed, 01 May 2024 08:42:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714578121; cv=pass; d=google.com; s=arc-20160816; b=hve15UYqTGxkchx62o2O9P6GGYBUOeCJM5b/lj7+sbw0oMk1oREJrr7ANOy1VUpwQf JtzwDMDzKPpRdsJI+uUjAtbwgx58ZcEezqmsKPj/NQLj1ZJnGeZR6ee0x2iprpWtiTrg GMxhw+PBakpoyNmT9iBVU/KzLJQMXBewuwpnuOEFll4IbUd0k5kSnR0Q8ezhujBj0bva euTIxpEzb9xEtPoV8uiw/qtIz4Xf8zRsAlwIaBaGPCokwz2JB6IVh1s8AcS9s9sWKRgH eLRn1XNApOxtjnsKNZGonRp34xG2XKXq+qn2Szc7OkRiyO25f4ZJRrd+14PL5AsDjtfm tnHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GUhar8p8x4SoS5ZT6orFCAFYwJgZhwIVns9k7kyNpAc=; fh=sSWMxOZz+jOfCdICJfDM8nvIt5v/NuLijeny2jgjbUE=; b=FKTmkriBP4nky/ijTjny2V17fhLXeD+gGQhKKg1QWlWV3BUbMoK3oP8ONUoZbjvrdZ PJ4hFpucTwADk1CW1qWdV7tOgNlDLKFse5Ln7+Hjgck5QMF95ttvrRlYY2AfGRuL1YXF IE5yuUXyERTm0zKavzGs6GtUciSERSNoXlPKa5Kadkdvei3qlEpL4iwjA+WpiIoSwiUl W70YjE8F8cOJv4SVRRKDPhTUcw7ln4fFR0TJo5SyEWvpn8Z8XvWLZJZWE1QR9Znb/v38 T4eTnQ++UAAWt8+xel8jRC+v0oXkL1ozf3XsLTdkqKKx/cFgQDdeViKEcyWgcMS43VIX vZ3A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OXnzuEXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i7-20020a6561a7000000b005d64d951c89si24908691pgv.143.2024.05.01.08.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 08:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OXnzuEXF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-165495-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165495-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 87A9EB23824 for ; Wed, 1 May 2024 15:36:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94752135A64; Wed, 1 May 2024 15:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OXnzuEXF" 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 A53E4130E2C; Wed, 1 May 2024 15:32:13 +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=1714577533; cv=none; b=CoM7/X5AYuQkyVtgO946Lx8MJgRQ3VQq2E4Dr8jZX6ac5yeRTbqhSa1r9m0yjkXkr7BxfmYa+m1UjfQFrfV2/BhFCtLA1pZNBy/npELw54Zii5bZrWGhEkKIOUojB++nFAEqCJ1J99IbefxYnygdC93ojHRT8RyKDGtPa3CvQ1o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714577533; c=relaxed/simple; bh=8WVzesDRY59eAiPcjnXVtYZdjfYneGgUndVN5TPMtzU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g2yfTwAV5BjBgaoQx/75YLzZ8us9SkC4kDu3lUMpZ+bDRXOHWu07HnOMnxTd+wUEgpRULxgxfAxsiwH0vP8aKZMTYOtmty/CjACWEBAMptmqsuS48pi7364aHKVID/vXZffFpSdJQt9TwIa9fDokl8RgwaKcRkyj908rZXZ+I7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OXnzuEXF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45B21C072AA; Wed, 1 May 2024 15:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714577533; bh=8WVzesDRY59eAiPcjnXVtYZdjfYneGgUndVN5TPMtzU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OXnzuEXFOzVTCgd5UODHWCQzEQeUrDLX81JT65/GEltCEd/tyHH+BLaUsWjdag4di hsX4FvfdNTemCxIOYPGYVnar8IwFthSkq78k64ASXt1W4BaEW83jvwX7uPMusoACjZ j66Fnuw8uVy+mpqhmjsjezyatLL2rRq2GpADPntHrJEffjsa7c8328QtaelxsbUBHV 2BDotzuP4B4uSEaplwH/uB4AdWjTqDZbsLgMkR0ZjGJ6S91803rYH7gOGjIopFU4Hf vQAKQgn9iCejJaFuT+QjyBrJ5fyl5Y+JgcaveC2Ih9v84TKeo+134tMrmAC49RAzXj BYWWsYFZ7UZQA== Date: Wed, 1 May 2024 18:30:40 +0300 From: Mike Rapoport To: Steven Rostedt 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: 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> <20240501105455.42b78a0b@gandalf.local.home> 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-Disposition: inline In-Reply-To: <20240501105455.42b78a0b@gandalf.local.home> On Wed, May 01, 2024 at 10:54:55AM -0400, Steven Rostedt wrote: > 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? Up to kaslr that might use that location for the kernel image. But it's the same as allocating from e820 after kaslr. And, TBH, I don't have good ideas how to ensure the same physical location with randomization of the physical address of the kernel image. > -- 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(); > > > } > > > -- Sincerely yours, Mike.