From nobody Tue Mar 3 05:11:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1772234228; cv=none; d=zohomail.com; s=zohoarc; b=bMaeTzCrdsBvAJBG2BoEIq/UtJK9dulJght4x9KqENVuRsc37m7z3tE7fDd1NwSzenHwFpd4mgZ/4j8kM+r5ewyBqCnf9pXAOlwPGE16028lDDDQInZ+ir/1XIq3M9fR8Mlu2hb0xoMSamsTvk+riJypgIK6Zo511ucWH7gXWOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772234228; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vW+QCUaUYuUq9G8gsk0OzquSefAutMzWyPSfjvJkvyY=; b=e4jOndW0Db7V8bYPqHirD9UEtXDeQd+hWtmHEwujEsJXALxWYKzl3c16kHISMnuU2vHtda++TdhGjYWv6+TTxIr3yV27TNMC7Qo6Q9nQh8gGW9oeJDTH0KbUk8lz/GBlumWk59fDOEujpLfWPDwiXijsal/57UjFHxgxwamO27E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1772234228087617.766815838593; Fri, 27 Feb 2026 15:17:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1243142.1543161 (Exim 4.92) (envelope-from ) id 1vw74l-0001Vk-TD; Fri, 27 Feb 2026 23:16:51 +0000 Received: by outflank-mailman (output) from mailman id 1243142.1543161; Fri, 27 Feb 2026 23:16:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vw74l-0001Vd-Ou; Fri, 27 Feb 2026 23:16:51 +0000 Received: by outflank-mailman (input) for mailman id 1243142; Fri, 27 Feb 2026 23:16:50 +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 1vw74j-0001Do-WE for xen-devel@lists.xenproject.org; Fri, 27 Feb 2026 23:16:50 +0000 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [2a00:1450:4864:20::42c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 63667f70-1432-11f1-9ccf-f158ae23cfc8; Sat, 28 Feb 2026 00:16:47 +0100 (CET) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-4377174e1ebso1836368f8f.3 for ; Fri, 27 Feb 2026 15:16:47 -0800 (PST) Received: from localhost.localdomain (host-92-22-18-152.as13285.net. [92.22.18.152]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4399c70e8e8sm9680306f8f.10.2026.02.27.15.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Feb 2026 15:16:45 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 63667f70-1432-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1772234207; x=1772839007; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vW+QCUaUYuUq9G8gsk0OzquSefAutMzWyPSfjvJkvyY=; b=vhLha4bonoIIVEtrCYPP1O9oG/HtAdS9glPqoD/EGaAeaM0qrSyp0hb7oBSKNSCxr2 KRSY5Z1dC4Xef20vDJo01G75YjPd8nLXjstEHDXml7wO7nRDcdxODY3UgTvjDCuwwFLW iDDmo7htP/Mp+Ob60RpxIlNP54a/Ft1pu3RKM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772234207; x=1772839007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vW+QCUaUYuUq9G8gsk0OzquSefAutMzWyPSfjvJkvyY=; b=Zzb6OjewaZBPMNFP4yyG4zRagBGyDLHRiZH+kU8H0a1ZZFJT1su8sOEPgGqF3Xkab+ xKVcOnURpeL2CRA1IRy49nKQZUbXWynSPRzisfbWZkqNUEXdF+SyaGhIJ9uv2eOwYFSU r+smbv4RG7+89alOMtK807xyaTm+pa6/TOwQjGvehB/54gIuZlOmuT7Jo7+5Xx1sVrzr 9QTrzy6z5ebOtFIdkb4Tlayh0+YpeBgP/9Nlp3GIrmsFpW+RpNeAMu1oRqjCZh4EupEV K1dY2E3IX9JmE6IO+DNKdAxirKLaHaf6Htwapa94+HLHbDjZvc+jR33DeAWxJmah6/lN 7sqQ== X-Gm-Message-State: AOJu0YzF0KyY8nDaaI8mPnMXdz0sjnr/xuOJSXZdvLYhJSe6iMRlsoZg 8Hqq466CnoaQPy833cIqJjoTlmkLn5d55a+p3LIjZrvokpp/ZPwYmx7kqSKhf4xbecBPlUpuSlj m56CTSJzVEQ== X-Gm-Gg: ATEYQzyOh+nZyZYUl+Oxb5m9gLnnvQ77+8+JLKCIDIOOG75jmX6c3c2Hny4bRsLsSID HTqm78aNhITRpVNnVF68OYTWjb8ttQNc5KFams6hw2dBiHL8hNSx4hVun2BaG361X9vmgX6gWw3 pc9oJu7k06bTSUMI7pgGL5drJZ7oEi4BAAcEN+/025FEN+xOs1e40Yx5eDlx4xy6ZseMbwH3MmL I4Qm5hpK/BEpab3zDC7AqBkJkgWYeaDzqTmUW6M11lc8Iv3F5XDciEjoeZh1XzwFTXqQzLDSAt2 j/hDv9SCfyvO2dm6J2GqyawyVp6iCPYRfIfIlmxOP4R2TFMCnji9oMinnZz4GbrncF0svUK5Cv3 nM2dfT24ZKjJecfOe2TJLHcRQD1TRbOxwHP10SgFf9F/Y6uhgtBW5au+rIZBaB/q8zZBA7nV19l uiUXPAw8wWXt6NpPm8FvK/CauML9WWnS1R1LxyzTUfgW+HtUgzDyKXG/JkJtVFlW2lXS/AI4g= X-Received: by 2002:a05:6000:2483:b0:439:5bfe:18ce with SMTP id ffacd0b85a97d-4399dde22d3mr8576771f8f.8.1772234206354; Fri, 27 Feb 2026 15:16:46 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v4 05/14] x86/traps: Move traps_init() earlier on boot Date: Fri, 27 Feb 2026 23:16:27 +0000 Message-Id: <20260227231636.3955109-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260227231636.3955109-1-andrew.cooper3@citrix.com> References: <20260227231636.3955109-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1772234246260158500 We wish to make use of opt_fred earlier on boot, which involves moving traps_init() earlier, but this comes with several ordering complications. The feature word containing FRED needs collecting in early_cpu_init(), and legacy_syscall_init() cannot be called that early because it relies on the stubs being allocated, yet must be called ahead of cpu_init() so the SYSCALL linkage MSRs are set up before being cached. Delaying legacy_syscall_init() is easy enough based on a system_state check. Reuse bsp_traps_reinit() to cause a call to legacy_syscall_init() to occur = at the same point as previously. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 v4: * New I don't particualrly like this solution, but the layout of these functions change for FRED. Any adjustments need to consider the logic at the end of = the series, not at this point. --- xen/arch/x86/cpu/common.c | 4 +++- xen/arch/x86/setup.c | 4 +++- xen/arch/x86/traps-setup.c | 12 +++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index bfa63fcfb721..5d0523a78b52 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -407,7 +407,9 @@ void __init early_cpu_init(bool verbose) } =20 if (max_subleaf >=3D 1) - cpuid_count(7, 1, &eax, &ebx, &ecx, + cpuid_count(7, 1, + &c->x86_capability[FEATURESET_7a1], + &ebx, &ecx, &c->x86_capability[FEATURESET_7d1]); } =20 diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 675de3a649ea..0816a713e1c8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1386,6 +1386,8 @@ void asmlinkage __init noreturn __start_xen(void) else panic("Bootloader provided no memory information\n"); =20 + traps_init(); + /* Choose shadow stack early, to set infrastructure up appropriately. = */ if ( !boot_cpu_has(X86_FEATURE_CET_SS) ) opt_xen_shstk =3D 0; @@ -2078,7 +2080,7 @@ void asmlinkage __init noreturn __start_xen(void) &this_cpu(stubs).mfn); BUG_ON(!this_cpu(stubs.addr)); =20 - traps_init(); /* Needs stubs allocated, must be before presmp_initcall= s. */ + bsp_traps_reinit(); /* Needs stubs allocated, must be before presmp_in= itcalls. */ =20 cpu_init(); =20 diff --git a/xen/arch/x86/traps-setup.c b/xen/arch/x86/traps-setup.c index c5fc71c75bca..b2c161943d1e 100644 --- a/xen/arch/x86/traps-setup.c +++ b/xen/arch/x86/traps-setup.c @@ -346,6 +346,10 @@ void __init traps_init(void) =20 /* * Re-initialise all state referencing the early-boot stack. + * + * This is called twice during boot, first to ensure legacy_syscall_init()= has + * run (deferred from earlier), and second when the virtual address of the= BSP + * stack changes. */ void __init bsp_traps_reinit(void) { @@ -359,7 +363,13 @@ void __init bsp_traps_reinit(void) */ void percpu_traps_init(void) { - legacy_syscall_init(); + /* + * Skip legacy_syscall_init() at early boot. It requires the stubs be= ing + * allocated, limiting the placement of the traps_init() call, and gets + * re-done anyway by bsp_traps_reinit(). + */ + if ( system_state > SYS_STATE_early_boot ) + legacy_syscall_init(); =20 if ( cpu_has_xen_lbr ) wrmsrl(MSR_IA32_DEBUGCTLMSR, IA32_DEBUGCTLMSR_LBR); --=20 2.39.5