Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1059278lqo; Fri, 17 May 2024 09:25:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9mIxKPb17FonVjpibWz2m+M2CbQGe+AnOCjp2QAasoBkCOabgnUW65CNPXBBjYT5m+/RLirm1mzSx7+1/a0GjZdZe5CLnQj4D9RdkOQ== X-Google-Smtp-Source: AGHT+IE1UddFwqmOpQ1mvO6x5iM2NMW4ddI9K6bdh0P83o8JDIwszhXZYZf1AHHddoIt6acPP2ho X-Received: by 2002:ac2:4a74:0:b0:51a:e305:eb20 with SMTP id 2adb3069b0e04-5220fc7bbb4mr18003386e87.17.1715963119292; Fri, 17 May 2024 09:25:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715963119; cv=pass; d=google.com; s=arc-20160816; b=toc3YlplsIMA9Tbg589JRj6kJ+1HAfxUeW4C2X3dzc8qasl/L5OyQcxrcfUTPcysiB TXvM4EfD/OGkk4e173XR5+q0tOlV2q2otyHRoJ/NWHtulUCmNryeJzqadQmzwwAzw1JY ng6DA1NxT3BMzooVfUzz55kwxqG5n1jTNQS1fxhz3WGvSfDCbiWfinYF8BKRwcY+GkwA jdV/333+lvLlhfeXFMWBBK+IQg971VAG1U6LEh1MhYoneVGWykaur2EEYjaOybfkcV1w 2T8px6GCuNn6pMZkpbkcEpxJYPEusJ92lFPIgHU4df3rrzoOM4XUq5RA/AS94oU0/QAX 26cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xX7N8RGo7rbSxfWh5L3VjUIzexUwNzT1XuwGG72Y6qw=; fh=/8XHUIisCckK1WON22AMYd1ULUseQWCB943z0j44tC8=; b=vEToUICiPGZ05WmAc19LAp+EO3ZVVlrWY8XFz1qfhGuC9toMJ6XZiG1YibZOBJ+oC9 FJAorq926xD+HBmDh38Zj3KqWS+l5KCUay8EViz8BxcusKDhn4bWhBgTaiglgUYwF5Ge GgZrRPrr1EO5zG/aoHwY62xqIp59zh1cGocdkajl+V0ec+rV+7v2XqMNbyqlOforLd7j rhouy/M4lyqvr9x5JbOCQx7poZjAGV9kLgWaINUGSACwcH4nyrc7sJegrjmFtpnvHN7e JYUiJrdVm4I8yJpsOCNB30f2BibSWWqPntWG5qPedX1D++WuYZq79H5p8JteKv7WijDl O2bQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OcOX+ZbI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c362b97si10250235a12.516.2024.05.17.09.25.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 09:25:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OcOX+ZbI; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182346-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182346-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 076341F23169 for ; Fri, 17 May 2024 16:25:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAA4C12FF64; Fri, 17 May 2024 16:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OcOX+ZbI" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A5AA3D9E; Fri, 17 May 2024 16:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715963108; cv=none; b=UJmnPm4n/rNjwtILaiLwHkTb6Svw53QhW/RYLcwvA5lUM+rowGCnQ6hGPGOJRkT1SqgyUUd84PMtSrQi+7t+R4DiUkw78PE60T7R70adMmIbG+TNDAJkF1IkMYkjTHQUhfU/gju1VPqwM68WhesT78kphIWMduOwH24WDtWmGRc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715963108; c=relaxed/simple; bh=vhNvc95DBkL2aLYyLqRIQcrflwmg0YDC3PVeoxygFSM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ujYBuFlHN5eF8O2NXle94QOtpiQULH6mTkPg6vf7U5YbHB0VVFeHRVKx3gy2H/inHYLZbEWM9Pg16thbUn3JVvwcmYvyUc2dJ9kVatqIp/fvgylSIdKSGIkzdZjDXzY63dXCA6fwbaWwZ4XTrv5oZpXpy+boEdSD6JtWFNRPOjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=OcOX+ZbI; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715963106; x=1747499106; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=vhNvc95DBkL2aLYyLqRIQcrflwmg0YDC3PVeoxygFSM=; b=OcOX+ZbIpHZd8cIWflTd3QO3eSreG+Bu82c7dXvtsyBMFYZOaNEVsYkw nPIHRZpsM8ylkbElqJbSxTj+1262EXlCn2/pT9eVxND04lwuZiIAg4GoW CSLBZNFUuLkh9PbeDIt2STiW9/3uv+qZND/VJyjBoBl3xH/b5GYpw8BsI i3e4JQ5BMRiuWYhI6q6iPmL/NS91mh7FyZB6TH4usbQ5+0VqEAN4CiIJW p+k17e8RHnewObqOAUQxr5gsVPyNoEzpyJpUpBK1lrezt38a6J2KSCTbF PKj+7JGqP9zJymxsC100PhOaD9UxS9UZPex5oZlxGVXqZ2DPfu/mJAM2B w==; X-CSE-ConnectionGUID: GY6FLpUoS0eN04Q1cTG+aQ== X-CSE-MsgGUID: TvQxkltzRaO/uWPp4/DoMQ== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="12360930" X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="12360930" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 09:25:05 -0700 X-CSE-ConnectionGUID: Zb/wWZh/Rc2luuvItdghFw== X-CSE-MsgGUID: XwKadQglQDKEPjnFfG4K3g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,168,1712646000"; d="scan'208";a="31847689" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 17 May 2024 09:25:02 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id DBDCF1F1; Fri, 17 May 2024 19:25:00 +0300 (EEST) Date: Fri, 17 May 2024 19:25:00 +0300 From: "Kirill A. Shutemov" To: =?utf-8?B?SsO8cmdlbiBHcm/Dnw==?= Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li Subject: Re: [PATCH v19 039/130] KVM: TDX: initialize VM with TDX specific parameters Message-ID: References: <5eca97e6a3978cf4dcf1cff21be6ec8b639a66b9.1708933498.git.isaku.yamahata@intel.com> <46mh5hinsv5mup2x7jv4iu2floxmajo2igrxb3haru3cgjukbg@v44nspjozm4h> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, May 17, 2024 at 05:00:19PM +0200, J?rgen Gro? wrote: > On 17.05.24 16:53, Kirill A. Shutemov wrote: > > On Fri, May 17, 2024 at 04:37:16PM +0200, Juergen Gross wrote: > > > On 17.05.24 16:32, Kirill A. Shutemov wrote: > > > > On Mon, Feb 26, 2024 at 12:25:41AM -0800, isaku.yamahata@intel.com wrote: > > > > > @@ -725,6 +967,17 @@ static int __init tdx_module_setup(void) > > > > > tdx_info->nr_tdcs_pages = tdcs_base_size / PAGE_SIZE; > > > > > + /* > > > > > + * Make TDH.VP.ENTER preserve RBP so that the stack unwinder > > > > > + * always work around it. Query the feature. > > > > > + */ > > > > > + if (!(tdx_info->features0 & MD_FIELD_ID_FEATURES0_NO_RBP_MOD) && > > > > > + !IS_ENABLED(CONFIG_FRAME_POINTER)) { > > > > > > > > I think it supposed to be IS_ENABLED(CONFIG_FRAME_POINTER). "!" shouldn't > > > > be here. > > > > > > No, I don't think so. > > > > > > With CONFIG_FRAME_POINTER %rbp is being saved and restored, so there is no > > > problem in case the seamcall is clobbering it. > > > > Could you check setup_tdparams() in your tree? > > > > Commit > > > > [SEAM-WORKAROUND] KVM: TDX: Don't use NO_RBP_MOD for backward compatibility > > > > in my tree comments out the setting TDX_CONTROL_FLAG_NO_RBP_MOD. > > > > I now remember there was problem in EDK2 using RBP. So the patch is > > temporary until EDK2 is fixed. > > > > I have the following line in setup_tdparams() (not commented out): > > td_params->exec_controls = TDX_CONTROL_FLAG_NO_RBP_MOD; Could you check if it is visible from the guest side? It is zero for me. diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index c1cb90369915..f65993a6066d 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -822,13 +822,33 @@ static bool tdx_enc_status_change_finish(unsigned long vaddr, int numpages, return true; } +#define TDG_VM_RD 7 + +#define TDCS_CONFIG_FLAGS 0x1110000300000016 + +#define TDCS_CONFIG_NO_RBP_MOD BIT_ULL(2) + +/* Read TD-scoped metadata */ +static inline u64 tdg_vm_rd(u64 field, u64 *value) +{ + struct tdx_module_args args = { + .rdx = field, + }; + u64 ret; + + ret = __tdcall_ret(TDG_VM_RD, &args); + *value = args.r8; + + return ret; +} + void __init tdx_early_init(void) { struct tdx_module_args args = { .rdx = TDCS_NOTIFY_ENABLES, .r9 = -1ULL, }; - u64 cc_mask; + u64 cc_mask, config; u32 eax, sig[3]; cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax, &sig[0], &sig[2], &sig[1]); @@ -893,4 +913,7 @@ void __init tdx_early_init(void) x86_cpuinit.parallel_bringup = false; pr_info("Guest detected\n"); + + tdg_vm_rd(TDCS_CONFIG_FLAGS, &config); + printk("NO_RBP_MOD: %#llx\n", config & TDCS_CONFIG_NO_RBP_MOD); } -- Kiryl Shutsemau / Kirill A. Shutemov