Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1601485lqo; Sun, 12 May 2024 09:31:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUFfkc+yV06HSHXAfa1exaYYfk7LvV89K71bbC+zf90MOjHaVgLCshrrA8woy4ZbHBRNXXWddQU/zwuqorzmltt27F9Q12DSfn2r1Xmvg== X-Google-Smtp-Source: AGHT+IE/TmTWVQMuLi3X/xujL65sFQU91rUoAVNWvboTkaFOsb1tHm0vgTSUKM6pm7ag+f/7w0qB X-Received: by 2002:a05:6e02:1c05:b0:36b:3a3b:b2c0 with SMTP id e9e14a558f8ab-36cc16fb5e3mr94110345ab.32.1715531490557; Sun, 12 May 2024 09:31:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715531490; cv=pass; d=google.com; s=arc-20160816; b=mDC8Eta/ci9vvdqgDQGU54LLU4iyW3YkzbEg1tdLgep5kGOGak15WGKqXaGnfnpr4H 0KxE+IyexGdk9vA8RmGti3vkcjifZiN8iUJ/k4B52yuofE+C6QBstTm2VTiiediTAg6y 7kfhiTGMAeBIug7xVpRPOPProgOhh5gthafo4tEA87xznqE5hL93pTY/JbMroRyJF2Vv b6OeDw2N5sOBMWanQvIQgnmXgzmHXm8jrFW9I3eGSo2DZSFetdPsYShflKD2lbp8I23p TGvxGrqJveeLrcvfGzisvBrKmb5ka3QrOLy0p6l1gRaTZUTnsPJ3/0W5aN5xsDQIrZlE WfAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TQk69Fq2Kl7JuE/PSmHL5iV+09Jzg//41nv0GTON7bk=; fh=WXgLF/dFh0/DsIcJfzi77yqe5HD78AKuIpYwcRDTe+w=; b=D4NJlUIi8rU4etbeLSV/T27JA4JeNlcBPoCgw8kAkWTJ3r4dFc7C/BZf3bToppmHyV DOZcFzy7YivKwNHQoRlPY0RoKkCpesjQKPohQuA47JWlcvjG9kvVv/Jvpd0BuEOe3UQ8 PSotre2zHXME/lpj7xBxemmbB1yPQ11xDSOAbKy1Lc6Z15tVP5b/Vbn6vgQXRyhmUVr+ y2+NRZ5+8Xvtwcn/ChLDmkMGjCY1g0W2bob6J6STJ4qe2G5c/4/qNz3a6/N5XXzLJ+zt pMq2BdZx9gzoPAftiDpiTSPu/0g5y1mql3sCjMF9iKXobe2Ci14sm2oFY4to41c9DTvj 16Ng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HdGnqjgY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-176877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-634133dec6esi7864754a12.788.2024.05.12.09.31.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 09:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-176877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HdGnqjgY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-176877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-176877-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A27C0B21390 for ; Sun, 12 May 2024 12:22:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD97D40879; Sun, 12 May 2024 12:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HdGnqjgY" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 86499210E4; Sun, 12 May 2024 12:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715516526; cv=none; b=NGrl8Dep/zrxDyc3iKW8LxrQ4cGMuY+t64qTZZ5MuH111jW1OTWWRrS5A9UBXnSJupdT4vn8mzEoX25rOWbpqy2/aiJlAYof+wCLWnNZrHIjoV1zWlFbZ/2laGdwDyvElNB4AcGnMz+CQk/p1mhF8SVcU9qBBnDai2MI6oKdbv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715516526; c=relaxed/simple; bh=Nn9Mpy/OuO4rHK6mkJg69gx7p20tgwscyOZVuw2SQfc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SL6Fzssu11wrJKMGX/odDLqqxo5JwZdaa6ri6bfe0h0TuyBNUiO0LuGhCleS4yfYGx7slEcjX2DbVDlNv5nROLn/ch12dG85b/J/TGgCqR+58DfSrnGl1ASX0CV5p6Kqbep5HXVadW/Q0M8ZgmdzsiNMtZovGgdmvet3ZrhjGJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.helo=mgamail.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HdGnqjgY; arc=none smtp.client-ip=198.175.65.21 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.helo=mgamail.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715516523; x=1747052523; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Nn9Mpy/OuO4rHK6mkJg69gx7p20tgwscyOZVuw2SQfc=; b=HdGnqjgYl6uWXQlintcrXmr0Agjz1tJtqauiCLzKbsjU5dnbr9sVo8ae 2G7fsHcQquzIkG1kGbhtzvnpDAu5u+ldv525hHZxNf9fWi1W72x5jCMYO FerGjaNiUlTqCF7U5AXVkSt0y4xhlns/ivGodOQHhu8uTiXfMF9xX0TKK dUCPk0+UidjbaQxU/9VQLcRDjjl4z3dGH6AnqsBfg0iUBXxIwpiJbOtMS JydjRhTVZiP/5CJyUHlJsjgKfrgMgs6MUYls9T6MIlVoYTGyynVsM4fsg MNAOaO3A/5mTz8cte50MDcwylFWnkavNzzPUCNdVCol1Q7G3GgIvoydxc Q==; X-CSE-ConnectionGUID: WQE200EDSjOcNIykHAi9pg== X-CSE-MsgGUID: gfm2v0UQQiy/IpL/uXIvzQ== X-IronPort-AV: E=McAfee;i="6600,9927,11071"; a="11397028" X-IronPort-AV: E=Sophos;i="6.08,155,1712646000"; d="scan'208";a="11397028" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2024 05:22:02 -0700 X-CSE-ConnectionGUID: s/CbvQF4Qu6sSHsOYxqWGQ== X-CSE-MsgGUID: 3pzUhakeTQe3qFGM5neuFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,155,1712646000"; d="scan'208";a="67579704" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 12 May 2024 05:21:59 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 24AF92E6; Sun, 12 May 2024 15:21:58 +0300 (EEST) From: "Kirill A. Shutemov" To: "Kirill A. Shutemov" , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, Kuppuswamy Sathyanarayanan , Kai Huang , stable@vger.kernel.org Subject: [PATCHv4 2/4] x86/tdx: Rename tdx_parse_tdinfo() to tdx_setup() Date: Sun, 12 May 2024 15:21:52 +0300 Message-ID: <20240512122154.2655269-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240512122154.2655269-1-kirill.shutemov@linux.intel.com> References: <20240512122154.2655269-1-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Rename tdx_parse_tdinfo() to tdx_setup() and move setting NOTIFY_ENABLES there. The function will be extended to adjust TD configuration. Signed-off-by: Kirill A. Shutemov Reviewed-by: Kuppuswamy Sathyanarayanan Reviewed-by: Kai Huang Cc: stable@vger.kernel.org --- arch/x86/coco/tdx/tdx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 4bb786dcd6b4..1ff571cb9177 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -179,7 +179,7 @@ static void __noreturn tdx_panic(const char *msg) __tdx_hypercall(&args); } -static void tdx_parse_tdinfo(u64 *cc_mask) +static void tdx_setup(u64 *cc_mask) { struct tdx_module_args args = {}; unsigned int gpa_width; @@ -204,6 +204,9 @@ static void tdx_parse_tdinfo(u64 *cc_mask) gpa_width = args.rcx & GENMASK(5, 0); *cc_mask = BIT_ULL(gpa_width - 1); + /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */ + tdg_vm_wr(TDCS_NOTIFY_ENABLES, 0, -1ULL); + /* * The kernel can not handle #VE's when accessing normal kernel * memory. Ensure that no #VE will be delivered for accesses to @@ -927,11 +930,11 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); cc_vendor = CC_VENDOR_INTEL; - tdx_parse_tdinfo(&cc_mask); - cc_set_mask(cc_mask); - /* Kernel does not use NOTIFY_ENABLES and does not need random #VEs */ - tdg_vm_wr(TDCS_NOTIFY_ENABLES, 0, -1ULL); + /* Configure the TD */ + tdx_setup(&cc_mask); + + cc_set_mask(cc_mask); /* * All bits above GPA width are reserved and kernel treats shared bit -- 2.43.0