Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp204199pxj; Tue, 1 Jun 2021 19:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykk5d7l8Xb7B02pZUGKRaLAiwruJjnQW6PYIIs5yuQG77zA+4fRi2EBEvXFzrhpVrTWOgF X-Received: by 2002:a6b:e501:: with SMTP id y1mr10025278ioc.115.1622600603771; Tue, 01 Jun 2021 19:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622600603; cv=none; d=google.com; s=arc-20160816; b=ExcPnTYV/ey1epOdZ3m1iZBr8V5Ql8xl+7Gq/DH+kcXPcX6bSDPIvaI5lVNN2fk8e2 qK8vPE2LtV+TFBMiVNX5q1/hI/HSAcaRSSyWQrsa0hXnA2P7Bd3uezQ7e8vbSr3rLXFT raaErhqILeA7qY+/+reSDePACaYjI2O4how1WgMv9KBaG2SvtCdqoGuFKC3mmiNzMfXc stue36NZ74RCLpcNDkQg8giSYU8vt6MROcEYyGFi/92w1bEpu5SaPQMg44CpdL33K6Hp 1HbvuB9ik99C68DBJ5LZDH8T2hN+T6js98hDznjd0LYMK/76ZIpVtlpyDVX61N8KEl2L fbtg== 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 :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=y8P+b7KUw1Gx9kFoQVyvUlmaYneuk7XAUy2Xm0f8GP4=; b=gE1oW/tn/tQAS4ZXBYFvu90XD82d/7cPK0bpBLpv2QtPp1a3NKAZgR86P9Zh3O/AOf AjoBRcN7ri8OH9QFy5K5D3aw5mG9yg31ijNf5gRWsrGX44gZ5WHOxCmfqIpHeXAluy4v uh802efUkMvHCE5MB9X8bs4ORbV4N/U6/maVp5z6fzLS6fn3ccahxJ3O39cKQv07S5BU ZPIQK0dwJUkqQ/y8L+qOE+B0tNOOWesL3chCdnQt3tAEyLetvjbsNhsx1ZD9FLNBA0Zu NkPhE6u568mLZqzCH9AI8Dh3dVN5VauprIs6e5eIGQawxUrtqob/BSfnL49R8HX0xxtU Tosw== 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 e1si11534493jai.106.2021.06.01.19.23.10; Tue, 01 Jun 2021 19:23:23 -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 S230034AbhFBCX1 (ORCPT + 99 others); Tue, 1 Jun 2021 22:23:27 -0400 Received: from mga06.intel.com ([134.134.136.31]:19493 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbhFBCX1 (ORCPT ); Tue, 1 Jun 2021 22:23:27 -0400 IronPort-SDR: 51fc7KZE7YDowUXi1aO5KpICXvm/kPTjzxczeC5N3gDNIY2apgpEtU28RzBeNb9GFQx33mqwq2 3nnABgPYpSoA== X-IronPort-AV: E=McAfee;i="6200,9189,10002"; a="264865314" X-IronPort-AV: E=Sophos;i="5.83,241,1616482800"; d="scan'208";a="264865314" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 19:21:44 -0700 IronPort-SDR: er/c/NC70xkhizWl2r0UzoPjPN7XAST/h9UzMaeWesX4VTmudgseZVp4ItuwBRbyszvyzh0cDo U2YHMIhFuVbA== X-IronPort-AV: E=Sophos;i="5.83,241,1616482800"; d="scan'208";a="633069177" Received: from mjdelaro-mobl.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.3.23]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jun 2021 19:21:43 -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 , Kuppuswamy Sathyanarayanan , Sean Christopherson , Kuppuswamy Sathyanarayanan , linux-kernel@vger.kernel.org, x86@kernel.org Subject: [PATCH v1 00/11] Add TDX Guest Support (Initial support) Date: Tue, 1 Jun 2021 19:21:25 -0700 Message-Id: <20210602022136.2186759-1-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 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 Hi All, Intel's Trust Domain Extensions (TDX) protect guest VMs from malicious hosts and some physical attacks. This series adds the basic TDX guest infrastructure support (including #VE handler support, and #VE support for halt and CPUID). This is just a subset of patches in the bare minimum TDX support patch list which is required for supporting minimal functional TDX guest. Other basic feature features like #VE support for IO, MMIO, boot optimization fixes and shared-mm support will be submitted in a separate patch set. To make reviewing easier we split it into smaller series. This series alone is not necessarily fully functional. Also, the host-side support patches, and support for advanced TD guest features like attestation or debug-mode will be submitted at a later time. Also, at this point it is not secure with some known holes in drivers, and also hasn’t been fully audited and fuzzed yet. TDX has a lot of similarities to SEV. It enhances confidentiality and of guest memory and state (like registers) and includes a new exception (#VE) for the same basic reasons as SEV-ES. Like SEV-SNP (not merged yet), TDX limits the host's ability to effect changes in the guest physical address space. With TDX the host cannot access the guest memory, so various functionality that would normally be done in KVM has moved into a (paravirtualized) guest. Partially this is done using the Virtualization Exception (#VE) and partially with direct paravirtual hooks. The TDX architecture also includes a new CPU mode called Secure-Arbitration Mode (SEAM). The software (TDX module) running in this mode arbitrates interactions between host and guest and implements many of the guarantees of the TDX architecture. Some of the key differences between TD and regular VM is, 1. Multi CPU bring-up is done using the ACPI MADT wake-up table. 2. A new #VE exception handler is added. The TDX module injects #VE exception    to the guest TD in cases of instructions that need to be emulated, disallowed    MSR accesses, etc. 3. By default memory is marked as private, and TD will selectively share it with    VMM based on need.     Note that the kernel will also need to be hardened against low level inputs from the now untrusted hosts. This will be done in follow on patches. You can find TDX related documents in the following link. https://software.intel.com/content/www/br/pt/develop/articles/intel-trust-domain-extensions.html Kirill A. Shutemov (7): x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT x86/tdx: Get TD execution environment information via TDINFO x86/traps: Add #VE support for TDX guest x86/tdx: Add HLT support for TDX guest x86/tdx: Wire up KVM hypercalls x86/tdx: Add MSR support for TDX guest x86/tdx: Handle CPUID via #VE Kuppuswamy Sathyanarayanan (4): x86/tdx: Introduce INTEL_TDX_GUEST config option x86/cpufeatures: Add TDX Guest CPU feature x86/x86: Add is_tdx_guest() interface x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions arch/x86/Kconfig | 20 ++ arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/tdx.c | 32 ++++ arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/idtentry.h | 4 + arch/x86/include/asm/irqflags.h | 40 ++-- arch/x86/include/asm/kvm_para.h | 21 +++ arch/x86/include/asm/paravirt.h | 20 +- arch/x86/include/asm/paravirt_types.h | 3 +- arch/x86/include/asm/tdx.h | 153 ++++++++++++++++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/asm-offsets.c | 22 +++ arch/x86/kernel/head64.c | 3 + arch/x86/kernel/idt.c | 6 + arch/x86/kernel/paravirt.c | 4 +- arch/x86/kernel/tdcall.S | 254 ++++++++++++++++++++++++++ arch/x86/kernel/tdx.c | 254 ++++++++++++++++++++++++++ arch/x86/kernel/traps.c | 69 +++++++ 18 files changed, 877 insertions(+), 31 deletions(-) create mode 100644 arch/x86/boot/compressed/tdx.c create mode 100644 arch/x86/include/asm/tdx.h create mode 100644 arch/x86/kernel/tdcall.S create mode 100644 arch/x86/kernel/tdx.c -- 2.25.1