Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp223061iob; Mon, 2 May 2022 17:41:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn4mRtpfi0DxzT4tGG6FH3C/1GSiggDmtwKQKpr0YvrK6MFz/LRhkvHgqx1YX8c6lDVrHq X-Received: by 2002:a17:902:ea01:b0:15c:e746:477a with SMTP id s1-20020a170902ea0100b0015ce746477amr14341230plg.8.1651538519272; Mon, 02 May 2022 17:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651538519; cv=none; d=google.com; s=arc-20160816; b=iIAc+lfYGhIF/+pEVDbyHTT/YAIwxIKzc6sJH42HwX+h8Dc+SPSW4k43yl1xm/ZXvN XhKzc7fG3FtG5uIXel7bgckJ4B9OkftHNJz83RTPp1+QEIUeIdzXlDjzBtQz4gbYV5UM r4iloys41OJDcFbmr0z0iyDnYlPyzpqAuvcnkYtBzf5gEpEMjPQMtFlohiZvsy0hyTFS YVVea9xd6c2P9vLnA3gh12OzOrNxR+3O5IWIPseh8MSBg6WY6S1m/OqDJgeI62sq2OMM jxzQbfPd5XQdGJe/hmrQOM/+m4NKlaE9ZXF5mA3EGyZEz2UECvA2svgjliu4rwPlbcPy Vwlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=NJrMNzG08gUEqXzgX4GfaR2EPFnOGQw2griUDGvZMm4=; b=vcAyKp9S82W+HdAo4PIxoBpLzVW9toa4CZnxtQg6fOwK25Ob4x8FYQlAsnVLfNjCOC I+2+YYFM0y3X6cQsvk7x8INsI81O+uqFgeYyhqiMnrUYqTYrxUIB8rraNdN/sJtsIIh5 6Rjg7/rpPgQXdCvC8M7K9V/ALRmNa4F4FT1xf7URP0JzHpPJjDCH4VhjZg4yQd1VdFTe UsETEitkQh/J/hl2Wc6L+7cqiBTa2Aks2kT08C1r0cheZKd3SuXkUUBGw36YJbp8BP3x 1wWIAo2G4PZOW/QwL9sTAPKOKT5EnLBk7Lx5XpF59uadZa2qHmmusPVEs8+dnRDIcqPb i7/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AfWWk3dq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id ls11-20020a17090b350b00b001dc4e0e712asi876350pjb.125.2022.05.02.17.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:41:59 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AfWWk3dq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0BE949276; Mon, 2 May 2022 17:32:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387632AbiEBWBY (ORCPT + 99 others); Mon, 2 May 2022 18:01:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387840AbiEBV7k (ORCPT ); Mon, 2 May 2022 17:59:40 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64455F33; Mon, 2 May 2022 14:55:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651528558; x=1683064558; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=xkColIiWzUzT63cjf0p5tiFtU1yhRN1jJlgXlzvVJqY=; b=AfWWk3dqhm8sCaX51ak8gVDAVC/2QTLsqoO3+DlRUDn7w/jboVdQzT+k rMYzpoNIub05Z0u1y3jNK3oCL1PO2P1lDC8uX58BWu/zGvDwqb9HnMLIo 2JoacArZzTYA1ROGGEzV3MixzNOOGKgVLQXtfzizqj+Ucyr7z6MhEKpwU V5iobYoQzkW+Nz5xBABrBz1BGomYblJvFUNQ9Zovf1mdQLw7s1Wq++0Oe p9uiZfsVDMAQeUkVBr7EBUrFZtcMFWOOr339iJ7Tlpu3/4lyMp/+j71go 8ox4cFUUgzqEtn7R6ir+ExbuJElfGvVnrH9kB2BUyChGyYjbCw2qhVTQs w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="266924602" X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="266924602" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 14:55:58 -0700 X-IronPort-AV: E=Sophos;i="5.91,193,1647327600"; d="scan'208";a="598813198" Received: from chgan-mobl1.gar.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.60.238]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 14:55:54 -0700 Message-ID: <8ba1a3ec3a4c5a02c28476cbb36118f61aea8a6c.camel@intel.com> Subject: Re: [PATCH v3 13/21] x86/virt/tdx: Allocate and set up PAMTs for TDMRs From: Kai Huang To: Dave Hansen , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com Date: Tue, 03 May 2022 09:55:52 +1200 In-Reply-To: <8d5715b5-d561-f482-af11-03a9a46e651a@intel.com> References: <3664ab2a8e0b0fcbb4b048b5c3aa5a6e85f9618a.camel@intel.com> <5984b61f-6a4a-c12a-944d-f4a78bdefc3d@intel.com> <8d5715b5-d561-f482-af11-03a9a46e651a@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Mon, 2022-05-02 at 07:17 -0700, Dave Hansen wrote: > On 5/1/22 22:59, Kai Huang wrote: > > On Fri, 2022-04-29 at 07:20 -0700, Dave Hansen wrote: > > How about adding below in the changelog: > > > > " > > However using alloc_contig_pages() to allocate large physically contiguous > > memory at runtime may fail. The larger the allocation, the more likely it is to > > fail. Due to the fragmentation, the kernel may need to move pages out of the > > to-be-allocated contiguous memory range but it may fail to move even the last > > stubborn page. A good way (although not foolproof) is to launch a TD VM early > > in boot to get PAMTs allocated before memory gets fragmented or consumed. > > " > > Better, although it's getting a bit off topic for this changelog. > > Just be short and sweet: > > 1. the allocation can fail > 2. Launch a VM early to (badly) mitigate this > 3. the only way to fix it is to add a boot option > OK. Thanks. > > > > > > > + /* > > > > > > + * One TDMR must cover at least one (or partial) RAM entry, > > > > > > + * otherwise it is kernel bug. WARN_ON() in this case. > > > > > > + */ > > > > > > + if (WARN_ON_ONCE((start >= end) || start >= TDMR_END(tdmr))) > > > > > > + return 0; > > > > > > This really means "no RAM found for this TDMR", right? Can we say that, > > > please. > > > > OK will add it. How about: > > > > /* > > * No RAM found for this TDMR. WARN() in this case, as it > > * cannot happen otherwise it is a kernel bug. > > */ > > The only useful information in that comment is the first sentence. The > jibberish about WARN() is patently obvious from the next two lines of code. > > *WHY* can't this happen? How might it have actually happened? When TDMRs are created, we already have made sure one TDMR must cover at least one or partial RAM entry. -- Thanks, -Kai