Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2307681pxb; Wed, 9 Feb 2022 15:46:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcjXIoYzaKt41x2O43ieS8vh/VyInr524qTx1gaC52O6usvEEZzBbGgiWmqJGuInPI7uge X-Received: by 2002:a05:6a00:2cf:: with SMTP id b15mr4913534pft.0.1644450385361; Wed, 09 Feb 2022 15:46:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644450385; cv=none; d=google.com; s=arc-20160816; b=qv1k2FzSorQR7ozw6DdazhUIy4g68lEPpOoEp8SbFIp07sIKkgzYR3XFl+dRacNFjz DypbORXjhgBOXYh8WhV3UYsJDSRCARs2rweWPY8H7AMe0BRQpKnNHpne6OECt/gBs4r5 jgnOJF4fVHkSScUSenmpqMl6sFxBDmVE7Rde1X7vMzqsYprqVmZbXUmKrc4vOtHwOxml xHVrqlGEyXUy+oL6M2nLk1O8JikEE3Fc3BndAuIYXCgl7TTU+tPEWqVQE0Ye1pStAf8y CbSbJB3FYcjMe0ccKkKhAont44BaETVOGAPYhX2xGvq/3yIj4CTvs0X+ZH42IRyNLsLX 7YBg== 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=470NEk44MftlpKs8Yo0Dk90zEc41WKeO5O9msVCZhqo=; b=nuLrVpwquWXHOF6pyPr5eqaPa5flukuIfrWEKTm1Xl7dKHfzYzqBA5E86+ZiILlYvn AyKujQ1LdzlxsvR4ov67odiA5TgFoW+1/+As1RQcSlyWjnD6mH7i4P4hz5JUpapWwhzZ WUrOIxh8vvQBybsBZ42JkfEMFiiN6IYrpQIt17lqVcVFcJcas+8VkDPqc3M5lW0+qU53 iFJz81MxPzFRF64q8mP6cBkHCrBg4l7JiZW5TplNGs7IP7WseaNeA05qDJVGzVfdPJHv TWfBWRNrMY3voezv2eKB7HEKzN3S54KqteJkAL2ZtuCWWgcck7vFRSg293cv7Zu2GZaq QunQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eHlIYscv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u36si351899pga.583.2022.02.09.15.46.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:46:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eHlIYscv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 36235E06A617; Wed, 9 Feb 2022 15:26:32 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbiBIXVh (ORCPT + 99 others); Wed, 9 Feb 2022 18:21:37 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiBIXV0 (ORCPT ); Wed, 9 Feb 2022 18:21:26 -0500 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DACE05ADCE for ; Wed, 9 Feb 2022 15:21:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644448883; x=1675984883; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Purxvy8vA6GA+gDSQ2rJk+wzjHjdsMrMrTSJsxNEzAM=; b=eHlIYscvj+OWo2SxystnMc337bB6rczYBlmvj2ODA3GeCftE0fWJ50zo 7ccwB7ohNkYpOYRLAFvWN9V99+mjdCBvXm3wDpmElQKTXoLFELfk7R789 EKDh/l9jDTXsFEnsspo8J+oDjKA/IT2nVEp53/DZk9JImxFc0Jfy6Oqsp 8X4VmEpw2oAka8/Vnkv6QrXaMUajeVipfCLL1eB9jtBzcqhqjjOTX6MlY ah4QvMKuTOqG8/wpV51gl2x+iNVGRg6HJPXo1vnoEQAPKG+4Cgo3geWJf Jjn/dkBXVrSjG5j6LJKqhletcz96eJJJE22UxKEQ+kxDrIkp6bO08IfzV w==; X-IronPort-AV: E=McAfee;i="6200,9189,10253"; a="232929601" X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="232929601" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 15:21:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="773679447" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 09 Feb 2022 15:21:15 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 1A7CC107; Thu, 10 Feb 2022 01:21:30 +0200 (EET) Date: Thu, 10 Feb 2022 02:21:29 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: tglx@linutronix.de, mingo@redhat.com, dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org, pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 23/29] x86/tdx: Add helper to convert memory between shared and private Message-ID: <20220209232129.puktrgtvpovunexc@black.fi.intel.com> References: <20220124150215.36893-1-kirill.shutemov@linux.intel.com> <20220124150215.36893-24-kirill.shutemov@linux.intel.com> 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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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, Feb 08, 2022 at 01:12:45PM +0100, Borislav Petkov wrote: > On Mon, Jan 24, 2022 at 06:02:09PM +0300, Kirill A. Shutemov wrote: > > + if (ret) > > + ret = -EIO; > > + > > + if (ret || !enc) > > Is the second case here after the "||" the conversion-to-shared where it > only needs to notify with MapGPA and return? Right. Memory accepting is required on the way to private. I will rewrite and comment this code to make it more readable. > > + return ret; > > + > > + /* > > + * For shared->private conversion, accept the page using > > + * TDX_ACCEPT_PAGE TDX module call. > > + */ > > + while (start < end) { > > + /* Try 2M page accept first if possible */ > > + if (!(start & ~PMD_MASK) && end - start >= PMD_SIZE && > > + !tdx_accept_page(start, PG_LEVEL_2M)) { > > What happens here if the module doesn't accept the page? No error > reporting, no error handling, no warning, nada? If it fails we fallback to 4k accept below. We only report error if 4k accept fails. -- Kirill A. Shutemov