Received: by 2002:a05:7208:13c3:b0:82:bbfa:f723 with SMTP id r3csp1541616rbe; Wed, 15 May 2024 06:28:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUWwJxOsJPiDEDt1R2rDvWkh2Xu/JFsiy3bXyJmE4aAVnwaT2CZ/zSdeK7iZGhS9ebuc8/Iz7M0Rgn4WhNhyfU/CXdAfje5NXc4p/uaGA== X-Google-Smtp-Source: AGHT+IGciqpl6io42bV0dQkD3trOOBw/VhvV83fN0/iDcSXmnBDUynIaW42UrgD58gERckyse3wZ X-Received: by 2002:a17:907:61a3:b0:a5c:3072:5084 with SMTP id a640c23a62f3a-a5c30725924mr127045366b.59.1715779694472; Wed, 15 May 2024 06:28:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715779694; cv=pass; d=google.com; s=arc-20160816; b=q+6WAKEeSYjtCX7U2ZBLRLesWXON7AvNv6EYmMLk9tG48I3nJiTJnkPhDelfwgMglM RibKb2buluGZrcIe99S6UUkj6/BtX2uo/MeaLM44EWZW6ZkCKTYijv5FNQr5d1X017Am YSarXzrSk279k5wHRqEkL+taK4e97SDw9/hQlVeBKFCPOGu/PPC32rAOanPj/IROAnir meWWel7xP4rg6BBkzBiiirvTLEKIEux8qdiSKWbuy/efSqR5MZn3HXUQQujl38EjVhFA toyqbiY35/WFcUdJjR4AoVakjEVhGnzwEA9LQ725pyqo2fvTl/wEuFZK8j4a/EFBCmcc CBgg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=+ZQczyYTUAQqghnJxDKHUmq7P5Cpxuc3TDeJECCySJQ=; fh=SjNk35o4dZVqVhpd4Fff6LjZ2GuI3c/fo/oNs3AF8R0=; b=Fc7PJBftnSXIsqIqiV4Eg36RXyC01HXj/348rwsfdjPRcs8chYTUY5GQBwC4I4qrrm kgE9VDQMvn+x5dGvrcV5BOMll1D1klw82VsEWNQL9+wp17W+vALhFKic1S5+q4Wh0zsN WOhxPWGyT5CyVZVAoGF8MS+DtQjdG3NlKhyGzLg7z6iPMOO7px3zyZhoieLxjmuPSGDF PlSKQ4s/t1XTrF8szJhJkivjsZq/+9EJZ87nEy+8F6i+/50yOVvi0LRIWxv2YD4mxyLI UPD6zoAg+o1drsyR8Nlk2LsUZpBB05+SVod9e21ZmuaIbXNkMbWfF4g0CFOxNNEM8CME r1rA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=bIBDbkop; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-179900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a8a846d2asi161301566b.453.2024.05.15.06.28.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:28:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=bIBDbkop; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-179900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 270ED1F26630 for ; Wed, 15 May 2024 13:17:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B264512C46B; Wed, 15 May 2024 13:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bIBDbkop" Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C03A785C42 for ; Wed, 15 May 2024 13:14:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715778863; cv=none; b=jshSgQJxFYqLHH192HrgKYt2qem85OkQ7CTJkkBXuiXhGA11gdjLO4qYo2xji3NbWw7RF+EdaKQpwPCx6NedLUYMpdVyB8EhKO57ZxT3AYPeZFeNHY/c9GOYQWiPElzSzpSsO+tLvzR9uOisjvy3CWVTxFML5iszf2qeIyqIdlM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715778863; c=relaxed/simple; bh=s2MsQsbOcEJaFuD6Ni7/NYOLXbHjY6U5QgaDyMhbiHw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=AsAXSXJJeRooye4bBFh4tf1r/TG1d2HQKuqO2ejSaqKo9hjbKRU5I/UhzgSdNoUTArhPdiZobKC0lGDdRIMg6lOPOlEjZz70nx3//wEBDl0NRrZ78ar8UVPsnRYgw2+bSQefUea7gZCtC5EY6rAos5uG3JBDgDu8preVXDo5occ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=bIBDbkop; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-351d309bbcfso9821f8f.3 for ; Wed, 15 May 2024 06:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1715778860; x=1716383660; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+ZQczyYTUAQqghnJxDKHUmq7P5Cpxuc3TDeJECCySJQ=; b=bIBDbkopJNG/Nsldb2WVubvW+IxpeiU9i0kgfdckqAbcjDzi05gxMXSHKpyQvXjsPO 6Bp9tSAe7qbe8AxoJ1qaj8tT80f9hkwoduv52+gOzciFJEmAI//Ot5AZl3bSV3w99Ydh beTWaI9zUYiRoqQrqKNdbcNPsA3h3qOJzO4+RpGJf+GvPRDB73wgsQxOHSh08Ggzygjq Cz0j0VeeVF+U+3MEZogIY8YguFXsQvabpQF/w9D3TSsxLxRk9Zg1yHZ10u4lzYP8yEPe wr0aB0IZkMCHS7geCVn5wn+VUJp0yVA3icNL7PeJ25ykOn34aK4bnsDycCnf5BMMCF2t jZzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715778860; x=1716383660; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+ZQczyYTUAQqghnJxDKHUmq7P5Cpxuc3TDeJECCySJQ=; b=LQ0cJoxqK1mIDUqB2RiDk1O+Mr4+uyn1R+Rh9Rh5bnaspzN6slvVUi12TZTv6xTCPu y2waR2epwmZujtN+l/52Ar29p6cAjCV5Tax8GG06WclBGDcW30Miq9EOmRbnK8QM3TNh T06Afi6G3yD8wXexCPuQGWhugvm20ng/ctU/rAkjlP8aA61PVL7xxutDLnWFTXv1e1+j BQC+EeQVmNpBMyxrIpDddbMjKZx3hVaDmNtbtMmA6nstFaVsGPxLNAVZQAehIIZpCYH5 mByU47EWvFfpiTI2jVrX+EJOk5a/4a+L4on8lhg03HVdvC8Xt6sTHpUrgJ2VkwDflxLm EZ4g== X-Forwarded-Encrypted: i=1; AJvYcCW/4UyJ8/fro+jMZfeu4qdcJm81fauGg8Nrg+Qy+oMPFQF07DHnrc3NCHinkJVhNO4jRYYDX/NCMXETsnlqauUZHSVmXDWAid0+XLfb X-Gm-Message-State: AOJu0Yyxz2OTnYGBxsBSZf4kdXp6TjNvOxDmF5oFSzBzRZ0aSkh8EWqC 83cpZ7RIVm1czBK9KR9jdxwpzXlDQ254QvSwF1tXfl1pB6DX4TohnShUEAp6JN8= X-Received: by 2002:a5d:4f04:0:b0:34e:89cf:4576 with SMTP id ffacd0b85a97d-3504a9689b3mr11621359f8f.51.1715778860187; Wed, 15 May 2024 06:14:20 -0700 (PDT) Received: from ?IPV6:2a10:bac0:b000:7315:bd27:5d9d:ab1e:9b6f? ([2a10:bac0:b000:7315:bd27:5d9d:ab1e:9b6f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502bbc5654sm16576757f8f.115.2024.05.15.06.14.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 May 2024 06:14:19 -0700 (PDT) Message-ID: <8a5fa107-a055-4c05-bcb1-dc4044be841d@suse.com> Date: Wed, 15 May 2024 16:14:18 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv4 3/4] x86/tdx: Dynamically disable SEPT violations from causing #VEs To: "Kirill A. Shutemov" , 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 References: <20240512122154.2655269-1-kirill.shutemov@linux.intel.com> <20240512122154.2655269-4-kirill.shutemov@linux.intel.com> <4019eff6-18a9-49b2-9567-096cdb498fb0@suse.com> From: Nikolay Borisov Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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. Anyway that could be considered a minor thing.