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().
Fixes: 6974c75180f1 ("xen/x86: Livepatch: support patching CET-enhanced
functions")
Signed-off-by: Jan Beulich <[email protected]>
---
Only build tested, as I don't have a live patching environment available.
For Arm this assumes that the patch_offset field starts out as zero; I
think we can make such an assumption, yet otoh on x86 explicit
initialization was added by the cited commit.
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -90,7 +90,7 @@ static inline
unsigned int livepatch_insn_len(const struct livepatch_func *func)
{
if ( !func->new_addr )
- return func->new_size;
+ return func->new_size - func->patch_offset;
return ARCH_PATCH_INSN_SIZE;
}