All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Dingwall <james-xen@dingwall.me.uk>
To: Teddy Astie <teddy.astie@vates.tech>
Cc: xen-devel@lists.xenproject.org
Subject: Re: Xen 4.22.1: CONFIG_LIVEPATCH=n with CONFIG_XSM=y crash
Date: Fri, 4 Dec 2026 09:20:21 +0000	[thread overview]
Message-ID: <axKF1XZH8SUpC6_v@dingwall.me.uk> (raw)
In-Reply-To: <1796333333.8631fc262581453bbf619ec5b2062170.1a23dcf6b21000c7df@vates.tech>

On Thu, Dec 03, 2026 at 10:28:51PM +0100, Teddy Astie wrote:
> Le 03/12/2026 à 21:10, James Dingwall a écrit :
> > Hi,
> > 
> > I'm going through the process of updating our Xen build from 4.20.5 to 4.22.1.
> > I've maintained the .config from 4.20.5 which had CONFIG_LIVEPATCH=n and
> > CONFIG_XSM=y and just updated for the new release with `make -C xen oldconfig`.
> > As soon as the dom0 memory is ballooned Xen crashes:
> > 
> > (XEN) [2026-12-03 13:24:40.751] ----[ Xen-4.22.1  x86_64  debug=n  Not tainted ]----
> > (XEN) [2026-12-03 13:24:40.751] CPU:    0
> > (XEN) [2026-12-03 13:24:40.751] RIP:    e008:[<ffff82d040235649>] do_memory_op+0x829/0x2b5e
> > (XEN) [2026-12-03 13:24:40.751] RFLAGS: 0000000000010202   CONTEXT: hypervisor (d0v0)
> > (XEN) [2026-12-03 13:24:40.751] rax: 0000000000000001   rbx: ffff831077c6ffff   rcx: 0000000000000001
> > (XEN) [2026-12-03 13:24:40.751] rdx: 00000000ffffffff   rsi: ffff831077c6fd78   rdi: 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751] rbp: 0000000000000000   rsp: ffff831077c6fbf0   r8:  00000000000000ff
> > (XEN) [2026-12-03 13:24:40.751] r9:  0000000000000001   r10: 0000000000000000   r11: 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751] r12: ffff83104f8d5000   r13: ffffc90040457dd8   r14: 0000000000000001
> > (XEN) [2026-12-03 13:24:40.751] r15: 0000000000000000   cr0: 0000000080050033   cr4: 00000000003526e0
> > (XEN) [2026-12-03 13:24:40.751] cr3: 00000009d2423000   cr2: ffff82d040459b40
> > (XEN) [2026-12-03 13:24:40.751] fsb: 0000000000000000   gsb: ffff889046c00000   gss: 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751] ds: 0000   es: 0000   fs: 0000   gs: 0000   ss: e010   cs: e008
> > (XEN) [2026-12-03 13:24:40.751] Xen code around <ffff82d040235649> (do_memory_op+0x829/0x2b5e):
> > (XEN) [2026-12-03 13:24:40.751]  01 89 ac 24 8c 01 00 00 <48> 8b 15 f0 44 22 00 c7 84 24 90 01 00 00 00 00
> > (XEN) [2026-12-03 13:24:40.751] Xen stack trace from rsp=ffff831077c6fbf0:
> > (XEN) [2026-12-03 13:24:40.751]    ffff83104f8d5000 8086000000008086 0000000000000000 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000003 0000000000000000 0000000000000000 8086000000008086
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000000 0000000000000000 0000000000000000 0203001a00000000
> > (XEN) [2026-12-03 13:24:40.751]    0e00000001480000 ffff82d0402507e4 ffffffff83f508a0 0000000000000200
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000000 0000000000007ff0 ffff83104f8ecdf0 ffff83104f8dc080
> > (XEN) [2026-12-03 13:24:40.751]    0000000100000007 0000000000000000 0000000000000000 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000003 00000000000000c0 0000000000000000 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000000 ffff82d0405ff058 ffff82d0405ff100 000000000000006f
> > (XEN) [2026-12-03 13:24:40.751]    ffff83100000006f ffff82d040600118 0000000000000202 ffff82d0402567bd
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000202 aaaaaaaaaaaaaaaa ffff83104f8c1000 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000206 ffff82d040350cb3 0000000000000000 0000000000000003
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000003 0000000000000006 ffff83104f8d5000 ffffffff83f508a0
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000200 0000000000000000 ffff831077c6fd8c 00000cfb4f8afe20
> > (XEN) [2026-12-03 13:24:40.751]    ffffffff00000000 0000000000000001 0000000000000001 ffff83104f8d5000
> > (XEN) [2026-12-03 13:24:40.751]    ffff83104f8c7000 0000000000000206 0000000000000000 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000001 ffff83104f8d5000 ffff83104f8c7000 ffff889046c1fad0
> > (XEN) [2026-12-03 13:24:40.751]    0000000000000000 ffff83104f8d5000 ffff82d040347b25 0000000000000000
> > (XEN) [2026-12-03 13:24:40.751]    ffff831077c6fe48 0000000100007ff0 ffff82d04021ffcc ffff830043fbc070
> > (XEN) [2026-12-03 13:24:40.751]    ffff82e000000000 0000000000000000 ffff888100000000 0000000000000006
> > (XEN) [2026-12-03 13:24:40.751]    00000000009d2423 0000000000000000 ffff831077c6ff08 000000000000000c
> > (XEN) [2026-12-03 13:24:40.751] Xen call trace:
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d040235649>] R do_memory_op+0x829/0x2b5e
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d0402507e4>] S common/sched/credit2.c#runq_tickle+0x304/0x651
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d0402567bd>] S vcpu_wake+0x13d/0x224
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d040350cb3>] S send_IPI_mask+0xc3/0x20b
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d040347b25>] S do_mmuext_op+0xda5/0x14eb
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d04021ffcc>] S do_event_channel_op+0x1cc/0x112a
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d04031d0fa>] S pv_hypercall+0x50a/0x563
> > (XEN) [2026-12-03 13:24:40.751]    [<ffff82d04020142d>] S lstar_enter+0x13d/0x142
> > (XEN) [2026-12-03 13:24:40.751]
> > (XEN) [2026-12-03 13:24:40.751] Pagetable walk from ffff82d040459b40:
> > (XEN) [2026-12-03 13:24:40.751]  L4[0x105] = 000000006fcb1063 ffffffffffffffff
> > (XEN) [2026-12-03 13:24:40.751]  L3[0x141] = 000000006fcae063 ffffffffffffffff
> > (XEN) [2026-12-03 13:24:40.751]  L2[0x002] = 0000001077c79063 ffffffffffffffff
> > (XEN) [2026-12-03 13:24:40.751]  L1[0x059] = 0000000000000000 ffffffffffffffff
> > (XEN) [2026-12-03 13:24:41.162]
> > (XEN) [2026-12-03 13:24:41.165] ****************************************
> > (XEN) [2026-12-03 13:24:41.172] Panic on CPU 0:
> > (XEN) [2026-12-03 13:24:41.176] FATAL PAGE FAULT
> > (XEN) [2026-12-03 13:24:41.180] [error_code=0000]
> > (XEN) [2026-12-03 13:24:41.185] Faulting linear address: ffff82d040459b40
> > (XEN) [2026-12-03 13:24:41.191] ****************************************
> > (XEN) [2026-12-03 13:24:41.198]
> > (XEN) [2026-12-03 13:24:41.201] Reboot in five seconds...
> > (XEN) [2026-12-03 13:24:46.206] Resetting with ACPI MEMORY or I/O RESET_REG.
> > 
> > Google AI suggested that the xsm_ops structure was being freed and that
> > toggling the LIVEPATCH .config option would prevent the crash, which it does.
> > I don't know if this dependency between the config options needs to be
> > expressed to avoid an invalid .config combination or whether a different
> > change is needed to allow XSM to remain independent of LIVEPATCH.
> > 
> > Trying to summarise the complete exchange if LIVEPATCH=n then xsm_ops is
> > in .init.data and gets unmapped after boot.  With LIVEPATCH=y xsm_ops is
> > in .data.ro_after_init.  These are details that don't mean much to me so
> > it is possible I have misunderstood.
> > 
> > I am building a patched tree but I don't believe there are changes which
> > would cause this.
> > 
> > Thanks,
> > James
> 
> Hello,
> 
> Thanks, I took a look and managed to reproduce locally, it seems to be a bug
> in alternative patching code, "g" constraint may add a load to a register,
> which here could access no-longer-there address.
> 
> Can you try this change :
> 
> diff --git a/xen/arch/x86/include/asm/alternative-call.h
> b/xen/arch/x86/include/asm/alternative-call.h
> index 809023bc4d..c877998f83 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_;                                                          \
>  })
> 
> Teddy

Hi Teddy,

This patch works for me, thank you.  Xen is being built via a gitlab pipeline
where the container is based on the ubuntu:24.04 image.

root@38c323f81d9d:/xen# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 13.3.0-6ubuntu2~24.04' --with-bugurl=file:///usr/share/doc/gcc-13/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-13 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-13-fG75Ri/gcc-13-13.3.0/debian/tmp-gcn/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04) 

In Andrew's first reply speculative hardening was mentioned, if it matters
this is included as a boot parameter: spec-ctrl=no-xen,gds-mit=0

If the behaviour isn't as expected and you'd like more information from
this environment please let me know.

James


      parent reply	other threads:[~2026-12-04  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 20:05 Xen 4.22.1: CONFIG_LIVEPATCH=n with CONFIG_XSM=y crash James Dingwall
2026-12-03 20:13 ` Andrew Cooper
2026-12-03 21:28 ` Teddy Astie
2026-12-03 21:50   ` Andrew Cooper
2026-12-04  9:20   ` James Dingwall [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axKF1XZH8SUpC6_v@dingwall.me.uk \
    --to=james-xen@dingwall.me.uk \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.