From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35743C433ED for ; Wed, 14 Apr 2021 15:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 163686120E for ; Wed, 14 Apr 2021 15:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233856AbhDNPyY (ORCPT ); Wed, 14 Apr 2021 11:54:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44288 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352425AbhDNPxX (ORCPT ); Wed, 14 Apr 2021 11:53:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618415581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=N3azEr1ngxbg5Okfzokn3K+Vj8x1YT1chtg/3cPj88jYlzCSUj97TjSeFM+icr/ZSz9UjK n8nyxXERFsZid/76ryc48rtDYfhUgd7Hr2CH7xzLpw/rKyfA3OsHjkzjaOEmzgCxy6r5Dc 8gRIO4EFpV1RVIW6vdrADRh67QLnPbg= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-GidRiZGwPLqdQKAyLMlfrw-1; Wed, 14 Apr 2021 11:53:00 -0400 X-MC-Unique: GidRiZGwPLqdQKAyLMlfrw-1 Received: by mail-wr1-f70.google.com with SMTP id t18-20020adfdc120000b02900ffe4432d8bso1259543wri.6 for ; Wed, 14 Apr 2021 08:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=AkFx2Ygit4SrXmu+B8aB7VJBGmZQ6ce5gK36nkVlqiSVlJC+gX6fq57e+zQTmzg3tm L+6C7bVbxH7RNrwXIEGFpk0kF9A86QEbSrl9rXRfYvr3KGQIMyVuGVloOdP0ou0q7r60 a7ir9vyWPJDnCR0/wXmdBsiuEZfEqHKhgJcxvGAc4h1fvbCFPgiGKlY6GOfjt7LY/Xae vQYRFgKE3xMzxqRjb/dQc3NnsbL2bVwe42q9hO/maqBdCxq9PRI6cM6K9M6iu2k8ZbIS a8gE+pX/m56j7G6MIgD5wqFjWqXf1UoL/LnxbY12fBCvvkfwG5rTi4ea9hYyhM9E9uMP N+wA== X-Gm-Message-State: AOAM532mh+hEtInP9EuxZxJ1i9bFI29/EI3O72tjfpvPc95xHmQgYeKs bvsyQJTGQM3mTgoTuvFtl8sUPFwtrpkD5TQ4u9j1OZ0jTXP2YghObYfYSrsylLKi31MHUqh/LfO Wg9vd3ytZsvhd+gKmc7hLv2G6 X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611098wrx.295.1618415578933; Wed, 14 Apr 2021 08:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwrSOMpK/YVN66pneA+j1TjD57EZ3NUFrkJFb4IkiDMz2r4seRtxhdfypbvJbPgTdVs+mLkw== X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611079wrx.295.1618415578737; Wed, 14 Apr 2021 08:52:58 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6470.dip0.t-ipconnect.de. [91.12.100.112]) by smtp.gmail.com with ESMTPSA id u3sm5657582wmg.48.2021.04.14.08.52.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Apr 2021 08:52:58 -0700 (PDT) To: Ard Biesheuvel Cc: Mike Rapoport , Linux ARM , Anshuman Khandual , Catalin Marinas , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm , Linux Kernel Mailing List , Linux Memory Management List References: <20210407172607.8812-1-rppt@kernel.org> <20210407172607.8812-2-rppt@kernel.org> <0c48f98c-7454-1458-15a5-cc5a7e1fb7cd@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages Message-ID: <3811547a-9057-3c80-3805-2e658488ac99@redhat.com> Date: Wed, 14 Apr 2021 17:52:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.04.21 17:27, Ard Biesheuvel wrote: > On Wed, 14 Apr 2021 at 17:14, David Hildenbrand wrote: >> >> On 07.04.21 19:26, Mike Rapoport wrote: >>> From: Mike Rapoport >>> >>> The struct pages representing a reserved memory region are initialized >>> using reserve_bootmem_range() function. This function is called for each >>> reserved region just before the memory is freed from memblock to the buddy >>> page allocator. >>> >>> The struct pages for MEMBLOCK_NOMAP regions are kept with the default >>> values set by the memory map initialization which makes it necessary to >>> have a special treatment for such pages in pfn_valid() and >>> pfn_valid_within(). >> >> I assume these pages are never given to the buddy, because we don't have >> a direct mapping. So to the kernel, it's essentially just like a memory >> hole with benefits. >> >> I can spot that we want to export such memory like any special memory >> thingy/hole in /proc/iomem -- "reserved", which makes sense. >> >> I would assume that MEMBLOCK_NOMAP is a special type of *reserved* >> memory. IOW, that for_each_reserved_mem_range() should already succeed >> on these as well -- we should mark anything that is MEMBLOCK_NOMAP >> implicitly as reserved. Or are there valid reasons not to do so? What >> can anyone do with that memory? >> >> I assume they are pretty much useless for the kernel, right? Like other >> reserved memory ranges. >> > > On ARM, we need to know whether any physical regions that do not > contain system memory contain something with device semantics or not. > One of the examples is ACPI tables: these are in reserved memory, and > so they are not covered by the linear region. However, when the ACPI > core ioremap()s an arbitrary memory region, we don't know whether it > is mapping a memory region or a device region unless we keep track of > this in some way. (Device mappings require device attributes, but > firmware tables require memory attributes, as they might be accessed > using misaligned reads) Using generically sounding NOMAP ("don't create direct mapping") to identify device regions feels like a hack. I know, it was introduced just for that purpose. Looking at memblock_mark_nomap(), we consider "device regions" 1) ACPI tables 2) VIDEO_TYPE_EFI memory 3) some device-tree regions in of/fdt.c IIUC, right now we end up creating a memmap for this NOMAP memory, but hide it away in pfn_valid(). This patch set at least fixes that. Assuming these pages are never mapped to user space via the struct page (which better be the case), we could further use a new pagetype to mark these pages in a special way, such that we can identify them directly via pfn_to_page(). Then, we could mostly avoid having to query memblock at runtime to figure out that this is special memory. This would obviously be an extension to this series. Just a thought. -- Thanks, David / dhildenb From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21DCDC433B4 for ; Wed, 14 Apr 2021 15:53:07 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 9601F61222 for ; Wed, 14 Apr 2021 15:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9601F61222 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 02BCD4B648; Wed, 14 Apr 2021 11:53:06 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@redhat.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t2vI7eaWIxpv; Wed, 14 Apr 2021 11:53:04 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id DD3194B65E; Wed, 14 Apr 2021 11:53:04 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 082BB4B648 for ; Wed, 14 Apr 2021 11:53:03 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4tOds0gjt6XE for ; Wed, 14 Apr 2021 11:53:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 0B5F04B63F for ; Wed, 14 Apr 2021 11:53:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618415581; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=N3azEr1ngxbg5Okfzokn3K+Vj8x1YT1chtg/3cPj88jYlzCSUj97TjSeFM+icr/ZSz9UjK n8nyxXERFsZid/76ryc48rtDYfhUgd7Hr2CH7xzLpw/rKyfA3OsHjkzjaOEmzgCxy6r5Dc 8gRIO4EFpV1RVIW6vdrADRh67QLnPbg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-62-wxX6_0tQO-qdsFuLmH3I3w-1; Wed, 14 Apr 2021 11:53:00 -0400 X-MC-Unique: wxX6_0tQO-qdsFuLmH3I3w-1 Received: by mail-wr1-f71.google.com with SMTP id y13-20020adfdf0d0000b02901029a3bf796so1258538wrl.15 for ; Wed, 14 Apr 2021 08:53:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=BB4sLNBb9wDMfeqcQqXMRw4/ctHOU+2csTHbGljGsQnAVYVaNQDEghH16w2ulN5cDs wkQC+TAIo4WQcVfN5LgVpRqr9FGcxsDBwyhC/tZhnc0GeDke0SXzJ7bPc4BfrZ8LHlwn N/ah+LOk7jYtDBHsrl4kwZ9A3ZP5k1kF90VcGVgvjXxuR+4bf70R2Lf+qxJH+Ov2vXRE 6AH/sJb0KfUkVrASjQoqR86b8h506OIRrLZR7p2u7rTu1sxQA9Vl6e067XW0kWMcqPKW x2nM4Z5KGNdmJFC3OBHW7+/WhRrqSfh5fMTZ4xApr1i7jahNfP+0M7CribFJotLD6R8w eQcQ== X-Gm-Message-State: AOAM533FP7pRLW0q1RoCgSQJ/PoxpnnPF22hiEMAOEUjHfpR9HV+juIX X/W5eXm0mpy4hGDK9X7kx0ZWiTVYoBwUJeOzYrwfDH4a13jQE9iGrvz7QrVEzfA4OIH1a4nvO7k Fqf0sB38nxfBt/FfhzdVOiRT/ X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611109wrx.295.1618415579020; Wed, 14 Apr 2021 08:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwrSOMpK/YVN66pneA+j1TjD57EZ3NUFrkJFb4IkiDMz2r4seRtxhdfypbvJbPgTdVs+mLkw== X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611079wrx.295.1618415578737; Wed, 14 Apr 2021 08:52:58 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6470.dip0.t-ipconnect.de. [91.12.100.112]) by smtp.gmail.com with ESMTPSA id u3sm5657582wmg.48.2021.04.14.08.52.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Apr 2021 08:52:58 -0700 (PDT) To: Ard Biesheuvel References: <20210407172607.8812-1-rppt@kernel.org> <20210407172607.8812-2-rppt@kernel.org> <0c48f98c-7454-1458-15a5-cc5a7e1fb7cd@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages Message-ID: <3811547a-9057-3c80-3805-2e658488ac99@redhat.com> Date: Wed, 14 Apr 2021 17:52:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Cc: Anshuman Khandual , Catalin Marinas , Linux Kernel Mailing List , Mike Rapoport , Linux Memory Management List , Mike Rapoport , Marc Zyngier , Will Deacon , kvmarm , Linux ARM X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On 14.04.21 17:27, Ard Biesheuvel wrote: > On Wed, 14 Apr 2021 at 17:14, David Hildenbrand wrote: >> >> On 07.04.21 19:26, Mike Rapoport wrote: >>> From: Mike Rapoport >>> >>> The struct pages representing a reserved memory region are initialized >>> using reserve_bootmem_range() function. This function is called for each >>> reserved region just before the memory is freed from memblock to the buddy >>> page allocator. >>> >>> The struct pages for MEMBLOCK_NOMAP regions are kept with the default >>> values set by the memory map initialization which makes it necessary to >>> have a special treatment for such pages in pfn_valid() and >>> pfn_valid_within(). >> >> I assume these pages are never given to the buddy, because we don't have >> a direct mapping. So to the kernel, it's essentially just like a memory >> hole with benefits. >> >> I can spot that we want to export such memory like any special memory >> thingy/hole in /proc/iomem -- "reserved", which makes sense. >> >> I would assume that MEMBLOCK_NOMAP is a special type of *reserved* >> memory. IOW, that for_each_reserved_mem_range() should already succeed >> on these as well -- we should mark anything that is MEMBLOCK_NOMAP >> implicitly as reserved. Or are there valid reasons not to do so? What >> can anyone do with that memory? >> >> I assume they are pretty much useless for the kernel, right? Like other >> reserved memory ranges. >> > > On ARM, we need to know whether any physical regions that do not > contain system memory contain something with device semantics or not. > One of the examples is ACPI tables: these are in reserved memory, and > so they are not covered by the linear region. However, when the ACPI > core ioremap()s an arbitrary memory region, we don't know whether it > is mapping a memory region or a device region unless we keep track of > this in some way. (Device mappings require device attributes, but > firmware tables require memory attributes, as they might be accessed > using misaligned reads) Using generically sounding NOMAP ("don't create direct mapping") to identify device regions feels like a hack. I know, it was introduced just for that purpose. Looking at memblock_mark_nomap(), we consider "device regions" 1) ACPI tables 2) VIDEO_TYPE_EFI memory 3) some device-tree regions in of/fdt.c IIUC, right now we end up creating a memmap for this NOMAP memory, but hide it away in pfn_valid(). This patch set at least fixes that. Assuming these pages are never mapped to user space via the struct page (which better be the case), we could further use a new pagetype to mark these pages in a special way, such that we can identify them directly via pfn_to_page(). Then, we could mostly avoid having to query memblock at runtime to figure out that this is special memory. This would obviously be an extension to this series. Just a thought. -- Thanks, David / dhildenb _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C2C8C433ED for ; Wed, 14 Apr 2021 15:54:58 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DD8AC613B3 for ; Wed, 14 Apr 2021 15:54:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD8AC613B3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:Subject: From:References:Cc:To:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/38drcXwFNdOxJWOBjG4Nhrw0CgURlh7DohdqiwAMYg=; b=c7EXpbBPiDFWHKG8MKleRB2ND lOM+QWkajFOK5xiofaSxZYRBZoF2VJo4dpimD8JxvlxYA1YZMg0obUrnODkbuPFJ4B+3pKOuhNlix HgcxzBySQP/IdzcL6HZ6Uf+M2X9y3ihqoCykn6VYG+9r6C/f86+fQwahDzCs9wLA04JOF5WvybqUT D1iTI2ndUej1YjLhYXIhgvzQwvT6HncCZT/Ac9afHoy9tqKNsWMz/5zHpBg31E0vwpvgvQ9X2cYqT myTjBxpWaX79sNqC4rakpgllOcXWIn9NsnhvD4uNTRzTLccsMor+v5wLvOfvNyifJaqin4Otpaui7 uzX5M0jhg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lWhpI-00D4HH-GE; Wed, 14 Apr 2021 15:53:12 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWhpB-00D4Gr-My for linux-arm-kernel@desiato.infradead.org; Wed, 14 Apr 2021 15:53:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:Subject:From:References :Cc:To:Sender:Reply-To:Content-ID:Content-Description; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=FdQHGCCnkwYKDaujk1AM4zpwfV ax22b5VcbPHx1kGmRk0e4vPOVInUTfyqN5u2sa3lS/Y+2jHWbdvB9/dG4saXKxKIQFmKo0e99xhBZ uJFzYpuCksEX8k2HdysrKbH6rX0Gl2oFKmvZnMHBjYxQ5AbkqNf1Rc7jSjF0rOLUeOz+HQXY8zDIR JuijMioExRwIYnv2NxurBVwf/PbXViefINr312rzIB7jrWta8vIITVpnPmWM+H4PGkdFNCDo/OcLv +LKM39ukHvz2ApSs2CJ8+Ltdfp2tHhnR6hHafK0q+rpYszCAL3OfI43x1dzgAFAwYb3elWKwpAKF/ oOVGzYVQ==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWhp9-007vCh-3a for linux-arm-kernel@lists.infradead.org; Wed, 14 Apr 2021 15:53:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618415582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=gxFVgMbOm9MxziHmUF4RQvNwMfmioV3WTibCcVw7ERP2NhSNgzEmm5eIyMLZx5dgVpk6xU BLJISfE83E4fxg79OSNH6H13Qe3er726RqJfi7BsfT+8vbeHHIFEuTkYNNakliRfYSIQzw 8tSBIyo5qih3guMJMenIrqNy1fZrAYA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-434-jhfAKJ5IO1ShMoG2oW_PJQ-1; Wed, 14 Apr 2021 11:53:00 -0400 X-MC-Unique: jhfAKJ5IO1ShMoG2oW_PJQ-1 Received: by mail-wr1-f72.google.com with SMTP id h3-20020adfa4c30000b02901027da44a81so1247956wrb.19 for ; Wed, 14 Apr 2021 08:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5YzCxsnnijC//XX+MlJqJz04Lu4zT3zQq8qLb1/6PL8=; b=pBTwBmtlp0edCapHWNxTYSThzWt9UQ/hGJvpd7vtayufKkS240TqOlXip3zz1HEFmh hxV2HOOZMMjhtK6JLQMrsrF+8fADPgmBaO7Wb0VCgesM535MDHGdI8bue3+aiGMoUsvx UFDOeXBLsAUbuBv504b2zhLZnl6t0IQZmmskDNHHsoCcYU6Dl6W+wxPrk1BYUkmnD52G HeQ5OvMv1y03JD1ZMmFx3PbjzD4MI3OAaDT2K1o1YZ60ROpDMx4zovkmI0zXX0EIUh7h 5Q4R7U+sIsbMDAEHg+O9/4uNTvnAuDvtwLfkUChsT7Ze+bnfbfqXqowLtU1U3Y9vqSrZ 1z0g== X-Gm-Message-State: AOAM5332/gi7MtMIqS+zICXUuK9qKU0gEFy7gtqe1n5dpbQBwgZ/CAzX EUP7VynFEtRZLuIDnB/DTXLagp5L0lo6H1mCpYU4vWa0SE2su86/SRihgngVs8DvR9B/wHqM3b8 dKFQXN3q4CF86VWfHYDS/talNmeX4HvAKlOY= X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611094wrx.295.1618415578932; Wed, 14 Apr 2021 08:52:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwrSOMpK/YVN66pneA+j1TjD57EZ3NUFrkJFb4IkiDMz2r4seRtxhdfypbvJbPgTdVs+mLkw== X-Received: by 2002:a05:6000:1449:: with SMTP id v9mr19611079wrx.295.1618415578737; Wed, 14 Apr 2021 08:52:58 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6470.dip0.t-ipconnect.de. [91.12.100.112]) by smtp.gmail.com with ESMTPSA id u3sm5657582wmg.48.2021.04.14.08.52.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Apr 2021 08:52:58 -0700 (PDT) To: Ard Biesheuvel Cc: Mike Rapoport , Linux ARM , Anshuman Khandual , Catalin Marinas , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm , Linux Kernel Mailing List , Linux Memory Management List References: <20210407172607.8812-1-rppt@kernel.org> <20210407172607.8812-2-rppt@kernel.org> <0c48f98c-7454-1458-15a5-cc5a7e1fb7cd@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [RFC/RFT PATCH 1/3] memblock: update initialization of reserved pages Message-ID: <3811547a-9057-3c80-3805-2e658488ac99@redhat.com> Date: Wed, 14 Apr 2021 17:52:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210414_085303_243567_DD32C401 X-CRM114-Status: GOOD ( 27.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 14.04.21 17:27, Ard Biesheuvel wrote: > On Wed, 14 Apr 2021 at 17:14, David Hildenbrand wrote: >> >> On 07.04.21 19:26, Mike Rapoport wrote: >>> From: Mike Rapoport >>> >>> The struct pages representing a reserved memory region are initialized >>> using reserve_bootmem_range() function. This function is called for each >>> reserved region just before the memory is freed from memblock to the buddy >>> page allocator. >>> >>> The struct pages for MEMBLOCK_NOMAP regions are kept with the default >>> values set by the memory map initialization which makes it necessary to >>> have a special treatment for such pages in pfn_valid() and >>> pfn_valid_within(). >> >> I assume these pages are never given to the buddy, because we don't have >> a direct mapping. So to the kernel, it's essentially just like a memory >> hole with benefits. >> >> I can spot that we want to export such memory like any special memory >> thingy/hole in /proc/iomem -- "reserved", which makes sense. >> >> I would assume that MEMBLOCK_NOMAP is a special type of *reserved* >> memory. IOW, that for_each_reserved_mem_range() should already succeed >> on these as well -- we should mark anything that is MEMBLOCK_NOMAP >> implicitly as reserved. Or are there valid reasons not to do so? What >> can anyone do with that memory? >> >> I assume they are pretty much useless for the kernel, right? Like other >> reserved memory ranges. >> > > On ARM, we need to know whether any physical regions that do not > contain system memory contain something with device semantics or not. > One of the examples is ACPI tables: these are in reserved memory, and > so they are not covered by the linear region. However, when the ACPI > core ioremap()s an arbitrary memory region, we don't know whether it > is mapping a memory region or a device region unless we keep track of > this in some way. (Device mappings require device attributes, but > firmware tables require memory attributes, as they might be accessed > using misaligned reads) Using generically sounding NOMAP ("don't create direct mapping") to identify device regions feels like a hack. I know, it was introduced just for that purpose. Looking at memblock_mark_nomap(), we consider "device regions" 1) ACPI tables 2) VIDEO_TYPE_EFI memory 3) some device-tree regions in of/fdt.c IIUC, right now we end up creating a memmap for this NOMAP memory, but hide it away in pfn_valid(). This patch set at least fixes that. Assuming these pages are never mapped to user space via the struct page (which better be the case), we could further use a new pagetype to mark these pages in a special way, such that we can identify them directly via pfn_to_page(). Then, we could mostly avoid having to query memblock at runtime to figure out that this is special memory. This would obviously be an extension to this series. Just a thought. -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel