Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10125064rwr; Fri, 12 May 2023 04:17:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hP52krLVC8qYj4ZQ0m6T/MzMbBUoOTh+wx4s+5uVMEfouh4MXzmlfkovMikAsTrnJPwRu X-Received: by 2002:a05:6a20:a104:b0:104:98ea:48d5 with SMTP id q4-20020a056a20a10400b0010498ea48d5mr1459596pzk.36.1683890274777; Fri, 12 May 2023 04:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683890274; cv=none; d=google.com; s=arc-20160816; b=CgxQHPruka+d2zAblel7tx4MEpG65zTbfsEuz2ALG+IHkPKNWHUHj0wvzy4yo9j9I1 ipkMvhRaA9lWjmP/ac1x4ayrQ3WiVPeReJQI6Mu1Eg/sNsZvk4LsDaOBKLDaeMgC4/bW V28Nsic84jN9SX4C2dhQ2Kgv4g8xFyMWjoJL556WcWO3jJw+VpWWk84XF+9rH8O+GbtL tsM9Op1M1M/n6t4kPZjUlk+0ssAMFq16SO0PB/fNHKYGVeUfbBTYiWXwbtxFEihQG6WE MNCAtRE3Fj5epun6Hak7ei6DeI7vKJuyAConkfK8ZzJnEDI75jwRfTlhMGacFwYw3+pT Gkyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1LmljYcNSoh3f14QbspK6/Wtrw6bPBoRX996WfqJEcg=; b=eKtuuB6N2OH7YsR6nh8mOSsuCRBcW0X/54i5y6H3KyICfl/poGv9BihB9tbmboV7I7 hUM8B4gPQKPuraM/aKq6Z+KNuznTQMQmUcAL2R25hX/5c4fbjMHRxbDJG+vk/OuzdmjH WsQq/sFrBen1iZuTkAtvhHlmR78P2SMTBv7nAuh5bs+Nr/QC8/vthTNOh+wWvEv4y17l vUYw9ck7A6BEiNX/9peiu0YyciNDAaKrrRqVBIYxhvtsiahFRAFpXbPw6JTibGXF70Wm wIzLMl6EBM/z+Yy0wmUHGD8nVuMJ+pwhQQ5HAG/x2r63wZcDCWcvJyzHJEKpVl+Oy4hF oRXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c+TBR77M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020a637157000000b0051b8a81c5d0si8888556pgn.606.2023.05.12.04.17.40; Fri, 12 May 2023 04:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c+TBR77M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240880AbjELLB7 (ORCPT + 99 others); Fri, 12 May 2023 07:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241067AbjELLBT (ORCPT ); Fri, 12 May 2023 07:01:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09571386E; Fri, 12 May 2023 04:01:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C8E865566; Fri, 12 May 2023 11:01:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F171DC433AF; Fri, 12 May 2023 11:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683889275; bh=WfMo/UCIoEAhIuI192bDSMME0+1kDUpIrgATnnqtCsM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=c+TBR77M4V+MLrEbx3zrrJ4/a8+IDr2YL33BtcYUwPIvSxPr/r2G8l2K4NsK6Fy97 8+f3fW80e8nIiX7Xonx9W+Uw4mnmGsx/G7R7aGHXI+xJEDO/aCMGCDl03aXIt4Qv4q E033s8QK58HpL5V7+/9PR2Id1fApkv8h59WJu8BbiK4tujxC/uYxKQsWeiM00xUMsg l5jpmCH4h751EpnI0Q+3IOKxwf3y32ZY58Cv/qkNJ5nWBDHZzR65rMjnVAYXYCnTK6 uOBYvkHHruKD80eVRxFlJDfCGUOLaZ7j3iJJPfut+kggGxFl/Xfc0SWJvIryAt1Qqt n1o/ysaCNUGJA== Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4f137dbaa4fso11424415e87.2; Fri, 12 May 2023 04:01:14 -0700 (PDT) X-Gm-Message-State: AC+VfDyEuiUa2GkwwPQAbXf40xMo8plX+cMhf5l9dWFtTbtx8JEu1Dvk Nm7ep2K1yZ90F+0SmA8VnwD7+UYjKFut0gPGtfk= X-Received: by 2002:a05:6512:961:b0:4eb:7e:1fa5 with SMTP id v1-20020a056512096100b004eb007e1fa5mr3761436lft.8.1683889272855; Fri, 12 May 2023 04:01:12 -0700 (PDT) MIME-Version: 1.0 References: <20230507234618.18067-1-kirill.shutemov@linux.intel.com> <20230507234618.18067-5-kirill.shutemov@linux.intel.com> <20230508190043.ouauzbghn27khdy4@box.shutemov.name> <20230509005634.qtuiodpirexbxu2k@box.shutemov.name> <20230512015909.2fj7bmp3ejc3owhs@box.shutemov.name> <20230512105919.lgy3cvio6m2vcygn@box.shutemov.name> In-Reply-To: <20230512105919.lgy3cvio6m2vcygn@box.shutemov.name> From: Ard Biesheuvel Date: Fri, 12 May 2023 13:01:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv10 04/11] efi/x86: Implement support for unaccepted memory To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Borislav Petkov , Andy Lutomirski , Dave Hansen , Sean Christopherson , Andrew Morton , Joerg Roedel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Dario Faggioli , Mike Rapoport , David Hildenbrand , Mel Gorman , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 12 May 2023 at 12:59, Kirill A. Shutemov wrote: > > On Fri, May 12, 2023 at 09:39:30AM +0200, Ard Biesheuvel wrote: > > Please replace PMD_SIZE with something along the lines of > > EFI_UNACCEPTED_UNIT_SIZE and #define it to PMD_SIZE in > > arch/x86/include/asm/efi.h. > > > > The comment below about the size of the bitmap vs the size of the > > address space should probably move there as well. > > Okay, will do. > > > > +void accept_memory(phys_addr_t start, phys_addr_t end) > > > +{ > > > + unsigned long range_start, range_end; > > > + unsigned long bitmap_size; > > > + u64 unit_size; > > > + > > > + if (!unaccepted_table) > > > + return; > > > + > > > + unit_size = unaccepted_table->unit_size; > > > + > > > + /* > > > + * Only care for the part of the range that is represented > > > + * in the bitmap. > > > + */ > > > + if (start < unaccepted_table->phys_base) > > > + start = unaccepted_table->phys_base; > > > + if (end < unaccepted_table->phys_base) > > > + return; > > > + > > > + /* Translate to offsets from the beginning of the bitmap */ > > > + start -= unaccepted_table->phys_base; > > > + end -= unaccepted_table->phys_base; > > > + > > > + /* Make sure not to overrun the bitmap */ > > > + if (end > unaccepted_table->size * unit_size * BITS_PER_BYTE) > > > + end = unaccepted_table->size * unit_size * BITS_PER_BYTE; > > > + > > > > Should we warn here? > > No. accept_memory() is nop for conventional memory (memblock calls it > unconditionally). > > With the fixup, we only allocate bitmap for the range of physical address > space where we have unaccepted memory. So if there's conventional memory > after unaccepted, bitmap will not cover it. > Fair enough.