Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6642589iob; Wed, 11 May 2022 02:03:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuRdTRZ1jibmIu4Lpen85JBMA6YgVU2wZsprAHonYepXP8rmUrXDlYubOZW3NWaxXmydXR X-Received: by 2002:a17:907:97cd:b0:6f4:29fa:7d40 with SMTP id js13-20020a17090797cd00b006f429fa7d40mr23735776ejc.664.1652259838120; Wed, 11 May 2022 02:03:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652259838; cv=none; d=google.com; s=arc-20160816; b=WUYqLdOVYTC3uKR6PqYqcU+f6sETgF4UDrbtbLwSKYXMfnREN6twHMf598yHz4rxgu 2drQVa2WNR1i1lSz0Ae7v0XpEqlsuXue6/nnJyOQqEJDD5xFisLHYfzVQH9Ztq5Et5Fi Xt12FQRoUb3RaR9Z1Z3eSm44Lh3XKzqrE1aN8BkAMAzwaLyQmUFKAcO+1GlvEbkIm8xj ODq2lCrjciSb2xFwj1UWRlI5p1sOXe4n4phSxVjSGFGL32IS3XqQtZ9spIpBJh8Tlfhf zvkO64DGKtn0oN1vXQgpfiMUI/jfwsK2T7q3Ncdib5LhcGbq6rhxz+00+mWlGOl39W5E Csyg== 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=l/R7CNjWmMZ859kdXkriliqHFZFmcdN2UKowY7vVOHU=; b=imb93SpAEfmjeRhedtwM6ehq3PjepplDcJTP59W7LR2djyeMiTpwDDX783XyQoQ8EF 0GKd6fWd5Ax0T1u+Vzt/kIBv3fiV1amYaGoEyE6v0fq+QIrusbNuvnqHyJhDyK79+oAq FTJpkwWwkv7NYJNq0FeH5GUH470Dkkx2agNTWfyYeUOg3AQrDfd5rqvxhutpyNnFUUHx 0qjGFgVUKeH015bXnBePxzmfVLHoC03rY/HZoHRz3IVqEZ0FTkiW5c3Qydu4UonWERTd IW8wdod3KG+Z8aYmreYZrl/luVvD+A8r7ihCLd5OYQJL9ylvFvmboV/HKGCXD6keQ1id MZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=8CJByluZ; 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 ho15-20020a1709070e8f00b006f458fb419dsi2162410ejc.223.2022.05.11.02.03.31; Wed, 11 May 2022 02:03:58 -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=8CJByluZ; 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 S240100AbiEKBRX (ORCPT + 99 others); Tue, 10 May 2022 21:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238619AbiEKBRV (ORCPT ); Tue, 10 May 2022 21:17:21 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCED3C4BC for ; Tue, 10 May 2022 18:17:20 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id m23so670409ljb.8 for ; Tue, 10 May 2022 18:17:20 -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=l/R7CNjWmMZ859kdXkriliqHFZFmcdN2UKowY7vVOHU=; b=8CJByluZYe0dkhytOZ7LANy/Q36T2SzxDWXpHLGeWnfxyvns0y176nq5wqABdl8MuS 8JWwhkw/8Dz/zjo0vYLE6X4ieGVgty19A6fmFFJfTAkZf0XwfmaUvEBa51chzTSw2fNk NCZFjZAzOuQZeVDNUshWB0ME+BKf6rAkRWyRi2suCa4HnC5cIEI70C8pbRMMhYKfUACy lHeDeT9I/k+fOz1ysSaU8nlyyAjEfuSDDWejsXcoXUidz55t1Wl6dZHJV9vvCP+L3IFs RWxkEh2zXcgX0WJ+D7S89UL9SGee8sjbbN4mdh9bgMFty7a0McfOFAswPU9H9kpsEhbS 0otA== 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=l/R7CNjWmMZ859kdXkriliqHFZFmcdN2UKowY7vVOHU=; b=M7BeqJj/4RiuMI+noqGWNpF4BPYHewi2/4HLjhReZGCE2E7g9fig6av765ssV8nJJc TBIKPePlkMjR5OfxlLsE1fCLUjQ8oBT0JLexN1ghLZLJRJl8GYzpldwUaL/mMTOgp2Sb Tdpxqr/ydFpD9kCwfSN4IV3KJ56AGgXiAJThUlNXRdLXRFdQdQJa2B9KT0dJwVG7GILK eSZUK4afUtDq5nY8CVTxF6E6fQgjytbodiEzMmKjl13U6dOXeQgn9BLNTe8D4a/qUJrx rbDZq32R3083PttROvY902S9cZUsfmuoVnu/H4OtMUjGe5f3jL7Vh+A1Lu7wb6GBz/A0 gF1g== X-Gm-Message-State: AOAM531Yg9jSRf5R/7r/X8ZfkZjA3A0/hqSbPMhxRcQCSthpsNymYdC1 kpSyTUaL9juDg35nt+CYkUzGQA== X-Received: by 2002:a2e:a810:0:b0:250:a19f:8b30 with SMTP id l16-20020a2ea810000000b00250a19f8b30mr14868052ljq.397.1652231838459; Tue, 10 May 2022 18:17:18 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id c20-20020ac25f74000000b0047255d21187sm62003lfc.182.2022.05.10.18.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 18:17:17 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 78BFE104757; Wed, 11 May 2022 04:19:06 +0300 (+03) Date: Wed, 11 May 2022 04:19:06 +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 10/12] x86/tdx: Unaccepted memory support Message-ID: <20220511011906.el4m54fns7ilh7fr@box.shutemov.name> References: <20220425033934.68551-1-kirill.shutemov@linux.intel.com> <20220425033934.68551-11-kirill.shutemov@linux.intel.com> <20220506204423.gu6jrb53kmuxze5r@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220506204423.gu6jrb53kmuxze5r@box.shutemov.name> 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=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 Fri, May 06, 2022 at 11:44:23PM +0300, Kirill A. Shutemov wrote: > > > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig > > > index 7021ec725dd3..e4c31dbea6d7 100644 > > > --- a/arch/x86/Kconfig > > > +++ b/arch/x86/Kconfig > > > @@ -885,6 +885,7 @@ config INTEL_TDX_GUEST > > > select ARCH_HAS_CC_PLATFORM > > > select X86_MEM_ENCRYPT > > > select X86_MCE > > > + select UNACCEPTED_MEMORY > > > > WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY > > Depends on [n]: EFI [=y] && EFI_STUB [=y] && !KEXEC_CORE [=y] > > Selected by [y]: > > - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] && CPU_SUP_INTEL [=y] && X86_X2APIC [=y] > > > > WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY > > Depends on [n]: EFI [=y] && EFI_STUB [=y] && !KEXEC_CORE [=y] > > Selected by [y]: > > - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] && CPU_SUP_INTEL [=y] && X86_X2APIC [=y] > > Ughh. Any ideas how to get around it? (Except for implementing kexec > support right away?) I reworked this to boot-time kexec disable. > > Also, it doesn't need to be bool - you can simply return accept_size on > > success and 0 on error so that you don't have an I/O argument. > > So on the calling side it would look like: > > accepted = try_accept_one(start, len, PG_LEVEL_1G) > if (accepted) { > start += accepted; > continue; > } > > And the similar for other levels. Is it really better? JFYI, I've reworked it as accepted = try_accept_one(start, len, PG_LEVEL_1G); if (!accepted) accepted = try_accept_one(start, len, PG_LEVEL_2M); if (!accepted) accepted = try_accept_one(start, len, PG_LEVEL_4K); if (!accepted) return false; start += accepted; looks good to me. -- Kirill A. Shutemov