x86,arm: Change arch_livepatch_quiesce() declaration.
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 22 Aug 2016 18:41:41 +0000 (14:41 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 9 Sep 2016 15:48:21 +0000 (11:48 -0400)
On ARM we need an alternative VA region to poke in the
hypervisor .text data. And since this is setup during runtime
we may fail (it uses vmap so most likely error is ENOMEM).

As such this error needs to be bubbled up and also abort
the livepatching if it occurs.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
xen/arch/arm/livepatch.c
xen/arch/x86/livepatch.c
xen/common/livepatch.c
xen/include/xen/livepatch.h

index aba13204f9409cbe638a42278e86090b78f3e23f..755f59686fcc65e89b25307a6ef8c5010ba8f49a 100644 (file)
@@ -7,8 +7,9 @@
 #include <xen/livepatch_elf.h>
 #include <xen/livepatch.h>
 
-void arch_livepatch_quiesce(void)
+int arch_livepatch_quiesce(void)
 {
+    return -ENOSYS;
 }
 
 void arch_livepatch_revive(void)
index 39620f99678feddb0361587e4f77846af855da35..725b3f636db0e2a5b355153dc3fb80b8c1257c94 100644 (file)
 
 #define PATCH_INSN_SIZE 5
 
-void arch_livepatch_quiesce(void)
+int arch_livepatch_quiesce(void)
 {
     /* Disable WP to allow changes to read-only pages. */
     write_cr0(read_cr0() & ~X86_CR0_WP);
+
+    return 0;
 }
 
 void arch_livepatch_revive(void)
index 282da743a815bcf4d78df0fb9405f5b35b5c58fc..23e4d515223d20689ac113f1fdf16cef5ebf03d8 100644 (file)
@@ -1004,11 +1004,17 @@ static int livepatch_list(xen_sysctl_livepatch_list_t *list)
 static int apply_payload(struct payload *data)
 {
     unsigned int i;
+    int rc;
 
     printk(XENLOG_INFO LIVEPATCH "%s: Applying %u functions\n",
             data->name, data->nfuncs);
 
-    arch_livepatch_quiesce();
+    rc = arch_livepatch_quiesce();
+    if ( rc )
+    {
+        printk(XENLOG_ERR LIVEPATCH "%s: unable to quiesce!\n", data->name);
+        return rc;
+    }
 
     for ( i = 0; i < data->nfuncs; i++ )
         arch_livepatch_apply_jmp(&data->funcs[i]);
@@ -1028,10 +1034,16 @@ static int apply_payload(struct payload *data)
 static int revert_payload(struct payload *data)
 {
     unsigned int i;
+    int rc;
 
     printk(XENLOG_INFO LIVEPATCH "%s: Reverting\n", data->name);
 
-    arch_livepatch_quiesce();
+    rc = arch_livepatch_quiesce();
+    if ( rc )
+    {
+        printk(XENLOG_ERR LIVEPATCH "%s: unable to quiesce!\n", data->name);
+        return rc;
+    }
 
     for ( i = 0; i < data->nfuncs; i++ )
         arch_livepatch_revert_jmp(&data->funcs[i]);
index 02f4572fb5031db5fb004882c779f56b7425f539..243e240511cd18110e4d78d44a69f5952bd031ec 100644 (file)
@@ -71,7 +71,7 @@ int arch_livepatch_verify_func(const struct livepatch_func *func);
  * These functions are called around the critical region patching live code,
  * for an architecture to take make appropratie global state adjustments.
  */
-void arch_livepatch_quiesce(void);
+int arch_livepatch_quiesce(void);
 void arch_livepatch_revive(void);
 
 void arch_livepatch_apply_jmp(struct livepatch_func *func);