From nobody Sun Nov 24 19:22:12 2024 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (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 E24F31B0F34; Mon, 4 Nov 2024 10:38:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730716711; cv=none; b=PmwDKu6keUBtJAZuCe8UPdKj0cPM8vgl4o9BSjLavpwJmCetwhKKy6XqKdvo8NLU7K6hI0TclA7PRCTKrbvwCn3QWY2S+WM5k/ib2jyWKH/fzBbXSaQpfCVV8y7QcIzBm02+jacBlCo1dAefugMwFbfcgFoNcFR5TS8atBXyDaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730716711; c=relaxed/simple; bh=gocM8aPyttzWISmlvpoeL5oA9VUV8xfMlYkDGj3TCos=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S3MdAs8ijrqmqDPWtb4gbxhd9A/kRkefxfQO8hpioQcp8LOmK71D9SNjakarS65eAXyQoBBZc4mg4n08jxfANBQwWIegX2wsP7mwi0rZDY+YpuDytjEV6CM/5g30DwuUVsoq0jjs+EaPJ87x6YT1a3Ati/LPdTmOfVKw2ac46AU= 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=nGD4SOt4; arc=none smtp.client-ip=198.175.65.17 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nGD4SOt4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730716710; x=1762252710; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gocM8aPyttzWISmlvpoeL5oA9VUV8xfMlYkDGj3TCos=; b=nGD4SOt4WSAMJd7Nrs6g3RoQtrquoZWuwg4dlfrSidgK0Px9oiWelVdQ y81gZRyBge8dLwezlkTrN7PeIve3fAqta7+LW7cjwtcdOpMOYH7d1xYc6 ueRXnyLet7il3KjtQhoELFxw2f0ywKNGxEVtOXIPeHMf9lnfZ8jYnVRqx F0Iy6/OcVT7Kj3XTxzA2hfxB6CBoJ6ccl+3R1WvBGLqAyUC0JkvNVLTHp 2IhxXix68H5QzOdo1xm6GibCAmIo8q2z/Hgy5usYDo3vnZn2q0CXG1Dzb vHRw3QJJFCG1D/bY3o2+UNG2agtNeXCiz9EizklwPfr//A6/mvFojnxMQ g==; X-CSE-ConnectionGUID: cLU6MBmfTuS+SzGMjymKzQ== X-CSE-MsgGUID: JLbFsyoCQuucLiuqAm68Ww== X-IronPort-AV: E=McAfee;i="6700,10204,11245"; a="30509352" X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="30509352" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2024 02:38:28 -0800 X-CSE-ConnectionGUID: wwOQ0HbqTzOGnBsdtsOHzA== X-CSE-MsgGUID: G+fvy3I/TXCrnwD2HmbWEg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,256,1725346800"; d="scan'208";a="84433002" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa008.jf.intel.com with ESMTP; 04 Nov 2024 02:38:25 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id AA35D26A; Mon, 04 Nov 2024 12:38:23 +0200 (EET) 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: [PATCHv6, RESEND 2/4] x86/tdx: Rename tdx_parse_tdinfo() to tdx_setup() Date: Mon, 4 Nov 2024 12:38:01 +0200 Message-ID: <20241104103803.195705-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104103803.195705-1-kirill.shutemov@linux.intel.com> References: <20241104103803.195705-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: quoted-printable Content-Type: text/plain; charset="utf-8" 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 c74bb9e7d7a3..28b321a95a5e 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -194,7 +194,7 @@ static void __noreturn tdx_panic(const char *msg) __tdx_hypercall(&args); } =20 -static void tdx_parse_tdinfo(u64 *cc_mask) +static void tdx_setup(u64 *cc_mask) { struct tdx_module_args args =3D {}; unsigned int gpa_width; @@ -219,6 +219,9 @@ static void tdx_parse_tdinfo(u64 *cc_mask) gpa_width =3D args.rcx & GENMASK(5, 0); *cc_mask =3D BIT_ULL(gpa_width - 1); =20 + /* 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 @@ -969,11 +972,11 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE); =20 cc_vendor =3D CC_VENDOR_INTEL; - tdx_parse_tdinfo(&cc_mask); - cc_set_mask(cc_mask); =20 - /* 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); =20 /* * All bits above GPA width are reserved and kernel treats shared bit --=20 2.45.2