Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1591777pxb; Tue, 8 Feb 2022 23:23:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR3JuzzK7Y2iOBlnygQn2ZGzvPswJQ5ZDYJtb1BAfb8yFLxyNJ9yKVLiIeVG4FG/O5ON3h X-Received: by 2002:a63:f942:: with SMTP id q2mr865854pgk.573.1644391438182; Tue, 08 Feb 2022 23:23:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644391438; cv=none; d=google.com; s=arc-20160816; b=zqI6jDk4l+Tynv/Pgpu+M/2aj5AqNQwlQSszorDbbKNPsTTPnYa8tUfperhqrXUv4A TkS55v38h9lBP5bgghV8FUy+wcuycYfMbKaBIeYgH87uKlCHeBbdp15Rn7HaLnTE6DDy QK2IW0Q37sO7Afjno3JwaH/odw5NK1yp6D+AK2Lnj5wWn5rMWEHBotY69wT95KFWIQft TLE8YVsHD7ru5wfU/s0RgvWYyBC+OInphsesNo/zKjke7jhZrdb1oZEhXgln/JCzvgFe 0kfHn1j3W3fJbLfc2owWArNbP0jZMKnwg5gocPvj9snu2K/4hJzGkd1TXYcxVJE+bPpG YBvw== 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=y/e2GhBcXzHymJgRHX3UzkyGtFMTu3KEOpP5+yH5sGI=; b=rU3rgyMhRBqkvYS419gMz3kRPFW+WPqxfMWERgknZx6Y+69G9VRMYWcn3Wcw0R2Bqg 8EFLiYaJKiR2k2kT9umfwolMIj/KuX9Ai4HgIoKFbHGMplVKvZuV7WpxN5PYjQ9LE6ON bjO+JimCgwM41MlKtcwUN4o/r84CKAoiHZDeY6Vv9twmBHiTnxOqGiC+rRCbCVOEf1dt m+Auwnan8jdHNDrtWtpbVwA2VI4D6zuZvXjoIn53RI0yq/AXMZWo/p+qAQ/KDipw8AqM Th+KMTtWlZGB9zSb7turvNd97z3KUCiXh3lrMEv0nhhrspRqhOmQQpZ3bfQ8Xn6x2xia Dgig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=sFeWiz2W; 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=alien8.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i189si14397414pge.114.2022.02.08.23.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 23:23:58 -0800 (PST) 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=@alien8.de header.s=dkim header.b=sFeWiz2W; 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=alien8.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EDEFCE030D44; Tue, 8 Feb 2022 22:36:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358771AbiBHNVn (ORCPT + 99 others); Tue, 8 Feb 2022 08:21:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349841AbiBHMM7 (ORCPT ); Tue, 8 Feb 2022 07:12:59 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 655D2C03FEC0 for ; Tue, 8 Feb 2022 04:12:58 -0800 (PST) Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id DC6C31EC02B9; Tue, 8 Feb 2022 13:12:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1644322373; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=y/e2GhBcXzHymJgRHX3UzkyGtFMTu3KEOpP5+yH5sGI=; b=sFeWiz2Wkl3Ujq/1CRN9aZeFQY8lvHEBQd5WzF9YEu28REyBhrAwJqpu8nyM7cTEfrBTpu R5xu0eUjuYiH8YFQ0v8VI16iNYPAL8+2CfrCfMB6pNlbNd+JtJ4Zrel3uri6pg7zKHhrRR Ki2MEP8chAEJrpKWIUi7ONPgDXEekUA= Date: Tue, 8 Feb 2022 13:12:45 +0100 From: Borislav Petkov To: "Kirill A. Shutemov" 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: 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=utf-8 Content-Disposition: inline In-Reply-To: <20220124150215.36893-24-kirill.shutemov@linux.intel.com> X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, 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, Jan 24, 2022 at 06:02:09PM +0300, Kirill A. Shutemov wrote: > +static bool tdx_accept_page(phys_addr_t gpa, enum pg_level pg_level) accept_page() as it is a static function. > +int tdx_hcall_request_gpa_type(phys_addr_t start, phys_addr_t end, bool enc) > +{ > + u64 ret; > + > + if (end <= start) > + return -EINVAL; > + > + if (!enc) { > + start |= tdx_shared_mask(); > + end |= tdx_shared_mask(); > + } > + > + /* > + * Notify the VMM about page mapping conversion. More info about ABI > + * can be found in TDX Guest-Host-Communication Interface (GHCI), > + * sec "TDG.VP.VMCALL" > + */ > + ret = _tdx_hypercall(TDVMCALL_MAP_GPA, start, end - start, 0, 0, NULL); > + ^ Superfluous newline. > + 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? Of all the places, this one needs a comment. > + 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? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette