Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2348192rwb; Thu, 27 Jul 2023 06:05:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlFX9ITK+hZmnPrzSiyQ+CenEpOIKPvmOuEOAzcpKMHZqdgRI50wVSv7UZk8d+OIBSENKbT8 X-Received: by 2002:a05:6a20:8f13:b0:130:661c:613d with SMTP id b19-20020a056a208f1300b00130661c613dmr4818985pzk.5.1690463152785; Thu, 27 Jul 2023 06:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690463152; cv=none; d=google.com; s=arc-20160816; b=AmLwUv0Mx2d5wlbcxUs5wrCwxWDjakS9AOiNz6GUGfKg9ITo79bC3gcGR/24HEZzGz HlPRLfRon9XOuyFn7eEwgAbw3mNuPKqDo9noatgAL098rXBkxp1LYctx07xN2pfKgywH D3bTKhIA3bK12loxYKPuuTm+juoNBWOHlGz+fg9yTq8STY1C7/AMzeniYf6faijvD2mW 2LjgLyinLq6TAOzvOjx70mca7k3VT8FQZiw19gDgyQ/vWMSng1cUBizsW8e8dBLhdNEV dJR+v+1tZQPGKOT7HO7XOPSI16RiuPXo/3CXdmsPRkGf+hI6P5lYbuoHLPR/MG7mQjNW AV8w== 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=MpMRZbwHOuFGtDnrKsMgG2yjFnD8Sd9wMx0yjmITZyE=; fh=zN2JBeE3ky/Xz5p/ZSHHDMuLiv0fZP/68F4Zs1KJnZc=; b=OtGeFbqc7GTLol/qRs72HWnBJmw53yM+td5dFnajH8WRwyBSZhfweGoYeWxvdfW6Tx L70bvLYhjJ47q5zsdPfvmtBlRBdiDqTgVxbaJEZLGbLKbLzDaZGloSQ01qdAKkkX2ZIK iK8U/kyTgoTstu6vhX2HLINamFTKcGbA0IlHB+oGJBcaWbDZ2kee7Jxwz0+XHSwrGm78 2mMomBuwEsfhrnz6bTs05QFhc88W8ktGJ700WrVNB16GOuhM1BF/7E8Cs1wECP9g9gkP L257f+BqzdatAt12OWysGx9n4c8l8n8Kn00HxSd1cRUQ5OvYCHzcGajEhp7pb83KCR8J eCng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="f5O7v/QM"; 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 t10-20020a63b70a000000b00563dc551164si1250238pgf.162.2023.07.27.06.05.39; Thu, 27 Jul 2023 06:05:52 -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="f5O7v/QM"; 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 S233749AbjG0Mse (ORCPT + 99 others); Thu, 27 Jul 2023 08:48:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbjG0Msd (ORCPT ); Thu, 27 Jul 2023 08:48:33 -0400 Received: from mgamail.intel.com (unknown [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E903B1737 for ; Thu, 27 Jul 2023 05:48: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=1690462112; x=1721998112; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=8FxoD7XbQTi048PFDj7HD73MEU7uEbz7jFpoEHMrqAk=; b=f5O7v/QMwVyD+jfXC3kV8bMIt6vG7PkfIDsRfLJdNU/0y+ewKCHxxHon lrpwdpTg7KyKMvLZ2Xafer+Sl8P5Ifdm3BbPF5vUYXUpKz1d2Ysa63T/A wCXxonRenQ8k1lPjaOIl/AtcDJMIfJ1DohAVSobH0ZdCprAVRurMn+6Cq IKV8N2oLDsUPsGwq/U+Kbt5he+SvjYUNUEaC0CNUH/KB4a9xPp45mMt1O uUS+EzevMEl+KJanBxZirQtiNi9OED8oJVbRfS6qH/6l88Sc3kOU1NNLB 0XVxPrWC9x753TwxoSCDztHpZ3d5gTSbiokQfo2Je4j5n7CaZHwi1TyaG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="371906204" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="371906204" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 05:48:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="677145430" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="677145430" Received: from lzhiguno-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.37.222]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 05:48:29 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 41A19109503; Thu, 27 Jul 2023 15:48:26 +0300 (+03) Date: Thu, 27 Jul 2023 15:48:26 +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 01/12] x86/tdx: Zero out the missing RSI in TDX_HYPERCALL macro Message-ID: <20230727124826.obblw2vtkavr4f2o@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,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 Wed, Jul 26, 2023 at 11:25:03PM +1200, Kai Huang wrote: > In the TDX_HYPERCALL asm, after the TDCALL instruction returns from the > untrusted VMM, the registers that the TDX guest shares to the VMM need > to be cleared to avoid speculative execution of VMM-provided values. > > RSI is specified in the bitmap of those registers, but it is missing > when zeroing out those registers in the current TDX_HYPERCALL. > > It was there when it was originally added in commit 752d13305c78 > ("x86/tdx: Expand __tdx_hypercall() to handle more arguments"), but was > later removed in commit 1e70c680375a ("x86/tdx: Do not corrupt > frame-pointer in __tdx_hypercall()"), which was correct because %rsi is > later restored in the "pop %rsi". However a later commit 7a3a401874be > ("x86/tdx: Drop flags from __tdx_hypercall()") removed that "pop %rsi" > but forgot to add the "xor %rsi, %rsi" back. > > Fix by adding it back. > > Fixes: 7a3a401874be ("x86/tdx: Drop flags from __tdx_hypercall()") > Signed-off-by: Kai Huang > Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Kirill A. Shutemov -- Kiryl Shutsemau / Kirill A. Shutemov