Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp257359pxm; Tue, 22 Feb 2022 10:00:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJwSey+Z8wdI0Mo3Adp3vwe6aDLtZDAb5augKekA6Ic+mnOUYfqglsjcc6TMtkcgIy5QiEGI X-Received: by 2002:a17:902:f54c:b0:14f:c36f:804 with SMTP id h12-20020a170902f54c00b0014fc36f0804mr8990519plf.119.1645552857966; Tue, 22 Feb 2022 10:00:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645552857; cv=none; d=google.com; s=arc-20160816; b=Napqtg9zXXC7V0zR1rnfTCzxTSrDfZCFa0NbePt1ISDN0cVHk8vvYBKR/1yqcpgnYT fgkZV8BptPy2Jo/ACCh6173oOyjNSNkLMtu0eXi2v4eT0y99L9BNoIssX5ai7GQ+Cff5 fLStYX2XX9DqoHijG/ajXjCjByqoO9LUsJuaEu+nuc/TDj4TLsVcnWXhF4PRhdvAkT4W Us079PATj+H5/alYoqOQ4rutUI0UjztH8lDL8KgR4cjttFW3Fsc88bNSHzreqewwiJfS q7AZwmCh6NBseamxLF1ewOllFyzluc62rLdfM1DBGRBk2DA4g5ZTXGeNp/ABi7cTtujy f97A== 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=04Nwcr+gH+zpahtDgRRtwfQnXG8gNPmcO7ROumgE4Ag=; b=U4O0M8xBhKzJ26nK9wCpJnTDDtFDZyh+J5zwfT1ziGQ/WnWrt7VL3+NxhnvlNaP+q1 n1z+cn7U4rsu/f4GF1ChU9jrFGzInnkoS1fr9e3Ilf70H4InHn2Z6lQHUCudk0x06yBR WB0sbB5Dx1pp+JcBMyk5no5J9qdfBUaFWIFD1E+8GnvGWjhtaMl+4FVQezAyvnuGzZQl K4UYjH+8iHowX3u1YyvH6U8FPGOa8eB7NWcW+F8MaOZP8HrrvifTJVtU6+rA9JNjpqPw XEJ6t8cNc5/ljCk5jd9/5v5/HCvJTMEJygcb7E/wplUeDm+XUUvae+nSvHmY/vTIHPMP DZBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VC5iP2qv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18si10303016pfu.27.2022.02.22.10.00.36; Tue, 22 Feb 2022 10:00:57 -0800 (PST) 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=@intel.com header.s=Intel header.b=VC5iP2qv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbiBVNxJ (ORCPT + 99 others); Tue, 22 Feb 2022 08:53:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbiBVNxI (ORCPT ); Tue, 22 Feb 2022 08:53:08 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAB0A9ADA4 for ; Tue, 22 Feb 2022 05:52:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645537963; x=1677073963; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=4jEaNgm19P8FjXxnGWpXVhLOGHVYgCc4zAob/JKxLo0=; b=VC5iP2qvCVdSiC0ldHIm4rfZH7KPkMKmQVBVHfnXDAwIKuqmNTt2bGa/ df4hAqp6V3821d8VA2e5Vj/AW9znrMJANL5b1Ay1ZY/+KvdIr2qt2mIJH bOZXFIn0MwWspon3BdCPXORpfnnz3rwkJ91wTOtFH2xvJ9US+8KwQ/yN9 R+CGkOlziz5wmKubfDxJky0ngXWMQKDy9s/MdPpEt2Xal/bXBkg+aKzec eR3jeeli0hbSlprJTBL8IsiZC4bbmKu2jK0RUh/bt5JYo1ENd7Bj4jZdy iwbgP7wnJM+Nt53+T7cbzuEX2LI+Te0wK4iDxGkGx5MZsKf+20GSp8nN8 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="251634366" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="251634366" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 05:52:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="627696968" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 22 Feb 2022 05:52:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id F0286142; Tue, 22 Feb 2022 15:52:53 +0200 (EET) Date: Tue, 22 Feb 2022 16:52:53 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: Dave Hansen , tglx@linutronix.de, mingo@redhat.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: [PATCHv3 02/32] x86/coco: Add API to handle encryption mask Message-ID: <20220222135253.k6ayc7zgpqrsoiex@black.fi.intel.com> References: <20220218161718.67148-1-kirill.shutemov@linux.intel.com> <20220218161718.67148-3-kirill.shutemov@linux.intel.com> <66fcd7e7-deb6-f27e-9fc6-33293ce04f16@intel.com> <20220218213300.2bs4t3admhozonaq@black.fi.intel.com> <7ebd6ba1-85a4-6fee-c897-22ed108ac8b7@intel.com> <20220221222856.c6b74b3n3fwqe6vy@black.fi.intel.com> <20220222110312.q7eaepfph2tyjq3e@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 22, 2022 at 02:37:27PM +0100, Borislav Petkov wrote: > On Tue, Feb 22, 2022 at 02:03:12PM +0300, Kirill A. Shutemov wrote: > > I would rather make cc_mkenc()/cc_mkdec() to operate on u64 (or > > phys_addr_t?) while pgprot_encrypted()/pgprot_decrypted() cover pgprot_t. > > It also makes set_memory cleaner: > > > > cpa.mask_set = __pgprot(enc ? cc_mkenc(0) : cc_mkdec(0)); > > cpa.mask_clr = __pgprot(enc ? cc_mkdec(0) : cc_mkenc(0)); > > > > Opinions? > > Right, do I see it correctly that the cc_mk{enc,dec}() things should > take a u64 as an argument and return a pgprot_t, and that would be the > most optimal way for all the use cases? No, not really. With u64-in-u64-out in tdx_enc_status_changed() we have if (!enc) { start |= cc_mkdec(0); end |= cc_mkdec(0); } to iterate over the range of physical addresses with shared bit set. With u64-in-pgprot_t-out we will have do add pgprot_val() there. We will have more cases like this in attestation code when we need to do hypercall on a shared page. -- Kirill A. Shutemov