Received: by 2002:a05:6520:2586:b029:fa:41f3:c225 with SMTP id u6csp20720lky; Wed, 9 Jun 2021 14:42:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGJ2Mjw/WTP549PmErQ2ocN8xqliBlEKApazVvEOmSnALfioe2l7zitcRr1YC+62DSq7jI X-Received: by 2002:a05:6402:685:: with SMTP id f5mr1387587edy.178.1623274930576; Wed, 09 Jun 2021 14:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623274930; cv=none; d=google.com; s=arc-20160816; b=T8lnF60jQ+mo427C6blOsF74nXGVcie26oFhyrSZGIS43jYbarhCWmTp+8APW9noaY p2mGYUwwk/e8UMMY3R0MLvxgJUM7B8Yav1DgfmrXaAjaBAgZB8GX48+JkXS3A4gWpIC5 Ypx2FjzQAklbaaNz6H7OK7V5BRxuQvA54km7Fzz9X8Lb2fChcpcMLUCvjUE2JhxeUFkd H2qywli7/ThW3Rqkh/ealIt81HyEt32RbTr6EaMduXDvbeUc43wKx9AA8CEZO6yoywIM 8O89+JPovJ730eVp3Plgjv7wZH8L2TLAp3ChxrvxD7C0y6PUG+MsKyQCjnXwam/oOhCN RAlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5k8vn+rwyY8CVPFTxUS93yHoMkcoR1Qk+6hMUJrS458=; b=y3hqBzT7/MP1ipycm6ZgUFzhrUk+aorRwALYn4o+L9XxCa9qqomQIYIQSHZDrmiVK/ IyEzJteskuqCeTuWELXz3WiHnLnsKDZ3h8UWHeAqFpLMI6raOIwAc3vAKrUAozogr+gK B44kkh6qV7YRlGXUDk0mt2HI6xUyKqu352zM+ZwiSMhX5CS8mjzVZduWyCEDWVdDRLGD atv/tJQ1wNCAp7JT/OOe7SlhOX3e4dTMOK9NKoIWRXLbFMfaJc3vx+x0Doldg8XsoZbI HBeNZhYnz1nSsj47znG28KXDzSUG/87jC+kFTY6kFpOk1+m9AM7fM4KUIzdjAI1KjW0v 18pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=DvCE+bt+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m25si682908ejb.570.2021.06.09.14.41.21; Wed, 09 Jun 2021 14:42:10 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=DvCE+bt+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbhFIVlg (ORCPT + 99 others); Wed, 9 Jun 2021 17:41:36 -0400 Received: from mail-ot1-f52.google.com ([209.85.210.52]:35531 "EHLO mail-ot1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbhFIVld (ORCPT ); Wed, 9 Jun 2021 17:41:33 -0400 Received: by mail-ot1-f52.google.com with SMTP id 69-20020a9d0a4b0000b02902ed42f141e1so25474172otg.2 for ; Wed, 09 Jun 2021 14:39:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5k8vn+rwyY8CVPFTxUS93yHoMkcoR1Qk+6hMUJrS458=; b=DvCE+bt+2SFBpEEqSVoxFeQdG4NT1jqDabvNdb6YYCb6mGbpHjrVN/nehVrTpJxmD5 aajvqjMhpLeq3bNOQcwKDNIw5F/6XIA84x21hCeNhDy6GvKkjsnvoXMOp2Nk7/Lwu4yO IOtyBCGhZ7Urq3Plk1sD9fiXOvTQsIKn0AeFjrsY0B/H72HTK6awzdEp8fzHaAQXZuhg HvFuhoZ94NgT77jdJZQY69sDIIdxEgX98TfP/qvuh8WGNuFC8fm+t+N+JLv6rjhxnUfc vNMp5BY5b4hi+0fb6Ktj4Xte7ojXZT9ahoe5mmOv1xQ+7jRFUuST72i02i6SSPY+46bP qC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5k8vn+rwyY8CVPFTxUS93yHoMkcoR1Qk+6hMUJrS458=; b=R3AP2cAH5/tunDwHUd45gorpDJE0r4HBPUcjUt34uCk8d4opRar8hfLGFQGU6Wf5dV f5q0gwxVfbi9a8gRcjLAXYwd5KsQeqZZ+otRlRUjoEyA+DOgT4r3Q+gwJnSYa48Lltdp nipFdc+X+VbDcEJvFe8TFsorhgYLMd0sCdA8NwbTpAyhjTbzcOe1p71+Hwy7Jce2aNjR Vn2tyD//my7SuAVmnzI/8z6Ijj+iW+yFr7+o1rb3c8bn2z8mtAWOihvtrQa1EWM/QbR9 PsTPP0UOS9Q2ztCGHVJBdEpjW96MbJsVkvTFwTkEQWewXU1abClSyF8v72CQ5CGMT78A fQEw== X-Gm-Message-State: AOAM533zN5DuGw15P6mL3VDTTE0BiM6dZ94+VjVY3dktmJ43cSleQtMQ QvCh4RxH8VntrzwN9HJ6QaXAEsyAOkWpi9BzJV6LVw== X-Received: by 2002:a9d:748d:: with SMTP id t13mr1286459otk.6.1623274717780; Wed, 09 Jun 2021 14:38:37 -0700 (PDT) MIME-Version: 1.0 References: <973add45-9fd2-7abc-3a97-96a26c263ea0@linux.intel.com> <20210609194926.1949859-1-sathyanarayanan.kuppuswamy@linux.intel.com> <7c06b567-9a65-8c7c-6046-3dcb32d4bb15@intel.com> In-Reply-To: <7c06b567-9a65-8c7c-6046-3dcb32d4bb15@intel.com> From: Dan Williams Date: Wed, 9 Jun 2021 14:38:26 -0700 Message-ID: Subject: Re: [RFC v2-fix-v5 1/1] x86: Skip WBINVD instruction for VM guest To: Dave Hansen Cc: Kuppuswamy Sathyanarayanan , Peter Zijlstra , Andy Lutomirski , Tony Luck , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Raj Ashok , Sean Christopherson , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 9, 2021 at 2:03 PM Dave Hansen wrote: > > This changelog lacks both clear problem statements and a clear solution > implemented within the patch. > > Here's a proposed changelog. It clearly spells out the two problems > caused by WBINVD within a guest, and the proposed solution which fixes > those two problems. Looks good to me modulo the comment below... > > Is this missing anything? > > -- > > VM guests that support ACPI use standard ACPI mechanisms to signal sleep > state entry to the host. To ACPI, reboot is simply another sleep state. > > ACPI specifies that the platform preserve memory contents over (some) > sleep states. It does not specify any requirements for data > preservation in CPU caches. The ACPI specification mandates the use of > WBINVD to flush the contents of the CPU caches to memory before entering > specific sleep states, thus ensuring data in caches can survive sleep > state transitions.e > > Unlike when entering sleep states bare metal, no actions within a guest > can cause data in processor caches to be lost. That makes these WBINVD > invocations harmless but superfluous within a guest. (<--- problem #1) > > In TDX guests, these WBINVD operations cause #VE exceptions. For debug, > it would be ideal for the #VE handler to be able to WARN() when an > unexpected WBINVD occurs. (<--- problem #2) ...but it doesn't WARN() it triggers unhandled #VE, unless I missed another patch that precedes this that turns it into a WARN()? If a code path expects WBINVD for correct operation and the guest can't execute that sounds fatal, not a WARN to me. > Avoid WBINVD for all ACPI cache-flushing operations which occur while > running under a hypervisor, which includes TDX guests. This both avoids > TDX warnings and optimizes away superfluous WBINVD invocations. (<---- > solution) >