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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2932EB64DD for ; Thu, 13 Jul 2023 09:40:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234047AbjGMJk0 (ORCPT ); Thu, 13 Jul 2023 05:40:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbjGMJkZ (ORCPT ); Thu, 13 Jul 2023 05:40:25 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E461FD7; Thu, 13 Jul 2023 02:40:24 -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=kxEHiB4D3m9yY/2dDO7P2A7iGOSaPkpw/P8MmEhifuo=; b=lSisNuvY2Y6og/MU4fqubO5ZCZ o0KzISwWjmdnggSiCAUnk+jPi1PksKszWU9pCusCXpYuJyPWkreDmse7Kv2eiepI+jwnn6fyZM+wy xda8dv5rDApk0IOSAqGNjfJuVpxS6/dBkWUyeowaXAnXUiryry72KHG/g4a6i7Iaa7RyYi9OAcwrm Uk58a4HRX/Y+NjdP1dhDA+8Tsjs8WBXSegjYvvuBEWH/L14xE+Qmzw/Xg/WGTEnQiS+qi9PuykmSb v/Wwjg8LVKlAfcc8ECJA9VP5CMYQRJMZjEeUmDv/AOwrK7VPSAeAZyylvZClUFicci9hlNYCTFThN 3611ICNQ==; 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 1qJsnx-000140-6y; Thu, 13 Jul 2023 09:40:09 +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 25A5430007E; Thu, 13 Jul 2023 11:40:08 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0CA03245CA117; Thu, 13 Jul 2023 11:40:08 +0200 (CEST) Date: Thu, 13 Jul 2023 11:40:07 +0200 From: Peter Zijlstra To: "Huang, Kai" Cc: "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 07/10] x86/tdx: Extend TDX_MODULE_CALL to support more TDCALL/SEAMCALL leafs Message-ID: <20230713094007.GG3138667@hirez.programming.kicks-ass.net> References: <20230712165336.GA3115257@hirez.programming.kicks-ass.net> <6489a835da0d21c7637d071b7ef40ae1cda87237.camel@intel.com> <20230713084640.GB3138667@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jul 13, 2023 at 09:34:24AM +0000, Huang, Kai wrote: > On Thu, 2023-07-13 at 10:46 +0200, Peter Zijlstra wrote: > > On Thu, Jul 13, 2023 at 07:48:20AM +0000, Huang, Kai wrote: > > > > > I found below comment in KVM code: > > > > > > > + * 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. > > > > > > And KVM explicitly does XOR for the registers that gets "pop"ed almost > > > instantly, so I followed. > > > > > > But to be honest I don't quite understand this. :-) > > > > Urgh, I suppose that actually makes sense. Since pop is a load it might > > continue speculation with the previous value. Whereas the xor-clear > > idiom is impossible to speculate through. > > > > Oh well... > > Then should I keep those registers that are "pop"ed immediately afterwards? Yeah, I suppose so.