Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5122801pxj; Wed, 9 Jun 2021 09:37:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8UMMabPl7J38qMOTAEE7IIhC9a6YChsG79qG2KE1z2crMXIesrAh+i80FNHVlrWHTdu0z X-Received: by 2002:a17:906:3395:: with SMTP id v21mr766851eja.102.1623256647914; Wed, 09 Jun 2021 09:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623256647; cv=none; d=google.com; s=arc-20160816; b=q4ezupXtQy3mQwzheRCK47n3A6+boT0p1ac5KEj8BmU45h951Z0rTyj1KqLY1KRJFp rzzhFZRRXwJC9OxR5YsmR3RL9D8P8g4pnOwRJ+WMu5Xx6lMqh7ckcLdu7N6OViQYW/FT LWdSYmlGN849sN781yqw3SKpX8ue2b7UcHX0Z7Af6F6T+yW4Dpv3D824LBpIUUdIt2M0 eoxzZhezZrxJGt6JmBAWSOluH8/VBjumi2u7GVkZe8Jhug5KP65gJ39VeRaYfZFcduGq 3EVwR6ZUQ1OF8Lt45WEmB5lanQCONSkQCAH4BZuxvXhBFyiS6GoTpzLKsGcddXOn18Dk UAZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=RQn0V8xfk+1KtHDPotfEY13yplt1RHGKMzBaulyDQ8k=; b=eQv9SHokk/Rj87hBqzwfuNl9kGmThVeKoxXWl0CEWxZNLJfCvRph+BcVuZtL622qDB aqSu0Aje0sqR8xaQJT/+a/LcqYRciDlQ0ZSM7to8ZmMMk7ljh5DC5XVKED7SQ0DNu6Zf 65EspLe51rEevr4d8WDC2/f1Y+HzDLCLIgvccalVbc2IdusH5NGpFf1o2BXnWG4wxR17 KKvPlc3vadh4LPR2X9DZSGOGuF+lR59yDbBfKQ7cNfc0lck9qWmKl7RXQG/v27k7L52W BDYv24oeKAwX6gcnVBv7Zx32ApZ0rkL5s1Orvt02nrCtVknGFBmEaKEXposUwNddBcWO dORw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PPiPJw2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si209416edd.398.2021.06.09.09.37.02; Wed, 09 Jun 2021 09:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PPiPJw2y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236080AbhFIQOX (ORCPT + 99 others); Wed, 9 Jun 2021 12:14:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbhFIQOX (ORCPT ); Wed, 9 Jun 2021 12:14:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A074613B1; Wed, 9 Jun 2021 16:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623255148; bh=PKcMvlnuCGLjsb4hOzK8hNIvlkQ5Y4RWi55WNvghvU4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=PPiPJw2ymMgctmPJluUp2SzAbWsrj2hTh3Tnt4XAxDDWmdQgLwek9UEmTsAf5S2PF +eLxnF2d6xXxPytI5wB4OUgY+JGAhXMbXwIUrnCRHPG48qNkgG5wjAF+QoTWfbtIQ5 vx/ZiVVnk2LKEFDSQPvYY/q+j4ZBOr/E96pnl9o0PnAdHeOaa94zy3XruU8aUkEPUw nO2QTaA0v5EminN35R8cZqcSTgP1b+Mcn0Xi72cp21rRb1ycLV7yns8s2Rf+H/NoYl y03jBacciv5oDtT53eFnoN70bVYclsLsM+iLOlKd/pI7VsoP+Q5jf3b2neuDzO3MuO 4n1/QOBRFsGLw== Subject: Re: [RFC v2-fix-v4 1/1] x86/tdx: Skip WBINVD instruction for TDX guest To: Dan Williams , Andi Kleen Cc: "Kuppuswamy, Sathyanarayanan" , Peter Zijlstra , Dave Hansen , Tony Luck , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , Sean Christopherson , Linux Kernel Mailing List References: <20210609011030.751451-1-sathyanarayanan.kuppuswamy@linux.intel.com> <682f0239-8da0-3702-0f14-99b6244af499@linux.intel.com> From: Andy Lutomirski Message-ID: Date: Wed, 9 Jun 2021 09:12:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/9/21 8:09 AM, Dan Williams wrote: > On Tue, Jun 8, 2021 at 9:27 PM Andi Kleen wrote: >> >> >> here is no resume path. >> >>> Host is free to go into S3 independent of any guest state. >> >> Actually my understanding is that none of the systems which support TDX >> support S3. S3 has been deprecated for a long time. > > Ok, I wanted to imply any power state that might power-off caches. > >> >> >>> A hostile >>> host is free to do just enough cache management so that it can resume >>> from S3 while arranging for TDX guest dirty data to be lost. Does a >>> TDX guest go fatal if the cache loses power? >> >> That would be a machine check, and yes it would be fatal. > > Sounds good, so incorporating this and Andy's feedback: > > "TDX guests, like other typical guests, use standard ACPI mechanisms > to signal sleep state entry (including reboot) to the host. The ACPI > specification mandates WBINVD on any sleep state entry with the > expectation that the platform is only responsible for maintaining the > state of memory over sleep states, not preserving dirty data in any > CPU caches. ACPI cache flushing requirements pre-date the advent of > virtualization. Given guest sleep state entry does not affect any host > power rails it is not required to flush caches. The host is > responsible for maintaining cache state over its own bare metal sleep > state transitions that power-off the cache. A TDX guest, unlike a > typical guest, will machine check if the CPU cache is powered off." > > Andi, is that machine check behavior relative to power states > mentioned in the docs? I don't think there's anything about power states. There is a general documented mechanism to integrity-check TD guest memory, but it is *not* replay-resistant. So, if the guest dirties a cache line, and the cache line is lost, it seems entirely plausible that the guest would get silently corrupted. I would argue that, if this happens, it's a host, TD module, or architecture bug, and it's not the guest's fault. --Andy