From patchwork Wed Feb 5 09:10:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 13960684 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D2E0C02197 for ; Wed, 5 Feb 2025 09:11:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.881977.1292139 (Exim 4.92) (envelope-from ) id 1tfbR5-0007LE-66; Wed, 05 Feb 2025 09:11:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 881977.1292139; Wed, 05 Feb 2025 09:11:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tfbR5-0007L7-25; Wed, 05 Feb 2025 09:11:07 +0000 Received: by outflank-mailman (input) for mailman id 881977; Wed, 05 Feb 2025 09:11:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tfbR4-0007L1-Jl for xen-devel@lists.xenproject.org; Wed, 05 Feb 2025 09:11:06 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2a07:de40:b251:101:10:150:64:2]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1f2ab3bf-e3a1-11ef-99a4-01e77a169b0f; Wed, 05 Feb 2025 10:11:02 +0100 (CET) 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-out2.suse.de (Postfix) with ESMTPS id 03B2E1F455; Wed, 5 Feb 2025 09:11:02 +0000 (UTC) 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 A659F139D8; Wed, 5 Feb 2025 09:11:01 +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 D+IfJyUro2d0KQAAD6G6ig (envelope-from ); Wed, 05 Feb 2025 09:11:01 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1f2ab3bf-e3a1-11ef-99a4-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1738746662; 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=1qMmRxVIPypI1xC815rIwVGXXjNCPAkK8hThn5/x/rA=; b=LOERfISb+g25ZuGhv73mD20GA7oXGW6Pb6C6xSeDCVvwkKVIQ4aNPmcL1c50pzqmvEi65y Bt+BtBeetKB9dNEYTvHbdiMROa69F0k4e3GowabU0jMsGFNev/CWFZYRyJEkVG4NHV0YRU 2zCuPsgBj/orpvmGacjPYAAPANMsfLs= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1738746662; 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=1qMmRxVIPypI1xC815rIwVGXXjNCPAkK8hThn5/x/rA=; b=LOERfISb+g25ZuGhv73mD20GA7oXGW6Pb6C6xSeDCVvwkKVIQ4aNPmcL1c50pzqmvEi65y Bt+BtBeetKB9dNEYTvHbdiMROa69F0k4e3GowabU0jMsGFNev/CWFZYRyJEkVG4NHV0YRU 2zCuPsgBj/orpvmGacjPYAAPANMsfLs= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH] x86/xen: fix xen_hypercall_hvm() to not clobber %rbx Date: Wed, 5 Feb 2025 10:10:56 +0100 Message-ID: <20250205091056.17796-1-jgross@suse.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_SEVEN(0.00)[10]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] xen_hypercall_hvm(), which is used when running as a Xen PVH guest at most only once during early boot, is clobbering %rbx. Depending on whether the caller relies on %rbx to be preserved across the call or not, this clobbering might result in an early crash of the system. This can be avoided by not modifying %rbx in xen_hypercall_hvm(). Fixes: b4845bb63838 ("x86/xen: add central hypercall functions") Signed-off-by: Juergen Gross --- arch/x86/xen/xen-head.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S index 9252652afe59..4378b817ed32 100644 --- a/arch/x86/xen/xen-head.S +++ b/arch/x86/xen/xen-head.S @@ -117,8 +117,7 @@ SYM_FUNC_START(xen_hypercall_hvm) pop %ebx pop %eax #else - lea xen_hypercall_amd(%rip), %rbx - cmp %rax, %rbx + cmp xen_hypercall_amd(%rip), %rax #ifdef CONFIG_FRAME_POINTER pop %rax /* Dummy pop. */ #endif