From patchwork Fri Dec 8 17:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 175974 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5599547vqy; Fri, 8 Dec 2023 09:19:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8XEtVmsQjKX+rFU0LnoT13QpkX0o3YZcHMiOvHZxep/MNHrgD1Gr24FyTeGVgMveulr87 X-Received: by 2002:a05:6a20:e116:b0:190:a4d:b5cf with SMTP id kr22-20020a056a20e11600b001900a4db5cfmr400172pzb.48.1702055982877; Fri, 08 Dec 2023 09:19:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702055982; cv=none; d=google.com; s=arc-20160816; b=qKA/tEqXM2Wem5+zrv+brtYbymHh94C+x+Zi/dksaM1V4PozEJULy6qi1W7MasQCi5 C/oxeMr9x8NEwUiYF5aJdzu40y6JeaW+vmFySTUILbhi4yeXd1x7ibMdZ/oPRS6zMSa+ 2mK9g5tzxIdmpnOgs+HMkcrnUwzZurmDt9EyZtzbxt+0wo6hWWXXtghAsGyOzT2oye1z 7Tfl63k9BO0cR3pW8a2VmmD8g9PrvEKw+Fbn2f+wJ0McYBmUNGwXMt3lbZYxRq1PQAeN Vcv5Vp1j/1MvgHHOkhFGh/y7v+RWpyH2MLEpyyUV18qmwIUofOug20btYlJfy0O2CLH9 aSfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=9CV/95Dz+kJafe/zMAcyTIZFYP04cBNpwb7zoOnZypY=; fh=dHW0UmhHvAzPq6sNd0MMoRsSMue+Ti5UidMY9KhePnQ=; b=mrpeuz1gkgXqZG7eJVnvGszSeG3yn6nTpzEpRjL6tVkvg1NZ2P8qMkAF+ac5fwTISo 4qLiiSdgwWQWFEtMRzdabsXf+z1D+H2PlzbnfxAisSHja58Li2meCnG+H/vqRzLphUcj ZAUVuN8jxsJ/4S8klivSbgjkSkkfiRd00aA0KW7BtNCD5KgQi6U79ijb8JCeEphq3JCJ Vq+3NZs4wZcgogdMM6SrAqktFl2IgsQCpbx7L8AESG8wNR1O2ubeILb+JgTu3vz8F9j8 VMtiw3bk4AwSvg43tia6QiJNmj9NAAF1A/DGYXTik7WBh8+/mIjZIPB0e59EBzjNM++E d8xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=amNqOk+N; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v15-20020a63150f000000b005b91536981csi1874393pgl.11.2023.12.08.09.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 09:19:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=amNqOk+N; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9A11181DDD01; Fri, 8 Dec 2023 09:19:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574554AbjLHRS1 (ORCPT + 99 others); Fri, 8 Dec 2023 12:18:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235991AbjLHRSC (ORCPT ); Fri, 8 Dec 2023 12:18:02 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281151BC3; Fri, 8 Dec 2023 09:17:32 -0800 (PST) Date: Fri, 08 Dec 2023 17:17:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702055850; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9CV/95Dz+kJafe/zMAcyTIZFYP04cBNpwb7zoOnZypY=; b=amNqOk+N/CVEc1VWPv0K4geuI7Hs0iPvVjq9NgHLKPCwmjX9lfSA38qtV0PwdSkx+zNsdN mySL4qfiBimt6QSoR3QFgqGuL1C3btMjFQu18OIsGu4zCxd7AnsJ+/r0fopoMbfXptP6Rj OzN7cnE2pypkYDjCESqg8Q4vS7cgyIXpSDHYjAipLJpojxzMo4fQl5HTPu3TEqwmtfr/Zb 24L35y7Ijg9n5LsjDsGgfAEbL2Rue2xNbFGyUynCFEpIbFo2DDtKMCYSNMnUwKmjIS80dI e3gWMg0mLIQy4qo59fzn94lPG1ka9E/HM3+FmWm0FPrthBrwHjUGEmYCiSZOtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702055850; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9CV/95Dz+kJafe/zMAcyTIZFYP04cBNpwb7zoOnZypY=; b=ILJVGNab4OGD7YaDCtR81z+ldbhh9vRsXMIERPD3xtFLB1UIqTXSMo0jXUWVT1yuWvUOfv JQd62In6tK9LSbCw== From: "tip-bot2 for Kai Huang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/tdx] x86/virt/tdx: Define TDX supported page sizes as macros Cc: Kai Huang , Dave Hansen , "Kirill A. Shutemov" , David Hildenbrand , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <170205584992.398.5198513170089475670.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 08 Dec 2023 09:19:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784735054513956339 X-GMAIL-MSGID: 1784735054513956339 The following commit has been merged into the x86/tdx branch of tip: Commit-ID: d623704bb23901a25bf6d6a40aa16b43a17622eb Gitweb: https://git.kernel.org/tip/d623704bb23901a25bf6d6a40aa16b43a17622eb Author: Kai Huang AuthorDate: Fri, 08 Dec 2023 09:07:22 -08:00 Committer: Dave Hansen CommitterDate: Fri, 08 Dec 2023 09:12:00 -08:00 x86/virt/tdx: Define TDX supported page sizes as macros 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 Signed-off-by: Dave Hansen Reviewed-by: Kirill A. Shutemov Reviewed-by: Dave Hansen Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/all/20231208170740.53979-2-dave.hansen%40intel.com --- arch/x86/coco/tdx/tdx-shared.c | 6 +++--- arch/x86/include/asm/shared/tdx.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/coco/tdx/tdx-shared.c b/arch/x86/coco/tdx/tdx-shared.c index 78e4132..1655aa5 100644 --- a/arch/x86/coco/tdx/tdx-shared.c +++ b/arch/x86/coco/tdx/tdx-shared.c @@ -22,13 +22,13 @@ static unsigned long 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 0; diff --git a/arch/x86/include/asm/shared/tdx.h b/arch/x86/include/asm/shared/tdx.h index ccce7eb..a403614 100644 --- a/arch/x86/include/asm/shared/tdx.h +++ b/arch/x86/include/asm/shared/tdx.h @@ -55,6 +55,11 @@ (TDX_RDX | TDX_RBX | TDX_RSI | TDX_RDI | TDX_R8 | TDX_R9 | \ TDX_R10 | TDX_R11 | TDX_R12 | TDX_R13 | TDX_R14 | TDX_R15) +/* TDX supported page sizes from the TDX module ABI. */ +#define TDX_PS_4K 0 +#define TDX_PS_2M 1 +#define TDX_PS_1G 2 + #ifndef __ASSEMBLY__ #include