livepatch: account for patch offset when applying NOP patch
authorJan Beulich <jbeulich@suse.com>
Thu, 31 Mar 2022 08:45:46 +0000 (10:45 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 31 Mar 2022 08:45:46 +0000 (10:45 +0200)
commit8a87b9a0fb0564f9d68f0be0a0d1a17c34117b8b
treee5a76c9917a81e0269ae45f045309c2eee22d166
parent04f34f84aa8bac5893428c07421f4bddc79d2ec7
livepatch: account for patch offset when applying NOP patch

While not triggered by the trivial xen_nop in-tree patch on
staging/master, that patch exposes a problem on the stable trees, where
all functions have ENDBR inserted. When NOP-ing out a range, we need to
account for this. Handle this right in livepatch_insn_len().

This requires livepatch_insn_len() to be called _after_ ->patch_offset
was set.

Fixes: 6974c75180f1 ("xen/x86: Livepatch: support patching CET-enhanced functions")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/livepatch.c
xen/include/xen/livepatch.h