@@ -39,16 +39,8 @@ int arch_livepatch_verify_func(const struct livepatch_func *func)
return 0;
}
-void arch_livepatch_revert(const struct livepatch_func *func)
+void arch_livepatch_revert(uint32_t *new_ptr, unsigned int len)
{
- uint32_t *new_ptr;
- unsigned int len;
-
- new_ptr = func->old_addr - (void *)_start + livepatch_vmap.text;
-
- len = livepatch_insn_len(func);
- memcpy(new_ptr, func->opaque, len);
-
clean_and_invalidate_dcache_va_range(new_ptr, len);
}
@@ -81,15 +81,9 @@ void noinline arch_livepatch_apply(struct livepatch_func *func)
* "noinline" to cause control flow change and thus invalidate I$ and
* cause refetch after modification.
*/
-void noinline arch_livepatch_revert(const struct livepatch_func *func)
+void noinline arch_livepatch_revert(uint32_t *new_ptr, unsigned int len)
{
- uint32_t *new_ptr;
- unsigned int len;
-
- new_ptr = func->old_addr - (void *)_start + livepatch_vmap.text;
-
- len = livepatch_insn_len(func);
- memcpy(new_ptr, func->opaque, len);
+ /* Nothing to do. */
}
/*
@@ -1128,6 +1128,18 @@ static void livepatch_revive(void)
livepatch_vmap.offset = 0;
}
+static void livepatch_revert(const struct livepatch_func *func)
+{
+ uint32_t *new_ptr;
+ unsigned int len;
+
+ new_ptr = func->old_addr - (void *)_start + livepatch_vmap.text;
+
+ len = livepatch_insn_len(func);
+ memcpy(new_ptr, func->opaque, len);
+
+ arch_livepatch_revert(new_ptr, len);
+}
/*
* The following functions get the CPUs into an appropriate state and
* apply (or revert) each of the payload's functions. This is needed
@@ -1191,7 +1203,7 @@ static int revert_payload(struct payload *data)
}
for ( i = 0; i < data->nfuncs; i++ )
- arch_livepatch_revert(&data->funcs[i]);
+ livepatch_revert(&data->funcs[i]);
/*
* Since we are running with IRQs disabled and the hooks may call common
@@ -117,11 +117,10 @@ extern struct livepatch_vmap_stash livepatch_vmap;
* These functions are called around the critical region patching live code,
* for an architecture to take make appropratie global state adjustments.
*/
-int arch_livepatch_quiesce(struct livepatch_func *func, unsigned int nfuncs);
void arch_livepatch_revive(void);
void arch_livepatch_apply(struct livepatch_func *func);
-void arch_livepatch_revert(const struct livepatch_func *func);
+void arch_livepatch_revert(uint32_t *new_ptr, unsigned int len);
void arch_livepatch_post_action(void);
void arch_livepatch_mask(void);
The arch_livepatch_revert is very similar between the platforms. Lets unify it as much as possible. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> --- xen/arch/arm/livepatch.c | 10 +--------- xen/arch/x86/livepatch.c | 10 ++-------- xen/common/livepatch.c | 14 +++++++++++++- xen/include/xen/livepatch.h | 3 +-- 4 files changed, 17 insertions(+), 20 deletions(-)