]> xenbits.xensource.com Git - people/wipawel/livepatch-build-tools/commitdiff
create-diff-object: Add support for expectations
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Fri, 5 Oct 2018 08:08:28 +0000 (08:08 +0000)
committerPawel Wieczorkiewicz <wipawel@amazon.de>
Thu, 8 Aug 2019 14:32:25 +0000 (14:32 +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.

Bump the payload version for hotpatches built with expectations.
The expectations are supported starting from version 3 of the payload.

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>
common.h
create-diff-object.c

index d8cde35fa29db522d003ad31cc0d1ecf61ea087d..7c6fb7357b351b705efbe3b77624f2ca603ed185 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 534516bc9c5d5b01a98257bc6430d9fe6027943d..c7431cc5a4d612d26c960592fe5d671976eebd19 100644 (file)
@@ -2009,10 +2009,11 @@ static void livepatch_create_patches_sections(struct kpatch_elf *kelf,
                        funcs[index].old_size = result.size;
                        funcs[index].new_addr = 0;
                        funcs[index].new_size = sym->sym.st_size;
-                       funcs[index].version = 2;
+                       funcs[index].version = 3;
                        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