From nobody Wed Apr 15 21:27:21 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E806C4332F for ; Mon, 21 Nov 2022 16:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbiKUQYj (ORCPT ); Mon, 21 Nov 2022 11:24:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbiKUQYi (ORCPT ); Mon, 21 Nov 2022 11:24:38 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99ED6C8462 for ; Mon, 21 Nov 2022 08:24:36 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3D348220D0; Mon, 21 Nov 2022 16:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1669047875; 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=vM7lsk8RXRK5rWKi3euFrZN65JTSYYzeLkaycP3+980=; b=lQb73XmuRm9cAtopvVxw3SQmWht21QY4S171ZrLyfYCA9szFaF5WMaLQoFaaJ7cHRQwR3n nsupt0qTscoP313sDisopDmfcapC9h30V/Qz5P7dBh9GK3Kz6Px3C35142ZP3aWnXcYh2X VVD2FPS4NvnIK8XoAlO0pYandrnMQXg= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EB2E51377F; Mon, 21 Nov 2022 16:24:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5E3SN0Kme2NIYAAAMHmgww (envelope-from ); Mon, 21 Nov 2022 16:24:34 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH] x86/boot: skip realmode init code when running as Xen PV guest Date: Mon, 21 Nov 2022 17:24:33 +0100 Message-Id: <20221121162433.28070-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When running as a Xen PV guest there is no need for setting up the realmode trampoline, as realmode isn't supported in this environment. Trying to setup the trampoline has been proven to be problematic in some cases, especially when trying to debug early boot problems with Xen requiring to keep the EFI boot-services memory mapped (some firmware variants seem to claim basically all memory below 1M for boot services). Skip the trampoline setup code for Xen PV guests. Fixes: 084ee1c641a0 ("x86, realmode: Relocator for realmode code") Signed-off-by: Juergen Gross --- arch/x86/include/asm/realmode.h | 4 ++-- arch/x86/realmode/init.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmod= e.h index fd6f6e5b755a..5bfce58f1bab 100644 --- a/arch/x86/include/asm/realmode.h +++ b/arch/x86/include/asm/realmode.h @@ -78,8 +78,8 @@ extern unsigned char secondary_startup_64_no_verify[]; =20 static inline size_t real_mode_size_needed(void) { - if (real_mode_header) - return 0; /* already allocated. */ + if (real_mode_header || cpu_feature_enabled(X86_FEATURE_XENPV)) + return 0; /* already allocated or not needed. */ =20 return ALIGN(real_mode_blob_end - real_mode_blob, PAGE_SIZE); } diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c index 41d7669a97ad..1826700b156e 100644 --- a/arch/x86/realmode/init.c +++ b/arch/x86/realmode/init.c @@ -202,6 +202,9 @@ static void __init set_real_mode_permissions(void) =20 static int __init init_real_mode(void) { + if (cpu_feature_enabled(X86_FEATURE_XENPV)) + return 0; + if (!real_mode_header) panic("Real mode trampoline was not allocated"); =20 --=20 2.35.3