From patchwork Fri Jun 14 16:12:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13698929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8924DC27C6E for ; Fri, 14 Jun 2024 16:13:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.740801.1147899 (Exim 4.92) (envelope-from ) id 1sI9YE-0005ka-Gp; Fri, 14 Jun 2024 16:13:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 740801.1147899; Fri, 14 Jun 2024 16:13:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sI9YE-0005kT-Da; Fri, 14 Jun 2024 16:13:18 +0000 Received: by outflank-mailman (input) for mailman id 740801; Fri, 14 Jun 2024 16:13:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sI9YD-0005jz-6e for xen-devel@lists.xenproject.org; Fri, 14 Jun 2024 16:13:17 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 013e1e08-2a69-11ef-b4bb-af5377834399; Fri, 14 Jun 2024 18:13:15 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-79-46-197-197.retail.telecomitalia.it [79.46.197.197]) by support.bugseng.com (Postfix) with ESMTPSA id 369AF4EE0757; Fri, 14 Jun 2024 18:13:13 +0200 (CEST) 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" X-Inumbo-ID: 013e1e08-2a69-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 1/2] x86/mm address violations of MISRA C:2012 Rule 5.3 Date: Fri, 14 Jun 2024 18:12:25 +0200 Message-Id: <80cb7054b82f55f11159faf5f10bfacf44758be0.1718380780.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 This addresses violations of MISRA C:2012 Rule 5.3 which states as following: An identifier declared in an inner scope shall not hide an identifier declared in an outer scope. No functional change. Signed-off-by: Alessandro Zucchelli --- xen/arch/x86/mm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5471b6b1f2..720d56e103 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4703,7 +4703,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct xen_foreign_memory_map fmap; struct domain *d; - struct e820entry *map; + struct e820entry *e; if ( copy_from_guest(&fmap, arg, 1) ) return -EFAULT; @@ -4722,23 +4722,23 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg) return rc; } - map = xmalloc_array(e820entry_t, fmap.map.nr_entries); - if ( map == NULL ) + e = xmalloc_array(e820entry_t, fmap.map.nr_entries); + if ( e == NULL ) { rcu_unlock_domain(d); return -ENOMEM; } - if ( copy_from_guest(map, fmap.map.buffer, fmap.map.nr_entries) ) + if ( copy_from_guest(e, fmap.map.buffer, fmap.map.nr_entries) ) { - xfree(map); + xfree(e); rcu_unlock_domain(d); return -EFAULT; } spin_lock(&d->arch.e820_lock); xfree(d->arch.e820); - d->arch.e820 = map; + d->arch.e820 = e; d->arch.nr_e820 = fmap.map.nr_entries; spin_unlock(&d->arch.e820_lock); From patchwork Fri Jun 14 16:12:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13698930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 294CBC27C6E for ; Fri, 14 Jun 2024 16:13:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.740806.1147909 (Exim 4.92) (envelope-from ) id 1sI9YP-00068S-OH; Fri, 14 Jun 2024 16:13:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 740806.1147909; Fri, 14 Jun 2024 16:13:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sI9YP-00068H-LV; Fri, 14 Jun 2024 16:13:29 +0000 Received: by outflank-mailman (input) for mailman id 740806; Fri, 14 Jun 2024 16:13:29 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sI9YO-0005jz-WC for xen-devel@lists.xenproject.org; Fri, 14 Jun 2024 16:13:28 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 085fe45b-2a69-11ef-b4bb-af5377834399; Fri, 14 Jun 2024 18:13:27 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-79-46-197-197.retail.telecomitalia.it [79.46.197.197]) by support.bugseng.com (Postfix) with ESMTPSA id 3516B4EE0756; Fri, 14 Jun 2024 18:13:24 +0200 (CEST) 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" X-Inumbo-ID: 085fe45b-2a69-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH 2/2] x86/e820 address violations of MISRA C:2012 Rule 5.3 Date: Fri, 14 Jun 2024 18:12:26 +0200 Message-Id: <1a02a5af6c2a737bc814610d4cc684ad4a00b8dc.1718380780.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 This addresses violations of MISRA C:2012 Rule 5.3 which states as following: An identifier declared in an inner scope shall not hide an identifier declared in an outer scope. No functional change. Signed-off-by: Alessandro Zucchelli Acked-by: Jan Beulich --- xen/arch/x86/e820.c | 74 ++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/xen/arch/x86/e820.c b/xen/arch/x86/e820.c index 6a3ce7e0a0..3726823e88 100644 --- a/xen/arch/x86/e820.c +++ b/xen/arch/x86/e820.c @@ -593,79 +593,79 @@ int __init e820_add_range(uint64_t s, uint64_t e, uint32_t type) } int __init e820_change_range_type( - struct e820map *e820, uint64_t s, uint64_t e, + struct e820map *map, uint64_t s, uint64_t e, uint32_t orig_type, uint32_t new_type) { uint64_t rs = 0, re = 0; unsigned int i; - for ( i = 0; i < e820->nr_map; i++ ) + for ( i = 0; i < map->nr_map; i++ ) { /* Have we found the e820 region that includes the specified range? */ - rs = e820->map[i].addr; - re = rs + e820->map[i].size; + rs = map->map[i].addr; + re = rs + map->map[i].size; if ( (s >= rs) && (e <= re) ) break; } - if ( (i == e820->nr_map) || (e820->map[i].type != orig_type) ) + if ( (i == map->nr_map) || (map->map[i].type != orig_type) ) return 0; if ( (s == rs) && (e == re) ) { - e820->map[i].type = new_type; + map->map[i].type = new_type; } else if ( (s == rs) || (e == re) ) { - if ( (e820->nr_map + 1) > ARRAY_SIZE(e820->map) ) + if ( (map->nr_map + 1) > ARRAY_SIZE(map->map) ) goto overflow; - memmove(&e820->map[i+1], &e820->map[i], - (e820->nr_map-i) * sizeof(e820->map[0])); - e820->nr_map++; + memmove(&map->map[i+1], &map->map[i], + (map->nr_map-i) * sizeof(map->map[0])); + map->nr_map++; if ( s == rs ) { - e820->map[i].size = e - s; - e820->map[i].type = new_type; - e820->map[i+1].addr = e; - e820->map[i+1].size = re - e; + map->map[i].size = e - s; + map->map[i].type = new_type; + map->map[i+1].addr = e; + map->map[i+1].size = re - e; } else { - e820->map[i].size = s - rs; - e820->map[i+1].addr = s; - e820->map[i+1].size = e - s; - e820->map[i+1].type = new_type; + map->map[i].size = s - rs; + map->map[i+1].addr = s; + map->map[i+1].size = e - s; + map->map[i+1].type = new_type; } } else { - if ( (e820->nr_map + 2) > ARRAY_SIZE(e820->map) ) + if ( (map->nr_map + 2) > ARRAY_SIZE(map->map) ) goto overflow; - memmove(&e820->map[i+2], &e820->map[i], - (e820->nr_map-i) * sizeof(e820->map[0])); - e820->nr_map += 2; + memmove(&map->map[i+2], &map->map[i], + (map->nr_map-i) * sizeof(map->map[0])); + map->nr_map += 2; - e820->map[i].size = s - rs; - e820->map[i+1].addr = s; - e820->map[i+1].size = e - s; - e820->map[i+1].type = new_type; - e820->map[i+2].addr = e; - e820->map[i+2].size = re - e; + map->map[i].size = s - rs; + map->map[i+1].addr = s; + map->map[i+1].size = e - s; + map->map[i+1].type = new_type; + map->map[i+2].addr = e; + map->map[i+2].size = re - e; } /* Finally, look for any opportunities to merge adjacent e820 entries. */ - for ( i = 0; i < (e820->nr_map - 1); i++ ) + for ( i = 0; i < (map->nr_map - 1); i++ ) { - if ( (e820->map[i].type != e820->map[i+1].type) || - ((e820->map[i].addr + e820->map[i].size) != e820->map[i+1].addr) ) + if ( (map->map[i].type != map->map[i+1].type) || + ((map->map[i].addr + map->map[i].size) != map->map[i+1].addr) ) continue; - e820->map[i].size += e820->map[i+1].size; - memmove(&e820->map[i+1], &e820->map[i+2], - (e820->nr_map-i-2) * sizeof(e820->map[0])); - e820->nr_map--; + map->map[i].size += map->map[i+1].size; + memmove(&map->map[i+1], &map->map[i+2], + (map->nr_map-i-2) * sizeof(map->map[0])); + map->nr_map--; i--; } @@ -678,9 +678,9 @@ int __init e820_change_range_type( } /* Set E820_RAM area (@s,@e) as RESERVED in specified e820 map. */ -int __init reserve_e820_ram(struct e820map *e820, uint64_t s, uint64_t e) +int __init reserve_e820_ram(struct e820map *map, uint64_t s, uint64_t e) { - return e820_change_range_type(e820, s, e, E820_RAM, E820_RESERVED); + return e820_change_range_type(map, s, e, E820_RAM, E820_RESERVED); } unsigned long __init init_e820(const char *str, struct e820map *raw)