Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1034891iob; Fri, 13 May 2022 20:28:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUPNwO+W5c/Vn65uBDyvsg7TeCXwsz03w9ZY03rlL8PF9SW92+hAzygCzYJQcrKgPG2kFG X-Received: by 2002:a5d:5302:0:b0:20c:ff53:e24a with SMTP id e2-20020a5d5302000000b0020cff53e24amr168353wrv.396.1652498920421; Fri, 13 May 2022 20:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652498920; cv=none; d=google.com; s=arc-20160816; b=Qijg/ryIF7CeHh1fiBsaOKaDu8NGiONvyeFcNLA/K3BR6wz5Xp9fJttJQnRtTr33Lo qTxDp31Korp9sB90tzeBFpXdc+mT7lkdwOuWncn+zs67uVyEPo398Gpa6E+dOOqcYAgH xP6pCsaJ+awKXrfqGTdZBtVrwgYeNNHktVI45RknkzgfhlrrnGrBlF7Egtwtf/QOm4RU gO5eW+I2ZhOMj661Qx+b4v2Zu9Eu1c45sQRBhwF3mhpdsFSED/xclFaXGDcoTQRtkkXa TKgVLdZ0c25CfCQoJnK8V+v0DrFXzjlX67ubQXKNZXnW0SXD0HpaLG3DPtfk6U2Q+gTn 7K0A== 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:dkim-signature; bh=k+R4KrRJzCoSdMiaa/t7PZNkzWxkxmuyqIShSyAU25M=; b=VFwvrvzCKuf7M2y5LIuvRh4nW2zVNHfhMgZjqudwwhcpBQA9qFPSmG4no/TaVeF0J3 oozSatd5/LiZnFvakwBvkayU48k4nyOrtysAJ1vuAN43GsjJWDXFxAFkcW0Z3MgUUm/k Cjl3IqQqzrJTjV16RG4uEAHPmP+/ed32MBWiQ9huxZhRHWYk0AoRbAUnW5oP0M4AHlb4 W3AhK0qI32sKrgzQq2B/Bpo7X0xcseKoT02ynQAzCKXAPf2MDlYAJSC9zS/E31NVk1q1 g9s/z+Js5qZxYnG15zGCDAc+DS3wt0f/ecTTK40zefTNns70KoHEmrsz6/nuGlvCg3iH I5mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j10AORGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n29-20020a05600c3b9d00b0039431c104a7si7802050wms.4.2022.05.13.20.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:28:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=j10AORGs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4699741C874; Fri, 13 May 2022 17:05:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359113AbiELWUK (ORCPT + 99 others); Thu, 12 May 2022 18:20:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359098AbiELWUI (ORCPT ); Thu, 12 May 2022 18:20:08 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C939A2802F8 for ; Thu, 12 May 2022 15:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652394007; x=1683930007; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ndBCwqeq7YGl3P4/bA2nucn4xP9EenQsPVsPJbYSW84=; b=j10AORGs1o7mI95rGHbouQDk/Oo21IC85QMoLUxCzqG6fjgox7Bv1jW+ Wj+nOHfpXnuhlrpWMzq6DjfCMvmh4D4wRl2XajeWgFvyuLsrhVrrni0TO 230kXems07iL+SwbKLz6o/hSA4E87Cqb1QmziU15/g97tsE4qUd7Hg91n 3LCZCxjzTn5SDuyNZPNbyE9KvdJO1oVhFfREPiyRSRisAAajBTsQnR3gc 8fizG5AsGoSb5NR9sm8ZIrWKdUrkgEjj+G46/NpXZdrLI2EoCqgMTTkXI jYz817NcJ42jbXlopqLdW4cnWJKFFP3KJogySAyRTMQ00DyYeUTcuJQPp g==; X-IronPort-AV: E=McAfee;i="6400,9594,10345"; a="257694992" X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="257694992" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 15:20:07 -0700 X-IronPort-AV: E=Sophos;i="5.91,221,1647327600"; d="scan'208";a="594904457" Received: from skothapa-mobl.amr.corp.intel.com (HELO skuppusw-desk1.amr.corp.intel.com) ([10.209.67.107]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2022 15:20:06 -0700 From: Kuppuswamy Sathyanarayanan To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "H . Peter Anvin" , Kuppuswamy Sathyanarayanan , "Kirill A . Shutemov" , Tony Luck , Andi Kleen , Kai Huang , Wander Lairson Costa , Isaku Yamahata , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, linux-kernel@vger.kernel.org Subject: [PATCH v6 0/5] Add TDX Guest Attestation support Date: Thu, 12 May 2022 15:19:47 -0700 Message-Id: <20220512221952.3647598-1-sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. VM guest with TDX support is called as TD Guest. In TD Guest, the attestation process is used to verify the trustworthiness of TD guest to the 3rd party servers. Such attestation process is required by 3rd party servers before sending sensitive information to TD guests. One usage example is to get encryption keys from the key server for mounting the encrypted rootfs or secondary drive. Following patches add the attestation support to TDX guest which includes attestation user interface driver and related hypercall support. Any distribution enabling TDX is also expected to need attestation. So enable it by default with TDX guest support. The compiled size is quite small (~500 bytes). Changes since v5: * Added support for parallel GetQuote requests. * Add noalias variants of set_memory_*crypted() functions to changes page attribute without touching direct map. * Made set_memory_*crypted() functions vmalloc address compatible. * Use vmap()/set_memory_*crypted() functions to share/unshare memory without touching the direct map. * Add support to let driver handle the memory cleanup for the early termination of user requests. * Removed unused headers in attest.c * Fixed commit log and comments as per review comments. Changes since v4: * Removed platform driver model in attestation driver and used miscdevice and initcall approach. * Since dma_alloc*() APIs require a valid device reference, replaced it with __get_free_pages() and set_memory_decrypted() for quote memory allocation. * Removed tdx_mcall_tdreport() and moved TDG.MR.REPORT TDCALL code to tdx_get_report(). * Used kmalloc() for TDREPORT memory allocation instead of get_zeroed_page(). * Returned -EINVAL in default case of tdx_attest_ioctl(). * Added struct tdx_report_req to explicitly mention the TDX_CMD_GET_REPORT IOCTL argument. * Removed tdx_get_quote_hypercall() and moved hypercall code to attestation driver itself. * Removed GetQuote timeout support (since it is not defined in spec) * Added support to check for spurious callback interrupt in GetQuote request. * Fixed commit log and comments as per review suggestions. Changes since v3: * Moved the attestation driver from platform/x86 to arch/x86/coco/tdx/ and renamed intel_tdx_attest.c to attest.c. * Dropped CONFIG_INTEL_TDX_ATTESTATION and added support to compile attestation changes with CONFIG_INTEL_TDX_GUEST option. * Merged patch titled "x86/tdx: Add tdx_mcall_tdreport() API support" and "platform/x86: intel_tdx_attest: Add TDX Guest attestation interface" into a single patch. * Moved GetQuote IOCTL support changes from patch titled "platform/x86: intel_tdx_attest: Add TDX Guest attestation interface driver" to a separate patch. * Removed 8K size restriction when requesting quote, and added support to let userspace decide the quote size. * Added support to allow attestation agent configure quote generation timeout value. * Fixed commit log and comments as per review comments. Changes since v2: * As per Han's suggestion, modified the attestation driver to use platform device driver model. * Modified tdx_hcall_get_quote() and tdx_mcall_tdreport() APIs to return TDCALL error code instead of generic error info (like -EIO). * Removed attestation test app patch from this series to simplify the patchset and review process. Test app patches will be submitted once attestation support patches are merged. * Since patches titled "x86/tdx: Add SetupEventNotifyInterrupt TDX hypercall support" and "x86/tdx: Add TDX Guest event notify interrupt vector support" are related, combining them into a single patch. Changes since v1: * Moved test driver from "tools/tdx/attest/tdx-attest-test.c" to "tools/arch/x86/tdx/attest/tdx-attest-test.c" as per Hans review suggestion. * Minor commit log and comment fixes in patches titled "x86/tdx: Add tdx_mcall_tdreport() API support" and "x86/tdx: Add tdx_hcall_get_quote() API support" * Extended tdx_hcall_get_quote() API to accept GPA length as argument to accomodate latest TDQUOTE TDVMCALL related specification update. * Added support for tdx_setup_ev_notify_handler() and tdx_remove_ev_notify_handler() in patch titled "x86/tdx: Add TDX Guest event notify interrupt vector support" Kuppuswamy Sathyanarayanan (5): x86/tdx: Add TDX Guest attestation interface driver x86/tdx: Add TDX Guest event notify interrupt support x86/mm: Make tdx_enc_status_changed() vmalloc address compatible x86/mm: Add noalias variants of set_memory_*crypted() functions x86/tdx: Add Quote generation support arch/x86/coco/tdx/Makefile | 2 +- arch/x86/coco/tdx/attest.c | 411 +++++++++++++++++++++++++++++ arch/x86/coco/tdx/tdx.c | 84 +++++- arch/x86/include/asm/hardirq.h | 3 + arch/x86/include/asm/idtentry.h | 4 + arch/x86/include/asm/irq_vectors.h | 7 +- arch/x86/include/asm/set_memory.h | 2 + arch/x86/include/asm/tdx.h | 4 + arch/x86/include/uapi/asm/tdx.h | 87 ++++++ arch/x86/kernel/irq.c | 7 + arch/x86/mm/pat/set_memory.c | 26 +- 11 files changed, 627 insertions(+), 10 deletions(-) create mode 100644 arch/x86/coco/tdx/attest.c create mode 100644 arch/x86/include/uapi/asm/tdx.h -- 2.25.1