From patchwork Tue Jun 6 19:42:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 104097 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3635156vqr; Tue, 6 Jun 2023 12:57:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63q1ddTMZ7UE5LKjfZkFl9QHtZ8UGxp6dhAXx1TT73N9JKEidu5lFtKQ3gUeJMjVUELYdl X-Received: by 2002:a05:6214:2a84:b0:623:66ee:79b2 with SMTP id jr4-20020a0562142a8400b0062366ee79b2mr596424qvb.36.1686081449778; Tue, 06 Jun 2023 12:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686081449; cv=none; d=google.com; s=arc-20160816; b=ALVgRh59Z1l4+5Z3Sx0M1HZm7EmH7YAtLJt0T+i8hk00LfZ4OmdS6h96WKGEDvg4B3 /qcEYCygCMjKxzC+T/Si4aCUEyEfPK7NcG4+/Op8HCw3MZEpiRbJt6DpeSqo/24SGDz/ qry2pVq7cRIqGadM/lGYL6faKx+utzi1K2GWB1vjLCfcMLuxSOYUSd0PmdWR9w8G+j8E IekvVNsEPRXHEzv2wuTGh/Hdons8j+LzboiDPXoqy08CcrpSH81lXy3OgFtxEMOjAIJB pwfYyNEnmKM68umS5VJIXp9Jp4fs4gqCS/0UjBwYByQQXfx9xIHct8hs/apyHfoioYYs /LwQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iu4-20020ad45cc4000000b006282759d724si6846652qvb.603.2023.06.06.12.57.15; Tue, 06 Jun 2023 12:57:29 -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 S239350AbjFFTne (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767964136863009147?= X-GMAIL-MSGID: =?utf-8?q?1767984542063997804?= 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);