Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp204512iob; Mon, 2 May 2022 17:08:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGGRY8FkDyx3XDON1wZD0mQeXvpqiRFKPDHloUdNKZVfd1acm8EjP7q0DJvcMRNEKgCES3 X-Received: by 2002:a17:902:6b0b:b0:156:4ab0:3ddc with SMTP id o11-20020a1709026b0b00b001564ab03ddcmr14105251plk.22.1651536539437; Mon, 02 May 2022 17:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651536539; cv=none; d=google.com; s=arc-20160816; b=e5yQVQ37QGPlMRP98Q+P9G5uBfRLeCie1xIbnH6WRe8eNbtPtjy56jqmUM3yfN9tGI AHauX6jDyLzdHkXlouA8ifhZ4EJYxbK6mst4iKAXv6HuSZX8qoRXW57Uuodr2/Y4bzcO pHM3R1DR1EeddHfZpORBZcrla5hQf3RaERPGH6PpfZhFZoKeh0aM0oaRvnrFE3LEc7xP 1QzyU8dYFG9oyP3AxGWSnMAMhD5uao6Y58GRN/aGIxm4iqx9uWPHWg9lwH+0lwt6/8Te bkVzySrhQKrqgeD5huDFuYUe1y6+VkRCPRElTOY9US0zNKu3deNFocwKjqpbiprzh0eP Q85Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tUAJYdg6YdclsJstmgwc0rqcUtHlPtnD/2qFQEUAcJk=; b=d4tHKwQjQyGX7d/h5RK/2TJNbtXCMd9+6L/M81Qxn03wr3XgXSpmt6f4dUGSxK1DVa K9/sNS5lWkAqxuvGeVtrflA1WcG95fRR1rE/mQFE7ytZWHJSNb3DyrHD0I56G+DXfGN5 j8ugYlgeWRzFtq5R4T31fR6fQ/EaLhb4YNIIEh8OTs9YbxX3FwNxYapXo2z/Cc7MI5uV 0wF3A6zs+7O7JBh8zst3k3csV7g9q/hminOJelgi4GGwy401Zz7Vsih38TTty4TyCRIm vBaBAupuzTxZREaRaoPPaRg0LmxphxzhgyY8PDIuhEo5cWvXCcZzJH9NeidIza+JTWAE a2Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=a+VF1qza; 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 e17-20020a170902ef5100b001589c9ea308si14287255plx.349.2022.05.02.17.08.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:08: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=a+VF1qza; 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 56D5835251; Mon, 2 May 2022 17:08:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349387AbiEBOVC (ORCPT + 99 others); Mon, 2 May 2022 10:21:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232083AbiEBOU7 (ORCPT ); Mon, 2 May 2022 10:20:59 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5111A17049; Mon, 2 May 2022 07:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651501051; x=1683037051; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=CJgkaS9O4REA+/QIrvQMB9jS3Pr7zFdaQtj+hUxh90g=; b=a+VF1qzaTWMD8IoK9br7kV59IneIkZ2tURUCjnU66UsecbxNrYUeS897 5lF/+0RV0eH6mn6ElPIWOY673DokMxJzGHgg4ltJ9W38vMPHqtS68A5VM LgXNKeAxpGeFiyWZaWdDMDBzAHnU83t9baEBfndaoBSQ1FvDPLU9E0GK7 7viwFSc9ImOk4rq51chwAnL64Fdlw6Ra/QeRHvFsKPHaMMS9swKEg+4Cf Ppuo9rC86thrB78NT3Aq1kdLo/EcXnz237EI802pPtkfVk4hveokHNk5V UUUkPuk9VUV6Tysgi3sEEHF8Qcl5nF3oAurGC8zhrk1hHV9abhcn4gYZB w==; X-IronPort-AV: E=McAfee;i="6400,9594,10335"; a="327763628" X-IronPort-AV: E=Sophos;i="5.91,192,1647327600"; d="scan'208";a="327763628" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 07:17:30 -0700 X-IronPort-AV: E=Sophos;i="5.91,192,1647327600"; d="scan'208";a="663538658" Received: from gsteinke-mobl.amr.corp.intel.com (HELO [10.209.165.8]) ([10.209.165.8]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2022 07:17:29 -0700 Message-ID: <8d5715b5-d561-f482-af11-03a9a46e651a@intel.com> Date: Mon, 2 May 2022 07:17:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v3 13/21] x86/virt/tdx: Allocate and set up PAMTs for TDMRs Content-Language: en-US To: Kai Huang , 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 References: <3664ab2a8e0b0fcbb4b048b5c3aa5a6e85f9618a.camel@intel.com> <5984b61f-6a4a-c12a-944d-f4a78bdefc3d@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 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 >>>>> + /* >>>>> + * 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?