Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7609811rwb; Wed, 23 Nov 2022 08:31:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7OW5I88RLv8APnGFe2cvl7/6GRobYsFxiKSRlCRkBiHe3d9TJNepo6cxuWZ2iXEapDwKpR X-Received: by 2002:a17:906:4997:b0:7ae:ec5c:a99e with SMTP id p23-20020a170906499700b007aeec5ca99emr7789511eju.219.1669221110313; Wed, 23 Nov 2022 08:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669221110; cv=none; d=google.com; s=arc-20160816; b=jBJ5hEFLgqviC/TpmIbRbd95huxH0LfC5mMAfN63fTi7hnpoCl9wZ2MHoRozNvjxg/ b1ZJwYxDKcArIn8cy+36zcUc2ZEE5KyKhj4ITmnDtGyzNEPWDuAclBvtscguciXMrRuJ 8E4ASvJ5fTTyyT1nmd0VtrqmwRwCx3NWKTszEHV0ovrAhlM1+2+HalKq8vFwHaVgyKdC Ox1iRlR9MxLeadTSbMDGkDmkhAzLlWvYMI/3wQI0R2s1CS7Kq6v1Rh0OZdjrmHZJTZcp aWgBguRkH1e+KgNkUz5lzLPOkbv+kZEOvfV4EwgwgZnwl1BJc3v+WN/799gD12GO2fDv fdxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=oNBdQwc47REE6/G08TjXAHqQsS4+SwPYdrRdj4ICedY=; b=arNMZDPIALm4BJgxltgEX1Gl0b3UstF6SxKXaqA6BUP494jpZy3vm08ESGAVKCwGRD XaNZv/MSLxZ9QygdcsxNfFVOx/b8XVE6z/LsUX4+YMt4HFzBi4ydvyFHjAhqGqdhrdzA Qxum99ZPNLGI15AGP6ub6QE1xsvxAcio3e2MX0qGeRObFL/p+NL0+RO6QOeU/6a6tAQt +VoAo5vLs/RX0sFjld/vteGTZogcdgr++/spI5VvJaiBaYcT49B6zW/t1qHjH0G1nIuN 2IZidKJx0U6Z1QqnltdPCwvJjXBCP99HD2o5SZd3kVDZ5X8ezYc+xytTsvFkKZ/fkzMY 6XzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JVPL1BNM; 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 b2-20020a056402138200b00462c7bbc03esi3372704edv.114.2022.11.23.08.31.26; Wed, 23 Nov 2022 08:31:50 -0800 (PST) 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=JVPL1BNM; 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 S238348AbiKWQDk (ORCPT + 89 others); Wed, 23 Nov 2022 11:03:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237793AbiKWQDh (ORCPT ); Wed, 23 Nov 2022 11:03:37 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AFD258BE0; Wed, 23 Nov 2022 08:03:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669219416; x=1700755416; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=RC/dJSMFGCQR6lU8cmnAoaGtXjo/0QLdlyY2gZJCtVM=; b=JVPL1BNMfZ/pEW8CYSrUD1Wfdx8/qldoxg2wxw+WCQhzqGU5IAEfie26 GpDgbvnKM6m9zuu5XAgiTpBkEHzkdz0R6wqargqaHYNw3h99oNoQl/hyZ 6HSrxt/TrwqhQHqhnryXpjS1eQC7fHDkMpdzzt8iKRQTD4UMeQg20tfcF H12BSerBtrgenUFpoSTFF76olbynK4E/VGpWcCxFot7VKczhQ2OX0HzvB fpu2U3lXFTTU8mUGnc00QCLSEUuprPxN53Ga174Vr0XBUn28Pb8OV46O8 v0KcVBIE2oLpQIfBB58drPZifSKmLCKlIDeoxWrgBoUBxTxiUcpF+d38u Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="311728002" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="311728002" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 08:03:35 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10540"; a="619664771" X-IronPort-AV: E=Sophos;i="5.96,187,1665471600"; d="scan'208";a="619664771" Received: from vcbudden-mobl3.amr.corp.intel.com (HELO [10.212.129.67]) ([10.212.129.67]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2022 08:03:34 -0800 Message-ID: <1249f7d6-1a95-4268-366b-7da5ecec7b92@intel.com> Date: Wed, 23 Nov 2022 08:03:33 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 1/6] x86/tdx: Support hypercalls for TDX guests on Hyper-V Content-Language: en-US To: Dexuan Cui , "ak@linux.intel.com" , "arnd@arndb.de" , "bp@alien8.de" , "brijesh.singh@amd.com" , "Williams, Dan J" , "dave.hansen@linux.intel.com" , Haiyang Zhang , "hpa@zytor.com" , "jane.chu@oracle.com" , "kirill.shutemov@linux.intel.com" , KY Srinivasan , "linux-arch@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "luto@kernel.org" , "mingo@redhat.com" , "peterz@infradead.org" , "rostedt@goodmis.org" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "seanjc@google.com" , "tglx@linutronix.de" , "tony.luck@intel.com" , "wei.liu@kernel.org" , "x86@kernel.org" Cc: "linux-kernel@vger.kernel.org" References: <20221121195151.21812-1-decui@microsoft.com> <20221121195151.21812-2-decui@microsoft.com> <18323d11-146f-c418-e8f0-addb2b8adb19@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE 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 On 11/22/22 17:37, Dexuan Cui wrote: >> From: Dave Hansen >> Sent: Monday, November 21, 2022 12:39 PM >> [...] >> On 11/21/22 11:51, Dexuan Cui wrote: >>> __tdx_hypercall() doesn't work for a TDX guest running on Hyper-V, >>> because Hyper-V uses a different calling convention, so add the >>> new function __tdx_ms_hv_hypercall(). >> >> Other than R10 being variable here and fixed for __tdx_hypercall(), this >> looks *EXACTLY* the same as __tdx_hypercall(), or at least a strict >> subset of what __tdx_hypercall() can do. >> >> Did I miss something? > > The existing asm code for __tdx_hypercall() passes through R10~R15 > (see TDVMCALL_EXPOSE_REGS_MASK) to the (KVM) hypervisor. > > Unluckily, for Hyper-V, we need to pass through RDX, R8, R10 and R11 > to Hyper-V, so I don't think I can use the existing __tdx_hypercall() ? What's to prevent you from adding RDX and R8? You could make TDVMCALL_EXPOSE_REGS_MASK a macro argument. Look at 'has_erro_code', for instance in "idtentry_body" arch/x86/entry/entry_64.S. >> Another way of saying this: It seems like you could do this with a new >> version of _tdx_hypercall() (and all in C) instead of a new >> __tdx_hypercall(). > > I don't think the current TDVMCALL_EXPOSE_REGS_MASK allows me > to pass through RDX and R8 to Hyper-V. Right. So pass it in. > PS, the comment before __tdx_hypercall() contains this line: > > "* RBX, RBP, RDI, RSI - Used to pass VMCALL sub function specific > arguments." > > But it looks like currently RBX an RBP are not used at all in > arch/x86/coco/tdx/tdcall.S ? Yeah, it looks like they are a part of the hypercall ABI but no existing hypercall is using them. Patches to fix it accepted. :)