diff mbox

[v5,10/16] livepatch: x86, ARM, alternative: Expose FEATURE_LIVEPATCH

Message ID 1474479154-20991-11-git-send-email-konrad.wilk@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Konrad Rzeszutek Wilk Sept. 21, 2016, 5:32 p.m. UTC
To use as a common way of testing alternative patching for
livepatches. Both architectures have this FEATURE and the
test-cases can piggyback on that.

Suggested-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

---
Cc: Julien Grall <julien.grall@arm.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

v3: New submission
v4: Move the LIVEPATCH_FEATURE to asm-x86/livepatch.h
v5: Reorder the patch to be before " livepatch: tests: Make them
    compile under ARM64"
    Always expose FEATURE_LIVEPATCH on ARM.
---
 xen/arch/arm/livepatch.c                  | 3 +++
 xen/include/asm-arm/cpufeature.h          | 3 ++-
 xen/include/asm-x86/livepatch.h           | 1 +
 xen/test/livepatch/xen_hello_world_func.c | 3 ++-
 4 files changed, 8 insertions(+), 2 deletions(-)

Comments

Julien Grall Sept. 22, 2016, 1:03 p.m. UTC | #1
Hi Konrad,

On 21/09/16 18:32, Konrad Rzeszutek Wilk wrote:
> To use as a common way of testing alternative patching for
> livepatches. Both architectures have this FEATURE and the
> test-cases can piggyback on that.
>
> Suggested-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

For the ARM part:

Acked-by: Julien Grall <julien.grall@arm.com>

Regards,
Ross Lagerwall Sept. 27, 2016, 9:49 a.m. UTC | #2
On 09/21/2016 06:32 PM, Konrad Rzeszutek Wilk wrote:
> To use as a common way of testing alternative patching for
> livepatches. Both architectures have this FEATURE and the
> test-cases can piggyback on that.
>
> Suggested-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
>

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
diff mbox

Patch

diff --git a/xen/arch/arm/livepatch.c b/xen/arch/arm/livepatch.c
index 5a99ab5..7855bc5 100644
--- a/xen/arch/arm/livepatch.c
+++ b/xen/arch/arm/livepatch.c
@@ -8,6 +8,7 @@ 
 #include <xen/livepatch.h>
 #include <xen/vmap.h>
 
+#include <asm/cpufeature.h>
 #include <asm/livepatch.h>
 #include <asm/mm.h>
 
@@ -177,6 +178,8 @@  void __init arch_livepatch_init(void)
     end = (void *)LIVEPATCH_VMAP_END;
 
     vm_init_type(VMAP_XEN, start, end);
+
+    cpus_set_cap(LIVEPATCH_FEATURE);
 }
 
 /*
diff --git a/xen/include/asm-arm/cpufeature.h b/xen/include/asm-arm/cpufeature.h
index 66e930f..af60fe3 100644
--- a/xen/include/asm-arm/cpufeature.h
+++ b/xen/include/asm-arm/cpufeature.h
@@ -39,8 +39,9 @@ 
 #define ARM64_WORKAROUND_DEVICE_LOAD_ACQUIRE    1
 #define ARM32_WORKAROUND_766422 2
 #define ARM64_WORKAROUND_834220 3
+#define LIVEPATCH_FEATURE   4
 
-#define ARM_NCAPS           4
+#define ARM_NCAPS           5
 
 #ifndef __ASSEMBLY__
 
diff --git a/xen/include/asm-x86/livepatch.h b/xen/include/asm-x86/livepatch.h
index 7dfc2e7..00aefd2 100644
--- a/xen/include/asm-x86/livepatch.h
+++ b/xen/include/asm-x86/livepatch.h
@@ -10,6 +10,7 @@ 
 
 #define ARCH_PATCH_INSN_SIZE 5
 #define ARCH_LIVEPATCH_RANGE SZ_2G
+#define LIVEPATCH_FEATURE    X86_FEATURE_ALWAYS
 
 #endif /* __XEN_X86_LIVEPATCH_H__ */
 
diff --git a/xen/test/livepatch/xen_hello_world_func.c b/xen/test/livepatch/xen_hello_world_func.c
index 03d6b84..0321f3e 100644
--- a/xen/test/livepatch/xen_hello_world_func.c
+++ b/xen/test/livepatch/xen_hello_world_func.c
@@ -6,6 +6,7 @@ 
 #include <xen/types.h>
 
 #include <asm/alternative.h>
+#include <asm/livepatch.h>
 #include <asm/nops.h>
 #include <asm/uaccess.h>
 
@@ -17,7 +18,7 @@  const char *xen_hello_world(void)
     unsigned long tmp;
     int rc;
 
-    alternative(ASM_NOP8, ASM_NOP1, X86_FEATURE_LM);
+    alternative(ASM_NOP8, ASM_NOP1, LIVEPATCH_FEATURE);
     /*
      * Any BUG, or WARN_ON will contain symbol and payload name. Furthermore
      * exceptions will be caught and processed properly.