From patchwork Mon Feb 12 12:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13553014 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 88711C4829B for ; Mon, 12 Feb 2024 12:53:47 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.679568.1057044 (Exim 4.92) (envelope-from ) id 1rZVoY-0003FW-8P; Mon, 12 Feb 2024 12:53:38 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 679568.1057044; Mon, 12 Feb 2024 12:53:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rZVoY-0003FP-4F; Mon, 12 Feb 2024 12:53:38 +0000 Received: by outflank-mailman (input) for mailman id 679568; Mon, 12 Feb 2024 12:53:37 +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 1rZVoX-0003FJ-5Q for xen-devel@lists.xenproject.org; Mon, 12 Feb 2024 12:53:37 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bb41ee4b-c9a5-11ee-98f5-efadbce2ee36; Mon, 12 Feb 2024 13:53:34 +0100 (CET) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33b960e3b8fso51397f8f.1 for ; Mon, 12 Feb 2024 04:53:35 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id v9-20020a5d4b09000000b0033b843786e1sm1973101wrq.51.2024.02.12.04.53.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 04:53:34 -0800 (PST) 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: bb41ee4b-c9a5-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707742414; x=1708347214; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=gnaXKYsqx4CnSa2eo1JbWiq89d/Jw0i23q5wGyWRgbc=; b=KeJf1p5pfk9h8ebY9OnKDYvFrjgj6zx7bho1RQnE30Y5gTP7CBbdhDGekv3EqaWU/6 7p4OKrxnqRXoZG0ni8PgrA+hBQ1HzUbxKml+KDRJLHkVDiNYXTyCdUN/NByufEgWwuPp umF5BQ+2RS29+ON9HDZnX5SDsY4I6W1F35KJy+mU/4p+0Qu7c4GaRRN6n7SAItw8j3NS LTcciUdAWkwbzA/3Yw9WqE/MIJo3QnliW4elrrmPduOw3dQjbqzCu2HuAirOteklLXtb vbyJTjbatDyVCuizu08WlhemCk3A5HLXA/2VeH1U/Y3GSNg2PAd/cyfwGoP/IG+HVmNJ uM7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707742414; x=1708347214; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gnaXKYsqx4CnSa2eo1JbWiq89d/Jw0i23q5wGyWRgbc=; b=H/JxARpgCQWM8R0GOfao2mVLm004pFMoihf9QhIosVuwqmN2H/CPJY0FunjQmf4+9k Y6ujhnwPUosvrLGsSAfcahANxHa5GJRKSk8hw/a3Fpg/H0zfy0W98OETeeoiPg7uei+z Lqqn2rYVoR+Vqh7IdV0Zt1RlQroJ0z61jN13MP0uXjfFGPwoumJhSdJEPiTjXM9Qd44n 6gBVhn7x9rQHw8UwM0Qdm2Apmj37y0nq/G6WY4lYOZe771P2CQd6XyTSRPw6T+wKkE14 prCmoBkp1R0YYsfTD2cKD5l8a6UGC/hj3pBfJdVsrwzbO0spg1e0gvbRRF8N2Ft+VQvD 39uQ== X-Gm-Message-State: AOJu0YxQP0HM+sun7Lz9QFMrPAopdg9uTATcrhN09x9ROqd601lbW86w nyRjTs8P8XJZ9BFRKwxNN3WW+I2ayLbFvCRlS37S5sxDGbBKxR688CSdJS9fP65WLaiwkDecOP0 = X-Google-Smtp-Source: AGHT+IH9e8X3xpPzR5iMc18oxKPa1rgHP4+2e41uFq18jBhg4QQQjj0sEJ7GicSTGEPvifwctQ8Fmg== X-Received: by 2002:a05:6000:12ce:b0:33b:14f8:7331 with SMTP id l14-20020a05600012ce00b0033b14f87331mr4359069wrx.4.1707742414367; Mon, 12 Feb 2024 04:53:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWs+UAElik26OQ7RClJIH1gUUq4z4NF/7jYzfGkiaLL0aUky03fnC69655YmBGr1vT5WBMIQboJp06qd7HPH2R+mCLTHrvGDD1WQUjCT6UZOw== Message-ID: Date: Mon, 12 Feb 2024 13:53:33 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] x86/CPU: re-work populating of cpu_data[] Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: <4c4ff91e-ce66-428f-a360-6ffc55659e79@suse.com> Autoc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JW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <4c4ff91e-ce66-428f-a360-6ffc55659e79@suse.com> Forever since its introduction x86_mc_get_cpu_info() has been checking a structure field against BAD_APICID which would never have been set to that particular value. Arrange for this to actually be true ahead of CPU detection having run, which then also includes pruning after CPU removal. For this, - introduce a new helper function splitting reset logic out of identify_cpu(), and going slightly farther than the original code to achieve consistent results, - introduce a new helper macro for both initializing and resetting various fields. For boot_cpu_data this in particular means that cpuid_level will no longer be set to the bogus value of -1. Even before removal of 32-bit support we already assumed basic CPUID leaves to be available. Furthermore make sure initialize_cpu_data() doesn't populate fields with BSP's values which clearly aren't going to be applicable to APs. Fixes: e16fc5ba591c ("x86: mce: Provide extended physical CPU info") Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -413,6 +413,19 @@ void __init early_cpu_init(bool verbose) initialize_cpu_data(0); } +void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic) +{ + if (!keep_basic) { + c->x86 = c->x86_vendor = 0; /* So far unknown... */ + c->x86_model = c->x86_mask = 0; /* So far unknown... */ + memset(&c->x86_capability, 0, sizeof(c->x86_capability)); + memset(&c->x86_vendor_id, 0, sizeof(c->x86_vendor_id)); + memset(&c->x86_model_id, 0, sizeof(c->x86_model_id)); + } + + CPU_DATA_INIT((*c)); +} + static void generic_identify(struct cpuinfo_x86 *c) { u32 eax, ebx, ecx, edx, tmp; @@ -518,16 +531,7 @@ void identify_cpu(struct cpuinfo_x86 *c) { int i; - c->x86_cache_size = -1; - c->x86_model = c->x86_mask = 0; /* So far unknown... */ - c->x86_model_id[0] = '\0'; /* Unset */ - c->x86_max_cores = 1; - c->x86_num_siblings = 1; - c->x86_clflush_size = 0; - c->cpu_core_id = XEN_INVALID_CORE_ID; - c->compute_unit_id = INVALID_CUID; - memset(&c->x86_capability, 0, sizeof c->x86_capability); - + reset_cpuinfo(c, false); generic_identify(c); #ifdef NOISY_CAPS --- a/xen/arch/x86/include/asm/cpufeature.h +++ b/xen/arch/x86/include/asm/cpufeature.h @@ -40,6 +40,24 @@ struct cpuinfo_x86 { unsigned short x86_clflush_size; } __cacheline_aligned; +#define CPU_DATA_INIT(what...) \ + what.cpuid_level = 1, \ + what.extended_cpuid_level = 0, \ + what.x86_cache_size = -1, \ + what.x86_max_cores = 1, \ + what.x86_num_siblings = 1, \ + what.apicid = BAD_APICID, \ + what.phys_proc_id = XEN_INVALID_SOCKET_ID, \ + what.cpu_core_id = XEN_INVALID_CORE_ID, \ + what.compute_unit_id = INVALID_CUID + +/* + * @keep_basic set to true retains data firmly assumed to be symmetric + * across all CPUs. With it set to false only CPU_DATA_INIT() will be + * invoked on the passed structure. + */ +void reset_cpuinfo(struct cpuinfo_x86 *c, bool keep_basic); + extern struct cpuinfo_x86 boot_cpu_data; static inline bool cpu_has(const struct cpuinfo_x86 *info, unsigned int feat) --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -157,7 +157,7 @@ void *stack_start = cpu0_stack + STACK_S /* Used by the boot asm to stash the relocated multiboot info pointer. */ unsigned int asmlinkage __initdata multiboot_ptr; -struct cpuinfo_x86 __read_mostly boot_cpu_data = { 0, 0, 0, 0, -1 }; +struct cpuinfo_x86 __read_mostly boot_cpu_data = { CPU_DATA_INIT() }; unsigned long __read_mostly mmu_cr4_features = XEN_MINIMAL_CR4; --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -61,7 +61,8 @@ unsigned int __read_mostly nr_sockets; cpumask_t **__read_mostly socket_cpumask; static cpumask_t *secondary_socket_cpumask; -struct cpuinfo_x86 cpu_data[NR_CPUS]; +struct cpuinfo_x86 __read_mostly cpu_data[NR_CPUS] = + { [0 ... NR_CPUS - 1] = { CPU_DATA_INIT() } }; u32 x86_cpu_to_apicid[NR_CPUS] __read_mostly = { [0 ... NR_CPUS-1] = BAD_APICID }; @@ -81,7 +82,12 @@ void *stack_base[NR_CPUS]; void initialize_cpu_data(unsigned int cpu) { - cpu_data[cpu] = boot_cpu_data; + struct cpuinfo_x86 c = boot_cpu_data; + + /* Must not partially clear the BSP's collected data. */ + if ( cpu || system_state > SYS_STATE_smp_boot ) + reset_cpuinfo(&c, true); + cpu_data[cpu] = c; } static bool smp_store_cpu_info(unsigned int id) @@ -954,7 +960,6 @@ static void cleanup_cpu_root_pgt(unsigne static void cpu_smpboot_free(unsigned int cpu, bool remove) { unsigned int socket = cpu_to_socket(cpu); - struct cpuinfo_x86 *c = cpu_data; if ( cpumask_empty(socket_cpumask[socket]) ) { @@ -966,9 +971,7 @@ static void cpu_smpboot_free(unsigned in if ( remove ) { - c[cpu].phys_proc_id = XEN_INVALID_SOCKET_ID; - c[cpu].cpu_core_id = XEN_INVALID_CORE_ID; - c[cpu].compute_unit_id = INVALID_CUID; + reset_cpuinfo(&cpu_data[cpu], false); FREE_CPUMASK_VAR(per_cpu(cpu_sibling_mask, cpu)); FREE_CPUMASK_VAR(per_cpu(cpu_core_mask, cpu)); From patchwork Mon Feb 12 12:53:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13553017 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 47A2EC48297 for ; Mon, 12 Feb 2024 12:54:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.679570.1057053 (Exim 4.92) (envelope-from ) id 1rZVov-0003g9-EK; Mon, 12 Feb 2024 12:54:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 679570.1057053; Mon, 12 Feb 2024 12:54:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rZVov-0003g2-Ba; Mon, 12 Feb 2024 12:54:01 +0000 Received: by outflank-mailman (input) for mailman id 679570; Mon, 12 Feb 2024 12:53:59 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rZVot-0003YI-Dh for xen-devel@lists.xenproject.org; Mon, 12 Feb 2024 12:53:59 +0000 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [2a00:1450:4864:20::334]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c9c20310-c9a5-11ee-8a4c-1f161083a0e0; Mon, 12 Feb 2024 13:53:58 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-410deab9c56so4679755e9.0 for ; Mon, 12 Feb 2024 04:53:58 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id v9-20020a5d4b09000000b0033b843786e1sm1973101wrq.51.2024.02.12.04.53.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Feb 2024 04:53:58 -0800 (PST) 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: c9c20310-c9a5-11ee-8a4c-1f161083a0e0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1707742438; x=1708347238; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=mbVyp1i6IDxX6RGOTJDic76W4aj3SGd/6f+hawIv8lU=; b=cw5W3Hbon3d3BuN1Uueb0qsFBRmqi37mbAM0O1VeADl7BxtAFGpjtc0/9tNYbPklNn Zbkt6FR5lqOFRpCtfwGpIByX2O0epYLG6Sx++DjIwy+b1BMJQogIcOW/rcL7WFHrrgPQ R9glZkiDDnbKp5VrS3HQFO7RULZ/u9NwY4EfLryJwYcBXtjKvg7BaqQi7uuUWm91rDLq 4zfAvGx4lEK3nMfp+0zD9eL7ATR8psQbIBDt7jK3RpU9StBnTkTVxsnjLYeKjp1CY0PW beXfHHfwfViXR96e5BmQuQIBOcNZLQ+5l69foFPRmMSsxXkTI4T2KNQprgFKIWZSaVDi K4vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707742438; x=1708347238; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mbVyp1i6IDxX6RGOTJDic76W4aj3SGd/6f+hawIv8lU=; b=O0scs78ng9I42IiPlspWTlEE3QwU+3K3yINqzeRd3aZ0Y6x8BXNOH0iN/MhDUeBGMN wrhfZe9V16O7vK1hMkoYpHrPXeU9t4Fx9ayF40wzIUOGDZrP7EGAp5Wr6YXHzrmfHrjA WxdG+fcXAn4Jc267dQIMrItZu8i4yNEmcmFSMk2JfL/Q1qlbGZvyhaLgCCFq9HJQPbId Vq0WAb/lGZY0cmvFizrU7X3WxmiA9esdKzUD4aLqskbRrMH4pFPyoCeI8twpI2RxQLkF qnnb5dS4818dX2bZ9X/uXHsYpCnJ75srWuvSp8D+NwB/WoSFZnOam3v+hW5fLPEud4v1 uMQw== X-Gm-Message-State: AOJu0Yz1ohq+iaerwL8UPYeIz6+FTIAGNr3DWhRfV1epuCDUoQK5ajqj ePGDpI1cU1UldsKb+ghn/mwqRfH2EijVESRjD7zuEiG4Xo/iP+eyceWw9YgApLgHY3oj6nxzfTk = X-Google-Smtp-Source: AGHT+IEemPcHCzneBQ2LN1NYHNpP9iPDwNmQ8qR5MtXty/HpN3B/rmFG+l3d+UAx6jbLaq0hJyG+AA== X-Received: by 2002:a05:600c:3555:b0:410:61ce:f5c3 with SMTP id i21-20020a05600c355500b0041061cef5c3mr5453655wmq.19.1707742438328; Mon, 12 Feb 2024 04:53:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXD9gvlE/YKV/DqFTKJZ3cNvsnJambtTG3sUz1PYinFr9oBn8t7KnNa/npJJ2/PlH1JL2fswvNNo0RMPqJIC/YRrjUJjiFBzJbeDoyIzbp8qQ== Message-ID: <53bb631d-134c-4670-8bc2-aa5b5c4b558a@suse.com> Date: Mon, 12 Feb 2024 13:53:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] x86/MCE: adjust x86_mc_get_cpu_info() Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: <4c4ff91e-ce66-428f-a360-6ffc55659e79@suse.com> Autocrypt: addr=jbeulich@su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IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <4c4ff91e-ce66-428f-a360-6ffc55659e79@suse.com> Move logic independent of c->apicid's initialization status out of the if/else, leveraging that cpu_data[] now doesn't start out zero- initialized. Constify c and have it have an initializer. Signed-off-by: Jan Beulich --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -992,21 +992,14 @@ void x86_mc_get_cpu_info(unsigned cpu, u unsigned *ncores, unsigned *ncores_active, unsigned *nthreads) { - struct cpuinfo_x86 *c; + const struct cpuinfo_x86 *c = &cpu_data[cpu]; *apicid = cpu_physical_id(cpu); - c = &cpu_data[cpu]; if ( c->apicid == BAD_APICID ) { *chipid = cpu; *coreid = 0; *threadid = 0; - if ( ncores != NULL ) - *ncores = 1; - if ( ncores_active != NULL ) - *ncores_active = 1; - if ( nthreads != NULL ) - *nthreads = 1; } else { @@ -1016,13 +1009,16 @@ void x86_mc_get_cpu_info(unsigned cpu, u else *coreid = 0; *threadid = c->apicid & ((1 << (c->x86_num_siblings - 1)) - 1); - if ( ncores != NULL ) - *ncores = c->x86_max_cores; - if ( ncores_active != NULL ) - *ncores_active = c->booted_cores; - if ( nthreads != NULL ) - *nthreads = c->x86_num_siblings; } + + if ( ncores ) + *ncores = c->x86_max_cores ?: 1; + + if ( ncores_active ) + *ncores_active = c->booted_cores ?: 1; + + if ( nthreads ) + *nthreads = c->x86_num_siblings ?: 1; } #define INTPOSE_NENT 50