Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3192816lqo; Wed, 15 May 2024 02:31:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJkLGY2Yy/BwmuIjTjcaM+HqD+7x2/qRQNOyt57U0tLjdrUydQXu8B4GuZvWSln2XvEHqS46tWrZ5uinOZhxD5zmIyd5RtlJQymTZ4Dw== X-Google-Smtp-Source: AGHT+IFMWGO7zXosl7cMfvYx62YUz25YCc676jhnF59ii7KftvPhnlKcutLFsNBo96aQIG8RzId8 X-Received: by 2002:a50:d5d2:0:b0:574:ea9d:51f3 with SMTP id 4fb4d7f45d1cf-574ea9d5459mr2422232a12.15.1715765470058; Wed, 15 May 2024 02:31:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715765470; cv=pass; d=google.com; s=arc-20160816; b=wy5pqkdS3nLetXoP8feaoHOP7CcK7UDNxT+F3jZTDn9n+K1FGzaCuND2DqK/1HewdA g7VTfsaZpEeO8uVNS7hGUt/5FH+3m0Xqn8vZMczK3yCjVMItqrd1EReQ9FNf2Y6r0lJ1 Z8DFpk3boV24oLMSCPP903JfBzepCUcIa1CON+CGw1wKfNNVi57A1KuXv92sYBtCUhGB 3LVfHqPQaMVkh6brvPqsDh10QRb1j+q6/nXkRNkOlchJuP3soQogGfip5Mbjl6+iHXEu vM31d3VXDj1hFx8yA1FAO8mLizZ/ciI2vtSxRhbkatga5uVxnftSCHKaDRPYyumZtRgN nupg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xXaCaMZsTLIFtTuG+6JoBQFdcH6MmSqM28TZknmhEyY=; fh=QxbgYAy0VrsoMAdWHJQ/+lo+Jcu4KwlBIJRIF3qkh/g=; b=pELYAY5q7MDyDRJSCSuUM0tGbyhW8E80Zgb+rw7eWaIfWMH37YltyQw6SNt/JW3H2R E4HFqeVp+AIcfaDiCax7gkMZ35v0wknUYdEab8G6ppbdgJRHOMLCV12zHiw/rwW5qOrN 42cyMfyAJoFW7Ykxu8fUfYjXXZlW2UryYO337cE2sZZvxtLXIS88PIJEjTH93drxQo4B YHtbLyi4M0Zy8FQ5tU8ygGP8NlwBP2PBwOdt+KLF2a7JjjtLcl697DpcTQQZrgF7XXUB GCj13dp2gVj1ewxv211sZgrR8NZwZ+1e8NiLM7QK1IjlSur75YEeBBYG2nUdH0wZBd1n HSNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NNef67uq; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179704-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-5733c32880bsi7080918a12.410.2024.05.15.02.31.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 02:31:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179704-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=NNef67uq; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179704-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179704-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 CA6831F23ABE for ; Wed, 15 May 2024 09:31:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80C7559155; Wed, 15 May 2024 09:31:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NNef67uq" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 B921558AC3; Wed, 15 May 2024 09:31:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715765462; cv=none; b=sOPLazdOCBr3x76W+ooC/bOp+1kQeOVjdASq4PhCYnEBKtqHap00ZRj1005hTkNTzOJfK3/HF3a4RVOCEO84BXDOR1QW42DbgGbkBOXyzX1PcmR+xaczESGWQFwVK1pP2cLsps4GCHWi6sn8L6IKNS88MEexq66LjmsHr6help4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715765462; c=relaxed/simple; bh=x0WiLqGSoZ3LIOEaEn9qtWswtKOTZTI/9ZmHSmH3WiA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=AMDPeN/X7JC12Wlte9wxybVxx5WgFZKhYmWEX4D1c6QgNP3q1XBR10Xg1yHscXu5uoRGyvO3ndpChapw4cLnucUIck3FSF66wyY64+HjKfKJtOum53SkOaPRqoV8fGXRg5qAoaNAuV/VrgUn+aotuB56CR0IQpI+X+tBCT9r80s= 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=NNef67uq; arc=none smtp.client-ip=198.175.65.11 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=1715765461; x=1747301461; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=x0WiLqGSoZ3LIOEaEn9qtWswtKOTZTI/9ZmHSmH3WiA=; b=NNef67uqwRctz1IzaiLdjyzjK3pa72EbfGsoLR+JBTgSs6owD28UW4/v 15t3blYy0696ApdaqgnkL5V0Q8CRkIj0zN6OIwmltbeubGBdfT3vTsEiU w7bAqippbw+UAhvkXO2fxNjareen0OwoAXUkXdKMtaQkRBpYoqXAoYxlC UQdE0L8MzwG/APy295olbapZ71CUQuNj25sAEM/fHmhHLx+VPmqffUemH Amz3qhAVHPZBZmrt12VUwWWBISL/8GGqd6V9ahyvctAd+5S1sgyTzcQBY EiuCcVqPutgn2xkbj140HsEBBYe1ByJmKV2WYnYACoDAL3Hk4lj6KsrX5 Q==; X-CSE-ConnectionGUID: w5G1RsEHQmGKy7BVRFANdQ== X-CSE-MsgGUID: ihwy01NbS4CvNsdl5bBJVw== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="22386718" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="22386718" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 02:31:00 -0700 X-CSE-ConnectionGUID: rmsMv8BmTx6TfL6MlANqLg== X-CSE-MsgGUID: BeMOF8duQBW8pYVgEsaE4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="31078044" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 15 May 2024 02:30:58 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 95B0F327; Wed, 15 May 2024 12:30:56 +0300 (EEST) Date: Wed, 15 May 2024 12:30:56 +0300 From: "Kirill A. Shutemov" To: Nikolay Borisov Cc: Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCHv4 3/4] x86/tdx: Dynamically disable SEPT violations from causing #VEs Message-ID: References: <20240512122154.2655269-1-kirill.shutemov@linux.intel.com> <20240512122154.2655269-4-kirill.shutemov@linux.intel.com> <4019eff6-18a9-49b2-9567-096cdb498fb0@suse.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <4019eff6-18a9-49b2-9567-096cdb498fb0@suse.com> On Tue, May 14, 2024 at 05:56:21PM +0300, Nikolay Borisov wrote: > > diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c > > index 1ff571cb9177..ba37f4306f4e 100644 > > --- a/arch/x86/coco/tdx/tdx.c > > +++ b/arch/x86/coco/tdx/tdx.c > > @@ -77,6 +77,20 @@ static inline void tdcall(u64 fn, struct tdx_module_args *args) > > panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); > > } > > +/* 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; > > +} > > nit: Perhaps this function can be put in the first patch and the description > there be made more generic, something along the lines of "introduce > functions for tdg_rd/tdg_wr" ? A static function without an user will generate a build warning. I don't think it is good idea. -- Kiryl Shutsemau / Kirill A. Shutemov