Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7566844rwd; Tue, 6 Jun 2023 12:44:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7SMro9GfNdvAQmHF0/nXs3GJGa/iRhS0v+xOzEjtnGnBK8QEJSr8SJfOvdR64J9WnbxVXQ X-Received: by 2002:a05:6a00:a06:b0:64f:aea5:7b49 with SMTP id p6-20020a056a000a0600b0064faea57b49mr2207335pfh.17.1686080679520; Tue, 06 Jun 2023 12:44:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686080679; cv=none; d=google.com; s=arc-20160816; b=qF/h3+LHwqc+ZM8/GSBp8kMknb7c3KaBERaGrEGS3uwpGmbxDZCDoNaERcJn67JFwb ErU1+5OOVhoMTACaqYtHU2pQ3vf9M7zMWLBbmKwIXl08dfN+BX4HjAJrXPu52zFcW6K3 oWoTJBee7IQJMqP8HiAYQ/+cb2SJvX9HWgiX3yttDw2mQxg/9voWs+bogFrNW8FEnmD8 vn+6ysE0bnYd38r+1n7tRaNc+6/u6EQq009RpsKy+GpEtRZjMR7rdWY237W3B5Zxskt4 yWdAUqYQAdQ/y6GqjCytvgEcC1BQPWHbZ5IHGiC6JfIksXbNc+30OgS5Du/ovyjRuWsw M1dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=XmfBFSf2C3LJhhefwC/O7pKNZ+pUInq+fA2/eX3pAKg=; b=bOZXbrg+L1BZ3zNFUq9oqd+XQRegETjzRWtMJBSK9ApP/+E8SQ1vDPPe9FZmACFjJX eurvtN6vh2bw+6F4wMJ6T2KcsgIxKU1JkUBHOSwklOiKnsVA/xzbFhueatI5T+3OXZgN ySujqf4uZm1C7lFzVKJgqc3wAvgjz/sIZKinrAckMwcGBO/ZJYQqFByiSAsiJirm9Ul/ HZwT/w9uIlkd8w67qbeBkOD4LmshXMO/XYW6IZ2odRetWZnMDjRPTaXWgzeDF3URt4pk +Z2o0fer1rAVniK+vIX+dWwc8UbXGM5Z8Wfm2cLgBKX3GAf048/RMVyngMkOG9GkL+su UzTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xW8Z62iX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/2x9zyON"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a637304000000b0053f265b0eecsi7585834pgc.133.2023.06.06.12.44.26; Tue, 06 Jun 2023 12:44:39 -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=@linutronix.de header.s=2020 header.b=xW8Z62iX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/2x9zyON"; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239333AbjFFTne (ORCPT + 99 others); Tue, 6 Jun 2023 15:43:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239190AbjFFTmo (ORCPT ); Tue, 6 Jun 2023 15:42:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EAC410F1; Tue, 6 Jun 2023 12:42:42 -0700 (PDT) Date: Tue, 06 Jun 2023 19:42:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686080559; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XmfBFSf2C3LJhhefwC/O7pKNZ+pUInq+fA2/eX3pAKg=; b=xW8Z62iXSXz/CXoEyHyVDHw2jo2CTW225Wv2gbzAbuFq08SW32SVsDR5HP2lU8+U2GdpI9 kN0Rr6TylVJPyZcuSg31vMGvH73oHW74ggo8UMm4T/O9HhYrhxEh1DTBVapCOb2nI/pj3e 82iztNCkvL6pGZqLYvl9qTJU+oqf4EF+m7BhEFinPSoqeH+tIqEyVQOCw2YFrFtht7jJCv vobMmFdtpm+vS7hEhvraOz96miRSrC9zjqah7Eo2qpZ1ZZPhByfmId9g30MM/wLP1IQJQL S/zEf+GlwsDGg3B+Uk1cEtpZeazH6l3AkeR/8aougNM/nnq3H1iiPeHaTBuXAw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686080559; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XmfBFSf2C3LJhhefwC/O7pKNZ+pUInq+fA2/eX3pAKg=; b=/2x9zyONgdi/Db4vOyZ0hq9EwW8UxjZg83uaToWcT3v+4a02V0dXmF8HEQdfEOm2WmVp3u GeVLMDulGGZbeeDw== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cc] x86/tdx: Make _tdx_hypercall() and __tdx_module_call() available in boot stub Cc: "Kirill A. Shutemov" , "Borislav Petkov (AMD)" , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230606142637.5171-8-kirill.shutemov@linux.intel.com> References: <20230606142637.5171-8-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Message-ID: <168608055881.404.1921370774228488687.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,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 The following commit has been merged into the x86/cc branch of tip: Commit-ID: ff40b5769a50fab654a70575ff0f49853b799b0e Gitweb: https://git.kernel.org/tip/ff40b5769a50fab654a70575ff0f49853b799b0e Author: Kirill A. Shutemov AuthorDate: Tue, 06 Jun 2023 17:26:35 +03:00 Committer: Borislav Petkov (AMD) CommitterDate: Tue, 06 Jun 2023 17:31:23 +02:00 x86/tdx: Make _tdx_hypercall() and __tdx_module_call() available in boot stub 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 Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Dave Hansen Link: https://lore.kernel.org/r/20230606142637.5171-8-kirill.shutemov@linux.intel.com --- arch/x86/coco/tdx/tdx.c | 32 +------------------- arch/x86/include/asm/shared/tdx.h | 51 ++++++++++++++++++++++++++++++- arch/x86/include/asm/tdx.h | 19 +----------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index e146b59..e6f4c27 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -14,20 +14,6 @@ #include #include -/* TDX module Call Leaf IDs */ -#define TDX_GET_INFO 1 -#define TDX_GET_VEINFO 3 -#define TDX_GET_REPORT 4 -#define TDX_ACCEPT_PAGE 6 -#define TDX_WR 8 - -/* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */ -#define TDCS_NOTIFY_ENABLES 0x9100000000000010 - -/* TDX hypercall Leaf IDs */ -#define TDVMCALL_MAP_GPA 0x10001 -#define TDVMCALL_REPORT_FATAL_ERROR 0x10003 - /* MMIO direction */ #define EPT_READ 0 #define EPT_WRITE 1 @@ -51,24 +37,6 @@ #define TDREPORT_SUBTYPE_0 0 -/* - * 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); -} - /* Called from __tdx_hypercall() for unrecoverable failure */ noinstr void __tdx_hypercall_failed(void) { diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index 2631e01..1ff0ee8 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -10,6 +10,20 @@ #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_GET_REPORT 4 +#define TDX_ACCEPT_PAGE 6 +#define TDX_WR 8 + +/* TDCS fields. To be used by TDG.VM.WR and TDG.VM.RD module calls */ +#define TDCS_NOTIFY_ENABLES 0x9100000000000010 + +/* TDX hypercall Leaf IDs */ +#define TDVMCALL_MAP_GPA 0x10001 +#define TDVMCALL_REPORT_FATAL_ERROR 0x10003 + #ifndef __ASSEMBLY__ /* @@ -37,8 +51,45 @@ struct tdx_hypercall_args { u64 __tdx_hypercall(struct tdx_hypercall_args *args); u64 __tdx_hypercall_ret(struct tdx_hypercall_args *args); +/* + * 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); +} + + /* 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 28d889c..234197e 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -21,21 +21,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 * and not part of the TDX module/VMM ABI. @@ -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);