Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp898631lqo; Fri, 17 May 2024 05:15:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXq1KNfumuwRinWp/BhdcfTLGavr/u5J8GPVzB/tpN3lfY3PI369sZFcFsOM5UUHMPlPE5TwTdbPS5OzYREaxDWrcgQ1F6QljIX0ho4Tw== X-Google-Smtp-Source: AGHT+IG7SM8COHquluSqpYINmjCLYBWhy/e2CX8Q6WSRT8PbpOW1aOuIMI3vNNuMNPwdG5g8n06G X-Received: by 2002:a17:902:7c03:b0:1e6:6bba:7c70 with SMTP id d9443c01a7336-1ef43e233b3mr177720515ad.36.1715948103816; Fri, 17 May 2024 05:15:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715948103; cv=pass; d=google.com; s=arc-20160816; b=KOee7PvBWsCASRZjgOAMe4D850X2haVjX2s7Aaz9uX/0n173c2AosJQQQDtzxspFC7 ubuCegLSuuY9FRgA7+pwiqmnRn3pjH6QW3PH6m8AIEuyMS9iJVPTFnQRaVAdASZXLQM6 oBndS00iCl489Kw6nzib4daqOqdEjAAwlERMAXKfF2zm669mP058YxNDs277GajG8D2D J/HIibwZ7sKVv8Qm1NOKJQNHaIN0wmR/1OaoUNlg8mkbmim5WAuf8zgYe39PoKJFRPZ6 cpMXCAKXL/ro8aJ40UuAW9rYe4DpzuH//eeG2SmqZrlqpjuMW/NxyBO5VX+23/qDaEAr T8YQ== 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:message-id:date:subject:cc:to :from:dkim-signature:dkim-signature; bh=q0dBrwJEirdAJjc8aRzs+naGaaVcmwY3c6T6HYjMgu0=; fh=6/5LxNs3SliHtjvJ6M+86AYc1lih08qRipo5gYHRgDw=; b=LyZEsah/ZnaP4NiKCTCD590bPBYcs3685ytAa1WCYzjDeoP4vLUROTRWGzuqZpAw4Q hnfOOx3tlv7VXpy4fa1coR/mrKwqEU3lejoqB6fi3oMnxGQunskf3alnUSeQFHGp2CVH XXW+LiSzT5xIt0iRxE7OgATbFFZwcnRadMKA2d8U9+VE3gCq+78DyDxxEojLd2A/BATX 4+OOo21JfYVR+5P4XwwjfQ1C9QD+zrqlALwT6Hcm44utllIe1pqzIB0Sk50cB2dmn69/ 4pOj4hxW2DvFaLqfxdfXHjrCGM+ARA344qmNkmdk5HSNc6EaX5aOAT/D0gh8Y133iceY +mdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=hwQF7ZuF; dkim=pass header.i=@suse.com header.s=susede1 header.b=hwQF7ZuF; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-182091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c3691a2si182155835ad.617.2024.05.17.05.15.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 05:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=hwQF7ZuF; dkim=pass header.i=@suse.com header.s=susede1 header.b=hwQF7ZuF; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-182091-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.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 1DAE128445A for ; Fri, 17 May 2024 12:15:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0952841766; Fri, 17 May 2024 12:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="hwQF7ZuF"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="hwQF7ZuF" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71B474086F for ; Fri, 17 May 2024 12:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715948097; cv=none; b=gObZUklTjX6pm3KpEgqEQtUNoU1bBOoJXGS/uwnYrzHk7IZf3lJEuzluHbhecGp5qKXY2QBr99lD3Ob1rM3qhu2lo62nGCLB3u6IvKEOXJoJpC5DRCD87/iT1yvCES28VkkYvxsNI/NbxriDU178wPBkQocpkzHXlWYVUtbb3rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715948097; c=relaxed/simple; bh=FGJJaMByGBbYZYOyJrUGoh3jS9M7Ga+B3tR9vP10Ic8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZafLrhZziNhNApbHKBdOGrWL16yhTQ5evRFQJ2myILeKtpRbTS2qb0ggCTVRCqj/0dNFIddU0CGO5pk3p3qzgeQHCD2AE9BWEqmBwctPDHpZdscHCI7JjtcliCr3a+K5qIpyAbe8A3ABtKyGGAWpKctgbKiPB/71lIR/WcMxaJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=hwQF7ZuF; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=hwQF7ZuF; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 8107337444; Fri, 17 May 2024 12:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715948093; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=q0dBrwJEirdAJjc8aRzs+naGaaVcmwY3c6T6HYjMgu0=; b=hwQF7ZuFZ+zgQIPwcaCfQbrnJWo+YWOK8weKZptkAATgWPyYqFrSnfVvEHmGBNML2A7vIi aAKZY0w+lmbYeZpSUTRkJ/QZW1TtxbfZ0O+h7bG/ZNxTcsR7tN0cbaQit1csD0SAFJyF4o afi/Dqbrk8lGkxLrDN9DnHqiiUIZekM= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1715948093; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=q0dBrwJEirdAJjc8aRzs+naGaaVcmwY3c6T6HYjMgu0=; b=hwQF7ZuFZ+zgQIPwcaCfQbrnJWo+YWOK8weKZptkAATgWPyYqFrSnfVvEHmGBNML2A7vIi aAKZY0w+lmbYeZpSUTRkJ/QZW1TtxbfZ0O+h7bG/ZNxTcsR7tN0cbaQit1csD0SAFJyF4o afi/Dqbrk8lGkxLrDN9DnHqiiUIZekM= Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3163013942; Fri, 17 May 2024 12:14:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id CRWGCj1KR2Z7NQAAD6G6ig (envelope-from ); Fri, 17 May 2024 12:14:53 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-coco@lists.linux.dev Cc: Juergen Gross , "Kirill A. Shutemov" , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Subject: [PATCH] x86/kvm/tdx: Save %rbp in TDX_MODULE_CALL Date: Fri, 17 May 2024 14:14:50 +0200 Message-Id: <20240517121450.20420-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spamd-Result: default: False [0.07 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; BAYES_HAM(-0.13)[67.40%]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: 0.07 X-Spam-Flag: NO While testing TDX host support patches, a crash of the host has been observed a few instructions after doing a seamcall. Reason was a clobbered %rbp (set to 0), which occurred in spite of the TDX module offering the feature NOT to modify %rbp across TDX module calls. In order not having to build the host kernel with CONFIG_FRAME_POINTER, save %rbp across a seamcall/tdcall. Signed-off-by: Juergen Gross --- arch/x86/virt/vmx/tdx/tdxcall.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S index 016a2a1ec1d6..68728acf0d3a 100644 --- a/arch/x86/virt/vmx/tdx/tdxcall.S +++ b/arch/x86/virt/vmx/tdx/tdxcall.S @@ -44,6 +44,10 @@ */ .macro TDX_MODULE_CALL host:req ret=0 saved=0 FRAME_BEGIN +#ifndef CONFIG_FRAME_POINTER + /* Buggy firmware sometimes clobbers %rbp, so save it. */ + pushq %rbp +#endif /* Move Leaf ID to RAX */ mov %rdi, %rax @@ -187,6 +191,9 @@ popq %rbx .endif /* \saved */ +#ifndef CONFIG_FRAME_POINTER + popq %rbp +#endif FRAME_END RET -- 2.35.3