From nobody Fri Nov 29 19:37:02 2024 Received: from out0-214.mail.aliyun.com (out0-214.mail.aliyun.com [140.205.0.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5789938F83 for ; Mon, 16 Sep 2024 05:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.214 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726462827; cv=none; b=u202mfFsipIcq5cBydaiBVXbiErIFq5vdl3wbyDN16iZ2jTX2PQO7pA5AV2bLm0bGw4jI7Q5wEZIIsi7632f9i4T6Mf6yltAw/zBC5594MmcX+w37o9i2fCgQ0RFBN8aVpgF3TsKzQtK+Qa15ze3dYAABw/3Xxgj0qZYsxjEVAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726462827; c=relaxed/simple; bh=mSH6M9cARGi/4U8gWkJ/5L0xMNj6Gr5rXJEMqQfsui4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F6YvBcbqSMhCBB0nHX1g4TMO+uEylEGHuCoDDh9jS0P/Md+YWr68ycwME16bIMjbk8Gkd9vc+dm4ndZOW7F0mGn2WaGu8gumr5ANfeXQViLhkyyJemL5MZoQXJkRwoedw34vVD4YI0OVP7LMiyp4B3yJ/kecew36kurhDa0/rXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=ynWKEDUB; arc=none smtp.client-ip=140.205.0.214 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="ynWKEDUB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1726462805; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=ICwDMhjJ7dbADtxlBSbI8KnsxD7naRbiR1HvDVegF5k=; b=ynWKEDUBCMpclAFcP1leXS2SCvQz47YGrhlk7T6e0e0cSmZPJ1wId60qaJO90PdSxCwcg2EgdLWN+AUdOKY/7Dg3b9KiLPYbgiwMBiSZzYtCfoF77Bx2k9LxjEfvObiXqGMBTLiOCDN1Hz42hbZB4HVL/2bfjN6zPYOQ6pikH8g= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZKOkLRT_1726462802) by smtp.aliyun-inc.com; Mon, 16 Sep 2024 13:00:04 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , , "Tiwei Bie" Subject: [PATCH v2 1/4] um: Remove the redundant declaration of high_physmem Date: Mon, 16 Sep 2024 12:59:47 +0800 Message-Id: <20240916045950.508910-2-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916045950.508910-1-tiwei.btw@antgroup.com> References: <20240916045950.508910-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" high_physmem has already been declared in as-layout.h, so there is no need to declare it explicitly in the .c file again. While at it, group the declarations of __real_malloc and __real_free together to make the code slightly more readable. Signed-off-by: Tiwei Bie --- arch/um/os-Linux/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index f98ff79cdbf7..cf1179ed1aec 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c @@ -182,6 +182,7 @@ int __init main(int argc, char **argv, char **envp) } =20 extern void *__real_malloc(int); +extern void __real_free(void *); =20 /* workaround for -Wmissing-prototypes warnings */ void *__wrap_malloc(int size); @@ -219,10 +220,6 @@ void *__wrap_calloc(int n, int size) return ptr; } =20 -extern void __real_free(void *); - -extern unsigned long high_physmem; - void __wrap_free(void *ptr) { unsigned long addr =3D (unsigned long) ptr; --=20 2.34.1 From nobody Fri Nov 29 19:37:02 2024 Received: from out0-213.mail.aliyun.com (out0-213.mail.aliyun.com [140.205.0.213]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBAD623A9 for ; Mon, 16 Sep 2024 05:05:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.213 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726463134; cv=none; b=N5i/Km9LKrLdObOhfvpSulE7cC8ArLansgT23+/WwbA9QNdm+J+MONeHzMFUPGH8Hw8cSrYsMpozMhTJIXXWVGpWkJTfHiNE1xBMHzqQXKk7BT0n1TreGeb6LIEw8fT5VLE5VlbisQBysDzQTjQRXUuijx9rrldMRdNiJ3mwOMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726463134; c=relaxed/simple; bh=zGoiFZ/z/Sx8dq6MgXvj9Gkq5VNXp+C5J1FQyL3vMWE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VwoUZVuqeV2VTct4DfMixhZbAopXgSsMn9crhRX66jAFqtjfxfZWXcPPo+o7ae+XL1TrDvVXLLPT/051R4xYfJWbdCYqTvaxzxQ3WPWwqwjI+BIFbxuH07BYIS9dje875yZIJ8SpeqgVin8aNYC6SZmRZAJGWIvclFTwX/0MctA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=Clr/wFIo; arc=none smtp.client-ip=140.205.0.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="Clr/wFIo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1726463122; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=cbbIBKc7FkHrrK8qYg7r4mWInrYZd8lfitbgdnVzDr4=; b=Clr/wFIooIejDynfSDHbnlGZJNVfau2eHBjyIVWuBo/ad2qfdDmMfAGCnk58NJ5Xvxp4NuhFsJhXFIujPka/vLWAivqbMPpX6h/zh8kCpBiPaN9QnuzMg0MKuEYEItLTO6wGvBiUyiqcpwgWD2Ip/B+XYhz/Z84WkvnQdw7SC/U= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZKOkLWf_1726462804) by smtp.aliyun-inc.com; Mon, 16 Sep 2024 13:00:04 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , , "Tiwei Bie" Subject: [PATCH v2 2/4] um: Fix potential integer overflow during physmem setup Date: Mon, 16 Sep 2024 12:59:48 +0800 Message-Id: <20240916045950.508910-3-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916045950.508910-1-tiwei.btw@antgroup.com> References: <20240916045950.508910-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This issue happens when the real map size is greater than LONG_MAX, which can be easily triggered on UML/i386. Fixes: fe205bdd1321 ("um: Print minimum physical memory requirement") Signed-off-by: Tiwei Bie --- arch/um/kernel/physmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index fb2adfb49945..ee693e0b2b58 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -81,10 +81,10 @@ void __init setup_physmem(unsigned long start, unsigned= long reserve_end, unsigned long len, unsigned long long highmem) { unsigned long reserve =3D reserve_end - start; - long map_size =3D len - reserve; + unsigned long map_size =3D len - reserve; int err; =20 - if(map_size <=3D 0) { + if (len <=3D reserve) { os_warn("Too few physical memory! Needed=3D%lu, given=3D%lu\n", reserve, len); exit(1); @@ -95,7 +95,7 @@ void __init setup_physmem(unsigned long start, unsigned l= ong reserve_end, err =3D os_map_memory((void *) reserve_end, physmem_fd, reserve, map_size, 1, 1, 1); if (err < 0) { - os_warn("setup_physmem - mapping %ld bytes of memory at 0x%p " + os_warn("setup_physmem - mapping %lu bytes of memory at 0x%p " "failed - errno =3D %d\n", map_size, (void *) reserve_end, err); exit(1); --=20 2.34.1 From nobody Fri Nov 29 19:37:02 2024 Received: from out187-17.us.a.mail.aliyun.com (out187-17.us.a.mail.aliyun.com [47.90.187.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE9CB4084E for ; Mon, 16 Sep 2024 05:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=47.90.187.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726462848; cv=none; b=itRWtF5LRiIZw9c/+5qfbRMkXMo+9j4tkX0tOpNjqZ5UiaPCjngJ2/LS5oEETDJXK05OJI3gNjIkLY33ZdPvvqBf3Bde4ZV+lYsZ5ktnVdxmgwydgA+zy5pGcMigg9Ocjyu8ExhQQWh+pCfbLxpZDpgc0wYZFeJpFWS3sDsBMMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726462848; c=relaxed/simple; bh=ciFr6BKKgR5dNYGc75O211s2QG1qAB5wrdg1316NZ2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Br6CSl22W+XW6ndkMiVZKVR+WDZ5VjdY1D0bqXdqE5PWk/p2ogx6N85yHtkAHUZvoAN0dqdtzdS1A7gubcW+lSJLvmK5EUxXjV0uE6IXCraOJe+b4rggK2OVft9zNC946FQda5EdSuidZetXCKAhVY3mALcBew3E22sKn216/og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=R94+EY95; arc=none smtp.client-ip=47.90.187.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="R94+EY95" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1726462805; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=swaXqYJCm6gZY+XwsCGLcgH5EmR9VBQSRzPpl3Qd3GQ=; b=R94+EY95A4hkeaSveBf9uZfwh0H/cAA2o3Jzt91n7UgTbMXdd6b8tZ+242rR0hq44e4L/E0DFSDs4qyqj3ml1WoXxH9cJ6oJZoIYw+0JW6hFBNx59pGwl5fTq5x0pr7q6HlHOTAXfydY9zJCG4ScQXwLLTt8EpXuGEKv6crUeQQ= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZKOkLX7_1726462805) by smtp.aliyun-inc.com; Mon, 16 Sep 2024 13:00:05 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , , "Tiwei Bie" Subject: [PATCH v2 3/4] um: Remove highmem leftovers Date: Mon, 16 Sep 2024 12:59:49 +0800 Message-Id: <20240916045950.508910-4-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916045950.508910-1-tiwei.btw@antgroup.com> References: <20240916045950.508910-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Highmem was only supported on UML/i386. And the support has been removed by commit a98a6d864d3b ("um: Remove broken highmem support"). Remove the leftovers and stop UML from trying to setup highmem when the sum of physmem_size and iomem_size exceeds max_physmem. Signed-off-by: Tiwei Bie --- arch/um/drivers/virtio_uml.c | 9 +-------- arch/um/include/shared/as-layout.h | 1 - arch/um/include/shared/mem_user.h | 5 ++--- arch/um/kernel/mem.c | 3 --- arch/um/kernel/physmem.c | 28 ++++++++++------------------ arch/um/kernel/um_arch.c | 17 +++++++---------- 6 files changed, 20 insertions(+), 43 deletions(-) diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index 2b6e701776b6..e7f5556e3c96 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -72,7 +72,7 @@ struct virtio_uml_vq_info { bool suspended; }; =20 -extern unsigned long long physmem_size, highmem; +extern unsigned long long physmem_size; =20 #define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__) =20 @@ -673,13 +673,6 @@ static int vhost_user_set_mem_table(struct virtio_uml_= device *vu_dev) =20 if (rc < 0) return rc; - if (highmem) { - msg.payload.mem_regions.num++; - rc =3D vhost_user_init_mem_region(__pa(end_iomem), highmem, - &fds[1], &msg.payload.mem_regions.regions[1]); - if (rc < 0) - return rc; - } =20 return vhost_user_send(vu_dev, false, &msg, fds, msg.payload.mem_regions.num); diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as= -layout.h index 06292fca5a4d..61965a06c18a 100644 --- a/arch/um/include/shared/as-layout.h +++ b/arch/um/include/shared/as-layout.h @@ -41,7 +41,6 @@ extern unsigned long uml_physmem; extern unsigned long uml_reserved; extern unsigned long end_vm; extern unsigned long start_vm; -extern unsigned long long highmem; =20 extern unsigned long brk_start; =20 diff --git a/arch/um/include/shared/mem_user.h b/arch/um/include/shared/mem= _user.h index 11a723a58545..adfa08062f88 100644 --- a/arch/um/include/shared/mem_user.h +++ b/arch/um/include/shared/mem_user.h @@ -47,10 +47,9 @@ extern int iomem_size; #define ROUND_4M(n) ((((unsigned long) (n)) + (1 << 22)) & ~((1 << 22) - 1= )) =20 extern unsigned long find_iomem(char *driver, unsigned long *len_out); -extern void mem_total_pages(unsigned long physmem, unsigned long iomem, - unsigned long highmem); +extern void mem_total_pages(unsigned long physmem, unsigned long iomem); extern void setup_physmem(unsigned long start, unsigned long usable, - unsigned long len, unsigned long long highmem); + unsigned long len); extern void map_memory(unsigned long virt, unsigned long phys, unsigned long len, int r, int w, int x); =20 diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c index a5b4fe2ad931..5026668dc054 100644 --- a/arch/um/kernel/mem.c +++ b/arch/um/kernel/mem.c @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -51,8 +50,6 @@ EXPORT_SYMBOL(empty_zero_page); pgd_t swapper_pg_dir[PTRS_PER_PGD]; =20 /* Initialized at boot time, and readonly after that */ -unsigned long long highmem; -EXPORT_SYMBOL(highmem); int kmalloc_ok =3D 0; =20 /* Used during early boot */ diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index ee693e0b2b58..94aca17993fd 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -24,17 +24,14 @@ EXPORT_SYMBOL(high_physmem); =20 extern unsigned long long physmem_size; =20 -void __init mem_total_pages(unsigned long physmem, unsigned long iomem, - unsigned long highmem) +void __init mem_total_pages(unsigned long physmem, unsigned long iomem) { - unsigned long phys_pages, highmem_pages; - unsigned long iomem_pages, total_pages; + unsigned long phys_pages, iomem_pages, total_pages; =20 - phys_pages =3D physmem >> PAGE_SHIFT; - iomem_pages =3D iomem >> PAGE_SHIFT; - highmem_pages =3D highmem >> PAGE_SHIFT; + phys_pages =3D physmem >> PAGE_SHIFT; + iomem_pages =3D iomem >> PAGE_SHIFT; =20 - total_pages =3D phys_pages + iomem_pages + highmem_pages; + total_pages =3D phys_pages + iomem_pages; =20 max_mapnr =3D total_pages; } @@ -64,13 +61,12 @@ void map_memory(unsigned long virt, unsigned long phys,= unsigned long len, * @reserve_end: end address of the physical kernel memory. * @len: Length of total physical memory that should be mapped/made * available, in bytes. - * @highmem: Number of highmem bytes that should be mapped/made available. * - * Creates an unlinked temporary file of size (len + highmem) and memory m= aps + * Creates an unlinked temporary file of size (len) and memory maps * it on the last executable image address (uml_reserved). * * The offset is needed as the length of the total physical memory - * (len + highmem) includes the size of the memory used be the executable = image, + * (len) includes the size of the memory used be the executable image, * but the mapped-to address is the last address of the executable image * (uml_reserved =3D=3D end address of executable image). * @@ -78,7 +74,7 @@ void map_memory(unsigned long virt, unsigned long phys, u= nsigned long len, * of all user space processes/kernel tasks. */ void __init setup_physmem(unsigned long start, unsigned long reserve_end, - unsigned long len, unsigned long long highmem) + unsigned long len) { unsigned long reserve =3D reserve_end - start; unsigned long map_size =3D len - reserve; @@ -90,7 +86,7 @@ void __init setup_physmem(unsigned long start, unsigned l= ong reserve_end, exit(1); } =20 - physmem_fd =3D create_mem_file(len + highmem); + physmem_fd =3D create_mem_file(len); =20 err =3D os_map_memory((void *) reserve_end, physmem_fd, reserve, map_size, 1, 1, 1); @@ -109,7 +105,7 @@ void __init setup_physmem(unsigned long start, unsigned= long reserve_end, os_write_file(physmem_fd, __syscall_stub_start, PAGE_SIZE); os_fsync_file(physmem_fd); =20 - memblock_add(__pa(start), len + highmem); + memblock_add(__pa(start), len); memblock_reserve(__pa(start), reserve); =20 min_low_pfn =3D PFN_UP(__pa(reserve_end)); @@ -137,10 +133,6 @@ int phys_mapping(unsigned long phys, unsigned long lon= g *offset_out) region =3D region->next; } } - else if (phys < __pa(end_iomem) + highmem) { - fd =3D physmem_fd; - *offset_out =3D phys - iomem_size; - } =20 return fd; } diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 8e594cda6d77..8f86aa468b50 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -366,18 +366,15 @@ int __init linux_main(int argc, char **argv) =20 setup_machinename(init_utsname()->machine); =20 - highmem =3D 0; + physmem_size =3D (physmem_size + PAGE_SIZE - 1) & PAGE_MASK; iomem_size =3D (iomem_size + PAGE_SIZE - 1) & PAGE_MASK; + max_physmem =3D TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC; =20 - /* - * Zones have to begin on a 1 << MAX_PAGE_ORDER page boundary, - * so this makes sure that's true for highmem - */ - max_physmem &=3D ~((1 << (PAGE_SHIFT + MAX_PAGE_ORDER)) - 1); if (physmem_size + iomem_size > max_physmem) { - highmem =3D physmem_size + iomem_size - max_physmem; - physmem_size -=3D highmem; + physmem_size =3D max_physmem - iomem_size; + os_info("Physical memory size shrunk to %llu bytes\n", + physmem_size); } =20 high_physmem =3D uml_physmem + physmem_size; @@ -413,8 +410,8 @@ void __init setup_arch(char **cmdline_p) u8 rng_seed[32]; =20 stack_protections((unsigned long) &init_thread_info); - setup_physmem(uml_physmem, uml_reserved, physmem_size, highmem); - mem_total_pages(physmem_size, iomem_size, highmem); + setup_physmem(uml_physmem, uml_reserved, physmem_size); + mem_total_pages(physmem_size, iomem_size); uml_dtb_init(); read_initrd(); =20 --=20 2.34.1 From nobody Fri Nov 29 19:37:02 2024 Received: from out0-193.mail.aliyun.com (out0-193.mail.aliyun.com [140.205.0.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E32611BDC8 for ; Mon, 16 Sep 2024 05:05:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.205.0.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726463136; cv=none; b=ZTCTc9F0xd1sLFw4Be2z7x4+kK5WEUQUUIgeivAsR5SZ77nQPxDyKOzisyPH1kNSim3yv4CdT6kJarc0DeQVCSTNtm/zCYkYiH/5VvwyJ6BJBw1wkvBG0/WqalgFNYZQX7wQ0hSt4y9ga6DH5sl1IM2VHnL+w19di/kk/DznzPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726463136; c=relaxed/simple; bh=KVtJ0GFPR0VI0VxEJUftCKj8p2hAtkW1h7R09xBM5j4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LjJEk5h5h9NWq3/DlTJBEk08xgNPy+fo5Vnq0iuVPtv/URD0+xUzbXhMjqwM2TYI2UaE8cijPQGIjc060hqSuWfdOsuUm0wpaqDkrUkmB3yQWxbnaK1rkUd8cs8qZ3AUq7zET/Gk7UnabbKXv/2XH58fWWhyWDCeAb5XmGx0ap0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com; spf=pass smtp.mailfrom=antgroup.com; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b=ndjOabvJ; arc=none smtp.client-ip=140.205.0.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antgroup.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antgroup.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antgroup.com header.i=@antgroup.com header.b="ndjOabvJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=antgroup.com; s=default; t=1726463124; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=CJgZGzYMVBL3IfrmAZkoR5Aw2/PtQZpaw3y5LK6ZT4k=; b=ndjOabvJpPQxxFT5JqMp6hfbZSmh2vUqL6dwGH1wPlgt+FWEMhERZ/0CQ0aWoluny/99KBTEOKabeRCHGboH/8Den2WxBSbzv3B+nRv0Nle7N6tD0l002ZXt1usmMD/H8+dm2q+Un7LMksGWI5ImM/ASzMNe+NMkwChYuZjYsYU= Received: from ubuntu..(mailfrom:tiwei.btw@antgroup.com fp:SMTPD_---.ZKOkLXb_1726462805) by smtp.aliyun-inc.com; Mon, 16 Sep 2024 13:00:05 +0800 From: "Tiwei Bie" To: richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net Cc: , , , "Tiwei Bie" Subject: [PATCH v2 4/4] um: Fix the definition for physmem_size Date: Mon, 16 Sep 2024 12:59:50 +0800 Message-Id: <20240916045950.508910-5-tiwei.btw@antgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240916045950.508910-1-tiwei.btw@antgroup.com> References: <20240916045950.508910-1-tiwei.btw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently physmem_size is defined as long long but declared locally as unsigned long long before using it in separate .c files. Make them match by defining physmem_size as unsigned long long and also move the declaration to a common header to allow the compiler to check it. Signed-off-by: Tiwei Bie --- arch/um/drivers/virtio_uml.c | 2 -- arch/um/include/shared/as-layout.h | 2 ++ arch/um/kernel/physmem.c | 2 -- arch/um/kernel/um_arch.c | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index e7f5556e3c96..4d3e9b9f5b61 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -72,8 +72,6 @@ struct virtio_uml_vq_info { bool suspended; }; =20 -extern unsigned long long physmem_size; - #define vu_err(vu_dev, ...) dev_err(&(vu_dev)->pdev->dev, ##__VA_ARGS__) =20 /* Vhost-user protocol */ diff --git a/arch/um/include/shared/as-layout.h b/arch/um/include/shared/as= -layout.h index 61965a06c18a..283226c34ca4 100644 --- a/arch/um/include/shared/as-layout.h +++ b/arch/um/include/shared/as-layout.h @@ -36,6 +36,8 @@ struct cpu_task { =20 extern struct cpu_task cpu_tasks[]; =20 +extern unsigned long long physmem_size; + extern unsigned long high_physmem; extern unsigned long uml_physmem; extern unsigned long uml_reserved; diff --git a/arch/um/kernel/physmem.c b/arch/um/kernel/physmem.c index 94aca17993fd..636830fe00f2 100644 --- a/arch/um/kernel/physmem.c +++ b/arch/um/kernel/physmem.c @@ -22,8 +22,6 @@ static int physmem_fd =3D -1; unsigned long high_physmem; EXPORT_SYMBOL(high_physmem); =20 -extern unsigned long long physmem_size; - void __init mem_total_pages(unsigned long physmem, unsigned long iomem) { unsigned long phys_pages, iomem_pages, total_pages; diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 8f86aa468b50..99cdf4b2d648 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -131,7 +131,7 @@ static int have_root __initdata; static int have_console __initdata; =20 /* Set in uml_mem_setup and modified in linux_main */ -long long physmem_size =3D 64 * 1024 * 1024; +unsigned long long physmem_size =3D 64 * 1024 * 1024; EXPORT_SYMBOL(physmem_size); =20 static const char *usage_string =3D --=20 2.34.1