Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38040342rwd; Wed, 12 Jul 2023 02:02:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1S5n3aAd2bKF9GMQyUTim2Rg3SzXpsMPzr6Ki/mZ4DqU3NAFtN7wzpsPYyMlDOQ2sHhxj X-Received: by 2002:a05:6a21:900c:b0:130:74c8:b501 with SMTP id tq12-20020a056a21900c00b0013074c8b501mr10443989pzb.30.1689152521560; Wed, 12 Jul 2023 02:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689152521; cv=none; d=google.com; s=arc-20160816; b=gD3TD/5vwFg8mCuLCfqfvovLLZyy06XaDbZRsydNSO4T1SABO0G4IKlLeQ9og0MMiS 7Ex4C4Nxg1s+KGcKHjj+H9kmeWge/ofzDnHvCGJrT1MHe4BwkeZhlBhot/7UMOBtHSF/ cTxRie2ysaszzO/l2YdJEqfq7GF8l3GCdPhZSz331J5ZCx6+20dPQd+Yfipo1B8i4CAp MkK9/mXahX78D2OSfense2sMQ8mMcEAqseb6LGB96eNIGlB7KXJRpsQfCL4p7x/BLkTj tSFomETUe7a0RdC+gAzUgR04SuBvv5Jz4HDWVH12keYddGHAOrbQBil6lvrXCL+zsmSf U1HA== 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=pTUMrkqL59XZmE5rYxzU/B8RTiLOiFsMmm8RBvPWRto=; fh=edBx5P/zffK2H8fHqIB7+dmlz60K6YmM7EnWiorgzxE=; b=OT0ABQBmekrGtldXcFh5e8jaADGLj1USby4sCPzZfhKG8RUeQJeYAsUbIUc+DR7nGK RUyjUJkfMeIs+43UPJ0YXSTewuQ6sw4vwZuy3bzh8eKcJY5hkrxXwZvx9HEkESgiyUg3 7RMn70r6NBoT6OTDwdytMf7TMLZjYcBDFgnA51kfT+mQ2lbyvZvvVdZVKz4OCOC3eoEi lAdjoXIU4Q4Q9K+gdJuypgCjb+GVlgfDlVrc9SjmtgL7en2CmNWytJJk1GI8IQJw+ZVF xCiUJlboHNFsW7SJjXeQN5huFo/kwrnPa2VlcrE0bwh6+qwfFPI7/XEVMVDBNb7m41B2 co8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BkUiaUCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o22-20020a634e56000000b0054fa5f25cfasi2813075pgl.568.2023.07.12.02.01.48; Wed, 12 Jul 2023 02:02:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BkUiaUCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232169AbjGLIzl (ORCPT + 99 others); Wed, 12 Jul 2023 04:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjGLIzj (ORCPT ); Wed, 12 Jul 2023 04:55:39 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8595B7; Wed, 12 Jul 2023 01:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689152138; x=1720688138; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VdlbdD3uvfNfNAclvpv6o/FUkmCaohnfETFKewIjeT4=; b=BkUiaUCIkd4uoasnDjw2otoh3lJJlF/o/XrGG5d66KsI6JrOVA4mwOzD BnWfWCi88HVsijRLQV5rPR8p5KMENrmUHlmEq4tsX4lyvSPoEIcyg3n+O 7TVavXSwXhCPHx631QppT3Tnc0LPWuGqUtfCVuT2RL+TDzq3kxVQUamnk c9imEl0sgh5B882avjCODEvXhigM2bKeF+nKwvoqogLgGny7+9u98Jz0A Oi9+juEQERTdHvjERAqq4FVq8bnekBwq9N1oYMeu1fkK1sTFZqkP1Zq/U sC5NexEFgAXHacmiv5A+YoCR7+sLgvTezAWPwPR4m0PMV85e6qMwZElNQ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="344439089" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="344439089" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 01:55:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10768"; a="845573315" X-IronPort-AV: E=Sophos;i="6.01,199,1684825200"; d="scan'208";a="845573315" Received: from mjamatan-mobl2.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.209.168.102]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jul 2023 01:55:32 -0700 From: Kai Huang To: peterz@infradead.org, kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org Cc: dave.hansen@intel.com, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, seanjc@google.com, pbonzini@redhat.com, kvm@vger.kernel.org, isaku.yamahata@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, kai.huang@intel.com Subject: [PATCH 00/10] Unify TDCALL/SEAMCALL and TDVMCALL assembly Date: Wed, 12 Jul 2023 20:55:14 +1200 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 Peter, Kirill, all, This series unifies the assembly code for TDCALL/SEAMCALL and TDVMCALL. Now all of them use one singe TDX_MODULE_CALL asm macro. I basically followed Peter's code here: https://lore.kernel.org/linux-mm/20230630120650.GB2534364@hirez.programming.kicks-ass.net/ With some differences that I found during my code writing and testing. With this series, I have verified the TDX guest can boot successfully and the TDX module can also be initialized successfully. The last two patches are SEAMCALL patches that are needed for TDX host patchset. They are not mandatory to be here though, i.e., can be in the TDX host support series. I put them here so we can have a complete view how TDCALL/SEAMCALL and TDVMCALL are implemented. Could you help to review? Thanks in advance. Also cc Sean/Paolo/Isaku and KVM list for TDH.VP.ENTER part. Kai Huang (10): x86/tdx: Zero out the missing RSI in TDX_HYPERCALL macro x86/tdx: Use cmovc to save a label in TDX_MODULE_CALL asm x86/tdx: Move FRAME_BEGIN/END to TDX_MODULE_CALL asm macro x86/tdx: Make macros of TDCALLs consistent with the spec x86/tdx: Rename __tdx_module_call() to __tdcall() x86/tdx: Pass TDCALL/SEAMCALL input/output registers via a structure x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs x86/tdx: Unify TDX_HYPERCALL and TDX_MODULE_CALL assembly x86/virt/tdx: Wire up basic SEAMCALL functions x86/virt/tdx: Allow SEAMCALL to handle #UD and #GP arch/x86/Kconfig | 12 ++ arch/x86/Makefile | 2 + arch/x86/boot/compressed/tdx.c | 26 +++- arch/x86/coco/tdx/tdcall.S | 238 +++++------------------------- arch/x86/coco/tdx/tdx.c | 124 +++++++++------- arch/x86/include/asm/shared/tdx.h | 48 ++++-- arch/x86/include/asm/tdx.h | 31 ++-- arch/x86/kernel/asm-offsets.c | 33 ++--- arch/x86/virt/Makefile | 2 + arch/x86/virt/vmx/Makefile | 2 + arch/x86/virt/vmx/tdx/Makefile | 2 + arch/x86/virt/vmx/tdx/seamcall.S | 54 +++++++ arch/x86/virt/vmx/tdx/tdxcall.S | 206 ++++++++++++++++++++------ 13 files changed, 431 insertions(+), 349 deletions(-) create mode 100644 arch/x86/virt/Makefile create mode 100644 arch/x86/virt/vmx/Makefile create mode 100644 arch/x86/virt/vmx/tdx/Makefile create mode 100644 arch/x86/virt/vmx/tdx/seamcall.S base-commit: 94142c9d1bdf1c18027a42758ceb6bdd59a92012 -- 2.41.0