Received: by 2002:a05:7208:13c3:b0:82:bbfa:f723 with SMTP id r3csp1538900rbe; Wed, 15 May 2024 06:23:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHG6uIkJG314EM5R8Kzf9YYkKBW9rQak+khajpEBZCHsdJzVcPqHPI68UltwS8PnZPtH6LHOg3O9y7SO/g/Bg94id7eACpxnjQDyTwBA== X-Google-Smtp-Source: AGHT+IHIBI5H1WFfc6gNHAY3UEn+jjSgIb3JZLbSX68uQm+t1tAxRyQNf8E85AiX/xxB2OoAzNKJ X-Received: by 2002:a05:622a:1b17:b0:43b:15e1:1e87 with SMTP id d75a77b69052e-43dfdaab036mr248069941cf.11.1715779393074; Wed, 15 May 2024 06:23:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715779393; cv=pass; d=google.com; s=arc-20160816; b=yZlITKR72mqbY9EWQghP9D1J6GRSZF3kRlWKu2I+QVkXBjAdYgOii8HIhAcvZP9I1m SykQwnXGNdElcj14bSEgbvs2INwaTwo2ookBv4cAI6SjTT/fmDAjpM8pnZiW+N4loniv KmmktXnf3NeyyTMVfGqKt6+B2+SfeF7obYNK3VRNAfALjP5+BfkRCWE5tNjA1bHY7/nO UaK2L2En0h8xNFHhBYUqpGKXp6GWGqGXtEsWfgUh8WFfRIxxIVP9lV3yM6K261bYt3fd R9HTUtn3UGX2aKfEkP1p+8QExxv3AGjaoYRRBbZtFttr8EiTrVTDwGjNLnwMbQJUgR2v l3ew== 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=34yIgHkx85RnZavNUVZ163Cot2WxHhElTTxraTGgKpA=; fh=QxbgYAy0VrsoMAdWHJQ/+lo+Jcu4KwlBIJRIF3qkh/g=; b=KAk9mN0KA5jwhCj8QaeSMUGh5zqeiDrtdlgtGhEuohrxHefQqHT5Z73XY++cohVsmX QXWkKchGKolCNNr88SBWeQhZsz3A4JtryfJIseVZ2imIz2C8qZIR+kd9rBAy4EMQrvTi zy8zwvJJIZZaBlBbAP/gKnWTwBRiai8CwinhyRmtxvqbitKKGTj+BsE/U4Z0EK6MnaQG uVNIq19bOVI+k85eM06uHxmyCjvzPyvu38PdmlfcHobyM7uVQxzcwiHI+4X7nTTvkgAl 7A0XP/N8UIMK8gTtSG55oukRWkpFI2CPr2KX4eYWLV/Q+IyScLOIZkJx2Tuzwo3IEDzI XI8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U5QiQDgM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179910-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df56d5276si137856481cf.696.2024.05.15.06.23.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:23:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U5QiQDgM; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-179910-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179910-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CC6E71C21C06 for ; Wed, 15 May 2024 13:23:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00498126F33; Wed, 15 May 2024 13:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U5QiQDgM" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 C46DA14AB4; Wed, 15 May 2024 13:23:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715779383; cv=none; b=d260i0Mu/Gisf8JaLJ5uN0wzU0ngFytJLt6K/OejHeBhSxoJvSFaGRrqRFRJwVBwcZL/Cy9haqhriit+cT//PLbWKF9gdCxJd87dAfxYqi7WKjoGRAy1nidHHr458V100Ipn9Eota0rKT6FF0Dc0izYsEsYq4ClFQkcZYRku+qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715779383; c=relaxed/simple; bh=Wbg7b4ydt/+8jq5wvj6n6dJOlOXthP31qnywghWhedM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pXGqMLi7Y/H08U+PetUJL/gouzi0Q+f8hFBQZeXUOnIKsTkob+grR09MVFpY079CiOdyia3EyKSZ6BInt96DeR9NakMzsDBj5KkOJcj2fBmqDyXjSQ9sn+45hd0uNl8R+A0sFjSfROukBHOtHqRozakfVxUpeuo3RreTEBnoq9s= 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=U5QiQDgM; arc=none smtp.client-ip=192.198.163.13 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=1715779382; x=1747315382; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=Wbg7b4ydt/+8jq5wvj6n6dJOlOXthP31qnywghWhedM=; b=U5QiQDgMPcwIhvE7mimXvooiRK6ny5Co6AzhsB3A74WZHJtYPOlNgAkq JwNnH5897DQEBuA4Mk7DrmTUJYTtbq8b+QR2sQzo1aTfKqH0jB4FdcMbt L/UmTcXEVOLeQPMoxzmXtzQoGmzvTbxshZLTXrfNFn5PweM2YQd8daFoQ bO7gxwBCWpQPjSIHnRPA9nALQSrssbFqaUfwq97YFv4XMZoGuR581s8Dz Q0QYdV4aFWZwy0ON6vy9dkZfggxAbm6CDTzpXZKgNY+7ZJuPESuF75FNj Jqx/9DX0kgqPaB6eykr5njYaOhCOJ5TgvPNZr4Lt0iwOkIh9AtLmyYnrM g==; X-CSE-ConnectionGUID: nO8IaYXvTMarceGd4Y0kVA== X-CSE-MsgGUID: GmtG3dNpSN+IzNbjGr67uQ== X-IronPort-AV: E=McAfee;i="6600,9927,11073"; a="14774802" X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="14774802" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 06:23:01 -0700 X-CSE-ConnectionGUID: E0PZQ22fSbaKasd2DoLfUg== X-CSE-MsgGUID: +xP9Ra5UQF2dyU0evu9TUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,161,1712646000"; d="scan'208";a="35935779" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa004.jf.intel.com with ESMTP; 15 May 2024 06:22:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 96B6197D; Wed, 15 May 2024 16:22:57 +0300 (EEST) Date: Wed, 15 May 2024 16:22:57 +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> <8a5fa107-a055-4c05-bcb1-dc4044be841d@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8a5fa107-a055-4c05-bcb1-dc4044be841d@suse.com> On Wed, May 15, 2024 at 04:14:18PM +0300, Nikolay Borisov wrote: > > > On 15.05.24 г. 12:30 ч., Kirill A. Shutemov wrote: > > 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. > > > > But are those 2 wrappers really static-worthy? Those two interfaces seem to > be rather generic and could be used by more things in the future? OTOH when > the time comes they can be exposed as needed. Generally, functions have to static unless they used outside of the translation unit. -- Kiryl Shutsemau / Kirill A. Shutemov