From nobody Sat Jun 13 07:34:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1781106107; cv=none; d=zohomail.com; s=zohoarc; b=P2c4K2534QC+03ao9f6DbxZ4Dwv4nOAQrEPUO1x9U8vQSZhi0GdzTLcq+N6poyG/fykIKZvUrVthrYByaMwg7RVdpaZew8GozdTq5f5RSlwEmtBwUO2JIBqDRLUFUytoQQVaJ/waVX3wPAMxx4Pg0z56KGjhsR42Wv7jj0EkWVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781106107; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qndYU0vQVsNeLM+JlpEy3a/0w2lL2uNqn7mfGncOCjw=; b=E3krPHX4qA9TwT5Z0350FbHS+NRs2lzFI64KHFITzz2feFGM45qF5kox0dq4q+bHRfdcX1aQaRBhuz+2Qj1Jrs1XmG4pk5tOoto+CJ1YkxChaZ7DogqXOxb2A99cm62tvLkfqTdfByCROMrJG04JtnbdhjhMpO1CrvDJY1hlsUo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1781106107215320.93993448404785; Wed, 10 Jun 2026 08:41:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1334503.1597506 (Exim 4.92) (envelope-from ) id 1wXL3M-00042U-9h; Wed, 10 Jun 2026 15:41:16 +0000 Received: by outflank-mailman (output) from mailman id 1334503.1597506; Wed, 10 Jun 2026 15:41:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wXL3M-00042N-6v; Wed, 10 Jun 2026 15:41:16 +0000 Received: by outflank-mailman (input) for mailman id 1334503; Wed, 10 Jun 2026 15:41:14 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wXL3K-00042H-If for xen-devel@lists.xenproject.org; Wed, 10 Jun 2026 15:41:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wXL3J-002yQ2-Ux for xen-devel@lists.xenproject.org; Wed, 10 Jun 2026 17:41:13 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a29858d-e002-0a2a0a5209dd-0a2a4508dca0-10 for ; Wed, 10 Jun 2026 17:41:13 +0200 Received: from [209.85.221.42] (helo=mail-wr1-f42.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a298599-63b5-0a2a45080019-d155dd2ac1dc-3 for ; Wed, 10 Jun 2026 17:41:13 +0200 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-45ef82204c6so3879528f8f.3 for ; Wed, 10 Jun 2026 08:41:13 -0700 (PDT) Received: from localhost.localdomain (host-78-146-242-105.as13285.net. [78.146.242.105]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2dcde3sm74605802f8f.1.2026.06.10.08.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 08:41:12 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1781106073; x=1781710873; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qndYU0vQVsNeLM+JlpEy3a/0w2lL2uNqn7mfGncOCjw=; b=ux5y/heict7tvN/gH25PSDAuPgqnN7ZgUIX0RXPsbAkNvwepApr8J9XVG6Qc+egPJ8 hQ7f2vS5OV+g5RircDRnhMppga6LWa7pjyOdefKpfDMniRvW8JVDKC711d9oSJ3RNttT fY8MRd7Xd6TPivSRSbMd6MqsbKGjAWJb3e8KY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781106073; x=1781710873; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qndYU0vQVsNeLM+JlpEy3a/0w2lL2uNqn7mfGncOCjw=; b=Jqb5pkLfkY6xzryiep/UnnjlbNwx5MvDkWIEH0/POYmCWApzcX/2ZfqlvblTP33kRz DvCfy4wA37JB0bUPBeKwIrZVJ051nSwiWykNie6VbX158QWsBPO9W+mW5uoLLx1/D9Vn qnIhM8ulrynJ8RgviTRudyMvCy2fDEJzvXcT6Zd1JVXiHlOIZeaeDAREYrMiBmyryS0k 4Vwx+MfpamHiKrjbYPz/0mWAsNdOteZzsc1fiVT+qS7DezrLr29djHr9pXPgyypLoAa8 SDCruhq9tGI93GqrgYQG0t2FKBjZMjkgz9iThHTtLy/OSfYl9RvynWMDvfDk9rtxU2Za RIzg== X-Gm-Message-State: AOJu0YwoMiwNrN9uAQgSX+AduWbwEWBfrBEZbpTIfsK/dkxTLAzdKba5 Bt3qmuW6WloB5aoehOqk9dFjKe8Ir48/G0heuVxiFab0/7/K+s6w8L4dOMFKHoEgWoyijK9CStG lF8Xj X-Gm-Gg: Acq92OE334xPUh3LmT4OsRYex7DJSt5Ao+VQDgfyTuiyUpeoseRFbzGqAvca4LEVPal 4XalmVYmhOuQScDB1X8YpfwbIflXz9b/ndPGXhLBMX5j/7IrQdwgcXESws+Y9Hg9kim0Gri+olU qGUuSPnjMUsZlEj5lgt3kyqyhsPK0a5gs25Z1S0vGzmn0K+AiYYYUHk7pH5IDkTxK8FULrLlSx/ KM76dWOJNl/NqNB1hzmJSCSEWDjxQxZZtFDt0o5F3IrBSDRNrVlnSw0tLtPegnqybmfOCgf463C g81xqXYSkmEFtnBl4s7w8mZ7oITFtQzNZBMV4bsD8gW+oejT6sTLbfs8wVgxTOcfLC5RKBkFoD3 6sxJkhnnFn4xNGcE4SzlhQT9zPHmPGu3GaktzFFNecJMLnRLLDsejgZWJpCmfvAkUZef9d7oZ0S oFoz2PaAEvPQNio07+cKHiKM5ocNqIZNKOIudJtN95Uxnx11TT/VRXh1g8cg0ulCeSItwDtCOOG I63uhzFAp1iuYk= X-Received: by 2002:adf:ff89:0:b0:45e:ef2e:25a8 with SMTP id ffacd0b85a97d-46030623f7emr30417911f8f.32.1781106072650; Wed, 10 Jun 2026 08:41:12 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Kevin Lampis Subject: [PATCH for-next] xen/kexec: Style fixes Date: Wed, 10 Jun 2026 16:41:10 +0100 Message-Id: <20260610154110.2979888-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1781106073-BC567DB1-5811F338/0/0 X-purgate-type: clean X-purgate-size: 12351 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1781106110246158500 Adjust kexec and kimage to more closely adhere to Xen style. Sort the includes, dropping duplicates (kexec.h) and unused (ctype.h and kernel.h). No functional change. Signed-off-by: Andrew Cooper Acked-by: Roger Pau Monn=C3=A9 --- CC: Anthony PERARD CC: Michal Orzel CC: Jan Beulich CC: Julien Grall CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Kevin Lampis Fix these before they get copied around in the EFI changes. --- xen/common/kexec.c | 94 +++++++++++++++++++++++++-------------------- xen/common/kimage.c | 23 ++++++----- 2 files changed, 64 insertions(+), 53 deletions(-) diff --git a/xen/common/kexec.c b/xen/common/kexec.c index 65776a95fd70..9ff22e43991c 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -6,31 +6,33 @@ * - Magnus Damm */ =20 -#include -#include #include -#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include +#include #include #include -#include -#include -#include +#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include +#include + +#include + #include -#include + +#include +#include + #ifdef CONFIG_COMPAT #include #endif @@ -162,6 +164,7 @@ static int __init cf_check parse_crashkernel(const char= *str) =20 ++idx; } while ( *str =3D=3D ',' ); + if ( idx < ARRAY_SIZE(ranges) ) ranges[idx].size =3D 0; } @@ -317,7 +320,7 @@ void kexec_crash_save_cpu(void) ELF_Prstatus *prstatus; crash_xen_core_t *xencore; =20 - BUG_ON ( ! crash_notes ); + BUG_ON(!crash_notes); =20 if ( cpumask_test_and_set_cpu(cpu, &crash_saved_cpus) ) return; @@ -418,6 +421,7 @@ static void cf_check do_crashdump_trigger(unsigned char= key) static void setup_note(Elf_Note *n, const char *name, int type, int descsz) { int l =3D strlen(name) + 1; + strlcpy(ELFNOTE_NAME(n), name, l); n->namesz =3D l; n->descsz =3D descsz; @@ -427,7 +431,7 @@ static void setup_note(Elf_Note *n, const char *name, i= nt type, int descsz) static size_t sizeof_note(const char *name, int descsz) { return (sizeof(Elf_Note) + - ELFNOTE_ALIGN(strlen(name)+1) + + ELFNOTE_ALIGN(strlen(name) + 1) + ELFNOTE_ALIGN(descsz)); } =20 @@ -439,7 +443,7 @@ static size_t sizeof_cpu_notes(const unsigned long cpu) + sizeof_note("Xen", sizeof(crash_xen_core_t)); =20 /* CPU0 also presents the crash_xen_info note. */ - if ( ! cpu ) + if ( !cpu ) bytes =3D bytes + sizeof_note("Xen", sizeof(crash_xen_info_t)); =20 @@ -450,24 +454,27 @@ static size_t sizeof_cpu_notes(const unsigned long cp= u) * crash heap if the user has requested that crash notes be allocated * in lower memory. There is currently no case where the crash notes * should be free()'d. */ -static void * alloc_from_crash_heap(const size_t bytes) +static void *alloc_from_crash_heap(const size_t bytes) { - void * ret; + void *ret; + if ( crash_heap_current + bytes > crash_heap_end ) return NULL; - ret =3D (void*)crash_heap_current; + + ret =3D crash_heap_current; crash_heap_current +=3D bytes; + return ret; } =20 /* Allocate a crash note buffer for a newly onlined cpu. */ static int kexec_init_cpu_notes(const unsigned long cpu) { - Elf_Note * note =3D NULL; + Elf_Note *note =3D NULL; int ret =3D 0; int nr_bytes =3D 0; =20 - BUG_ON( cpu >=3D nr_cpu_ids || ! crash_notes ); + BUG_ON(cpu >=3D nr_cpu_ids || !crash_notes); =20 /* If already allocated, nothing to do. */ if ( crash_notes[cpu].start ) @@ -505,7 +512,7 @@ static int kexec_init_cpu_notes(const unsigned long cpu) =20 /* If the allocation failed, and another CPU did not beat us, give * up with ENOMEM. */ - if ( ! note ) + if ( !note ) ret =3D -ENOMEM; /* else all is good so lets set up the notes. */ else @@ -518,7 +525,7 @@ static int kexec_init_cpu_notes(const unsigned long cpu) setup_note(note, "Xen", XEN_ELFNOTE_CRASH_REGS, sizeof(crash_xen_core_t)); =20 - if ( ! cpu ) + if ( !cpu ) { /* Set up Xen Crash Info note. */ xen_crash_note =3D note =3D ELFNOTE_NEXT(note); @@ -548,8 +555,6 @@ static int cf_check cpu_callback( * fail the CPU_UP_PREPARE */ kexec_init_cpu_notes(cpu); break; - default: - break; } return NOTIFY_DONE; } @@ -592,7 +597,7 @@ static int __init cf_check kexec_init(void) get_order_from_bytes(crash_heap_size), MEMF_bits(crashinfo_maxaddr_bits) ); =20 - if ( ! crash_heap_current ) + if ( !crash_heap_current ) return -ENOMEM; =20 memset(crash_heap_current, 0, crash_heap_size); @@ -604,7 +609,7 @@ static int __init cf_check kexec_init(void) Only the individual CPU crash notes themselves must be allocated in lower memory if requested. */ crash_notes =3D xzalloc_array(crash_note_range_t, nr_cpu_ids); - if ( ! crash_notes ) + if ( !crash_notes ) return -ENOMEM; =20 register_keyhandler('C', do_crashdump_trigger, "trigger a crashdump", = 0); @@ -620,7 +625,8 @@ presmp_initcall(kexec_init); =20 static int kexec_get_reserve(xen_kexec_range_t *range) { - if ( kexec_crash_area.size > 0 && kexec_crash_area.start > 0) { + if ( kexec_crash_area.size > 0 && kexec_crash_area.start > 0 ) + { range->start =3D kexec_crash_area.start; range->size =3D kexec_crash_area.size; } @@ -636,7 +642,7 @@ static int kexec_get_cpu(xen_kexec_range_t *range) if ( nr < 0 || nr >=3D nr_cpu_ids ) return -ERANGE; =20 - if ( ! crash_notes ) + if ( !crash_notes ) return -EINVAL; =20 /* Try once again to allocate room for the crash notes. It is just po= ssible @@ -726,7 +732,7 @@ static int kexec_get_range_compat(XEN_GUEST_HANDLE_PARA= M(void) uarg) { XLAT_kexec_range(&compat_range, &range); if ( unlikely(__copy_to_guest(uarg, &compat_range, 1)) ) - ret =3D -EFAULT; + ret =3D -EFAULT; } =20 return ret; @@ -760,7 +766,7 @@ void vmcoreinfo_append_str(const char *fmt, ...) int r; size_t note_size =3D sizeof(Elf_Note) + ELFNOTE_ALIGN(strlen(VMCOREINF= O_NOTE_NAME) + 1); =20 - if (vmcoreinfo_size + note_size + sizeof(buf) > VMCOREINFO_BYTES) + if ( vmcoreinfo_size + note_size + sizeof(buf) > VMCOREINFO_BYTES ) return; =20 va_start(args, fmt); @@ -776,7 +782,7 @@ static void crash_save_vmcoreinfo(void) { size_t data_size; =20 - if (vmcoreinfo_size > 0) /* already saved */ + if ( vmcoreinfo_size > 0 ) /* already saved */ return; =20 data_size =3D VMCOREINFO_BYTES - (sizeof(Elf_Note) + ELFNOTE_ALIGN(str= len(VMCOREINFO_NOTE_NAME) + 1)); @@ -835,7 +841,7 @@ static int kexec_exec(XEN_GUEST_HANDLE_PARAM(void) uarg) if ( !test_bit(base + pos, &kexec_flags) ) return -ENOENT; =20 - switch (exec.type) + switch ( exec.type ) { case KEXEC_TYPE_DEFAULT: image =3D kexec_image[base + pos]; @@ -917,8 +923,8 @@ static int kexec_segments_add_segment(unsigned int *nr_= segments, unsigned int n =3D *nr_segments; =20 /* Need a new segment? */ - if ( n =3D=3D 0 - || segments[n-1].dest_maddr + segments[n-1].dest_size !=3D maddr ) + if ( n =3D=3D 0 || + segments[n-1].dest_maddr + segments[n-1].dest_size !=3D maddr ) { n++; if ( n > KEXEC_SEGMENT_MAX ) @@ -1139,7 +1145,7 @@ static int kexec_load(XEN_GUEST_HANDLE_PARAM(void) ua= rg) return 0; =20 error: - if ( ! kimage ) + if ( !kimage ) xfree(segments); kimage_free(kimage); return ret; @@ -1229,32 +1235,38 @@ static int do_kexec_op_internal(unsigned long op, switch ( op ) { case KEXEC_CMD_kexec_get_range: - if (compat) - ret =3D kexec_get_range_compat(uarg); + if ( compat ) + ret =3D kexec_get_range_compat(uarg); else - ret =3D kexec_get_range(uarg); + ret =3D kexec_get_range(uarg); break; + case KEXEC_CMD_kexec_load_v1: if ( compat ) ret =3D kexec_load_v1_compat(uarg); else ret =3D kexec_load_v1(uarg); break; + case KEXEC_CMD_kexec_unload_v1: if ( compat ) ret =3D kexec_unload_v1_compat(uarg); else ret =3D kexec_unload_v1(uarg); break; + case KEXEC_CMD_kexec: ret =3D kexec_exec(uarg); break; + case KEXEC_CMD_kexec_load: ret =3D kexec_load(uarg); break; + case KEXEC_CMD_kexec_unload: ret =3D kexec_unload(uarg); break; + case KEXEC_CMD_kexec_status: ret =3D kexec_status(uarg); break; diff --git a/xen/common/kimage.c b/xen/common/kimage.c index 6202491f7e76..a0e4e67df7ee 100644 --- a/xen/common/kimage.c +++ b/xen/common/kimage.c @@ -11,15 +11,13 @@ * Version 2. See the file COPYING for more details. */ =20 -#include -#include -#include #include -#include #include -#include +#include #include #include +#include +#include =20 #include =20 @@ -166,7 +164,7 @@ static int do_kimage_alloc(struct kexec_image **rimage,= paddr_t entry, goto out; } =20 - /*=20 + /* * Page for the relocation code must still be accessible after the * processor has switched to 32-bit mode. */ @@ -221,8 +219,8 @@ static int kimage_crash_alloc(struct kexec_image **rima= ge, paddr_t entry, unsigned long i; =20 /* Verify we have a valid entry point */ - if ( (entry < kexec_crash_area.start) - || (entry > kexec_crash_area.start + kexec_crash_area.size)) + if ( entry < kexec_crash_area.start || + entry > kexec_crash_area.start + kexec_crash_area.size ) return -EADDRNOTAVAIL; =20 /* @@ -244,8 +242,8 @@ static int kimage_crash_alloc(struct kexec_image **rima= ge, paddr_t entry, mstart =3D segments[i].dest_maddr; mend =3D mstart + segments[i].dest_size; /* Ensure we are within the crash kernel limits. */ - if ( (mstart < kexec_crash_area.start ) - || (mend > kexec_crash_area.start + kexec_crash_area.size)) + if ( mstart < kexec_crash_area.start || + mend > kexec_crash_area.start + kexec_crash_area.size ) return -EADDRNOTAVAIL; } =20 @@ -606,7 +604,7 @@ static struct page_info *kimage_alloc_page(struct kexec= _image *image, } } page =3D NULL; - for (;;) + for ( ;; ) { kimage_entry_t *old; =20 @@ -825,7 +823,8 @@ int kimage_load_segments(struct kexec_image *image) int s; int result; =20 - for ( s =3D 0; s < image->nr_segments; s++ ) { + for ( s =3D 0; s < image->nr_segments; s++ ) + { result =3D kimage_load_segment(image, &image->segments[s]); if ( result < 0 ) return result; --=20 2.39.5