Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19978841rwd; Wed, 28 Jun 2023 17:53:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Fk02H93wnSSiK3auvfgrISAllFBEGgjUMicjB3aFINqoeKz2mQD87accY2TO00v10pv7O X-Received: by 2002:a05:6a00:1a01:b0:65e:1d92:c0cc with SMTP id g1-20020a056a001a0100b0065e1d92c0ccmr3779037pfv.10.1687999980208; Wed, 28 Jun 2023 17:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687999980; cv=none; d=google.com; s=arc-20160816; b=O9yRBsxvlzEfteANSAHfQT1eBMXduNHUOePwaLKYCZrs1+m2r4JQTQdnryHoCH9S0A Cp8MqnfQMsFRWuzeObzpher8xq5JsOD/uxJbdoSpnK/N/kEtUK0A+eZ/gk/wz0kifsT1 0pFwaHJ3fstMOo3/A+uclJDaIAAQ69i6AjSQpyH0G1KBuFHyF6K/MfE1+WsC4cdem1Q6 V0cJYPEA05u93HnI6LUllKFKrAfjDr1L/RaIaUlltrqLDYdGPVGpCEetGmCPr4yzwiYv tLNxCf7uQarIU7R+AmmKkhxY2HbZpKrDrMt42sQI+YRPaPZS1wGBeOzCcObkeBCRFxVj gYPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Fk8LHel2FaQC480M0ZAORNBVqXT2ke43gC5IFGWWjGA=; fh=bjHePpHdY0ENANwmOYWhnEWYcULZiajKQyfVdfAOXQw=; b=R42O7FdFTn6lWMDWTR7jjdYW+1LnTJ2r4ojKYETwKAyQPaKtkE69ysvx4gpkuq0gu3 xQ2xosLC/czbOpEmjEaeuSpcJoLL8V3Ob/Tq5hNAPwQ5qYLONN2OAmnoNfcAMIG0x1NX jYO7+NnZ6dVIEIBsyNBNo1SAy0zT2u3j5IHJ5lbZJ9VGWA4W6mmBb/bpIBa6Q3QIVOOc BAD3vwUmd/FRzPtjid74s9Gxs4e2lG0jcBf7n2L/4coTwQ2DYJ5Np+LpUE9pUNB/sekx QTQUWIJb2zUXm9/B27H4dd/5eCEiDp6N/iHoYMkuqnmbea370lVCPEsTN8FxUmJKpsmZ 6fYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="QV/GX4LH"; 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 cg20-20020a056a00291400b00646672f2be3si7974262pfb.282.2023.06.28.17.52.45; Wed, 28 Jun 2023 17:53:00 -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=@intel.com header.s=Intel header.b="QV/GX4LH"; 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 S230314AbjF2AcP (ORCPT + 99 others); Wed, 28 Jun 2023 20:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbjF2AcO (ORCPT ); Wed, 28 Jun 2023 20:32:14 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884161BFE; Wed, 28 Jun 2023 17:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687998733; x=1719534733; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=sqRArJ9svcYk8Srvkb99FaaP4ltBUPw0xtk0ZlIVfjk=; b=QV/GX4LHVL7oonoqRN5/fZJrvDXcnSlIE1vr3SJpN+wVcqi7tV2+a/26 9ib7h0OXwHGOrou380D4jA2cg1s2crAqxq3AwkK+hMO0PVEjcceHEyok0 +RJv/OmMyOElyAXAI83327/iWEqo6xclkOOX0yA5G13vVZdzo9jTIY/W1 4nBae17Q12w5FWDZUsALojGPAIowo6SseuQpY1jNFlQn4V0aqweEyHnxp yvPH62lrYVihlCQYeT16cBkXKrtxmPFG9BS4Rl+kD//8DNT8s0msJ8zAm CQL8SsEKbXuGyC3apiryjixqjSbe2KeYje7MLSgDGDDRPIjkNFqQfCW4c A==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="365455150" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="365455150" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 17:32:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="891226114" X-IronPort-AV: E=Sophos;i="6.01,166,1684825200"; d="scan'208";a="891226114" Received: from adamha2x-mobl.amr.corp.intel.com (HELO [10.209.108.95]) ([10.209.108.95]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 17:32:12 -0700 Message-ID: Date: Wed, 28 Jun 2023 17:32:13 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v12 19/22] x86/kexec(): Reset TDX private memory on platforms with TDX erratum Content-Language: en-US To: Nikolay Borisov , Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, kirill.shutemov@linux.intel.com, tony.luck@intel.com, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, david@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, ashok.raj@intel.com, reinette.chatre@intel.com, len.brown@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, ying.huang@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com References: <28aece770321e307d58df77eddee2d3fa851d15a.1687784645.git.kai.huang@intel.com> <1662a5ef-c333-d6d6-7605-060f4bcca6fd@suse.com> From: Dave Hansen In-Reply-To: <1662a5ef-c333-d6d6-7605-060f4bcca6fd@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, 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 6/28/23 02:20, Nikolay Borisov wrote: >> >>   +    /* >> +     * Starting from this point the system may have TDX private >> +     * memory.  Make it globally visible so tdx_reset_memory() only >> +     * reads TDMRs/PAMTs when they are stable. >> +     * >> +     * Note using atomic_inc_return() to provide the explicit memory >> +     * ordering isn't mandatory here as the WBINVD above already >> +     * does that.  Compiler barrier isn't needed here either. >> +     */ > > If it's not needed, then why use it? Simply do atomic_inc() and instead > rephrase the comment to state what are the ordering guarantees and how > they are achieved (i.e by using wbinvd above). Even better, explain why the barrier needs to be there and *IGNORE* the WBVIND. If the WBINVD gets moved -- or if the gods ever bless us with a halfway reasonable way to flush the caches that's not full serializing -- this code is screwed. There is _zero_ reason to try and "optimize" this junk by trying to get rid of a memory barrier at the risk of screwing it over later. I use "optimize" in quotes because that's a highly charitable way of describing this activity.