Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2996062pxm; Mon, 28 Feb 2022 09:58:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3aRbhFkcXSQVkVT8j3WLutuoQDOaW1CHQ544jrC8689us5+K6B7n2iPjLg/1GLsCccy0o X-Received: by 2002:a17:903:40cc:b0:150:199a:c381 with SMTP id t12-20020a17090340cc00b00150199ac381mr20481550pld.22.1646071130762; Mon, 28 Feb 2022 09:58:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646071130; cv=none; d=google.com; s=arc-20160816; b=ifYDZZdT8wrVe40wJPhpWPdVO2FlAe447ad9vQrswZ5CivoeNJ9Vao97taz2Q0TX8J 08RYEbk2dDRV/zFWxBYrPIdjQ710rsDRGCD/J9ed+G3qPbtbFPm0BLVlfsWu4Iep+fgG +UjXbLDidihHbpxhxXqzMJBmhMhQwyOoZbiXfcvhwOEjFD8cKrKFrqrAo1CEaKPXggD9 S2u9alhNXKLRMbSEX3iPugFw4wCWRGLOhntP6qwgWs859NZf9WipHrb2OgWzvxl/qMnB v1fPaOjEROCzzinmgMMrWaMW4JxkxjORvYjy4pDBfTqyizX085T6Ts6JTTjs4+8LUIT+ 8JXw== 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=bTJs+XJuztigw3GbZ3t30dvbSAKamp+b28u3hPimDdk=; b=gWxYcnulq9aAzQlTAL0Y1Xm4HKwkcL/t2HcNh7zZccZ3YqspkLy6rtDs3tpGrnUSSz eFRKItF1XhfsKl6RzC8eUqli6OdF/ZDmMmpO8ZgAuc5qFTvYhbyb5d/QOyf1+zfZmYdn +hDwzfxZf4We+U4Gu86o5K8UWVHK8wotJtl9b+WaD2DPodrXY7/y0O3i5X2A56MQhBwC UcPm53OlaNwxi6lSpEOAunFDskKRpAG13JcaI27Wv/afTylpcGJKmxNJ0Mx4KDLGFQjP 7RBp9W5MTumrBvXZdzCePvL5I3XUingAtyX65GHGu4DrlrYExMIbtd286HQRARWdP88e DYgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DJokzQ5c; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 17-20020a630d51000000b003439d3fecf6si9853109pgn.493.2022.02.28.09.58.34; Mon, 28 Feb 2022 09:58:50 -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=@redhat.com header.s=mimecast20190719 header.b=DJokzQ5c; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237928AbiB1RDT (ORCPT + 99 others); Mon, 28 Feb 2022 12:03:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238038AbiB1RDL (ORCPT ); Mon, 28 Feb 2022 12:03:11 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85C41DF4B for ; Mon, 28 Feb 2022 09:02:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646067751; 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: in-reply-to:in-reply-to:references:references; bh=bTJs+XJuztigw3GbZ3t30dvbSAKamp+b28u3hPimDdk=; b=DJokzQ5c8Iy0OP7UpQSJKS+AOQaLK+/vhMerDM29W9jogHBmD1bTK+9KaUCTOdppPPzc5g 4ySixw1XMemtxC/NP/6X8GlnSgCala9EzSn3iLWUEIItxQHk3PxF3iPbNC9odHZdTNhhJC h3XpIgDjBaSich67qVAaxu4zXbKEpO4= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-148-4-2kcuvXMD6L1z5-gr9s6g-1; Mon, 28 Feb 2022 12:02:30 -0500 X-MC-Unique: 4-2kcuvXMD6L1z5-gr9s6g-1 Received: by mail-qk1-f197.google.com with SMTP id 2-20020a370a02000000b0060df1ac78baso11619359qkk.20 for ; Mon, 28 Feb 2022 09:02:30 -0800 (PST) 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=bTJs+XJuztigw3GbZ3t30dvbSAKamp+b28u3hPimDdk=; b=unzlS1KDt5Y576Mu4EmW82lYIWJRX8c3paTJikgFvBNL88mssuuswa/30nGX5LAnXN zjoViSKaG9XCvWNeDx34q8/LEcajhJ+CIznpff1APR10OAqilgTMeLH6iYR5nuXM1j5O hCP4gTY8EoXYGf5vN6VNvMzIbOu8UJ4TLX52tEJ6MF2g+lPJXlEZLukpe8AqASdj4rdG DlvLNdf+zvuCqs8SfNohHK718YMsjS3a2JFBuGFYE7OXyAvzq0/taqr6x87E2l1nRnBl DKN3pK+7temCxmyvZHN09hgQGf0Q+t5jnoAyxAmYulvjPLlpJNMeknwFA3Ucc9GAIkpK cOZw== X-Gm-Message-State: AOAM532BhV+qzuBhzQ739PKWZUnpxbUmf59xlNSCoyG4fCgSD/HXLzaK AWS769FelEpJBePnxi8gBqjSEXtIW/ajYyOSztsXtv1LXrMm1bxNuEVKCy3swyn0BMFuV7IBUZt ZdzYNibMT3SmSjr3WSeTlVSHc X-Received: by 2002:a05:622a:13d0:b0:2de:7076:72ef with SMTP id p16-20020a05622a13d000b002de707672efmr16576284qtk.394.1646067749623; Mon, 28 Feb 2022 09:02:29 -0800 (PST) X-Received: by 2002:a05:622a:13d0:b0:2de:7076:72ef with SMTP id p16-20020a05622a13d000b002de707672efmr16576233qtk.394.1646067749291; Mon, 28 Feb 2022 09:02:29 -0800 (PST) Received: from treble ([2600:1700:6e32:6c00::45]) by smtp.gmail.com with ESMTPSA id i20-20020ac85c14000000b002de4b6004a7sm7048642qti.27.2022.02.28.09.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 09:02:28 -0800 (PST) Date: Mon, 28 Feb 2022 09:02:24 -0800 From: Josh Poimboeuf To: "Kirill A. Shutemov" Cc: Dan Williams , 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: <20220228170224.igzvf7e3tc6ujrfq@treble> References: <20220224155630.52734-1-kirill.shutemov@linux.intel.com> <20220224155630.52734-30-kirill.shutemov@linux.intel.com> <20220227220526.3rrmy3u7j2xpelcn@treble> <20220228163713.5eewdwcqhmulsp4z@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220228163713.5eewdwcqhmulsp4z@black.fi.intel.com> X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,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 Mon, Feb 28, 2022 at 07:37:13PM +0300, Kirill A. Shutemov wrote: > 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. X86_FEATURE_HYPERVISOR -- Josh