Message ID | 05adfd0b3f59b1f3eb10a1a1d045b01b9bba4379.1687784645.git.kai.huang@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7523763vqr; Mon, 26 Jun 2023 07:28:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JYxeZLP2aTixzxAZuw0TEFAORcmXjdkRsaTgg73Krp7+KxC+LKIxPHE5cRJTqvzlktskL X-Received: by 2002:a05:6a20:a122:b0:11c:fd2d:ea75 with SMTP id q34-20020a056a20a12200b0011cfd2dea75mr26631969pzk.14.1687789693612; Mon, 26 Jun 2023 07:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687789693; cv=none; d=google.com; s=arc-20160816; b=ULCKf4HGKy1EUULjSm5v/MtRsvQoSIaTYFAUC6yYa9PkzGbCisj9RIKyCp27X1Vm2y 5qdu+WS0WHylnu2QoTOORD/7FckMkRFTxV5CsR3OXE5zaBwX9uCCf+2dUBQZ7vPBKFIi Sv2qDEJUjq38NRSBUsSUf4oTmbnOsDuRRhgr1zHpqu6tvUuMs6QB0nBuWZ5o3M2FYDtd gyxEHHIH71G7XAeq6nLWq7x/ZomOYr6n3Z8zra1/fIOxDceOyfQ8/qn26nZLkOkIfU0y ApFterAUN5gL7sF18zrZKbCLNBM7rFCryl5U+nsY+MQW4v7NqxXMIUW+IfFY8cMu6qP6 V/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p4DTLo54iegSkS9sYaMOi473XFN2/OAaN6fXny9U4ho=; fh=6HfxY0KVNaGJjlkZjh3Hzm5TphdbqQTBO+53/7gNlSk=; b=hcmANjEs/vcisYzNupPoq0nFuj/GnHXdsxc2HpJ/DFjmHrvPrsbYcUc6HSNJGZNu01 JzvWkeEvxAdTQIueZxuzz8rxPntfVG35TpJE4ovI6M7yfua4YEP0MxnljPwGScP3tjM0 xPc14DmOPZjFshMzn/ZqE5czYbqNnPi8Lma2i4zvvQnEbxh5LZ/C1yOQ6haiagSdnmL4 vGOV7+hUwojMg8FmjvG/3Q9ntOvcxboviyygz6j9PbCT4iBD6+ZqLFK3yivnnfYGMFog LK56ggAAUYIhGLbXJOf3jeF1Q6VjoM5pej8gynmWJxI23otggaISmKzf6Sf2ZyZL6/eo Plkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hYhJ+CgC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d7-20020a656207000000b00524ecfa05d8si5562970pgv.15.2023.06.26.07.28.00; Mon, 26 Jun 2023 07:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hYhJ+CgC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231214AbjFZOOB (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 10:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231165AbjFZONx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 10:13:53 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 168EF10C8; Mon, 26 Jun 2023 07:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687788825; x=1719324825; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IazzBZEPaJdhzuSVqXgULVuwNqeSBeuaUYlXXc8k87w=; b=hYhJ+CgCC0mxotu6UMu5yIczG/1YdvqozjIM9/yvx/mKG5QKTjdxVK3B wyaqz7yD9WUSWPPcmfBBr5Bj6Hn/lPtIGxwIwt72EdltBnBjfbYeHX0Uc S1d3I6z74lnnXx89qnAAyQm40zWYuZweGnRRe4v89orqLDyUIw0SbNIQ2 oitQ3aeqj1OIl2wE2nRj9N31gdReeoKgkjpcS1yQBC7wplwho6iaHB7Fw +tTrlfAclv6hITnAZqlHInDiY67lDEDRzeQBF27/mcwN4oz748iFUQdcB 8BerEMFnXGIuiG2gifga/g9soe9fhr4TV3p3hP1VWdplMsYG5bFup/zLa A==; X-IronPort-AV: E=McAfee;i="6600,9927,10753"; a="346033488" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="346033488" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 07:13:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10753"; a="890292212" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="890292212" Received: from smithau-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.213.179.223]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 07:13:31 -0700 From: Kai Huang <kai.huang@intel.com> To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, x86@kernel.org, dave.hansen@intel.com, kirill.shutemov@linux.intel.com, tony.luck@intel.com, peterz@infradead.org, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, hpa@zytor.com, seanjc@google.com, pbonzini@redhat.com, david@redhat.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, ashok.raj@intel.com, reinette.chatre@intel.com, len.brown@intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, ying.huang@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, nik.borisov@suse.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com, kai.huang@intel.com Subject: [PATCH v12 01/22] x86/tdx: Define TDX supported page sizes as macros Date: Tue, 27 Jun 2023 02:12:31 +1200 Message-Id: <05adfd0b3f59b1f3eb10a1a1d045b01b9bba4379.1687784645.git.kai.huang@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <cover.1687784645.git.kai.huang@intel.com> References: <cover.1687784645.git.kai.huang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769775765619605889?= X-GMAIL-MSGID: =?utf-8?q?1769775765619605889?= |
Series |
TDX host kernel support
|
|
Commit Message
Kai Huang
June 26, 2023, 2:12 p.m. UTC
TDX supports 4K, 2M and 1G page sizes. The corresponding values are defined by the TDX module spec and used as TDX module ABI. Currently, they are used in try_accept_one() when the TDX guest tries to accept a page. However currently try_accept_one() uses hard-coded magic values. Define TDX supported page sizes as macros and get rid of the hard-coded values in try_accept_one(). TDX host support will need to use them too. Signed-off-by: Kai Huang <kai.huang@intel.com> Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: David Hildenbrand <david@redhat.com> --- v11 -> v12: - No change. v10 -> v11: - Added David's Reviewed-by. v9 -> v10: - No change. v8 -> v9: - Added Dave's Reviewed-by v7 -> v8: - Improved the comment of TDX supported page sizes macros (Dave) v6 -> v7: - Removed the helper to convert kernel page level to TDX page level. - Changed to use macro to define TDX supported page sizes. --- arch/x86/coco/tdx/tdx.c | 6 +++--- arch/x86/include/asm/tdx.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 5b8056f6c83f..b34851297ae5 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -755,13 +755,13 @@ static bool try_accept_one(phys_addr_t *start, unsigned long len, */ switch (pg_level) { case PG_LEVEL_4K: - page_size = 0; + page_size = TDX_PS_4K; break; case PG_LEVEL_2M: - page_size = 1; + page_size = TDX_PS_2M; break; case PG_LEVEL_1G: - page_size = 2; + page_size = TDX_PS_1G; break; default: return false; diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h index 28d889c9aa16..25fd6070dc0b 100644 --- a/arch/x86/include/asm/tdx.h +++ b/arch/x86/include/asm/tdx.h @@ -20,6 +20,11 @@ #ifndef __ASSEMBLY__ +/* TDX supported page sizes from the TDX module ABI. */ +#define TDX_PS_4K 0 +#define TDX_PS_2M 1 +#define TDX_PS_1G 2 + /* * Used to gather the output registers values of the TDCALL and SEAMCALL * instructions when requesting services from the TDX module.