From nobody Mon Dec 15 18:01:59 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1747843458; cv=none; d=zohomail.com; s=zohoarc; b=KcMpwy+JAIjwvyZQdkoZbduvgGELP7y8RGJLCgNjfkl6pTVkY/nqTIY6NsXeNZramnQyYK3ke2VLIRlY22fLa8J1HmEYxQ9bCtuRWpNJDrjtsPV5sl4Jb6N4BLQMZQLEV64aCYSf52OQxnMWKExABdirarg3FN/rEaVDh1bPcfo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747843458; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=shglBms3cAYrXtkagIZN9N+XVCLYlAM3GBQ8WROjCv4=; b=Lq5n81aLu0IgR5Lgv+Lkov6zMBv4FJOjeCGr9iY74ttOGrp/nabpaGPJxROGlBtAiO7Wc1fQDs67CGsOVg9SAxJuM35hmnRT0Bn3okghaqMVeWCD4germUReR8KxiUEaNfxGeyxYp5AwAW585oCvAllIn5L6Wh9krDSIc3yynmo= 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=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1747843458171182.4765736825285; Wed, 21 May 2025 09:04:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.992138.1375927 (Exim 4.92) (envelope-from ) id 1uHlvI-0004lz-1I; Wed, 21 May 2025 16:04:04 +0000 Received: by outflank-mailman (output) from mailman id 992138.1375927; Wed, 21 May 2025 16:04:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uHlvH-0004lr-TY; Wed, 21 May 2025 16:04:03 +0000 Received: by outflank-mailman (input) for mailman id 992138; Wed, 21 May 2025 16:04:02 +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 1uHlvG-0004Wm-TD for xen-devel@lists.xenproject.org; Wed, 21 May 2025 16:04:02 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 35c55240-365d-11f0-b892-0df219b8e170; Wed, 21 May 2025 18:04:01 +0200 (CEST) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-60236e3d093so1573669a12.3 for ; Wed, 21 May 2025 09:04:01 -0700 (PDT) Received: from fedora.. (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6004d502736sm9152513a12.25.2025.05.21.09.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 May 2025 09:03:59 -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" X-Inumbo-ID: 35c55240-365d-11f0-b892-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747843440; x=1748448240; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=shglBms3cAYrXtkagIZN9N+XVCLYlAM3GBQ8WROjCv4=; b=mZrN6r2fPHSISpLslWZngLYwmK0y5nAMxIn26CogtZpnGRs7j3uYJGgVRcSxxOK3Ov CafF80a/yiJXYSycNHCSP5BzUp2fdwDmUiAHAh4vmjZH2vfYI33HeI/P+14e8SJ0xpwq pCabSaeaNCWFLyCaL0NzGfHaTU4hgXWHfRlhajpTScIhl+VPUiXO89YTKPydlNhKlVwg 7qykmMSduMtbykvwrgY0aA+kQzN3ugTxugk88923DvidhVUbvGl1IL2aYYxgmvlr0RFg 7wIlMXCRCjThGGMFvmrL3EIlxy4SNrQA1mjUP5qURoQ4WASgIvpofmeuMVKRHIzIM0CR iLcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747843440; x=1748448240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=shglBms3cAYrXtkagIZN9N+XVCLYlAM3GBQ8WROjCv4=; b=iZ96X5iZAvqZyQ4ZInX2N0FyuUtFA1n3CsVyn9zK+QimKtQKw5Uo561dJMn+NKiag3 ccklRQfSAwL6DvOXrkYErKxY9xIfqMp0aWwyXdDCnCmWs0MFOcsfjejk9NTxYAFQTPB0 WfF+d1qFkNX378lmTAwjq0VnXH/8hZJM9kNK86pnB7zgDoJTVsIqP3xXirVjmLMzIjSm qomgFa2pKTQtoynNFKsjZUr/whcWCWjlNa47u9zgwgazfrEck37d+G4j6UssgTaqkyND NWIPhkrIhg9H5beRIFTwKbDLLX84iSJoxLp/xwT7nExUm/+bX1ncTRV30YAOT0WNczzF US+A== X-Gm-Message-State: AOJu0YzIpNNXXK12rAH4u+qQy9sqAECnU1sHDUZeLUWOSF8Co4kxqc8I wI3xgoM6+94oBxXHqS7ZP4n0nEdXsXqnlRY0WJmHG9USA+59MAo6aGLj8Or3fQ== X-Gm-Gg: ASbGncvKY39fDuF1JNqOL2U6AptC3KOGktXCXKx+k4+5oUNlqRmuj/vYkvPlG9CZ1s3 muYKaOuSVGzsD/ZFWU4nqinPWi9HNQNKW7mGyqKRgQgKlZ3LHnZ2UWWCza+Z2PNdUXVUz+2bGlE Jwgu4PWx8jEeXQQ7aLrf/7OiIAwDDmAr3XxMJiws9D/40RVMZE2gmzyESeLwh4MWHjk85SQIyMn ydmFR02YQqXMNRuSUaCFwCEXvaAjXU/qCy3I1+Yz+HXMZ7NRHIqNKButJYX4P9TEkrTNJEhamBq vQ0SfT0INZUFuVslrlh4s+j1l23LljX6IMMCyzV4Xfm0zwUxkDtwzgJ48N2SGJNKyKbfW4MNuA3 Xy/aYxpXcH6Qfx1Z7Dw== X-Google-Smtp-Source: AGHT+IGXKA2S9+ecIE6syxuKTBTXlChTOcT8GX4dk5kuzybbiWRvidQud5EUiYkHTkrzJvp6rSGEcw== X-Received: by 2002:a05:6402:3492:b0:601:ef7e:fb49 with SMTP id 4fb4d7f45d1cf-601ef7efe12mr8735000a12.12.1747843439705; Wed, 21 May 2025 09:03:59 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v3 01/14] xen/riscv: introduce smp_prepare_boot_cpu() Date: Wed, 21 May 2025 18:03:41 +0200 Message-ID: <33f3e8378631f6b73148402bbb0b6bb3c64bf754.1747843009.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1747843459018116600 Content-Type: text/plain; charset="utf-8" Initialize cpu_{possible, online}_map by using smp_prepare_boot_cpu(). Drop DEFINE_PER_CPU(unsigned int, cpu_id) from stubs.c as this variable isn= 't expected to be used in RISC-V at all. Move declaration of cpu_{possible,online}_map from stubs.c to smpboot.c as now smpboot.c is now introduced. Other defintions keep in stubs.c as they are not initialized and not needed= , at the moment. Drop cpu_present_map as it is enough to have cpu_possible_map. Also, ask linker to provide symbol for cpu_present_map as common code references it. Move call of set_processor_id(0) to smp_prepare_boot_cpu(). Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich --- Changes in V3: - Move call of set_processor_id(0) inside smp_prepare_boot_cpu(). - Update the commit message. --- Changes in v2: - Add __read_mostly for cpu_online_map. - Add __ro_after_init for cpu_possible_map. - Drop cpu_present_map and cpumask_copy(&cpu_present_map, &cpu_possible_ma= p); - Drop cpumask_clear() for cpu_{possible,online}_map. - Ask the linker provide the symbol for cpu_present_map as common code uses it. - s/smp_clear_cpu_maps/smp_prepare_boot_cpu. - Include in setup.c as smp_prepare_boot_cpu() is declare in t= hat header now. Also, drop inclusion of asm/smp.h in setup.c asm xen/smp.h has inclusion= of asm/smp.h. - Update the commit message. --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/setup.c | 4 ++-- xen/arch/riscv/smpboot.c | 16 ++++++++++++++++ xen/arch/riscv/stubs.c | 6 ------ xen/arch/riscv/xen.lds.S | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 xen/arch/riscv/smpboot.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index d882c57528..f42cf3dfa6 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -10,6 +10,7 @@ obj-y +=3D sbi.o obj-y +=3D setup.o obj-y +=3D shutdown.o obj-y +=3D smp.o +obj-y +=3D smpboot.o obj-y +=3D stubs.o obj-y +=3D time.o obj-y +=3D traps.o diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 4e416f6e44..a9c0c61fb6 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include =20 @@ -19,7 +20,6 @@ #include #include #include -#include #include =20 /* Xen stack for bringing up the first CPU. */ @@ -72,7 +72,7 @@ void __init noreturn start_xen(unsigned long bootcpu_id, =20 remove_identity_mapping(); =20 - set_processor_id(0); + smp_prepare_boot_cpu(); =20 set_cpuid_to_hartid(0, bootcpu_id); =20 diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c new file mode 100644 index 0000000000..0f9c2cc54a --- /dev/null +++ b/xen/arch/riscv/smpboot.c @@ -0,0 +1,16 @@ +#include +#include +#include + +#include + +cpumask_t __read_mostly cpu_online_map; +cpumask_t __ro_after_init cpu_possible_map; + +void __init smp_prepare_boot_cpu(void) +{ + set_processor_id(0); + + cpumask_set_cpu(0, &cpu_possible_map); + cpumask_set_cpu(0, &cpu_online_map); +} diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index 83416d3350..fdcf91054e 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -11,12 +11,6 @@ =20 /* smpboot.c */ =20 -cpumask_t cpu_online_map; -cpumask_t cpu_present_map; -cpumask_t cpu_possible_map; - -/* ID of the PCPU we're running on */ -DEFINE_PER_CPU(unsigned int, cpu_id); /* XXX these seem awfully x86ish... */ /* representing HT siblings of each logical CPU */ DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_mask); diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S index 818aa43669..8c3c06de01 100644 --- a/xen/arch/riscv/xen.lds.S +++ b/xen/arch/riscv/xen.lds.S @@ -165,6 +165,8 @@ SECTIONS ELF_DETAILS_SECTIONS } =20 +PROVIDE(cpu_present_map =3D cpu_possible_map); + ASSERT(IS_ALIGNED(__bss_start, POINTER_ALIGN), "__bss_start is misali= gned") ASSERT(IS_ALIGNED(__bss_end, POINTER_ALIGN), "__bss_end is misalign= ed") =20 --=20 2.49.0