From nobody Fri Dec 19 19:01:26 2025 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=1745370189; cv=none; d=zohomail.com; s=zohoarc; b=n61QBGFsiA+VdLgMDSjtDD5XP2vTiBDLYv3B2DTCdvYn1Btw0sdM9UxAP/sXzQjZ34N7Gvn7ZxKKHibbiPAhhD41eQ5Gh6XInDBtLrTxyhbxXntEc8VtMCSiyJ6nUpJDiKk2uurh0bkBK18nVcHbQ7dwhRfc4UQgFcjzK5vBn5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745370189; 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=Hixb/ZwuxNqQ0rmjpvM4G3/QpMDCCkyGKcIaO2DF2yg=; b=Frhn80Q5L9mbnL2+NxHPMUXbfMTWOoA61dEfqKxsKhVQMBAgQ9+vonuILyBglBv6v+9H9DLS7kaJLlbT1lWFi2doWnwgda2Xz8oeVhBszPMCOmeLk39ICwKKBb0zlLwDCmjlo6xS9MO7ohsdGsjIToQcBM2SaJEXCsMr6qc1tpU= 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 174537018911882.85365393200789; Tue, 22 Apr 2025 18:03:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.963778.1354722 (Exim 4.92) (envelope-from ) id 1u7OVm-0001Fr-IX; Wed, 23 Apr 2025 01:02:50 +0000 Received: by outflank-mailman (output) from mailman id 963778.1354722; Wed, 23 Apr 2025 01:02:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7OVm-0001Fk-Fo; Wed, 23 Apr 2025 01:02:50 +0000 Received: by outflank-mailman (input) for mailman id 963778; Wed, 23 Apr 2025 01:02:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7OVl-0000oH-2l for xen-devel@lists.xenproject.org; Wed, 23 Apr 2025 01:02:49 +0000 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [2a00:1450:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ac78f74a-1fde-11f0-9eb0-5ba50f476ded; Wed, 23 Apr 2025 03:02:48 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43cf0d787eeso67688295e9.3 for ; Tue, 22 Apr 2025 18:02:48 -0700 (PDT) Received: from localhost.localdomain ([83.104.178.215]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-44092d2326dsm6707635e9.15.2025.04.22.18.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 18:02:47 -0700 (PDT) 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: ac78f74a-1fde-11f0-9eb0-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1745370168; x=1745974968; 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=Hixb/ZwuxNqQ0rmjpvM4G3/QpMDCCkyGKcIaO2DF2yg=; b=RjlGaz3BAFrynbTC29EjpQtESSz2LoFW7nPfAzd5GddUurdmcIekNRaFH21URheUqh 9cMYY2b8R9EJLUOqqd7egQn9Pwond3y6PMmIqX6tenjniIO9mwrkXUHCleEXZ0FInckg nU7DnJ9TVLbmBAVLyNJd3YspSgs1E7lgkO328= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745370168; x=1745974968; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hixb/ZwuxNqQ0rmjpvM4G3/QpMDCCkyGKcIaO2DF2yg=; b=t4J3nQt5YzXekkLwjvrlNz8GKOVywz8C8hKK29lQZPzXHMC1ezc7n8VJ/V2z2TcaOK 9ICeE0KusW3QoWv+cxLDCSc3lxwN08gGfy282KqB1O8yVBIlS3XiKliQWJInr5mBRqSB kMUzVbhkGBxD9H9sjqOz25VSLK8TWSOcX9Gd1VH9YPDuhg4cC78d5csC8s/RokAd2wLp 2lGlgU/7dvxzONALTZ3M4ANRRqqoFDgvw+ShoLIn6VoUpYjbraR+FHI9Q8ZhQrvGOaPF EUHqKSN11/Q5HHSAi7ODJ7p6icq/uJzak2oJf5LsqWSNgStPJsE59bE4Ix2ejznBjNSv gEtg== X-Gm-Message-State: AOJu0YwfnPxIfY0Qv4FLYGUxHqCrO5c3+eIbARphyCtMUG6/8x8wxJnp BT0tIHxknSMlqFhzssKx0AeHSuku4nRg0KqjKPFnrvsX9gjOHtNYUHW1IdFuGWLAzH0LPY6ArLx s X-Gm-Gg: ASbGnctZixydjEScJokOXtL3SGS1Tjg/eZBDO+m1Y+ChyQn+ijbtG9dqtPkzXov3peE CcFR0Ii1w/aJJXEXBQzSnpVq/hXNJhat89Ftu5iu4lb5yQgnHkgm8NnmjxybncVLBRwsSe8JcBB kgVqPxif1weX2GvvigpRz4+EYhgM4+089vDwg7JrbTUNHQBS5TlXaEdKtVPJINzhzNIK/cHOabN NJls92OibasyzfM7LDSUiJxh8uXvCkHHCF+fSvwfPP/GQKeTiqGSrt6COy2rUsdm0m2qHG/oxGx n42QrkcZaKdDXuYbcedYs7ifZG7BJrNv9pXJ/J0MLWBgoRSvQY8XYhna40HmGg== X-Google-Smtp-Source: AGHT+IGG65bPPpjp6zyCd08HRoORDUf6/LHaa7fgyod4T8zNUbNxIP+hfw/DjUz88TWXAFtevruM/w== X-Received: by 2002:a05:600c:3d96:b0:43c:f895:cb4e with SMTP id 5b1f17b1804b1-4406aba6809mr162887685e9.17.1745370167910; Tue, 22 Apr 2025 18:02:47 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 3/8] x86/alternatives: Rework information passing into nmi_apply_alternatives() Date: Wed, 23 Apr 2025 02:02:32 +0100 Message-Id: <20250423010237.1528582-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250423010237.1528582-1-andrew.cooper3@citrix.com> References: <20250423010237.1528582-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: 1745370191703019100 nmi_apply_alternatives() is soon going to need to dispatch to multiple functions, and a force parameter is not a good way of passing information. Introduce ALT_INSNS and ALT_CALLS to pass in at the top level to select the operation(s) desired. They represent what will happen when we've separated the altcalls out of the general alternative instructions infrastructure, although in the short term we still need to synthesise the force parameter = for _apply_alternatives(). Move two externs to reduce their scope a little. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/alternative.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/alternative.c b/xen/arch/x86/alternative.c index d1a3b7ea7ca6..9aa591b364a4 100644 --- a/xen/arch/x86/alternative.c +++ b/xen/arch/x86/alternative.c @@ -19,8 +19,6 @@ =20 #define MAX_PATCH_LEN (255-1) =20 -extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; - #ifdef K8_NOP1 static const unsigned char k8nops[] init_or_livepatch_const =3D { K8_NOP1, @@ -387,9 +385,13 @@ int apply_alternatives(struct alt_instr *start, struct= alt_instr *end) } #endif =20 +#define ALT_INSNS (1U << 0) +#define ALT_CALLS (1U << 1) static unsigned int __initdata alt_todo; static unsigned int __initdata alt_done; =20 +extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; + /* * At boot time, we patch alternatives in NMI context. This means that the * active NMI-shadow will defer any further NMIs, removing the slim race @@ -419,7 +421,7 @@ static int __init cf_check nmi_apply_alternatives( flush_local(FLUSH_TLB_GLOBAL); =20 rc =3D _apply_alternatives(__alt_instructions, __alt_instructions_= end, - alt_done); + alt_todo =3D=3D ALT_CALLS); if ( rc ) panic("Unable to apply alternatives: %d\n", rc); =20 @@ -442,7 +444,7 @@ static int __init cf_check nmi_apply_alternatives( * This routine is called with local interrupt disabled and used during * bootup. */ -static void __init _alternative_instructions(bool force) +static void __init _alternative_instructions(unsigned int what) { unsigned int i; nmi_callback_t *saved_nmi_callback; @@ -460,7 +462,7 @@ static void __init _alternative_instructions(bool force) ASSERT(!local_irq_is_enabled()); =20 /* Set what operation to perform /before/ setting the callback. */ - alt_todo =3D 1u << force; + alt_todo =3D what; barrier(); =20 /* @@ -490,12 +492,12 @@ static void __init _alternative_instructions(bool for= ce) void __init alternative_instructions(void) { arch_init_ideal_nops(); - _alternative_instructions(false); + _alternative_instructions(ALT_INSNS); } =20 void __init boot_apply_alt_calls(void) { local_irq_disable(); - _alternative_instructions(true); + _alternative_instructions(ALT_CALLS); local_irq_enable(); } --=20 2.39.5