Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1346564lqh; Mon, 6 May 2024 05:16:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVCUTsB5omf3p2rcsQfOuz9bLcThbZ2S22N5ly4mfWTXFSfTDVie6EhPh32mqBBVrMzka4xNq1yUp3rO9AxIOxUDwAX14ELJG9QbALdPg== X-Google-Smtp-Source: AGHT+IFFmKkxW7aIg1QXVC1BRt6e/4xo8MdGHG8S86X4KMYkvaaYKZb0C5d+xf+kk18qEYtQW21m X-Received: by 2002:a05:6808:1388:b0:3c9:69b3:8f6a with SMTP id c8-20020a056808138800b003c969b38f6amr4987575oiw.19.1714997791310; Mon, 06 May 2024 05:16:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714997791; cv=pass; d=google.com; s=arc-20160816; b=XHfQl2AAKYujzSxltt02lkb/0wG261FBvIEFNPMCorKIIdr+3RiLcX5/BY0fJt+V9T ZpJ3dtFHbJAP3iSv6smSYOfDBJCXfXUUjiKy6fITXMpmSexBU9h6b9LbWGSGyYiyiFNy JPB6scuCSdTlbtJJMGUeNXMfTzCS3jjwqPEGTu9FIJ51IPsFWwdbLJiSodLBOW4spa1e BYr2xXL3CuC1yYOiUOEYicPDdOTy+Lwp4b3NZTESHW398GHWVE6J1thIVPRYdhuJGB+f FwPVqtsQMaQxQ5nwptulBrIHg88hFqx3d6dRyxByntYbjnNJm960ck+Gsgm8gvcgSDoZ ke3g== 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=162ZGNxM96lgXcC43pLKPuVC3HGfqcayp6XII7C4hzU=; fh=W6SWkVnPIo4oGlmnjQZT1L/aGexx/yPCgAPWK2YNujU=; b=gqeG4RBKtYj7hnIJJ7ejI9RzJIUfnLOhUsheacJ5kFPFbHfxWqp3gXRImJg2CfsKIj GfP0+CPrdiywkFKpjYbWlNbCwy+ZL1UFfUq+tMpDh8t6Uh9M325Z4or/vKI0QBq1iriL w1lSyGO49gRMrQk5pTNLnc7rqD9tqElU8sn9mkmbpUNmsRkQwHfKfxSYzEHkboEEABoO bsbVacc6jcCQxdaq4HfQMt+mO+rFbcMRfSHRG6P4OJeRPGcfKH6KxDxgWMF/i23cCG7S taPsGui1xpf23+1T9qsZNAeY1cEvOwtWNpOxoh8EZSb3TVFYZ8dXO0opHyi7Djzj+cHp /+jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CRYep0uf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-169784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169784-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. [147.75.199.223]) by mx.google.com with ESMTPS id h17-20020ac85851000000b0043aea66e5dbsi9351876qth.485.2024.05.06.05.16.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 05:16:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CRYep0uf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-169784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169784-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 0DC501C22808 for ; Mon, 6 May 2024 12:16:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7C7D1442FF; Mon, 6 May 2024 12:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CRYep0uf" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 C377E143C46 for ; Mon, 6 May 2024 12:16:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714997763; cv=none; b=Lv8I+r6H0tKDgN8PiaVwRNu5YW3W9bzknnx/coqY7qWBJllOEYxAxc6m49V3BUVmuYuQ4ZI61b5fWnnaHBLhrufwb8TAI6Vzj6LH1vOSeyPlXS1Eybi5FXVdY6PFX7uYWYfOr9YZnRzuB25/qriEoQY3RDTM8MstXQk/HSFIIpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714997763; c=relaxed/simple; bh=thgtjAPUlcHd9NBfHBwdSKUpdpm4qAYPqeeCKH2/TjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=In7zCHlfkzFUvo4DDN8XIyh+s6uRDIs/XNusLH/Tovp067ZhulSl2MfmYSTJ45bzxPuB0wq8Q1/K8woDHs1eNpHrsOd5ByXG4HUn6vl69Hn8hcWQmix4MJjgjRBhUMzO2WV6dyRx1PJckUPYlgbrBONEeeTsmN432oJlZS1rA2w= 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=CRYep0uf; arc=none smtp.client-ip=192.198.163.16 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=1714997761; x=1746533761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=thgtjAPUlcHd9NBfHBwdSKUpdpm4qAYPqeeCKH2/TjY=; b=CRYep0ufX1NCImI5vmfj/9VtOefhcD2YnFuOmGRNyOLdykv7rwXcgHZN ndsvdKoiHd3wyiGvpRp/2lyh5bwpnev8O3TlS3mBsym9LBePjIj+l2sGx EKb1ckCuxKq9pe/cGRxWDAUIrZXgWHvMYW0c9iBpXujF/nk1ngoZFfWqV XzSsgG10vefryVhwMXHBM6EyhTsst8nbfsqrPgUnWjwz8U3Z7ID0+4Iq9 jg1ebV12p8RyGyHm+PQVCN/e28BX+E1zvAn8cthbN8HVaUTq8OmmMH992 9QScUc5g2iP+vYrUFNCUGlkKBxqY5R2aQzl2cbAR8Nf6t8LsUUrA/AoL+ g==; X-CSE-ConnectionGUID: cfYnQHlNRsyTQRdA08uf2A== X-CSE-MsgGUID: MAJQqZTfSe6KyE8kcNNpog== X-IronPort-AV: E=McAfee;i="6600,9927,11064"; a="11271853" X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="11271853" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2024 05:15:58 -0700 X-CSE-ConnectionGUID: OCeGGIsWT0aQrv1fu/2uwg== X-CSE-MsgGUID: +V2NucTLRbG9e9qKnnRqMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,258,1708416000"; d="scan'208";a="28140603" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa007.fm.intel.com with ESMTP; 06 May 2024 05:15:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id E931F2DC; Mon, 06 May 2024 15:15:54 +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 Subject: [PATCHv3 2/4] x86/tdx: Rename tdx_parse_tdinfo() to tdx_setup() Date: Mon, 6 May 2024 15:15:51 +0300 Message-ID: <20240506121553.3824346-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240506121553.3824346-1-kirill.shutemov@linux.intel.com> References: <20240506121553.3824346-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 --- 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 b926221f1264..964149d3be5e 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 @@ -928,11 +931,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