diff mbox series

[livepatch-hooks-2,2/4] create-diff-object: Add support for applied/reverted marker

Message ID 20190814083815.89086-1-wipawel@amazon.de (mailing list archive)
State New, archived
Headers show
Series [livepatch-hooks-2,1/4] create-diff-object: Handle optional apply|revert hooks | expand

Commit Message

Wieczorkiewicz, Pawel Aug. 14, 2019, 8:38 a.m. UTC
With version 2 of a payload structure additional field is supported
to track whether given function has been applied or reverted.
There also comes additional 8-byte alignment padding to reserve
place for future flags and options.

The new fields are zero-out upon .livepatch.funcs section creation.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
---
 common.h             | 2 ++
 create-diff-object.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Konrad Rzeszutek Wilk Aug. 21, 2019, 6:09 p.m. UTC | #1
On 8/14/19 4:38 AM, Pawel Wieczorkiewicz wrote:
> With version 2 of a payload structure additional field is supported
> to track whether given function has been applied or reverted.
> There also comes additional 8-byte alignment padding to reserve
> place for future flags and options.
> 
> The new fields are zero-out upon .livepatch.funcs section creation.
> 
> Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
> ---
>   common.h             | 2 ++
>   create-diff-object.c | 4 +++-
>   2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/common.h b/common.h
> index 06e19e7..d8cde35 100644
> --- a/common.h
> +++ b/common.h
> @@ -124,6 +124,8 @@ struct livepatch_patch_func {
>   	uint32_t old_size;
>   	uint8_t version;
>   	unsigned char pad[31];

So the 31 pad is for this purpose - that you can make it smaller. Why 
not use that?

> +	uint8_t applied;
> +	uint8_t _pad[7];
>   };
>   
>   struct special_section {
> diff --git a/create-diff-object.c b/create-diff-object.c
> index 263c7d2..534516b 100644
> --- a/create-diff-object.c
> +++ b/create-diff-object.c
> @@ -2009,8 +2009,10 @@ 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 = 1;
> +			funcs[index].version = 2;
>   			memset(funcs[index].pad, 0, sizeof funcs[index].pad);
> +			funcs[index].applied = 0;
> +			memset(funcs[index]._pad, 0, sizeof funcs[index]._pad);
>   
>   			/*
>   			 * Add a relocation that will populate
>
Wieczorkiewicz, Pawel Aug. 21, 2019, 6:57 p.m. UTC | #2
On 21. Aug 2019, at 20:09, Konrad Rzeszutek Wilk <konrad.wilk@oracle.com<mailto:konrad.wilk@oracle.com>> wrote:

On 8/14/19 4:38 AM, Pawel Wieczorkiewicz wrote:
With version 2 of a payload structure additional field is supported
to track whether given function has been applied or reverted.
There also comes additional 8-byte alignment padding to reserve
place for future flags and options.

The new fields are zero-out upon .livepatch.funcs section creation.

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de<mailto:wipawel@amazon.de>>
---
 common.h             | 2 ++
 create-diff-object.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/common.h b/common.h
index 06e19e7..d8cde35 100644
--- a/common.h
+++ b/common.h
@@ -124,6 +124,8 @@ struct livepatch_patch_func {
  uint32_t old_size;
  uint8_t version;
  unsigned char pad[31];

So the 31 pad is for this purpose - that you can make it smaller. Why
not use that?

No, I must not use that. The 31 pad should be actually called opaque,
and corresponds to the location where hypervisor stores replaced bytes
of the replaced functions.


+ uint8_t applied;
+ uint8_t _pad[7];
 };

 struct special_section {
diff --git a/create-diff-object.c b/create-diff-object.c
index 263c7d2..534516b 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -2009,8 +2009,10 @@ 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 = 1;
+ funcs[index].version = 2;
  memset(funcs[index].pad, 0, sizeof funcs[index].pad);
+ funcs[index].applied = 0;
+ memset(funcs[index]._pad, 0, sizeof funcs[index]._pad);

  /*
   * Add a relocation that will populate

Best Regards,
Pawel Wieczorkiewicz



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
diff mbox series

Patch

diff --git a/common.h b/common.h
index 06e19e7..d8cde35 100644
--- a/common.h
+++ b/common.h
@@ -124,6 +124,8 @@  struct livepatch_patch_func {
 	uint32_t old_size;
 	uint8_t version;
 	unsigned char pad[31];
+	uint8_t applied;
+	uint8_t _pad[7];
 };
 
 struct special_section {
diff --git a/create-diff-object.c b/create-diff-object.c
index 263c7d2..534516b 100644
--- a/create-diff-object.c
+++ b/create-diff-object.c
@@ -2009,8 +2009,10 @@  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 = 1;
+			funcs[index].version = 2;
 			memset(funcs[index].pad, 0, sizeof funcs[index].pad);
+			funcs[index].applied = 0;
+			memset(funcs[index]._pad, 0, sizeof funcs[index]._pad);
 
 			/*
 			 * Add a relocation that will populate