Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp803686rwp; Thu, 13 Jul 2023 00:56:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlHj+EyX7CcZrECse/DmMuDLDTacvewDwiYRW5bv3x85yipH4u/TZ5CiznHMVBACDFtFpcC2 X-Received: by 2002:a17:90a:ff0e:b0:25e:a1ae:16c6 with SMTP id ce14-20020a17090aff0e00b0025ea1ae16c6mr231207pjb.27.1689235014894; Thu, 13 Jul 2023 00:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689235014; cv=none; d=google.com; s=arc-20160816; b=rbOOv3+MykfrFU6TYhosA8he2cm0/3xjBcxPd1+o1aX6Rz5IiNUGnixp4GlWzbFITd PhQgA+XsfH35DJGdc2ZzXAlsxMdVRvZoIt6AJ41Y2E5iBoOL97DcfRb5wvq8btXsnO4d R0AVJBA3FfjLqAFtRwiBu9V7RuQpev82ZR9V/9uGzmNBvvNCRXSPHxBVZ+O+6j7e98lB dmVOcyBqqmQla/G1z5vnrMWm1TxWaxdhL0GX5wMg1Ly0QbZ/zp3cTxx3+qRxEL/ZoSgJ PUb/Mmh4za23n44hWaKR58TB5aa7dN+T4eGbyvtFZ5CDdnIOrU0sLDykoo+5TzBxEAiM x4TA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kTKp92nMORKUni0dDHjGU0PJGOsCJq93jIUVcsPJDLw=; fh=6qr3p3W8my/LuooMd5Xj8Uyk6qXhNDJNlekZX0tZbEE=; b=GcZ4+MyEBLfuZRtyp0lWb805CmzzbujG2bW+z/xn4XfLzOM7bCQDyRiO73I9MSRZU3 TFkQhiZqX5DAtDS2pmlxGwx/ZBe1pJqhbg6Q9/AFEORmSFBJU4SJgiaEcsTKqCxxhets zi7eAdNN6k2mEqvij52U+hYqh2mOkWXOVgaCCgIFujoK386MDvkFWpyUatv0UThwnMDT MhE4kybpfm6aBmpFz/RbZKyqZys81slpAk4mvb4kJCaN31FOeZGIupNa1NdBKyW/NTDe WQcWIHuz+FdxD7UUXYXGegxw5er7YeLBAVtPKyGrWqAIGstGjnzKisF7Wu/kWGerUqe1 dLPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PG+QC7QZ; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f24-20020a17090aa79800b002633b73a4a6si12003892pjq.54.2023.07.13.00.56.43; Thu, 13 Jul 2023 00:56:54 -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=@infradead.org header.s=casper.20170209 header.b=PG+QC7QZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232126AbjGMHm2 (ORCPT + 99 others); Thu, 13 Jul 2023 03:42:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbjGMHm1 (ORCPT ); Thu, 13 Jul 2023 03:42:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B02AF2108; Thu, 13 Jul 2023 00:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=kTKp92nMORKUni0dDHjGU0PJGOsCJq93jIUVcsPJDLw=; b=PG+QC7QZT8c+wHG7QXMZtiU7Iy ns+yBDoctmpQZtLYxx8Jh9fErsXo4fYvBoNvzrEiiSndGFfr/bH5n73gubATb70OgYYjgLd8HEuEg LEEbJCb7EURr0jtB8Iq0U1kOrfZ6StJPQafc/fycSi8g6+wXwkxULR9L6/Oi3RWFjIs5ksIhRUjV+ 8HPV7UlgLkogadF3uFtCQcSgp4TMw3pco0zEcmU34g+rP3kro6LVtryBS2u4Hs22A6bv9fyLSZNGt eU6AhoJuG27LpS/37Sr6ztYuoP5dgUBegqL2/IzxGH4RBpLZAOjWU0XQ/e3cOCoeTFBzUuDziyXbg m5AQX5xA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qJqxi-00HWIH-GC; Thu, 13 Jul 2023 07:42:06 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DA6BB300222; Thu, 13 Jul 2023 09:42:04 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C17F9245CA115; Thu, 13 Jul 2023 09:42:04 +0200 (CEST) Date: Thu, 13 Jul 2023 09:42:04 +0200 From: Peter Zijlstra To: "Huang, Kai" Cc: "isaku.yamahata@gmail.com" , "Hansen, Dave" , "Christopherson,, Sean" , "bp@alien8.de" , "x86@kernel.org" , "hpa@zytor.com" , "mingo@redhat.com" , "kirill.shutemov@linux.intel.com" , "tglx@linutronix.de" , "linux-kernel@vger.kernel.org" , "pbonzini@redhat.com" , "Yamahata, Isaku" , "kvm@vger.kernel.org" , "sathyanarayanan.kuppuswamy@linux.intel.com" Subject: Re: [PATCH 09/10] x86/virt/tdx: Wire up basic SEAMCALL functions Message-ID: <20230713074204.GA3139243@hirez.programming.kicks-ass.net> References: <41b7e5503a3e6057dc168b3c5a9693651c501d22.1689151537.git.kai.huang@intel.com> <20230712221510.GG3894444@ls.amr.corp.intel.com> <4202b26acdb3fe926dd1a9a46c2c7c35a5d85529.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4202b26acdb3fe926dd1a9a46c2c7c35a5d85529.camel@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Thu, Jul 13, 2023 at 03:46:52AM +0000, Huang, Kai wrote: > On Wed, 2023-07-12 at 15:15 -0700, Isaku Yamahata wrote: > > > The SEAMCALL ABI is very similar to the TDCALL ABI and leverages much > > > TDCALL infrastructure.? Wire up basic functions to make SEAMCALLs for > > > the basic TDX support: __seamcall(), __seamcall_ret() and > > > __seamcall_saved_ret() which is for TDH.VP.ENTER leaf function. > > > > Hi.? __seamcall_saved_ret() uses struct tdx_module_arg as input and output.? For > > KVM TDH.VP.ENTER case, those arguments are already in unsigned long > > kvm_vcpu_arch::regs[].? It's silly to move those values twice.? From > > kvm_vcpu_arch::regs to tdx_module_args.? From tdx_module_args to real registers. > > > > If TDH.VP.ENTER is the only user of __seamcall_saved_ret(), can we make it to > > take unsigned long kvm_vcpu_argh::regs[NR_VCPU_REGS]?? Maybe I can make the > > change with TDX KVM patch series. > > The assembly code assumes the second argument is a pointer to 'struct > tdx_module_args'. I don't know how can we change __seamcall_saved_ret() to > achieve what you said. We might change the kvm_vcpu_argh::regs[NR_VCPU_REGS] to > match 'struct tdx_module_args''s layout and manually convert part of "regs" to > the structure and pass to __seamcall_saved_ret(), but it's too hacky I suppose. I suspect the kvm_vcpu_arch::regs layout is given by hardware; so the only option would be to make tdx_module_args match that. It's a slightly unfortunate layout, but meh. Then you can simply do: __seamcall_saved_ret(leaf, (struct tdx_module_args *)vcpu->arch->regs);