Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4937496pxj; Wed, 9 Jun 2021 05:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO6LS93q/fABzpsF4H7eTHrexRur6J0CTNjofCYLXN9DFV6cGFB930CTHqAcgCEEwYjinE X-Received: by 2002:a17:906:660c:: with SMTP id b12mr28958185ejp.86.1623242564252; Wed, 09 Jun 2021 05:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623242564; cv=none; d=google.com; s=arc-20160816; b=Rzl7PY8pVrmnU2TQl2DlxOnyG12X4eD45nxp1jNosHxH2qmOGCNYNrw2TgIpuXMea3 jBcrIsIRg3nLS+tkq2lS+U8lpHXsCIxC442am4MeC68YUYsRt9LKi+lp1my706WEi8/F NbG16XACy5+1RnLr4DbkL5e++vSLhyJAM09soEuFzJGCV+UqdEuzwuOh0D8SBAdd5CA3 s+fpFloEjaqhN6Gs5cjtRgx5tsnxBvYNZcyV8v/n/usBgmhU5Dq0aAC1wXkU3sGRzjwI 1kz61D+s5EgyJ3O7hW7r7DYPdQwIplr8//uG23sp48KtXCdQPhH051daBFIYedceZLcN rAbA== 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=zSnEhqkT1Z+DeW90dYgUgwmhkZTddL0/KUpG0/wiDdE=; b=NTeeXrsp0ueuKthEU3g5ooJIOhHwC7u75LizP4C0VeQqsCG7nsMpYjkwB2mUBQGnO1 J1nbbmweBIomKPzkTMelotz8gS9vbDWfTRZ5apVsy8g7X8WBFBZ2pRYfH8KaZM383cID tmraVJeXBC67DRUmfLUwlsZgoT7eP0KH0b1sFFIcc+Y2lXFz5xagAkzJhfoB1XCZJVWp u/BmrcQOJtsRWyBzFDzS8TaUnlsvonAv9jjoQ8pp4jnHJs4CDySCkai81lzK+gp1oG2H tJzkq7sNWVdN/DEcmj+GXEArBTPAZ1RwkyVrWhZjYNZUjDV+7F27LAvJUEaCT81Cvh52 sqnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YYstf3Dn; 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 z16si2093429ejx.706.2021.06.09.05.42.20; Wed, 09 Jun 2021 05:42:44 -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=YYstf3Dn; 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 S229588AbhFIEEa (ORCPT + 99 others); Wed, 9 Jun 2021 00:04:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:53078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbhFIEE3 (ORCPT ); Wed, 9 Jun 2021 00:04:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B5C3610A1; Wed, 9 Jun 2021 04:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623211355; bh=vG4MZxfZKKAdoDa8I1pKOegdBTS9SI6qjGNjRE+Y3xI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=YYstf3DnnS6f/0+GrLOXK4nzyU5W6nT6O3AszfAKV09kcpG09VXBbFTjrnGGF5vdO oUMvMeiZRuSdzfMqE0r/Xtihm+J3EwbiszOmobbcMJ3C5YPrp3WKaWpQ1jhRGEJ4Hs dRNc5HmYZG7Mdj5kKCFlj+2F0J2F6a8g/xzMy0u/XLo+V7daRmQSMNx2DR4rTdcNv5 9tm3Dde1P/+TgNdmtlhpvz95F/SqNuhPuL8XkTCc3UnnYRjqcvCs5KMRCSFEOgQqxf PkEokeYpWsUwcNq89+IatiPEiyl4bDy0TU0zxR5SeRgpX6HjFbIgRbHwKGqLTTUKFb 1Adcc+mQa95Iw== Subject: Re: [RFC v2-fix-v4 1/1] x86/tdx: Skip WBINVD instruction for TDX guest To: Dan Williams , Kuppuswamy Sathyanarayanan Cc: Peter Zijlstra , Dave Hansen , Tony Luck , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , Sean Christopherson , Linux Kernel Mailing List References: <20210609011030.751451-1-sathyanarayanan.kuppuswamy@linux.intel.com> From: Andy Lutomirski Message-ID: <23418f34-7c03-7477-6fbf-1b36b4718cb9@kernel.org> Date: Tue, 8 Jun 2021 21:02:34 -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/8/21 8:40 PM, Dan Williams wrote: > On Tue, Jun 8, 2021 at 6:10 PM Kuppuswamy Sathyanarayanan > wrote: >> >> Current TDX spec does not have support to emulate the WBINVD >> instruction. If any feature that uses WBINVD is enabled/used >> in TDX guest, it will lead to un-handled #VE exception, which >> will be handled as #GP fault. >> >> ACPI drivers also uses WBINVD instruction for cache flushes in >> reboot or shutdown code path. Since TDX guest has requirement >> to support shutdown feature, skip WBINVD instruction usage >> in ACPI drivers for TDX guest. > > This sounds awkward... > >> Since cache is always coherent in TDX guests, making wbinvd as > > This is incorrect, ACPI cache flushing is not about I/O or CPU coherency... > >> noop should not cause any issues in above mentioned code path. > > ..."should" is a famous last word... > >> The end-behavior is the same as KVM guest (treat as noops). > > ..."KVM gets away with it" is not a justification that TDX can stand > on otherwise we would not be here fixing up ACPICA properly. > > How about: > > "TDX 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 TDX > 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. If the host fails to manage caches over its sleep > state transitions the guest..." > I like this description, but shouldn't the logic be: if (!CPUID has hypervisor bit set) wbinvd(); As far as I know, most hypervisors will turn WBINVD into a noop and, even if they don't, it seems to be that something must be really quite wrong for a guest to need to WBINVD for ACPI purposes. -Andy