Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp381630pxt; Wed, 4 Aug 2021 13:46:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLIGUUNcvfNOVSGkiDMaiJTAMkIL62ybWqJJYTt87Td8WnsEnjyYVQigqtqo68vFFZEajs X-Received: by 2002:a5d:984d:: with SMTP id p13mr1040478ios.182.1628109981397; Wed, 04 Aug 2021 13:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628109981; cv=none; d=google.com; s=arc-20160816; b=VqO76ksUa240yEQnn8ed0dRzAlf5n+xFujh+ZVWfJjHosQ7uVTdDg9DBdD8/jYKa2p HPaNvUtPp7Apw1tmb3xZDjZazKx0BlWkoR1InzbMOs5hlbWud7SmEce8gWRQEwWOevo2 bKXtOos5k7mg0bvZC3YTL2d1D41qeTAcaA8ufX3DSa6NUwMYwTGlfhxq2WgTd7iWk+rZ UjFlhQqz45Gcu5VP3mAoshOgNOiChRJnmGCN7/qxwwgED9EtJtdkQ9781KIA7l81FOqP 9YFpa3vIidUMgBgLBcS5cQDETHVJDwrXvEc8SuYXhphdIj4mxXL/LxPYsveaO64t1a19 ylHQ== 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; bh=T6GXYidMNi5kYI9LhQwWa6Xlx9PTOitvhNcu6geqpX4=; b=KzIWseCEXKLiy2knCzlomHuj+0v0NB7ujANr9hBTATjFx1X1pFQ1VoZBNgccDPpqvL HkSfwleDqx9B1J5OOTyeRiUTEsp7neZ7CrsNi35M1L4wVFExcaQXxBu8fPT5dBMI5P62 MBgKK8YBM6DBO3mTHMP75YK/mfzWA3e7Vbj3Nfl4Nf1B+Oqa+zrVkKIdHnXQFZCmOkL6 9oNWWjXT3P8e7q0YUw2YImE7NigatuCJwLkNC+nKq1zMlQlI4xn3TbV5IGoiGLMwiuss Y9GkZR1cWT/8x8BAmtgWvCSZq0Vl1+pbHP1tHfCd1Bbm7OG3XZZM13linReQBBPMTpci rW9w== 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 m12si3464532ilq.105.2021.08.04.13.46.08; Wed, 04 Aug 2021 13:46:21 -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 S240047AbhHDSO7 (ORCPT + 99 others); Wed, 4 Aug 2021 14:14:59 -0400 Received: from mga02.intel.com ([134.134.136.20]:49808 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238406AbhHDSO6 (ORCPT ); Wed, 4 Aug 2021 14:14:58 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10066"; a="201151072" X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="201151072" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 11:14:45 -0700 X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="503075810" Received: from mjkendri-mobl.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.254.17.117]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 11:14:44 -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 Subject: [PATCH v5 00/12] Add TDX Guest Support (Initial support) Date: Wed, 4 Aug 2021 11:13:17 -0700 Message-Id: <20210804181329.2899708-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 This patchset has dependency on protected guest changes submitted by Tom Lendacky https://lore.kernel.org/patchwork/cover/1468760/ Changes since v4: * Added a patch that adds TDX guest exception for CSTAR MSR. * Rebased on top of Tom Lendacky's protected guest changes. * Rest of the change log is added per patch. Changes since v3: * Moved generic protected guest changes from patch titled "x86: Introduce generic protected guest abstraction" into seperate patch outside this patchset. Also, TDX specific changes are moved to patch titled "x86/tdx: Add protected guest support for TDX guest" * Rebased on top of v5.14-rc1. * Rest of the change log is added per patch. Changes since v1 (v2 is partial set submission): * Patch titled "x86/x86: Add early_is_tdx_guest() interface" is moved out of this series. * Rest of the change log is added per patch. Andi Kleen (1): x86/tdx: Don't write CSTAR MSR on Intel 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/tdx: Add protected guest support for TDX guest x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions arch/x86/Kconfig | 20 ++ arch/x86/include/asm/asm-prototypes.h | 4 + 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 | 22 ++ arch/x86/include/asm/paravirt.h | 20 +- arch/x86/include/asm/paravirt_types.h | 3 +- arch/x86/include/asm/protected_guest.h | 5 + arch/x86/include/asm/tdx.h | 109 +++++++++ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/asm-offsets.c | 23 ++ arch/x86/kernel/cpu/common.c | 11 +- arch/x86/kernel/head64.c | 3 + arch/x86/kernel/idt.c | 6 + arch/x86/kernel/paravirt.c | 4 +- arch/x86/kernel/tdcall.S | 313 +++++++++++++++++++++++++ arch/x86/kernel/tdx.c | 242 +++++++++++++++++++ arch/x86/kernel/traps.c | 69 ++++++ include/linux/protected_guest.h | 3 + 20 files changed, 870 insertions(+), 33 deletions(-) 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