Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6854954iob; Wed, 11 May 2022 06:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxajDl4MBWPCxpVuU5L62CjghpgNvuWWz3tlUm/Nt/yjOhZtsrN5ekoRF7UzqorjvNmjTou X-Received: by 2002:a63:814a:0:b0:3db:3cba:323b with SMTP id t71-20020a63814a000000b003db3cba323bmr1547439pgd.142.1652277043545; Wed, 11 May 2022 06:50:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652277043; cv=none; d=google.com; s=arc-20160816; b=M8Z+t3ND6MJbVajXzgigkczORlwaXW425YNXHx/1nv2vP5bbjb9vUTUz+SzK3ITbXo yT4N5HCYxPLkFi/2MwWB39fM2lBjulcrERYdSZ+FV15L92JiLYQA7TdfNCwx7o8iNAp7 BUh1zj6subRpSBNNiNojUx+SOsepqL93m9fEYX+zsBjU3cp1cazlmXERlKSLPhepGfyL ilusm6NLrb4Y7vBPaR/VAManlARg8cM/Ubvi522/N6jMpMWaPU2rUqow0f2q/lhLJIRC MxmjOJWyGmNgAWgXai2UFp7xmBFT3UKYpZOJAQ1YAzgqEUTL9MLzWX9h+aEGL4YhOW6Z k+4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Bz7T0QeLgAJ6DucemKvTFSRRlyGBkltInGSYnDXnR6E=; b=yvlfECol7lnJlzhykmU8rQl5FmxwFbmX7dpSQ1HShnsjy4QTXYbaDLzoFseEvfK27V UoZ29lACM63PyZfCg8KdTTHroYOtppQcvdk+2bR7yOaQS2rQf8OHoRCGpXLZW0n1WzAB obxLm7N7PCPOhXIPpWNuTXZUaaoWiPtLZs2fTd0e8MKQCoKfghcIbUDB3JpSu7qq/cdk 0c1WP7c5I7GBtcsY0wVh98OaZssj5wFXKOW1/saUstPo89hzm7Oz86sq0EqkaoUO5vMv FJQbrJ5QQJ86Ulkjtrg9c4sorQzs5M+sdvTGDpuoLTUp8Vik43YDmkuWkmmterC4nKy8 eHZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=SITdpMnl; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a056a001a8d00b004fa8832da6dsi2734927pfv.76.2022.05.11.06.50.28; Wed, 11 May 2022 06:50:43 -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=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=SITdpMnl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238317AbiEKBN5 (ORCPT + 99 others); Tue, 10 May 2022 21:13:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235580AbiEKBNz (ORCPT ); Tue, 10 May 2022 21:13:55 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C645C21AABC for ; Tue, 10 May 2022 18:13:49 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id y32so952634lfa.6 for ; Tue, 10 May 2022 18:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Bz7T0QeLgAJ6DucemKvTFSRRlyGBkltInGSYnDXnR6E=; b=SITdpMnlNlx+3zL+SdaU/V7AVAmvkiqPssMcBSWZWWDUdtfPM2FI3GlFrfXkRXujBX 9DWIF4Ur9OceQgYPcvcJD9fJw9kaCM0AzQ4sZUpZoprhUue1tO/tTqWR5hLzH1p6ksQR 00Sf1wl28/tqU/6fg3271g6fUeNlfzqwzZNRgg52wEaXuyvenE+FO7wFGU35V0JkRyE/ KeKZekt1aeYzaQ0P/YK4BNZk+xtI8SMHuieVKGSc8Vjj/SDBRoUU3xQ0u7y1HOm5z/Lx tGHJClst604ij70mzpHhoKbFU46qmOdfa5hyokCbDK1fsQLPyd7EbGxQ37aGOSA7H/7s ZRaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Bz7T0QeLgAJ6DucemKvTFSRRlyGBkltInGSYnDXnR6E=; b=iLpMTXKAxch4ZxbjtKen9fUyFcGw1qxEjU74mTOnj/YMVAGrtjmiANhljc52GmEaL5 Q3uR/gpj++NVMgOWzHpvTbaQqSkT2j1qyLGUQo10ZXW4QY/vR0lrff22Msik0tl5khAx iQ7jROWcvF0VAim4m6Q0GWLb+KR8C10y0DBRUShiNpHOFL5frCcsqGeIPO/F2GEj5o20 5VN+bt8+6EXBKGVUoU01v9YUBLzy9YRkkTg984zEHUinuEeJD5X9fzfMmmJw7DB0wQ0o /ATr3V3r6kitHXYEQreRy0N1yOHzPDmtC0/z2ewnZ8e9EfZ2KLunW7oCT+553Hle9v4M 88KA== X-Gm-Message-State: AOAM531aa8DvU3Yn65hQaJb9aa82Mg0hoYtHchweBsSzmFD16ncRUyTL QBmo9XBcrEiRmBWDjMBkPeqr6g== X-Received: by 2002:a05:6512:32ca:b0:473:cb3d:6ca2 with SMTP id f10-20020a05651232ca00b00473cb3d6ca2mr18143399lfg.261.1652231628067; Tue, 10 May 2022 18:13:48 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id o9-20020ac24349000000b0047428dbea1csm56357lfl.303.2022.05.10.18.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 18:13:47 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 75072104757; Wed, 11 May 2022 04:15:35 +0300 (+03) Date: Wed, 11 May 2022 04:15:35 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: "Kirill A. Shutemov" , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Dave Hansen , Brijesh Singh , Mike Rapoport , David Hildenbrand , x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv5 08/12] x86/mm: Provide helpers for unaccepted memory Message-ID: <20220511011535.or73rm6oviwa5niy@box.shutemov.name> References: <20220425033934.68551-1-kirill.shutemov@linux.intel.com> <20220425033934.68551-9-kirill.shutemov@linux.intel.com> <20220506161359.4j5j5fxrw53fdbyr@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, 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 Tue, May 10, 2022 at 08:32:23PM +0200, Borislav Petkov wrote: > On Fri, May 06, 2022 at 07:13:59PM +0300, Kirill A. Shutemov wrote: > > Failure to accept the memory is fatal. Why pretend it is not? > > > > For TDX it will result in a crash on the first access. Prolonging the > > suffering just make it harder to understand what happened. > > Ok then. Does that panic message contain enough info so that the > acceptance failure can be debugged? > > Just "Cannot accept memory" doesn't seem very helpful to me... Okay. Fair enough. I will change it to panic("Cannot accept memory: unknown platform."); > > > That's true. Note also that the check is inherently racy. Other CPU can > > get the range or subrange accepted just after spin_unlock(). > > > > The check indicates that accept_memory() has to be called on the range > > before first access. > > > > Do you have problem with a name? Maybe has_unaccepted_memory()? > > I have a problem with the definition of this function, what it is > supposed to do and how it is supposed to be used. > > Right now, it looks weird and strange: is it supposed to check for *all* > in-between (start, end)? It doesn't, atm, so what's the meaning of > @start and @end then at all? It checks if the range of memory requires accept_memory() call before it can be accessed. If any part of the range is not accepted, the call is required. accept_memory() knows what exactly has to be done. Note that accept_memory() call is harmless for any valid memory range. It can be called on already accepted memory. -- Kirill A. Shutemov