From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83589EB64D7 for ; Fri, 30 Jun 2023 09:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F368A8E0002; Fri, 30 Jun 2023 05:34:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE6B48D0001; Fri, 30 Jun 2023 05:34:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D87958E0002; Fri, 30 Jun 2023 05:34:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id C4F9C8D0001 for ; Fri, 30 Jun 2023 05:34:59 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 908481A0E47 for ; Fri, 30 Jun 2023 09:34:59 +0000 (UTC) X-FDA: 80958905118.05.C3EC5C3 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf13.hostedemail.com (Postfix) with ESMTP id C52062000D for ; Fri, 30 Jun 2023 09:34:57 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="q6KW/ltd"; dmarc=none; spf=none (imf13.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688117697; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gjvjkCCihEKSHCtNs55Vy6HK0fcX8LSjTlJEivouiKY=; b=KCEFD7diJIkzjQkhtq5Xz0ehVy5oW6ZLbzO7iVRXAKDOTgZBmNdNDbxlgVqlefrpQOW4xw HhOf5ZyIwqkY9VxsEafpTAv9rMZLaxTuVmS5rnDS51Jad0hki75vtGN9U5y4ljmIYNlrdb 8VyjA6uuz18skXtYvhxchwq18bUthpQ= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b="q6KW/ltd"; dmarc=none; spf=none (imf13.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688117697; a=rsa-sha256; cv=none; b=KDBafG4GFcAWAbju88VMM+PU6RiCINR0FI7paO9GQxURSKvjE6OsG5OKdndK3NNvDM/63v MeAxCEYy2m7J9oA8eF8GCgfb7nsyPintt3ulO/qk+zzsRsCSOe5nsCpwc+jAZ9HW5osgSy qrsDdy0zQ0g4ipxfO1LIUDWXFjJu/is= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=gjvjkCCihEKSHCtNs55Vy6HK0fcX8LSjTlJEivouiKY=; b=q6KW/ltdiPKvvuRUgkhRpG5tiX xYPuaOz5D40BDLakmqRRweDB6CAbOHn5CbNRYUObwWPty+Rz7sxXyh62XDqPKlr/cq5bQYuU+k9h7 K/Z8H3HKvofJrY19uhf+RIta3h1hV8kLApOolc7NVHrSdb6RvUTaT7JwZwTxPX4LI9+9Xy72rG22a kF4L29JAf6v+j0l75hsaiKVdYYzy4PchGG9Q60FBOH9LaYWPbILZaeajIyiNXj6/KlV7DAJEmT9hP BYlCELyihyg0JOiaLMm4xWuaDdkxkPdRq+iPXtofR+QiyEtQp9l52W6yIUpwyqXXZdZGFCgArrW7A 1yKY3AjA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qFAWa-007wV9-29; Fri, 30 Jun 2023 09:34:44 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 21D78300118; Fri, 30 Jun 2023 11:34:44 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 07396245D3645; Fri, 30 Jun 2023 11:34:44 +0200 (CEST) Date: Fri, 30 Jun 2023 11:34:43 +0200 From: Peter Zijlstra To: "Huang, Kai" Cc: "kvm@vger.kernel.org" , "Raj, Ashok" , "Hansen, Dave" , "david@redhat.com" , "bagasdotme@gmail.com" , "Luck, Tony" , "ak@linux.intel.com" , "Wysocki, Rafael J" , "linux-kernel@vger.kernel.org" , "Christopherson,, Sean" , "mingo@redhat.com" , "pbonzini@redhat.com" , "linux-mm@kvack.org" , "tglx@linutronix.de" , "kirill.shutemov@linux.intel.com" , "Chatre, Reinette" , "Yamahata, Isaku" , "nik.borisov@suse.com" , "hpa@zytor.com" , "Shahar, Sagi" , "imammedo@redhat.com" , "bp@alien8.de" , "Gao, Chao" , "Brown, Len" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Huang, Ying" , "Williams, Dan J" , "x86@kernel.org" Subject: Re: [PATCH v12 08/22] x86/virt/tdx: Get information about TDX module and TDX-capable memory Message-ID: <20230630093443.GE2533791@hirez.programming.kicks-ass.net> References: <20230628141011.GG2438817@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C52062000D X-Stat-Signature: 8wgw683jiwbzgxxx1ubin83rhqr5j7mj X-HE-Tag: 1688117697-153431 X-HE-Meta: U2FsdGVkX1+xxEiQzyHQaH7LA1AkGhcWgZ8zEsFwSvM1mVYJyNqxhFmncDLsxJ8gXsAMKzPio1D3Sn0NHUbiYbWGn8oCiQKgsqq5OyGcCNFRKoMuPjVAb3iaz2umRBUy0ew+8vBob1WDegfr3e2OeYshF/7lT2czVt/eE62Soh3kF4bnxdJj+uRo9jIKC9OF6cldbr0zOTUenwAyqZFhVq81hJbXXOOCDesT0CZ7Gnts7UNGElNhANshE77hMhB6/UysXRmyAVpXSzvHERcJs3HDbRqWPJyzUiA5OwruI7omV5atIbQd4YPAMAVCnZ8MSORJICKOY4llbneKAf/0IyP5+hj+crUogAC8Zq+8ICnGW643UPKYi0I4vA5qqXrG8OmivD8lZIz5SLvuhoBlySFFihQuyWfUW6tzgMZlaW56IctRdN5YXPmSkbYFZukJaDNDIYyqAaOdVxDEw7XO/vDSq99yfsBlS5ZoNRDi1CtA9chWq2gdpoT2ERz7LG1o+Aj6gSMGZw7NTvIUT+2qj2o5jSCpTSfUez0LtdsWeqqI1xzBJA1RLUQ7Nbs78IT7SjTQpVujNvtABX3aUvZngVlw94xmJpCRJrrpnoI/JjrBmtqdq8FZXaWPIqdKHoEJFBLvb1KyCO5CO/9EK8spGwZvaSkaNVHKnVq8RCcTgKUDqyXDX7zNuaTjzsM/xJL3gYDaDBO9DcWr1eOkdLsgrm5K6NJr6UaSDE/yTvjgqe14XqiMBb1a7RCb1P7HRZy5xq2lw/lU/QUX2dN3fUpXI2kq7ztR1PkVRs7PRGiTgeimXTfgIU0KsHngxFFGmIO1rACGzTmDHgPJZ0N9WFkTFzT7unpyzimgJTIXegwWk9YHZr91+udd9oCSXeYeT+pVpGO9Sq9UUGd8dDlB0ZtmQFN6QpNZpgN/wMyRZxNQJCP8U+XfCjY4lAlcPmdvRr2+x9HYIh9qRv1r/V/Fko8 5WIRIqOl bvEL9QkUiJR18ColNXN+CyghRTLTpJXljyXl96eLHZ8EKXeBA0Uh/i1hcCkh8FBh4wAsTJaegbTpKc21KcN9J39+p0X6twnT4St71SUM8d5MLq7Q/+VwX2KRBTpUlhzurIfF9+GOaMGReU29lZlmb+qbvsHFL9qwGgdUYUdx7ZpBgYXXxDWVhJvk10l+aBXrjWA+wm6+v4oQAbaVvgURK/Xs2GFdS2zxaLnSnmRuU5h4sJgEjMIJOcOT7T1cUB+6A0qCeJylj1ojcMjhZ1o3OPuw3Jd1PSKEK7RAZvEZsTdqenNRhi62UACqAmQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 29, 2023 at 09:15:39AM +0000, Huang, Kai wrote: > Sure. How about below? > > + /* > + * TDH.SYS.INFO writes the TDSYSINFO_STRUCT and the CMR array > + * to the buffers provided by the kernel (via RCX and R8 > + * respectively). The buffer size of the TDSYSINFO_STRUCT > + * (via RDX) and the maximum entries of the CMR array (via R9) > + * passed to this SEAMCALL must be at least the size of > + * TDSYSINFO_STRUCT and MAX_CMRS respectively. > + * > + * Upon a successful return, R9 contains the actual entries > + * written to the CMR array. > + */ > sysinfo_pa = __pa(sysinfo); > cmr_array_pa = __pa(cmr_array); > ret = seamcall(TDH_SYS_INFO, sysinfo_pa, TDSYSINFO_STRUCT_SIZE, > Or should I just repeat the spec like below? > + /* > + * TDH.SYS.INFO writes the TDSYSINFO_STRUCT and the CMR array > + * to the buffers provided by the kernel: > + * > + * Input: > + * - RCX: The buffer of TDSYSINFO_STRUCT > + * - RDX: The size of the TDSYSINFO_STRUCT buffer, must be at > + * at least the size of TDSYSINFO_STRUCT > + * - R8: The buffer of the CMR array > + * - R9: The entry number of the array, must be at least > + * MAX_CMRS. > + * > + * Output (successful): > + * - RDX: The actual bytes written to the TDSYSINFO_STRUCT > + * buffer > + * - R9: The actual entries written to the CMR array. > + */ > sysinfo_pa = __pa(sysinfo); > cmr_array_pa = __pa(cmr_array); > ret = seamcall(TDH_SYS_INFO, sysinfo_pa, TDSYSINFO_STRUCT_SIZE, Either of them work for me, thanks! > > SDM doesn't seem to be the place. That doesn't > > even list TDCALL/SEAMCALL in Volume 2 :-( Let alone describe the magic > > values. > > > > TDX has it's own specs at here: > > https://www.intel.com/content/www/us/en/developer/articles/technical/intel-trust-domain-extensions.html > > For this one you can find it in here: > > https://cdrdv2.intel.com/v1/dl/getContent/733568 Yeah, eventually found it. I still think both TDCALL and SEAMCALL should be listed in SDM Vol.2 instruction listing -- every valid instruction should be found there IMO. I also feel strongly that a global ABI should be decided upon for them and the SDM would be a good place to mention that. leaving this to individual calls like now is a giant pain in the rear. As is, we have TDCALL leaf-0 with a giant regset but every other leaf has (c,d,8,9) for input and +(10,11) for output. Lets fix that in stone. Obviously I also very strongly feel any such ABI must not confict with pre-existing calling conventions -- IOW, using BP is out, must not happen.