xen/livepatch: make .livepatch.funcs read-only for in-tree tests

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>
This commit is contained in:
Roger Pau Monné authored and Jan Beulich committed 2024-05-23 10:03:14 +02:00
1 parent ced21fbb28
commit 3a3111d018
13 files changed
+27 -13

No files matched your search

+4 -1
View 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)
+2 -1
View 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,
+2 -1
View 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,
@@ -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,
@@ -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,
+2 -1
View 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,
+2 -1
View 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,
+2 -1
View 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,
+2 -1
View 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,
+1 -1
View 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,
+2 -1
View 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,
+2 -1
View 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,
+2 -1
View 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 */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.