Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp126153rwp; Wed, 12 Jul 2023 10:38:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1lypgSnRlqhx/Cyqe+iXW4X0qCV3k/+Vo8BFP3IY5t4ipzp3i3I244Cn6XUBbxY01gWX4 X-Received: by 2002:a05:6a21:32a2:b0:130:d234:c914 with SMTP id yt34-20020a056a2132a200b00130d234c914mr19393539pzb.26.1689183522934; Wed, 12 Jul 2023 10:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689183522; cv=none; d=google.com; s=arc-20160816; b=p+MCxQJVYkT/bsAMkZDndFzNd/kwNbsE6Rn9gLzB5ZofwDTrRMuEVO7m/CIoONtOph 8t1sxr27gqz+T0Vb4te/eeUsmZgeQ4vmZ3+ae4Xpl1lFUZy1eQTH2ok4EIOUt+qUk5vc hJZ7tTN8Vm0M7ZHFnlevSXXwHY4uBYlPLV9FQ4evl6vW2BZB0mVFOLcdr26iyqgkw0Oy F6UBtuot2xTeuNYtDqR2t6lQklKIUxu6rB+jWZFFoB2uq/0mke11w+4uT7EDdePbvjUg u+e19laV+m7uZDxyIXAzuVUwpC9il2neSDykV9Vd1tS+8cguemGWRO4dXx3A+qD5+mzl nALA== 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=HHorMwySluudpbrm2kHEFECtUNJWABsOsPm2V3H84B4=; fh=KIjGkAxmv/xewVcbgJIacpYvCmB6XJK44imZqBcIWEI=; b=yyGmx5uS8JfXhDWSzYlxN1hXX6xo02FlYcjORN+gpHe2hls7lhEFbajBltbbLv9E6O rdFnTxrBxnolnpfGKnPKPUFdHZ4iyEnTnv10HcOsP9rf7LDWi82ZYevL/3vbABsSifq8 87jwFb7IJTTGw/qaCNwpmLY8kyvJ4ZY7ui5Q1riV7YNWjf/dxiS3LkLQWWNsSgBd/RB2 c9KyG4kTGjbOFPkDhMEAklMSccyagjq/hYoz5HKd+G/G3uYwwP1fz5IRFoMR5sVy0HOY dH5/hcRItz/VYZETPCl3MypF2i3VkYjxjXY2l2bdniYAAqNlibiMTCy9o5HEvll3BCWY Bq4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=a5FZQOMx; 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 i5-20020a628705000000b0068283238326si3484573pfe.344.2023.07.12.10.38.31; Wed, 12 Jul 2023 10:38:42 -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=a5FZQOMx; 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 S232529AbjGLQx5 (ORCPT + 99 others); Wed, 12 Jul 2023 12:53:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232600AbjGLQxz (ORCPT ); Wed, 12 Jul 2023 12:53:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A2712E; Wed, 12 Jul 2023 09:53:53 -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-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HHorMwySluudpbrm2kHEFECtUNJWABsOsPm2V3H84B4=; b=a5FZQOMxmxJy9IfEQ5SA3svsng PI6+f2Lz6iwIDyI7KPVa7oKtuLASYXiVsCOxohgD9xia5150VCwZ8AqN4raTfa4ypwusB0YgCxtXx Z3brASfbg1U8tbyYqifWCpyCpj+TRHPFCmFSR70vrkF96TZoM120DDKRKFVXZFcka+dOj+OHjkfBP fcsT1KuUhep/jKrt+M5rN7GcDeBnWqIucpgz6pJit/VAv0xNytjKIULwuWHiunUS8sqLoimwrNj0N PHz5I+i3S6/nY5wITsJTdZ8QTIxHXUuszU1ro7vuY5UX92iuLgZS//eYBpdnn7e187HlwAH0TKV4T BIIDYtaQ==; 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 1qJd5v-00GtJ8-BO; Wed, 12 Jul 2023 16:53:39 +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 24BEC3002CE; Wed, 12 Jul 2023 18:53:37 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0E7072464A14A; Wed, 12 Jul 2023 18:53:37 +0200 (CEST) Date: Wed, 12 Jul 2023 18:53:36 +0200 From: Peter Zijlstra To: Kai Huang Cc: kirill.shutemov@linux.intel.com, 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, kvm@vger.kernel.org, isaku.yamahata@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH 07/10] x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs Message-ID: <20230712165336.GA3115257@hirez.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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_NONE,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 On Wed, Jul 12, 2023 at 08:55:21PM +1200, Kai Huang wrote: > @@ -72,7 +142,46 @@ > movq %r9, TDX_MODULE_r9(%rsi) > movq %r10, TDX_MODULE_r10(%rsi) > movq %r11, TDX_MODULE_r11(%rsi) > - .endif > + .endif /* \ret */ > + > + .if \saved > + .if \ret && \host > + /* > + * Clear registers shared by guest for VP.ENTER to prevent > + * speculative use of guest's values, including those are > + * restored from the stack. > + * > + * See arch/x86/kvm/vmx/vmenter.S: > + * > + * In theory, a L1 cache miss when restoring register from stack > + * could lead to speculative execution with guest's values. > + * > + * Note: RBP/RSP are not used as shared register. RSI has been > + * restored already. > + * > + * XOR is cheap, thus unconditionally do for all leafs. > + */ > + xorq %rcx, %rcx > + xorq %rdx, %rdx > + xorq %r8, %r8 > + xorq %r9, %r9 > + xorq %r10, %r10 > + xorq %r11, %r11 > + xorq %r12, %r12 > + xorq %r13, %r13 > + xorq %r14, %r14 > + xorq %r15, %r15 > + xorq %rbx, %rbx ^ those are an instant pop below, seems daft to clear them. > + xorq %rdi, %rdi > + .endif /* \ret && \host */ > + > + /* Restore callee-saved GPRs as mandated by the x86_64 ABI */ > + popq %r15 > + popq %r14 > + popq %r13 > + popq %r12 > + popq %rbx > + .endif /* \saved */ > > FRAME_END > RET > -- > 2.41.0 >