Received: by 2002:a05:6520:2586:b029:fa:41f3:c225 with SMTP id u6csp28297lky; Wed, 9 Jun 2021 14:55:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjMkiQCvEkXaoayBwUHNUm57wGa6SYIUUdxHrQatlJe7oyEocaX7X/qH1DYtqCbU2vsWe0 X-Received: by 2002:a50:ee18:: with SMTP id g24mr1455228eds.11.1623275722693; Wed, 09 Jun 2021 14:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623275722; cv=none; d=google.com; s=arc-20160816; b=v90uRUV+W8ICeXFnn1tCjLsebJvrvQwa/vxKkaub29kPG3PeMPzGwzXugPdceecBpM U1mkHJ6yBO11d1fn5Id/Gr788OClyYCY4W5kI7mlpS58UZ6NX6dWyxvAwWGqGpj0mpkB sTj29fi0m1G2yf1gX8f3Jg5LATTspNo8lcVR17W0BRrN/pL7ysk6tBwLb+9Wto0gQ7YI yLV1BTzEgmIAzYrMyW5MSKy/LaPS6Pw8kK3hGHNpo2/OF2Ngab+bfW4RO3Sh5DJdKt1l 8gdaVGxtsE1kSGk9400Wxr4MHS5A9f/eLJ3RQCn4i/rK7f+KznJsNZrFSkeLhtABwB1p v0bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=3AetbvDG7CbE1JFgtrYVuc2oRq9PJ7r5ubh86gfIMu4=; b=xlErp6Gf/ifZ8se5gVK3NRoUvK/iq8gRgTFND3oopr7tGFX9mki+4QloGAqPxZib4D tblU/9Dew72fWbEvTJYdcQJ8bUMvcGTNppj4WTfjPUvuGsfhscLuD4eHYYpuXpXJi2or kFCaOsFn1/hEYwgGfRtYByhPBGMT4H9eGsyNAQhciS6KmzWCDhfsXuzMzDw4Bm0NNk9O XxmW51cQUgb0mIg6ikL96nvht68G9midBhlOA9rrnf8iP0KLeoKfHvVPnbOIlJxEEr/s t+DNanQI5E6blkpVtKxus6ovcCftJXGFwVTBYG1oTaMsXKYzzBDDAdCzMKO+bes5qjd0 oqgg== ARC-Authentication-Results: i=1; mx.google.com; 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 j7si857680ejm.280.2021.06.09.14.54.59; Wed, 09 Jun 2021 14:55:22 -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; 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 S230233AbhFIVxN (ORCPT + 99 others); Wed, 9 Jun 2021 17:53:13 -0400 Received: from mga04.intel.com ([192.55.52.120]:35337 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbhFIVxG (ORCPT ); Wed, 9 Jun 2021 17:53:06 -0400 IronPort-SDR: 0K6JEMkyxJIm8QCao8Iq1tXz2jS1qAMMRNMfUdAnPw2Lkyd9b+J1e6qnnXsfs+i4N3Bd+49uKP GGjnqRm5tpUg== X-IronPort-AV: E=McAfee;i="6200,9189,10010"; a="203326907" X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="203326907" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 14:51:11 -0700 IronPort-SDR: 76UfN3uDjvraRlsgIXYVAqXNWyLC2g80Jbwag83r2dAG9EW7+00wAWv3cNy1lfvx3sFvpWteOZ xEBBEcMfDxHQ== X-IronPort-AV: E=Sophos;i="5.83,261,1616482800"; d="scan'208";a="482553415" Received: from qwang4-mobl1.ccr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.35.228]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2021 14:51:10 -0700 From: Kuppuswamy Sathyanarayanan To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski Cc: Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org, "Rafael J . Wysocki" , linux-acpi@vger.kernel.org Subject: [PATCH v1 5/5] x86: Skip WBINVD instruction for VM guest Date: Wed, 9 Jun 2021 14:50:47 -0700 Message-Id: <20210609215047.1955866-6-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609215047.1955866-1-sathyanarayanan.kuppuswamy@linux.intel.com> References: <20210609215047.1955866-1-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org VM guests that supports ACPI, 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. Cc: Rafael J. Wysocki Cc: linux-acpi@vger.kernel.org Reviewed-by: Dan Williams Signed-off-by: Kuppuswamy Sathyanarayanan --- arch/x86/include/asm/acenv.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h index 9aff97f0de7f..d4162e94bee8 100644 --- a/arch/x86/include/asm/acenv.h +++ b/arch/x86/include/asm/acenv.h @@ -10,10 +10,15 @@ #define _ASM_X86_ACENV_H #include +#include /* Asm macros */ -#define ACPI_FLUSH_CPU_CACHE() wbinvd() +#define ACPI_FLUSH_CPU_CACHE() \ +do { \ + if (!boot_cpu_has(X86_FEATURE_HYPERVISOR)) \ + wbinvd(); \ +} while (0) int __acpi_acquire_global_lock(unsigned int *lock); int __acpi_release_global_lock(unsigned int *lock); -- 2.25.1