Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp57437pxb; Tue, 15 Feb 2022 05:33:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2szOjGT6F3VPAHDN3/Thibx19F/KoLFn44QEI1JPqOAlnBUzyJn1znqpgrWmeMRt8YUk8 X-Received: by 2002:a05:6402:354d:: with SMTP id f13mr3901197edd.289.1644932025897; Tue, 15 Feb 2022 05:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644932025; cv=none; d=google.com; s=arc-20160816; b=nukskqauI1ip6JxY7QzZ1TOCs8QmRDvm8pFTShaUgFOP9dj6n+gQdx6OwR7VqPOAdd 47voCXZzBWj2/+t2qDb49+fe94KZZHXpxOS1NEThilNbCkBq/LaOQdN1fCNfVdZ8mkYm YrKsfESLx0s6WoBxpF5bRsAV2T1D1lgdQhTU5ugs+lKet7OQNWwpmOxTpj+YmxcyF/Rv 5TX9A02GVmLBCoI+s/dzXZMUted7eQcKT+hbQu64x9yhPuTGJhsTIMC+cXrY+Tajt9Qz BKi3ja5G++X03iaBVhpbe6GJQbcP2GMjiul1kQaCjh8LSFouQFQTxeDVsUjxke9kAEmT /KJQ== 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=bZ/hPvhB6l/GT98IyjxTlesdblulBOqx0t8aw3A0jHw=; b=Zm9X853lzPErMt5NOnQObEK0x+lSst5qzYdAxZMqLySffY4uiewfwJVAIH1ZOScNtj cSraUb01ChDPNFNVtBkR6dus9OJdMB2PTx3Vzgolqc7ORf+3AgwrSIKrC24lN1INdB7W y7Cs5JsLFDrzwvN39XG2Sn/SICYC7kutMi9tIHB1xfhxRDo8QR48MRi6WIZB5/AmcUiS /lakMLde5kL0Vj1GCYVUilnW5yGLOT9Ks8VY6q5Vcb/EpaVM9eapuo7Mpq+0IdqMxkAK D8u/HNeVRYpnqmiCI+Zun3tnRcUiQ4EMAbAk+iGI2HDYontfJ4icq68FhHSFfYI/bcxV E7vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=uJNVxw9r; 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 qa32si3259282ejc.992.2022.02.15.05.33.17; Tue, 15 Feb 2022 05:33:45 -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=@shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=uJNVxw9r; 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 S238001AbiBOMoC (ORCPT + 99 others); Tue, 15 Feb 2022 07:44:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237936AbiBOMn3 (ORCPT ); Tue, 15 Feb 2022 07:43:29 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AFA71111BC for ; Tue, 15 Feb 2022 04:42:40 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id u6so36618664lfc.3 for ; Tue, 15 Feb 2022 04:42:40 -0800 (PST) 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=bZ/hPvhB6l/GT98IyjxTlesdblulBOqx0t8aw3A0jHw=; b=uJNVxw9rQQ9Ric3MtAGmVVmQ9e9tx8jQSgqxtiLH6Tj9yRS0M5phMpCdbQO2CuS6Lo 2HGd2G5RWhNEhynYJ75YmyD3ubNHBr+EmixSyhOVAAc1UFQlJYdRqEZ9tyVhySlGZVE7 dAd0xOczoO+SD/q/GWS5j625mh91rbBwm1JR6GZHaUA/Ox9usN2kusbueTAnKHUJ6kjf fk7v8g69zom2gOxNIPReCCZP0/wysVgPU1aXmkvq6tMliKexaCj588lYYxM2fkBbdADt T+UPbUVFQeVZzDNCmcWzvU9c5LGMxOlCAWo3RDuQeVVxuK30MNLWblvyBbxH/cfOpYTh OVaw== 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=bZ/hPvhB6l/GT98IyjxTlesdblulBOqx0t8aw3A0jHw=; b=RuB3OyvzHXxjFsIvrIz3yinlnUW8iyqCwwX3Epuj45LXQWmVhFB6QuyhyBZChhrujM kzJGd5XDi+nPH583AqCf17Lw8TkA66rUw0plYzVCRdRc+ZnM94LSENd4QnK9OdtnPm5/ Xd+/wO5khD7WWd4jKL979b5CwjrPEEPL/+iyK2x9ylK/bMqDRv0OK4bfmjfXsfWY1gA2 KjqrLrKtSCKA1e7KeSZkyNtkDlnX2aWHYChklaowNhNw5hkoPT9Ybjl2zULqDgoMo4yi 0q+2UPCA1uGBMoVxsbWX5DzdZ8BDSfvn7MYe3M0QCNO2ry2bbEvuuHD6Uc7K82pbe6vT 2UBw== X-Gm-Message-State: AOAM531vodVPjjLBDO4N9osuHGVN794HbcJNUy7Puo5MNdLVdzswq6Gz E3wcTwEDKdsHvqS8DFZUhjHfxw== X-Received: by 2002:a19:6549:: with SMTP id c9mr3066138lfj.150.1644928958898; Tue, 15 Feb 2022 04:42:38 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id bf10sm4394566ljb.130.2022.02.15.04.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 04:42:37 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 6DD81103F44; Tue, 15 Feb 2022 15:43:31 +0300 (+03) Date: Tue, 15 Feb 2022 15:43:31 +0300 From: "Kirill A. Shutemov" To: Borislav Petkov Cc: Brijesh Singh , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , Andi Kleen , "Dr . David Alan Gilbert" , brijesh.ksingh@gmail.com, tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH v10 21/45] x86/mm: Add support to validate memory when changing C-bit Message-ID: <20220215124331.i4vgww733fv5owrx@box.shutemov.name> References: <20220209181039.1262882-1-brijesh.singh@amd.com> <20220209181039.1262882-22-brijesh.singh@amd.com> <0242e383-5406-7504-ff3d-cf2e8dfaf8a3@amd.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,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 Sun, Feb 13, 2022 at 01:15:23PM +0100, Borislav Petkov wrote: > On Fri, Feb 11, 2022 at 11:27:54AM -0600, Brijesh Singh wrote: > > > Simply have them always present. They will have !0 values on the > > > respective guest types and 0 otherwise. This should simplify a lot of > > > code and another unconditionally present u64 won't be the end of the > > > world. > > > > > > Any other aspect I'm missing? > > > > I think that's mostly about it. IIUC, the recommendation is to define a > > new callback in x86_platform_op. The callback will be invoked > > unconditionally; The default implementation for this callback is NOP; > > The TDX and SEV will override with the platform specific implementation. > > I think we may able to handle everything in one callback hook but having > > pre and post will be a more desirable. Here is why I am thinking so: > > > > * On SNP, the page must be invalidated before clearing the _PAGE_ENC > > from the page table attribute > > > > * On SNP, the page must be validated after setting the _PAGE_ENC in the > > page table attribute. > > Right, we could have a pre- and post- callback, if that would make > things simpler/clearer. > > Also, in thinking further about the encryption mask, we could make it a > *single*, *global* variable called cc_mask which each guest type sets it > as it wants to. I don't think it works. TDX and SME/SEV has opposite polarity of the mask. SME/SEV has to clear the mask to share the page. TDX has to set it. Making a single global mask only increases confusion. -- Kirill A. Shutemov