[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/kexec: Use noreturn attributes, and drop unreachable code


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 7 Mar 2022 21:02:10 +0000
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Mon, 07 Mar 2022 21:02:56 +0000
  • Ironport-data: A9a23:4YUFdqOO208u6NTvrR2il8FynXyQoLVcMsEvi/4bfWQNrUom02AFn GAZXDyCa6mKamXwKNokPo/go09X78TTm4Q2QAto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH1dOKJQUBUjclkfJKlYAL/En03FFcMpBsJ00o5wbZi2tEw2rBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Z0 ch0p6KMGQIVL4qRu94fbyhlPyBhIvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 7pCcmlLN03dwbLtqF64YrAEasALBc/nJo4A/FpnyinUF60OSpHfWaTao9Rf2V/cg+gQQqePN 5RCOFKDajzfOB9WBHYVJqsRs9e6mV77TQ9mkV2a8P9fD2/7k1UqjemF3MDuUsOObdVYmACfv G2u10bTDwweNdef4SGY6X/qjejK9QvrVYRXGLCm+/pChFyI2ndVGBAQTUG8o/Sylgi5Qd03F qAP0nNw9+5orhXtF4SjGU3jyJKZgvICc8NNKv8E1FGI9rvzviWjBFQ1cxJAd8Nz4afaWgcW/ lOOmtroAxlmv7uUVW+R+9+okN+iBcQGBTRcPHFZFGPp9/Gm+dhu1UyXEr6PBYbo1oWdJN3m/ 9ydQMHSbZ03hNVD6ai09Euvb9mE9smQFV5dCuk6swuYAuJFiGyNOtTABbvzt68owGOlor+p5 iBsdy+2trxmMH11vHbRKNjh5Znwjxp/DBXSgER0A74q/Cm39niocOh4uW8iehk2YptfIG+0O yc/XD+9ArcJZxNGioctP+qM5zkCl/C8RbwJqNiOBjaxXnSBXFDep3w/DaJh92vsjFItgckC1 WSzKq6R4YIhIf0/llKeHr5FuZdyn3xW7T6DFPjTkkX8uZLDNSH9dFvwGAbXBgzPxPjf+1u9H hc2H5bi9iizp8WlOniHqdNIdAtSRZX5bLivw/Fqmie4ClIOMAkc5zX5mO1Jl1BN90iNqtr1w w==
  • Ironport-hdrordr: A9a23:TpbXV6BgdpSbzNPlHemg55DYdb4zR+YMi2TC1yhKJyC9Ffbo8P xG/c5rsSMc5wxwZJhNo7y90cq7MBbhHPxOkOos1N6ZNWGM0gaVxelZnO3fKlbbehEWmNQz6U 4ZSdkdNOHN
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

kexec_reloc() does not return.  Plumbing this property upwards lets us mark
machine_kexec() and machine_reboot_kexec() noreturn too.  This in turn lets us
drop some unreachable BUG()/return statements.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
---
 xen/arch/x86/include/asm/machine_kexec.h | 7 ++++---
 xen/arch/x86/machine_kexec.c             | 5 ++---
 xen/common/kexec.c                       | 5 -----
 xen/include/xen/kexec.h                  | 4 ++--
 4 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/include/asm/machine_kexec.h 
b/xen/arch/x86/include/asm/machine_kexec.h
index d4880818c1d9..81fe95e091d1 100644
--- a/xen/arch/x86/include/asm/machine_kexec.h
+++ b/xen/arch/x86/include/asm/machine_kexec.h
@@ -4,10 +4,11 @@
 #define KEXEC_RELOC_FLAG_COMPAT 0x1 /* 32-bit image */
 
 #ifndef __ASSEMBLY__
+#include <xen/compiler.h>
 
-extern void kexec_reloc(unsigned long reloc_code, unsigned long reloc_pt,
-                        unsigned long ind_maddr, unsigned long entry_maddr,
-                        unsigned long flags);
+extern void noreturn kexec_reloc(
+    unsigned long reloc_code, unsigned long reloc_pt, unsigned long ind_maddr,
+    unsigned long entry_maddr, unsigned long flags);
 
 extern const char kexec_reloc_end[];
 
diff --git a/xen/arch/x86/machine_kexec.c b/xen/arch/x86/machine_kexec.c
index d83aa4e7e93b..d9b839f46401 100644
--- a/xen/arch/x86/machine_kexec.c
+++ b/xen/arch/x86/machine_kexec.c
@@ -138,15 +138,14 @@ void machine_kexec_unload(struct kexec_image *image)
     /* no-op. kimage_free() frees all control pages. */
 }
 
-void machine_reboot_kexec(struct kexec_image *image)
+void noreturn machine_reboot_kexec(struct kexec_image *image)
 {
     BUG_ON(smp_processor_id() != 0);
     smp_send_stop();
     machine_kexec(image);
-    BUG();
 }
 
-void machine_kexec(struct kexec_image *image)
+void noreturn machine_kexec(struct kexec_image *image)
 {
     int i;
     unsigned long reloc_flags = 0;
diff --git a/xen/common/kexec.c b/xen/common/kexec.c
index a2ffb6530cff..0c85f6171a98 100644
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -391,8 +391,6 @@ void kexec_crash(enum crash_reason reason)
     kexec_crash_save_cpu();
     machine_crash_shutdown();
     machine_kexec(kexec_image[KEXEC_IMAGE_CRASH_BASE + pos]);
-
-    BUG();
 }
 
 static long cf_check kexec_reboot(void *_image)
@@ -403,9 +401,6 @@ static long cf_check kexec_reboot(void *_image)
 
     kexec_common_shutdown();
     machine_reboot_kexec(image);
-
-    BUG();
-    return 0;
 }
 
 static void cf_check do_crashdump_trigger(unsigned char key)
diff --git a/xen/include/xen/kexec.h b/xen/include/xen/kexec.h
index e66eb6a8e593..ff3531586a21 100644
--- a/xen/include/xen/kexec.h
+++ b/xen/include/xen/kexec.h
@@ -48,8 +48,8 @@ int machine_kexec_add_page(struct kexec_image *image, 
unsigned long vaddr,
 int machine_kexec_load(struct kexec_image *image);
 void machine_kexec_unload(struct kexec_image *image);
 void machine_kexec_reserved(xen_kexec_reserve_t *reservation);
-void machine_reboot_kexec(struct kexec_image *image);
-void machine_kexec(struct kexec_image *image);
+void noreturn machine_reboot_kexec(struct kexec_image *image);
+void noreturn machine_kexec(struct kexec_image *image);
 void kexec_crash(enum crash_reason reason);
 void kexec_crash_save_cpu(void);
 struct crash_xen_info *kexec_crash_save_info(void);
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.