Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp1886733rwb; Sun, 6 Aug 2023 05:22:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECzTT82G37PPFINlgYY4E4oJxf1z5YggsVxVHvYFe67P/N4h/WU1vWtJEzYUSBlR2qFuyZ X-Received: by 2002:a17:90b:24c:b0:267:c21f:ce0d with SMTP id fz12-20020a17090b024c00b00267c21fce0dmr4607741pjb.27.1691324524037; Sun, 06 Aug 2023 05:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691324524; cv=none; d=google.com; s=arc-20160816; b=fCb3CzVGQLPGdpppfb/QFAGbOCVqXxlMYA/Kt/AzYaU9nx2CBauROPA+kmBou41pvK qkFbrm9SOkq4DLALpqu+zYKVMxdZSlWoRKE+UecFcNOnBeUx/3I0GmOybSOZEtjSV1QF w4QLGF3VZWcI1K8Lde7bWzh+0fOy/lA63+s0vxp5jxoqgvGIjJIMYz4LHa+TR5aERymB UOxVRsxxRCamUBChDAZ3cvWk6z3hT8scJM4zZqVSB/fvfIFhBn+FYx/iSQL08jJls1I6 j7Ty/248ffqS4RhFRGVeb02xdIgv8YDAmyd784oOfjI6zVSWNdocEin9lMuVbue2Cxq2 Esmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dpzRE18eL7SafnSG4jyqQw3KcnNspscLL5U5EKmqrXY=; fh=zN2JBeE3ky/Xz5p/ZSHHDMuLiv0fZP/68F4Zs1KJnZc=; b=iJn4owI+0SaNQRvKkZppQVkMxHEY2KHt1pTFVPAhQIJtaODd68EgsJdPIKNl7N+OIC GOHFw66O5CCMttUDIAGgdz5aMR+bpIbANwWlrDimR1BuwsgrMpHzER7Y8VLJ++jgOvY1 L+JBGXIHDIR5JwN2dOyQ6XlZd3Alz+Ur6vSgRbLQIet6E5U2JDpmRDDL15eBVM/shXjv TNZR/3rXOO/0eE78QpoFr1P2nuExSLHm3rYY8CFy2GSSPANXjl1VKeA2O1Sp0Wge5TIi ZrvQHCcd9TyKe7OhHrjeRNOx0htqNXEa5Nd+ysGPACCwmTyN6b8HxSFSaLh9eOU/4UKR +0Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="cX+n/S6y"; 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 pg3-20020a17090b1e0300b00268122b5e44si4603195pjb.134.2023.08.06.05.21.50; Sun, 06 Aug 2023 05:22:04 -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=@intel.com header.s=Intel header.b="cX+n/S6y"; 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 S230014AbjHFLuf (ORCPT + 99 others); Sun, 6 Aug 2023 07:50:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjHFLue (ORCPT ); Sun, 6 Aug 2023 07:50:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2CD13E for ; Sun, 6 Aug 2023 04:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691322633; x=1722858633; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=Ba9pH4Ej96kIzhLD9374A9bsflq4WpKM4PvDVeUYqSA=; b=cX+n/S6yZ/lZE5mLiB3GlHEZDFzkKaTJw+RhwT5CRkgmLv70gh+N6WPq rcM4ESLo/Q3XRPrPV5B492fpKohBhe0Ipn6bc091m1SKHaDrIIZYSYxAx UBc0FmvGwis0koeVmrEE3AZp8zuwybKgJr/ZGMf8kkcTG7jNp1Ab02gxp NM/E1AWibjt2k1xnXPOrHBaAIEv3E/sOxm1aVqHq7C/mzaO4NRhA0kxQD gBrmbRsucMhB2rkkVhX020CwoTT5FG/LSSobZ5GZ8rgjGpIb+yKZoTjbi Y/NgbQYBRE+rvrYWhficGZIsSsB2Uq0g3+CZI496Js4nATf41PgzyFWGo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10794"; a="373128851" X-IronPort-AV: E=Sophos;i="6.01,259,1684825200"; d="scan'208";a="373128851" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2023 04:50:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10794"; a="760137935" X-IronPort-AV: E=Sophos;i="6.01,259,1684825200"; d="scan'208";a="760137935" Received: from mvalka-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.63.122]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2023 04:50:27 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id A989A10A117; Sun, 6 Aug 2023 14:50:24 +0300 (+03) Date: Sun, 6 Aug 2023 14:50:24 +0300 From: kirill.shutemov@linux.intel.com To: Kai Huang Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, seanjc@google.com, pbonzini@redhat.com, isaku.yamahata@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, n.borisov.lkml@gmail.com Subject: Re: [PATCH v3 12/12] x86/virt/tdx: Adjust 'struct tdx_module_args' to use x86 "register index" layout Message-ID: <20230806115024.k3oc6u3yu42q7h5l@box.shutemov.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 Wed, Jul 26, 2023 at 11:25:14PM +1200, Kai Huang wrote: > For TDX guest, KVM needs to call __seamcall_saved_ret() to make the > TDH.VP.ENTER SEAMCALL to enter the guest, possibly taking all registers > in 'struct tdx_module_args' as input/output. > > KVM caches guest's GPRs in 'kvm_vcpu_arch::regs[]', which follows the > "register index" hardware layout of x86 GPRs. On the other hand, the > __seamcall_saved_ret() takes the pointer of 'struct tdx_module_args' as > argument, thus there's a mismatch. > > KVM could choose to copy input registers from 'vcpu::regs[]' to a > 'struct tdx_module_args' and use that as argument to make the SEAMCALL, > but such memory copy isn't desired and should be avoided if possible. I doubt the copy will be visible on any profile. I personally don't like that kvm implementation detail leaks here. It suppose to be generic TDX code. -- Kiryl Shutsemau / Kirill A. Shutemov