Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9298F606A334 for ; Fri, 4 Dec 2026 11:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=citrix.com header.i=@citrix.com header.a=rsa-sha256 header.s=google header.b=O91pozH6 Received: from list by lists.xenproject.org with outflank-mailman.1514112.1705431 (Exim 4.92) (envelope-from ) id 1xZR3O-000765-57; Fri, 04 Dec 2026 11:02:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1514112.1705431; Fri, 04 Dec 2026 11:02:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xZR3O-00075x-2L; Fri, 04 Dec 2026 11:02:14 +0000 Received: by outflank-mailman (input) for mailman id 1514112; Fri, 04 Dec 2026 11:02:12 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xZR3M-00075r-Ql for xen-devel@lists.xenproject.org; Fri, 04 Dec 2026 11:02:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1xZR3M-000SGS-2u for xen-devel@lists.xenproject.org; Fri, 04 Dec 2026 12:02:12 +0100 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6b129db1-8faa-0a2a0a5109dd-0a2a4507947c-14 for ; Fri, 04 Dec 2026 12:02:12 +0100 Received: from [209.85.221.53] (helo=mail-wr1-f53.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6b129db3-b4ea-0a2a45070019-d155dd35c593-3 for ; Fri, 04 Dec 2026 12:02:11 +0100 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4c8fef0a906so465718f8f.1 for ; Fri, 04 Dec 2026 03:02:11 -0800 (PST) Received: from localhost.localdomain (host-78-146-248-75.as13285.net. [78.146.248.75]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d17302b0c9sm4625725f8f.28.2026.12.04.03.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 03:02:09 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Post: List-Help: List-Subscribe: , Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1796382131; x=1796986931; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Erjd97wSE5zj2aIikBdrdyoplL5eY8eV9LlDFjX5Cvo=; b=O91pozH6sSoZvLTgsvMSWS/PpHQUpKInDg+7lyijGb5Yr/TWPcj9SuZ4yL7PLxPYLI K3HrQMECEVsEiqAoiT1m6yU3bJ+58s8gcEKtlEu6HurxDsMMsUc1gUlyKPgL1Cm6Vzy7 Sq8IcuL6R0X3l2bb+akza7oFMYh1F46IO8zpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796382131; x=1796986931; h=content-transfer-encoding:content-type:mime-version:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=Erjd97wSE5zj2aIikBdrdyoplL5eY8eV9LlDFjX5Cvo=; b=nTLdSlcmj+4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t0CuD5 R2nHvMV01fWU3SeqiQwRn8Pz//HdMD0eww8ibMPNuESRnF0jA23Vqr8Oi/RLbwGwljWHWymW5rD 8sh0= X-Received: by 2002:a05:6000:186e:b0:4a9:5848:3640 with SMTP id ffacd0b85a97d-4d1ebca1a1fmr2669861f8f.55.1796382130108; Fri, 04 Dec 2026 03:02:10 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , James Dingwall , Teddy Astie , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH] x86/altcall: Fix crash caused by code generation in alternative_callN() Date: Fri, 4 Dec 2026 11:02:07 +0000 Message-Id: <20261204110207.1119348-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-ef75cf/1796382131-37AD0AE4-479274B9/0/0 X-purgate-type: clean X-purgate-size: 3066 X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 The "g" constraint is not actually used by the asm() block. It's there to communicate to the compiler that func() is referenced. Unfortuantely, "g" is permitted to be interpreted by the compiler as "irm", and both "r" and "m" are explicitly unsafe for certain altcalls. James reports that GCC 13 from Ubuntu 24.04 emitted the following code: do_memory_op (inlined xsm_memory_adjust_reservation, common/memory.c:1577) mov 0x2210c3(%rip),%rdx # ... call *0x2210a9(%rip) # // Patched to direct call at boot With CONFIG_XSM=y and CONFIG_LIVEPATCH=n, the xsm_ops structure is __initdata, causing the MOV to fault. Remove the constraint entirely. Because [addr] "i" (&(func)) is a pointer capture, it ought to convey the same "func is referenced" information to the compiler. Fixes: 67d01cdb5518 ("x86: infrastructure to allow converting certain indirect calls to direct ones") Fixes: d6385ea15f70 ("xsm: Switch xsm_ops to __alt_call_maybe_initdata") Reported-by: James Dingwall Debugged-by: Teddy Astie Signed-off-by: Andrew Cooper Tested-by: James Dingwall --- CC: Jan Beulich CC: Roger Pau Monné CC: Teddy Astie Tracing the second fixes tag also identifies why this showed up in 4.22. The bad code generation was latent before __alt_call_maybe_initdata. I don't have a compiler handy which generates the problem seqeunce for xsm_memory_adjust_reservation(), but the patch does have a reasonable change generally. For the conditional altcalls, it changes from: mov 0xf951(%rip),%rdx # test %rdx,%rdx je ... call *0xf946(%rip) # to the slightly shorter: cmpq $0x0,0x108d0(%rip) # je ... call *0x108c8(%rip) # and with a knock-on effect with register schedulling. --- xen/arch/x86/include/asm/alternative-call.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/include/asm/alternative-call.h b/xen/arch/x86/include/asm/alternative-call.h index 809023bc4d87..c877998f8363 100644 --- a/xen/arch/x86/include/asm/alternative-call.h +++ b/xen/arch/x86/include/asm/alternative-call.h @@ -94,7 +94,7 @@ struct alt_call { ".popsection" \ : ALT_CALL ## n ## _OUT, "=a" (ret_), \ "=r" (r10_), "=r" (r11_) ASM_CALL_CONSTRAINT \ - : [addr] "i" (&(func)), "g" (func) \ + : [addr] "i" (&(func)) \ : "memory" ); \ ret_; \ }) base-commit: a1bb3efd35c2ea04c861f53df602795abb52038a -- 2.39.5