[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v1 2/3] livepatch: Add xen_local_symbols test-case
To exercise the local/global visibility. With "livepatch: Add local and global symbol resolution." we can load both xen_hello_world and xen_local_symbols without having to worry about: -bash-4.1# xen-livepatch load xen_hello_world.livepatch Uploading xen_hello_world.livepatch... completed Applying xen_hello_world... completed -bash-4.1# xen-livepatch list ID | status ----------------------------------------+------------ xen_hello_world | APPLIED -bash-4.1# xen-livepatch upload xen_local_symbols xen_local_symbols.livepatch Uploading xen_local_symbols.livepatch... failed (XEN) livepatch.c:819: livepatch: xen_local_symbols: duplicate new symbol: revert_hook In fact you will see: livepatch: xen_hello_world: new local symbol revert_hook livepatch: xen_hello_world: new local symbol apply_hook livepatch: xen_hello_world: new local symbol check_fnc livepatch: xen_hello_world: new local symbol hello_world_patch_this_fnc ... livepatch: xen_local_symbols: new local symbol revert_hook livepatch: xen_local_symbols: new local symbol apply_hook livepatch: xen_local_symbols: new local symbol hello_world_patch_this_fnc .. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> --- xen/test/livepatch/Makefile | 10 ++++++- xen/test/livepatch/xen_local_symbols.c | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 xen/test/livepatch/xen_local_symbols.c diff --git a/xen/test/livepatch/Makefile b/xen/test/livepatch/Makefile index 6831383d..b9ad291 100644 --- a/xen/test/livepatch/Makefile +++ b/xen/test/livepatch/Makefile @@ -19,11 +19,13 @@ LIVEPATCH := xen_hello_world.livepatch LIVEPATCH_BYE := xen_bye_world.livepatch LIVEPATCH_REPLACE := xen_replace_world.livepatch LIVEPATCH_NOP := xen_nop.livepatch +LIVEPATCH_LOCAL := xen_local_symbols.livepatch LIVEPATCHES += $(LIVEPATCH) LIVEPATCHES += $(LIVEPATCH_BYE) LIVEPATCHES += $(LIVEPATCH_REPLACE) LIVEPATCHES += $(LIVEPATCH_NOP) +LIVEPATCHES += $(LIVEPATCH_LOCAL) LIVEPATCH_DEBUG_DIR ?= $(DEBUG_DIR)/xen-livepatch @@ -107,5 +109,11 @@ xen_nop.o: config.h $(LIVEPATCH_NOP): xen_nop.o note.o $(LD) $(LDFLAGS) $(build_id_linker) -r -o $(LIVEPATCH_NOP) $^ +xen_local_symbols.o: config.h + +.PHONY: $(LIVEPATCH_LOCAL) +$(LIVEPATCH_LOCAL): xen_hello_world_func.o xen_local_symbols.o note.o + $(LD) $(LDFLAGS) $(build_id_linker) -r -o $(LIVEPATCH_LOCAL) $^ + .PHONY: livepatch -livepatch: $(LIVEPATCH) $(LIVEPATCH_BYE) $(LIVEPATCH_REPLACE) $(LIVEPATCH_NOP) +livepatch: $(LIVEPATCH) $(LIVEPATCH_BYE) $(LIVEPATCH_REPLACE) $(LIVEPATCH_NOP) $(LIVEPATCH_LOCAL) diff --git a/xen/test/livepatch/xen_local_symbols.c b/xen/test/livepatch/xen_local_symbols.c new file mode 100644 index 0000000..eb01b69 --- /dev/null +++ b/xen/test/livepatch/xen_local_symbols.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved. + */ + +#include "config.h" +#include <xen/lib.h> +#include <xen/types.h> +#include <xen/version.h> +#include <xen/livepatch.h> +#include <xen/livepatch_payload.h> + +#include <public/sysctl.h> + +/* Same name as in xen_hello_world */ +static const char hello_world_patch_this_fnc[] = "xen_extra_version"; +extern const char *xen_hello_world(void); + +/* + * The hooks are static here (LOCAL) and also in xen_hello_world.c + * and their name is exactly the same. + */ +static void apply_hook(void) +{ + printk(KERN_DEBUG "local_symbols: Hook executing.\n"); +} + +static void revert_hook(void) +{ + printk(KERN_DEBUG "local_symbols: Hook unloaded.\n"); +} + +LIVEPATCH_LOAD_HOOK(apply_hook); +LIVEPATCH_UNLOAD_HOOK(revert_hook); + +struct livepatch_func __section(".livepatch.funcs") livepatch_xen_local_symbols = { + .version = LIVEPATCH_PAYLOAD_VERSION, + .name = hello_world_patch_this_fnc, + .new_addr = xen_hello_world, + .old_addr = xen_extra_version, + .new_size = NEW_CODE_SZ, + .old_size = OLD_CODE_SZ, +}; + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ -- 2.9.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |