Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1078599lqo; Fri, 17 May 2024 10:00:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4udz4SlOfHKUPhcfTuG2whd6/XtpG55+QnK09DnKCTJLkyIZVfTrmcBaPSh/u7kmxuajYp2I+HVlObCemiJdfrFWGP+p34zmBsLiHzQ== X-Google-Smtp-Source: AGHT+IH+keBUh+FgounY1iPjqrTDW2iYpq8M+60gRlhjPaklBUG1r825bYwoJpoHERBSY/L9huGO X-Received: by 2002:a17:902:7d95:b0:1ee:b2ff:c93a with SMTP id d9443c01a7336-1ef43f3e4admr211372625ad.40.1715965210872; Fri, 17 May 2024 10:00:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715965210; cv=pass; d=google.com; s=arc-20160816; b=PV6CrWb9slCllQu2qNlT3EU9vzEip4zG2tNjmUqQ64AKQ8RHz3fZNasczlfXNbANyD EYW8ddFQrTy1t9qR0OongpCTRxSZGdH6VDQsAhCSvh6wM8T6WFwNxa44gP7Ci6mHFWE2 PocCfd4m4EM+zVDAES8Jyli3Y1yXT8spmOCMG6PWsCOhFHdBLVYeTBAnqIjI4pyZt0xt uVQZRvTieYs6Xfk2G7BiJzDPsVXbKkUykrq3U1uMnANGLXoS4m2Ir4ORAvuX3HyyTcRj 6hsuqZnUzBANiN4v8z4tGspA8OVCcD35CJyFBWBiWHRL20/DQxJTIznAVKFiZ9xcXgbh bmVg== 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=tlAyTzVUm9HdxTtbSZlVsb9hRZv/6RyOXl5YbU+P9hM=; fh=hXU1gnBYTQtxPAarsVIsRjsd20EbUeSZmvMOiujEIyU=; b=KmDY0WtgQ6l1zGtJlaO8npuKZhzHQgTHasYQ8M/MXuL1azHKnXiVYBP7JnOrh1aDYe ZJofTkeyWLVZtPLvB/ZpXgT02zpTSjwvpGcXNQYGulZYkWS3LHbPTM86qpZznm2YYVNQ vaqk/sTlousc6bebQ+dyUX+RB6HNWM/Z+onDRfaaSz25sO94JlmKx7CUmJL2S5OqkZJn RWtRL3nWuf0S5fxlU+YvA8GA5eEwrPY3mOPJnXdvrhUqtlM//6VOF4GNllL1RwlnpFDz HUvefTQMYE0b4iZUgl9O7F2HD7aZSEEu4HLV0y5Ge4nR8siBlMeBk2WGiDLGRZXIbWya 16Pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b5jGO0Pw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c03b741si190540005ad.434.2024.05.17.10.00.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=b5jGO0Pw; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-182190-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182190-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 71C62285F87 for ; Fri, 17 May 2024 14:21:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 303996EB4D; Fri, 17 May 2024 14:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="b5jGO0Pw" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) (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 84C806A353; Fri, 17 May 2024 14:20:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715955604; cv=none; b=Jw4iFfoetF3gKlnVE2adUlbe5sJkx1KGVNrHCyQpoENLlSCWXhRc8RWWyGHOo6SYw9s7Ey2ENCXtDrtATVYgCDoN3/SLw27Gq1UQ9OEBE0eOBR06hPHIe58/lBMWzuCeMpA92HaF6s5WKCgVzVNtjsIBn0vLTKCnynYXd6BJ3CQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715955604; c=relaxed/simple; bh=mwZWrFqPlAATgrpluzFmNP8LOZ2SkfC+w1PDY7N0GkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fJe13V1JFvkOIBGnPbDnGXl8Lhdub9oYxSBDnfvmJBtpPT30W0QujV97oTb+x6JolY5JsdWlNxok475P57VpMuxUSr0j8BPXRTQxH7oj7dPUQZF9hk/9zbSHrJpoR2ADqs0yWPHXTluVLt7rEUFxW0dbwr6ENgJ6Sm5Jv4JudlA= 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=b5jGO0Pw; arc=none smtp.client-ip=192.198.163.9 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=1715955603; x=1747491603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mwZWrFqPlAATgrpluzFmNP8LOZ2SkfC+w1PDY7N0GkI=; b=b5jGO0Pwvig4hkqyQ8EH7jMxAQwjZWo2Nb9Lr2kp0M6a4G+Zr7hGD2Tl q2dWa5mfSbX6Vl93vNAv3tq5k/BBQ5cunhGVOZryO5JreOffTDKX8reUl 1KRycxXkTvy7MYnfCVl5BbcVWMe/bZpml2KF/gCG1sOv4kkvJ0qxI6MX7 L22BWBvOM/EwP1qIXaTCeTxFnkbNYm98kgQ7Hh68/2NfiaP88xcEH3tYy Qtq+Mk2Vhx2/YH3QGUmu6Lg5k9VbpvwF7Unhr4nBMynoybNQ+aCvWm+MZ euDp8i4dINuWxDITb+9XACNfYwE1WYggKXG8Zi59G+fvaCThWewI0/duU A==; X-CSE-ConnectionGUID: srDpFdgbRD2LdUQDHIQsEw== X-CSE-MsgGUID: C1vK2izGQJeDCi4sTCX51w== X-IronPort-AV: E=McAfee;i="6600,9927,11075"; a="22808661" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="22808661" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 07:20:00 -0700 X-CSE-ConnectionGUID: u/UyLr5SQ0md6MvEb5xcUw== X-CSE-MsgGUID: Lot0qZVdQp6wzxYOJB6H/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="69253383" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa001.jf.intel.com with ESMTP; 17 May 2024 07:19:56 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id EEF7CD0D; Fri, 17 May 2024 17:19:49 +0300 (EEST) From: "Kirill A. Shutemov" To: Sean Christopherson , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Josh Poimboeuf , Peter Zijlstra Cc: linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 07/20] x86/tdx: Convert CPUID handling to use new TDVMCALL_4() Date: Fri, 17 May 2024 17:19:25 +0300 Message-ID: <20240517141938.4177174-8-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240517141938.4177174-1-kirill.shutemov@linux.intel.com> References: <20240517141938.4177174-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 Use newly introduced TDVMCALL_4() instead of __tdx_hypercall() to handle CPUID instruction emulation. It cuts code bloat substantially: Function old new delta tdx_handle_virt_exception 1819 1747 -72 Signed-off-by: Kirill A. Shutemov --- arch/x86/coco/tdx/tdx.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index f59a2b3500db..c436cab355e0 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -414,13 +414,6 @@ static int write_msr(struct pt_regs *regs, struct ve_info *ve) static int handle_cpuid(struct pt_regs *regs, struct ve_info *ve) { - struct tdx_module_args args = { - .r10 = TDX_HYPERCALL_STANDARD, - .r11 = hcall_func(EXIT_REASON_CPUID), - .r12 = regs->ax, - .r13 = regs->cx, - }; - /* * Only allow VMM to control range reserved for hypervisor * communication. @@ -438,19 +431,10 @@ static int handle_cpuid(struct pt_regs *regs, struct ve_info *ve) * ABI can be found in TDX Guest-Host-Communication Interface * (GHCI), section titled "VP.VMCALL". */ - if (__tdx_hypercall(&args)) + if (TDVMCALL_4(EXIT_REASON_CPUID, regs->ax, regs->cx, 0, 0, + regs->ax, regs->bx, regs->cx, regs->dx)) return -EIO; - /* - * As per TDX GHCI CPUID ABI, r12-r15 registers contain contents of - * EAX, EBX, ECX, EDX registers after the CPUID instruction execution. - * So copy the register contents back to pt_regs. - */ - regs->ax = args.r12; - regs->bx = args.r13; - regs->cx = args.r14; - regs->dx = args.r15; - return ve_instr_len(ve); } -- 2.43.0