Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp120716iob; Tue, 17 May 2022 20:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/lk4OLVgj168wVWS2iL5gR0BCgOcO7RbtaHO2bzMxBelMyX0Wk1k93mU6W5uMZYTltjd1 X-Received: by 2002:a17:903:2350:b0:15e:d63f:9721 with SMTP id c16-20020a170903235000b0015ed63f9721mr25714179plh.116.1652846103241; Tue, 17 May 2022 20:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652846103; cv=none; d=google.com; s=arc-20160816; b=kQa6/BoJhYJM/LhRwku3b6SRoTSTOf7Mgp0/sq5TgDtXbqEW1dGjPI7ho0ulEaXRzv 1GoKmZmSq02h+feKKHpMbsljk0T4uQ9iTySi1FGWURArsxaIK+s024KxPD8TDXjiOBGJ td45N5diiVG68tJFi5k/JFz6kCcnyqgZyu9r4Gx/XRAZnbRWWhVVaGyDkxN7KZ7nue4q Xp9dtYpNFFivzccDZNWbDG/VlyddJJgM9+N5Zsk1D+9SawT97Pk7JRk4v1K9WUuw56cl 00Y9xWKZiD2IwkVmwm6JycVD+GpVoFAfdNHPEC0ucGO1in7F9EI+/zDsCKgsgmWtIckw R9+w== 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 :dkim-signature; bh=AigzXdMRoud4AEn/VY4gGUrB6e1zlCVzvxWX9Wc3BOk=; b=QyWiCT5ihztiFGdS9ZsCdGtFb8muRSN1Wzq6ku28l8wwYPv7pgD6VCCm7Fp1TOpagb +xwnHz3qAyZgsqThxzU3NMYNQ0ylMzv1/oD2iu0X6RmMbWI85sJB6/vnk+2m68AxjvMZ 0sZkkcCQmu+Rd5+H1cjI/DROcz436fufA1+Hyn96vOFPLXlUbMB6YYC1Ct8Z7+PWD5Hl wOtByW9nEiQl7b8/VweU6FiKhIb5PzWwxW1l1LjGNlIWzwlHPU2bDIWAlsPT1wl/rKpF rrjojkQz9AYpPivDZj9EgyEggRDhLBUoK0RgR0w7zBpV+9Qp5o3jP4GN3yTZuBtPu9nm A1NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=XKZqZopm; 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 15-20020a63144f000000b003f5ef329b7csi1085116pgu.607.2022.05.17.20.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 20:55:03 -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=XKZqZopm; 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 375BC986F1; Tue, 17 May 2022 20:35:32 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350217AbiEQPfu (ORCPT + 99 others); Tue, 17 May 2022 11:35:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347265AbiEQPfH (ORCPT ); Tue, 17 May 2022 11:35:07 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45DE84F9E4; Tue, 17 May 2022 08:35:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652801706; x=1684337706; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ba5aaba6CYtwjhjErhM4Hq7HhJDf0ny+Fwb4XqWMwfA=; b=XKZqZopmk+lKFTgjrYbDQ8JkLcBBfa0WvcdLtMpgGrXESuzJFLXN0Wmz H7z5dKbEqUdDMFMNBGnAwAM27F9UM7gtsiL03tJD9juLVJOOZd4NqHntc jjdVlfsFq2qH7Ro09fP/Yr/k2rGJn7tQJutiZalbMXH6/H05njWV9Vnjc NJdWF2ZalVc12ttDFXqBE3VVOO61CzWp52BYNHIzcWkEt3P2tLIJf2obQ ol3wBa6G2nEDOc7jBxtvs23B4pDMLdgrxL470nHUDCgNHWZkTji90ZbAy SgRjQggkX+ZD6v13C0790UL1D1d4HMKZqVMMizXHXEU2fYWlnQIk+ybrH A==; X-IronPort-AV: E=McAfee;i="6400,9594,10350"; a="331837229" X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="331837229" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 08:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="660661437" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 17 May 2022 08:34:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id D232269F; Tue, 17 May 2022 18:34:50 +0300 (EEST) From: "Kirill A. Shutemov" To: Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel Cc: Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Dave Hansen , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv6 12/15] x86/tdx: Make _tdx_hypercall() and __tdx_module_call() available in boot stub Date: Tue, 17 May 2022 18:34:41 +0300 Message-Id: <20220517153444.11195-13-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220517153444.11195-1-kirill.shutemov@linux.intel.com> References: <20220517153444.11195-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 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=no 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 Memory acceptance requires a hypercall and one or multiple module calls. Make helpers for the calls available in boot stub. It has to accept memory where kernel image and initrd are placed. Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 26 ------------------ arch/x86/include/asm/shared/tdx.h | 45 +++++++++++++++++++++++++++++++ arch/x86/include/asm/tdx.h | 19 ------------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 5fbdda2f2b86..6a62d3950619 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -14,14 +14,6 @@ #include #include -/* TDX module Call Leaf IDs */ -#define TDX_GET_INFO 1 -#define TDX_GET_VEINFO 3 -#define TDX_ACCEPT_PAGE 6 - -/* TDX hypercall Leaf IDs */ -#define TDVMCALL_MAP_GPA 0x10001 - /* MMIO direction */ #define EPT_READ 0 #define EPT_WRITE 1 @@ -36,24 +28,6 @@ #define VE_GET_PORT_NUM(e) ((e) >> 16) #define VE_IS_IO_STRING(e) ((e) & BIT(4)) -/* - * Wrapper for standard use of __tdx_hypercall with no output aside from - * return code. - */ -static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15) -{ - struct tdx_hypercall_args args = { - .r10 = TDX_HYPERCALL_STANDARD, - .r11 = fn, - .r12 = r12, - .r13 = r13, - .r14 = r14, - .r15 = r15, - }; - - return __tdx_hypercall(&args, 0); -} - /* Called from __tdx_hypercall() for unrecoverable failure */ void __tdx_hypercall_failed(void) { diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index e53f26228fbb..956ced04c3be 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -13,6 +13,14 @@ #define TDX_CPUID_LEAF_ID 0x21 #define TDX_IDENT "IntelTDX " +/* TDX module Call Leaf IDs */ +#define TDX_GET_INFO 1 +#define TDX_GET_VEINFO 3 +#define TDX_ACCEPT_PAGE 6 + +/* TDX hypercall Leaf IDs */ +#define TDVMCALL_MAP_GPA 0x10001 + #ifndef __ASSEMBLY__ /* @@ -33,8 +41,45 @@ struct tdx_hypercall_args { /* Used to request services from the VMM */ u64 __tdx_hypercall(struct tdx_hypercall_args *args, unsigned long flags); +/* + * Wrapper for standard use of __tdx_hypercall with no output aside from + * return code. + */ +static inline u64 _tdx_hypercall(u64 fn, u64 r12, u64 r13, u64 r14, u64 r15) +{ + struct tdx_hypercall_args args = { + .r10 = TDX_HYPERCALL_STANDARD, + .r11 = fn, + .r12 = r12, + .r13 = r13, + .r14 = r14, + .r15 = r15, + }; + + return __tdx_hypercall(&args, 0); +} + + /* Called from __tdx_hypercall() for unrecoverable failure */ void __tdx_hypercall_failed(void); +/* + * Used in __tdx_module_call() to gather the output registers' values of the + * TDCALL instruction when requesting services from the TDX module. This is a + * software only structure and not part of the TDX module/VMM ABI + */ +struct tdx_module_output { + u64 rcx; + u64 rdx; + u64 r8; + u64 r9; + u64 r10; + u64 r11; +}; + +/* Used to communicate with the TDX module */ +u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, + struct tdx_module_output *out); + #endif /* !__ASSEMBLY__ */ #endif /* _ASM_X86_SHARED_TDX_H */ diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 020c81a7c729..d9106d3e89f8 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -20,21 +20,6 @@ #ifndef __ASSEMBLY__ -/* - * Used to gather the output registers values of the TDCALL and SEAMCALL - * instructions when requesting services from the TDX module. - * - * This is a software only structure and not part of the TDX module/VMM ABI. - */ -struct tdx_module_output { - u64 rcx; - u64 rdx; - u64 r8; - u64 r9; - u64 r10; - u64 r11; -}; - /* * Used by the #VE exception handler to gather the #VE exception * info from the TDX module. This is a software only structure @@ -55,10 +40,6 @@ struct ve_info { void __init tdx_early_init(void); -/* Used to communicate with the TDX module */ -u64 __tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, - struct tdx_module_output *out); - void tdx_get_ve_info(struct ve_info *ve); bool tdx_handle_virt_exception(struct pt_regs *regs, struct ve_info *ve); -- 2.35.1