Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2987605pxm; Mon, 28 Feb 2022 09:48:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyp9fGJSngqI5OLklibmSLH5bDz0dpviWiJaiuqJXa+EsJuXFUPBFcSO3uVtk6akRk3pSB X-Received: by 2002:a05:6a00:16d6:b0:4bf:325:de2f with SMTP id l22-20020a056a0016d600b004bf0325de2fmr22675038pfc.7.1646070499475; Mon, 28 Feb 2022 09:48:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646070499; cv=none; d=google.com; s=arc-20160816; b=NtRcNjZJA/pougYjaMGBBGEW/MlgjnHlF/kllSwneTKcKwkwlD351FDfAeQOfzAn3w IEaP32zxXKmVhz4/bbvazr5M21hteOiEXR6dkGfqEG49to8SbA/8ihKwZE3rqEg9swK4 CDJ40luFSbJGJBaqjpbF1xyuQKE3tZSk+GteMExyrd5PADIVoLJTKq9RGXus62WziSKK UKeS0NcqzIvnrG7FGub+WN5B1O0xbTrb0IEcbdTqDOjBS1BdIDsAVkfUUUtjraOKIfpo 1J45PIAt5i4Nyx+5V+GbZflTCzOlcpWsK32NdkvrDQARVqxgA9+oT+w+GX4sSrEhvJ0g yLMQ== 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=WBm6NRTJN4WhDbdzNl3Dp12fEXnBggnnAm/N5DZ+cNk=; b=zFFm/xj1hh28+IZGFuMlwwxUbtbuA2LSGRL1fFzUrYpPpw1jVskRJS62Ut3eoFCPLW cq0sxFQCuuscciLcy27yg1fIPNfZ4ncRDGPZlxxkD8KzWjXMSFl+jnTDIl28cSUTiPVI wrDtrf2TPKEDyiqnkrhGjPZyDTpdz45Ns3xr+UHQ9M1sO9eSFe8TlEPgIJZ/+Z+Jbg2o nHtCGgDdkB6jOzYnF3XSLgiEJ7IkZD67R+e9jTNfg42gFakhu65vlBttM6k4mDgaYBHW lk5YuaO68+cNjBdvtQaVguFiFKqP5IZkhYaY9hXVDt1jHDyHwDO7yzYerjesOpXW8Jnv r9mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N2tu3U0E; 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 i8-20020a635848000000b00362ec71645esi9793179pgm.15.2022.02.28.09.48.02; Mon, 28 Feb 2022 09:48:19 -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=N2tu3U0E; 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 S234352AbiB1Qho (ORCPT + 99 others); Mon, 28 Feb 2022 11:37:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiB1Qhm (ORCPT ); Mon, 28 Feb 2022 11:37:42 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5A264706D for ; Mon, 28 Feb 2022 08:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646066222; x=1677602222; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=9FeEydnMapu+ZhBBImuOhTDsk/PcwUc5kO2GwFXbvzY=; b=N2tu3U0EwCL2PgZvngkgzBtXhAbo5If4R2qaKG90N7AT022HWB/EnThI c58JXB1v6e5DXSiolsqxkhQkuYQGNT+O+j2ajNZetbyZNJbIoXgwCaaDz +eVbfTx2P+LN3TGuCAlYuPgdZ5tKhxr3OuWSOvoHdc/prQWpEfZhyt7DO tfiYy+KTqg9RGJth9rraAECDA6ao/8vZ6OZ7XUpZjNodAC4JTZNHiACn4 YGlJvBtoO0dBDi3Qg6U2pEjM0eZFqh7jrcBjd9V18BfxH4h3C7jajNyvN 1FUO/AiD8Oj0LW/AwZ21TeVL+moajJCImy7HCWQyTq/G3K8Cm6BGCcTLO A==; X-IronPort-AV: E=McAfee;i="6200,9189,10272"; a="240333921" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="240333921" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 08:37:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="640938471" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 28 Feb 2022 08:36:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 7052B142; Mon, 28 Feb 2022 18:37:13 +0200 (EET) Date: Mon, 28 Feb 2022 19:37:13 +0300 From: "Kirill A. Shutemov" To: Dan Williams Cc: Josh Poimboeuf , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Kuppuswamy Sathyanarayanan , Andrea Arcangeli , Andi Kleen , David Hildenbrand , "H. Peter Anvin" , Juergen Gross , Jim Mattson , Joerg Roedel , Kuppuswamy Sathyanarayanan , Paolo Bonzini , sdeep@vmware.com, Sean Christopherson , "Luck, Tony" , Vitaly Kuznetsov , Wanpeng Li , Tom Lendacky , Brijesh Singh , X86 ML , Linux Kernel Mailing List Subject: Re: [PATCHv4 29/30] ACPICA: Avoid cache flush on TDX guest Message-ID: <20220228163713.5eewdwcqhmulsp4z@black.fi.intel.com> References: <20220224155630.52734-1-kirill.shutemov@linux.intel.com> <20220224155630.52734-30-kirill.shutemov@linux.intel.com> <20220227220526.3rrmy3u7j2xpelcn@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Sun, Feb 27, 2022 at 05:34:45PM -0800, Dan Williams wrote: > On Sun, Feb 27, 2022 at 2:05 PM Josh Poimboeuf wrote: > > > > On Thu, Feb 24, 2022 at 06:56:29PM +0300, Kirill A. Shutemov wrote: > > > +/* > > > + * ACPI_FLUSH_CPU_CACHE() flushes caches on entering sleep states. > > > + * It is required to prevent data loss. > > > + * > > > + * While running inside TDX guest, the kernel can bypass cache flushing. > > > + * Changing sleep state in a virtual machine doesn't affect the host system > > > + * sleep state and cannot lead to data loss. > > > + * > > > + * TODO: Is it safe to generalize this from TDX guests to all guest kernels? > > > + */ > > > +#define ACPI_FLUSH_CPU_CACHE() \ > > > +do { \ > > > + if (!cpu_feature_enabled(X86_FEATURE_TDX_GUEST)) \ > > > + wbinvd(); \ > > > +} while (0) > > > > If it's safe, why not do it for all VMs? Is there something specific > > about TDX which makes this more obviously known to be safe than for > > regular VMs? > > > > The patch description and the above comment make it sound like "we're > > not really sure this is safe, so we'll just use TDX as a testing ground > > for the idea." Which doesn't really inspire a lot of confidence in the > > stability of TD sleep states. > > Agree, why is this marked as "TODO"? The cache flushes associated with > ACPI sleep states are to flush cache before bare metal power loss to > CPU caches and bare metal transition of DDR in self-refresh mode. If a > cache flush is required it is the responsibility of the hypervisor. > Either it is safe for all guests or it is unsafe for all guests, not > TD specific. Do we have "any VM" check? I can't find it right away. -- Kirill A. Shutemov