]> xenbits.xensource.com Git - livepatch-build-tools.git/commitdiff
create-diff-object: Add support for expectations
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Tue, 26 Nov 2019 12:25:09 +0000 (12:25 +0000)
committerRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 6 Feb 2020 16:26:05 +0000 (16:26 +0000)
Extend livepatch_patch_func to support a new field: expect. This new
field describes the expected data, its length and whether expectation
is enabled. The expectation's data is of opaque padding size.

By default the expectation field is zero-out and the expectation is
disabled unless explicitly specified in the patch.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
common.h
create-diff-object.c

index 7a6620387e6d72be0efa9ff5c278f720839f3c8d..02c9b7bec3e7ea1690f850b86ba68f8d7d9b8fe7 100644 (file)
--- a/common.h
+++ b/common.h
@@ -115,6 +115,14 @@ struct kpatch_elf {
 };
 
 #define PATCH_INSN_SIZE 5
+#define MAX_REPLACEMENT_SIZE 31
+struct livepatch_expectation {
+       uint8_t enabled : 1;
+       uint8_t len : 5;
+       uint8_t pad : 2;
+       uint8_t data[MAX_REPLACEMENT_SIZE];
+};
+typedef struct livepatch_expectation livepatch_expectation_t;
 
 struct livepatch_patch_func {
        char *name;
@@ -123,9 +131,10 @@ struct livepatch_patch_func {
        uint32_t new_size;
        uint32_t old_size;
        uint8_t version;
-       unsigned char pad[31];
+       unsigned char pad[MAX_REPLACEMENT_SIZE];
        uint8_t applied;
        uint8_t _pad[7];
+       livepatch_expectation_t expect;
 };
 
 struct special_section {
index e54821c2babffb32d61bc1153ff05baad9e7cba3..a5166701d43089c2a78a9e25f1a771cb47baeb6e 100644 (file)
@@ -2030,6 +2030,7 @@ static void livepatch_create_patches_sections(struct kpatch_elf *kelf,
                        memset(funcs[index].pad, 0, sizeof funcs[index].pad);
                        funcs[index].applied = 0;
                        memset(funcs[index]._pad, 0, sizeof funcs[index]._pad);
+                       memset(&funcs[index].expect, 0, sizeof funcs[index].expect);
 
                        /*
                         * Add a relocation that will populate