Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3840656pxj; Mon, 24 May 2021 16:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzprfAbGyqiguoGV7+i7QmswXPL7LLNJkmvYJ2SyTKy0FAyqXVNPOItBNKV+5VCfeSI5shs X-Received: by 2002:a17:906:b0c9:: with SMTP id bk9mr9632799ejb.517.1621899235707; Mon, 24 May 2021 16:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621899235; cv=none; d=google.com; s=arc-20160816; b=XeSI4908h232UbvTBL+9dipJ5Hx4txe2gRDpJv6N5w/KwvsPUs+1kTAPYuFO/R6fRa E/BNdfE69Px/0Md9TiwAGgvsIrLO59kcZRH9AxdDV3wxymxewmco8pwmP2p7MIO9f2zF XehmsNqEJ+wysidQj7rSS0SFvMztWJyPRLncvUEAIQAtaBVE1pUuDNxM2C4z4i57qGSu GSeW2IzjfMRbTWPaUpGCJcclSMZQkaSV11k3OqLFXM4oQzVBHe/M+Vkp1W4zRMXjv4Cp IMaTrvVQBrs1r3QH/VDGSCZLciqII5PW/kNElBq+Bf6x1vGe2GzcvKeasmS/RpYTOYpi tdng== 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=huq7UmQAA39ECfurY0uBnYvspGCBbBsZIAuqNYo75Wo=; b=FEexfix+iflROnrr1AZWT+1CttsD/d/V1fn4VM0xDApzX8toRG2I8XvVAzDNRiFgkZ 5E8amyihjLmkO8JSfYZGKYpvuZh9oTX2Ju1CDU77aISV4967kv1kpSlvfntThzDiEyaQ MJXY4flyyjIdfU9rdzLsupp4P6Dm1wQQIDqjr3HKXsiiRrf00pQu6VGPlnT4eKjOQP4k vU9/hRrOzFTPYvWb1xyenLpe8AyFwVJgN6KcxgX4fJo2SgTa8e4NQ60mGygYWxcHiFwX 3jfK1qgefqL38grlQUVooNmDjyd5oqgpsG6/eM78RaXoBEz/6cJ5xYkanAexFm4e7IPD tJ3A== 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 c10si13363642edr.581.2021.05.24.16.33.33; Mon, 24 May 2021 16:33:55 -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 S229503AbhEXXeA (ORCPT + 99 others); Mon, 24 May 2021 19:34:00 -0400 Received: from mga09.intel.com ([134.134.136.24]:39314 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbhEXXdx (ORCPT ); Mon, 24 May 2021 19:33:53 -0400 IronPort-SDR: xmGw6oaexb+x57fZxGQqJq/YHAzkn7G4oJc2Br+9i1XU44ijVDqzZRu9qXe5eINOrDujpyIpE9 SxjDiBFTEJGQ== X-IronPort-AV: E=McAfee;i="6200,9189,9994"; a="202074825" X-IronPort-AV: E=Sophos;i="5.82,327,1613462400"; d="scan'208";a="202074825" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 16:32:24 -0700 IronPort-SDR: tMMpTMnSpbpiKlV23esSQpMsNXGRomnh7I0F2BjF87tgEUs7nWFjv+NUOjyJql7bGB9gjztE24 pzLBDuMWpa9w== X-IronPort-AV: E=Sophos;i="5.82,327,1613462400"; d="scan'208";a="476126864" Received: from eyoukerh-mobl.ger.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.2.69]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2021 16:32:23 -0700 From: Kuppuswamy Sathyanarayanan To: Peter Zijlstra , Andy Lutomirski , Dave Hansen Cc: Tony Luck , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , Dan Williams , Raj Ashok , Sean Christopherson , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org Subject: [RFC v2-fix-v2 2/2] x86/tdx: Ignore WBINVD instruction for TDX guest Date: Mon, 24 May 2021 16:32:11 -0700 Message-Id: <20210524233211.802033-2-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210524233211.802033-1-sathyanarayanan.kuppuswamy@linux.intel.com> References: <37ad50ca-f568-4c62-56e2-9e9b1f34084c@linux.intel.com> <20210524233211.802033-1-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Functionally only DMA devices can notice a side effect from WBINVD's cache flushing. But, TDX does not support DMA, because DMA typically needs uncached access for MMIO, and the current TDX module always sets the IgnorePAT bit, which prevents that. So handle the WBINVD instruction as nop. Currently, we did not include any warning for WBINVD handling because ACPI reboot code uses it. This is the same behavior as KVM. It only allows WBINVD in a guest when the guest supports VT-d (=DMA), but just handles it as a nop if it doesn't . If TDX ever gets DMA support, a hypercall will be added to implement it similar to AMD-SEV. But current TDX does not support direct DMA. Signed-off-by: Kuppuswamy Sathyanarayanan --- Changes since RFC v2: * Fixed commit log as per review comments. * Removed WARN_ONCE for WBINVD #VE support. arch/x86/kernel/tdx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c index 3800c7cbace3..21dec5bfc88e 100644 --- a/arch/x86/kernel/tdx.c +++ b/arch/x86/kernel/tdx.c @@ -511,6 +511,12 @@ int tdg_handle_virtualization_exception(struct pt_regs *regs, case EXIT_REASON_EPT_VIOLATION: ve->instr_len = tdg_handle_mmio(regs, ve); break; + case EXIT_REASON_WBINVD: + /* + * Non coherent DMA is not supported in TDX guest. + * So ignore WBINVD and treat it nop. + */ + break; case EXIT_REASON_MONITOR_INSTRUCTION: case EXIT_REASON_MWAIT_INSTRUCTION: /* -- 2.25.1