Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2923379lqp; Mon, 25 Mar 2024 13:12:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWmiBDEXZzoMgmSzCHi1K/02qfBVWkMuFuws33NC8DQwHaBJsuyl9T1wNGPa25N2adhU9TnasMs7YU8p1MtkyJBt/zdWQNcFKbk+ivwfg== X-Google-Smtp-Source: AGHT+IHZVdzHsuBxYvwcFNo+VkArEIcz7v6z9ht/HaUxkmsc28+zEyPEncqvp7mchdw3lR5ZnR9I X-Received: by 2002:a17:90a:a083:b0:2a0:3050:17ba with SMTP id r3-20020a17090aa08300b002a0305017bamr6329035pjp.38.1711397565437; Mon, 25 Mar 2024 13:12:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711397565; cv=pass; d=google.com; s=arc-20160816; b=VnV8CRlqWiqrZPz9aAZp8haMaaM8KQZtJu8MvIWcI1/L/akLko5bc/Q4zgzYFOReVU zPmItiW3YWQXsJQn1e0PFyyqzE7jbUcqQ10p1QuM9KMQ4H9p2VHeevuxaey96HeMVckW JSytvRnzezgiXmjNzbhHR02Z22PWxz8AQl7zJPWu+jdBB3625tN+9SUydNdCL1+3jp9w 72to6s8iTRCadCVgMe+i9E0VOCISXvWdBwOLdGJM+PW2VkWyFIBh2f9rM+Ukywn0K6jW 5LpkNnV/1IchVIWi2hrFATH258K6POczq/nwRSia0XSkXqD5fGuChuqYo3l4HKV8B02x Gxvw== 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=4P2iTb2B5nJahbm4Pstp5pQSrM+PzwYxc9uJo0WxfzQ=; fh=vSzhW+9BQ94T5YyXYzqBt8+itL0niQiJkycT8MquqfE=; b=nNQUOP5tRLwiPJST9NrdAfeZloUnv30BqUbXFzbBc7QjkSyJFfR+F0yqtBT9pl5xgW o6JK8bnAB+S2S5bw2PZKyuBFnDW3I2epZAaIt9UEb6rsUC2q++Zdtsul2UpY9d3auS/k vciPSq/38b8lQbrSZqiPXnE/gOWeTc6GOP3ne7yPB57v5ormU8XCzGYQ+D5czxCrdQU5 qwDC2HooXrejRRkC3QGYD/ScM8pnXQ8pXX3pctzoPVKVe9hXEtDsnUlhxjYBX5IdZlKf 4Oi/l4JQBVMAgSBgE85zygrwCA1UoJPgAfrMWj0RC1firmU0T9W0zl8zLh/dt6RHkVWe SsRw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NjNqLfHb; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116878-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. [147.75.48.161]) by mx.google.com with ESMTPS id 91-20020a17090a09e400b002a03864ce2bsi7726652pjo.171.2024.03.25.13.12.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 13:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NjNqLfHb; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-116878-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116878-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 E1209C04E81 for ; Mon, 25 Mar 2024 14:39:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D370617D239; Mon, 25 Mar 2024 11:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="NjNqLfHb" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (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 582DB129E8A for ; Mon, 25 Mar 2024 10:46:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711363586; cv=none; b=e2QEOPMcGLbDXu5r56hsHi/DYVhF3B/7HQpq8LdzwZMl2UF0EiGDHe6Wg0zszkm62TSlRPPMyiHGUpOUMa1TgSILYxvSWDEemU4o7+kYfd1DvgZV8XCuTLagd2BV1nbV0edPeUUdQTX4p72TJo9/2PX8bOSTXYtl9lF9oBQMZPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711363586; c=relaxed/simple; bh=1hJMdWMyKbRxuulTM+24tZ/hnpaqrnzbQWbwnHMvu3M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F/OdSot+4XkSGYdwOZ7HbbSE+Gb9hihBEwmWHagDhDugO41X2/1WNkB7aMfQql1z/cIxVo8JSok8WQXkQekgzG4M8uaZlxi3by2nos5c7Oyf4UWoVgcGaQrGXWOLA8nX9ZSUz7TBnl6Vwkr/l3oWeycH+4BKhq1TObcfmY8Wd60= 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=NjNqLfHb; arc=none smtp.client-ip=192.198.163.14 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=1711363585; x=1742899585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1hJMdWMyKbRxuulTM+24tZ/hnpaqrnzbQWbwnHMvu3M=; b=NjNqLfHbGuzVvLHEPgW4NPKg9k9ZnCayqSs0BxD4WlBxJZWrJ4cD6K+h CftUsSS6KeYUOHcJiGQYNOiy+jC22vRHMwdWn9McqLqAg3bsX9B422/Cc /BYx3+wNqMIlFirwIlWc8biZYyZVrdMlMklNyo6M5JvNyf87KBD0xP41Y lI+8b1yDCS9n5vL8nl5B2IgG8lvK/0b0e34aDIimtZk9KINdN1epwDoIf 5Wrhk1vxhZqOSihBZxGRUWa5kTdV8D5bP1QWsZQyxgBljlvPt/fULUEU7 jCDJAnGGe8AurOW3CKTlHq6zvuM+VwgX/wOGogtixuf4Z/PkOxXa8g57Z w==; X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="6561993" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="6561993" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 03:46:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11023"; a="937070187" X-IronPort-AV: E=Sophos;i="6.07,152,1708416000"; d="scan'208";a="937070187" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 25 Mar 2024 03:46:11 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id DD91E3C5; Mon, 25 Mar 2024 12:46:10 +0200 (EET) From: "Kirill A. Shutemov" To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com Cc: sathyanarayanan.kuppuswamy@linux.intel.com, hpa@zytor.com, seanjc@google.com, elena.reshetova@intel.com, rick.p.edgecombe@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv2 2/4] x86/tdx: Rename tdx_parse_tdinfo() to tdx_setup() Date: Mon, 25 Mar 2024 12:46:05 +0200 Message-ID: <20240325104607.2653307-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240325104607.2653307-1-kirill.shutemov@linux.intel.com> References: <20240325104607.2653307-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 --- 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 4fb36e5c4e80..08e2bb462ce8 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -181,7 +181,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; @@ -206,6 +206,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 @@ -930,11 +933,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