]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
xen/livepatch: make .livepatch.funcs read-only for in-tree tests
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 23 May 2024 08:03:14 +0000 (10:03 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 23 May 2024 08:03:14 +0000 (10:03 +0200)
This matches the flags of the .livepatch.funcs section when generated using
livepatch-build-tools, which only sets the SHT_ALLOC flag.

Also constify the definitions of the livepatch_func variables in the tests
themselves, in order to better match the resulting output.  Note that just
making those variables constant is not enough to force the generated sections
to be read-only.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
13 files changed:
xen/test/livepatch/Makefile
xen/test/livepatch/xen_action_hooks.c
xen/test/livepatch/xen_action_hooks_marker.c
xen/test/livepatch/xen_action_hooks_noapply.c
xen/test/livepatch/xen_action_hooks_norevert.c
xen/test/livepatch/xen_bye_world.c
xen/test/livepatch/xen_expectations.c
xen/test/livepatch/xen_expectations_fail.c
xen/test/livepatch/xen_hello_world.c
xen/test/livepatch/xen_nop.c
xen/test/livepatch/xen_prepost_hooks.c
xen/test/livepatch/xen_prepost_hooks_fail.c
xen/test/livepatch/xen_replace_world.c

index d987a8367f1557299a575b8a52a5ec887eed8211..4caa9e24324eea26abf08de9db099e117a96ae57 100644 (file)
@@ -142,7 +142,10 @@ xen_expectations_fail-objs := xen_expectations_fail.o xen_hello_world_func.o not
 
 
 quiet_cmd_livepatch = LD      $@
-cmd_livepatch = $(LD) $(XEN_LDFLAGS) $(build_id_linker) -r -o $@ $(real-prereqs)
+define cmd_livepatch
+    $(LD) $(XEN_LDFLAGS) $(build_id_linker) -r -o $@ $(real-prereqs); \
+    $(OBJCOPY) --set-section-flags ".livepatch.funcs=alloc,readonly" $@
+endef
 
 $(obj)/%.livepatch: FORCE
        $(call if_changed,livepatch)
index fa0b3ab35f384185e73976aa73e8e1c0c4fad3fb..30c2c5de3c82128dfe984339fa025a4f27161f64 100644 (file)
@@ -84,7 +84,8 @@ LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_POSTREVERT_HOOK(post_revert_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index d2e22f70d1f4a22d6d4b8b5ffbc7bb7930a23e97..eb31a4abc48b175b3ab47afa776bef720bd87078 100644 (file)
@@ -96,7 +96,8 @@ LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
 LIVEPATCH_PREREVERT_HOOK(pre_revert_hook);
 LIVEPATCH_POSTREVERT_HOOK(post_revert_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index 646a5fd2f002b9d684340219b957476767b5d139..92d10d53ffc16fa8e324a4b7e0526c48f7640fc6 100644 (file)
@@ -120,7 +120,8 @@ LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
 LIVEPATCH_PREREVERT_HOOK(pre_revert_hook);
 LIVEPATCH_POSTREVERT_HOOK(post_revert_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index c5fbab174680ce342b892c1a1ba3b8987a8afaeb..fc2d33b531e1ea8149158b77145842fae1c5389a 100644 (file)
@@ -115,7 +115,8 @@ LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
 LIVEPATCH_PREREVERT_HOOK(pre_revert_hook);
 LIVEPATCH_POSTREVERT_HOOK(post_revert_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index 2700f0eeddd2835f6d5b2017a647a7b9113eab84..86589205d8bd223506ce248e274ea10a73ba6c37 100644 (file)
@@ -14,7 +14,8 @@
 static const char bye_world_patch_this_fnc[] = "xen_extra_version";
 extern const char *xen_bye_world(void);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_bye_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_bye_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = bye_world_patch_this_fnc,
     .new_addr = xen_bye_world,
index c8175a458b3c24ed96aeb71564f7b72eda25a2c5..06c752c818279db33c69a1200d838857d132c00c 100644 (file)
@@ -15,7 +15,8 @@
 static const char livepatch_exceptions_str[] = "xen_extra_version";
 extern const char *xen_hello_world(void);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_exceptions = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_exceptions = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = livepatch_exceptions_str,
     .new_addr = xen_hello_world,
index 36a110286fafa9239f642dd5f47bb0c3562e0080..f42c19a953d1e72752393412189f6f11920881df 100644 (file)
@@ -16,7 +16,8 @@ extern const char *xen_hello_world(void);
 
 #define EXPECT_BYTES_COUNT 6
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_exceptions = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_exceptions = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = livepatch_exceptions_str,
     .new_addr = xen_hello_world,
index 02f3f85dc062acb3583377e7f414736ba95496b2..08ab2f197e2c5657ba01624a836523f41d983b38 100644 (file)
@@ -47,7 +47,8 @@ LIVEPATCH_UNLOAD_HOOK(hi_func);
 
 LIVEPATCH_UNLOAD_HOOK(check_fnc);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index a224b7c67073f7420f30e83a5c40b977b8d98df3..6dea657365fb07586bb252db329067010e70b170 100644 (file)
@@ -14,7 +14,7 @@
  * running this test-case you MUST verify that the assumptions are
  * correct (Hint: make debug and look in xen.s).
  */
-struct livepatch_func __section(".livepatch.funcs") livepatch_nop = {
+const struct livepatch_func __section(".livepatch.funcs") livepatch_nop = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .old_size = MINOR_VERSION_SZ,
 
index 17f5af6a192183f8d4b7dc820b08a52e16d575a5..00b0b3abb08e38daf7fc44fb0ec09a3681d8b8e2 100644 (file)
@@ -102,7 +102,8 @@ LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
 LIVEPATCH_PREREVERT_HOOK(pre_revert_hook);
 LIVEPATCH_POSTREVERT_HOOK(post_revert_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index 52fd7f642ecb7f86ee6322d51d7de887abcbfd15..8497715646ecde81b9258c2769ba41b6d1aa02a8 100644 (file)
@@ -55,7 +55,8 @@ LIVEPATCH_POSTAPPLY_HOOK(unreachable_post_hook);
 LIVEPATCH_PREREVERT_HOOK(unreachable_pre_hook);
 LIVEPATCH_POSTREVERT_HOOK(unreachable_post_hook);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_hello_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_hello_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = hello_world_patch_this_fnc,
     .new_addr = xen_hello_world,
index 78a8f528b3d5ab2971e797fd32fdb2905aa9f01c..272cc55e825a03f61d4782406e4114d38a0385bf 100644 (file)
@@ -13,7 +13,8 @@
 static const char xen_replace_world_name[] = "xen_extra_version";
 extern const char *xen_replace_world(void);
 
-struct livepatch_func __section(".livepatch.funcs") livepatch_xen_replace_world = {
+const struct livepatch_func __section(".livepatch.funcs")
+livepatch_xen_replace_world = {
     .version = LIVEPATCH_PAYLOAD_VERSION,
     .name = xen_replace_world_name,
     .old_addr = 0, /* Forces the hypervisor to lookup .name */