From patchwork Mon Jul 17 23:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121665 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406052vqt; Mon, 17 Jul 2023 16:36:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0z0P3gce4QXSFPsXQ3Sgfgk/u/IqdLe7F5zwrn3fC5b2ipq/ags17YFw029kqfTU337tP X-Received: by 2002:a05:6a20:5487:b0:134:ceb7:6dfa with SMTP id i7-20020a056a20548700b00134ceb76dfamr4357244pzk.49.1689637010136; Mon, 17 Jul 2023 16:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637010; cv=none; d=google.com; s=arc-20160816; b=yR0TVxuYomx+Dm93FFEa+DM+1aLAyJ07KwR2L+nmu1xR15DWrFn3oXeYUSwElCEjfp JmHTpNcFX0lpmmixD/5vAW9gksOSphiZo9ppKuPqjeU6/zoaTs/9sYtug8BJ/ktRzJbe /dj1IiimoJIRI4zDWXmLmL1godYarP/VjKhNh84S3IM/Pq4sbdHUOOpIgcoxe86ll8iJ 6yOgkwbhTkWVMq1x8BF5Q2n/Nl48DhFAd4RgSftzmQHuJvdHF/IQIpwmvb4WkR4ucGnM F9oHtLbndtTFsrdZoj0RiDjiwRx7AUNBNz2IleDw62pzibf2HZ9czLcdJ2oAV+6+UeNC K+/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=M0jSiCsQ7CMtXtLpUe8NnWl6LgxPIdT2LQPqXY/B010=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=HF4onLPv91pK8OjWiPk2Zcvfh3ydvjznTAGs1C6WEFKGBNU8qXEs45jVqrRllJEVlH uPzYZkIZBdRYQE259Qe7W8TnhY5XwnvF390bozBVKHnxqJ6Gv0VxquAyWBCxAKNlbE6u rbJxAfciP7FmvtJaNWVVxBMWgfRPIQ9g54+mUo/kuqUZmIxFXcL5KMrSf9om22M/cE5w ChEpbdY3+Wo30neqSOQUVvsvos2M/P177sXZXvCUHJ/gLdLq1Xv1GHB19F5rG1A1tA+D GtxGagBuS53HbLkWlMTq84b+caknC2+EewM+e1aZ2dNRZmtHsH8G/uP/32jxmDJyFIB9 SQTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ERBnEIn7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0FkHf1ad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a170902ea0a00b001b8a840e783si608643plg.442.2023.07.17.16.36.37; Mon, 17 Jul 2023 16:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ERBnEIn7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0FkHf1ad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231263AbjGQXOp (ORCPT + 99 others); Mon, 17 Jul 2023 19:14:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbjGQXOo (ORCPT ); Mon, 17 Jul 2023 19:14:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 504CF10B for ; Mon, 17 Jul 2023 16:14:38 -0700 (PDT) Message-ID: <20230717223223.133987570@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=M0jSiCsQ7CMtXtLpUe8NnWl6LgxPIdT2LQPqXY/B010=; b=ERBnEIn79Bu9QSKIoMn+fHdK4gIfX8KEiTmh8bJE5iNHtOcSS3NkSFTc3RZ9wQTc+ZVw9O SIUDyRXPWb/iERKMUtrU1NWucmjEASGwGp0XcRWJVpREbAm1ftrSAdFRyOkFrQ0MVgL99s Lcncxdpx2p16ogw8Kr/7+DET0U9sW7ILHBUgpKXhhsxKgAdx81lvKLX8oFMxxrw2SWqQAD V+u40tZiRwS0Av9AZppWlIrYOQCLLNit/kzeF5O7eq3d8+32O4IM8kwA6N8ra//WOBlPKx Yl8u536+11Z6SaynRB1HN4M5LwdMe721i+WMfbXN9bZH4wAFOA9b1cGx9EgKSw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=M0jSiCsQ7CMtXtLpUe8NnWl6LgxPIdT2LQPqXY/B010=; b=0FkHf1ads7F4traM8giao9RtwB8UYif28wOFycU0DCs5KlpAQXiirEv68DhTAkL9tSiOiP SYJTc5IDenMcAvBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 01/58] x86/cpu: Make identify_boot_cpu() static References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:35 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712817782958050 X-GMAIL-MSGID: 1771712817782958050 It's not longer used outside the source file. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/processor.h | 1 - arch/x86/kernel/cpu/common.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -190,7 +190,6 @@ static inline unsigned long long l1tf_pf } extern void early_cpu_init(void); -extern void identify_boot_cpu(void); extern void identify_secondary_cpu(struct cpuinfo_x86 *); extern void print_cpu_info(struct cpuinfo_x86 *); void print_cpu_msr(struct cpuinfo_x86 *); --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1937,7 +1937,7 @@ void enable_sep_cpu(void) } #endif -void __init identify_boot_cpu(void) +static __init void identify_boot_cpu(void) { identify_cpu(&boot_cpu_data); if (HAS_KERNEL_IBT && cpu_feature_enabled(X86_FEATURE_IBT)) From patchwork Mon Jul 17 23:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399120vqt; Mon, 17 Jul 2023 16:17:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFaV+UiVoS9VYojFHVII9hFwKI6j7ZBPcwPc477m2Ak1J9lSxf7ZSDD1Wuk7bQfwCpPXJ9p X-Received: by 2002:a05:6402:68e:b0:51e:17d:a1c3 with SMTP id f14-20020a056402068e00b0051e017da1c3mr11812380edy.32.1689635851478; Mon, 17 Jul 2023 16:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635851; cv=none; d=google.com; s=arc-20160816; b=ihzqMOtCjsg00oZyzCvmDWWRA7luUkk4sQt0N1BRPccAMmJdtGESLW6SgS1Gv1Z8A8 cREMXnO8cWL7GozVgUtGBiR5twlOQ6njWMd2B49Rp4PtJC9zoG4g3MHKhbh1wc2aXk22 33B5L+EZ9Du5ykw8FXCpw6vRdDbSUHxpmo5O/wL8+erqPqcaexRuky/BMNEl4wJeeay7 4K8ONX7wPEboXRwMvZzjywhELoU0ANykcyP7oq9GeX+km14rsV0w4Cz5aecfP1WXjXB5 L3IYQkLwjOLKl4i6fIQM54kyf4JXdMohkS/bkgEox9N9XmCRfDQBhStMV9VCLkifVO6X Kxlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=wpfpHOFENc3IPULGB99WSPXmdgySC90OqR7vmMwU8qU=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=V5UO4iKOyMYi5tZc+f6vRsHrROdCT3/bzCqiq9knQEJ/0GDX/b/6bG85KgpxQ8+URQ zDkFZ0As+bg1DVr9elP4cSca+vE+uMmwksvoBpj4ZF9lcZL8WMzcOLaf+kYDeDSXIQ/n 1dAn+aZXyt0NwEtz47QsFsqlp703L+Kp3WLPQ/4Vp8pqrtps7ie2lyunPrkWP5iwinxc dfF8HkLzg4rqSgT6xVAPfOB7eR9V0CeelkJMrzNrcNrteNlWUsULtd8FQo2qeWjUTIxH qmAV8dPEiMnWboBGwirXSCyCB9U0+QbTkMDLqsOP6Y2I6jxDcBHbv/FPuI3Wm63yViwx 0cEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qAJH9ZIn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZwLQueWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf22-20020a0564021a5600b0051bf8f889dbsi302512edb.448.2023.07.17.16.17.08; Mon, 17 Jul 2023 16:17:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qAJH9ZIn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ZwLQueWk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbjGQXOv (ORCPT + 99 others); Mon, 17 Jul 2023 19:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbjGQXOo (ORCPT ); Mon, 17 Jul 2023 19:14:44 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B887E12D for ; Mon, 17 Jul 2023 16:14:38 -0700 (PDT) Message-ID: <20230717223223.194942624@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wpfpHOFENc3IPULGB99WSPXmdgySC90OqR7vmMwU8qU=; b=qAJH9ZInd6QS57kqU21jjx7PhuqHsepVuGll5ofOEwQWJL1/sFLOnjZ34EBGsJwJWbKvpY wv+zh4cBYwLIzYXEPvnhIHZg8F86wcIdAl2xh8iRVq8plyF22kHCi4ZU5rD9mh8u3+yc2b BcKn8m/oiYwct7zjwIhDevHX2StrtmZzarP6GQkFUqkwqnZTYA+OqDymMH05RTuF2sGRk6 aiqek6XxC65mA9bJ3Klc1FP49ItANn3puhn0SNDgV4UcNPTKDCzKQNOF0vdJGr65iPfrHN bjDQkqSbexkWzcb/BN7wQYYsrxxFtUXSHylPl74uFG92tSDMrZ6GD6rfXRnK5Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wpfpHOFENc3IPULGB99WSPXmdgySC90OqR7vmMwU8qU=; b=ZwLQueWk3iuye6RCxPL7GI5eQfeQLFp/Cmp+9F4jdovHOSbJt2O3OGatSO5ru7KKSf09oo qoIwD8KcUbsW+VBA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 02/58] x86/cpu: Remove unused physid_*() nonsense References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:36 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711602511947998 X-GMAIL-MSGID: 1771711602511947998 Tons of silly unused bitmap wrappers... Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/mpspec.h | 26 -------------------------- 1 file changed, 26 deletions(-) --- a/arch/x86/include/asm/mpspec.h +++ b/arch/x86/include/asm/mpspec.h @@ -87,13 +87,7 @@ struct physid_mask { typedef struct physid_mask physid_mask_t; #define physid_set(physid, map) set_bit(physid, (map).mask) -#define physid_clear(physid, map) clear_bit(physid, (map).mask) #define physid_isset(physid, map) test_bit(physid, (map).mask) -#define physid_test_and_set(physid, map) \ - test_and_set_bit(physid, (map).mask) - -#define physids_and(dst, src1, src2) \ - bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_LOCAL_APIC) #define physids_or(dst, src1, src2) \ bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_LOCAL_APIC) @@ -101,29 +95,9 @@ typedef struct physid_mask physid_mask_t #define physids_clear(map) \ bitmap_zero((map).mask, MAX_LOCAL_APIC) -#define physids_complement(dst, src) \ - bitmap_complement((dst).mask, (src).mask, MAX_LOCAL_APIC) - #define physids_empty(map) \ bitmap_empty((map).mask, MAX_LOCAL_APIC) -#define physids_equal(map1, map2) \ - bitmap_equal((map1).mask, (map2).mask, MAX_LOCAL_APIC) - -#define physids_weight(map) \ - bitmap_weight((map).mask, MAX_LOCAL_APIC) - -#define physids_shift_right(d, s, n) \ - bitmap_shift_right((d).mask, (s).mask, n, MAX_LOCAL_APIC) - -#define physids_shift_left(d, s, n) \ - bitmap_shift_left((d).mask, (s).mask, n, MAX_LOCAL_APIC) - -static inline unsigned long physids_coerce(physid_mask_t *map) -{ - return map->mask[0]; -} - static inline void physids_promote(unsigned long physids, physid_mask_t *map) { physids_clear(*map); From patchwork Mon Jul 17 23:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406204vqt; Mon, 17 Jul 2023 16:37:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHl1p22ji80ywzRWY+wB+z8EFAhDiuPezQaOVBcQ685D7YmO1IGawXD7Ah0Yw2gmDyGjw29 X-Received: by 2002:a05:6a21:6da6:b0:135:7f9:a56c with SMTP id wl38-20020a056a216da600b0013507f9a56cmr3450026pzb.24.1689637040082; Mon, 17 Jul 2023 16:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637040; cv=none; d=google.com; s=arc-20160816; b=hGY8y64GHGbzIwXzKeQlvds4NLNp+6r0WnnrolxclLYk65smc3JaF91ECIds30QrJE S4TEUpJWv5UmRXFyw+kXhKxRf8FImdsN0gBZ1UyAeuHytR97xaC1fTfg6uHUBAwrAhKa pcS9B4z5awDgMBsk73yX53hWbU4yuEiQm4JXo92hsR2EzKActBjX8giACDCa+3wB4Fdh QfOIr+WzXew4tDH1wl1MxsgxeJ4vpXvImBoT4vkjWucSVYyeVCScp2ygoN3mE20M3/wU dEt45PCvOF2gIHt5q1SFR57bYgOc3egrmXbQM0AsCkJLMKNxdbDYlzHGk4AqBA+al0QH HvMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=kmGoR4mtRRMrd4AtT9GP/yyIU8+rEj6XhsXhXl097vA=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=nucRrs8O6gPZpYa4ljCLD8z6Rwn2/xg9ev9NEy3CzAGfO/M0D6gbjHwGfJdlhuTUn6 jyaT1qI7MUaVHP84aUA+NMjh3lcG0fAHPGhgebbWM6d+0h+1aj7WcLfCS+j96SDX8Z9J th6fUg8RMLJkrswF3g5otrJglFgR/Z2c4XwfjqOnorxWfUfem5jHwY+x03M8cNZbeabR XuWN1ghpjhM7FGk9qSBzzUDpSjHD+8OjfLzrRpKkzeOoQ9pzlBC1sbygrUJcwRKv8YRd m7mrQyJeV2CebUj+WxzRkfwFEYAxal70iYp5LoWafCjbjcg1enfG5vhBM2WwPyA3mAtw 1Z3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="OYTaewL/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170902d88800b001ac6d4e1d72si604774plz.149.2023.07.17.16.37.06; Mon, 17 Jul 2023 16:37:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="OYTaewL/"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231337AbjGQXO4 (ORCPT + 99 others); Mon, 17 Jul 2023 19:14:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbjGQXOr (ORCPT ); Mon, 17 Jul 2023 19:14:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F9D8134 for ; Mon, 17 Jul 2023 16:14:41 -0700 (PDT) Message-ID: <20230717223223.254985852@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=kmGoR4mtRRMrd4AtT9GP/yyIU8+rEj6XhsXhXl097vA=; b=OYTaewL/r1krBi7/RMUewtLpZAjjdK8XBzCYSA3e5FoFsCHBjhcV/w1LBCVXCMJG6oHkzU nKqRcxARz3gVxzT6vDFby5/k2C5NJqbfr8X3v6Fq1hfde7WihAiL/sQIgrCxVrCBSrrkIh 7C3KILzRfvkaXWsOH1EzeaBltlzdTW2tgIrF1fMMzzclfXw17n3v8a2gCVENjdFDg/8h9I nPkkY44s4LLmNEDoiKgvSrra84aKFxIFUp37j8dFkxb+lRzgAr5exn/FdqKt3yxBVZSdHP 1nBxuqJQM1DqM/+BppMCSQpjoY9oRYIx3M2Fy3C+dswONZtvhbAbaFKp18/1aQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=kmGoR4mtRRMrd4AtT9GP/yyIU8+rEj6XhsXhXl097vA=; b=iXr/4XntnkHqmSiW/g8fdw+oCcu+dignGQiY50w41sNM4KD3aEUwLpm3pwHjaG0hkciWc1 qUyDCuAm/fm+YgAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 03/58] x86/apic: Rename disable_apic References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:38 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712848555073656 X-GMAIL-MSGID: 1771712848555073656 It reflects a state and not a command. Make it bool while at it. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 4 ++-- arch/x86/kernel/apic/apic.c | 22 +++++++++++----------- arch/x86/kernel/apic/apic_noop.c | 6 +++--- arch/x86/kernel/apic/msi.c | 2 +- arch/x86/kernel/apic/vector.c | 2 +- arch/x86/kernel/setup.c | 2 +- arch/x86/pci/xen.c | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -52,7 +52,7 @@ static inline void generic_apic_probe(vo extern int apic_verbosity; extern int local_apic_timer_c2_ok; -extern int disable_apic; +extern bool apic_is_disabled; extern unsigned int lapic_timer_period; extern int cpuid_to_apicid[]; @@ -90,7 +90,7 @@ static inline void default_inquire_remot */ static inline bool apic_from_smp_config(void) { - return smp_found_config && !disable_apic; + return smp_found_config && !apic_is_disabled; } /* --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -180,7 +180,7 @@ static __init int setup_apicpmtimer(char #endif unsigned long mp_lapic_addr __ro_after_init; -int disable_apic __ro_after_init; +bool apic_is_disabled __ro_after_init; /* Disable local APIC timer from the kernel commandline or via dmi quirk */ static int disable_apic_timer __initdata; /* Local APIC timer works in C2 */ @@ -810,7 +810,7 @@ bool __init apic_needs_pit(void) return true; /* Is there an APIC at all or is it disabled? */ - if (!boot_cpu_has(X86_FEATURE_APIC) || disable_apic) + if (!boot_cpu_has(X86_FEATURE_APIC) || apic_is_disabled) return true; /* @@ -1299,7 +1299,7 @@ enum apic_intr_mode_id apic_intr_mode __ static int __init __apic_intr_mode_select(void) { /* Check kernel option */ - if (disable_apic) { + if (apic_is_disabled) { pr_info("APIC disabled via kernel command line\n"); return APIC_PIC; } @@ -1308,7 +1308,7 @@ static int __init __apic_intr_mode_selec #ifdef CONFIG_X86_64 /* On 64-bit, the APIC must be integrated, Check local APIC only */ if (!boot_cpu_has(X86_FEATURE_APIC)) { - disable_apic = 1; + apic_is_disabled = true; pr_info("APIC disabled by BIOS\n"); return APIC_PIC; } @@ -1317,14 +1317,14 @@ static int __init __apic_intr_mode_selec /* Neither 82489DX nor integrated APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC) && !smp_found_config) { - disable_apic = 1; + apic_is_disabled = true; return APIC_PIC; } /* If the BIOS pretends there is an integrated APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC) && APIC_INTEGRATED(boot_cpu_apic_version)) { - disable_apic = 1; + apic_is_disabled = true; pr_err(FW_BUG "Local APIC %d not detected, force emulation\n", boot_cpu_physical_apicid); return APIC_PIC; @@ -1567,7 +1567,7 @@ static void setup_local_APIC(void) int cpu = smp_processor_id(); unsigned int value; - if (disable_apic) { + if (apic_is_disabled) { disable_ioapic_support(); return; } @@ -1943,7 +1943,7 @@ void __init check_x2apic(void) pr_err("Kernel does not support x2APIC, please recompile with CONFIG_X86_X2APIC.\n"); pr_err("Disabling APIC, expect reduced performance and functionality.\n"); - disable_apic = 1; + apic_is_disabled = true; setup_clear_cpu_cap(X86_FEATURE_APIC); } @@ -2037,7 +2037,7 @@ int __init apic_force_enable(unsigned lo { u32 h, l; - if (disable_apic) + if (apic_is_disabled) return -1; /* @@ -2064,7 +2064,7 @@ int __init apic_force_enable(unsigned lo static int __init detect_init_APIC(void) { /* Disabled by kernel option? */ - if (disable_apic) + if (apic_is_disabled) return -1; switch (boot_cpu_data.x86_vendor) { @@ -2919,7 +2919,7 @@ int apic_is_clustered_box(void) */ static int __init setup_disableapic(char *arg) { - disable_apic = 1; + apic_is_disabled = true; setup_clear_cpu_cap(X86_FEATURE_APIC); return 0; } --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -71,13 +71,13 @@ static int noop_apic_id_registered(void) static u32 noop_apic_read(u32 reg) { - WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic); + WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled); return 0; } -static void noop_apic_write(u32 reg, u32 v) +static void noop_apic_write(u32 reg, u32 val) { - WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic); + WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled); } #ifdef CONFIG_X86_32 --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -269,7 +269,7 @@ static const struct msi_parent_ops x86_v struct irq_domain * __init native_create_pci_msi_domain(void) { - if (disable_apic) + if (apic_is_disabled) return NULL; x86_vector_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -536,7 +536,7 @@ static int x86_vector_alloc_irqs(struct struct irq_data *irqd; int i, err, node; - if (disable_apic) + if (apic_is_disabled) return -ENXIO; /* --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1020,7 +1020,7 @@ void __init setup_arch(char **cmdline_p) if (acpi_mps_check()) { #ifdef CONFIG_X86_LOCAL_APIC - disable_apic = 1; + apic_is_disabled = true; #endif setup_clear_cpu_cap(X86_FEATURE_APIC); } --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -517,7 +517,7 @@ int __init pci_xen_init(void) #ifdef CONFIG_PCI_MSI static void __init xen_hvm_msi_init(void) { - if (!disable_apic) { + if (!apic_is_disabled) { /* * If hardware supports (x2)APIC virtualization (as indicated * by hypervisor's leaf 4) then we don't need to use pirqs/ From patchwork Mon Jul 17 23:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121684 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407392vqt; Mon, 17 Jul 2023 16:41:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHqBsFts3HiTWISmhTvxkbmA5hz6/N7lnQ3uSgMxDFblawh9ddUXZpwMiFlNyzNsehd6xAE X-Received: by 2002:a05:6808:2027:b0:398:9ee4:1dac with SMTP id q39-20020a056808202700b003989ee41dacmr15654035oiw.32.1689637277071; Mon, 17 Jul 2023 16:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637277; cv=none; d=google.com; s=arc-20160816; b=YEy3J6ZqI2Gd+c8qpSt/esvsyYZm7OO+Wtae8VIHyrXjexc+dp4Hx7qxVEbM83sDuX 909zPJLx2CN7WLU8ZGpO9iz6OwMuXpOZxmSRHtXrR4MVWVTQDunW7kxl8220njnTG46U c5dEiPPsmemXMVe13CnC0Dzhss1cpE9XcVJe9mGFOirzLRN6MFlX3Bpv/FVlzQ0/PV1q +eC5hzlRSUPTC0tsTkhtO8DX5vWuHQtxCfmFC8nZD0xk3cl6fcCT9Yfvn7IFYfU2Fns4 2xt+2/Kmec7i6V497zjOzOZ6f16eUU25YZrmBWP+mZ3oMNF79OtaNC7fnGfwHbcjz9Xa //VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=F/lkmcLew6wqhkY5nJAZg4imK+gggfMNV+OuyUmPL8o=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=xRBO96dD4Mha+mbnnbf9DX69GCRdFg1DFkXaK3N3pesEtCzWVPnWOUIYF/gqVh7RUF 6h5thRnLQ3gNt5uBoeFxCnTR+4pVCLcW1dAD2tF0o0Ot6uK5ra9hIVs0aBEZ+tl16BpI m06nmvfyXGACAu8I3uhrHhbySOQIkt2t7Esh+3EsBe6H/6gpR3G9yBnxYrQ4HYjTR73b jRgEUWYNKHI+/5bR3Leiy5+0UVMlTmabV7a2Wjcqg4v3xrjHa9Hlnu6WTg8mUyq+B2o3 UK3x7IdQsSFY2ZDAEXZsDNSlxdhzVEOde3uRVBjyqLVXXYgEwEYGvt0cXCjtHjswRuCW 5DQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uiFj6CC6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6300c2000000b005347c4d09ddsi538054pga.678.2023.07.17.16.41.04; Mon, 17 Jul 2023 16:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uiFj6CC6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231328AbjGQXOy (ORCPT + 99 others); Mon, 17 Jul 2023 19:14:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbjGQXOr (ORCPT ); Mon, 17 Jul 2023 19:14:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C81DEE for ; Mon, 17 Jul 2023 16:14:42 -0700 (PDT) Message-ID: <20230717223223.317323519@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=F/lkmcLew6wqhkY5nJAZg4imK+gggfMNV+OuyUmPL8o=; b=uiFj6CC6v/py1Hit7tvREfXSrDdl8w9xO+wN+Mr35tSIF1WJcillzcqndfYZoFIS0Cq70f KknJhHr/Gg0MnpqRg7Y+BKELgG0auUUjoI5EWKq6gya8zPlSk7ItJIJlOjwUa/gJseRkUl DFR/Cv6jmYuOGVLd3G8PtS+XoI6wd2XMs5E5Zo++suwaI9psUn/Mw3CJfKX2lvfEyVzGGy OAyuzEXqzu/q8ir/hX/zn2Oako1xwQfnIOpFYBQAws1nhDCou1bOAEpznPWAcnvz7/77a3 GmAsk+/TkC42G7PC4UYZN4FUnY7Y1x1HQC9maw47xRi2e9FmnUk5SLRhhrxdoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=F/lkmcLew6wqhkY5nJAZg4imK+gggfMNV+OuyUmPL8o=; b=q2ghj+d5WmJExyAmN1P51i1+vZOwEurdMplxcG6ahp9nlsJkce/+Jg1dyUz0JTjqhDCpi4 HFhQmyOcsOXn+8Aw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 04/58] x86/apic/ioapic: Rename skip_ioapic_setup References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:40 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713097356336903 X-GMAIL-MSGID: 1771713097356336903 Another variable name which is confusing at best. Convert to bool. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/io_apic.h | 7 ++++--- arch/x86/kernel/acpi/boot.c | 2 +- arch/x86/kernel/apic/apic.c | 12 ++++++------ arch/x86/kernel/apic/io_apic.c | 12 ++++++------ arch/x86/xen/smp_pv.c | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) --- a/arch/x86/include/asm/io_apic.h +++ b/arch/x86/include/asm/io_apic.h @@ -109,8 +109,8 @@ extern int mp_irq_entries; /* MP IRQ source entries */ extern struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES]; -/* 1 if "noapic" boot option passed */ -extern int skip_ioapic_setup; +/* True if "noapic" boot option passed */ +extern bool ioapic_is_disabled; /* 1 if "noapic" boot option passed */ extern int noioapicquirk; @@ -129,7 +129,7 @@ extern unsigned long io_apic_irqs; * assignment of PCI IRQ's. */ #define io_apic_assign_pci_irqs \ - (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs) + (mp_irq_entries && !ioapic_is_disabled && io_apic_irqs) struct irq_cfg; extern void ioapic_insert_resources(void); @@ -179,6 +179,7 @@ extern void print_IO_APICs(void); #define IO_APIC_IRQ(x) 0 #define io_apic_assign_pci_irqs 0 #define setup_ioapic_ids_from_mpc x86_init_noop +#define nr_ioapics (0) static inline void ioapic_insert_resources(void) { } static inline int arch_early_ioapic_init(void) { return 0; } static inline void print_IO_APICs(void) {} --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1275,7 +1275,7 @@ static int __init acpi_parse_madt_ioapic /* * if "noapic" boot option, don't look for IO-APICs */ - if (skip_ioapic_setup) { + if (ioapic_is_disabled) { pr_info("Skipping IOAPIC probe due to 'noapic' option.\n"); return -ENODEV; } --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1691,7 +1691,7 @@ static void setup_local_APIC(void) * TODO: set up through-local-APIC from through-I/O-APIC? --macro */ value = apic_read(APIC_LVT0) & APIC_LVT_MASKED; - if (!cpu && (pic_mode || !value || skip_ioapic_setup)) { + if (!cpu && (pic_mode || !value || ioapic_is_disabled)) { value = APIC_DM_EXTINT; apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", cpu); } else { @@ -1956,7 +1956,7 @@ void __init enable_IR_x2apic(void) unsigned long flags; int ret, ir_stat; - if (skip_ioapic_setup) { + if (ioapic_is_disabled) { pr_info("Not enabling interrupt remapping due to skipped IO-APIC setup\n"); return; } @@ -2956,11 +2956,11 @@ early_param("nolapic_timer", parse_nolap static int __init apic_set_verbosity(char *arg) { if (!arg) { -#ifdef CONFIG_X86_64 - skip_ioapic_setup = 0; + if (IS_ENABLED(CONFIG_X86_32)) + return -EINVAL; + + ioapic_is_disabled = false; return 0; -#endif - return -EINVAL; } if (strcmp("debug", arg) == 0) --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -178,7 +178,7 @@ int mp_bus_id_to_type[MAX_MP_BUSSES]; DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES); -int skip_ioapic_setup; +bool ioapic_is_disabled __ro_after_init; /** * disable_ioapic_support() - disables ioapic support at runtime @@ -189,7 +189,7 @@ void disable_ioapic_support(void) noioapicquirk = 1; noioapicreroute = -1; #endif - skip_ioapic_setup = 1; + ioapic_is_disabled = true; } static int __init parse_noapic(char *str) @@ -831,7 +831,7 @@ static int __acpi_get_override_irq(u32 g { int ioapic, pin, idx; - if (skip_ioapic_setup) + if (ioapic_is_disabled) return -1; ioapic = mp_find_ioapic(gsi); @@ -1366,7 +1366,7 @@ void __init enable_IO_APIC(void) int i8259_apic, i8259_pin; int apic, pin; - if (skip_ioapic_setup) + if (ioapic_is_disabled) nr_ioapics = 0; if (!nr_legacy_irqs() || !nr_ioapics) @@ -2399,7 +2399,7 @@ void __init setup_IO_APIC(void) { int ioapic; - if (skip_ioapic_setup || !nr_ioapics) + if (ioapic_is_disabled || !nr_ioapics) return; io_apic_irqs = nr_legacy_irqs() ? ~PIC_IRQS : ~0UL; @@ -2715,7 +2715,7 @@ void __init io_apic_init_mappings(void) "address found in MPTABLE, " "disabling IO/APIC support!\n"); smp_found_config = 0; - skip_ioapic_setup = 1; + ioapic_is_disabled = true; goto fake_ioapic_page; } #endif --- a/arch/x86/xen/smp_pv.c +++ b/arch/x86/xen/smp_pv.c @@ -209,7 +209,7 @@ static void __init xen_pv_smp_prepare_cp { unsigned cpu; - if (skip_ioapic_setup) { + if (ioapic_is_disabled) { char *m = (max_cpus == 0) ? "The nosmp parameter is incompatible with Xen; " \ "use Xen dom0_max_vcpus=1 parameter" : From patchwork Mon Jul 17 23:14:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121669 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406162vqt; Mon, 17 Jul 2023 16:37:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlHRdVE5nHweKV6eQsTuUHj8lzEzMyhALUgOrphm8ZDOlBR5Zq9FmwSfNUKDx9gTU2htdHcy X-Received: by 2002:a05:6a00:22cc:b0:64f:7a9c:cb15 with SMTP id f12-20020a056a0022cc00b0064f7a9ccb15mr14117317pfj.11.1689637030935; Mon, 17 Jul 2023 16:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637030; cv=none; d=google.com; s=arc-20160816; b=kMwJIddL2TQDhRlSo88F60oARR2AkBqVtXuWuAYDJ+XfyZETXnI+8v5GIrLhgOtKKP xpaIGljJvmR12xKaITuRmn7zFZbMk4dS0rRwU3cQDJMSjAp0B6QLqqFkYBdP7RlSCBDA 8rqzW+V2gFsluHNYbn/0ZBb5RVzDBQh6Z6uVdSBeJ5FvdFHUNvuisorDxJVnunDHgoGI ufcIGXdt0AqIeUsnqFEMlNMHYtX3GQENpgQv9aGgG7HvdB3hfFOOdme1yyxHDAdLklL2 sLCgbBQm57EyZGdaqK+PcSUVhB25B2qWJTQm+WK9IntNJLixYDrabpayYL0ptenDVY7J hACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=sgp4Cpxc278kVycdX9SIuNrsT7R7GKw0D1ebmk2Yzdc=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=gBgQ4bJsa5d0mk/bJwqGtdPKPTrBhYUiFm4vRbBnHiTkNQeoySj5T/xrI+xtofPwAp t0RNQcXTbKCT7jzUeHVDUfXOGoBueqUYDGaKa3fsCjbEuroWPEQpr8+jcLusqN48x7EY UGFJJb9zIWd+IaeWhnuP7BFXpaesrC1//Cr93XxrlcH/8HTITVbhCm+ckOgtREGD32Ed 5E2HpM4qTtuDyf3osWWcxduvrriD5/KBUK6GOSEuk4nETnS0jNgllnxvohj+zgxJdK30 jHsAcs7cKdzAR48ditsPTQPmvOAXBVKQCLk5wsIab+bT9AVskqLAoCOJPc1C/PbkBrng EdzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0q4LFQnJ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020a056a00125300b0066871b54e15si535888pfi.359.2023.07.17.16.36.58; Mon, 17 Jul 2023 16:37:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0q4LFQnJ; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230274AbjGQXO7 (ORCPT + 99 others); Mon, 17 Jul 2023 19:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231288AbjGQXOt (ORCPT ); Mon, 17 Jul 2023 19:14:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F070D103 for ; Mon, 17 Jul 2023 16:14:43 -0700 (PDT) Message-ID: <20230717223223.378340278@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=sgp4Cpxc278kVycdX9SIuNrsT7R7GKw0D1ebmk2Yzdc=; b=0q4LFQnJjpYRlnTDc8bZdTei1OzL5wuMK4xXXo1j3y7tjv7rh1PJipNPrk50e/vgGo2431 3tqtsT/EHzNnuIMOHa/8TEqxXMCiwGxNSoAGaVs4GDOmOFvEuihtXhgu+DjnwuhePZTFWU 0CzHimOzSBgJA5Q4wJU2WxpKEu0vRBTcGxuf1AGBgyXNfnvOLwc6L9y8jy2XS1ZyvRIGpf feA1F/N1VH4NG3n9cygptFjkz0wM7tj/W+PscLcAHXgXz5hM/3adFm3KKfBwD+ckLOmGrb fvzWECWgppZK/OhhRycITP0+G7ekmutGZ7l8ZrJ07x8sWmqaSj+qmhc5YfVCGg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=sgp4Cpxc278kVycdX9SIuNrsT7R7GKw0D1ebmk2Yzdc=; b=I2LneLJvvSILrQQSkCNlZLnjLon4cEtxb5pZSW/6MvTU7z2qiRk0/0FHavygX9Y6fBbf4g xR4yntUdN4xtIcBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 05/58] x86/apic: Remove pointless x86_bios_cpu_apicid References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:41 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712839617861524 X-GMAIL-MSGID: 1771712839617861524 It's a useless copy of x86_cpu_to_apicid. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 -- arch/x86/include/asm/smp.h | 1 - arch/x86/kernel/apic/apic.c | 5 +---- arch/x86/kernel/apic/apic_common.c | 2 +- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/probe_64.c | 4 +--- arch/x86/kernel/setup_percpu.c | 3 --- 7 files changed, 4 insertions(+), 15 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -477,8 +477,6 @@ extern void generic_bigsmp_probe(void); #define APIC_DFR_VALUE (APIC_DFR_FLAT) -DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid); - extern struct apic apic_noop; static inline unsigned int read_apic_id(void) --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -22,7 +22,6 @@ DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid); DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid); -DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid); #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid); #endif --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -108,10 +108,8 @@ unsigned long apic_mmio_base __ro_after_ * Map cpu index to physical APIC ID */ DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid, BAD_APICID); -DEFINE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_bios_cpu_apicid, BAD_APICID); DEFINE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid, U32_MAX); EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_apicid); -EXPORT_EARLY_PER_CPU_SYMBOL(x86_bios_cpu_apicid); EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid); #ifdef CONFIG_X86_32 @@ -2511,7 +2509,7 @@ int generic_processor_info(int apicid, i if (apicid == boot_cpu_physical_apicid) { /* - * x86_bios_cpu_apicid is required to have processors listed + * x86_cpu_to_apicid is required to have processors listed * in same order as logical cpu numbers. Hence the first * entry is BSP, and so on. * boot_cpu_init() already hold bit 0 in cpu_present_mask @@ -2548,7 +2546,6 @@ int generic_processor_info(int apicid, i #if defined(CONFIG_SMP) || defined(CONFIG_X86_64) early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; - early_per_cpu(x86_bios_cpu_apicid, cpu) = apicid; #endif #ifdef CONFIG_X86_32 early_per_cpu(x86_cpu_to_logical_apicid, cpu) = --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -29,7 +29,7 @@ void default_ioapic_phys_id_map(physid_m int default_cpu_present_to_apicid(int mps_cpu) { if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu)) - return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu); + return (int)per_cpu(x86_cpu_to_apicid, mps_cpu); else return BAD_APICID; } --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -52,7 +52,7 @@ static void bigsmp_setup_apic_routing(vo static int bigsmp_cpu_present_to_apicid(int mps_cpu) { if (mps_cpu < nr_cpu_ids) - return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu); + return (int) per_cpu(x86_cpu_to_apicid, mps_cpu); return BAD_APICID; } --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -13,9 +13,7 @@ #include "local.h" -/* - * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. - */ +/* Select the appropriate APIC driver */ void __init default_setup_apic_routing(void) { struct apic **drv; --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c @@ -181,8 +181,6 @@ void __init setup_per_cpu_areas(void) #ifdef CONFIG_X86_LOCAL_APIC per_cpu(x86_cpu_to_apicid, cpu) = early_per_cpu_map(x86_cpu_to_apicid, cpu); - per_cpu(x86_bios_cpu_apicid, cpu) = - early_per_cpu_map(x86_bios_cpu_apicid, cpu); per_cpu(x86_cpu_to_acpiid, cpu) = early_per_cpu_map(x86_cpu_to_acpiid, cpu); #endif @@ -214,7 +212,6 @@ void __init setup_per_cpu_areas(void) /* indicate the early static arrays will soon be gone */ #ifdef CONFIG_X86_LOCAL_APIC early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; - early_per_cpu_ptr(x86_bios_cpu_apicid) = NULL; early_per_cpu_ptr(x86_cpu_to_acpiid) = NULL; #endif #ifdef CONFIG_X86_32 From patchwork Mon Jul 17 23:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1402265vqt; Mon, 17 Jul 2023 16:26:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlH2xzIR8WPtRILemrtzn1J35FOk0i2/3poGXJklb5fRoE5tNTX3VLjcmPHuH/qx11nhEuPq X-Received: by 2002:a05:6a20:144d:b0:132:bf3e:d643 with SMTP id a13-20020a056a20144d00b00132bf3ed643mr17287038pzi.5.1689636386423; Mon, 17 Jul 2023 16:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636386; cv=none; d=google.com; s=arc-20160816; b=Dhev5/g0w1OsbzRM60TNvR1r0sd0ygsx4MEIzhRJxqoGQ8EAENq/Rj6GxZamaexQB8 k6eXTyLQsn6ByW9objLb2OxtSBMaGzYr4xwu02kWCGMSHVXgXbDLrilayb5+6HOTDskj dHkwH4BbEuFqbFIlYftWqsqtEjlWu5HnIDAq1V7MeEvZafOZOTW9lwDfNIYM9tLqrO20 XS8ZVY8ncIi6KIrXL+c5D4Hxw8pp4eLtLZOXb5iRXG+2ATgW8kPM8QLTEZIM7kh1NaFO 7LRSZbHQgYjBO0Pm/wMSefwkBLn0eJzr3LwQoyM2EpEgd2UcUb8AdWSu1JJz835PMHRC woBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=H6xuaSb8Kv7Un+nSM3Vt2lhh8dacGbRBYIeoXvHjk4U=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=AhlGPj/FgSumjip1DvrZGxMfvk56rWbzEBtoKWPSt6wiDYKYxuWL3MCRHZ/lTP9w6h 9Ufhzpfb62/SNArO+0ZB650P2gIlE/JpV3VORqhplzEv+zG2jG6s4JI2UqdUTz+GV9kl /rLJY3ndkVXa9w3jyrueVx8b/oho3TphJdMkeQ861BZvZzLqzCGPNhFZedKvLnBfO8Bh 9YI4E4hIvLev5QHunThDBa7HrEJd1YDHowAQqKBa7hH4EZ7LVKgpsTx/vcAua1YHeL7U lN98BZMU4SURZPvoNK9lJq1VQT5PSStYKA0QewYR97Mpkbmd3hKQXb/mYEh72xCrm4dj Gf9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZJdVRLZP; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce11-20020a056a002a0b00b006826c5b86dasi508007pfb.364.2023.07.17.16.26.13; Mon, 17 Jul 2023 16:26:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZJdVRLZP; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231373AbjGQXPF (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbjGQXOu (ORCPT ); Mon, 17 Jul 2023 19:14:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4109D12D for ; Mon, 17 Jul 2023 16:14:46 -0700 (PDT) Message-ID: <20230717223223.438098301@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=H6xuaSb8Kv7Un+nSM3Vt2lhh8dacGbRBYIeoXvHjk4U=; b=ZJdVRLZPN67L2dDZ8WvxnfDEt6uQADsS5bnFlPHvH3ZRokAIdVrgaEVoGxFE5UMbpwyDpv nF4bEllwtYfNdLtVwXJ6jaBIatetjaRvX0m4A7FoTO/ZECJiJRRvxpwgxmGj9MMqZa4cYA N8tyvOa5T46kp31qUnrrsWwKICmDRC/lUQ5iXXNiIS1alfimY4XPDxpGeqyqG00EQUVMay yoQkOaCtTaaB9W8lw1zqtjQ+3L4fXyHeNOEZxlfNkxDdRlzV6OSf+VEkaITAn288LuxqTm TdMk2I16aIMyq1F78nBA7FpBp4ZEMPl45zL1Kcye9hJGHU1LmyqM6EbBdM8+Qg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635683; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=H6xuaSb8Kv7Un+nSM3Vt2lhh8dacGbRBYIeoXvHjk4U=; b=fz3+bO0FtQwi+qTH7NfLuuj8FqYv8Q2KtVMXfd2KDhSIJ3inQcicCkuFCsIh1GYw3WqUB5 STHbbuMJxXOwMeCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 06/58] x86/apic: Get rid of hard_smp_processor_id() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:43 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712163415524256 X-GMAIL-MSGID: 1771712163415524256 No point in having a wrapper around read_apic_id(). Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 6 +++++- arch/x86/include/asm/smp.h | 7 ------- arch/x86/kernel/apic/apic.c | 5 ----- arch/x86/kernel/apic/io_apic.c | 2 +- arch/x86/kernel/apic/ipi.c | 2 +- arch/x86/kernel/apic/vector.c | 2 +- arch/x86/kernel/cpu/amd.c | 2 +- arch/x86/kernel/cpu/hygon.c | 3 ++- arch/x86/kernel/smpboot.c | 10 +++++----- arch/x86/kernel/vsmp_64.c | 2 +- 10 files changed, 17 insertions(+), 24 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -503,7 +503,11 @@ extern void default_ioapic_phys_id_map(p extern int default_cpu_present_to_apicid(int mps_cpu); extern int default_check_phys_apicid_present(int phys_apicid); -#endif /* CONFIG_X86_LOCAL_APIC */ +#else /* CONFIG_X86_LOCAL_APIC */ + +static inline unsigned int read_apic_id(void) { return 0; } + +#endif /* !CONFIG_X86_LOCAL_APIC */ #ifdef CONFIG_SMP void apic_smt_update(void); --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -185,13 +185,6 @@ static inline struct cpumask *cpu_llc_sh extern unsigned disabled_cpus; -#ifdef CONFIG_X86_LOCAL_APIC -extern int hard_smp_processor_id(void); - -#else /* CONFIG_X86_LOCAL_APIC */ -#define hard_smp_processor_id() 0 -#endif /* CONFIG_X86_LOCAL_APIC */ - #ifdef CONFIG_DEBUG_NMI_SELFTEST extern void nmi_selftest(void); #else --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2562,11 +2562,6 @@ int generic_processor_info(int apicid, i return cpu; } -int hard_smp_processor_id(void) -{ - return read_apic_id(); -} - void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg, bool dmar) { --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2095,7 +2095,7 @@ static inline void __init unlock_ExtINT_ entry0 = ioapic_read_entry(apic, pin); clear_IO_APIC_pin(apic, pin); - apic_id = hard_smp_processor_id(); + apic_id = read_apic_id(); memset(&entry1, 0, sizeof(entry1)); entry1.dest_mode_logical = true; --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -320,7 +320,7 @@ int safe_smp_processor_id(void) if (!boot_cpu_has(X86_FEATURE_APIC)) return 0; - apicid = hard_smp_processor_id(); + apicid = read_apic_id(); if (apicid == BAD_APICID) return 0; --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -1150,7 +1150,7 @@ static void __init print_local_APIC(void u64 icr; pr_debug("printing local APIC contents on CPU#%d/%d:\n", - smp_processor_id(), hard_smp_processor_id()); + smp_processor_id(), read_apic_id()); v = apic_read(APIC_ID); pr_info("... APIC ID: %08x (%01x)\n", v, read_apic_id()); v = apic_read(APIC_LVR); --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -934,7 +934,7 @@ static void init_amd(struct cpuinfo_x86 set_cpu_cap(c, X86_FEATURE_FSRS); /* get apicid instead of initial apic id from cpuid */ - c->apicid = hard_smp_processor_id(); + c->apicid = read_apic_id(); /* K6s reports MCEs but don't actually have all the MSRs */ if (c->x86 < 6) --- a/arch/x86/kernel/cpu/hygon.c +++ b/arch/x86/kernel/cpu/hygon.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -300,7 +301,7 @@ static void init_hygon(struct cpuinfo_x8 set_cpu_cap(c, X86_FEATURE_REP_GOOD); /* get apicid instead of initial apic id from cpuid */ - c->apicid = hard_smp_processor_id(); + c->apicid = read_apic_id(); /* * XXX someone from Hygon needs to confirm this DTRT --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1220,11 +1220,11 @@ static void __init smp_sanity_check(void } #endif - if (!physid_isset(hard_smp_processor_id(), phys_cpu_present_map)) { + if (!physid_isset(read_apic_id(), phys_cpu_present_map)) { pr_warn("weird, boot CPU (#%d) not listed by the BIOS\n", - hard_smp_processor_id()); + read_apic_id()); - physid_set(hard_smp_processor_id(), phys_cpu_present_map); + physid_set(read_apic_id(), phys_cpu_present_map); } /* @@ -1234,7 +1234,7 @@ static void __init smp_sanity_check(void if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) { pr_notice("weird, boot CPU (#%d) not listed by the BIOS\n", boot_cpu_physical_apicid); - physid_set(hard_smp_processor_id(), phys_cpu_present_map); + physid_set(read_apic_id(), phys_cpu_present_map); } preempt_enable(); } @@ -1431,7 +1431,7 @@ early_param("possible_cpus", _setup_poss if (!num_processors) { if (boot_cpu_has(X86_FEATURE_APIC)) { int apicid = boot_cpu_physical_apicid; - int cpu = hard_smp_processor_id(); + int cpu = read_apic_id(); pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu); --- a/arch/x86/kernel/vsmp_64.c +++ b/arch/x86/kernel/vsmp_64.c @@ -129,7 +129,7 @@ static void __init vsmp_cap_cpus(void) static int apicid_phys_pkg_id(int initial_apic_id, int index_msb) { - return hard_smp_processor_id() >> index_msb; + return read_apic_id() >> index_msb; } static void vsmp_apic_post_init(void) From patchwork Mon Jul 17 23:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399218vqt; Mon, 17 Jul 2023 16:17:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFSzibfmXlCfp1kWZUjith+1tT0S8CeNlweG1arbz/CcHjRgoWwIv/htMmcL8OixBr2qi+S X-Received: by 2002:aa7:c74d:0:b0:51d:f37b:1b4e with SMTP id c13-20020aa7c74d000000b0051df37b1b4emr11205240eds.19.1689635863511; Mon, 17 Jul 2023 16:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635863; cv=none; d=google.com; s=arc-20160816; b=Z8H6GQ2laVvIkoBOP11VZm94h7UcorWjOg0oRfWaI5gmEo2vi6mIDeOH9rrLgOPFph xOx5A3mAUuwxKA10cRUn+jNyKQtgQQZgmN096HmBecnaR5akN58McdoNteorbOmWTKkh jv5FUlq3Y4MbRP5+hCuw/wr0hXPFsc4OrY5bAocr0NQop2qGiueHKNp8yLpg6VWRVgaR yjc9VgmgMfD3EuT1+jqmqW7aIU0IybKL5lLk/FKQ6wZ4TLcqLVlm/3sZadh3nIyySELB xwN1hdcred4c7o9AGq32VB+l50s2gxIyFfpxjd5L3fxKGtTgcumyxntPFiF2xzrvPHn+ J86A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=809REvyTd02dVym8hZUdnfHZr/NK3BOiIohksfQj1oM=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=PFiW9ZCU7I4+Vaqa3sFzQ42zasmP3mYCCZUTZLXkZhPxv9jzbzuzD4Yqs9hb0YldmQ b+1LORcxvE1uul/us8Ltb8z82PEVdX5GRWKRnwul7B9sFcSBjshnNO8CYEVJbMJjRkE/ CklIxZOcd1Vew5HVYoaojcIbkqqs73U94uv6zUw46Dtg0JQrXQQgfVggb3AF7RBZ2E+G fO4T58koHj1NyT5blH/u5hkq+PHXP+LiErqtjljRAH+n2jWetKr0eZ8tdgKyLr/oeY1q vYSjWSPz/kkHLvme/KzpfU6Z7tV8ocRbwhy46oTYrYbIZPpLChiPIxboJAsA87BbZPYo Mtjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OSPy2UhF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm10-20020a0564020b0a00b0051ff079876fsi272114edb.621.2023.07.17.16.17.20; Mon, 17 Jul 2023 16:17:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OSPy2UhF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231366AbjGQXPC (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231265AbjGQXOu (ORCPT ); Mon, 17 Jul 2023 19:14:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8F1213D for ; Mon, 17 Jul 2023 16:14:46 -0700 (PDT) Message-ID: <20230717223223.499996154@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=809REvyTd02dVym8hZUdnfHZr/NK3BOiIohksfQj1oM=; b=OSPy2UhFd09/ntzkIYSXS6s/mbRnTChHppEUB/1L2PXKotrU23qCWkP8rxGdbPNv02bis+ a3VCnrvCQZPqGUmclFr74+BQHp9hdtpLRFY7zP36qb4OjntldkSH8WFQ5b0ADcfT+ig4LF eodtB48BkmezgzqNwbtnP17fFMJR448pc8MEA0r6+T+7ly8pKiDaFwuF8n3F0cnIAz0Mc0 xyu+Ma0s7h2rS+J5rRTiPPbqBZw2H9d61TYrZwzO1nnnvxnr4WPVs8iiOItqVIaMHA79th f1kiVjK9qaWpdmb3IH0SVvyhkWHNKuJAaaL6FDyF6uUP9hTmct+e4Xg6WjONyQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635685; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=809REvyTd02dVym8hZUdnfHZr/NK3BOiIohksfQj1oM=; b=ADoR2blho6PKngC8a52eEUoeHgo7A+4lZEFer0P0ADyyZzbXHXrPAP/lkqekL+1+GQLbtY lfMOU4x36OYNRbDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 07/58] x86/apic: Remove unused max_physical_apicid References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:44 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711614884707905 X-GMAIL-MSGID: 1771711614884707905 Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 8 -------- 1 file changed, 8 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -74,11 +74,6 @@ EXPORT_SYMBOL_GPL(boot_cpu_physical_apic u8 boot_cpu_apic_version __ro_after_init; /* - * The highest APIC ID seen during enumeration. - */ -static unsigned int max_physical_apicid; - -/* * Bitmask of physically existing CPUs: */ physid_mask_t phys_cpu_present_map; @@ -2541,9 +2536,6 @@ int generic_processor_info(int apicid, i boot_cpu_apic_version, cpu, version); } - if (apicid > max_physical_apicid) - max_physical_apicid = apicid; - #if defined(CONFIG_SMP) || defined(CONFIG_X86_64) early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; #endif From patchwork Mon Jul 17 23:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1404082vqt; Mon, 17 Jul 2023 16:31:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHRi56r9P+JV9R0EiHpnvdyBJqF7IeQUWpIes1oKOui0pkBR5g/ejyLZLptm+znci4kly5z X-Received: by 2002:a05:6a20:160e:b0:135:26ad:124 with SMTP id l14-20020a056a20160e00b0013526ad0124mr2118507pzj.5.1689636661012; Mon, 17 Jul 2023 16:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636660; cv=none; d=google.com; s=arc-20160816; b=nmkoH5Vpqy4ImZxVwD9XP23POnmyE/nr0tBSxK3Acci9G3LQ90d8f7ZE/cZ59AsX1E IFQ2ofNnlGbRDk5jRfHIen9S3Sf4xuntLfUyKL+bxRRg/Kn0qLzsvFJr3JJh8D6TnjqJ 7o0BVeAvNXJphwDQtsCqK4D4mxrrnEKPfp8EXhCBYIOjGrDXwXsewHnQBzANJvi2d4Vj muhB7IqrdbKmFhVnIyZtaYP/QlEvkoJbEqjSLVxmEu2p9zSQ/ubPAuZyZoz+FZ74qTVC lkNwFwr6xs2gXSNzGP+ehIrIgn2tGv6S0/jQHCmhEIXIn/tjNB8FFz4lEFI8t7l/660w rnxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=4e7J9tdOEFPNygIrLyHrVQ7kBA5TGJ7oCmaEMf40odE=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Lb0RmTyKpEZeXl3lOFxAM8SjqY1+LVtraDbVEwa+Bir0fOwtdndSe5Aqc310ZeJ0ft WNCIr1uKREbLnaL9ZNoxE0ckr/BRa+ZVKENB4vM8MGMeeeLXU8zcvs44pxgj72JXsjAm j4nDJEktZb1id63mvgBCjBjrulAeodyy6czWI96EepA7D8e3/CckCGPek77IlxyaZSna FmNkPbQKcVi7v1gr/amovxvVMGX1bUvO5sCrxFij+YWFmE7SF0AN7p0wBvCB2aAbAnQ+ UJlT4ldpMyGwXhQRK94Oo431MwwL6CNiI1yp5xY96k5Dt4ApIxI0wDBOk96QUBF1Wkph 50sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=roXABOm6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a170902c40b00b001b84c7d4716si669974plk.32.2023.07.17.16.30.46; Mon, 17 Jul 2023 16:31:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=roXABOm6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231394AbjGQXPK (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbjGQXO5 (ORCPT ); Mon, 17 Jul 2023 19:14:57 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 374771B1 for ; Mon, 17 Jul 2023 16:14:49 -0700 (PDT) Message-ID: <20230717223223.560174779@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4e7J9tdOEFPNygIrLyHrVQ7kBA5TGJ7oCmaEMf40odE=; b=roXABOm6JzrHGMN1SS6GsUcPfnP+P2vXUTi9U1fWSZrNOmhixrvlLyT2mBh3kx9QbBlTPo jZW21CSS5Al1ujrgpEswN7MKRQ6r9SOcELaz+qZm/hwi1LEH/xYssoTfwB1CrxDVX4dTNB c8b5EmRTiWGD4coqUPh9ISRzXL7dkHuK/ZEgl5IBCAcHX3pVKpk8GD5bEnBChE9gPFBPkA mG8gtU0dBekBxTG46EuWl+eCok3KUTug1vPIhb8IJSpEvrWgpwMlvMTbIZEpqqVi6id3pD ywQHdVdM1pDnYC2H4ntvJP2LDTQE4Lu68zghWgvho3hKeYpRikVAXbQwHr8diA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635687; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4e7J9tdOEFPNygIrLyHrVQ7kBA5TGJ7oCmaEMf40odE=; b=cYBl40JbWXYzWsB7zA7tcgBD1FPoNWdUP9nok6MbS6FbUbn/ABbMN3gqAvRZ+BHSohh+RR m9buVCYMnuchb5BQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 08/58] x86/apic: Nuke unused apic::inquire_remote_apic() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:46 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712451275302682 X-GMAIL-MSGID: 1771712451275302682 Put it to the other historical leftovers. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 16 -------------- arch/x86/kernel/apic/apic_flat_64.c | 4 --- arch/x86/kernel/apic/apic_noop.c | 2 - arch/x86/kernel/apic/apic_numachip.c | 2 - arch/x86/kernel/apic/bigsmp_32.c | 2 - arch/x86/kernel/apic/probe_32.c | 2 - arch/x86/kernel/apic/x2apic_cluster.c | 2 - arch/x86/kernel/apic/x2apic_phys.c | 2 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 arch/x86/kernel/smpboot.c | 38 ---------------------------------- arch/x86/xen/apic.c | 7 ------ 11 files changed, 78 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -66,20 +66,6 @@ enum apic_intr_mode_id { APIC_SYMMETRIC_IO_NO_ROUTING }; -#ifdef CONFIG_SMP -extern void __inquire_remote_apic(int apicid); -#else /* CONFIG_SMP */ -static inline void __inquire_remote_apic(int apicid) -{ -} -#endif /* CONFIG_SMP */ - -static inline void default_inquire_remote_apic(int apicid) -{ - if (apic_verbosity >= APIC_DEBUG) - __inquire_remote_apic(apicid); -} - /* * With 82489DX we can't rely on apic feature bit * retrieved via cpuid but still have to deal with @@ -330,8 +316,6 @@ struct apic { /* wakeup secondary CPU using 64-bit wakeup point */ int (*wakeup_secondary_cpu_64)(int apicid, unsigned long start_eip); - void (*inquire_remote_apic)(int apicid); - #ifdef CONFIG_X86_32 /* * Called very early during boot from get_smp_config(). It should --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -139,8 +139,6 @@ static struct apic apic_flat __ro_after_ .send_IPI_all = default_send_IPI_all, .send_IPI_self = default_send_IPI_self, - .inquire_remote_apic = default_inquire_remote_apic, - .read = native_apic_mem_read, .write = native_apic_mem_write, .eoi_write = native_apic_mem_write, @@ -230,8 +228,6 @@ static struct apic apic_physflat __ro_af .send_IPI_all = default_send_IPI_all, .send_IPI_self = default_send_IPI_self, - .inquire_remote_apic = default_inquire_remote_apic, - .read = native_apic_mem_read, .write = native_apic_mem_write, .eoi_write = native_apic_mem_write, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -125,8 +125,6 @@ struct apic apic_noop __ro_after_init = .wakeup_secondary_cpu = noop_wakeup_secondary_cpu, - .inquire_remote_apic = NULL, - .read = noop_apic_read, .write = noop_apic_write, .eoi_write = noop_apic_write, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -273,7 +273,6 @@ static const struct apic apic_numachip1 .send_IPI_self = numachip_send_IPI_self, .wakeup_secondary_cpu = numachip_wakeup_secondary, - .inquire_remote_apic = NULL, /* REMRD not supported */ .read = native_apic_mem_read, .write = native_apic_mem_write, @@ -320,7 +319,6 @@ static const struct apic apic_numachip2 .send_IPI_self = numachip_send_IPI_self, .wakeup_secondary_cpu = numachip_wakeup_secondary, - .inquire_remote_apic = NULL, /* REMRD not supported */ .read = native_apic_mem_read, .write = native_apic_mem_write, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -153,8 +153,6 @@ static struct apic apic_bigsmp __ro_afte .send_IPI_all = bigsmp_send_IPI_all, .send_IPI_self = default_send_IPI_self, - .inquire_remote_apic = default_inquire_remote_apic, - .read = native_apic_mem_read, .write = native_apic_mem_write, .eoi_write = native_apic_mem_write, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -95,8 +95,6 @@ static struct apic apic_default __ro_aft .send_IPI_all = default_send_IPI_all, .send_IPI_self = default_send_IPI_self, - .inquire_remote_apic = default_inquire_remote_apic, - .read = native_apic_mem_read, .write = native_apic_mem_write, .eoi_write = native_apic_mem_write, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -265,8 +265,6 @@ static struct apic apic_x2apic_cluster _ .send_IPI_all = x2apic_send_IPI_all, .send_IPI_self = x2apic_send_IPI_self, - .inquire_remote_apic = NULL, - .read = native_apic_msr_read, .write = native_apic_msr_write, .eoi_write = native_apic_msr_eoi_write, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -189,8 +189,6 @@ static struct apic apic_x2apic_phys __ro .send_IPI_all = x2apic_send_IPI_all, .send_IPI_self = x2apic_send_IPI_self, - .inquire_remote_apic = NULL, - .read = native_apic_msr_read, .write = native_apic_msr_write, .eoi_write = native_apic_msr_eoi_write, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -862,7 +862,6 @@ static struct apic apic_x2apic_uv_x __ro .send_IPI_self = uv_send_IPI_self, .wakeup_secondary_cpu = uv_wakeup_secondary, - .inquire_remote_apic = NULL, .read = native_apic_msr_read, .write = native_apic_msr_write, --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -774,44 +774,6 @@ static void impress_friends(void) pr_debug("Before bogocount - setting activated=1\n"); } -void __inquire_remote_apic(int apicid) -{ - unsigned i, regs[] = { APIC_ID >> 4, APIC_LVR >> 4, APIC_SPIV >> 4 }; - const char * const names[] = { "ID", "VERSION", "SPIV" }; - int timeout; - u32 status; - - pr_info("Inquiring remote APIC 0x%x...\n", apicid); - - for (i = 0; i < ARRAY_SIZE(regs); i++) { - pr_info("... APIC 0x%x %s: ", apicid, names[i]); - - /* - * Wait for idle. - */ - status = safe_apic_wait_icr_idle(); - if (status) - pr_cont("a previous APIC delivery may have failed\n"); - - apic_icr_write(APIC_DM_REMRD | regs[i], apicid); - - timeout = 0; - do { - udelay(100); - status = apic_read(APIC_ICR) & APIC_ICR_RR_MASK; - } while (status == APIC_ICR_RR_INPROG && timeout++ < 1000); - - switch (status) { - case APIC_ICR_RR_VALID: - status = apic_read(APIC_RRR); - pr_cont("%08x\n", status); - break; - default: - pr_cont("failed\n"); - } - } -} - /* * The Multiprocessor Specification 1.4 (1997) example code suggests * that there should be a 10ms delay between the BSP asserting INIT --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -129,10 +129,6 @@ static void xen_noop(void) { } -static void xen_silent_inquire(int apicid) -{ -} - static int xen_cpu_present_to_apicid(int cpu) { if (cpu_present(cpu)) @@ -173,9 +169,6 @@ static struct apic xen_pv_apic = { .send_IPI_all = xen_send_IPI_all, .send_IPI_self = xen_send_IPI_self, #endif - /* .wait_for_init_deassert- used by AP bootup - smp_callin which we don't use */ - .inquire_remote_apic = xen_silent_inquire, - .read = xen_apic_read, .write = xen_apic_write, .eoi_write = xen_apic_write, From patchwork Mon Jul 17 23:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121680 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406975vqt; Mon, 17 Jul 2023 16:39:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlGEH9MmQk0KT7aiowKSMdwhJU+xjHbAWPapJum8AFieuDTqBsGnnsgsmwhht5s80AzIzlab X-Received: by 2002:a05:6a00:15c2:b0:682:4edf:b9b4 with SMTP id o2-20020a056a0015c200b006824edfb9b4mr15058867pfu.23.1689637193673; Mon, 17 Jul 2023 16:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637193; cv=none; d=google.com; s=arc-20160816; b=iPqVxB8pIjsv0xra6IILmEIWDRTaV77XI00AB16tzZZK0Z5hu1Xoa0z9W//QiB389U qnLhvjVbRt32YiN8ciCV/at82f20nfBMPSgOnfTW8a+J2lKBtqxAYfcrxKt0w9oQW0C5 RIJLqlUM2jAZlTpmZyXPNbSnUUPJd9gmM+7frDLZ09NEFuvnTl+U15Zr7msD9GCqzcdd Rpi0esgS29gG/TsXQuHH9YUMdvQ2/PG+akbUONVO9tcGpKuY0s+m6YpbSfmIl3jg4M5t 2DunhlseJXJMi4afPr8magf/NBAxYJyT9UZTkFlXaLhP9dYhetO5C5ddVmwK6/BuCwta f5cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=H5i4GGKgRO3TiiYH+SmmQBdthZUJ+Bs0TnVK3jLC+DU=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=HUkFUgN983sOO1MIDhCWOLaXfwTs46gqD1hxQVObKw0h37VsxQ1gLSIxsn12zBwgxz wjdKWpQ0o3VjopnOGI54RSADgZj1jhLc+DP4WCLTAvBqWZ86B+LSuqUtdTBl0j3yasS7 VMAuJJuLUqr2xeQIwQ+mJV+vKDjaB70KM4/WADKJAiIwZMkMm2xfU9S83fBWUuULiCZI j87VNnQn1LomTpgML65RI+yQJjjR4xYo3TyfV/clE/l9h/GFCxv4ciqM54aVNgpH93gO KMkRt8N59dcwFz0QiTi4tHSrriLwUBCQBGSZ95cxy9o72DqL32h2PK4PvgPxSqZPybwL 0rpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0eEZsi8l; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k25-20020a6568d9000000b0055727399652si529960pgt.577.2023.07.17.16.39.41; Mon, 17 Jul 2023 16:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0eEZsi8l; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231356AbjGQXPN (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231345AbjGQXO6 (ORCPT ); Mon, 17 Jul 2023 19:14:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF88EE for ; Mon, 17 Jul 2023 16:14:50 -0700 (PDT) Message-ID: <20230717223223.619742209@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=H5i4GGKgRO3TiiYH+SmmQBdthZUJ+Bs0TnVK3jLC+DU=; b=0eEZsi8l3pELHg1uw7TgE6WQyXiehyoMohC4RaoBFxKY6CU6j4nuf87eB8xfx55yfJKbkJ cxJHtVLCqxqEQmGdhHUnZTO1Uk68d5btdmFF8GiQDvfoIv/1IxTOd7kllbMBHPc073HUyD N1CPQIDbYwq0EspllFFI25M0uWPUVggoolU6+6kk/xbqHW8sZFgjr4u4mWoQZKlNyTcv4Z vl2nkNes58MpKh2Y6iwXpscx5unsbgXgnZXuOb/jnRDf6JuHH4cqO6ZSNIvh3I9N1asaMu NRPkhwozIg6tCqrhIEikbzoaaCpOju0Ulu6J6LmY4K9yuZC1eb/xo0rsi5VXLQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=H5i4GGKgRO3TiiYH+SmmQBdthZUJ+Bs0TnVK3jLC+DU=; b=uQDan8++eDr5/q31MdW+XBJjSY5q8cCK5Jhe7aKeuc1TcVbN84ScwI+nxx+mRq5y6eu+r0 yY5mhplJ7RbBclBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 09/58] x86/apic: Get rid of boot_cpu_physical_apicid madness References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:48 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713009938863944 X-GMAIL-MSGID: 1771713009938863944 boot_cpu_physical_apicid is written in random places and in the last consequence filled with the APIC ID read from the local APIC. That causes it to have inconsistent state when the MPTABLE is broken. As a consequence tons of moronic checks are sprinkled all over the place. Consolidate the code and read it exactly once when either X2APIC mode is detected early or when the APIC mapping is established. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 arch/x86/kernel/apic/apic.c | 102 +++++++++++++------------------------------- arch/x86/kernel/mpparse.c | 4 - 3 files changed, 34 insertions(+), 74 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -247,7 +247,7 @@ static inline int x2apic_enabled(void) #else /* !CONFIG_X86_X2APIC */ static inline void x2apic_setup(void) { } static inline int x2apic_enabled(void) { return 0; } - +static inline u32 native_apic_msr_read(u32 reg) { BUG(); } #define x2apic_mode (0) #define x2apic_supported() (0) #endif /* !CONFIG_X86_X2APIC */ --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1318,8 +1318,7 @@ static int __init __apic_intr_mode_selec if (!boot_cpu_has(X86_FEATURE_APIC) && APIC_INTEGRATED(boot_cpu_apic_version)) { apic_is_disabled = true; - pr_err(FW_BUG "Local APIC %d not detected, force emulation\n", - boot_cpu_physical_apicid); + pr_err(FW_BUG "Local APIC not detected, force emulation\n"); return APIC_PIC; } #endif @@ -1340,12 +1339,6 @@ static int __init __apic_intr_mode_selec pr_info("APIC: SMP mode deactivated\n"); return APIC_SYMMETRIC_IO_NO_ROUTING; } - - if (read_apic_id() != boot_cpu_physical_apicid) { - panic("Boot APIC ID in local APIC unexpected (%d vs %d)", - read_apic_id(), boot_cpu_physical_apicid); - /* Or can we switch back to PIC here? */ - } #endif return APIC_SYMMETRIC_IO; @@ -1741,6 +1734,23 @@ void apic_ap_setup(void) end_local_APIC_setup(); } +static __init void apic_read_boot_cpu_id(bool x2apic) +{ + /* + * This can be invoked from check_x2apic() before the APIC has been + * selected. But that code knows for sure that the BIOS enabled + * X2APIC. + */ + if (x2apic) { + boot_cpu_physical_apicid = native_apic_msr_read(APIC_ID); + boot_cpu_apic_version = GET_APIC_VERSION(native_apic_msr_read(APIC_LVR)); + } else { + boot_cpu_physical_apicid = read_apic_id(); + boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR)); + } +} + + #ifdef CONFIG_X86_X2APIC int x2apic_mode; EXPORT_SYMBOL_GPL(x2apic_mode); @@ -1921,6 +1931,7 @@ void __init check_x2apic(void) x2apic_state = X2APIC_ON_LOCKED; else x2apic_state = X2APIC_ON; + apic_read_boot_cpu_id(true); } else if (!boot_cpu_has(X86_FEATURE_X2APIC)) { x2apic_state = X2APIC_DISABLED; } @@ -2109,15 +2120,11 @@ static int __init detect_init_APIC(void) */ void __init init_apic_mappings(void) { - unsigned int new_apicid; - if (apic_validate_deadline_timer()) pr_info("TSC deadline timer available\n"); - if (x2apic_mode) { - boot_cpu_physical_apicid = read_apic_id(); + if (x2apic_mode) return; - } /* If no local APIC can be found return early */ if (!smp_found_config && detect_init_APIC()) { @@ -2134,39 +2141,19 @@ void __init init_apic_mappings(void) if (!acpi_lapic && !smp_found_config) register_lapic_address(apic_phys); } - - /* - * Fetch the APIC ID of the BSP in case we have a - * default configuration (or the MP table is broken). - */ - new_apicid = read_apic_id(); - if (boot_cpu_physical_apicid != new_apicid) { - boot_cpu_physical_apicid = new_apicid; - /* - * yeah -- we lie about apic_version - * in case if apic was disabled via boot option - * but it's not a problem for SMP compiled kernel - * since apic_intr_mode_select is prepared for such - * a case and disable smp mode - */ - boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR)); - } } void __init register_lapic_address(unsigned long address) { mp_lapic_addr = address; - if (!x2apic_mode) { - set_fixmap_nocache(FIX_APIC_BASE, address); - apic_mmio_base = APIC_BASE; - apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", - APIC_BASE, address); - } - if (boot_cpu_physical_apicid == -1U) { - boot_cpu_physical_apicid = read_apic_id(); - boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR)); - } + if (x2apic_mode) + return; + + set_fixmap_nocache(FIX_APIC_BASE, address); + apic_mmio_base = APIC_BASE; + apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", APIC_BASE, address); + apic_read_boot_cpu_id(false); } /* @@ -2446,31 +2433,15 @@ int generic_processor_info(int apicid, i phys_cpu_present_map); /* - * boot_cpu_physical_apicid is designed to have the apicid - * returned by read_apic_id(), i.e, the apicid of the - * currently booting-up processor. However, on some platforms, - * it is temporarily modified by the apicid reported as BSP - * through MP table. Concretely: - * - * - arch/x86/kernel/mpparse.c: MP_processor_info() - * - arch/x86/mm/amdtopology.c: amd_numa_init() - * - * This function is executed with the modified - * boot_cpu_physical_apicid. So, disabled_cpu_apicid kernel - * parameter doesn't work to disable APs on kdump 2nd kernel. - * - * Since fixing handling of boot_cpu_physical_apicid requires - * another discussion and tests on each platform, we leave it - * for now and here we use read_apic_id() directly in this - * function, generic_processor_info(). + * boot_cpu_physical_apicid is guaranteed to contain the boot CPU + * APIC ID read from the local APIC when this function is invoked. */ - if (disabled_cpu_apicid != BAD_APICID && - disabled_cpu_apicid != read_apic_id() && + if (disabled_cpu_apicid != boot_cpu_physical_apicid && disabled_cpu_apicid == apicid) { int thiscpu = num_processors + disabled_cpus; - pr_warn("APIC: Disabling requested cpu." - " Processor %d/0x%x ignored.\n", thiscpu, apicid); + pr_warn("APIC: Disabling requested cpu. Processor %d/0x%x ignored.\n", + thiscpu, apicid); disabled_cpus++; return -ENODEV; @@ -2626,15 +2597,6 @@ static void __init apic_bsp_up_setup(voi { #ifdef CONFIG_X86_64 apic_write(APIC_ID, apic->set_apic_id(boot_cpu_physical_apicid)); -#else - /* - * Hack: In case of kdump, after a crash, kernel might be booting - * on a cpu with non-zero lapic id. But boot_cpu_physical_apicid - * might be zero if read from MP tables. Get it from LAPIC. - */ -# ifdef CONFIG_CRASH_DUMP - boot_cpu_physical_apicid = read_apic_id(); -# endif #endif physid_set_mask_of_physid(boot_cpu_physical_apicid, &phys_cpu_present_map); } --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -58,10 +58,8 @@ static void __init MP_processor_info(str apicid = m->apicid; - if (m->cpuflag & CPU_BOOTPROCESSOR) { + if (m->cpuflag & CPU_BOOTPROCESSOR) bootup_cpu = " (Bootup-CPU)"; - boot_cpu_physical_apicid = m->apicid; - } pr_info("Processor #%d%s\n", m->apicid, bootup_cpu); generic_processor_info(apicid, m->apicver); From patchwork Mon Jul 17 23:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399302vqt; Mon, 17 Jul 2023 16:17:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlHH5oTsiL4TnMxodIAX7QBu1eknIOHPIpejD19aO0IMOz15sQPC5+zxyMEL9hX5vUQ547AP X-Received: by 2002:a19:6743:0:b0:4ed:cc6d:61fe with SMTP id e3-20020a196743000000b004edcc6d61femr447424lfj.24.1689635872359; Mon, 17 Jul 2023 16:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635872; cv=none; d=google.com; s=arc-20160816; b=QaiLu5n7nmfDWAdDqNJVT0kr8m2Qt9fxx3af7LHnZo/9NJOkWAOx7iNulMnRXQkbM6 8mCcmJLQOBKTMMqLNxdUx2a1rdCzJggrVigdyxDo9E3Ed3vuK7A4G7HMYU1TrqGDGKTB 66Q/I3Pl3Z0D+BQvcjh3V5DrH5HPvLCIxvm0+ugS8KBI4W24KggSeLVQKR5uVxxK/7Qo AnTYj2ucQ6bPzWDFcwluwrkVTgMFkM9tcNViggbzbeuDPSkvYWTFIhj2jn/YHC92Nby9 iU07Tb39h8xfogQun5W+AwgbaIWXBKensWR+kvOLi786BoIleSM7QgrnFQnuY/6/YiK2 iRWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=+hrw46hsMBswWQNzqDZfoOo5VDQtds9fIHiVlhGFvxE=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=yqGD8tpmXpKEDltYjf+LeY59rEJ4vfi/ASuW8Z6bB0DQNGdjNkvj1UOa7AP3zk765N 38zANaAjEqYAyaImGXYdrtTXey9AAVaq8Tl28jAoDh04L3J0sp5bD531js4Hgrg3LuOl NUmiAkgEF8F6ca70jwXEtKJjM1M8TPrQQsxgxND93waJdz0Z1iNxe5l8V1JHMQM8uKNj G2Kfl7i/VhH5NjvkeawGDQRrmKO5A318FhLziT4h2vG6bZaQf0mdTSyJ9NqFnKKJxJnq fRce9HlM7vHmFdsKOf/P/K558ZvZVNfmS13NDYrWogNwtUV/Il7pTbOX4UDAaKrWLQxk dekQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1iTxgDBd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020aa7d449000000b0051dd4de9b90si271645edr.509.2023.07.17.16.17.29; Mon, 17 Jul 2023 16:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1iTxgDBd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbjGQXPR (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbjGQXPC (ORCPT ); Mon, 17 Jul 2023 19:15:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20004E51 for ; Mon, 17 Jul 2023 16:14:51 -0700 (PDT) Message-ID: <20230717223223.679207826@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=+hrw46hsMBswWQNzqDZfoOo5VDQtds9fIHiVlhGFvxE=; b=1iTxgDBd2IbtrJHBH42NS0qXgndUHXqc+7hJZhMPlsQ1A5nnuWul3sMzl1eRLXfeL79pal 6M8fKqhPBbLvUGtpV6azGOGtAzJJrbxi3/x2wDCA7V1+RmHC84NRiWYKNXIHmwWZhW5ny3 YCN5lpG9uZAC0AveAZ1JK0yfseY4HNZFMCGOTUlTg8Ggn/anco5DaSbMbIqMMll3AVbWBe mzIBF21GQmLd55tm7d3RRgZZ4sXmkgKz44j9OpUBGcjdxBBuoKp7X/Sh6zmwAHZuCnIF/t sC3HmdEAFAdUrBq7X9t+1n9PNKlpW5p2orCq35A8ulMSINTDxYzaI6vGi1rfeg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635690; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=+hrw46hsMBswWQNzqDZfoOo5VDQtds9fIHiVlhGFvxE=; b=iAwgexARZuIjyMMP7UxCAZX4JGqXaF5PrTmuzRWnXmv0RdbAK+3jOqKoz3aUpSMx1/Ml/O n+7JxTHMmJ8CMNCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 10/58] x86/apic: Register boot CPU APIC early References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:49 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711624651049333 X-GMAIL-MSGID: 1771711624651049333 Register the boot CPU APIC right when the boot CPUs APIC is read from the hardware. No point is doing this on random places and having wild heuristics to save the boot CPU APIC ID slot and CPU number 0 reserved. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 120 ++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 70 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1734,6 +1734,8 @@ void apic_ap_setup(void) end_local_APIC_setup(); } +static __init void cpu_set_boot_apic(void); + static __init void apic_read_boot_cpu_id(bool x2apic) { /* @@ -1748,9 +1750,9 @@ static __init void apic_read_boot_cpu_id boot_cpu_physical_apicid = read_apic_id(); boot_cpu_apic_version = GET_APIC_VERSION(apic_read(APIC_LVR)); } + cpu_set_boot_apic(); } - #ifdef CONFIG_X86_X2APIC int x2apic_mode; EXPORT_SYMBOL_GPL(x2apic_mode); @@ -2426,76 +2428,8 @@ static int allocate_logical_cpuid(int ap return nr_logical_cpuids++; } -int generic_processor_info(int apicid, int version) +static void cpu_update_apic(int cpu, int apicid, int version) { - int cpu, max = nr_cpu_ids; - bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, - phys_cpu_present_map); - - /* - * boot_cpu_physical_apicid is guaranteed to contain the boot CPU - * APIC ID read from the local APIC when this function is invoked. - */ - if (disabled_cpu_apicid != boot_cpu_physical_apicid && - disabled_cpu_apicid == apicid) { - int thiscpu = num_processors + disabled_cpus; - - pr_warn("APIC: Disabling requested cpu. Processor %d/0x%x ignored.\n", - thiscpu, apicid); - - disabled_cpus++; - return -ENODEV; - } - - /* - * If boot cpu has not been detected yet, then only allow upto - * nr_cpu_ids - 1 processors and keep one slot free for boot cpu - */ - if (!boot_cpu_detected && num_processors >= nr_cpu_ids - 1 && - apicid != boot_cpu_physical_apicid) { - int thiscpu = max + disabled_cpus - 1; - - pr_warn("APIC: NR_CPUS/possible_cpus limit of %i almost" - " reached. Keeping one slot for boot cpu." - " Processor %d/0x%x ignored.\n", max, thiscpu, apicid); - - disabled_cpus++; - return -ENODEV; - } - - if (num_processors >= nr_cpu_ids) { - int thiscpu = max + disabled_cpus; - - pr_warn("APIC: NR_CPUS/possible_cpus limit of %i reached. " - "Processor %d/0x%x ignored.\n", max, thiscpu, apicid); - - disabled_cpus++; - return -EINVAL; - } - - if (apicid == boot_cpu_physical_apicid) { - /* - * x86_cpu_to_apicid is required to have processors listed - * in same order as logical cpu numbers. Hence the first - * entry is BSP, and so on. - * boot_cpu_init() already hold bit 0 in cpu_present_mask - * for BSP. - */ - cpu = 0; - - /* Logical cpuid 0 is reserved for BSP. */ - cpuid_to_apicid[0] = apicid; - } else { - cpu = allocate_logical_cpuid(apicid); - if (cpu < 0) { - disabled_cpus++; - return -EINVAL; - } - } - - /* - * Validate version - */ if (version == 0x0) { pr_warn("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n", cpu, apicid); @@ -2521,10 +2455,56 @@ int generic_processor_info(int apicid, i if (system_state != SYSTEM_BOOTING) cpu_mark_primary_thread(cpu, apicid); +} + +static __init void cpu_set_boot_apic(void) +{ + cpuid_to_apicid[0] = boot_cpu_physical_apicid; + cpu_update_apic(0, boot_cpu_physical_apicid, boot_cpu_apic_version); +} + +int generic_processor_info(int apicid, int version) +{ + int cpu, max = nr_cpu_ids; + + /* The boot CPU must be set before MADT/MPTABLE parsing happens */ + if (cpuid_to_apicid[0] == BAD_APICID) + panic("Boot CPU APIC not registered yet\n"); + + if (apicid == boot_cpu_physical_apicid) + return 0; + + if (disabled_cpu_apicid == apicid) { + int thiscpu = num_processors + disabled_cpus; + + pr_warn("APIC: Disabling requested cpu. Processor %d/0x%x ignored.\n", + thiscpu, apicid); + disabled_cpus++; + return -ENODEV; + } + + if (num_processors >= nr_cpu_ids) { + int thiscpu = max + disabled_cpus; + + pr_warn("APIC: NR_CPUS/possible_cpus limit of %i reached. " + "Processor %d/0x%x ignored.\n", max, thiscpu, apicid); + + disabled_cpus++; + return -EINVAL; + } + + cpu = allocate_logical_cpuid(apicid); + if (cpu < 0) { + disabled_cpus++; + return -EINVAL; + } + + cpu_update_apic(cpu, apicid, version); return cpu; } + void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg, bool dmar) { From patchwork Mon Jul 17 23:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121647 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399395vqt; Mon, 17 Jul 2023 16:18:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlGZuYZclcuLPuKwPAozqnuh3HI+YdAQWDj3eNr4BN5WD+AgjzS/6h5X/zyWY6s/L9JUyW1O X-Received: by 2002:a05:6512:a8b:b0:4f8:587e:cbe0 with SMTP id m11-20020a0565120a8b00b004f8587ecbe0mr10111760lfu.52.1689635883563; Mon, 17 Jul 2023 16:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635883; cv=none; d=google.com; s=arc-20160816; b=fmL0gcvgFfbZke6t/A/NXsM2jSj93PbKT9BBMRQjKx6RKK+1s/M0dTSCRj5jyK+dms mGeae3uJMNudLeNAizYwnNmbdD5x5p8ZS5yo58qiSnou797+vOYj/2Q3y/Zt1/DsJYUc 53v1R3if7YCv0TP5msR5ioiqpMU/8h2j2H72O0HaPry5Q5dDQTwg0cFvQVbOHuY90oPj iGFQ3ftDp52SxpEk0Z5BNYVYrBiC99qzluYSED62Os83zAUOTiC70j8E/4XapLld2aU0 IIrovVhNMijYuBGiguXQtzuC13QXKikOayCd0yp71/c9yIWTnUK3IrPxvuzHTBSJWxdI 9qnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=OZddm0qMa+fCQ/gmjuY/HZsd/K8NL9drgmrzgYZMbN0=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=N2+02riM8qLFsMIFUECeFaxkhNyImcV7rMghNJmw52Z1bT4YtpvBmOMb2m5eM6UC4w 0j6glAZvytTeIpH8rh2J0DqDqIqcmj3eY+obS+OGOY0kyz/u5REHxVsbCeCzNs0wKUT1 d7yfGo60WpNAGRvslGBSYdgBR5Q9kRJipeXzghfW+K1LsagGODQvPhUP3LSDUrLuRgnB 36T1+qKfLnrvVruYGbrzY/38WTt/TX8Eijij+tvRfU3nZXvF7/p4LhwJOlk2gfX3C/Dp ttmXzxZBaryhC6lXQP9EGaVUQmPJHhEdF/g583pTtx+tBuYxuj2Vg+CkhlpkBEPjHMej QE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DTHVIP8i; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d24-20020a05640208d800b0051ddbf43286si296290edz.403.2023.07.17.16.17.39; Mon, 17 Jul 2023 16:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DTHVIP8i; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbjGQXPX (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231342AbjGQXPI (ORCPT ); Mon, 17 Jul 2023 19:15:08 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 855AA1705 for ; Mon, 17 Jul 2023 16:14:54 -0700 (PDT) Message-ID: <20230717223223.737031480@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=OZddm0qMa+fCQ/gmjuY/HZsd/K8NL9drgmrzgYZMbN0=; b=DTHVIP8iXYhNrFjvw9p/C2zr4c7ot1d9tCd6POZvTETzn0MTNiS5u7DZwMdZoIoYAOmw1O 9NMHAnqpb4W/lZlutMAxq/SbEPbQU2I+TqWaAExtQngcEsNZuw1XYcswpck1epK5BwrM7P oias9id99krUtB0tUxmV6y+NjT6C/ejpLsTz2cPmwQTww96bilAv/rghpHIV5fhjWB4IhX gVOPKswnR5rOn0qMfkGw9O+i4JPLPgOHwCesez9uaBQ47nb/iljsviKJmpWEQc0Bpx/wN/ RwEqmRk1fU4c52/0sd/puvM7J1x6Gz2nxgWIKfJc6c+iYgC33WLaT0PHZk89qg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=OZddm0qMa+fCQ/gmjuY/HZsd/K8NL9drgmrzgYZMbN0=; b=uOTNnL5z3cSHcYx8OH+2g7Ajf3JECnWtkbAWERtDmsPHq3HawaQth2gZnAjWUJHugdxbTC dfPJ4MR2zHOIyvBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 11/58] x86/apic: Remove the pointless APIC version check References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:51 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711636294502964 X-GMAIL-MSGID: 1771711636294502964 This historical leftover is really uninteresting today. Whatever MPTABLE or MADT delivers we only trust the hardware anyway. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/mpspec.h | 2 +- arch/x86/kernel/acpi/boot.c | 6 +----- arch/x86/kernel/apic/apic.c | 19 ++++--------------- arch/x86/kernel/devicetree.c | 5 ++--- arch/x86/kernel/jailhouse.c | 6 ++---- arch/x86/kernel/mpparse.c | 2 +- arch/x86/kernel/smpboot.c | 4 ++-- 7 files changed, 13 insertions(+), 31 deletions(-) --- a/arch/x86/include/asm/mpspec.h +++ b/arch/x86/include/asm/mpspec.h @@ -76,7 +76,7 @@ static inline void e820__memblock_alloc_ #define default_get_smp_config x86_init_uint_noop #endif -int generic_processor_info(int apicid, int version); +int generic_processor_info(int apicid); #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_LOCAL_APIC) --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -169,7 +169,6 @@ static int __init acpi_parse_madt(struct */ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled) { - unsigned int ver = 0; int cpu; if (id >= MAX_LOCAL_APIC) { @@ -182,10 +181,7 @@ static int acpi_register_lapic(int id, u return -EINVAL; } - if (boot_cpu_physical_apicid != -1U) - ver = boot_cpu_apic_version; - - cpu = generic_processor_info(id, ver); + cpu = generic_processor_info(id); if (cpu >= 0) early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid; --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2428,19 +2428,8 @@ static int allocate_logical_cpuid(int ap return nr_logical_cpuids++; } -static void cpu_update_apic(int cpu, int apicid, int version) +static void cpu_update_apic(int cpu, int apicid) { - if (version == 0x0) { - pr_warn("BIOS bug: APIC version is 0 for CPU %d/0x%x, fixing up to 0x10\n", - cpu, apicid); - version = 0x10; - } - - if (version != boot_cpu_apic_version) { - pr_warn("BIOS bug: APIC version mismatch, boot CPU: %x, CPU %d: version %x\n", - boot_cpu_apic_version, cpu, version); - } - #if defined(CONFIG_SMP) || defined(CONFIG_X86_64) early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; #endif @@ -2460,10 +2449,10 @@ static void cpu_update_apic(int cpu, int static __init void cpu_set_boot_apic(void) { cpuid_to_apicid[0] = boot_cpu_physical_apicid; - cpu_update_apic(0, boot_cpu_physical_apicid, boot_cpu_apic_version); + cpu_update_apic(0, boot_cpu_physical_apicid); } -int generic_processor_info(int apicid, int version) +int generic_processor_info(int apicid) { int cpu, max = nr_cpu_ids; @@ -2500,7 +2489,7 @@ int generic_processor_info(int apicid, i return -EINVAL; } - cpu_update_apic(cpu, apicid, version); + cpu_update_apic(cpu, apicid); return cpu; } --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -128,16 +128,15 @@ static void __init dtb_setup_hpet(void) static void __init dtb_cpu_setup(void) { struct device_node *dn; - u32 apic_id, version; + u32 apic_id; - version = GET_APIC_VERSION(apic_read(APIC_LVR)); for_each_of_cpu_node(dn) { apic_id = of_get_cpu_hwid(dn, 0); if (apic_id == ~0U) { pr_warn("%pOF: missing local APIC ID\n", dn); continue; } - generic_processor_info(apic_id, version); + generic_processor_info(apic_id); } } --- a/arch/x86/kernel/jailhouse.c +++ b/arch/x86/kernel/jailhouse.c @@ -101,10 +101,8 @@ static void __init jailhouse_get_smp_con register_lapic_address(0xfee00000); - for (cpu = 0; cpu < setup_data.v1.num_cpus; cpu++) { - generic_processor_info(setup_data.v1.cpu_ids[cpu], - boot_cpu_apic_version); - } + for (cpu = 0; cpu < setup_data.v1.num_cpus; cpu++) + generic_processor_info(setup_data.v1.cpu_ids[cpu]); smp_found_config = 1; --- a/arch/x86/kernel/mpparse.c +++ b/arch/x86/kernel/mpparse.c @@ -62,7 +62,7 @@ static void __init MP_processor_info(str bootup_cpu = " (Bootup-CPU)"; pr_info("Processor #%d%s\n", m->apicid, bootup_cpu); - generic_processor_info(apicid, m->apicver); + generic_processor_info(apicid); } #ifdef CONFIG_X86_IO_APIC --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1389,7 +1389,7 @@ early_param("possible_cpus", _setup_poss { int i, possible; - /* No boot processor was found in mptable or ACPI MADT */ + /* No processor was found in mptable or ACPI MADT */ if (!num_processors) { if (boot_cpu_has(X86_FEATURE_APIC)) { int apicid = boot_cpu_physical_apicid; @@ -1400,7 +1400,7 @@ early_param("possible_cpus", _setup_poss /* Make sure boot cpu is enumerated */ if (apic->cpu_present_to_apicid(0) == BAD_APICID && apic->apic_id_valid(apicid)) - generic_processor_info(apicid, boot_cpu_apic_version); + generic_processor_info(apicid); } if (!num_processors) From patchwork Mon Jul 17 23:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399467vqt; Mon, 17 Jul 2023 16:18:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlGtDyTf6Rkh+ETtn6n4VRB7GHA99LsGfi/koI4OnW6dNrCN+43BvCc2Ioa67buLT0j9lcFe X-Received: by 2002:a17:906:64d6:b0:97e:56d5:b885 with SMTP id p22-20020a17090664d600b0097e56d5b885mr11710020ejn.60.1689635892886; Mon, 17 Jul 2023 16:18:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635892; cv=none; d=google.com; s=arc-20160816; b=lULpJrZeUpEKYF94nvNFGYsNCcvFK8jWJlcGKcmHO5g1IZCxVI/9KU0qkFED6X3mJx pkSa+k+DID8mECfyBE2LM58OMzDn9ba4D28S4DgNgSHqfrC/AwBcis/laNjyUHiAGc+h FqGQkIp1SVfE2A19vR2CrmvUIsh1SnRg4rPhLv7JOsj368vEIOAxlxLlWEr1vLmi7Hf9 QcYc9kyFlelsm/RVFCe23jEjoliL/EDx0pHyvKvut2oSz4mAD51ofpqgP4NBFxym9Ht8 A5fjZ5rEd8h0u44uNk4oZxuf2DpWC1nCtGEYASRO89uefX4qwikSQVwoWpCzs9JlYb6+ BRaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=oO9hcqnpNwvqYXrZ+6Z6cARd5ofqbuQWYypUIdXUUcI=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=GubwsQe0C5uryLRJTQLbcSyc42YoV/lW2UQPZ7qYJzjcVmPSYyASfaSo5T2lrhuOP5 q8K51ZmkTwZbdtzG1D0kbYYvkp5YbRiMgB2QuUxRLsFYsuSfTTfvm2q6gIa7KysDTQOf MtwiYY4WqfBpgB9fGXXnVlLo65oypWzMaJn/gRhcgkbEAs1nx9UxYJIVqKyAO3jTNyKZ xa08zTm6lnaO69xquFKeHPWxXE+NpOtszjifq1DkV3/+waV4596Q4ZVETrtngbth2z/M j7dATMN5pVvwtIt5/uGgYOU1NN++N0oSByy1P1FiuGvxMBoYKQ1hhy/THI/Pz+oHebiA pF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="p7b6/Bis"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wZpkUn2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr23-20020a170906fb9700b00997124ebc83si341066ejb.6.2023.07.17.16.17.50; Mon, 17 Jul 2023 16:18:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="p7b6/Bis"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wZpkUn2c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbjGQXPZ (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbjGQXPM (ORCPT ); Mon, 17 Jul 2023 19:15:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D24A170F for ; Mon, 17 Jul 2023 16:14:55 -0700 (PDT) Message-ID: <20230717223223.795705685@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oO9hcqnpNwvqYXrZ+6Z6cARd5ofqbuQWYypUIdXUUcI=; b=p7b6/Bis4eXvJ7P7OK19N8ZEt+C+dp7pjK1yD7IFcMFEtxgTJl/IOBgPbh/NH6/bVPfEtC Czqqoyll9VnvOxtEJyIjAvCu4MvMRESmDb0VPpLkAh0kOdiMOzcyseAr5qz64QkYxsuW6E Df1ytueO2TeawBnB7AQ4SjbREIiyOtCkPaJORc7Lzi6T3dcXVJTtZV0oDnovkz1SOoNb4S iFSvOFBCbL0BCHi2YBAeI7UCunfSMds2s06ogGyPWe3Dgiyf5hm35WtNp4HeqwIDD5sUtk 5qg7YT2NCTcZSIeekDKkhG0NriDLzT0xxBrLR0FbUF22dUH4d4y2B/Gg5pcy5w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oO9hcqnpNwvqYXrZ+6Z6cARd5ofqbuQWYypUIdXUUcI=; b=wZpkUn2cRMrRvmnxKnBieim+IVSwk2CPB0K19234yqR5v4qeFA6mJIP/kDNHpMJXAyyovl 53nr1vAHeDKHfzAw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 12/58] x86/of: Fix the APIC address registration References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:52 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711646185630073 X-GMAIL-MSGID: 1771711646185630073 The device tree APIC parser tries to force enable the local APIC when it is not set in CPUID. apic_force_enable() registers the boot CPU apic on success. If that succeeds then dtb_lapic_setup() registers the local APIC again eventually with a different address. Rewrite the code so that it only registers it once. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/devicetree.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -157,19 +157,15 @@ static void __init dtb_lapic_setup(void) /* Did the boot loader setup the local APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC)) { + /* Try force enabling, which registers the APIC address */ if (apic_force_enable(lapic_addr)) return; - } - smp_found_config = 1; - if (of_property_read_bool(dn, "intel,virtual-wire-mode")) { - pr_info("Virtual Wire compatibility mode.\n"); - pic_mode = 0; } else { - pr_info("IMCR and PIC compatibility mode.\n"); - pic_mode = 1; + register_lapic_address(lapic_addr); } - - register_lapic_address(lapic_addr); + smp_found_config = 1; + pic_mode = !of_property_read_bool(dn, "intel,virtual-wire-mode"); + pr_info("%s compatibility mode.\n", pic_mode ? "IMCR and PIC" : "Virtual Wire"); } #endif /* CONFIG_X86_LOCAL_APIC */ From patchwork Mon Jul 17 23:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121686 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407897vqt; Mon, 17 Jul 2023 16:42:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlEPzXJlAIhEp8P/Jikkq6Q9+pzm5w+ccn2hB35ZWB/KUbV+8wi7XPEDwJYxBae9rIMnx8da X-Received: by 2002:a05:6358:2495:b0:133:c03:53c6 with SMTP id m21-20020a056358249500b001330c0353c6mr10903345rwc.14.1689637375638; Mon, 17 Jul 2023 16:42:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637375; cv=none; d=google.com; s=arc-20160816; b=i0709amjnD2lXD+E05b0y8kYhzFrBWq4kV5eR97ZgMjpnvTpN+SGCsL+WRr6W6XzAj PX9a3dJ0WGg1CIn6NBSEEJKw1uoGZKbuD7fr3rTTHwfrFtePcecPepsbk/slS0n16hYF Kpq6rDcgkGonyy4d/tTgeJSwmrF4vz+LgCpYC66NUw10UVxGEVH7i0O7dORvyRrP8uFo TdcA+lV52nAIE6SwBixpA/5PPTJfErUTr3q4opQMkHpAMcn01iY+LgsfchovgWoA1gmR xU07cdQDhHBoFfp8/HtZPoYPINGTVBSQAm44tgwcqsz7UDNE5ZbLlJK3LOtgf+bflV16 ZGfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=pZQ9lH7uKukYhk1nKowW452zbwwO1eTDkvObOGS1SuA=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=HvsevlisH3R9Ls86kkK5OSpfXoA/0EIXLfiPNADqvfMpkr2OZMexV+SZyv8zuljoE8 G4GWy3GpTUnPTXUJmOictSxMF8gyJt6B/sOhEVF/6LmoDFkvgupmi1Ck9P7eLbk1kreU yGN7Q9Avi24kanqosOY2dem78YqId3+QvjFgdX7RlMlJgx8U0OsBu62FJIw6+Nmgr61N tFIPJreEnRhgJIDRgdCnaUsOvxtMsjGulIdUuG7tzC7Zz2rTILOFhwvXktfnIa6/APjc UeNcd4J0qRVNZVPpO5b+9OZHwmssQ7150srnTCJ7FnK8DTgVOnoetuH3hegmjgH9jjfx QdQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bBgGdLV6; dkim=neutral (no key) header.i=@linutronix.de header.b=Md1YPbX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a056a00084100b0065bbe39e1b3si594198pfk.146.2023.07.17.16.42.42; Mon, 17 Jul 2023 16:42:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bBgGdLV6; dkim=neutral (no key) header.i=@linutronix.de header.b=Md1YPbX2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231398AbjGQXP1 (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231315AbjGQXPQ (ORCPT ); Mon, 17 Jul 2023 19:15:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE08B1726 for ; Mon, 17 Jul 2023 16:14:56 -0700 (PDT) Message-ID: <20230717223223.853631722@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=pZQ9lH7uKukYhk1nKowW452zbwwO1eTDkvObOGS1SuA=; b=bBgGdLV6z4Gucf5BLCilurt+G4NPVjt7yUAMe2NpLbuO4kYTMDXwYp69w8fNDwrIFZr06F c4whOHyL0bv8WGB6q2q/uZZlgrnaqJpQ9aNE2wknLupIPzrMDRUzxJFXB3yOaZTRN7ZZLJ W+1OhHbiVl12bb+JlTy+jZ8KgF5x1FzeKWauWZtc2Lw61kosGiptRF4EmxpZvTlJoNS9pB QavdBqbURkoHl+306co554Co5kPodOX/hxwSjrNNTgD6CiM971XVekYXmEg00+86C+YUuD EhT7nlvziwwzcr40h3abV/ouf8SydJ7VHo1pdIdwiqIBZCFFy7anVD8+Gx2fQw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=pZQ9lH7uKukYhk1nKowW452zbwwO1eTDkvObOGS1SuA=; b=Md1YPbX2At1yWdGCd3T6EY7E8h4c5v+OzzmVQtmvSUspYaw0xYaLUdCVLjW8oA+aumR6n4 0I1fBIQXE9KNmuCA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 13/58] x86/apic: Make some APIC init functions bool References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:54 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713200653937545 X-GMAIL-MSGID: 1771713200653937545 Quite some APIC init functions are pure boolean, but use the success = 0, fail < 0 model. That's confusing as hell when reading through the code. Convert them to boolean. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 6 +++--- arch/x86/kernel/apic/apic.c | 36 ++++++++++++++++++------------------ arch/x86/kernel/devicetree.c | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -135,12 +135,12 @@ extern void setup_secondary_APIC_clock(v extern void lapic_update_tsc_freq(void); #ifdef CONFIG_X86_64 -static inline int apic_force_enable(unsigned long addr) +static inline bool apic_force_enable(unsigned long addr) { - return -1; + return false; } #else -extern int apic_force_enable(unsigned long addr); +extern bool apic_force_enable(unsigned long addr); #endif extern void apic_ap_setup(void); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2000,19 +2000,19 @@ void __init enable_IR_x2apic(void) * On AMD64 we trust the BIOS - if it says no APIC it is likely * not correctly set up (usually the APIC timer won't work etc.) */ -static int __init detect_init_APIC(void) +static bool __init detect_init_APIC(void) { if (!boot_cpu_has(X86_FEATURE_APIC)) { pr_info("No local APIC present\n"); - return -1; + return false; } mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; - return 0; + return true; } #else -static int __init apic_verify(void) +static bool __init apic_verify(void) { u32 features, h, l; @@ -2023,7 +2023,7 @@ static int __init apic_verify(void) features = cpuid_edx(1); if (!(features & (1 << X86_FEATURE_APIC))) { pr_warn("Could not enable APIC!\n"); - return -1; + return false; } set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; @@ -2036,15 +2036,15 @@ static int __init apic_verify(void) } pr_info("Found and enabled local APIC!\n"); - return 0; + return true; } -int __init apic_force_enable(unsigned long addr) +bool __init apic_force_enable(unsigned long addr) { u32 h, l; if (apic_is_disabled) - return -1; + return false; /* * Some BIOSes disable the local APIC in the APIC_BASE @@ -2067,11 +2067,11 @@ int __init apic_force_enable(unsigned lo /* * Detect and initialize APIC */ -static int __init detect_init_APIC(void) +static bool __init detect_init_APIC(void) { /* Disabled by kernel option? */ if (apic_is_disabled) - return -1; + return false; switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_AMD: @@ -2098,22 +2098,22 @@ static int __init detect_init_APIC(void) if (!force_enable_local_apic) { pr_info("Local APIC disabled by BIOS -- " "you can enable it with \"lapic\"\n"); - return -1; + return false; } - if (apic_force_enable(APIC_DEFAULT_PHYS_BASE)) - return -1; + if (!apic_force_enable(APIC_DEFAULT_PHYS_BASE)) + return false; } else { - if (apic_verify()) - return -1; + if (!apic_verify()) + return false; } apic_pm_activate(); - return 0; + return true; no_apic: pr_info("No local APIC present or hardware disabled\n"); - return -1; + return false; } #endif @@ -2129,7 +2129,7 @@ void __init init_apic_mappings(void) return; /* If no local APIC can be found return early */ - if (!smp_found_config && detect_init_APIC()) { + if (!smp_found_config && !detect_init_APIC()) { /* lets NOP'ify apic operations */ pr_info("APIC: disable apic facility\n"); apic_disable(); --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c @@ -158,7 +158,7 @@ static void __init dtb_lapic_setup(void) /* Did the boot loader setup the local APIC ? */ if (!boot_cpu_has(X86_FEATURE_APIC)) { /* Try force enabling, which registers the APIC address */ - if (apic_force_enable(lapic_addr)) + if (!apic_force_enable(lapic_addr)) return; } else { register_lapic_address(lapic_addr); From patchwork Mon Jul 17 23:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121649 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399537vqt; Mon, 17 Jul 2023 16:18:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEG/mgnYItnuPqGXE/jZ7VtDVzareOscK9K1kP/pZs5aa86CxNKUT2Co7FwqsiG68FORJfK X-Received: by 2002:a17:906:14e:b0:992:5399:2543 with SMTP id 14-20020a170906014e00b0099253992543mr12158579ejh.30.1689635899974; Mon, 17 Jul 2023 16:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635899; cv=none; d=google.com; s=arc-20160816; b=U/LF1emRk+pLNtIq3u9yFuP9PT3nrPxwoAGkG1uWvkz8ZSymZ2zjgsk1V2UB232nfe DjmZ5wNZfXWKSjU3TYQX1PK3NKq8IaBpmrE2+bxg+gPaZb1Bo/zRphg9cxMKjvMkQ2GI MJuhiD/hIvSDPhMl/GdqQ1eArzwvVfSddk1qa2mivy3RPB2+0dRRsDw2PTCI+ick0Wbi FsYy8b5sfoynM2XViHhpOvp78lZ2kV0nUZm6+4ZhdK/zmJwcVUfB0EdeDfEGDqhWUilp RbmI+OFbJhQOw3/YLdfssu6xV/F5gou1N2JxQWf4fEWRuH/Aoi2ZyAOJu5rgRP/EU2A3 BLtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=6lsXOSCdebUCwT7n6zhHvn8DJi5YZlZjkDwKMSiOzL0=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=wBUrMSErFW4KX49bncOMmIweIEFKiP9lpGH69Qd38DrcLf/pfxiFqrchdfDpr3trmQ dwvt6/EVCmVRzQrrMTY2riZ5uD80BNc66W5tsPnWN6RrV5VE9xAYVBQFz7e7Mr+q5qKG JhK+38F3osf3+BfBIwGMnWMJh5mBJa9Mk2fxpDSFEXDYOs9QmSwuO9/n10QZ0TKaJmNR v4LKoKN8t0SnS3Wz8NK7x1dbGMLTsYChbKCB0VMB2Q6sqOcsYm5l2PqUTF9tqpj1ajgX va/lIJJHvBmADfFsiWsBQbGUG/s6/JYE1VioUwYZC6zRorjQMRhKeuRjn5LRpV2ol/tO Ai0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MXEXcw0t; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170906064900b00992dcae843esi292467ejb.202.2023.07.17.16.17.56; Mon, 17 Jul 2023 16:18:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MXEXcw0t; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231368AbjGQXPk (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231316AbjGQXP1 (ORCPT ); Mon, 17 Jul 2023 19:15:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6585B173B for ; Mon, 17 Jul 2023 16:14:58 -0700 (PDT) Message-ID: <20230717223223.913161388@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6lsXOSCdebUCwT7n6zhHvn8DJi5YZlZjkDwKMSiOzL0=; b=MXEXcw0tO5uqiDRsXTnO1WBHMsD/0ClTumSqTLX7DyN70nfu5/fdzzOhrzzHZveO4r1D6b 6oFfLSbK9kF08uQuLICNty1yodyumD3rKz9EfI1n6JlwYTnhRbYjPmjljqGX88Fpw6La/A IfOhKQHwTm4IMWL9cXEE2SV8Oud65buCZfMODG/e15uAOUkuas3ZVUryW2B8WNTWnC2Stl l21SnNLcNOUFeL3EoBv9UMs5smQlqxLC6U0Vt8nUWuPCE7I6TslCptB5rm3FY2B8Lu5SSw IJdpheAGkEm4JBZDXY9EzzzUCRWQSdGzg476eSlIl9BHbbmZCowo7t8utmrO+A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=6lsXOSCdebUCwT7n6zhHvn8DJi5YZlZjkDwKMSiOzL0=; b=7Y5AMRjCRyDwmGRaUhRVIFOHgb79/2tewqVXhnRTQVeAcdD8zj38cRXDrd1JXiGD518QaE KdXPf7Sd90IYV3CQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 14/58] x86/apic: Split register_apic_address() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:55 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711653583742846 X-GMAIL-MSGID: 1771711653583742846 Split the fixmap setup out of register_lapic_address() and reuse it when the X2APIC is disabled during setup. This avoids that the APIC ID is registered twice. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1852,6 +1852,8 @@ void x2apic_setup(void) __x2apic_enable(); } +static __init void apic_set_fixmap(void); + static __init void x2apic_disable(void) { u32 x2apic_id, state = x2apic_state; @@ -1872,7 +1874,7 @@ static __init void x2apic_disable(void) } __x2apic_disable(); - register_lapic_address(mp_lapic_addr); + apic_set_fixmap(); } static __init void x2apic_enable(void) @@ -2145,17 +2147,21 @@ void __init init_apic_mappings(void) } } +static __init void apic_set_fixmap(void) +{ + set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr); + apic_mmio_base = APIC_BASE; + apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", + apic_mmio_base, mp_lapic_addr); + apic_read_boot_cpu_id(false); +} + void __init register_lapic_address(unsigned long address) { mp_lapic_addr = address; - if (x2apic_mode) - return; - - set_fixmap_nocache(FIX_APIC_BASE, address); - apic_mmio_base = APIC_BASE; - apic_printk(APIC_VERBOSE, "mapped APIC to %16lx (%16lx)\n", APIC_BASE, address); - apic_read_boot_cpu_id(false); + if (!x2apic_mode) + apic_set_fixmap(); } /* From patchwork Mon Jul 17 23:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1404725vqt; Mon, 17 Jul 2023 16:32:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlG8xujWuaO42kgYcCLFQ8WszG6WYBmq9eOra5bMYyBQZotNIRE3xRxR1cVVwsm4UOZjkPGJ X-Received: by 2002:a05:6808:13cc:b0:3a3:8e77:ddfd with SMTP id d12-20020a05680813cc00b003a38e77ddfdmr15421747oiw.8.1689636765602; Mon, 17 Jul 2023 16:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636765; cv=none; d=google.com; s=arc-20160816; b=AAtZRO4fMBVp98y/yv9/hbnk5AAZGZ1WQAltzVHDMUlzfkqCtc18IAnXOHqRAbXfxP K8lp1So1YNBhVaewV6IafWZpMWKYoGbr1ShOZWDQrmqFCSqADJ/UctF/xWGpbB5B5y8g Fap4QJk0Um84zQq3+zuu6EZZ6L7gXRdiMt4eSID2nKf1k4RDF+B8QjcGjcGMS1xQMcJi F2pfXRjUVidWP8PgBPktBy24Q0rSDtlq9yBK7wONH1DhbIIE1FzJtsiExFifc9IaR4kK SkPP8+vgmzKd6GI9GAfEuMKGzSOhkBLQGe+U/rOaeuaCXar2bRJi/F4y52Ot40UxCjTn wl1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=8u5DJ4HOBNg4NQW33fRGAZF4EOI10KBFaQA+4tROpKs=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=X8FOw5O0wQZ90M4rxyaGN+5/F7M9ixAyl0VqWJID2/3wFYv0qYVXCRcAbaFUz1MsvF JzoU/gr6caxm1DZs/VvOFAWZqMiq8eSvcKMb6bwrTBWhMLHxab1jD4TUBPnCDeVdxjn1 PLn/O1y0rtORETQOVb3P2KTVzcxxp/X2iAdFPpKn5C5/XS8GTksFz/Xnj6ps/2pydRIh aOs9C0TqpfsONf8F8n1vkF/SREcjxE305sOgvk6oLidVgPnuMrdL6vLEUNvQBUc5oouj DAe+yNniP43ER03zgyrG88QCqVu+RwRu6HlaRc+wjPIlfe8ukTdl9UywB4cNDpy2cLhU v/+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QLI6o7zZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f34-20020a631f22000000b00543c8ad57f7si536243pgf.83.2023.07.17.16.32.32; Mon, 17 Jul 2023 16:32:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QLI6o7zZ; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjGQXPo (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjGQXPj (ORCPT ); Mon, 17 Jul 2023 19:15:39 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5072B198B for ; Mon, 17 Jul 2023 16:15:00 -0700 (PDT) Message-ID: <20230717223223.971994770@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8u5DJ4HOBNg4NQW33fRGAZF4EOI10KBFaQA+4tROpKs=; b=QLI6o7zZfUJ6uEVO0T/AOaNQcFm6gfKddASqWmV7W5RXFSwy+nUSFe+jExElnmyMygYN6h O+A5BETXOY1qqqEmS9oY4XobPnGU8HRsrbtcHv5Dn94m867kCJI7J+ttmS9qV65vU6Vssm FsumQO6gxgYEnklbeiHdvqw0/jtVCo/zvPRZ9UXkKY2VfzJlu/StHZP59Sn0pHK3a8g24R BjRFse4HgOgghai1BtadP3xVsgPMXnCBCavZHPnwdRl+ZHOfRdGz/Ev2KB4az9ANz9MAnQ FKYADvdw62f6MK9bCryiUKZcK/pPQbhyeq/Ju/O8+m534u8J+HoKFD3u44SOuQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=8u5DJ4HOBNg4NQW33fRGAZF4EOI10KBFaQA+4tROpKs=; b=6oIKa1QrGezq5SuZ1jAJQe+seQVOmDV0SoWdTq18WSUjH1qD+gBOI2S4ha/qprGXeVBtCz C8rL0lbTGf5dxABA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 15/58] x86/apic: Sanitize APIC address setup References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:57 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712560942566068 X-GMAIL-MSGID: 1771712560942566068 Convert places which just write mp_lapic_addr and let them register the local APIC address directly instead of relying on magic other code to do so. Add a WARN_ON() into register_lapic_address() which is raised when register_lapic_address() is invoked more than once during boot. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2009,12 +2009,12 @@ static bool __init detect_init_APIC(void return false; } - mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; + register_lapic_address(APIC_DEFAULT_PHYS_BASE); return true; } #else -static bool __init apic_verify(void) +static bool __init apic_verify(unsigned long addr) { u32 features, h, l; @@ -2028,15 +2028,15 @@ static bool __init apic_verify(void) return false; } set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC); - mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; /* The BIOS may have set up the APIC at some other address */ if (boot_cpu_data.x86 >= 6) { rdmsr(MSR_IA32_APICBASE, l, h); if (l & MSR_IA32_APICBASE_ENABLE) - mp_lapic_addr = l & MSR_IA32_APICBASE_BASE; + addr = l & MSR_IA32_APICBASE_BASE; } + register_lapic_address(addr); pr_info("Found and enabled local APIC!\n"); return true; } @@ -2063,7 +2063,7 @@ bool __init apic_force_enable(unsigned l enabled_via_apicbase = 1; } } - return apic_verify(); + return apic_verify(addr); } /* @@ -2105,7 +2105,7 @@ static bool __init detect_init_APIC(void if (!apic_force_enable(APIC_DEFAULT_PHYS_BASE)) return false; } else { - if (!apic_verify()) + if (!apic_verify(APIC_DEFAULT_PHYS_BASE)) return false; } @@ -2130,20 +2130,9 @@ void __init init_apic_mappings(void) if (x2apic_mode) return; - /* If no local APIC can be found return early */ if (!smp_found_config && !detect_init_APIC()) { - /* lets NOP'ify apic operations */ pr_info("APIC: disable apic facility\n"); apic_disable(); - } else { - apic_phys = mp_lapic_addr; - - /* - * If the system has ACPI MADT tables or MP info, the LAPIC - * address is already registered. - */ - if (!acpi_lapic && !smp_found_config) - register_lapic_address(apic_phys); } } @@ -2158,6 +2147,8 @@ static __init void apic_set_fixmap(void) void __init register_lapic_address(unsigned long address) { + /* This should only happen once */ + WARN_ON_ONCE(mp_lapic_addr); mp_lapic_addr = address; if (!x2apic_mode) From patchwork Mon Jul 17 23:14:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121650 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399704vqt; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+fc9Y6FQCD/VgubM0g/XT7blgnRx71tgZ7S6GCOiHnxQ6jIwiHPlKQsDqH0GIPo/QC/HV X-Received: by 2002:a17:906:5a45:b0:977:95f4:5cca with SMTP id my5-20020a1709065a4500b0097795f45ccamr11723796ejc.54.1689635919185; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635919; cv=none; d=google.com; s=arc-20160816; b=pyanLVvI5XdBrwOSIQLTAX1pL8mzLRfTUHBPVxowNfYsrG/YappmIRoEOF7eWjKgJz JJSZp34kfIeH1LkEWET+z3J/qgUtHtKlJMaj4050gfOMSPI1W0fW6ikbTubWyQbmOgIv Z2ANdqouVJVI53d22okbyggxAvISczyTj/EynvGSOIZOmpcEK4x46Ta3y7JQkPBTspRA Eo5MA4Uz4nPNOxIbay/wh3zvqt9G6a/x3GBefH8qMEGE/gOzuLFgHPvVKTty2wlenGnS 9hR61Zvn8rcLulCvLoJzmIsTUqJny8csZ1qq6CViRKHOF23G6mlpa803ggTffbNtIswy 8BWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Kbncsb1cYjTHrBQrXWBFHc1mWdtISJ/STtnqETwjP25UUp0MLZIaOYmAIrJQBGyPSA ccxNF1vDcF7cwq7d2GNKUDQKgJwS22SQgEVw58S51+jV1z8WvHZq9DeWkt8On08iAMJt RbfhsOpSza4eRcOj7KfiQJ8bnpsVNWVl5j2DBX0GdFM9vyWUmYQHeapU2/JUgXQ0NXC9 JHFO78utf1aXOZpfXX05cyzjWdDcV1LERXT/Jvpv2Wit3SgsD6byNIv5ZBO8zF9VPgcn DwCGFhQZjtHaektAeNYi87sI8YUXyGRhzfD6AZeuf9MI+5u8CXOgF1Qnhm5kzRLOYbWK n8HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NcyMzc1S; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020a1709067d9700b00992f1b3ce88si306771ejo.590.2023.07.17.16.18.16; Mon, 17 Jul 2023 16:18:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=NcyMzc1S; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjGQXPs (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229724AbjGQXPk (ORCPT ); Mon, 17 Jul 2023 19:15:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2301A1BCF for ; Mon, 17 Jul 2023 16:15:01 -0700 (PDT) Message-ID: <20230717223224.030628920@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; b=NcyMzc1SpuMYk05jsCRG2BlucobaDGGxjcwIrVbflUWp+DfMWiCjUrOP+3T+SHBItpDnJz JQr/UwH+IrAWFgJHt+49ROFOgVq7XMwdrqWa3LoPyQNrsokPM2L/hm6rOLOxye6alIHXNu d+in5MQswN9Xf2J5maeJBeEjIlAiNDVaybk/8iFq9y+Pl7tX9B26CTM/jkG2tCTAzAxfex 1gAqexir7pwpa8+ntX2jez7qrxyTZQjDNTsyGVvwhm3gQvaaOYMA5Q7jUuQ249K0aqwulA VuQ0imijJyYSAG6hb74CJdYn7kMHxSPWQEFrohzQ+t675BzWo6RSomjFTM4RHg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rxQN3La4uHdTmHXWvnEPxqt3sCLh4RNMZmN6BFMgny4=; b=B6sKhRrWrOBnzZ3M5Uk7oINAy9QWuQJLDHj4bnToS+GnxoWP+NoHkWASgNtcqo603IhS08 YD51KKO/6iFbZLCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 16/58] x86/apic: Sanitize num_processors handling References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:14:59 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711673664473580 X-GMAIL-MSGID: 1771711673664473580 num_processors is 0 by default and only gets incremented when local APICs are registered. Make init_apic_mappings(), which tries to enable the local APIC in the case that no SMP configuration was found set num_processors to 1. This allows to remove yet another check for the local APIC and yet another place which registers the boot CPUs local APIC ID. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 9 ++++++--- arch/x86/kernel/smpboot.c | 18 ------------------ 2 files changed, 6 insertions(+), 21 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2130,9 +2130,12 @@ void __init init_apic_mappings(void) if (x2apic_mode) return; - if (!smp_found_config && !detect_init_APIC()) { - pr_info("APIC: disable apic facility\n"); - apic_disable(); + if (!smp_found_config) { + if (!detect_init_APIC()) { + pr_info("APIC: disable apic facility\n"); + apic_disable(); + } + num_processors = 1; } } --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1389,24 +1389,6 @@ early_param("possible_cpus", _setup_poss { int i, possible; - /* No processor was found in mptable or ACPI MADT */ - if (!num_processors) { - if (boot_cpu_has(X86_FEATURE_APIC)) { - int apicid = boot_cpu_physical_apicid; - int cpu = read_apic_id(); - - pr_warn("Boot CPU (id %d) not listed by BIOS\n", cpu); - - /* Make sure boot cpu is enumerated */ - if (apic->cpu_present_to_apicid(0) == BAD_APICID && - apic->apic_id_valid(apicid)) - generic_processor_info(apicid); - } - - if (!num_processors) - num_processors = 1; - } - i = setup_max_cpus ?: 1; if (setup_possible_cpus == -1) { possible = num_processors; From patchwork Mon Jul 17 23:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1404079vqt; Mon, 17 Jul 2023 16:31:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlEMbrQ/KnBqDp1pPPqaxZDEXCufUVFMFF4RpfIDMMEr1GU9j98dxs/HyNVLr/wMz1QUzpLl X-Received: by 2002:a05:6830:1148:b0:6b9:8feb:7f1e with SMTP id x8-20020a056830114800b006b98feb7f1emr11952079otq.35.1689636661029; Mon, 17 Jul 2023 16:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636660; cv=none; d=google.com; s=arc-20160816; b=DxZGsgodikUSFLa7+0DW549y8nwDNEkEdpAhelzaoXEb2fB13YSefIrdHm92ohB4kG awv+Hl43lbbsbtFwJBIvdLuvC8FNWMEKNtRVIRGuozETZWEZwHUdAHaiQ5uV0cQPUsE5 SN65thlyPohI5nbmf2LrbKoMdghyzr8jYIIcHSUijDASyxaGsV4EkLLOfUmIjBe0BvpW mY2fAoRwu/UFbLoV9O0G/mHzkB7PP4vuE/56heO2itCbNHkRme8bW3wjNBZPPy4O7IKH rkagkAtMJPMdWUwFqsNrIst57orn1NcbDDuRK6aTvWbfglp6djwRXXQHVTv5uYc4F0ln ekYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=XkrXDbsHY2D9ad8FanhOEsbWH/XRHFiUnXbnPluBQA4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Rwu6nbTEKcGioKl9jqzV9vaIWTza3yN2RQ+/JiNvTQBN2LG8m7Fl522/wST2DwFOWg DpUCE6xvUZZ1p9lLxbdtkdTzBdpyoXdaYWu8EwJXEQkC8igeXW+iaYIvQ7l9FhJ6EhxS +0Hz+PhAFuCTYi2rK465A7fXrGq6Qp0Qg7ZEZu89VHuUwHOmoukj54vkRcS8GRObhDbP nKjPRFGOR5srwtqmq5nELoA71yGSVA3bWe4sJkc/fvsaMpnyCJHx3jBSU0kmiSkY5Xe8 uuGae6flkpvcfVYO9InjuDxhSRosm937G6VG3tv2MYTBvc1C9Qb/k6Nc8m465zGhSUsw NQnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qHr9oU0r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Y2epMBLy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j184-20020a638bc1000000b0055c7f16bb29si544015pge.143.2023.07.17.16.30.47; Mon, 17 Jul 2023 16:31:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qHr9oU0r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=Y2epMBLy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231404AbjGQXP7 (ORCPT + 99 others); Mon, 17 Jul 2023 19:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229637AbjGQXP6 (ORCPT ); Mon, 17 Jul 2023 19:15:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC62A1BE9 for ; Mon, 17 Jul 2023 16:15:06 -0700 (PDT) Message-ID: <20230717223224.087678447@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=XkrXDbsHY2D9ad8FanhOEsbWH/XRHFiUnXbnPluBQA4=; b=qHr9oU0r8qd75flp4JICvC2WzEGZhBOzfBTH3weDwjKcfD6yYyGalQdW4miVeRgWj0l2e/ tIDwfzYN6GoMqSDz2C9DJDCM2DFUEtyol2WRxlDye+RWteoV9blj8j1+KozQJQlZvu9Qo8 XuFhXBO9qA6pYyfvhWleXKXTiw7IjJko1rC/K63sU+BkFiX2YhaO/4iEWZqfizTTIFMPeB ifAgFG8CjrNLaQ2LP0KVQR8U/PW+1xWjo8JhDNmjTccvNR3jtSAfRzQvk1HGSb7wBS+NAf NswX7cpXaJtqH6x9MQpUsffedDA9nI9KrDeKCFwpMdRD0Xu4zfd7Fl7ZISn68g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=XkrXDbsHY2D9ad8FanhOEsbWH/XRHFiUnXbnPluBQA4=; b=Y2epMBLyA0KIYVFu+nXXQ8o2u/0MgriTKxN4OMyc74CJxKXayyzEDBjmXwEq0julz01liv r0SLracH4XiXNzBg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 17/58] x86/apic: Nuke another processor check References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:00 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712451361327162 X-GMAIL-MSGID: 1771712451361327162 The boot CPUs local APIC is now always registered, so there is no point to have another unreadable validatation for it. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/smpboot.c | 17 ----------------- 1 file changed, 17 deletions(-) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1181,23 +1181,6 @@ static void __init smp_sanity_check(void set_nr_cpu_ids(8); } #endif - - if (!physid_isset(read_apic_id(), phys_cpu_present_map)) { - pr_warn("weird, boot CPU (#%d) not listed by the BIOS\n", - read_apic_id()); - - physid_set(read_apic_id(), phys_cpu_present_map); - } - - /* - * Should not be necessary because the MP table should list the boot - * CPU too, but we do it for the sake of robustness anyway. - */ - if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) { - pr_notice("weird, boot CPU (#%d) not listed by the BIOS\n", - boot_cpu_physical_apicid); - physid_set(read_apic_id(), phys_cpu_present_map); - } preempt_enable(); } From patchwork Mon Jul 17 23:15:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121688 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1408177vqt; Mon, 17 Jul 2023 16:44:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlET9lDzVUxlWC/ceePAVdiB0ByXjUA6pVV0AxAQis/KKPbQyfwYbeHAMbvdU3eC0nyekZuQ X-Received: by 2002:a05:6808:1241:b0:39c:93ba:cb92 with SMTP id o1-20020a056808124100b0039c93bacb92mr14670744oiv.8.1689637441405; Mon, 17 Jul 2023 16:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637441; cv=none; d=google.com; s=arc-20160816; b=lAiNzcwa3my97v1W9yge5Vrurar1jvxb7mxWOlLMV0aZ/32uFlkFujc555AQY3bAm3 +9JP4CErQpxYhx96rWTdb+ECilbH8IKqEZmmN5wEQd2YO4McidL1RqCqh/NvozyzlJPR 2JQO1ETdZRcnPdh97ynsg9U+cFb3HdkCepETGzrCCXc2t9hnAbQWw5fO7eJWYYl/5SSZ bP6oek4bx1CXxFE3ZnfjniaHm6rV2Ta+9wJvwCqZmzK9oTyVb4C28KptuX3WVYs1kpus jNID4pqHi3Hgk6rFjOIBmUriSQnyQxFgC4uC3juz2XtvY6OsRuyqTvv9RBSWf7FvAwlt kNYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=JNhxutEtXryZ8mfn8zBsCWNzhhaSX4crArjVTieUfW4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=b6EWRi7bDFizPLgdwsE+zXgzCOSvOIcfLRJ0CPz6WPgAvvYEvcRnXeRnyDTCaw5TpG NkD1UoLiKDltqvv5o3ffentkZSSEqY+qxn1UDM2+GYYiiylMtX5dwOb+hX95gto/6gM5 x7YiJyr+prfMG6GylMctfJNF0NucBUMGx4NIaPA6IJwavoeUVsP8IrK+6d2KqRNpzR8G RJ3h85yKk8TJll5fxhD1PJELvNZusieNfYf7z3C3IcCKFfE2ERrka4PF9mHHFABVvyCo BR85t4X13BHP9Q040M9ToTky2CzkOVM0XJ5/jUL3l4gVyuhMTpmkRiJppT6NdNZ+pS1t YImg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tPVYPQ5R; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=chAts+bF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q13-20020a63d60d000000b00553a99dd783si533083pgg.778.2023.07.17.16.43.48; Mon, 17 Jul 2023 16:44:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tPVYPQ5R; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=chAts+bF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbjGQXQQ (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjGQXQO (ORCPT ); Mon, 17 Jul 2023 19:16:14 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E2C110F9 for ; Mon, 17 Jul 2023 16:15:23 -0700 (PDT) Message-ID: <20230717223224.147988474@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=JNhxutEtXryZ8mfn8zBsCWNzhhaSX4crArjVTieUfW4=; b=tPVYPQ5RwA3FpuRSmL8I88TiobqjXSpUowNZ/tKDY0KoCSGmLqD3NtophJLqqvygbzti5i 3tkJ0Vbjm01eJtK4Of+ClRDKtE0zk71QK9xPc3N+V9AZbAUQAFfmDt7GHCFy2ecdbp48iJ izC9uSSC0b3GmylnUYjcmiOlZNLATAkrtGMXcqUjVD6XuOt2MtVkq7agmh/lVY7VbbZEYw y7GNgLIIMcWbx9TJB0HQArMj+OCK/NJj7IfmaZoWWIHicxOIYSJ0Xw3a6y7Ps91HH4foMA keEjeo0SRiEOgKfs+cJi+m8vpYMFJKNp3w4SUEdBrQG/5eS8RTuXsxyGzPtz0w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=JNhxutEtXryZ8mfn8zBsCWNzhhaSX4crArjVTieUfW4=; b=chAts+bFtOccc+XLYzmttX7xrePhNREvW4V+SHtWSutziUOSPsG7D2igHx7bALrXPXHFVw T0ydmwyvwVQhCUBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 18/58] x86/apic: Remove check_phys_apicid_present() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:02 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713269800350602 X-GMAIL-MSGID: 1771713269800350602 The only silly usage site is gone. Remove the gunk which was even outright wrong in the bigsmp_32 case which returned true unconditionally. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 -- arch/x86/kernel/apic/apic_common.c | 5 ----- arch/x86/kernel/apic/apic_flat_64.c | 2 -- arch/x86/kernel/apic/apic_noop.c | 2 -- arch/x86/kernel/apic/apic_numachip.c | 2 -- arch/x86/kernel/apic/bigsmp_32.c | 6 ------ arch/x86/kernel/apic/probe_32.c | 1 - arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 1 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 - arch/x86/xen/apic.c | 1 - 11 files changed, 24 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -305,7 +305,6 @@ struct apic { void (*setup_apic_routing)(void); int (*cpu_present_to_apicid)(int mps_cpu); void (*apicid_to_cpu_present)(int phys_apicid, physid_mask_t *retmap); - int (*check_phys_apicid_present)(int phys_apicid); int (*phys_pkg_id)(int cpuid_apic, int index_msb); u32 (*get_apic_id)(unsigned long x); @@ -485,7 +484,6 @@ extern u32 apic_flat_calc_apicid(unsigne extern bool default_check_apicid_used(physid_mask_t *map, int apicid); extern void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap); extern int default_cpu_present_to_apicid(int mps_cpu); -extern int default_check_phys_apicid_present(int phys_apicid); #else /* CONFIG_X86_LOCAL_APIC */ --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -35,11 +35,6 @@ int default_cpu_present_to_apicid(int mp } EXPORT_SYMBOL_GPL(default_cpu_present_to_apicid); -int default_check_phys_apicid_present(int phys_apicid) -{ - return physid_isset(phys_apicid, phys_cpu_present_map); -} - int default_apic_id_valid(u32 apicid) { return (apicid < 255); --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -124,7 +124,6 @@ static struct apic apic_flat __ro_after_ .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = flat_phys_pkg_id, .get_apic_id = flat_get_apic_id, @@ -213,7 +212,6 @@ static struct apic apic_physflat __ro_af .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = flat_phys_pkg_id, .get_apic_id = flat_get_apic_id, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -107,8 +107,6 @@ struct apic apic_noop __ro_after_init = .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = physid_set_mask_of_physid, - .check_phys_apicid_present = default_check_phys_apicid_present, - .phys_pkg_id = noop_phys_pkg_id, .get_apic_id = noop_get_apic_id, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -257,7 +257,6 @@ static const struct apic apic_numachip1 .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = numachip_phys_pkg_id, .get_apic_id = numachip1_get_apic_id, @@ -303,7 +302,6 @@ static const struct apic apic_numachip2 .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = numachip_phys_pkg_id, .get_apic_id = numachip2_get_apic_id, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -63,11 +63,6 @@ static void bigsmp_ioapic_phys_id_map(ph physids_promote(0xFFL, retmap); } -static int bigsmp_check_phys_apicid_present(int phys_apicid) -{ - return 1; -} - static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb) { return cpuid_apic >> index_msb; @@ -138,7 +133,6 @@ static struct apic apic_bigsmp __ro_afte .setup_apic_routing = bigsmp_setup_apic_routing, .cpu_present_to_apicid = bigsmp_cpu_present_to_apicid, .apicid_to_cpu_present = physid_set_mask_of_physid, - .check_phys_apicid_present = bigsmp_check_phys_apicid_present, .phys_pkg_id = bigsmp_phys_pkg_id, .get_apic_id = bigsmp_get_apic_id, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -80,7 +80,6 @@ static struct apic apic_default __ro_aft .setup_apic_routing = setup_apic_flat_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = physid_set_mask_of_physid, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = default_phys_pkg_id, .get_apic_id = default_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -250,7 +250,6 @@ static struct apic apic_x2apic_cluster _ .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = x2apic_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -174,7 +174,6 @@ static struct apic apic_x2apic_phys __ro .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = x2apic_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -846,7 +846,6 @@ static struct apic apic_x2apic_uv_x __ro .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = NULL, - .check_phys_apicid_present = default_check_phys_apicid_present, .phys_pkg_id = uv_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -154,7 +154,6 @@ static struct apic xen_pv_apic = { .setup_apic_routing = NULL, .cpu_present_to_apicid = xen_cpu_present_to_apicid, .apicid_to_cpu_present = physid_set_mask_of_physid, /* Used on 32-bit */ - .check_phys_apicid_present = default_check_phys_apicid_present, /* smp_sanity_check needs it */ .phys_pkg_id = xen_phys_pkg_id, /* detect_ht */ .get_apic_id = xen_get_apic_id, From patchwork Mon Jul 17 23:15:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121651 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1399833vqt; Mon, 17 Jul 2023 16:18:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlFXb9iSI/aGDssGMw8p/th4cEuGrhd5kiB/BDKoRjFy6zIDXhTW0AVofbK6OtxLmNDpi4S+ X-Received: by 2002:a17:906:2213:b0:988:f93:32e8 with SMTP id s19-20020a170906221300b009880f9332e8mr12895080ejs.26.1689635936313; Mon, 17 Jul 2023 16:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635936; cv=none; d=google.com; s=arc-20160816; b=vLgEzrC17cOnyCnnPRwF4J8Xi33LznvqfqOVzqNOsLx88bhMCxcXbJzJdOXIc7Wkx0 AE6WeXzfRT+ixQNpAv5vXkYD4lYwuiGhcwQSdOlVmaDe7fopuXpVdf94Cl9LMRCJOaC6 x36NMDVpbgpNXGsTG9qCbCQeojnGTNXRurICaRKjjXKUz++GKySuspXxAOoRa0XkWZ/H WBXDVAyDc2coRgOpCDywl2dSxj/OuKuy+Rb7QH1iqVbdqv/YQFD8nCgsECw1/7QK4UJG aqXPp/a32TnJ48C/ubtJETDYVf4BZLsW8jyO7GD6SErRBjovv512GyrFGopVdGQwof8I YwHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=aIQdyjgeuqgS020loHjY5emNS2jBJ0TkBAxP1UcK54o=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=QSWzmXBg1BdlJzQNe9eXGgMmcjequbLYy86Kynj51nBW0YedeVjcTKtjgxAvs1pWyv opghWFOy9UZ8XWQJpti9Qo/K5jkJlO6CR4RqxdbwWSlnEfo6/HLAAiokB02fHB8dCS66 Czeg/IMoneRmtk14NTz3RUZOogtAezWbu0cFJRr6CgsfTCCGT2s5JFPitz5HUwiR3oDY KbkDQpjeY8OW1syN4JDL/4m0zwDo5PkurAmod07uzOM06VnlN38l4EC6Of8Rr7ic82Qy 5hbwbjaVqE0wEFYMvYtpvkSeYGEq6oRCFmaZORdbxhaW8Fu1Nk8BHx+WTOeXD4Ezkch/ cTfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pVf2lpDp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=09NZQgSJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh17-20020a170906f8d100b009886470de61si291321ejb.857.2023.07.17.16.18.32; Mon, 17 Jul 2023 16:18:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pVf2lpDp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=09NZQgSJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbjGQXQR (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231403AbjGQXQP (ORCPT ); Mon, 17 Jul 2023 19:16:15 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F872170A for ; Mon, 17 Jul 2023 16:15:28 -0700 (PDT) Message-ID: <20230717223224.207131427@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=aIQdyjgeuqgS020loHjY5emNS2jBJ0TkBAxP1UcK54o=; b=pVf2lpDpYh4f4Usviw2kiFQu2Jrlvpla6YoI0IZG/Je+7EeA9q4wQXJO7zgw2cGOIhTr7D G4/L0eSr2IO68nZPcnUThmeg6prXf8by+wFL0/cALVQ4VwnxzppGdKnEzxwQ7mgvGtmj8N SoxA4LHNYRvpK8PxwvSezE5MkEjpahZhFSpPzqZV1eV95sdImEjwNkB6x8lxPw1RXe2iwS jTQNbfeR2A+ZrpwUfUL/Ts+u+1tsNYfls1dsVbMiJCbiFpdwiLLEQ1BlT2LXP+Df9+7rXu Rgj927xY2AUtkww2RNplnOw9rY5Zp7dN0wN1xilJibUpyDO9RjAYDf3MwNAlYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635704; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=aIQdyjgeuqgS020loHjY5emNS2jBJ0TkBAxP1UcK54o=; b=09NZQgSJHMQd45+whsEMRbCci79Ic6kHVNQJPgI/5G8hxpJby9SlVUEoYFWvRr+g/wYcg4 FMJ2PnKAbU/wNAAA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 19/58] x86/apic: Get rid of apic_phys References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:03 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711691859626108 X-GMAIL-MSGID: 1771711691859626108 No need for an extra variable to find out whether the APIC has been mapped or is accessible (X2APIC mode). Provide an inline for this and check apic_mmio_base which is only set when the local APIC has been mapped. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -99,6 +99,11 @@ static bool virt_ext_dest_id __ro_after_ /* For parallel bootup. */ unsigned long apic_mmio_base __ro_after_init; +static inline bool apic_accessible(void) +{ + return x2apic_mode || apic_mmio_base; +} + /* * Map cpu index to physical APIC ID */ @@ -199,8 +204,6 @@ unsigned int lapic_timer_period = 0; static void apic_pm_activate(void); -static unsigned long apic_phys __ro_after_init; - /* * Get the LAPIC version */ @@ -1127,8 +1130,7 @@ void clear_local_APIC(void) int maxlvt; u32 v; - /* APIC hasn't been mapped yet */ - if (!x2apic_mode && !apic_phys) + if (!apic_accessible()) return; maxlvt = lapic_get_maxlvt(); @@ -1218,8 +1220,7 @@ void apic_soft_disable(void) */ void disable_local_APIC(void) { - /* APIC hasn't been mapped yet */ - if (!x2apic_mode && !apic_phys) + if (!apic_accessible()) return; apic_soft_disable(); @@ -1921,7 +1922,6 @@ static __init void try_to_enable_x2apic( * be addressed must not be brought online. */ x2apic_set_max_apicid(apic_limit); - x2apic_phys = 1; } x2apic_enable(); } @@ -2895,11 +2895,11 @@ early_param("apic", apic_set_verbosity); static int __init lapic_insert_resource(void) { - if (!apic_phys) + if (!apic_mmio_base) return -1; /* Put local APIC into the resource map. */ - lapic_resource.start = apic_phys; + lapic_resource.start = apic_mmio_base; lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1; insert_resource(&iomem_resource, &lapic_resource); From patchwork Mon Jul 17 23:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121687 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1408117vqt; Mon, 17 Jul 2023 16:43:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9lkkpE7HgoQqOA7KMMgeaSVP1iDLQmSsGOX3IKpi4MDDwd87mYgtjQzfnbin587ZSW2Yx X-Received: by 2002:a17:90b:4a0f:b0:262:d49f:ee63 with SMTP id kk15-20020a17090b4a0f00b00262d49fee63mr12259014pjb.11.1689637429053; Mon, 17 Jul 2023 16:43:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637429; cv=none; d=google.com; s=arc-20160816; b=OOaRsJ0TMKoFv4vhDCTcWBphSuQlWlZl9iOURCLjjRiCYpfew00MrCzCgaXdJOU7q6 IpFi8XiQHk7AJvHA2/g9QlWGAkslQ7OrIy+fj8YaWFWWfg/Iv9+g1jcqaSEG5zgrXm54 o/2X34m9J7f4Az3krXPu6r7aYmMLmg2jI3PUFNTmltJGPjHEJrNq+1dfNFUi1CiILErR XZloXbh2OlOcB9982o4bd2cqCsJ8/3weip9QUUDAgUkSFM/OswNgwOGwK5Pdg3/qKZwO MXmBC4qFMrR0448sfobsumfy7pgmPXpIOccRlVZvS0KY8sNr7qsrFr8o2HYR56AOBcyQ y28Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=LOe1UoiHO0aHtIvZLfVAh+MlqMt/c3MCV5lR+OfD/ak=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=UxcKPQslwJxiIEIe7iMzgPpUHKnXR4Ez5MCyx4lPNPSX437vfVq3DNNPynrk/2nnIO 8X1ggyPDMiZiEtgXTYHUJ5olSreNbwlFAcC45EWK5iAClZ0i+pcigLQMEwxHZ28fRlMm dNPBtsELkxbFiKddh7WU2gHm4nZzlw8bpJliNMNHulJvzAsTuPN9lbbiTVkYlvIszt0i LUvOFHKT75It19ZDqJIV7jp4wgmtwLW5mHGr/bcvK1DKcdcUBV9NpfIQ+K1/Yegonodl Xj3XuCtVxolVW/fSpi/CsABd4jXJe/jAaSTH32zuon9Ch5chEek4iw4+QfPlg6duGDc/ YIGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DP+ucTBL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RQbAdPYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l1-20020a17090a72c100b00261266bf8b8si6456326pjk.179.2023.07.17.16.43.36; Mon, 17 Jul 2023 16:43:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DP+ucTBL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RQbAdPYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbjGQXQU (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231420AbjGQXQQ (ORCPT ); Mon, 17 Jul 2023 19:16:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A58D170B for ; Mon, 17 Jul 2023 16:15:28 -0700 (PDT) Message-ID: <20230717223224.268566460@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=LOe1UoiHO0aHtIvZLfVAh+MlqMt/c3MCV5lR+OfD/ak=; b=DP+ucTBLyxyq0EBs0k+ln0LD9AxMX1VyQ/hhPgpJMOnhr+QtIZw+EfjFAkP+DXSk5iRbIP 0hpeyOn/xyVxTcczHjbCaXTSZd3CT6xDA3OsEercG21qP3isLsEw0n+bIwMpHa6NNhhoe5 zrC41CD2xPyi+3RrnrbuNlGPvTV40Nn1raqZO1iSepAcIBByu5ORIjAMShN5rEAyGShwLf enlkPe1F1b9r55isJkG7JlterUd8SLiuaNT9euIcalvrwhgU92/qoT97JeAqPs8RQv9cig hp4OYrX7Hp/HV+dW3wvzL+PBGBl4smrM0dCgWrNyP+hJ88ZUG5STDyJxWhliVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=LOe1UoiHO0aHtIvZLfVAh+MlqMt/c3MCV5lR+OfD/ak=; b=RQbAdPYOX2KtL5Tcp4ULrped4lliiLCRgEZOw57CX7AxHODoEhlxpJG9oeqPb4wknIR7+4 5BvEYYF3dlenBYCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 20/58] x86/apic/32: Sanitize logical APIC ID handling References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:05 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713256804735166 X-GMAIL-MSGID: 1771713256804735166 apic::x86_32_early_logical_apicid() is yet another historical joke. It is used to preset the x86_cpu_to_logical_apicid per CPU variable during APIC enumeration with: - 1 shifted left by the CPU number - the physical APIC ID in case of bigsmp The latter is hillarious because bigsmp uses physical destination mode which never can use the logical APIC ID. It gets even worse. As bigsmp can be enforced late in the boot process the probe function overwrites the per CPU variable which is never used for this APIC type once again. Remove that gunk and store 1 << cpunr unconditionally if and only if the CPU number is less than 8, because the default logical destination mode only allows up to 8 CPUs. This is just an intermediate step before removing the per CPU insanity completely. Stay tuned. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 13 ------------- arch/x86/kernel/apic/apic.c | 4 ++-- arch/x86/kernel/apic/apic_noop.c | 11 ----------- arch/x86/kernel/apic/bigsmp_32.c | 18 ------------------ arch/x86/kernel/apic/probe_32.c | 7 ------- 5 files changed, 2 insertions(+), 51 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -315,19 +315,6 @@ struct apic { /* wakeup secondary CPU using 64-bit wakeup point */ int (*wakeup_secondary_cpu_64)(int apicid, unsigned long start_eip); -#ifdef CONFIG_X86_32 - /* - * Called very early during boot from get_smp_config(). It should - * return the logical apicid. x86_[bios]_cpu_to_apicid is - * initialized before this function is called. - * - * If logical apicid can't be determined that early, the function - * may return BAD_APICID. Logical apicid will be configured after - * init_apic_ldr() while bringing up CPUs. Note that NUMA affinity - * won't be applied properly during early boot in this case. - */ - int (*x86_32_early_logical_apicid)(int cpu); -#endif char *name; }; --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2434,8 +2434,8 @@ static void cpu_update_apic(int cpu, int early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; #endif #ifdef CONFIG_X86_32 - early_per_cpu(x86_cpu_to_logical_apicid, cpu) = - apic->x86_32_early_logical_apicid(cpu); + if (cpu < 8) + early_per_cpu(x86_cpu_to_logical_apicid, cpu) = 1U << cpu; #endif set_cpu_possible(cpu, true); physid_set(apicid, phys_cpu_present_map); --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -80,13 +80,6 @@ static void noop_apic_write(u32 reg, u32 WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled); } -#ifdef CONFIG_X86_32 -static int noop_x86_32_early_logical_apicid(int cpu) -{ - return BAD_APICID; -} -#endif - struct apic apic_noop __ro_after_init = { .name = "noop", .probe = noop_probe, @@ -130,8 +123,4 @@ struct apic apic_noop __ro_after_init = .icr_write = noop_apic_icr_write, .wait_icr_idle = noop_apic_wait_icr_idle, .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, - -#ifdef CONFIG_X86_32 - .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid, -#endif }; --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -28,12 +28,6 @@ static bool bigsmp_check_apicid_used(phy return false; } -static int bigsmp_early_logical_apicid(int cpu) -{ - /* on bigsmp, logical apicid is the same as physical */ - return early_per_cpu(x86_cpu_to_apicid, cpu); -} - /* * bigsmp enables physical destination mode * and doesn't use LDR and DFR @@ -154,27 +148,15 @@ static struct apic apic_bigsmp __ro_afte .icr_write = native_apic_icr_write, .wait_icr_idle = native_apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, - - .x86_32_early_logical_apicid = bigsmp_early_logical_apicid, }; void __init generic_bigsmp_probe(void) { - unsigned int cpu; - if (!probe_bigsmp()) return; apic = &apic_bigsmp; - for_each_possible_cpu(cpu) { - if (early_per_cpu(x86_cpu_to_logical_apicid, - cpu) == BAD_APICID) - continue; - early_per_cpu(x86_cpu_to_logical_apicid, cpu) = - bigsmp_early_logical_apicid(cpu); - } - pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name); } --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -16,11 +16,6 @@ #include "local.h" -static int default_x86_32_early_logical_apicid(int cpu) -{ - return 1 << cpu; -} - static void setup_apic_flat_routing(void) { #ifdef CONFIG_X86_IO_APIC @@ -101,8 +96,6 @@ static struct apic apic_default __ro_aft .icr_write = native_apic_icr_write, .wait_icr_idle = native_apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, - - .x86_32_early_logical_apicid = default_x86_32_early_logical_apicid, }; apic_driver(apic_default); From patchwork Mon Jul 17 23:15:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121667 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406094vqt; Mon, 17 Jul 2023 16:36:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlH9IKm7BOF9va64dPkpks3855tMUangRXEJvEqHDmX4ijP4l74ETVkUDYM23OJwoP616SD3 X-Received: by 2002:a05:6a00:1505:b0:67a:6af6:5171 with SMTP id q5-20020a056a00150500b0067a6af65171mr1198437pfu.13.1689637017084; Mon, 17 Jul 2023 16:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637017; cv=none; d=google.com; s=arc-20160816; b=ty9rfiguJ+azlHiiDApkGDto1p4LMG8n/756hPkn28H/nJ9bFfGkZCgM/pd6JC3SYS uFazmB2XZ1BJLi20hP5CUvEnygs1zLHepuf04VtIuDCM/GLX35mqIGqho2efYq6NlL+t 2DMu3li4CfAVYrqDqEgv5LtTfAPb5GwUnysNcKGGmGf4kJftJRCjtgR2iPYnRT4jpprB EQkIoLQtn44kVc+4KFQFVLvM8LhsIke5v2R08RCE1s0rvQhi9cieZfWkHlrznk/knqyh fsdAJcRTVbzwnOiLCO4KMZWrLewKoo+7pzIjjPUXMlmTRHu6qcL+ofT5laY1CijXI1/P hntA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=RDUEJbQ4kWbt2l91v1HLuRRyZwh425n2zPuDH8hhE+w=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=krrxPep4dfm+T3RL6A3Fl+ghscUAIr0Ufw9G++/pYhUQE79q71G3Fd/Mg45qpFL3m8 ZC8Qn6/OzcSLYRn7EtPHV7exDRts3uBjsoXbfVkiWtfe7+yJI1N37ZVkM/mJm1Wmu1pC stHt+FerjQUCvoyIGfYn24Sj8im6AFhG4E3zGA9VrW1uCQK/uW9cCLhuzmmJAtttuQyP fvZyqJUZJZ3HT9LZXVIcRZm5xm28uS7+QFxj9o7/twOVAK0tP5g/8EYqdi+sUmjtvEoA 0JuC1rxuFiqazZ2BmyMTS7cYxaDFmkHoxkgwo5HjWawdXB/JHlKfYeNt1V6zUKgsD7jU hh8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EQ3Rk00r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=M59EGHjA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l4-20020a63ba44000000b00550e8b3614asi526326pgu.901.2023.07.17.16.36.44; Mon, 17 Jul 2023 16:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EQ3Rk00r; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=M59EGHjA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbjGQXQd (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231422AbjGQXQb (ORCPT ); Mon, 17 Jul 2023 19:16:31 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A999172E for ; Mon, 17 Jul 2023 16:15:45 -0700 (PDT) Message-ID: <20230717223224.328307760@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=RDUEJbQ4kWbt2l91v1HLuRRyZwh425n2zPuDH8hhE+w=; b=EQ3Rk00rf3sVU10BxtvPZV6/6BI2sAMv0ynyJSJy/ZQqfJYlDchem0giciNwE4fkR0LiIU h1IWUm6bDWXUkjLh1icTpmQ5rJJvKR7tAlFBevC2C0nqVCbLd2/plc2gTMEHgFsjAnvZ4T c9ZW65DamhpU+j+AZIWXIsxO0foCDrdsmYLzDPgcyh3W/D1ORWz57jXWCezRQDo10GA6M2 iia08BiH8QBiQpMKoydcAT9mJCPnmD0mTJ0aKDXdP/XfefJKD+iHmLx/oP56X5dOzdIDkv ASzgwR1C6ZYyKc+i/AoLJkOKFrQN8ZHNgMlxXc+T+iI9cw7811WPUOwSKdAHdg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=RDUEJbQ4kWbt2l91v1HLuRRyZwh425n2zPuDH8hhE+w=; b=M59EGHjAOsvIzjUf7LmE/wgADhnqezVIlDcvVLUqSDmSgmyL4ug52kJfOBduHpim92br9C RLEqt6oxqAP+h7DQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 21/58] x86/apic/32: Remove x86_cpu_to_logical_apicid References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:07 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712824546978859 X-GMAIL-MSGID: 1771712824546978859 This per CPU variable is just yet another form of voodoo programming. The boot ordering is: per_cpu(x86_cpu_to_logical_apicid, cpu) = 1U << cpu; ..... setup_apic() apic->init_apic_ldr() default_init_apic_ldr() apic_write(SET_APIC_LOGICAL_ID(1UL << smp_processor_id(), APIC_LDR); id = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR); WARN_ON(id != per_cpu(x86_cpu_to_logical_apicid, cpu)); per_cpu(x86_cpu_to_logical_apicid, cpu) = id; So first write the default into LDR and then validate it against the same default which was set up during early boot APIC enumeration. Brilliant, isn't it? The comment above the per CPU variable declaration describes it well: 'Let's keep it ugly for now.' Remove the useless gunk and use '1U << cpu' consistently all over the place. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/smp.h | 3 --- arch/x86/kernel/apic/apic.c | 31 ------------------------------- arch/x86/kernel/apic/ipi.c | 36 +++++++++--------------------------- arch/x86/kernel/setup_percpu.c | 7 ------- 4 files changed, 9 insertions(+), 68 deletions(-) --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -22,9 +22,6 @@ DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_l2c DECLARE_EARLY_PER_CPU_READ_MOSTLY(u16, x86_cpu_to_apicid); DECLARE_EARLY_PER_CPU_READ_MOSTLY(u32, x86_cpu_to_acpiid); -#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) -DECLARE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid); -#endif struct task_struct; --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -113,15 +113,6 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_a EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid); #ifdef CONFIG_X86_32 - -/* - * On x86_32, the mapping between cpu and logical apicid may vary - * depending on apic in use. The following early percpu variable is - * used for the mapping. This is where the behaviors of x86_64 and 32 - * actually diverge. Let's keep it ugly for now. - */ -DEFINE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid, BAD_APICID); - /* Local APIC was disabled by the BIOS and enabled by the kernel */ static int enabled_via_apicbase __ro_after_init; @@ -1589,24 +1580,6 @@ static void setup_local_APIC(void) */ apic->init_apic_ldr(); -#ifdef CONFIG_X86_32 - if (apic->dest_mode_logical) { - int logical_apicid, ldr_apicid; - - /* - * APIC LDR is initialized. If logical_apicid mapping was - * initialized during get_smp_config(), make sure it matches - * the actual value. - */ - logical_apicid = early_per_cpu(x86_cpu_to_logical_apicid, cpu); - ldr_apicid = GET_APIC_LOGICAL_ID(apic_read(APIC_LDR)); - if (logical_apicid != BAD_APICID) - WARN_ON(logical_apicid != ldr_apicid); - /* Always use the value from LDR. */ - early_per_cpu(x86_cpu_to_logical_apicid, cpu) = ldr_apicid; - } -#endif - /* * Set Task Priority to 'accept all except vectors 0-31'. An APIC * vector in the 16-31 range could be delivered if TPR == 0, but we @@ -2433,10 +2406,6 @@ static void cpu_update_apic(int cpu, int #if defined(CONFIG_SMP) || defined(CONFIG_X86_64) early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; #endif -#ifdef CONFIG_X86_32 - if (cpu < 8) - early_per_cpu(x86_cpu_to_logical_apicid, cpu) = 1U << cpu; -#endif set_cpu_possible(cpu, true); physid_set(apicid, phys_cpu_present_map); set_cpu_present(cpu, true); --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -243,50 +243,32 @@ void default_send_IPI_self(int vector) } #ifdef CONFIG_X86_32 - -void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, - int vector) +void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector) { unsigned long flags; - unsigned int query_cpu; - - /* - * Hack. The clustered APIC addressing mode doesn't allow us to send - * to an arbitrary mask, so I do a unicasts to each CPU instead. This - * should be modified to do 1 message per cluster ID - mbligh - */ + unsigned int cpu; local_irq_save(flags); - for_each_cpu(query_cpu, mask) - __default_send_IPI_dest_field( - early_per_cpu(x86_cpu_to_logical_apicid, query_cpu), - vector, APIC_DEST_LOGICAL); + for_each_cpu(cpu, mask) + __default_send_IPI_dest_field(1U << cpu, vector, APIC_DEST_LOGICAL); local_irq_restore(flags); } void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector) { + unsigned int cpu, this_cpu = smp_processor_id(); unsigned long flags; - unsigned int query_cpu; - unsigned int this_cpu = smp_processor_id(); - - /* See Hack comment above */ local_irq_save(flags); - for_each_cpu(query_cpu, mask) { - if (query_cpu == this_cpu) + for_each_cpu(cpu, mask) { + if (cpu == this_cpu) continue; - __default_send_IPI_dest_field( - early_per_cpu(x86_cpu_to_logical_apicid, query_cpu), - vector, APIC_DEST_LOGICAL); - } + __default_send_IPI_dest_field(1U << cpu, vector, APIC_DEST_LOGICAL); + } local_irq_restore(flags); } -/* - * This is only used on smaller machines. - */ void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector) { unsigned long mask = cpumask_bits(cpumask)[0]; --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c @@ -184,10 +184,6 @@ void __init setup_per_cpu_areas(void) per_cpu(x86_cpu_to_acpiid, cpu) = early_per_cpu_map(x86_cpu_to_acpiid, cpu); #endif -#ifdef CONFIG_X86_32 - per_cpu(x86_cpu_to_logical_apicid, cpu) = - early_per_cpu_map(x86_cpu_to_logical_apicid, cpu); -#endif #ifdef CONFIG_NUMA per_cpu(x86_cpu_to_node_map, cpu) = early_per_cpu_map(x86_cpu_to_node_map, cpu); @@ -214,9 +210,6 @@ void __init setup_per_cpu_areas(void) early_per_cpu_ptr(x86_cpu_to_apicid) = NULL; early_per_cpu_ptr(x86_cpu_to_acpiid) = NULL; #endif -#ifdef CONFIG_X86_32 - early_per_cpu_ptr(x86_cpu_to_logical_apicid) = NULL; -#endif #ifdef CONFIG_NUMA early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; #endif From patchwork Mon Jul 17 23:15:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121666 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406057vqt; Mon, 17 Jul 2023 16:36:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGT+VILCtoY+sPMBDuyRPgzmTsJNM1Lz78RyIQ0sVSM515+rCOE9S+teDeWGw5ahF4oOnBh X-Received: by 2002:a05:6a00:a29:b0:675:667c:f261 with SMTP id p41-20020a056a000a2900b00675667cf261mr17764858pfh.2.1689637010652; Mon, 17 Jul 2023 16:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637010; cv=none; d=google.com; s=arc-20160816; b=NrUpx2LmB5eRZhAz3h6NChY5sTvzwLribQJ0hgtixFLvkx8fXSs9JvWj4TP3AmAWFJ yyF0E2TWXixDT9Rq1bfSzOG4ikqJ0LhMra+e+LSe0CW/y4ABpmU3Ueueuyj8ld3gPVK2 zS2TUf7Wl78HBkfkp1bqsiuoqbOtFC2/tGMKvtwIpyR0X6dDDHBuaYIbVqphx+WZqqcA G5foHaAGvBZGeHDIGfbEiGcZ6L0SB8aQr+sGk9UIEBNnIY9JLbmI0C+F0RitxWoCdPRu VWnKjnPL1uNH6q3UJ+kO8Af+MUjnWK8+bnSwWwHMtnb8UI3fCge1uBj9xNDbrdLdqWY6 25mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=oBy16z9oVs8uzIdM6vzKosS3I9qeD3Jk8eFl+Cs6+fk=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=d1Grp+2w5f+ks3vKD4tMVSdTmLExi2gTWiGTsdlm6y+pm8/1BY+9+QUwPSG2Ibuyzi dhDXQnxDR3u6/+4bmt79gC8MoOmXB9Mk/2SX1+oqDd1E5+NKxR2pK/Lhahcv84SHXMRS Giy8Yry5SAcnjSJQc1Muh0iHundpg5zApdhIjVACdmxBLKxpuGLyK1eA8TgFIVeZdmm1 CUtOFC6L//+jOSW/yjdU6PqaVadARfBf8XjSrLBj1QbD5LVnAsAdcOePyJqKI6B1tO+D mF11tY8kxy5B3Hdqny0dl+12FzoKkiQm0ev9eACjnt+2wlKQVjgYyBFNkTg31NpQNfOB D2rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tmIcEk9X; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a63f718000000b0054fdb063301si561440pgh.252.2023.07.17.16.36.37; Mon, 17 Jul 2023 16:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tmIcEk9X; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231438AbjGQXQb (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231432AbjGQXQ3 (ORCPT ); Mon, 17 Jul 2023 19:16:29 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002A4132 for ; Mon, 17 Jul 2023 16:15:42 -0700 (PDT) Message-ID: <20230717223224.387322230@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oBy16z9oVs8uzIdM6vzKosS3I9qeD3Jk8eFl+Cs6+fk=; b=tmIcEk9XpjQcUhC77tzrt+q6FJfA7Knf1Ts0BMgMqrctHb+QoRjibisDoJ+IlNuvLYbdHv Y3t5PbjQ34QB12uGL4rRDgtbBlTsBEQM1vUxhslhlp+EL0AXi6WVOspkW3vWriRoDHWIcF 21rlQp09gIBPBDTSx5doUgfDue9Dj3Lope9QbyjBGRcC+4Cm52sVTdR9caVuRM9ub1XIyf VeDbUgz7AcsvfhZUDIy3CS8yderQtxaVl1K0cR6ELUAAA0RG9Mv6X6IA57H6O05F5gE60d 8U9Y6un/5bfDVB6EWESnD706BJrJHTDUmKTYhdgwzI0qnB0Fppl2yyODXwiD+g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635709; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=oBy16z9oVs8uzIdM6vzKosS3I9qeD3Jk8eFl+Cs6+fk=; b=OMBprqP0VGos8jmJkNRVP95C0AxZwsyctJ+1dU9Xsy94RSKAwUReBcNWlf5zFtOlMcIbqH rmyWLpGg2NiFaDAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 22/58] x86/apic/ipi: Code cleanup References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:08 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712818246323814 X-GMAIL-MSGID: 1771712818246323814 Remove completely useless and mindlessly copied comments and tidy up the code which causes eye bleed when looking at it. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/ipi.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -184,18 +184,13 @@ void default_send_IPI_single_phys(int cp void default_send_IPI_mask_sequence_phys(const struct cpumask *mask, int vector) { - unsigned long query_cpu; unsigned long flags; + unsigned long cpu; - /* - * Hack. The clustered APIC addressing mode doesn't allow us to send - * to an arbitrary mask, so I do a unicast to each CPU instead. - * - mbligh - */ local_irq_save(flags); - for_each_cpu(query_cpu, mask) { + for_each_cpu(cpu, mask) { __default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, - query_cpu), vector, APIC_DEST_PHYSICAL); + cpu), vector, APIC_DEST_PHYSICAL); } local_irq_restore(flags); } @@ -203,18 +198,15 @@ void default_send_IPI_mask_sequence_phys void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask, int vector) { - unsigned int this_cpu = smp_processor_id(); - unsigned int query_cpu; + unsigned int cpu, this_cpu = smp_processor_id(); unsigned long flags; - /* See Hack comment above */ - local_irq_save(flags); - for_each_cpu(query_cpu, mask) { - if (query_cpu == this_cpu) + for_each_cpu(cpu, mask) { + if (cpu == this_cpu) continue; __default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, - query_cpu), vector, APIC_DEST_PHYSICAL); + cpu), vector, APIC_DEST_PHYSICAL); } local_irq_restore(flags); } @@ -283,7 +275,6 @@ void default_send_IPI_mask_logical(const local_irq_restore(flags); } -/* must come after the send_IPI functions above for inlining */ static int convert_apicid_to_cpu(int apic_id) { int i; From patchwork Mon Jul 17 23:15:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1424683vqt; Mon, 17 Jul 2023 17:29:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEMxOSI7iVMT+U0KgQWBgzKwQM0GAUh4RBySwn52L0PLpFwKKPGBIeVtQLPLiem1eh9zrK+ X-Received: by 2002:a17:902:e54a:b0:1b8:a54c:6183 with SMTP id n10-20020a170902e54a00b001b8a54c6183mr17783680plf.46.1689640184419; Mon, 17 Jul 2023 17:29:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640184; cv=none; d=google.com; s=arc-20160816; b=gamXAtucUPZXeq7W/VbBFlvSfB/Cx6rjcHaB1GS8FW9pq8oJuJZbc7w4cdlgdJU5LY cf7Iuf3scBRQmGdea/OL7aktowrqcsmzPvyF/AJgQX/tpdF0HdVzD1z9g2cRNET5zqoQ 74wNh/O1s1ZtkU9/o+qiuimCZoVte3koflhvgVReZ7xxOi8ReREgqlp1+I8zPKdyPRJb X8y0g9P3zWw+PqnYyI98wN5iNDGAQXicTBMxwf8RQ0m3NL/sfljI8MRPqRA+2gh/ltWM bcq0xO+4KjnnPWkETxiLGH2qTQh4mPhv/R9rKCJEC7rDW3DIyKvWwwLUU1fc+xQ48gIp xh1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=cjdrCvZHnH3sO0Olcvdwl8Hi5blCr2ZcSnmxA24BUR4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=PBXDEcvPt3i7chWAL/w1QFIVF7e+romyBdAm9r3al197U7Szr948nvVePiG2C3bMnu g69OX2fi2KnxTt56m/57vuMl5NZXfmGmRDhmQUcCWfHYY3VImuWDpACrtJ0eBLcgFyTZ G/0mt9Yqux4hoAOksPRDnEtXqXUKOhWTu2bXWA32cBPCKnB35YcSvgzMtO/SmcgeRy3P mdWnLQQOkdACjue1wOSWh+xU7LescT5t2QuDrNNovGKzmXTgrVjGgSFnR6Vuar0F1hvn d983StnjWBOzJ5Y55+QEpku7QUVXejvumNgn1nS4bdQ+4XpY5ZIYCVLtVSNaCd4vQ1if QnSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=y+8T2oDv; dkim=neutral (no key) header.i=@linutronix.de header.b=dMchqiD6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a17090332d100b001afd000029bsi680307plr.581.2023.07.17.17.29.30; Mon, 17 Jul 2023 17:29:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=y+8T2oDv; dkim=neutral (no key) header.i=@linutronix.de header.b=dMchqiD6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbjGQXQk (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbjGQXQe (ORCPT ); Mon, 17 Jul 2023 19:16:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DBE1737 for ; Mon, 17 Jul 2023 16:15:46 -0700 (PDT) Message-ID: <20230717223224.444954484@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cjdrCvZHnH3sO0Olcvdwl8Hi5blCr2ZcSnmxA24BUR4=; b=y+8T2oDvcEKeyeCklnaCk/WqabLO+VADf6/86pJOumvRNn807m/oM/f4/ZaF5eqKLpUJMe WyyZIKdKMOnXFZNL85mdijnrsPok8rCWBoj9m6n7YP9eOec6BJKerMR02JPrpKCRR/SgkY LbcIieBr6+SgFB4gdawQZfkdS50w1fmwXJeSWkXHPVewa1s7kHPQ1X7++8wM3nWpPW+NM6 OmjEhNgCSCHKySE0xdxT3/CixuiiJVA+YYByUOX79ZvuNHnvmLaKE0elftUvvTdKaXXqVD q4HbBJSqcwbs9y+B1XUrZAHXcZmTZa8zUsfTe6b7+Z1lIaWCSNLjhKvSKWJFCw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cjdrCvZHnH3sO0Olcvdwl8Hi5blCr2ZcSnmxA24BUR4=; b=dMchqiD6AEKV99oENrDA29LWzQtH/vD5fWx6eCd9Xl/jF7vVCTzTSpOQGbuMgA35gtqdJP gX912dygNeZJVnCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 23/58] x86/apic: Mop up early_per_cpu() abuse References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:10 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716146253441648 X-GMAIL-MSGID: 1771716146253441648 UV X2APIC uses the per CPU variable from: native_smp_prepare_cpus() uv_system_init() uv_system_init_hub() which is long after the per CPU areas have been set up. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/x2apic_uv_x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -1843,7 +1843,7 @@ static void __init uv_system_init_hub(vo /* Initialize per CPU info: */ for_each_possible_cpu(cpu) { - int apicid = early_per_cpu(x86_cpu_to_apicid, cpu); + int apicid = per_cpu(x86_cpu_to_apicid, cpu); unsigned short bid; unsigned short pnode; From patchwork Mon Jul 17 23:15:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406413vqt; Mon, 17 Jul 2023 16:38:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlHoMRFAtiVxLmIIdEy8R5hpc3CPU7Fn+6Dy/NnmW6px1wIQD7Qk/2OBg1riqt+tbqzkms9m X-Received: by 2002:a05:6808:171c:b0:3a3:4314:8dc0 with SMTP id bc28-20020a056808171c00b003a343148dc0mr12174096oib.5.1689637086176; Mon, 17 Jul 2023 16:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637086; cv=none; d=google.com; s=arc-20160816; b=KcWEH5rp4Ox6aWBaNN0V4wpmI1MEZxKS9/vzH2O+dVjtcxeGvYjUf11GB4IYjiTs+q T3/oeN6ypHCmWO3Ywk8fjZJg+CIyGCbO6UHcdx5BmgZF0HCodQCXe1K5wYs725QSkxX3 CwZd9y7iuOKzn35plotCIGv2HfV6qVD/H0nvp1SyKozA6/C75kgNcHEOFvhvHwL5yrtD q4n058mhENtv/PMvSQiKOKTEOWUCwKCgYWx+GX1Kw9cBCz20APKtP8pFe/P12I1tu8Vt ZDkyDGm7npRV6O6qSsE2eGF9RrOYl+Bz3OrNkzmdBRecganaARBGm3hj4v+qreq5mmKg ucSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=KOrCgxfZUWOEP5kQU9kDQX721qeaGgb7AagTW/GicUQ=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=SQ/KsIgQoIto4cC7Rb23w0AGnmPYOvqKzJgRTqHNycvwvZLJiDxpHHM/DRooFz2hPH jRZjl3vInbABE6OKj065/KQPqWclr/LoIM75RPHOmOOyGWGKuwlKtNBkaBNbUELtruj6 IAvQwtedfR61iiIaTgw1eAgMFFYzPhFUgx3NMgfrQeciwbAOAaN7CtkQd7PDlGOGfDp2 56kQqvB9URQ3NpKz2+O1mmhRyVAGmu5M0I1bKRdj2Z4fHv8fJGFyxe9AE1TolZWX8wms mHQ4Fqgbl9wvewLydlgH8upSy/9EPjV2naWyGJby5KOJJF12LgY5xRJvrdSgAHx6xqVP JO4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oiRhFEFF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j184-20020a638bc1000000b0055c7f16bb29si549736pge.143.2023.07.17.16.37.53; Mon, 17 Jul 2023 16:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=oiRhFEFF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231452AbjGQXQn (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231459AbjGQXQk (ORCPT ); Mon, 17 Jul 2023 19:16:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E67619B3 for ; Mon, 17 Jul 2023 16:15:51 -0700 (PDT) Message-ID: <20230717223224.504601096@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=KOrCgxfZUWOEP5kQU9kDQX721qeaGgb7AagTW/GicUQ=; b=oiRhFEFFvGuOGsKWDiQ8THEq6of5+8aMxDRz8+YOj50I8rOP8AY970wOn35phqd76f38XD 8zFZw3BC4E+ZRTJpTr258Pf6glz18bevFmz9K6hBj8mpl+QBFT1gSk4iufxaN9carsBtW5 Y9hPPM2z54hgpT/d95k7+tP8iAenhd3Zu24DrOkb4wMhbk71PFHTUeaAQHx9cMzZ1ScpzO +vonEO4uHaQTiCsl6RtjECwQNpDVscxUFX9mv5tM7A1TvJmY9NGwsttjuzZyNEnnMhNsdZ +cZpTde91cpythj/IUHK3pJ0alWpYsPvUwPplg6p/kTdR+rYnQmi2MFL3FPH8w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=KOrCgxfZUWOEP5kQU9kDQX721qeaGgb7AagTW/GicUQ=; b=Nc/fnigbZfoKzY8HMkUzD6HHp5XpCEeUqCsfekUtoDmN4YGLGQMvvszhGWqLGWAXsaq1Ai 5HwnoT74tFmHmJAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 24/58] x86/apic/32: Remove pointless default_acpi_madt_oem_check() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:11 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712897084216249 X-GMAIL-MSGID: 1771712897084216249 On 32bit there is no APIC implementing the acpi_madt_oem_check() except XEN PV, but that does not matter at all. generic_apic_probe() runs before ACPI tables are parsed. This selects the XEN APIC if there is no command line override because the XEN APIC driver is the first to be probed. If there is a command line override then the XEN PV driver won't be selected in the MADT OEM check either. As there is no other MADT check implemented for 32bit APICs, this whole excercise is a NOOP and can be removed. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 4 +++- arch/x86/kernel/apic/bigsmp_32.c | 1 - arch/x86/kernel/apic/probe_32.c | 22 ---------------------- 3 files changed, 3 insertions(+), 24 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -459,10 +459,12 @@ static inline unsigned int read_apic_id( #ifdef CONFIG_X86_64 typedef int (*wakeup_cpu_handler)(int apicid, unsigned long start_eip); extern void acpi_wake_cpu_handler_update(wakeup_cpu_handler handler); +extern int default_acpi_madt_oem_check(char *, char *); +#else +static inline int default_acpi_madt_oem_check(char *a, char *b) { return 0; } #endif extern int default_apic_id_valid(u32 apicid); -extern int default_acpi_madt_oem_check(char *, char *); extern void default_setup_apic_routing(void); extern u32 apic_default_calc_apicid(unsigned int cpu); --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -112,7 +112,6 @@ static struct apic apic_bigsmp __ro_afte .name = "bigsmp", .probe = probe_bigsmp, - .acpi_madt_oem_check = NULL, .apic_id_valid = default_apic_id_valid, .apic_id_registered = bigsmp_apic_id_registered, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -60,7 +60,6 @@ static struct apic apic_default __ro_aft .name = "default", .probe = probe_default, - .acpi_madt_oem_check = NULL, .apic_id_valid = default_apic_id_valid, .apic_id_registered = default_apic_id_registered, @@ -176,24 +175,3 @@ void __init generic_apic_probe(void) } printk(KERN_INFO "Using APIC driver %s\n", apic->name); } - -/* This function can switch the APIC even after the initial ->probe() */ -int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id) -{ - struct apic **drv; - - for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { - if (!(*drv)->acpi_madt_oem_check) - continue; - if (!(*drv)->acpi_madt_oem_check(oem_id, oem_table_id)) - continue; - - if (!cmdline_apic) { - apic = *drv; - printk(KERN_INFO "Switched to APIC driver `%s'.\n", - apic->name); - } - return 1; - } - return 0; -} From patchwork Mon Jul 17 23:15:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406757vqt; Mon, 17 Jul 2023 16:39:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNKzzHo0P5OYbUjnrV1Z5bGcp2Q3RAFn+4y9o1yU9H9ZheTB9p8UJTGZdR3qWsYxeFPHdA X-Received: by 2002:a05:6358:c1d:b0:135:4dcf:9a2a with SMTP id f29-20020a0563580c1d00b001354dcf9a2amr10433447rwj.7.1689637150286; Mon, 17 Jul 2023 16:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637150; cv=none; d=google.com; s=arc-20160816; b=RKXfK7rVfzch6958b3Qtrv9GAH0qxgO9NAI4aM7gdnrn9K8kcQiW6/N1aPNWtOwXAN jzUrvJtlkyJ8IH5DJnRcPUqcZvVGAs2Crc5QsFYDcSYq51Etp7rtJoKNFN6cbWC/s7jY ixRkiYA0hLgk95a+v98LW9kYUazGnx4Lv5v4eZ5DDXYJbY7xWB1cbwzzinzAAmXbfq5M T5TzPH8+WuGmErXXWu5g/4GoUfN9xI22F8PMUDLGOpC4TV+iC5H5tRplR0LnOrs0+dmj S/EDmak97wijJzcdY/4ZhMsd9KJsn+uNUioKM1Vdaw5+XHEJBjxyn2+yF34PiVFpUeIt Qkpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=rQwiDVrZdKXtkOeCkuU+BAsq9XS3fbn/pUNfphOa6Ug=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=KPVpD/ozZJt6gBnrux+an3eZfFdLObe98thpG3yFeuqc6hOPHD8eQjXKtuk+IdqzA3 Bg0QSDRiEyHchjvA5LiksFFWoxLEnKnRONCStwU9vXxB/u478xBgHjdZSqIxNtamQr1X hI4Lh2PWf3uyhr3lMgtfqYLhS8IUXkkKsHpOb4GqoOnt1nK86GsYv8vyw/cbzsYKGqmf GAihDnKA3vA+Wjk8AClrOLcVktH9zIPhQYWhKnHR2xpKeGJxbIP45l4z2v4jS9zhnzTx 9lI9xmUTjSqmffo7GnFsX4NJSMSKN4umzOTOfE0xAuWJcFKVETx82q2TOXVkruujfYZ4 XdHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Pim/4Lru"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=hzhBJlXw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f35-20020a635123000000b0055337508370si501123pgb.889.2023.07.17.16.38.57; Mon, 17 Jul 2023 16:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Pim/4Lru"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=hzhBJlXw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231470AbjGQXR1 (ORCPT + 99 others); Mon, 17 Jul 2023 19:17:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230325AbjGQXRZ (ORCPT ); Mon, 17 Jul 2023 19:17:25 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71691AC for ; Mon, 17 Jul 2023 16:16:43 -0700 (PDT) Message-ID: <20230717223224.564567063@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rQwiDVrZdKXtkOeCkuU+BAsq9XS3fbn/pUNfphOa6Ug=; b=Pim/4LrukbAuWI2R7g6Iki1lM0VXNQWjRthfzaL22Na0tDjjPIfMO5sG/Y6coO6Hx3eb3l +umH32CdFdB1Ob8eT0EkEZ3Ze62SiYZ4R1u0D4UYMq4MadwqEqY0I0i/e+O1c4wVJNbrbb hEfFbVzsi9TwesIU9bhBMJqLZe9fIIE5b8zKJOn14+aOyjL0Upyl5ok+ay7vPSp6WLyPky Q22Uu/FVeLSFid2urWQDQB/I1OWGPUzMhJGSjUvSI/J/ZqsQEPlQWtrW+IQMLLIsAPLli3 7GGmJw1HB4Mc4gguWxqKhM1y3EV3Ra+Y7tZyMjbmAsFr4L6PW3P1yFYKaXUGtQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rQwiDVrZdKXtkOeCkuU+BAsq9XS3fbn/pUNfphOa6Ug=; b=hzhBJlXwg7x0YxSpbK4V31U/2U+qJdnSGHMqjXU+hC3oXhHjNOl5cN7+sqnSEqcDyf5oMO Jf/joeeBgWmmaNAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 25/58] x86/apic/32: Decrapify the def_bigsmp mechanism References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:13 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712964651006239 X-GMAIL-MSGID: 1771712964651006239 If the system has more than 8 CPUs then XAPIC and the bigsmp APIC driver is required. This is ensured via: 1) Enumerating all possible CPUs up to NR_CPUS 2) Checking at boot CPU APIC setup time whether the system has more than 8 CPUs and has an XAPIC. If that's the case then it's attempted to install the bigsmp APIC driver and a magic variable 'def_to_bigsmp' is set to one. 3) If that magic variable is set and CONFIG_X86_BIGSMP=n and the system has more than 8 CPUs smp_sanity_check() removes all CPUs >= #8 from the present and possible mask in the most convoluted way. This logic is completely broken for the case where the bigsmp driver is enabled, but not selected due to a command line option specifying the default APIC. In that case the system boots with default APIC in logical destination mode and fails to reduce the number of CPUs. That aside the above which is sprinkled over 3 different places is yet another piece of art. It would have been too obvious to check the requirements upfront and limit nr_cpu_ids _before_ enumerating tons of CPUs and then removing them again. Implement exactly this. Check the bigsmp requirement when the boot APIC is registered which happens _before_ ACPI/MPTABLE parsing and limit the number of CPUs to 8 if it can't be used. Switch it over when the boot CPU apic is set up if necessary. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic.c | 3 +++ arch/x86/kernel/apic/bigsmp_32.c | 22 ++++++++++------------ arch/x86/kernel/apic/local.h | 11 +++++++++++ arch/x86/kernel/apic/probe_32.c | 35 +++++++++++++++++------------------ arch/x86/kernel/smpboot.c | 37 ------------------------------------- 5 files changed, 41 insertions(+), 67 deletions(-) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -63,6 +63,8 @@ #include #include +#include "local.h" + unsigned int num_processors; unsigned disabled_cpus; @@ -2418,6 +2420,7 @@ static __init void cpu_set_boot_apic(voi { cpuid_to_apicid[0] = boot_cpu_physical_apicid; cpu_update_apic(0, boot_cpu_physical_apicid); + x86_32_probe_bigsmp_early(); } int generic_processor_info(int apicid) --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -100,12 +100,7 @@ static const struct dmi_system_id bigsmp static int probe_bigsmp(void) { - if (def_to_bigsmp) - dmi_bigsmp = 1; - else - dmi_check_system(bigsmp_dmi_table); - - return dmi_bigsmp; + return dmi_check_system(bigsmp_dmi_table); } static struct apic apic_bigsmp __ro_after_init = { @@ -149,14 +144,17 @@ static struct apic apic_bigsmp __ro_afte .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; -void __init generic_bigsmp_probe(void) +bool __init apic_bigsmp_possible(bool cmdline_override) { - if (!probe_bigsmp()) - return; - - apic = &apic_bigsmp; + return apic == &apic_bigsmp || !cmdline_override; +} - pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name); +void __init apic_bigsmp_force(void) +{ + if (apic != &apic_bigsmp) { + apic = &apic_bigsmp; + pr_info("Overriding APIC driver with bigsmp\n"); + } } apic_driver(apic_bigsmp); --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -66,4 +66,15 @@ void default_send_IPI_self(int vector); void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector); void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector); void default_send_IPI_mask_logical(const struct cpumask *mask, int vector); +void x86_32_probe_bigsmp_early(void); +#else +static inline void x86_32_probe_bigsmp_early(void) { } +#endif + +#ifdef CONFIG_X86_BIGSMP +bool apic_bigsmp_possible(bool cmdline_selected); +void apic_bigsmp_force(void); +#else +static inline bool apic_bigsmp_possible(bool cmdline_selected) { return false; }; +static inline void apic_bigsmp_force(void) { } #endif --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -10,6 +10,8 @@ #include #include +#include + #include #include #include @@ -123,36 +125,33 @@ static int __init parse_apic(char *arg) } early_param("apic", parse_apic); -void __init default_setup_apic_routing(void) +void __init x86_32_probe_bigsmp_early(void) { - int version = boot_cpu_apic_version; + if (nr_cpu_ids <= 8 || xen_pv_domain()) + return; - if (num_possible_cpus() > 8) { + if (IS_ENABLED(CONFIG_X86_BIGSMP)) { switch (boot_cpu_data.x86_vendor) { case X86_VENDOR_INTEL: - if (!APIC_XAPIC(version)) { - def_to_bigsmp = 0; + if (!APIC_XAPIC(boot_cpu_apic_version)) break; - } /* P4 and above */ fallthrough; case X86_VENDOR_HYGON: case X86_VENDOR_AMD: - def_to_bigsmp = 1; + if (apic_bigsmp_possible(cmdline_apic)) + return; + break; } } + pr_info("Limiting to 8 possible CPUs\n"); + set_nr_cpu_ids(8); +} -#ifdef CONFIG_X86_BIGSMP - /* - * This is used to switch to bigsmp mode when - * - There is no apic= option specified by the user - * - generic_apic_probe() has chosen apic_default as the sub_arch - * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support - */ - - if (!cmdline_apic && apic == &apic_default) - generic_bigsmp_probe(); -#endif +void __init default_setup_apic_routing(void) +{ + if (nr_cpu_ids >= 8 && !xen_pv_domain()) + apic_bigsmp_force(); if (apic->setup_apic_routing) apic->setup_apic_routing(); --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1149,41 +1149,6 @@ static __init void disable_smp(void) cpumask_set_cpu(0, topology_die_cpumask(0)); } -/* - * Various sanity checks. - */ -static void __init smp_sanity_check(void) -{ - preempt_disable(); - -#if !defined(CONFIG_X86_BIGSMP) && defined(CONFIG_X86_32) - if (def_to_bigsmp && nr_cpu_ids > 8) { - unsigned int cpu; - unsigned nr; - - pr_warn("More than 8 CPUs detected - skipping them\n" - "Use CONFIG_X86_BIGSMP\n"); - - nr = 0; - for_each_present_cpu(cpu) { - if (nr >= 8) - set_cpu_present(cpu, false); - nr++; - } - - nr = 0; - for_each_possible_cpu(cpu) { - if (nr >= 8) - set_cpu_possible(cpu, false); - nr++; - } - - set_nr_cpu_ids(8); - } -#endif - preempt_enable(); -} - static void __init smp_cpu_index_default(void) { int i; @@ -1243,8 +1208,6 @@ void __init native_smp_prepare_cpus(unsi { smp_prepare_cpus_common(); - smp_sanity_check(); - switch (apic_intr_mode) { case APIC_PIC: case APIC_VIRTUAL_WIRE_NO_CONFIG: From patchwork Mon Jul 17 23:15:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1410053vqt; Mon, 17 Jul 2023 16:50:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+ncbyQlCj/aDm1XWjDwLH6jc7O17nP7CtdtVYX+s0JJ4fwO3eilKK4J8D/CjvJKe9PwiR X-Received: by 2002:a05:6a20:8e14:b0:135:bf8d:b758 with SMTP id y20-20020a056a208e1400b00135bf8db758mr219712pzj.16.1689637830988; Mon, 17 Jul 2023 16:50:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637830; cv=none; d=google.com; s=arc-20160816; b=Wn/AbL5f7jnC/Ioymq70Zc1f3AQhuxUshnlakDrpfl/dSTPbxqbiLNbiehc7wZdgTH 9i8M5rvBVEhVrtA5LwdRgWI80guBY7MmFm0H/yShA+c6QIK4SC4m9ikP2cZl2ARxnj5U gOfnRclogjh0Tmphv+tBLMjiL5BDfHiADFFVHDIUZkds75gqnp7lsRiLOul735zjCcXw fDhtMbZTBSUVxVpIajCIJdh43ykIAyvj5KbnaVTuFi2Ipup3PCGZcuOqR3bf6hwcYWAH 0id8iD6e6ExVfzK4jJAvRwRrfckPn7DE8ztjNcucRf+IoJ0HbVrEU6YiX/xm2vWnqFOI RUUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=EVZ3Nalwxs4PGlJG4O/zCaoIlP8Kdk3XpwGeUBcVZSg=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=QijTb/dVd9qIj19Kxs+8XVV5PEBHtjspCBTlQNMQxEQh4G/Rb/VkWMmSkTm1z6Bwrz EwBGK4VqoF/q4Iuht0QD48gmzHOGdlAe8RGeEgp0Ps8VuZRffRGLSeXkWtQ2og17k0M0 sZhhGXRk40texfZtS3XSa5Hv4OWMAJVS2GEaj9dYysCf+NhRBhUHsjLWxZQHlu+KDZ4N TCMb4TIf4fbGgUBJPEld8soMoNISfAxJSu/lfS4QhXEpI9cK8zzcg6dTYawBI5GTvneW WKc8V9yC0/8zG42BDduH50X9pabS0KenJApig+svPda8M1068BUj+GhungPA+6A8QM7+ PVqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0pf9RWB1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x7-20020a655387000000b0055ff89f224bsi545018pgq.689.2023.07.17.16.50.17; Mon, 17 Jul 2023 16:50:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0pf9RWB1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjGQX1c (ORCPT + 99 others); Mon, 17 Jul 2023 19:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjGQX1a (ORCPT ); Mon, 17 Jul 2023 19:27:30 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5643186 for ; Mon, 17 Jul 2023 16:26:44 -0700 (PDT) Message-ID: <20230717223224.623297513@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EVZ3Nalwxs4PGlJG4O/zCaoIlP8Kdk3XpwGeUBcVZSg=; b=0pf9RWB1fwKjGpEZA2bDmksipqXKofRhPUeloFtOb3VR7ML7OYdXyDCeKOdNSKBwOC43r4 Vwu+tTGK1yHwm0Mf61yxA7ejaUNV5eIJptgXC7sQx7N/Vw5YJYxssU94+dEccyMqX4e2Qm ztXccliUFlnCFAU+7Z8QFRMfrxUpqVvL24eFMXNoeVHYxRB7qgAPT0BU2v25/HIp0w369N XQs1N4losx/R/25jl8bWHGtcz2PR4NOnx532FpAE4Ib6YqNjqfFbtz2BdTPI9jYt2hvXQ8 gHf0DeWBbnPDqrtBzzhJ4iz017o91rICWKuOfLC50GPUxoczfKErrhcXaNC6qQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=EVZ3Nalwxs4PGlJG4O/zCaoIlP8Kdk3XpwGeUBcVZSg=; b=cwwdVUeQvFPDl21od6SdWk2ZI0dFdarJO/au6C/T1qOTHKScqvO0XGiK/RN9uGLw0vRh4t cec6hDjXpELcFGAA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 26/58] x86/apic/32: Remove bigsmp_cpu_present_to_apicid() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:14 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713678059887775 X-GMAIL-MSGID: 1771713678059887775 It's a copy of default_cpu_present_to_apicid() with the omission of the actual check whether the CPU is present. This APIC callback should die completely, but the XEN APIC implementation does something different which needs to be addressed first. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/bigsmp_32.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -43,14 +43,6 @@ static void bigsmp_setup_apic_routing(vo nr_ioapics); } -static int bigsmp_cpu_present_to_apicid(int mps_cpu) -{ - if (mps_cpu < nr_cpu_ids) - return (int) per_cpu(x86_cpu_to_apicid, mps_cpu); - - return BAD_APICID; -} - static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap) { /* For clustered we don't have a good way to do this yet - hack */ @@ -119,7 +111,7 @@ static struct apic apic_bigsmp __ro_afte .init_apic_ldr = bigsmp_init_apic_ldr, .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, .setup_apic_routing = bigsmp_setup_apic_routing, - .cpu_present_to_apicid = bigsmp_cpu_present_to_apicid, + .cpu_present_to_apicid = default_cpu_present_to_apicid, .apicid_to_cpu_present = physid_set_mask_of_physid, .phys_pkg_id = bigsmp_phys_pkg_id, From patchwork Mon Jul 17 23:15:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1400201vqt; Mon, 17 Jul 2023 16:19:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlH1X3SLS9pCpzzsgENi943LSwVBXLTQ52h4LdbJbbMVY39CpXG2il3nppAu92q1FE3iNWmL X-Received: by 2002:aa7:cfc3:0:b0:51d:dbf1:c825 with SMTP id r3-20020aa7cfc3000000b0051ddbf1c825mr15398165edy.1.1689635997178; Mon, 17 Jul 2023 16:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689635997; cv=none; d=google.com; s=arc-20160816; b=HrvHdq9mRzS1M8BVUjtdoGVw1zAHqzCLe2ZI/vwOvlnfDQZjiu6VbuuYkQOWE3REe3 /cRA/eLvElGApcEhD/6bI4hOtiD7OEVvQs37Km39VN0MGSqr5k6eKMjULgvD+hG2ZZjM X9Mb3x9rzoz1oiQZ6YZ3fGUtMQvzjV0zh7cHdK8SHylJMZpkzV856OeD4dq91TKEQ3cT SNwKpMLoG0KK8utPC68e4ZLgHkQd0PZR5IJ6j2uLIl9Z5SOwGLsrJfBOoz6pVSymTsqS HgYf1Ykeq+zFK291CnuTBxklC3BhjPEadEivHxJ/nwYjXdb9lmLp1rdrrmXKEDhrYiQh lF5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=2GgBvlBwBjHxdRJmr9WUDSqYy6anA/COSWCNzKyoDG8=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Xhg8cFQRN11lx9Spej2XkUeLj3zFQ7Eopi6R+RmR2/e8x5fcAA/HRGEx3O87CpDkjF EnbsCQnSlFDXQS0nl3j61+d+zbWvckIF3msyGHltbnfBeuKZQ5IUkeppsTV6LVbnANr1 K+SRiu4euDKaSQaOOUastnNencPkOSwnzxSLbBwBi5pqwRyd+3nDEq9iIgyka78Zn2bg vGFTEpJmjtPQsTX3lMGJleNKdu2sLlBxkXzLxMUbqIN7HN5dTDhJQOts2AHx9U/w0gZT i9GUWDLNqAIQDFlE02xpPuxwrMDpMOpJPZGoe2YDZMVvWxW0eNhRAcQeBy7h4gNzjtg6 Cc/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="2/Vn8u2+"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020aa7d449000000b0051dd4de9b90si271645edr.509.2023.07.17.16.19.33; Mon, 17 Jul 2023 16:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="2/Vn8u2+"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231461AbjGQXQu (ORCPT + 99 others); Mon, 17 Jul 2023 19:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjGQXQq (ORCPT ); Mon, 17 Jul 2023 19:16:46 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D303D8E for ; Mon, 17 Jul 2023 16:16:00 -0700 (PDT) Message-ID: <20230717223224.682027281@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=2GgBvlBwBjHxdRJmr9WUDSqYy6anA/COSWCNzKyoDG8=; b=2/Vn8u2+5/SRnXwpXbVScxhgRhTVpcYBF1bp0Qm/eorg2zZ10PWEtPP7zC1kuoeejFt4ck uHW0cDhYA4ZtpVzipDMw9xmyzIbhck5hWat7PhMZM1CMJXcex/4NkY9R/i8xmzLRdLIZlJ wJIk4Yw6zruuwmQxGOZXV2g0EsXQuZgab6O8CHg30q4ycyxMZopKsi9kejHqFHq9j98xjz /WPUnck8R3NVqQCVA70OlPpYwjzVhXXo7r+vPqb+orP4GlUq2RvEPTX7tBG98vwDMaZuKQ FDeUMaGnmqCWtwAnoZcVKKGYzShPHF+Xr71OQ0E2R3i9OH2ffqQPsClypsVbIw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=2GgBvlBwBjHxdRJmr9WUDSqYy6anA/COSWCNzKyoDG8=; b=+45cMtNHe2gF+qi3ndt0ELLn3sJ2cayrCo/T3BcL/O6wM4XHQFN8OmK1fLJBTkOsNBlECf Tc+s0g0pYK1zSgCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 27/58] x86/apic: Nuke empty init_apic_ldr() callbacks References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:16 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711755086027603 X-GMAIL-MSGID: 1771711755086027603 apic::init_apic_ldr() is only invoked when the APIC is initialized. So there is really no point in having: - Default empty callbacks all over the place - Two implementations of the actual LDR init function where one is just unreadable gunk but does exactly the same as the other. Make the apic::init_apic_ldr() invocation conditional, remove the empty callbacks and consolidate the two implementation into one. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 -- arch/x86/kernel/apic/apic.c | 7 +++++-- arch/x86/kernel/apic/apic_common.c | 16 ++++++++++++++++ arch/x86/kernel/apic/apic_flat_64.c | 32 +------------------------------- arch/x86/kernel/apic/apic_noop.c | 2 -- arch/x86/kernel/apic/apic_numachip.c | 2 -- arch/x86/kernel/apic/bigsmp_32.c | 9 --------- arch/x86/kernel/apic/local.h | 5 ++--- arch/x86/kernel/apic/probe_32.c | 15 --------------- arch/x86/kernel/apic/x2apic_phys.c | 5 ----- arch/x86/kernel/apic/x2apic_uv_x.c | 5 ----- arch/x86/xen/apic.c | 1 - 12 files changed, 24 insertions(+), 77 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -445,8 +445,6 @@ extern void generic_bigsmp_probe(void); #include -#define APIC_DFR_VALUE (APIC_DFR_FLAT) - extern struct apic apic_noop; static inline unsigned int read_apic_id(void) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1578,9 +1578,12 @@ static void setup_local_APIC(void) /* * Intel recommends to set DFR, LDR and TPR before enabling * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel - * document number 292116). So here it goes... + * document number 292116). + * + * Except for APICs which operate in physical destination mode. */ - apic->init_apic_ldr(); + if (apic->init_apic_ldr) + apic->init_apic_ldr(); /* * Set Task Priority to 'accept all except vectors 0-31'. An APIC --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -6,6 +6,8 @@ #include #include +#include "local.h" + u32 apic_default_calc_apicid(unsigned int cpu) { return per_cpu(x86_cpu_to_apicid, cpu); @@ -39,3 +41,17 @@ int default_apic_id_valid(u32 apicid) { return (apicid < 255); } + +/* + * Set up the logical destination ID when the APIC operates in logical + * destination mode. + */ +void default_init_apic_ldr(void) +{ + unsigned long val; + + apic_write(APIC_DFR, APIC_DFR_FLAT); + val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; + val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id()); + apic_write(APIC_LDR, val); +} --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -28,26 +28,6 @@ static int flat_acpi_madt_oem_check(char return 1; } -/* - * Set up the logical destination ID. - * - * Intel recommends to set DFR, LDR and TPR before enabling - * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel - * document number 292116). So here it goes... - */ -void flat_init_apic_ldr(void) -{ - unsigned long val; - unsigned long num, id; - - num = smp_processor_id(); - id = 1UL << num; - apic_write(APIC_DFR, APIC_DFR_FLAT); - val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; - val |= SET_APIC_LOGICAL_ID(id); - apic_write(APIC_LDR, val); -} - static void _flat_send_IPI_mask(unsigned long mask, int vector) { unsigned long flags; @@ -119,7 +99,7 @@ static struct apic apic_flat __ro_after_ .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = flat_init_apic_ldr, + .init_apic_ldr = default_init_apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, @@ -175,15 +155,6 @@ static int physflat_acpi_madt_oem_check( return 0; } -static void physflat_init_apic_ldr(void) -{ - /* - * LDR and DFR are not involved in physflat mode, rather: - * "In physical destination mode, the destination processor is - * specified by its local APIC ID [...]." (Intel SDM, 10.6.2.1) - */ -} - static int physflat_probe(void) { if (apic == &apic_physflat || num_possible_cpus() > 8 || @@ -207,7 +178,6 @@ static struct apic apic_physflat __ro_af .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = physflat_init_apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -14,7 +14,6 @@ #include -static void noop_init_apic_ldr(void) { } static void noop_send_IPI(int cpu, int vector) { } static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { } static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { } @@ -94,7 +93,6 @@ struct apic apic_noop __ro_after_init = .disable_esr = 0, .check_apicid_used = default_check_apicid_used, - .init_apic_ldr = noop_init_apic_ldr, .ioapic_phys_id_map = default_ioapic_phys_id_map, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -252,7 +252,6 @@ static const struct apic apic_numachip1 .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = flat_init_apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, @@ -297,7 +296,6 @@ static const struct apic apic_numachip2 .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = flat_init_apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -28,14 +28,6 @@ static bool bigsmp_check_apicid_used(phy return false; } -/* - * bigsmp enables physical destination mode - * and doesn't use LDR and DFR - */ -static void bigsmp_init_apic_ldr(void) -{ -} - static void bigsmp_setup_apic_routing(void) { printk(KERN_INFO @@ -108,7 +100,6 @@ static struct apic apic_bigsmp __ro_afte .disable_esr = 1, .check_apicid_used = bigsmp_check_apicid_used, - .init_apic_ldr = bigsmp_init_apic_ldr, .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, .setup_apic_routing = bigsmp_setup_apic_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -13,9 +13,6 @@ #include #include -/* APIC flat 64 */ -void flat_init_apic_ldr(void); - /* X2APIC */ int x2apic_apic_id_valid(u32 apicid); int x2apic_apic_id_registered(void); @@ -46,6 +43,8 @@ static inline unsigned int __prepare_ICR return icr; } +void default_init_apic_ldr(void); + void __default_send_IPI_shortcut(unsigned int shortcut, int vector); /* --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -32,21 +32,6 @@ static int default_apic_id_registered(vo return physid_isset(read_apic_id(), phys_cpu_present_map); } -/* - * Set up the logical destination ID. Intel recommends to set DFR, LDR and - * TPR before enabling an APIC. See e.g. "AP-388 82489DX User's Manual" - * (Intel document number 292116). - */ -static void default_init_apic_ldr(void) -{ - unsigned long val; - - apic_write(APIC_DFR, APIC_DFR_VALUE); - val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; - val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id()); - apic_write(APIC_LDR, val); -} - static int default_phys_pkg_id(int cpuid_apic, int index_msb) { return cpuid_apic >> index_msb; --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -91,10 +91,6 @@ static void x2apic_send_IPI_all(int vect __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLINC); } -static void init_x2apic_ldr(void) -{ -} - static int x2apic_phys_probe(void) { if (!x2apic_mode) @@ -169,7 +165,6 @@ static struct apic apic_x2apic_phys __ro .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = init_x2apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -788,10 +788,6 @@ static int uv_apic_id_registered(void) return 1; } -static void uv_init_apic_ldr(void) -{ -} - static u32 apic_uv_calc_apicid(unsigned int cpu) { return apic_default_calc_apicid(cpu); @@ -841,7 +837,6 @@ static struct apic apic_x2apic_uv_x __ro .disable_esr = 0, .check_apicid_used = NULL, - .init_apic_ldr = uv_init_apic_ldr, .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -149,7 +149,6 @@ static struct apic xen_pv_apic = { .disable_esr = 0, .check_apicid_used = default_check_apicid_used, /* Used on 32-bit */ - .init_apic_ldr = xen_noop, /* setup_local_APIC calls it */ .ioapic_phys_id_map = default_ioapic_phys_id_map, /* Used on 32-bit */ .setup_apic_routing = NULL, .cpu_present_to_apicid = xen_cpu_present_to_apicid, From patchwork Mon Jul 17 23:15:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121683 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407291vqt; Mon, 17 Jul 2023 16:40:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlFwjuFBfoHlLZo2cyRu9n/4O96AdkoJsc3h/5tPx+iHUhZTYz1Qt0tJCYKsKgLip711VXHV X-Received: by 2002:a05:6808:1a01:b0:3a4:316c:8eeb with SMTP id bk1-20020a0568081a0100b003a4316c8eebmr13863785oib.40.1689637251961; Mon, 17 Jul 2023 16:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637251; cv=none; d=google.com; s=arc-20160816; b=N/jWfTwyebL2G/9hl9SLWQFOb7lFIoERozMkAnCo9nw5dM0VKnRY1tqbDDuTUMpTeu qYr7pG86+6UYRxO6q9A6ZVAeH2fBP5Q4RoVMLV46NTWaa5h7cVymDTrlo6bMyHZsPKZu 5W2VJvbxRMIhtOcrDBkDs6qUxJn9X8KDVfhnPpqwtCzbMKoJVYZGTMbtLlcujMpJAU+P W146qrJid1XwLwRNbH34yoz5hCjiLfyT0q9J8dSkSLRFs5HDIuVIZSBP9ZjqnlvtjYXx Fc794NGp3RZ1u1hew+9egDbJlIfJuqz3RAwK12unHcVFCt15moKtDo/DTIGF7+s+NGmT Wz0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=06ExdfZEOQwXniOfctX3V6uycMvnEsSlc1/tN9llaWA=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Jyx9TL1iRFLzGYeizXLw7m3q5675DUD0t87/f8H0FGDJqRpxDo2vfByapvom1phNfk q7lz0o/q4EoNFO7eoL0eLZaUgz7zRuC4Yt/fKtH1p7wSHgtTejb1ptM/v1KZy5NeIBkw GQxgJWtfXXTh1wt9i4ozNatqmwfpDhCkxYlg7lPU0BpfJ8I2eWLuCB0W0zxDQsX5FIcx xrri8mEdoUZgeszGAbIVwY2ZAW+z+q7Ak1BzqbRU+9SUXLK+OwCqXbhNFUoEx57D3uAb n94ksEIMLoVaqz1ee3olvdxJts6UGXfwbVwQ2cFYwt7CCDlRkW1mnY6mznTGjYtARrWa pCXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y5TIsgm3; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6300c2000000b005347c4d09ddsi538054pga.678.2023.07.17.16.40.38; Mon, 17 Jul 2023 16:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y5TIsgm3; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbjGQXX3 (ORCPT + 99 others); Mon, 17 Jul 2023 19:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbjGQXXF (ORCPT ); Mon, 17 Jul 2023 19:23:05 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD1B1BE for ; Mon, 17 Jul 2023 16:22:27 -0700 (PDT) Message-ID: <20230717223224.743460570@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=06ExdfZEOQwXniOfctX3V6uycMvnEsSlc1/tN9llaWA=; b=Y5TIsgm3UB4GQd4xPU3Jxtpjd+P64bIN4L0cCuI5aJFNUojUyHpraiU8nzdHWhGjxrk/fA dqYip7WtPPV+lz7RLKaOEkv1AmKvQSiTF4x2YVPzo3NHtOgXfmPA6LtY7vJuBr0H49HSqn d0PsZNGJ3OPbl08OauxkypDlGgJNWeg5JzN3NiYW3jJVSkYEcTv/ExQ7kGm3WC2mkaFlYY p+tS+wnw/cObQ7A2eMAt4YN8YUDi4DNryJK+cukhHck49ND6U4ZCKKd3eItKwZXCIcdIf9 kYc+ll9vu9vupoWFA0b19VCfAKgTVzthUmo5daBiKABbSD+2dg8z7XEob/GEQQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=06ExdfZEOQwXniOfctX3V6uycMvnEsSlc1/tN9llaWA=; b=yAf99dYfM9/hctShZts9tsNqrTREmcL4MAvMxrxTJxfe1cwm4n/izQxAEGGiXl2Red32a6 vLH1fUZBasT7FeCA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 28/58] x86/apic: Nuke apic::apicid_to_cpu_present() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:17 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713070986807356 X-GMAIL-MSGID: 1771713070986807356 This is only used on 32bit and is a wrapper around physid_set_mask_of_physid() in all 32bit APIC drivers. Remove the callback and use physid_set_mask_of_physid() in the code directly, Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 1 - arch/x86/kernel/apic/apic_flat_64.c | 2 -- arch/x86/kernel/apic/apic_noop.c | 1 - arch/x86/kernel/apic/apic_numachip.c | 2 -- arch/x86/kernel/apic/bigsmp_32.c | 1 - arch/x86/kernel/apic/io_apic.c | 11 +++++------ arch/x86/kernel/apic/probe_32.c | 1 - arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 1 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 - arch/x86/xen/apic.c | 1 - 11 files changed, 5 insertions(+), 18 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -304,7 +304,6 @@ struct apic { void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap); void (*setup_apic_routing)(void); int (*cpu_present_to_apicid)(int mps_cpu); - void (*apicid_to_cpu_present)(int phys_apicid, physid_mask_t *retmap); int (*phys_pkg_id)(int cpuid_apic, int index_msb); u32 (*get_apic_id)(unsigned long x); --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -103,7 +103,6 @@ static struct apic apic_flat __ro_after_ .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = flat_phys_pkg_id, .get_apic_id = flat_get_apic_id, @@ -181,7 +180,6 @@ static struct apic apic_physflat __ro_af .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = flat_phys_pkg_id, .get_apic_id = flat_get_apic_id, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -96,7 +96,6 @@ struct apic apic_noop __ro_after_init = .ioapic_phys_id_map = default_ioapic_phys_id_map, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = physid_set_mask_of_physid, .phys_pkg_id = noop_phys_pkg_id, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -255,7 +255,6 @@ static const struct apic apic_numachip1 .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = numachip_phys_pkg_id, .get_apic_id = numachip1_get_apic_id, @@ -299,7 +298,6 @@ static const struct apic apic_numachip2 .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = numachip_phys_pkg_id, .get_apic_id = numachip2_get_apic_id, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -103,7 +103,6 @@ static struct apic apic_bigsmp __ro_afte .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, .setup_apic_routing = bigsmp_setup_apic_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = physid_set_mask_of_physid, .phys_pkg_id = bigsmp_phys_pkg_id, .get_apic_id = bigsmp_get_apic_id, --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1512,11 +1512,10 @@ void __init setup_ioapic_ids_from_mpc_no ioapics[ioapic_idx].mp_config.apicid = i; } else { physid_mask_t tmp; - apic->apicid_to_cpu_present(mpc_ioapic_id(ioapic_idx), - &tmp); - apic_printk(APIC_VERBOSE, "Setting %d in the " - "phys_id_present_map\n", - mpc_ioapic_id(ioapic_idx)); + + physid_set_mask_of_physid(mpc_ioapic_id(ioapic_idx), &tmp); + apic_printk(APIC_VERBOSE, "Setting %d in the phys_id_present_map\n", + mpc_ioapic_id(ioapic_idx)); physids_or(phys_id_present_map, phys_id_present_map, tmp); } @@ -2546,7 +2545,7 @@ static int io_apic_get_unique_id(int ioa apic_id = i; } - apic->apicid_to_cpu_present(apic_id, &tmp); + physid_set_mask_of_physid(apic_id, &tmp); physids_or(apic_id_map, apic_id_map, tmp); if (reg_00.bits.ID != apic_id) { --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -60,7 +60,6 @@ static struct apic apic_default __ro_aft .ioapic_phys_id_map = default_ioapic_phys_id_map, .setup_apic_routing = setup_apic_flat_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = physid_set_mask_of_physid, .phys_pkg_id = default_phys_pkg_id, .get_apic_id = default_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -249,7 +249,6 @@ static struct apic apic_x2apic_cluster _ .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = x2apic_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -168,7 +168,6 @@ static struct apic apic_x2apic_phys __ro .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = x2apic_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -840,7 +840,6 @@ static struct apic apic_x2apic_uv_x __ro .ioapic_phys_id_map = NULL, .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, - .apicid_to_cpu_present = NULL, .phys_pkg_id = uv_phys_pkg_id, .get_apic_id = x2apic_get_apic_id, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -152,7 +152,6 @@ static struct apic xen_pv_apic = { .ioapic_phys_id_map = default_ioapic_phys_id_map, /* Used on 32-bit */ .setup_apic_routing = NULL, .cpu_present_to_apicid = xen_cpu_present_to_apicid, - .apicid_to_cpu_present = physid_set_mask_of_physid, /* Used on 32-bit */ .phys_pkg_id = xen_phys_pkg_id, /* detect_ht */ .get_apic_id = xen_get_apic_id, From patchwork Mon Jul 17 23:15:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407835vqt; Mon, 17 Jul 2023 16:42:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlq78TBhxXDZXNrax5tLZmDMHlBdaLrcjZtNqiKiRsCMQqRoMMT4jDAP2dXJwkhVjZ/47o X-Received: by 2002:a17:902:ec88:b0:1b6:b805:5ae3 with SMTP id x8-20020a170902ec8800b001b6b8055ae3mr15347150plg.3.1689637365812; Mon, 17 Jul 2023 16:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637365; cv=none; d=google.com; s=arc-20160816; b=atisllz9F3WybtQ6Zl9EJ1cOAIta7WcvwnxrdM1VyNzJAYqU+kIuPnLukNtR6u3RKO maBxOIsM5oAv1KNiU8FPkpmfUdou3vUBWRVrwDFCDemt7VGxTUQ0nCkFUDXXRfX7a19Y aqtiiw0a1xsS8eZZEBH9RfyuEJquNYkysFgFhU/+pPGl74sjqfDT0yQyHxTOhhoArV7c sUFpkx9/k7dkcRzHAmq8pViDUMr9bmeN41UhhivAPK//voVencarMqqjsJQfqqoqPkA3 PjqVye9qosUEyKupm8ALsBPoHEP6whKnejgZ9kzFHJXxj0SmBCQ5ajJXz8EtEwouWA1n GGpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=1fi5EfwywiW+JxLoqkaaJxdnnrJM3lL64yD5t1OC3bQ=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=bSRubNYxR1CEVg4faG2otY/1E9g68j8Cj5R/p0p4e7+U/mdmLiSXJN1KvPUPsSTEj7 Rwxx4QMwVpHG1YkCWK8zSjAMq6j6EIK7oK08SXt8i1Hs7akDH1/TDjwxHpXI38Di/gYL WtefZM0wMpEkFdV7fuNEGjgkopzx4r1AW7lTJBQFOlLPMaykwLO+W+rYniMPfdYJGtwr ISh7VcErlM6cdm7aOPbVMCu8jEBEzM2U2FAOtJbtP+3+HpW+uAnZUDyHT3hMmTdmYCtH sumb0mzdt9IPoBGV1Hsdz0d9TUt5zy53UjzzG407BETGil/b11pERYlIMuOqH+RzRrtr v8Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BADiRAFT; dkim=neutral (no key) header.i=@linutronix.de header.b=gEMTuYy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id im15-20020a170902bb0f00b001bb42c274a9si280282plb.504.2023.07.17.16.42.32; Mon, 17 Jul 2023 16:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=BADiRAFT; dkim=neutral (no key) header.i=@linutronix.de header.b=gEMTuYy1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbjGQXSU (ORCPT + 99 others); Mon, 17 Jul 2023 19:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231508AbjGQXSR (ORCPT ); Mon, 17 Jul 2023 19:18:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3774F172E for ; Mon, 17 Jul 2023 16:17:27 -0700 (PDT) Message-ID: <20230717223224.801556578@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1fi5EfwywiW+JxLoqkaaJxdnnrJM3lL64yD5t1OC3bQ=; b=BADiRAFTkC6r+a6gyybktPa+HfMXroxjn94l+bXbqaw3hq9umOUNeI+hfDtflvabJCgkd5 QafHXvflNvNJy/0aP7T1om1tokKWKy0kWeS+wIa6a4G5IGSmufLN9xvcqtTEjwOi5+MXx3 8GezOJsDcGML0gR+CwAMJGMfWTiy3rS/rOqo0rJkKJerU87KohFbetomtjwF9muWhZpVNZ RESKOnkG/WXU0hxG3iczaPFjdgcOdTFWoH2KDBpEX4wf1GuCXUvbJphNnlnb2y2YfXeuTK uvQ6KOXl/URhjav4FU825U9eo8rowRqpyoA8+YJI3k64zJF5s4YiDqPk1NdtLQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=1fi5EfwywiW+JxLoqkaaJxdnnrJM3lL64yD5t1OC3bQ=; b=gEMTuYy1EBhlm7p9f9Q1LKgSaDPFxw28WPcOb9fBTWlqY6cWG1255arVxNdYPX4Kr9ZFwy ZCcvTKnNXjsBQoCw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 29/58] x86/ioapic/32: Decrapify phys_id_present_map operation References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:19 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713190972706527 X-GMAIL-MSGID: 1771713190972706527 The operation to set the IOAPIC ID in phys_id_present_map is as convoluted as it can be. 1) Allocate a bitmap of 32byte size on the stack 2) Zero the bitmap and set the IOAPIC ID bit 3) Or the temporary bitmap over phys_id_present_map The same functionality can be achieved by setting the IOAPIC ID bit directly in the phys_id_present_map. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/io_apic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1511,12 +1511,9 @@ void __init setup_ioapic_ids_from_mpc_no physid_set(i, phys_id_present_map); ioapics[ioapic_idx].mp_config.apicid = i; } else { - physid_mask_t tmp; - - physid_set_mask_of_physid(mpc_ioapic_id(ioapic_idx), &tmp); apic_printk(APIC_VERBOSE, "Setting %d in the phys_id_present_map\n", mpc_ioapic_id(ioapic_idx)); - physids_or(phys_id_present_map, phys_id_present_map, tmp); + physid_set(mpc_ioapic_id(ioapic_idx), phys_id_present_map); } /* From patchwork Mon Jul 17 23:15:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121663 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1405732vqt; Mon, 17 Jul 2023 16:35:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlE4k+qBmUkTDGTrvkAhNoP5LcBvYhtjh5B+BiNanKjLpr7cBAnuSNmdNpfpakpGaBKB040Y X-Received: by 2002:a05:6a00:2ea9:b0:673:8dfb:af32 with SMTP id fd41-20020a056a002ea900b006738dfbaf32mr1115467pfb.26.1689636947064; Mon, 17 Jul 2023 16:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636947; cv=none; d=google.com; s=arc-20160816; b=wCo1KXF0qk9ATy1GmPAJW5NCgVHlwORwn1guPAj8ZXh32rjMawmrWIsjdkbO+lct+D jA/3eR/2w+mHTacgPTdLKBhT1IremYZYFLXfpJt30If0xHhiuoG1Ptm1+vmhAV8lSkgk VHFmht4QJ/cVFRAaEIoPlrtyBq10Mgq7anUDqQ/QkvJft1ZeJLdk36oqqb79Ya2/NAeG e3xza+gsq2aGdYPv/WF2eXkJXGMBynOhg0nooS9BdlXV5pHLnQ9hlqizfWg7zbbKAimO 7xkQON+Vvgl/IeMPnOHSQRXsdqcnAhtdpjyPMsK5mGSP1sGOKqYwccK8uTFZMY/RzZhe 104Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=iXqYtXrlduXImtg8HbwwswgIFt4N10phn1SThuuoL6E=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=FOJMTCH2rVKCBhgcYb2xnSx0Yeeyt5cvqtvq0PNzi8mfiAzjCJEyEyxm26tykBg60I 2LawMRp3sSFOaAcm2MIwm84C2eVdkSJbb2CKny6SgPx0g+BnwhBG1QHZsr1ey+zH24JM cSTNn6MS5OvT14K3hp2fCjyInIVcgAzAX2tU55geALkPV5Y0wqFixVNvwSc00LhJJoH6 Bsq0lXoerj5c48BXu617gT0ZhegHiuhWHqqS+x8uOmWVKQrPepjHUm9Iw+iAG1AbVlMB 7QsJbHOyjv1MCzpZ63L0CEFz7l92g0xRyfiWbiVW87myrd+WnLOSJaNkGwqqsobkB+kD Fl5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0dN0OrCK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=KTUaoc8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k8-20020aa788c8000000b006688882d4d8si544984pff.403.2023.07.17.16.35.33; Mon, 17 Jul 2023 16:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0dN0OrCK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=KTUaoc8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbjGQXRC (ORCPT + 99 others); Mon, 17 Jul 2023 19:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbjGQXRA (ORCPT ); Mon, 17 Jul 2023 19:17:00 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73EDE170C for ; Mon, 17 Jul 2023 16:16:18 -0700 (PDT) Message-ID: <20230717223224.862165651@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iXqYtXrlduXImtg8HbwwswgIFt4N10phn1SThuuoL6E=; b=0dN0OrCKNxWlr5OUQVlboRcw+6j9f+o+Z+6J+4QtQ3GKT2Cgj0hsFEfQrxu+xACuAcS61S jrW2X46+nGZAH1ez5UXmb3euZvH09YDs0h86ztj5vWsD+PglInLBG1bUn7UVP0xq17fjUs Ppd2Qr6TZg4jMEIB57MOqiQW6Uk8yKl7eH5movcXVeGxa8G/s5HjeU/NAncBTQCpSqcsay wMm9dnBJNheAOXFoRWfXQoPJ0cR2M5R94OHwTqm5yE+f2OETSt6EprXQyDhM7AWbxSD253 e1hH4ajwe8DVFBURr+tT2Qt3BWVDfLZ6MmhPlgXhI07OeKtlBmi+GywO4FC4dw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635721; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iXqYtXrlduXImtg8HbwwswgIFt4N10phn1SThuuoL6E=; b=KTUaoc8lM7LP9M80N+0b8tgyPboz6lk8Eo7zzKzV6CRIrHbLn3ug4RN3UiRrj39yEbUU4U 38HzOpfLbVM0ZzAw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 30/58] x86/apic: Mop up *setup_apic_routing() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:21 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712751708623983 X-GMAIL-MSGID: 1771712751708623983 default_setup_apic_routing() is a complete misnomer. On 64bit it does the actual APIC probing and on 32bit it is used to force select the bigsmp APIC and to emit a redundant message in the apic::setup_apic_routing() callback. Rename the 64bit and 32bit function so they reflect what they are doing and remove the useless APIC callback. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 10 ++++------ arch/x86/kernel/apic/apic.c | 4 +++- arch/x86/kernel/apic/apic_flat_64.c | 2 -- arch/x86/kernel/apic/apic_noop.c | 1 - arch/x86/kernel/apic/apic_numachip.c | 2 -- arch/x86/kernel/apic/bigsmp_32.c | 8 -------- arch/x86/kernel/apic/local.h | 2 ++ arch/x86/kernel/apic/probe_32.c | 17 ++--------------- arch/x86/kernel/apic/probe_64.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 1 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 - arch/x86/kernel/setup.c | 2 +- arch/x86/xen/apic.c | 1 - 14 files changed, 13 insertions(+), 41 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -40,11 +40,9 @@ #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32) -extern void generic_apic_probe(void); +extern void x86_32_probe_apic(void); #else -static inline void generic_apic_probe(void) -{ -} +static inline void x86_32_probe_apic(void) { } #endif #ifdef CONFIG_X86_LOCAL_APIC @@ -302,7 +300,6 @@ struct apic { bool (*check_apicid_used)(physid_mask_t *map, int apicid); void (*init_apic_ldr)(void); void (*ioapic_phys_id_map)(physid_mask_t *phys_map, physid_mask_t *retmap); - void (*setup_apic_routing)(void); int (*cpu_present_to_apicid)(int mps_cpu); int (*phys_pkg_id)(int cpuid_apic, int index_msb); @@ -457,12 +454,13 @@ static inline unsigned int read_apic_id( typedef int (*wakeup_cpu_handler)(int apicid, unsigned long start_eip); extern void acpi_wake_cpu_handler_update(wakeup_cpu_handler handler); extern int default_acpi_madt_oem_check(char *, char *); +extern void x86_64_probe_apic(void); #else static inline int default_acpi_madt_oem_check(char *a, char *b) { return 0; } +static inline void x86_64_probe_apic(void) { } #endif extern int default_apic_id_valid(u32 apicid); -extern void default_setup_apic_routing(void); extern u32 apic_default_calc_apicid(unsigned int cpu); extern u32 apic_flat_calc_apicid(unsigned int cpu); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1419,7 +1419,9 @@ void __init apic_intr_mode_init(void) break; } - default_setup_apic_routing(); + x86_64_probe_apic(); + + x86_32_install_bigsmp(); if (x86_platform.apic_post_init) x86_platform.apic_post_init(); --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -101,7 +101,6 @@ static struct apic apic_flat __ro_after_ .check_apicid_used = NULL, .init_apic_ldr = default_init_apic_ldr, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = flat_phys_pkg_id, @@ -178,7 +177,6 @@ static struct apic apic_physflat __ro_af .check_apicid_used = NULL, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = flat_phys_pkg_id, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -94,7 +94,6 @@ struct apic apic_noop __ro_after_init = .check_apicid_used = default_check_apicid_used, .ioapic_phys_id_map = default_ioapic_phys_id_map, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = noop_phys_pkg_id, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -253,7 +253,6 @@ static const struct apic apic_numachip1 .check_apicid_used = NULL, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, @@ -296,7 +295,6 @@ static const struct apic apic_numachip2 .check_apicid_used = NULL, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -28,13 +28,6 @@ static bool bigsmp_check_apicid_used(phy return false; } -static void bigsmp_setup_apic_routing(void) -{ - printk(KERN_INFO - "Enabling APIC mode: Physflat. Using %d I/O APICs\n", - nr_ioapics); -} - static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap) { /* For clustered we don't have a good way to do this yet - hack */ @@ -101,7 +94,6 @@ static struct apic apic_bigsmp __ro_afte .check_apicid_used = bigsmp_check_apicid_used, .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map, - .setup_apic_routing = bigsmp_setup_apic_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = bigsmp_phys_pkg_id, --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -66,8 +66,10 @@ void default_send_IPI_mask_sequence_logi void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector); void default_send_IPI_mask_logical(const struct cpumask *mask, int vector); void x86_32_probe_bigsmp_early(void); +void x86_32_install_bigsmp(void); #else static inline void x86_32_probe_bigsmp_early(void) { } +static inline void x86_32_install_bigsmp(void) { } #endif #ifdef CONFIG_X86_BIGSMP --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -18,15 +18,6 @@ #include "local.h" -static void setup_apic_flat_routing(void) -{ -#ifdef CONFIG_X86_IO_APIC - printk(KERN_INFO - "Enabling APIC mode: Flat. Using %d I/O APICs\n", - nr_ioapics); -#endif -} - static int default_apic_id_registered(void) { return physid_isset(read_apic_id(), phys_cpu_present_map); @@ -58,7 +49,6 @@ static struct apic apic_default __ro_aft .check_apicid_used = default_check_apicid_used, .init_apic_ldr = default_init_apic_ldr, .ioapic_phys_id_map = default_ioapic_phys_id_map, - .setup_apic_routing = setup_apic_flat_routing, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = default_phys_pkg_id, @@ -132,16 +122,13 @@ void __init x86_32_probe_bigsmp_early(vo set_nr_cpu_ids(8); } -void __init default_setup_apic_routing(void) +void __init x86_32_install_bigsmp(void) { if (nr_cpu_ids >= 8 && !xen_pv_domain()) apic_bigsmp_force(); - - if (apic->setup_apic_routing) - apic->setup_apic_routing(); } -void __init generic_apic_probe(void) +void __init x86_32_probe_apic(void) { if (!cmdline_apic) { struct apic **drv; --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -14,7 +14,7 @@ #include "local.h" /* Select the appropriate APIC driver */ -void __init default_setup_apic_routing(void) +void __init x86_64_probe_apic(void) { struct apic **drv; --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -247,7 +247,6 @@ static struct apic apic_x2apic_cluster _ .check_apicid_used = NULL, .init_apic_ldr = init_x2apic_ldr, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = x2apic_phys_pkg_id, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -166,7 +166,6 @@ static struct apic apic_x2apic_phys __ro .check_apicid_used = NULL, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = x2apic_phys_pkg_id, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -838,7 +838,6 @@ static struct apic apic_x2apic_uv_x __ro .check_apicid_used = NULL, .ioapic_phys_id_map = NULL, - .setup_apic_routing = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = uv_phys_pkg_id, --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1253,7 +1253,7 @@ void __init setup_arch(char **cmdline_p) map_vsyscall(); - generic_apic_probe(); + x86_32_probe_apic(); early_quirks(); --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -150,7 +150,6 @@ static struct apic xen_pv_apic = { .check_apicid_used = default_check_apicid_used, /* Used on 32-bit */ .ioapic_phys_id_map = default_ioapic_phys_id_map, /* Used on 32-bit */ - .setup_apic_routing = NULL, .cpu_present_to_apicid = xen_cpu_present_to_apicid, .phys_pkg_id = xen_phys_pkg_id, /* detect_ht */ From patchwork Mon Jul 17 23:15:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121664 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1405970vqt; Mon, 17 Jul 2023 16:36:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+KOh+3Dn6VDChLBZWYD7Skkz9L3dHKtlXcN5+pt8JbS4Q29CDPeXUZo5YzXvGpUkefovR X-Received: by 2002:a05:6a20:3c8b:b0:134:87c3:7a73 with SMTP id b11-20020a056a203c8b00b0013487c37a73mr5659621pzj.5.1689636994137; Mon, 17 Jul 2023 16:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636994; cv=none; d=google.com; s=arc-20160816; b=bINkpmyFT3SX43SKHeupl6mFYaAxEAqqkykkUvi8rq0T6F1SK1FBWTaYW05Y+6kt8k JQnNcbbHVX3v6D46mqHr7hSZ2NDiFtSpieQdb0kJkBMctWOWe2ciFKv5Y3+znnDygsJz IhI8B1ubLppfnkaPVYKq9fmyjo6HG5SMt9BDDm8koJMDj857qMzZquBavkXY18lP4Udd Zlb7gPSLctF+9143ozAr9WCaCSOYtgpOoeeS7ECWJirRIs+6vXYxiJdnUWOykMft6f/u Fx+IpAyUmz61CMsewEAPP0UYNQP/8QO4ieiGZ/5Lpt3UearSf1MgL3T8XP17C92EpurZ WcQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=4cC4gJwVGzfQ/DDJivInGesMRSEte1u8rqPl+IK7uLs=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=HTOv0wul13YadgAkfAZwwD63D/oaB/zKQQ7b3EPkhHvoMLyUD6nbEzsir8xgpr+aWo dCPpy7VXKyYSBJcOUkpjY2fsv0VmCFjihhM2YwWiSZznFNzX4BuJv3qQa76H2WYHJxmg 3zpWvfI724T3i+yitiuboxjgfVBAjAnnCLJg3j47rb5jQsWzhqaeomWPO3ajA3Ahi3TF OpgNvgKfo6BG4r9uZcqHh5komtys5xwmcEBtdVCXISygSP16hfBZ5mdGK8kav6kwZDjS rBWvhQIfB9w97JvZ0NkcTI7ikbZn6iF+qgWZufK6JOKlbz60lQ8hc1suxSXnEm1XBV7p BR0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=x2OwiovR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j187-20020a638bc4000000b00553823e936fsi544771pge.135.2023.07.17.16.36.21; Mon, 17 Jul 2023 16:36:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=x2OwiovR; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbjGQXSh (ORCPT + 99 others); Mon, 17 Jul 2023 19:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjGQXSf (ORCPT ); Mon, 17 Jul 2023 19:18:35 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FE6A1BC9 for ; Mon, 17 Jul 2023 16:17:46 -0700 (PDT) Message-ID: <20230717223224.921638275@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4cC4gJwVGzfQ/DDJivInGesMRSEte1u8rqPl+IK7uLs=; b=x2OwiovRgP3Ti374y+naWdxFUW4LO15taPJclPM/rV49rWk7ZvNoWMYQKUo2dfpkIBc5wa 7o0oztMttS41xHmMbeQreErz8nFomzmhNOsKyMHyoUp6PTsSMdNt8WdvIKFumkEXG1MSTX 0BtX8u07+2hqv3eKkRbDG0ZXPG6GjoA+b/f1c40Z7eH40+zz4HaIt3bCVdwGUvPP2OPGNm vvfpTqTV3Nil/bJXzHIfaxP/KwTLuHWg6kEG/rLUX1h6Hprv18kfr6W04tJx6qaj4y8j9j 8mKKL3GeokQgmJrcTCp2oj9sDSAH+P1qvKsYpJrFourR74mHFPUQ4AjvvT614g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635723; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4cC4gJwVGzfQ/DDJivInGesMRSEte1u8rqPl+IK7uLs=; b=VjIPl7Vd9e666BaiIjoAdVALonqvd3jD8zMlLkTKt1bjHB7VdEktjxIJNnneJ3FI39ot23 pUP2cPXigIOWPWDQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 31/58] x86/apic: Mop up apic::apic_id_registered() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:22 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712800688718570 X-GMAIL-MSGID: 1771712800688718570 Really not a hotpath and again no reason for having a gazillion of empty callbacks returning 1. Make it return bool and provide one shared implementation for the remaining users. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 +- arch/x86/kernel/apic/apic.c | 7 ++----- arch/x86/kernel/apic/apic_common.c | 5 +++++ arch/x86/kernel/apic/apic_flat_64.c | 14 ++------------ arch/x86/kernel/apic/apic_noop.c | 12 ------------ arch/x86/kernel/apic/apic_numachip.c | 7 ------- arch/x86/kernel/apic/bigsmp_32.c | 6 ------ arch/x86/kernel/apic/local.h | 3 ++- arch/x86/kernel/apic/probe_32.c | 5 ----- arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 6 ------ arch/x86/kernel/apic/x2apic_uv_x.c | 6 ------ arch/x86/xen/apic.c | 6 ------ 13 files changed, 12 insertions(+), 68 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -295,7 +295,7 @@ struct apic { int (*probe)(void); int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); int (*apic_id_valid)(u32 apicid); - int (*apic_id_registered)(void); + bool (*apic_id_registered)(void); bool (*check_apicid_used)(physid_mask_t *map, int apicid); void (*init_apic_ldr)(void); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1571,11 +1571,8 @@ static void setup_local_APIC(void) apic_write(APIC_ESR, 0); } #endif - /* - * Double-check whether this APIC is really registered. - * This is meaningless in clustered apic mode, so we skip it. - */ - BUG_ON(!apic->apic_id_registered()); + /* Validate that the APIC is registered if required */ + BUG_ON(apic->apic_id_registered && !apic->apic_id_registered()); /* * Intel recommends to set DFR, LDR and TPR before enabling --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -42,6 +42,11 @@ int default_apic_id_valid(u32 apicid) return (apicid < 255); } +bool default_apic_id_registered(void) +{ + return physid_isset(read_apic_id(), phys_cpu_present_map); +} + /* * Set up the logical destination ID when the APIC operates in logical * destination mode. --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -66,16 +66,6 @@ static u32 set_apic_id(unsigned int id) return (id & 0xFF) << 24; } -static unsigned int read_xapic_id(void) -{ - return flat_get_apic_id(apic_read(APIC_ID)); -} - -static int flat_apic_id_registered(void) -{ - return physid_isset(read_xapic_id(), phys_cpu_present_map); -} - static int flat_phys_pkg_id(int initial_apic_id, int index_msb) { return initial_apic_id >> index_msb; @@ -91,7 +81,7 @@ static struct apic apic_flat __ro_after_ .probe = flat_probe, .acpi_madt_oem_check = flat_acpi_madt_oem_check, .apic_id_valid = default_apic_id_valid, - .apic_id_registered = flat_apic_id_registered, + .apic_id_registered = default_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, @@ -168,7 +158,7 @@ static struct apic apic_physflat __ro_af .probe = physflat_probe, .acpi_madt_oem_check = physflat_acpi_madt_oem_check, .apic_id_valid = default_apic_id_valid, - .apic_id_registered = flat_apic_id_registered, + .apic_id_registered = default_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -57,17 +57,6 @@ static int noop_probe(void) return 0; } -static int noop_apic_id_registered(void) -{ - /* - * if we would be really "pedantic" - * we should pass read_apic_id() here - * but since NOOP suppose APIC ID = 0 - * lets save a few cycles - */ - return physid_isset(0, phys_cpu_present_map); -} - static u32 noop_apic_read(u32 reg) { WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled); @@ -85,7 +74,6 @@ struct apic apic_noop __ro_after_init = .acpi_madt_oem_check = NULL, .apic_id_valid = default_apic_id_valid, - .apic_id_registered = noop_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -62,11 +62,6 @@ static int numachip_apic_id_valid(u32 ap return 1; } -static int numachip_apic_id_registered(void) -{ - return 1; -} - static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) { return initial_apic_id >> index_msb; @@ -244,7 +239,6 @@ static const struct apic apic_numachip1 .probe = numachip1_probe, .acpi_madt_oem_check = numachip1_acpi_madt_oem_check, .apic_id_valid = numachip_apic_id_valid, - .apic_id_registered = numachip_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, @@ -286,7 +280,6 @@ static const struct apic apic_numachip2 .probe = numachip2_probe, .acpi_madt_oem_check = numachip2_acpi_madt_oem_check, .apic_id_valid = numachip_apic_id_valid, - .apic_id_registered = numachip_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -18,11 +18,6 @@ static unsigned bigsmp_get_apic_id(unsig return (x >> 24) & 0xFF; } -static int bigsmp_apic_id_registered(void) -{ - return 1; -} - static bool bigsmp_check_apicid_used(physid_mask_t *map, int apicid) { return false; @@ -85,7 +80,6 @@ static struct apic apic_bigsmp __ro_afte .name = "bigsmp", .probe = probe_bigsmp, .apic_id_valid = default_apic_id_valid, - .apic_id_registered = bigsmp_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -15,7 +15,6 @@ /* X2APIC */ int x2apic_apic_id_valid(u32 apicid); -int x2apic_apic_id_registered(void); void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest); unsigned int x2apic_get_apic_id(unsigned long id); u32 x2apic_set_apic_id(unsigned int id); @@ -61,6 +60,8 @@ void default_send_IPI_allbutself(int vec void default_send_IPI_all(int vector); void default_send_IPI_self(int vector); +bool default_apic_id_registered(void); + #ifdef CONFIG_X86_32 void default_send_IPI_mask_sequence_logical(const struct cpumask *mask, int vector); void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask, int vector); --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -18,11 +18,6 @@ #include "local.h" -static int default_apic_id_registered(void) -{ - return physid_isset(read_apic_id(), phys_cpu_present_map); -} - static int default_phys_pkg_id(int cpuid_apic, int index_msb) { return cpuid_apic >> index_msb; --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -237,7 +237,6 @@ static struct apic apic_x2apic_cluster _ .probe = x2apic_cluster_probe, .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, .apic_id_valid = x2apic_apic_id_valid, - .apic_id_registered = x2apic_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -111,11 +111,6 @@ int x2apic_apic_id_valid(u32 apicid) return 1; } -int x2apic_apic_id_registered(void) -{ - return 1; -} - void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) { unsigned long cfg = __prepare_ICR(0, vector, dest); @@ -157,7 +152,6 @@ static struct apic apic_x2apic_phys __ro .probe = x2apic_phys_probe, .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, .apic_id_valid = x2apic_apic_id_valid, - .apic_id_registered = x2apic_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -783,11 +783,6 @@ static int uv_apic_id_valid(u32 apicid) return 1; } -static int uv_apic_id_registered(void) -{ - return 1; -} - static u32 apic_uv_calc_apicid(unsigned int cpu) { return apic_default_calc_apicid(cpu); @@ -829,7 +824,6 @@ static struct apic apic_x2apic_uv_x __ro .probe = uv_probe, .acpi_madt_oem_check = uv_acpi_madt_oem_check, .apic_id_valid = uv_apic_id_valid, - .apic_id_registered = uv_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -115,11 +115,6 @@ static int xen_id_always_valid(u32 apici return 1; } -static int xen_id_always_registered(void) -{ - return 1; -} - static int xen_phys_pkg_id(int initial_apic_id, int index_msb) { return initial_apic_id >> index_msb; @@ -142,7 +137,6 @@ static struct apic xen_pv_apic = { .probe = xen_apic_probe_pv, .acpi_madt_oem_check = xen_madt_oem_check, .apic_id_valid = xen_id_always_valid, - .apic_id_registered = xen_id_always_registered, /* .delivery_mode and .dest_mode_logical not used by XENPV */ From patchwork Mon Jul 17 23:15:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407116vqt; Mon, 17 Jul 2023 16:40:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHdIrv3aP4Enwib6VheOQZBrYTbN+808VQO9XUQA/FtJvTIwYlhcbSFIQcV0Xxjd9ZB87vS X-Received: by 2002:a05:6a20:430a:b0:f0:50c4:4c43 with SMTP id h10-20020a056a20430a00b000f050c44c43mr14186066pzk.5.1689637219886; Mon, 17 Jul 2023 16:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637219; cv=none; d=google.com; s=arc-20160816; b=ChgWQWVjNKNqoVUTQVlPjOhHd1LPgb6RO6pH0iCJKODwZcUtIGZNYK/8bj/oUXKi1r zP5KYFsVbof5JAfxCkf4IP6oiOIzcuROo3QfCYkjLYEiFOq8re/Z3FNrSGc9u86YXKha phX4yEgqi+aK8ETt4e7C6scq7BymMmW1mTwQ/OzghYnqyZM+U+h4S58DWePhDTFJBGav Q0eQUBYy54YyUZ0Udx/FrOyhIfesthWnEhc60hFEM6uKleO0RvfbQoAIX0FvBhAMD1Nx GzXsQ+X7GKj5GOb2FVKwFn1O2g8HI3KMLYemcP57vMEA54GOno4ffWtVB18ZM+oyd8MC GAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=Wo3JBTvCQoJQW2SUExSVUktNUCEvCHCZ3yixiHATHeQ=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=CTfucf3S2sZyOdxnpMv3PDho5JEwZgJ+iVpfWbSr2AkDhJ27mTAJoxeju+GnwV646z etDXfCcVVyiUuRyLpK131RoIii154lil6RqGoB62e/x4avWl2w7/TLLiUxkayHZrXlU9 HdgS0PYHvYsLhiRdzlIMixE5zpyfEx5rK7jBC2dS1xKfvFDnZVlOglVvFsN9PExV+HHU lILzr6ofG3X3yhgEQq3UEGBExQOlR+R+jWsgDh4KRilmfAJPinxm6JU4f/+85Hq0uA+x s75IBon4439acnuHz4YiuzlQ61QFuiuouSE6+Nx2hA0SFP/P1wJ0HMQJhYY/5zSX59EL j90Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kN5D1+kp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6300c2000000b005347c4d09ddsi538054pga.678.2023.07.17.16.40.07; Mon, 17 Jul 2023 16:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=kN5D1+kp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231485AbjGQXRe (ORCPT + 99 others); Mon, 17 Jul 2023 19:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231476AbjGQXRd (ORCPT ); Mon, 17 Jul 2023 19:17:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3746219BD for ; Mon, 17 Jul 2023 16:16:47 -0700 (PDT) Message-ID: <20230717223224.979781880@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Wo3JBTvCQoJQW2SUExSVUktNUCEvCHCZ3yixiHATHeQ=; b=kN5D1+kpe82x5535R+8MyScBmHvOwIfhwiRY786PEZkMcCkCfmvxMhmrhrNL/wIhq9A/w8 sxMc2aLDqmFRTf6KGyBSI3iEOb6lZcgHpkmd6XHREin9xRYcZcCwOhUKcpsXm+cvrLQhSV O4s2LzxAAuaF+G9mEGOy6MHQHQNqN2Egde0OxWwWiCXzwov0iYBqUE9e86v/pmuBoGg534 +YBWXCRADo7zNUT2YFNMGDBFWw6k57F8AG8GMPLco3/2FYgNVMaMwRCxarsTbw1EoGpLCt ItHgfa4eHj1zwK/EVMpfHzGObP6SldEdJ/Jc8Zb5+o1DHpwuRBPhC/nRITHs3Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Wo3JBTvCQoJQW2SUExSVUktNUCEvCHCZ3yixiHATHeQ=; b=NiGBPNwoOpOk9xZPiJabG49K3ip5AkKaUYnzDrYFQgfCraB9Dk3FmtMJ08POqhhSYmIsJ2 vbxa40csLOvoQpBQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 32/58] x86/apic/ipi: Tidy up the code and fixup comments References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:24 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713037713677719 X-GMAIL-MSGID: 1771713037713677719 Replace the undecodable comment on top of the function, replace the space consuming zero content comments with useful ones and tidy up the implementation to prevent further eye bleed. Make __default_send_IPI_shortcut() static as it has no other users. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/ipi.c | 74 ++++++++++++++++++------------------------- arch/x86/kernel/apic/local.h | 2 - 2 files changed, 32 insertions(+), 44 deletions(-) --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -108,68 +108,58 @@ static inline void __xapic_wait_icr_idle cpu_relax(); } -void __default_send_IPI_shortcut(unsigned int shortcut, int vector) +/* + * This is safe against interruption because it only writes the lower 32 + * bits of the APIC_ICR register. The destination field is ignored for + * short hand IPIs. + * + * wait_icr_idle() + * write(ICR2, dest) + * NMI + * wait_icr_idle() + * write(ICR) + * wait_icr_idle() + * write(ICR) + * + * This function does not need to disable interrupts as there is no ICR2 + * interaction. The memory write is direct except when the machine is + * affected by the 11AP Pentium erratum, which turns the plain write into + * an XCHG operation. + */ +static void __default_send_IPI_shortcut(unsigned int shortcut, int vector) { /* - * Subtle. In the case of the 'never do double writes' workaround - * we have to lock out interrupts to be safe. As we don't care - * of the value read we use an atomic rmw access to avoid costly - * cli/sti. Otherwise we use an even cheaper single atomic write - * to the APIC. - */ - unsigned int cfg; - - /* - * Wait for idle. + * Wait for the previous ICR command to complete. Use + * safe_apic_wait_icr_idle() for the NMI vector as there have been + * issues where otherwise the system hangs when the panic CPU tries + * to stop the others before launching the kdump kernel. */ if (unlikely(vector == NMI_VECTOR)) safe_apic_wait_icr_idle(); else __xapic_wait_icr_idle(); - /* - * No need to touch the target chip field. Also the destination - * mode is ignored when a shorthand is used. - */ - cfg = __prepare_ICR(shortcut, vector, 0); - - /* - * Send the IPI. The write to APIC_ICR fires this off. - */ - native_apic_mem_write(APIC_ICR, cfg); + /* Destination field (ICR2) and the destination mode are ignored */ + native_apic_mem_write(APIC_ICR, __prepare_ICR(shortcut, vector, 0)); } /* * This is used to send an IPI with no shorthand notation (the destination is * specified in bits 56 to 63 of the ICR). */ -void __default_send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest) +void __default_send_IPI_dest_field(unsigned int dest_mask, int vector, + unsigned int dest_mode) { - unsigned long cfg; - - /* - * Wait for idle. - */ + /* See comment in __default_send_IPI_shortcut() */ if (unlikely(vector == NMI_VECTOR)) safe_apic_wait_icr_idle(); else __xapic_wait_icr_idle(); - /* - * prepare target chip field - */ - cfg = __prepare_ICR2(mask); - native_apic_mem_write(APIC_ICR2, cfg); - - /* - * program the ICR - */ - cfg = __prepare_ICR(0, vector, dest); - - /* - * Send the IPI. The write to APIC_ICR fires this off. - */ - native_apic_mem_write(APIC_ICR, cfg); + /* Set the IPI destination field in the ICR */ + native_apic_mem_write(APIC_ICR2, __prepare_ICR2(dest_mask)); + /* Send it with the proper destination mode */ + native_apic_mem_write(APIC_ICR, __prepare_ICR(0, vector, dest_mode)); } void default_send_IPI_single_phys(int cpu, int vector) --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -44,8 +44,6 @@ static inline unsigned int __prepare_ICR void default_init_apic_ldr(void); -void __default_send_IPI_shortcut(unsigned int shortcut, int vector); - /* * This is used to send an IPI with no shorthand notation (the destination is * specified in bits 56 to 63 of the ICR). From patchwork Mon Jul 17 23:15:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1407286vqt; Mon, 17 Jul 2023 16:40:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvPzmiLIvkBEYeTTwhcpII9g4ytuSE1ngypBppitX0uq61P2qk+opr2ksC9Eogz6KXxcU+ X-Received: by 2002:a05:6a00:1c8b:b0:666:c1ae:3b87 with SMTP id y11-20020a056a001c8b00b00666c1ae3b87mr11481437pfw.12.1689637251551; Mon, 17 Jul 2023 16:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637251; cv=none; d=google.com; s=arc-20160816; b=W+cW+9qraLCEKPrMl8F8ocMr+L3kzKDD81R0G82TvmHZ6axAEBX8tgOJgQlLZRy7E2 UWFHAiwg0/ty/x5s5MgHcWaDPh2Z7Xk1pcRfdXgCGTw6QEItsEZzmNabfKrC1gMeIxi9 MBQAqZlUWRXeJzXB+Hc2aNDLjHEdYB946jerbKuSYY9/gQUH2IYqZNtC3FD3vaqKgoGo FBvY9/Z9pWs/aa8unCHsT8saWVXMForg/6vrCu8Q/Uq1tsLe28vGx2eAddHgCc1AthRq quHghbLL5mH2quitTAA0cNYAPFUYCCQGt8G350oeozG8XErKQywFp2qc09Jp3BGJa1uu D8WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=NZd5xR1HtDqEMrh0B1hOXEFIalKc6LgOvxIkfivvEsc=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=CgyyWIFo6YiOXp3NR3KGg6GO1PrXq2ZxpcACiKqTT/eIQRM8ZK+3tquXsrrGJ66K8V cPWvJ8RclS6a7MD5GveROoLnJNKhrfKy4DxCPjeUmWTuXYAQVtNPlFQblg/GTX8WON3e JmJoHE2QKaul6+10KmCnA41jrPEUFIP9WnVpEGpxWEyET0mkL3PBVchkmhxdqPKNr1MQ 8Nx8M0SO3XcPrIeOG0KU9mE5Ve/pKXTUr7by81P693KuyvFFxJ2KqGKBza+IKxfUNwFw hO2HIGugRfC3IsGVMfjTa2VTuXPC8u1qxPzC5cN9wk4dtmArm/ClKFQuDeGHMXyLxPdQ S4uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4WyKvRD0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u19-20020a056a00125300b0066871b54e15si535888pfi.359.2023.07.17.16.40.38; Mon, 17 Jul 2023 16:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4WyKvRD0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbjGQXRy (ORCPT + 99 others); Mon, 17 Jul 2023 19:17:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbjGQXRt (ORCPT ); Mon, 17 Jul 2023 19:17:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3123DE47 for ; Mon, 17 Jul 2023 16:16:55 -0700 (PDT) Message-ID: <20230717223225.037396803@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=NZd5xR1HtDqEMrh0B1hOXEFIalKc6LgOvxIkfivvEsc=; b=4WyKvRD03r1sRefT9H8XV9xm5jc3hbqy6kdcvvRCsdBOXA+DEyWI5yorwbxVLJlrkYY+hl aIM2Tn2ypEqXAcX8j3F5ucE/OF8osNHnG/kiZT3I564AoA7I2IQfW6junat62MBAgeHoVZ M+X6hW/bQnCvkYt8dBbtNG8SCVoA3i/xQ37Yisf9i1dHnypV0+ApTTLDWG7Q4qzvkjVTI6 s/ZkRRibovsdv+tEClU1L8H6V0/r0kRQfel4gcZQvVACXYR0fU4qVmKGIn4IacSekfrBV2 GcdToV5d7Zjnq8ouEspuDCm6g9dRx1Dt9aDv5uLQJ/0rQnp4ujEwZywBjHz1Gg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=NZd5xR1HtDqEMrh0B1hOXEFIalKc6LgOvxIkfivvEsc=; b=7eC6VKmrXMOHZhBfpJUG/fIFo2F27iX4w5tC0x6K1SjZ0JgoMJQemwCfx2TBWec7aOR2Cs wgTV8TJd36/IBdBA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 33/58] x86/apic: Consolidate wait_icr_idle() implementations References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:25 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713070289457093 X-GMAIL-MSGID: 1771713070289457093 Two copies and also needlessly public. Move it into ipi.c so it can be inlined. Rename it to apic_mem_wait_icr_idle(). Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 1 - arch/x86/kernel/apic/apic.c | 6 ------ arch/x86/kernel/apic/apic_flat_64.c | 4 ++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/ipi.c | 6 +++--- arch/x86/kernel/apic/local.h | 2 ++ arch/x86/kernel/apic/probe_32.c | 2 +- 7 files changed, 9 insertions(+), 14 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -98,7 +98,6 @@ static inline u32 native_apic_mem_read(u return *((volatile u32 *)(APIC_BASE + reg)); } -extern void native_apic_wait_icr_idle(void); extern u32 native_safe_apic_wait_icr_idle(void); extern void native_apic_icr_write(u32 low, u32 id); extern u64 native_apic_icr_read(void); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -240,12 +240,6 @@ static void __init apic_disable(void) apic = &apic_noop; } -void native_apic_wait_icr_idle(void) -{ - while (apic_read(APIC_ICR) & APIC_ICR_BUSY) - cpu_relax(); -} - u32 native_safe_apic_wait_icr_idle(void) { u32 send_status; --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -111,7 +111,7 @@ static struct apic apic_flat __ro_after_ .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = native_apic_wait_icr_idle, + .wait_icr_idle = apic_mem_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; @@ -187,7 +187,7 @@ static struct apic apic_physflat __ro_af .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = native_apic_wait_icr_idle, + .wait_icr_idle = apic_mem_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -108,7 +108,7 @@ static struct apic apic_bigsmp __ro_afte .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = native_apic_wait_icr_idle, + .wait_icr_idle = apic_mem_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -102,7 +102,7 @@ static inline int __prepare_ICR2(unsigne return SET_XAPIC_DEST_FIELD(mask); } -static inline void __xapic_wait_icr_idle(void) +void apic_mem_wait_icr_idle(void) { while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY) cpu_relax(); @@ -137,7 +137,7 @@ static void __default_send_IPI_shortcut( if (unlikely(vector == NMI_VECTOR)) safe_apic_wait_icr_idle(); else - __xapic_wait_icr_idle(); + apic_mem_wait_icr_idle(); /* Destination field (ICR2) and the destination mode are ignored */ native_apic_mem_write(APIC_ICR, __prepare_ICR(shortcut, vector, 0)); @@ -154,7 +154,7 @@ void __default_send_IPI_dest_field(unsig if (unlikely(vector == NMI_VECTOR)) safe_apic_wait_icr_idle(); else - __xapic_wait_icr_idle(); + apic_mem_wait_icr_idle(); /* Set the IPI destination field in the ICR */ native_apic_mem_write(APIC_ICR2, __prepare_ICR2(dest_mask)); --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -44,6 +44,8 @@ static inline unsigned int __prepare_ICR void default_init_apic_ldr(void); +void apic_mem_wait_icr_idle(void); + /* * This is used to send an IPI with no shorthand notation (the destination is * specified in bits 56 to 63 of the ICR). --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -64,7 +64,7 @@ static struct apic apic_default __ro_aft .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = native_apic_wait_icr_idle, + .wait_icr_idle = apic_mem_wait_icr_idle, .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, }; From patchwork Mon Jul 17 23:15:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121674 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406819vqt; Mon, 17 Jul 2023 16:39:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHsnnvSKoueGGuVlONtxAni+9Wu+e3398FNfrCoSNvULclFGsQhJXOkbCJ74jlt9a2RIcmO X-Received: by 2002:a05:6a20:5487:b0:134:ceb7:6dfa with SMTP id i7-20020a056a20548700b00134ceb76dfamr4361263pzk.49.1689637164637; Mon, 17 Jul 2023 16:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637164; cv=none; d=google.com; s=arc-20160816; b=EeNcNHkJl2ckc1zQDN9kmwOEpO7BmFO1XbCliWHR6K9u+3C8qt7jl5v1+3kIHInumH zaGehXTWh9x+dzHLdnG7FPmjiMSnX48k4odw9XEE5N4ct+bnbJ9jGHvdrM+2SS+ksLFC 5HSkINYYRn08i3oR+U5yBYF+rKs0MIF/qqLtdvPGfB/I4AwntOBoR+d0g/mYiu4N9PSo ognH6OAdyWq6nqT9PjTZG57VgI8InDEfkWTp26cLx/SelvhLBwYQslOFrMhqVvU+Gz1y VXxTdO5ghx1qnw+BZTrTxGtL+I3WzcG894LGRkgTp7c5tVfVBbeae7TZxZoFmAfG2JiE 1qkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=s4wbt5O4wQYbAqg6kKvi3oCsmzwopLD0vJC7pLObyok=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=FXPDLCizudzpy9o1dwkq45m6i2Nyo7R5WcMmgIFBLZ5+DD9jUGhP4WvSAqISr2mEum WrRc02wmgk61Hl3xPBBK6UWQHh7+qxFyqLzfSrhdWVBdG5PHJvrakDTWQKU02uUMpp+S hv5d2lAAHQvdTvnmgAnfpjeUL0cUos7tMUa4ckvfL24Om9KE/pcpTpm31cbZcQoPcUog /nMR/09ef2cglTHUcZXepCV61JSSrl/5PlJf2fTIkWRPeIJsBYj05LBJHEMJgIhxaUQc ZFiBRfrtDxNZiORww3j9qDEG+8nUJNp54PgOq9z+EGjiAUqh62qJZVucPI9TOuQ9/scQ UNJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WFlLmFuO; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id im15-20020a170902bb0f00b001bb42c274a9si280282plb.504.2023.07.17.16.39.11; Mon, 17 Jul 2023 16:39:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WFlLmFuO; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231491AbjGQXRw (ORCPT + 99 others); Mon, 17 Jul 2023 19:17:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbjGQXRr (ORCPT ); Mon, 17 Jul 2023 19:17:47 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C5F81B5 for ; Mon, 17 Jul 2023 16:16:54 -0700 (PDT) Message-ID: <20230717223225.096117007@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s4wbt5O4wQYbAqg6kKvi3oCsmzwopLD0vJC7pLObyok=; b=WFlLmFuOKyst8qV7bJZwbtJ0k7Yn8oD8fw4od6p4NQgCSt61dO4gmKqs0gtJf94ZoVdHUM UOnQF2IMM/Lj0meFsCIhl5AYiRFkRfEXOR3O1EJFfKVdjGQjtFV6QrWh+cf3M84bheSLmS vsUn9coI9NfSrELRw0sM26luIrDv97lhfnLlEf4OxRxlziceGJNDTCRwhlv8HIqgoG718x BbIB+SFNBwlJUtrkygFQ69F9Na/niXUEAYHv2e4SbwH1DICJs1KO1q5rXwfJdDw9wI8HZo ME71NSVafHXVOFrZV8N9fa5JJ2kfek41Mj+swXdz+hn0oRGQdx6GISlfRjQGnA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635727; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s4wbt5O4wQYbAqg6kKvi3oCsmzwopLD0vJC7pLObyok=; b=W4GStyA8Y5TOj5iYcRe9Fem4XzOngNju0S+a8QFd8jTypeSd0UGziWSXrynn053oXRXxnT UwUdkSDk/RF2y/Dw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 34/58] x86/apic: Allow apic::wait_icr_idle() to be NULL References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:27 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712979539309331 X-GMAIL-MSGID: 1771712979539309331 Nuke more NOOP callbacks and make the invocation conditional. Will be replaced with a static call later. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 9 ++------- arch/x86/kernel/apic/apic_noop.c | 2 -- arch/x86/kernel/apic/apic_numachip.c | 7 ------- arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 1 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 - arch/x86/xen/apic.c | 5 ----- 7 files changed, 2 insertions(+), 24 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -206,12 +206,6 @@ static inline u32 native_apic_msr_read(u return (u32)msr; } -static inline void native_x2apic_wait_icr_idle(void) -{ - /* no need to wait for icr idle in x2apic */ - return; -} - static inline u32 native_safe_x2apic_wait_icr_idle(void) { /* no need to wait for icr idle in x2apic */ @@ -376,7 +370,8 @@ static inline void apic_icr_write(u32 lo static inline void apic_wait_icr_idle(void) { - apic->wait_icr_idle(); + if (apic->wait_icr_idle) + apic->wait_icr_idle(); } static inline u32 safe_apic_wait_icr_idle(void) --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -20,7 +20,6 @@ static void noop_send_IPI_mask_allbutsel static void noop_send_IPI_allbutself(int vector) { } static void noop_send_IPI_all(int vector) { } static void noop_send_IPI_self(int vector) { } -static void noop_apic_wait_icr_idle(void) { } static void noop_apic_icr_write(u32 low, u32 id) { } static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) @@ -105,6 +104,5 @@ struct apic apic_noop __ro_after_init = .eoi_write = noop_apic_write, .icr_read = noop_apic_icr_read, .icr_write = noop_apic_icr_write, - .wait_icr_idle = noop_apic_wait_icr_idle, .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -223,11 +223,6 @@ static int numachip2_acpi_madt_oem_check return 1; } -/* APIC IPIs are queued */ -static void numachip_apic_wait_icr_idle(void) -{ -} - /* APIC NMI IPIs are queued */ static u32 numachip_safe_apic_wait_icr_idle(void) { @@ -269,7 +264,6 @@ static const struct apic apic_numachip1 .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = numachip_apic_wait_icr_idle, .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle, }; @@ -310,7 +304,6 @@ static const struct apic apic_numachip2 .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .wait_icr_idle = numachip_apic_wait_icr_idle, .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -266,7 +266,6 @@ static struct apic apic_x2apic_cluster _ .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -180,7 +180,6 @@ static struct apic apic_x2apic_phys __ro .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -854,7 +854,6 @@ static struct apic apic_x2apic_uv_x __ro .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .wait_icr_idle = native_x2apic_wait_icr_idle, .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -120,10 +120,6 @@ static int xen_phys_pkg_id(int initial_a return initial_apic_id >> index_msb; } -static void xen_noop(void) -{ -} - static int xen_cpu_present_to_apicid(int cpu) { if (cpu_present(cpu)) @@ -165,7 +161,6 @@ static struct apic xen_pv_apic = { .icr_read = xen_apic_icr_read, .icr_write = xen_apic_icr_write, - .wait_icr_idle = xen_noop, .safe_wait_icr_idle = xen_safe_apic_wait_icr_idle, }; From patchwork Mon Jul 17 23:15:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1400806vqt; Mon, 17 Jul 2023 16:21:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGFu/K2t0NyrfN85gUSj0IwFQ2InkH54t7vMJ1Q/IN7vMJHXXQzdhp8c1LCm8LgkZin6KcS X-Received: by 2002:a9d:6219:0:b0:6b9:a6ef:2709 with SMTP id g25-20020a9d6219000000b006b9a6ef2709mr1169358otj.8.1689636107731; Mon, 17 Jul 2023 16:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636107; cv=none; d=google.com; s=arc-20160816; b=Dsv0xaSnv9DvFFt1cPN9j46u9LxGuc4PSTBBnVkragUiFG51YZShtj/j2AVZ+e1lWT bYtXNCql32aIvnMjEIxQKcjCHsynO4pWlrmXqAlJXskjmftuC3p6OSYO+iBqydvniNNC vNbfFSTjA6i1QrFfkdQz6qSCX36q/UQMqqqjG/JUxNc20wEQ6vs5wv3bs/5Qs3RmL/NA 2SUds7HW8UcVqsUJImG/nHYEMzN6f+GVomKwbSwLOb79855FRtGKZXcZvR/KuR+7q4ae 8Th3FX9ODINm6ordbvz+INkq0RzP+dcwYnpF/KiDgdnqPoXblheU/zotbSJ/Y8vkg3ks SDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=X34cmveL8Me/hBK02cEFeh6qWm49lBpmvG/a5va6nks=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=DgK5WH/iadzc8t5KMlHgmBKJwkCR7NfJtWJZjDxvep28bhjGmH2pPPHtuOCbQp0n31 InWWpF7O2oaj7Qn2RwuBlMp+XB4vFvkxulkooA8UBqUZv0ynnkVk/nu0CzP4eqDaY5J0 yAOMzE0KuJsJK3WWu+xVtQFNfjdpVqOjy+vRS/pbGjEcHg4aKEuf/+c44xLXBOlI4AuY +WS0kd8SqlRNBLJMf9SnqQ3ZMTW4S9ujM+BLCrdeZ50b7NsGy/L+hFWvWnc5z7Mf+BCr QEjwT8aNiD8UF9rt4S7tXAxwHkJ1dF2HyVuqoxTV2iUMq8awwnsdZ9ZZ5NXq+WOycgVh E5/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tcurvsLO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k25-20020a6568d9000000b0055727399652si511007pgt.577.2023.07.17.16.21.34; Mon, 17 Jul 2023 16:21:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tcurvsLO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbjGQXST (ORCPT + 99 others); Mon, 17 Jul 2023 19:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231496AbjGQXSR (ORCPT ); Mon, 17 Jul 2023 19:18:17 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 309D7172A for ; Mon, 17 Jul 2023 16:17:23 -0700 (PDT) Message-ID: <20230717223225.156587052@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=X34cmveL8Me/hBK02cEFeh6qWm49lBpmvG/a5va6nks=; b=tcurvsLO1Z2sDkcBbbOc40m0poc21jDMJnyhGRIczV4CuIdgr4zYf33u+9rQutqDfIAofd TpIxSPWbW7z1GS2p9YahX+v7n+8hVXaqzJCkgP7OfblUwP/zlGxcnvnAHkDiRXuNpcPmKP /H2Cet1v8UouW9r2CehjOE56QyDMxrP53QqfTcIxD2oRqUdh2+RHbPl97y7lBvlG//QPCP 6exmGfO4U7YgaddsJOxT2hW1o66TWFvwLTeb9e3ViKChP9OmKMscjF2kSYfum+buLg8fQh cGw5siSoB+4bNNzY7UhmP/KPpSfASMaiM8WVauuOkDRpq6ei0uMNGgnEExh3lQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=X34cmveL8Me/hBK02cEFeh6qWm49lBpmvG/a5va6nks=; b=DpW4Ja5T5hp5CfsVhrAqaGt+QRZyT1Bdijwy2WeaP87aHEYHESUPwwXwPxf9AlxWGVO1+g ch7z4ToBXjLKBnCg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 35/58] x86/apic: Allow apic::safe_wait_icr_idle() to be NULL References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:28 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771711870967143521 X-GMAIL-MSGID: 1771711870967143521 Remove tons of NOOP callbacks by making the invocation of safe_wait_icr_idle() conditional in the inline wrapper. Will be replaced by a static_call_cond() later. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 8 +------- arch/x86/kernel/apic/apic_noop.c | 6 ------ arch/x86/kernel/apic/apic_numachip.c | 8 -------- arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 1 - arch/x86/kernel/apic/x2apic_uv_x.c | 1 - arch/x86/xen/apic.c | 6 ------ 7 files changed, 1 insertion(+), 30 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -206,12 +206,6 @@ static inline u32 native_apic_msr_read(u return (u32)msr; } -static inline u32 native_safe_x2apic_wait_icr_idle(void) -{ - /* no need to wait for icr idle in x2apic */ - return 0; -} - static inline void native_x2apic_icr_write(u32 low, u32 id) { wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low); @@ -376,7 +370,7 @@ static inline void apic_wait_icr_idle(vo static inline u32 safe_apic_wait_icr_idle(void) { - return apic->safe_wait_icr_idle(); + return apic->safe_wait_icr_idle ? apic->safe_wait_icr_idle() : 0; } extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)); --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -27,11 +27,6 @@ static int noop_wakeup_secondary_cpu(int return -1; } -static u32 noop_safe_apic_wait_icr_idle(void) -{ - return 0; -} - static u64 noop_apic_icr_read(void) { return 0; @@ -104,5 +99,4 @@ struct apic apic_noop __ro_after_init = .eoi_write = noop_apic_write, .icr_read = noop_apic_icr_read, .icr_write = noop_apic_icr_write, - .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, }; --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -223,12 +223,6 @@ static int numachip2_acpi_madt_oem_check return 1; } -/* APIC NMI IPIs are queued */ -static u32 numachip_safe_apic_wait_icr_idle(void) -{ - return 0; -} - static const struct apic apic_numachip1 __refconst = { .name = "NumaConnect system", .probe = numachip1_probe, @@ -264,7 +258,6 @@ static const struct apic apic_numachip1 .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle, }; apic_driver(apic_numachip1); @@ -304,7 +297,6 @@ static const struct apic apic_numachip2 .eoi_write = native_apic_mem_write, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, - .safe_wait_icr_idle = numachip_safe_apic_wait_icr_idle, }; apic_driver(apic_numachip2); --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -266,7 +266,6 @@ static struct apic apic_x2apic_cluster _ .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; apic_driver(apic_x2apic_cluster); --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -180,7 +180,6 @@ static struct apic apic_x2apic_phys __ro .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; apic_driver(apic_x2apic_phys); --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -854,7 +854,6 @@ static struct apic apic_x2apic_uv_x __ro .eoi_write = native_apic_msr_eoi_write, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, - .safe_wait_icr_idle = native_safe_x2apic_wait_icr_idle, }; #define UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_LENGTH 3 --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -92,11 +92,6 @@ static void xen_apic_icr_write(u32 low, WARN_ON(1); } -static u32 xen_safe_apic_wait_icr_idle(void) -{ - return 0; -} - static int xen_apic_probe_pv(void) { if (xen_pv_domain()) @@ -161,7 +156,6 @@ static struct apic xen_pv_apic = { .icr_read = xen_apic_icr_read, .icr_write = xen_apic_icr_write, - .safe_wait_icr_idle = xen_safe_apic_wait_icr_idle, }; static void __init xen_apic_check(void) From patchwork Mon Jul 17 23:15:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1421212vqt; Mon, 17 Jul 2023 17:20:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlFE7IZcyoRSFz13SAHeK2KiuCiuU7jqD9oY/cOtkIoGLasP2G6oMmCTcoo4KE47j2TgEnRO X-Received: by 2002:a50:ef19:0:b0:51f:f079:875f with SMTP id m25-20020a50ef19000000b0051ff079875fmr12708638eds.4.1689639622701; Mon, 17 Jul 2023 17:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689639622; cv=none; d=google.com; s=arc-20160816; b=MKmhE1nQpEoU9JD3oxegCOKfBZZsJAQZEy/V5iZh+E/SMmYj7shn9OkJS3mJb4WXfE WG2rX+9LTSPBfm+oV/+gC+QiChF+qW2vwx/T+7ynfHyQxJnnTVc1k0r7pvkJ4TSLE2Dd WM9BGsfO/nUgJAdms09AQItAsWHO3rUnvZ0h4P8uQgGvYrpzc+3APwmOW0PtphPXT0RG +0WzbP+XQsk3vw8hh+xZ/OGSkhBPpI2HjkjFHjKUB/UuoyOMp0Ew5QDfi5RvhE7+IBTc 5Oa1Xmi/1jmNdunyPQNasAv29uq/9pkeU9bNheL5kFxOHMmzOR+ryHgygTjSFT/zbSLg 2clw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=rgmHkZejpS0qXydJ9Am1q5T6I2ZzaAIkhjBamrktz/k=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Lqzm0QiBPhWnxIczTuJIxhInJp8IgtJqxnKMWcRZVNXcJ4yfx0waHIONzyBfnCkQdc IXjwwcmP/YytPA3jhnRSkQOJazzI8n251JIJl+KVD6Vd4L2kn7KGExBDzrGGjyTELats afH7vhbuX40aWBmcYdrOlWUmR52n6Km535pkCkErHgMzROv/CcfOeJsXevE1n8OTSfdE MuGeiGnOSNCAgWgWwa05NZdx3GiUrrBQraZao3/0PG5fWNXApBMShzqORsFpWq+4qzTf 4y+XRAPFTy1KufkZW3ZLV8qXSQGr5pAgXlEVA0m1qoCilKV7x99d6hkCwHSzYqR0L2by 7Zlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="00T/e6sX"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020a056402148900b005219be8c5d0si385167edv.77.2023.07.17.17.19.58; Mon, 17 Jul 2023 17:20:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="00T/e6sX"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229718AbjGQXcb (ORCPT + 99 others); Mon, 17 Jul 2023 19:32:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjGQXcX (ORCPT ); Mon, 17 Jul 2023 19:32:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 194B810C7 for ; Mon, 17 Jul 2023 16:31:26 -0700 (PDT) Message-ID: <20230717223225.215108043@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rgmHkZejpS0qXydJ9Am1q5T6I2ZzaAIkhjBamrktz/k=; b=00T/e6sXThT1a85ZqQWdu4xc7BpHBKIk3Qhl9MSi4pTKDhJ/pMd6BApjqpH2BGrQLrhxxt 1s79dzgkYBcIKnwpf6IGXIfCfZU6AMwqT7dStRocDbGuhg+qqlo1zvgLz5mIJfljLQBza4 xsTvlFgCq6cHXBrSESzgYSMW2CG6bveLkiCdTBgaD/ME0c7CpbLioRHO+WjDiAbS+oyigY /DKRO860dhFktAeMTG/qFGvcMSCWEfv9zFV86X9Aoyats4xyFA8WXp5vyIgxXejShgFqaf djmiJKzZfweQmFHkJdl1+XkzZdxphlUvlKk6NQUTemrAG8p7azBCC39eEvDPxA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=rgmHkZejpS0qXydJ9Am1q5T6I2ZzaAIkhjBamrktz/k=; b=BcG88HF8RG3MClC7We1N4mClZ4OL32G72fXeOqgkXZZNutvTPHKBw7OJJ5/JBwqHppsCsT ePH+1GPO1XU6v8Dw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 36/58] x86/apic: Move safe wait_icr_idle() next to apic_mem_wait_icr_idle() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:30 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771715557016880114 X-GMAIL-MSGID: 1771715557016880114 Move it next to apic_mem_wait_icr_idle(), rename it so that it's clear what it does and rewrite it in readable form. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 1 - arch/x86/kernel/apic/apic.c | 17 ----------------- arch/x86/kernel/apic/apic_flat_64.c | 4 ++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/ipi.c | 19 +++++++++++++++++-- arch/x86/kernel/apic/local.h | 1 + arch/x86/kernel/apic/probe_32.c | 2 +- 7 files changed, 22 insertions(+), 24 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -98,7 +98,6 @@ static inline u32 native_apic_mem_read(u return *((volatile u32 *)(APIC_BASE + reg)); } -extern u32 native_safe_apic_wait_icr_idle(void); extern void native_apic_icr_write(u32 low, u32 id); extern u64 native_apic_icr_read(void); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -240,23 +240,6 @@ static void __init apic_disable(void) apic = &apic_noop; } -u32 native_safe_apic_wait_icr_idle(void) -{ - u32 send_status; - int timeout; - - timeout = 0; - do { - send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY; - if (!send_status) - break; - inc_irq_stat(icr_read_retry_count); - udelay(100); - } while (timeout++ < 1000); - - return send_status; -} - void native_apic_icr_write(u32 low, u32 id) { unsigned long flags; --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -112,7 +112,7 @@ static struct apic apic_flat __ro_after_ .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; /* @@ -188,7 +188,7 @@ static struct apic apic_physflat __ro_af .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; /* --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -109,7 +109,7 @@ static struct apic apic_bigsmp __ro_afte .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; bool __init apic_bigsmp_possible(bool cmdline_override) --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -1,7 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include + #include #include "local.h" @@ -102,6 +104,19 @@ static inline int __prepare_ICR2(unsigne return SET_XAPIC_DEST_FIELD(mask); } +u32 apic_mem_wait_icr_idle_timeout(void) +{ + int cnt; + + for (cnt = 0; cnt < 1000; cnt++) { + if (!(apic_read(APIC_ICR) & APIC_ICR_BUSY)) + return 0; + inc_irq_stat(icr_read_retry_count); + udelay(100); + } + return APIC_ICR_BUSY; +} + void apic_mem_wait_icr_idle(void) { while (native_apic_mem_read(APIC_ICR) & APIC_ICR_BUSY) @@ -135,7 +150,7 @@ static void __default_send_IPI_shortcut( * to stop the others before launching the kdump kernel. */ if (unlikely(vector == NMI_VECTOR)) - safe_apic_wait_icr_idle(); + apic_mem_wait_icr_idle_timeout(); else apic_mem_wait_icr_idle(); @@ -152,7 +167,7 @@ void __default_send_IPI_dest_field(unsig { /* See comment in __default_send_IPI_shortcut() */ if (unlikely(vector == NMI_VECTOR)) - safe_apic_wait_icr_idle(); + apic_mem_wait_icr_idle_timeout(); else apic_mem_wait_icr_idle(); --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -45,6 +45,7 @@ static inline unsigned int __prepare_ICR void default_init_apic_ldr(void); void apic_mem_wait_icr_idle(void); +u32 apic_mem_wait_icr_idle_timeout(void); /* * This is used to send an IPI with no shorthand notation (the destination is --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -65,7 +65,7 @@ static struct apic apic_default __ro_aft .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, - .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, + .safe_wait_icr_idle = apic_mem_wait_icr_idle_timeout, }; apic_driver(apic_default); From patchwork Mon Jul 17 23:15:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1431910vqt; Mon, 17 Jul 2023 17:49:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdXADVKszAiYgdSma4rNzqPNyC+ZyepLzjaRzFZewMjoW1gff6B8HPN3ws3xW8iyefQQFr X-Received: by 2002:a17:903:1d1:b0:1bb:3d05:764 with SMTP id e17-20020a17090301d100b001bb3d050764mr1935689plh.32.1689641387762; Mon, 17 Jul 2023 17:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689641387; cv=none; d=google.com; s=arc-20160816; b=aZdlnwQS89ihXla+u5ePqJvImWKBn1Mb19tYAAVZeAUmeA4g72/fkLgsfkCgz0t+z8 2gKXkLSE5m/PPNvyCVdui05k9f1CN0IjN3d67F0NyCKwNYygDrkRDRIQ9LAHQPV1MSvF mwsGXy1ATUru2E7ilE3UlNCj8V+vM1AyBTOwPTHLunuNlbbz8RPbIwDefgtec7An2i1c KhjXfKFFHYxrrD4eyjB8UE3MB10JGXR5/PWquDoXn1h6TNx23MnuATp+G9ldkWCQVAtF rHM+aYW4SydJnrH+fdJzJ2xcz4NNVc+Cmt0fRQTJGEduvOPEgNbGwD20i2bIqWK7QY2u NzBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=0+V5+gDglWXFOXAl/NKeyplEXp2IefeCUE4Fh7G+n/4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=kjujrhBPD3VmHeEECzUwt8F3p8Ua3Gojs8K9fugmn0v9X3mC8AoyAeUDW1P3w3hcNu FjLuhTRJjee1oOjoDHGlgh+86z3h1dImMq4545T3YvJ0YIvpzvhgRcR+iGAAeYDYtfbM kOQTMie0ttG/CgC+LtSrtiKIOi+wDxQjX3MRUcH8JYR1I0NPAScaC9n7ZH/gv/CsR777 KCq2vJZcmkotJqsMj0bMctjd4Z5luxV2XEspOmIMTpEbQwEl+CTXKmq6lAD4TQnKsWZX E9bCR6MZlsQW1nYyA6hjApeT3uAXP4FGNu39ArW5A9bGeO2Uyk/29LuJ2iKBKu0kERVu 3K4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KmKQ0C6Z; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a17090340cc00b001ab089f7329si713759pld.73.2023.07.17.17.49.35; Mon, 17 Jul 2023 17:49:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KmKQ0C6Z; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229470AbjGQXg5 (ORCPT + 99 others); Mon, 17 Jul 2023 19:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231685AbjGQXgv (ORCPT ); Mon, 17 Jul 2023 19:36:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86751719 for ; Mon, 17 Jul 2023 16:36:03 -0700 (PDT) Message-ID: <20230717223225.273415268@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0+V5+gDglWXFOXAl/NKeyplEXp2IefeCUE4Fh7G+n/4=; b=KmKQ0C6ZMTvfEMgWOWKvqJMIcQO3L7KYwm4M44SqqGkqOH2msmDctXcslNo37q98COYsjG 07S6EO1elC3GA+p5bQiQHXM/8k4yka5pcdl2S5mvDJNsZhxVwmT059drPucIR4jysYlhId C7JPTtIBcluvu3sPuF7gFwik4+hY/O87pPgcZ8r7V5GUTNXJRZaUegt8JEwcEx9wtTxgky 4NbMROhWywUFAQzWyWAvwbgTlGskzmamUcc0fqwyNVt7+ay+/TtP3IoSi5msrNH2ytXSfB hkD1nkn5ZQORYTnsqLKGNnP95WTAniZsQ8HWKf4GcItae+rAMAvIdO0a+i10ug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=0+V5+gDglWXFOXAl/NKeyplEXp2IefeCUE4Fh7G+n/4=; b=LJkgLnx1AiB7LE4UdEfC/YxcSdmOw+WdxAJOnnMQ5DtxuaNVKgM7lUrO/t2Pw8cojki5fP NAcoDqSF1Z9mQ2Dg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 37/58] x86/apic/uv: Get rid of wrapper callbacks References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:31 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771717408001157613 X-GMAIL-MSGID: 1771717408001157613 Why on earth makes a wrapper around some common function sense? Just to be able to slap some vendor name on it... Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/x2apic_uv_x.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -783,11 +783,6 @@ static int uv_apic_id_valid(u32 apicid) return 1; } -static u32 apic_uv_calc_apicid(unsigned int cpu) -{ - return apic_default_calc_apicid(cpu); -} - static unsigned int x2apic_get_apic_id(unsigned long id) { return id; @@ -838,7 +833,7 @@ static struct apic apic_x2apic_uv_x __ro .get_apic_id = x2apic_get_apic_id, .set_apic_id = set_apic_id, - .calc_dest_apicid = apic_uv_calc_apicid, + .calc_dest_apicid = apic_default_calc_apicid, .send_IPI = uv_send_IPI_one, .send_IPI_mask = uv_send_IPI_mask, From patchwork Mon Jul 17 23:15:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1401807vqt; Mon, 17 Jul 2023 16:25:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbblswG0Ss4/WVfRIiqNB4J0xa8ZFYOEM/fbvqhn1TmObzy7UOyvEdLFExsTFb8syY3FmN X-Received: by 2002:a17:903:249:b0:1bb:1e69:28be with SMTP id j9-20020a170903024900b001bb1e6928bemr10071575plh.42.1689636301138; Mon, 17 Jul 2023 16:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636301; cv=none; d=google.com; s=arc-20160816; b=jXBuneieLoxBpBEJiG7zSgtkPneHwiM7Xm4a+SO2udVSd/rzpDDaPBECufOtURxz2j ASKN8sOgE8KmS+0q2gzBrsfAnle/pNtH5SZxtyhODESkD3VEVfPGof8x0C377EPcggPa Kq0Q6rg9iPFjB3utxXGgnYNW2p0/ZCHAZbvqZQP/vBnVMv+UK0PXSqzEWJYX9HLWLjUT QY/8dlRzH61gXBO2pgGQBd1Wg6H2KwIQiPp8RHW6uIv9yQM1C88XOkwE2y93UQycUJ93 W4ypTDygpU4Ar+i1OOvoRelq+snhipszm1xLEDSovxmAVuJOiqJW7L44iXT1JUKMJw8E HpwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=WHis69mmEACCZeo2mW2vVxOI6ZmCX2FA8vZEK44ZXAtxWP2C+YSJhl2RdwdfMHrur5 P76jtGHd3pAV5SsAASB7LWWCEaN8JL5aNQfjws1RdXCtBnKbdjiryxHByubyk/REvYOc 6W+x2lD7dMkY9sMG4mzilp8U4pmT903jkqj/cl1qCcbkcTpUy4l9t9ICgGro/JYNufjr IIZ9uUYoUTxhTWH/L3l12LYA6+eVrD2HOKKw1arNIfhtuPvJmdSl5DPF6OfNJ2jECL8n lhDrM6CgiTR0DZYqyOI+8QZRO6Y2XIRbt6drLsJATGHO5RuHDTuO+OCz8k3AA1x1lx7E bjeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qOxr+TxD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u17-20020a170902e5d100b001b9e3a18270si607410plf.420.2023.07.17.16.24.48; Mon, 17 Jul 2023 16:25:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qOxr+TxD; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231610AbjGQXSu (ORCPT + 99 others); Mon, 17 Jul 2023 19:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjGQXSm (ORCPT ); Mon, 17 Jul 2023 19:18:42 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091AEE4F for ; Mon, 17 Jul 2023 16:17:57 -0700 (PDT) Message-ID: <20230717223225.334807697@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; b=qOxr+TxD5+bSVnDx7EcALBZ038LlrFO0DGfArAheniYF+ztj6KV158Wd0YQqVelpmmV/UT iNOK9KeYViRVTAsYFWk6gBzq+FFuTRZH88638kX7qEdvX+LgHcKvYoBKildgmXrqdjrta8 QZaykCZ1jC3OPi7yfOPytJnEADZ8HfdvUtJh76EbzTWmTo9a8HnKqfcWdaXBtK46pv94mb 0imusoafVA5qYwgm62wcBJmOXMGjTeWo1MKNzw1Q2cB0bxqfFpEjgpI02e675DTVeGk627 QVcvjYK1cImRR/wl248VNa+DBpa9Fgn3VInl67UO2HMMbAIwuPUwXh5x+FpqMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=4BLE3+yKPO5gwc0BMR9mix8xtcjKVx9Oe/w05M3UNgo=; b=cnDdZ0mfDxo2YlLhWMoPIG2qgSk5TCJnk1FcqhpGJyC5cP0NmesbixwZsa3moIeJ+c0JCE 3tiCxmpEZJOjZYBw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 38/58] x86/apic/x2apic: Share all common IPI functions References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:33 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712073849339684 X-GMAIL-MSGID: 1771712073849339684 Yet more copy and pasta gone. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/local.h | 4 ++- arch/x86/kernel/apic/x2apic_cluster.c | 10 ------- arch/x86/kernel/apic/x2apic_phys.c | 44 +++++++++++++++++----------------- arch/x86/kernel/apic/x2apic_uv_x.c | 14 ++-------- 4 files changed, 28 insertions(+), 44 deletions(-) --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -19,8 +19,10 @@ void __x2apic_send_IPI_dest(unsigned int unsigned int x2apic_get_apic_id(unsigned long id); u32 x2apic_set_apic_id(unsigned int id); int x2apic_phys_pkg_id(int initial_apicid, int index_msb); + +void x2apic_send_IPI_all(int vector); +void x2apic_send_IPI_allbutself(int vector); void x2apic_send_IPI_self(int vector); -void __x2apic_send_IPI_shorthand(int vector, u32 which); /* IPI */ --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -83,16 +83,6 @@ x2apic_send_IPI_mask_allbutself(const st __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_allbutself(int vector) -{ - __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLBUT); -} - -static void x2apic_send_IPI_all(int vector) -{ - __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLINC); -} - static u32 x2apic_calc_apicid(unsigned int cpu) { return x86_cpu_to_logical_apicid[cpu]; --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -81,16 +81,36 @@ static void __x2apic_send_IPI_mask(mask, vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_allbutself(int vector) +static void __x2apic_send_IPI_shorthand(int vector, u32 which) +{ + unsigned long cfg = __prepare_ICR(which, vector, 0); + + /* x2apic MSRs are special and need a special fence: */ + weak_wrmsr_fence(); + native_x2apic_icr_write(cfg, 0); +} + +void x2apic_send_IPI_allbutself(int vector) { __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLBUT); } -static void x2apic_send_IPI_all(int vector) +void x2apic_send_IPI_all(int vector) { __x2apic_send_IPI_shorthand(vector, APIC_DEST_ALLINC); } +void x2apic_send_IPI_self(int vector) +{ + apic_write(APIC_SELF_IPI, vector); +} + +void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) +{ + unsigned long cfg = __prepare_ICR(0, vector, dest); + native_x2apic_icr_write(cfg, apicid); +} + static int x2apic_phys_probe(void) { if (!x2apic_mode) @@ -111,21 +131,6 @@ int x2apic_apic_id_valid(u32 apicid) return 1; } -void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest) -{ - unsigned long cfg = __prepare_ICR(0, vector, dest); - native_x2apic_icr_write(cfg, apicid); -} - -void __x2apic_send_IPI_shorthand(int vector, u32 which) -{ - unsigned long cfg = __prepare_ICR(which, vector, 0); - - /* x2apic MSRs are special and need a special fence: */ - weak_wrmsr_fence(); - native_x2apic_icr_write(cfg, 0); -} - unsigned int x2apic_get_apic_id(unsigned long id) { return id; @@ -141,11 +146,6 @@ int x2apic_phys_pkg_id(int initial_apici return initial_apicid >> index_msb; } -void x2apic_send_IPI_self(int vector) -{ - apic_write(APIC_SELF_IPI, vector); -} - static struct apic apic_x2apic_phys __ro_after_init = { .name = "physical x2apic", --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -25,6 +25,8 @@ #include #include +#include "local.h" + static enum uv_system_type uv_system_type; static int uv_hubbed_system; static int uv_hubless_system; @@ -783,11 +785,6 @@ static int uv_apic_id_valid(u32 apicid) return 1; } -static unsigned int x2apic_get_apic_id(unsigned long id) -{ - return id; -} - static u32 set_apic_id(unsigned int id) { return id; @@ -803,11 +800,6 @@ static int uv_phys_pkg_id(int initial_ap return uv_read_apic_id() >> index_msb; } -static void uv_send_IPI_self(int vector) -{ - apic_write(APIC_SELF_IPI, vector); -} - static int uv_probe(void) { return apic == &apic_x2apic_uv_x; @@ -840,7 +832,7 @@ static struct apic apic_x2apic_uv_x __ro .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself, .send_IPI_allbutself = uv_send_IPI_allbutself, .send_IPI_all = uv_send_IPI_all, - .send_IPI_self = uv_send_IPI_self, + .send_IPI_self = x2apic_send_IPI_self, .wakeup_secondary_cpu = uv_wakeup_secondary, From patchwork Mon Jul 17 23:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1419574vqt; Mon, 17 Jul 2023 17:16:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFJ4ogIoUsHDvumcptLdTl3obbUiAp7qfKV4g7zLMz4aXO0wcuduuuxPAUfoQNhv6Kd9KPn X-Received: by 2002:a05:6512:10d0:b0:4f9:556b:93c2 with SMTP id k16-20020a05651210d000b004f9556b93c2mr10019676lfg.1.1689639374109; Mon, 17 Jul 2023 17:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689639374; cv=none; d=google.com; s=arc-20160816; b=iebjfHmnOy6FoyhWoI32yQc4/Zh2rv8blqRWdWeNMoaJ2KTKi8GTQ11Nx2xaXAI9qe /g6QwQGOBOBrbqAoJEepPUsqToY0h9p/vIHo7c+wUSdGshxJqPtbMNeVA/JhcDdxzCJP FSOlwe+RSnlhdR+lmiC8HytvX6sqP+huzjkLXLlfEb/9olTQJbISGmCYwNS3o1ZBC4Pt wP1gHQuci9dTq//O5IZZlKrAOiM0x5Fz1lGl01s3uv43Dv2zpocym8HwgX4iji30KMBX o+rGB4fNssNQIN+l7dknYKYywtpwS9bSnrIB0H/trtNGXbHOWcDxbelAOQKwhB8/kNka t23A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=s19156BZmBKn/+gIefFlMT9NlvbxtvZTdSeLRnjoukg=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=VixVx8O+q1i464cFL/EejWWFAcBsqYyw2BO0fhYwErkeNnFUTAnuKi+q87yO8U5676 MoT9CPzSZG2Mf0ov74b2AeJbo0wYiDxq0Zy52WF11ktZxXoLPW0T6MrexcphsFOjhifO nkMZ7MhSzilZbrr9FD1Xx1boAoNaDXMmZ3OZ9snmmQGW+SaP28fPlonvTNBjtl2n7dph LVVjpQmcZ3/tmkrvTsS24WSqS3MIB13gD8l3cL0AMEpkTRlts7BKL+t1NV+2ocT2+Evh 82JYgmtm/ivqDw6vSsZFNI9EzCrp0kFF5Ig7DZ2cxm0D/LGJVtl/sCS21XvBzHr0APUj cheA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AWwAwQ1T; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=BgH8Loq6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a05640204c700b0051e1688dd92si341811edw.566.2023.07.17.17.15.45; Mon, 17 Jul 2023 17:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AWwAwQ1T; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=BgH8Loq6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbjGQXdF (ORCPT + 99 others); Mon, 17 Jul 2023 19:33:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbjGQXdC (ORCPT ); Mon, 17 Jul 2023 19:33:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F353170B for ; Mon, 17 Jul 2023 16:32:09 -0700 (PDT) Message-ID: <20230717223225.394633265@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s19156BZmBKn/+gIefFlMT9NlvbxtvZTdSeLRnjoukg=; b=AWwAwQ1TbJlPno3V2qAdO5g6RApmn7VllVPsrl/7OPR6659zM4BKEJfpKFZfw+TxUZxr8N 5KNw4pbJeD8lt5X1aBHqb1168Xxk6sieVUBDc+DIiioSkkqUlXj/Z8wCRFmyJBODduSL9N 5UVyNpTG+YH5kAOCpIB3FGSuoAXW3PWtRwb5fsqJePV+23OeXsS43kReNA9XEU5Vq/GoYk YxXxqyrGsGoyhPJYBRFPiI7w7gP/P0bVfA5dYxqij9B6LhGFF/eOOUBOkKW0I7RVhLsRvt 6DMXYRsr54FdCXrhmgUz2pB7PqHkXRJZgRn+3MpdCr69VZRUICG1yE7+PE+fCQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=s19156BZmBKn/+gIefFlMT9NlvbxtvZTdSeLRnjoukg=; b=BgH8Loq6CGCh7V/YU3PyzfQ/I2OtaC9oE8h4mS+YVzQZWiGu8SJrNesSc+PPSfipdXfBvI NpYRqDGn+YCxsDAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 39/58] x86/apic/64: Uncopypaste probing References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:35 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771715296434060042 X-GMAIL-MSGID: 1771715296434060042 No need for the same thing twice. Also prepares for simplifying the APIC ID validation checks. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/probe_64.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -13,6 +13,15 @@ #include "local.h" +static __init void apic_install_driver(struct apic *driver) +{ + if (apic == driver) + return; + + apic = driver; + pr_info("Switched APIC routing to %s:\n", apic->name); +} + /* Select the appropriate APIC driver */ void __init x86_64_probe_apic(void) { @@ -22,11 +31,7 @@ void __init x86_64_probe_apic(void) for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { if ((*drv)->probe && (*drv)->probe()) { - if (apic != *drv) { - apic = *drv; - pr_info("Switched APIC routing to %s.\n", - apic->name); - } + apic_install_driver(*drv); break; } } @@ -38,11 +43,7 @@ int __init default_acpi_madt_oem_check(c for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { if ((*drv)->acpi_madt_oem_check(oem_id, oem_table_id)) { - if (apic != *drv) { - apic = *drv; - pr_info("Setting APIC routing to %s.\n", - apic->name); - } + apic_install_driver(*drv); return 1; } } From patchwork Mon Jul 17 23:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406905vqt; Mon, 17 Jul 2023 16:39:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlEK4rA9C0lsS15IyZEfVcmPpOz6w57RMW9To7V+90+AeYA4OVUYOK64fjqCrK8wBX+DW4du X-Received: by 2002:a05:6a20:2450:b0:134:fd58:ce41 with SMTP id t16-20020a056a20245000b00134fd58ce41mr1025087pzc.12.1689637180454; Mon, 17 Jul 2023 16:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637180; cv=none; d=google.com; s=arc-20160816; b=iCxOv0o6WcYCUiQ7uMIFpYSPeylO98KKlwrMW1udNljIAOKCw4kKzgwvPtqFRIP/zp W3VcO3Omk8WKVvcQkSz9CSickfrk69dZTslF1PVkNm2QX751lF3LmdUtJc0BAVBeMhI7 m093NAJMIoEw0zB7rOICd23AetOEJbez0MI7LrmI3Hi0SEuIyHKdc7sME3tVODO5/VBv WYrf212ASrJW+NM6thId23Wydxm4i9MIeARSRiI2zbBN1ipe+JfKYB1ieteHm/c5NwCq PoCvixprkogO/1Jm1g7zlf0aCcGsfFJCNsFc+d6hucFhmhjDGe+VOWaDxSjMsjgU3RwP 5Sxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=UJGgSk85bCjHVvLP0ge+jZsQpl98WT3tTk4TUIufIuY=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=Os7wob4p6OUrH0HhxM9Gb2FO1K4bOY2DkgNlNUml0y0NEpqCMm0ykQl7HESC7Bq5R+ cfA2aaNMOIRXnWIfeEclUoOWWTptJJ/TcRQrsu+ok//WcTMCzW1aJcALdVQO8eVB0lYJ DH3GsfP4IE2BjxeuaOlwtdjDQPnixi62MEUAsHSZUzI22/y8sRKmyxQNnsVCFtz6eJNN b9MOffRtkxTIulpXkxlGecbyzszebpRUljWTjZg0ewi66TEhBbeYP9MdR2P8LJq3Icie sX8TNwcjhZX4mWp6e5UtVks/O111GMCoRXuJQjq0kYbmRuvGOEhvqVLSkW54A3nUoKXZ jNhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=34XUGULg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SyyQCuPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a631f4e000000b0052c54de0299si507594pgm.637.2023.07.17.16.39.28; Mon, 17 Jul 2023 16:39:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=34XUGULg; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=SyyQCuPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231605AbjGQXTA (ORCPT + 99 others); Mon, 17 Jul 2023 19:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231612AbjGQXS7 (ORCPT ); Mon, 17 Jul 2023 19:18:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D0F18B for ; Mon, 17 Jul 2023 16:18:14 -0700 (PDT) Message-ID: <20230717223225.455893009@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=UJGgSk85bCjHVvLP0ge+jZsQpl98WT3tTk4TUIufIuY=; b=34XUGULgjMZnaDR0zYz+a2ScDMU1gMClqjqwfOMIqqvFLURLF0fWGBewpUzjQprH5bGEAN gXL25vmys9ZGKNx2svTpmbTkzSFEGUDis1BFJCXF7IWkCbaVp2PDZjcPy601BjPlVxeFjM j3C0yEgbVpHkPnMmPvSIYyFi/6vqwjn+wVNZOZuB143DhiXJ0PPq9lh+U8Xq+uUw/bY6Dg 8TaquW6QI16PSztszaFX1jkN4AffIvzZILM5aiwJTWm0DY6TEh1g6E+ZbHirvbhIooebur H+7a/8guqbYwJig6huGevK/4YUbkeP+e0YAD6O1u0cpm/0JIvTKODZ4EZ3XTJg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=UJGgSk85bCjHVvLP0ge+jZsQpl98WT3tTk4TUIufIuY=; b=SyyQCuPOHu36zMqQjGqNhA/yh5lP9vpGv4aV3nUSXYM45fPGbFQXh1L3CnIdZDdBkG6bNF qMaKe780Iu8e8TDQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 40/58] x86/apic: Wrap APIC ID validation into an inline References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:36 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712996215049969 X-GMAIL-MSGID: 1771712996215049969 Prepare for removing the callback and making this as simple comparison to an upper limit, which is the obvious solution to do for limit checks... Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 5 +++++ arch/x86/kernel/acpi/boot.c | 2 +- arch/x86/kernel/apic/vector.c | 2 +- arch/x86/kernel/smpboot.c | 5 ++--- arch/x86/mm/srat.c | 5 ++--- 5 files changed, 11 insertions(+), 8 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -372,6 +372,11 @@ static inline u32 safe_apic_wait_icr_idl return apic->safe_wait_icr_idle ? apic->safe_wait_icr_idle() : 0; } +static inline bool apic_id_valid(u32 apic_id) +{ + return apic->apic_id_valid(apic_id); +} + extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)); #else /* CONFIG_X86_LOCAL_APIC */ --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -235,7 +235,7 @@ acpi_parse_x2apic(union acpi_subtable_he * to not preallocating memory for all NR_CPUS * when we use CPU hotplug. */ - if (!apic->apic_id_valid(apic_id)) { + if (!apic_id_valid(apic_id)) { if (enabled) pr_warn("x2apic entry ignored\n"); return 0; --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -680,7 +680,7 @@ static int x86_vector_select(struct irq_ * if IRQ remapping is enabled. APIC IDs above 15 bits are * only permitted if IRQ remapping is enabled, so check that. */ - if (apic->apic_id_valid(32768)) + if (apic_id_valid(32768)) return 0; return x86_fwspec_is_ioapic(fwspec) || x86_fwspec_is_hpet(fwspec); --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -1064,9 +1064,8 @@ int native_kick_ap(unsigned int cpu, str pr_debug("++++++++++++++++++++=_---CPU UP %u\n", cpu); - if (apicid == BAD_APICID || - !physid_isset(apicid, phys_cpu_present_map) || - !apic->apic_id_valid(apicid)) { + if (apicid == BAD_APICID || !physid_isset(apicid, phys_cpu_present_map) || + !apic_id_valid(apicid)) { pr_err("%s: bad cpu %d\n", __func__, cpu); return -EINVAL; } --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -40,9 +40,8 @@ acpi_numa_x2apic_affinity_init(struct ac return; pxm = pa->proximity_domain; apic_id = pa->apic_id; - if (!apic->apic_id_valid(apic_id)) { - printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n", - pxm, apic_id); + if (!apic_id_valid(apic_id)) { + pr_info("SRAT: PXM %u -> X2APIC 0x%04x ignored\n", pxm, apic_id); return; } node = acpi_map_pxm_to_node(pxm); From patchwork Mon Jul 17 23:15:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1415039vqt; Mon, 17 Jul 2023 17:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGM8eg9jVjcMoXP8ydQdkMSbeAE3wid+Vcb9f7RZenAsZqWWQkNXchydHMs/ijtiFA+ps4K X-Received: by 2002:a05:6e02:1b87:b0:346:6274:5d70 with SMTP id h7-20020a056e021b8700b0034662745d70mr1246371ili.26.1689638690855; Mon, 17 Jul 2023 17:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689638690; cv=none; d=google.com; s=arc-20160816; b=dJZOcI6Pvn5qVqNLNkADWm/qIGnKvay4lf2J8Js+HOvf1TBhtvbcxdmwxQr/FkceCN kgkEbc7iiP1Eu0yPMg5ApqtE1cgk4Umhn3GwWYhTxq+5pv7+hDT2qxWr2YwPO6HrWTP+ L/5htwszhLGqGWer6K47OC20jnyk+HN5ZERjG1lwHmxbYQsWuR87uOGCHyOzN/a08uoQ cDDs517Jc6wn5BSrJUtahOxbRXnrwnOaktoTqxy14asEqUtTtc4fes5OmdLU4IX81K1l paRl9RjVWZ5mVu9BcGX17rlfh8cMao/jEnjAzL8+8UavimfW3E+HOZw/lD9OX0rjHjZK ORvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=c6/l6FDyGOdgCBOzK6YM6Al7WkOQ1ZlJVvPCzCOr2Oc=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=jscEtS+vEucWeUDhx0n0U+UAtZGMtLEQcrkrPNbHl7HXBUxvUlv6VqWXcjq9NI5cXQ ozec8j8gEDHUp2t2abovjnJAVJ4VIaOx+l8fKChc0wmfgliRHOaaPP+2eYNGLJ0XvbpI SWj1qh41on8GMPSIZgYEbXoVqU2K/Ni63MlIBJ/R/jb95dJisYSNNAdQoVzyIZGSqkHI H+SG8MyVYmIBp4/RHZNlML+PCE5y5Nq2YAlZ4kjvj0dtSg9gIatV4gqcx4KIlur9fW25 u9t4Tfsk9qo4TRUvntdV7+pRwI8VKrb+2gdL2KtLY+PGcPCaH0kGNs4g1EBOGaud+o25 8xzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PwXUrh0e; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a17090a2a0200b00257482b1795si6404654pjd.166.2023.07.17.17.04.37; Mon, 17 Jul 2023 17:04:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=PwXUrh0e; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231652AbjGQXcZ (ORCPT + 99 others); Mon, 17 Jul 2023 19:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjGQXcX (ORCPT ); Mon, 17 Jul 2023 19:32:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF0410FF for ; Mon, 17 Jul 2023 16:31:25 -0700 (PDT) Message-ID: <20230717223225.515238528@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=c6/l6FDyGOdgCBOzK6YM6Al7WkOQ1ZlJVvPCzCOr2Oc=; b=PwXUrh0eXPLIe807EceAtbRNsYdNTOdidk7cstYM+s51wVsQiziUIczLzUU/Q98eRqsIaJ UesYZj7Swn1Ys7MoCvfa8vUB9nmG/B2vZbcL4mgoyCDp44BQ9Ij0vXM4MtJ06uzKZl+W7x 1pwbBnWDsUcdQH9VvGGnUveUnRbP4N8MzZpw2nDIOsWY8reGUbFNrpOVHGgMBxD6k+k4ov fNuuJ8w24gz9MlJ+klSVzfk3yhtYwBN75/GfMcF0dsQgK1lu8gAoZtETno4KwltupV5Akm bH1PGY5a+uTJaNgy/2xhZp+XgQNobf4P/bNBgb6RQxmk7gS49HE4GOS+rhNH/A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=c6/l6FDyGOdgCBOzK6YM6Al7WkOQ1ZlJVvPCzCOr2Oc=; b=tv9bAsob+ud2xRxMgItASl8k6W9hHNoTeFSxcOZqvz/zyhehM2XZdTkA/01XTZEmVUfJOm c434w9zKYSYnBMDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 41/58] x86/apic: Add max_apic_id member References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:38 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771714580150276351 X-GMAIL-MSGID: 1771714580150276351 There is really no point to have a callback which compares numbers. Add a field which allows each APIC to store the maximum APIC ID supported and fill it in for all APIC incarnations. The next step will remove the callback. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 3 +++ arch/x86/kernel/apic/apic_flat_64.c | 2 ++ arch/x86/kernel/apic/apic_noop.c | 1 + arch/x86/kernel/apic/apic_numachip.c | 2 ++ arch/x86/kernel/apic/bigsmp_32.c | 1 + arch/x86/kernel/apic/probe_32.c | 1 + arch/x86/kernel/apic/x2apic_cluster.c | 1 + arch/x86/kernel/apic/x2apic_phys.c | 1 + arch/x86/kernel/apic/x2apic_uv_x.c | 1 + arch/x86/xen/apic.c | 1 + 10 files changed, 14 insertions(+) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -277,6 +277,9 @@ struct apic { u64 (*icr_read)(void); void (*icr_write)(u32 low, u32 high); + /* The limit of the APIC ID space. */ + u32 max_apic_id; + /* Probe, setup and smpboot functions */ int (*probe)(void); int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -94,6 +94,7 @@ static struct apic apic_flat __ro_after_ .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = flat_phys_pkg_id, + .max_apic_id = 0xFE, .get_apic_id = flat_get_apic_id, .set_apic_id = set_apic_id, @@ -170,6 +171,7 @@ static struct apic apic_physflat __ro_af .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = flat_phys_pkg_id, + .max_apic_id = 0xFE, .get_apic_id = flat_get_apic_id, .set_apic_id = set_apic_id, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -80,6 +80,7 @@ struct apic apic_noop __ro_after_init = .phys_pkg_id = noop_phys_pkg_id, + .max_apic_id = 0xFE, .get_apic_id = noop_get_apic_id, .set_apic_id = NULL, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -239,6 +239,7 @@ static const struct apic apic_numachip1 .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, + .max_apic_id = UINT_MAX, .get_apic_id = numachip1_get_apic_id, .set_apic_id = numachip1_set_apic_id, @@ -278,6 +279,7 @@ static const struct apic apic_numachip2 .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, + .max_apic_id = UINT_MAX, .get_apic_id = numachip2_get_apic_id, .set_apic_id = numachip2_set_apic_id, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -91,6 +91,7 @@ static struct apic apic_bigsmp __ro_afte .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = bigsmp_phys_pkg_id, + .max_apic_id = 0xFE, .get_apic_id = bigsmp_get_apic_id, .set_apic_id = NULL, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -47,6 +47,7 @@ static struct apic apic_default __ro_aft .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = default_phys_pkg_id, + .max_apic_id = 0xFE, .get_apic_id = default_get_apic_id, .set_apic_id = NULL, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -239,6 +239,7 @@ static struct apic apic_x2apic_cluster _ .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = x2apic_phys_pkg_id, + .max_apic_id = UINT_MAX, .get_apic_id = x2apic_get_apic_id, .set_apic_id = x2apic_set_apic_id, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -163,6 +163,7 @@ static struct apic apic_x2apic_phys __ro .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = x2apic_phys_pkg_id, + .max_apic_id = UINT_MAX, .get_apic_id = x2apic_get_apic_id, .set_apic_id = x2apic_set_apic_id, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -822,6 +822,7 @@ static struct apic apic_x2apic_uv_x __ro .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = uv_phys_pkg_id, + .max_apic_id = UINT_MAX, .get_apic_id = x2apic_get_apic_id, .set_apic_id = set_apic_id, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -138,6 +138,7 @@ static struct apic xen_pv_apic = { .cpu_present_to_apicid = xen_cpu_present_to_apicid, .phys_pkg_id = xen_phys_pkg_id, /* detect_ht */ + .max_apic_id = UINT_MAX, .get_apic_id = xen_get_apic_id, .set_apic_id = xen_set_apic_id, /* Can be NULL on 32-bit. */ From patchwork Mon Jul 17 23:15:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1426071vqt; Mon, 17 Jul 2023 17:32:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpkS2aF6AsSPE5HlX5yTsx3z+6dw7iOr8M7p85xbds9b6iK4y+Uen8eCqyohPKIxUykMxM X-Received: by 2002:a05:6a20:8e1c:b0:12f:f9af:3a2a with SMTP id y28-20020a056a208e1c00b0012ff9af3a2amr16074599pzj.54.1689640350921; Mon, 17 Jul 2023 17:32:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640350; cv=none; d=google.com; s=arc-20160816; b=gUrT7kGOiQYbUKW2ayTPRvHbY/vFEuV3u0KzaSilLBwIy6zJv8UHsIEK99fDaqnA0Y 8Th99EmOnkQ1ZkCRLkk3F56i8c+B0aqthJ3WjR/P/2m9xvG6BNPoSNXnOnX/adkuMdS3 wCU71YB6oFsETjCYePwqjN0FIFQj7VDE4TH4AjXrDgTGvvEVthdOmf4Xe6cMw7X0MG4J +9znAS7ACur9LLPIwP6QQFSTjizgHTmX5U/rj9bIGUgg4Sf6JsqdcnGBSjs5bM/jXwcK 8l3jJ13OVrgWkkDk7VcXDwJbqH48crG33rnJ0rf0ZE8clame+Jwopep/qK5jlNuSMMs8 SmWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=Q1JNQJEMBxAgDkdW0pLI2m/sGBRaEoryy+htOkBQTrI=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=CULeiCNTDFghuP33easSLugkc22nPj4VtOqpZrXW+tnAsToE2xBY02bY/swKQnmGeB 7HTEz2G7TPD9UMxtoUUTMJw4NNLtBtik1TfNCR6/XPiDrfUlTnURa5qDOcpAW/P5BREC LY6kEcyMHiTSbPmhaVWUEhnXR7mjfsxlJYfVZciAFivdNTbcrDtxqc2eJKSnkOnbE82j QXf34UvsioHvAn3cpV3xexDafP5XokzLjGwsnc+eqi7Tc/T9UvIO6UHuuKQrSxRi1wsP BM60AkZpXjqxgMq42SVime+h+7g3jztoXdsKkSasbhMU71J1p7wX73H5TtetYPSgfZy2 TptA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XVTtGjs7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cq8-20020a056a00330800b00666e42caa20si605492pfb.203.2023.07.17.17.32.18; Mon, 17 Jul 2023 17:32:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XVTtGjs7; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbjGQXkZ (ORCPT + 99 others); Mon, 17 Jul 2023 19:40:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjGQXkX (ORCPT ); Mon, 17 Jul 2023 19:40:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3A71BC8 for ; Mon, 17 Jul 2023 16:40:02 -0700 (PDT) Message-ID: <20230717223225.574767249@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Q1JNQJEMBxAgDkdW0pLI2m/sGBRaEoryy+htOkBQTrI=; b=XVTtGjs7K8KwXqAXQvamTB5j0FI8ZG0Etn3P0nAYb44RxqjvhlSp/ZMS0bTDhd47zD421T KNyKLFg4ir8BlPTfLrXqqVk2afMM57cZg4BVBNQ2m7ARbx4+Li0B3zFwQHqmBDIpzLCZEk eWS64EuDFrq0TnFan+G9UnQ31oTgdewrokNT4L0FUVteWoPDDIuNG9Ttv/XBiO68fEPZmM w95GoK1ph9rrJH7FmgkY9Tn5BQ6qtkgmJhr4ykrP99iENkaYkw0LW9YZ0m+M/a6fyEft+C V7xpiILcDTYOsS/19vI1LjzzCDfsEj/JtuOV8m1pWdkWZjl7Hfkik4V0lMy93Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635740; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=Q1JNQJEMBxAgDkdW0pLI2m/sGBRaEoryy+htOkBQTrI=; b=XU+BJFq/bYmMMjorgjZW5KwpaePkOpCDNCYgLXktF/uhc13HDW746lbXxGqxGnZ9sSSM/M UmZoOTTbC187LCCg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 42/58] x86/apic: Simplify X2APIC ID validation References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:40 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716320516384574 X-GMAIL-MSGID: 1771716320516384574 No point in doing the zero equals unlimited check and if not zero compare against the real number. Unlimited is UINT_MAX. So initialize the variable with UINT_MAX and compare less than or equal. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/x2apic_phys.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -8,7 +8,7 @@ int x2apic_phys; static struct apic apic_x2apic_phys; -static u32 x2apic_max_apicid __ro_after_init; +static u32 x2apic_max_apicid __ro_after_init = UINT_MAX; void __init x2apic_set_max_apicid(u32 apicid) { @@ -125,10 +125,7 @@ static int x2apic_phys_probe(void) /* Common x2apic functions, also used by x2apic_cluster */ int x2apic_apic_id_valid(u32 apicid) { - if (x2apic_max_apicid && apicid > x2apic_max_apicid) - return 0; - - return 1; + return apicid <= x2apic_max_apicid; } unsigned int x2apic_get_apic_id(unsigned long id) From patchwork Mon Jul 17 23:15:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121692 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1411070vqt; Mon, 17 Jul 2023 16:54:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6uq7l5tMbwWJS/fkclEUFLOIXTE+XHVWLiXcr9BL7JvhEnsmv5+rPxHadWjqKEuDlE/3m X-Received: by 2002:a17:907:6da2:b0:991:b292:695 with SMTP id sb34-20020a1709076da200b00991b2920695mr13370333ejc.55.1689638051920; Mon, 17 Jul 2023 16:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689638051; cv=none; d=google.com; s=arc-20160816; b=hiwXcsNcqfpLl77UHVlWS6dGeNsej0RdOfwycYL78zPc1VKHyU8B2z1OsEvdT71eX3 hL9lFZ3f3pnjQIx19adpTDVX91Pf+tR4truFO2OBeXuRuhvvuRQ3OXFIxE0b2Q9hJ+SB x6oRLjgPj0S9zVzRDbi8UDEY8oWjD+iZkuei9V6llyCCHmAajBc0jmldAAPhABf2X8lj ZATLi9AHjBxrO3UqMJOLXsZZJNu5EHHCm6uQ1dtSx2kp1g14IjNmOxKkAIw5rvEVH/UJ rxe3eSF1x1IbNn5XtAgxmBMFGk8w+WxGqPfoTd5rDRAj9GxKqM+SSC6Evb9lh9tMhbtA OVZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=zCuopdE3RQFCHCsf4zrOItotVQ+TGysIbFJ/I2GYtw8=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=DPwTHBdGVDvh1m2q0v7M33hXaYUtpmHwElKZx7SSh931Je1z2/PWMvMQIaykqpBPKe PGUMy53zM73nrfZmUYc3eIfyIxdQMs92Y9hYqz0ZlHwtQep+V9aGftc4was+2Qh+M9WE 0IbRC3JefDwh/mSFutxK294o9m2FwSuG5JPZUmf2HIo74FdgOw6ff2j8Img8HrsP4Be1 OQyO8uuFjd27v56eXU9GtANwDWoOvXmiEEEOnjKYUeLvznOqm1M2OPEnb/q0TDpImEcw u7Y/kA+shtZX58Oz9/vE11qeXvqyRNFno4x7oO7GrFUrkxOQRzQBQdWqgS61LyZM4Qnt 0ZkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dppNph2l; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv21-20020a170906b1d500b0099290e2c162si293017ejb.444.2023.07.17.16.53.48; Mon, 17 Jul 2023 16:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dppNph2l; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231621AbjGQXYq (ORCPT + 99 others); Mon, 17 Jul 2023 19:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230183AbjGQXYp (ORCPT ); Mon, 17 Jul 2023 19:24:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83227173D for ; Mon, 17 Jul 2023 16:24:07 -0700 (PDT) Message-ID: <20230717223225.634205045@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=zCuopdE3RQFCHCsf4zrOItotVQ+TGysIbFJ/I2GYtw8=; b=dppNph2lvl/AOCMRGkW5+6iP+zBV6T6fhualr5yM3nTvvGsVHRkvAczwnO5iChrUEZTBLr MPzxLG322AeGzqsLHIL4lC77BEWkGJt0evtw7wNvM39/0e9r3ULKKR7Zit9hFaUE1uj8Ys D//L5k0w6q8X4zMFjlVdWr8AhneziF8A2VOYgW6vRHH6H3uV6JQDO+1p9kX8jabWS+JGdG Q+Sn/dd8s8F4QKFSAZHe7Kf9G4wCTmahDZtMHlQM78GGnRnHIRHj0cfVyEOUlH8kF4WfKi YGMkvlg7YcxM9HqhFrXUKnyQZoItU3nMPjRw+jS2TME8KfxqdewJMzSu+ngFNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635742; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=zCuopdE3RQFCHCsf4zrOItotVQ+TGysIbFJ/I2GYtw8=; b=X3TZmsQ1KOmKrkLjA6RX6lbC27nGCSpGt7+z4PlXHaB7WPz4d7khssHbEuHP3Mrf/F6XmQ gx147IAen5VtsuDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 43/58] x86/apic: Prepare x2APIC for using apic::max_apic_id References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:41 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713910206738589 X-GMAIL-MSGID: 1771713910206738589 In order to remove the apic::apic_id_valid() callback and switch to checking apic::max_apic_id, it is required to update apic::max_apic_id when the APIC initialization code overrides it via x2apic_set_max_apicid(). Make the existing booleans a bitfield and add a flag which lets the update function and the core code which switches the driver detect whether the apic instance wants to have that update or not and apply it if required. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 7 ++++--- arch/x86/kernel/apic/local.h | 1 + arch/x86/kernel/apic/probe_64.c | 4 ++++ arch/x86/kernel/apic/x2apic_cluster.c | 1 + arch/x86/kernel/apic/x2apic_phys.c | 5 ++++- 5 files changed, 14 insertions(+), 4 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -266,10 +266,11 @@ struct apic { void (*send_IPI_all)(int vector); void (*send_IPI_self)(int vector); - u32 disable_esr; - enum apic_delivery_modes delivery_mode; - bool dest_mode_logical; + + u32 disable_esr : 1, + dest_mode_logical : 1, + x2apic_set_max_apicid : 1; u32 (*calc_dest_apicid)(unsigned int cpu); --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -23,6 +23,7 @@ int x2apic_phys_pkg_id(int initial_apici void x2apic_send_IPI_all(int vector); void x2apic_send_IPI_allbutself(int vector); void x2apic_send_IPI_self(int vector); +extern u32 x2apic_max_apicid; /* IPI */ --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -19,6 +19,10 @@ static __init void apic_install_driver(s return; apic = driver; + + if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid) + apic->max_apic_id = x2apic_max_apicid; + pr_info("Switched APIC routing to %s:\n", apic->name); } --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -240,6 +240,7 @@ static struct apic apic_x2apic_cluster _ .phys_pkg_id = x2apic_phys_pkg_id, .max_apic_id = UINT_MAX, + .x2apic_set_max_apicid = true, .get_apic_id = x2apic_get_apic_id, .set_apic_id = x2apic_set_apic_id, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -8,11 +8,13 @@ int x2apic_phys; static struct apic apic_x2apic_phys; -static u32 x2apic_max_apicid __ro_after_init = UINT_MAX; +u32 x2apic_max_apicid __ro_after_init = UINT_MAX; void __init x2apic_set_max_apicid(u32 apicid) { x2apic_max_apicid = apicid; + if (apic->x2apic_set_max_apicid) + apic->max_apic_id = apicid; } static int __init set_x2apic_phys_mode(char *arg) @@ -161,6 +163,7 @@ static struct apic apic_x2apic_phys __ro .phys_pkg_id = x2apic_phys_pkg_id, .max_apic_id = UINT_MAX, + .x2apic_set_max_apicid = true, .get_apic_id = x2apic_get_apic_id, .set_apic_id = x2apic_set_apic_id, From patchwork Mon Jul 17 23:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121679 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406961vqt; Mon, 17 Jul 2023 16:39:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGAqnyIjH1+dxmqYnrdSmTBlqpo8TY4m1jaWrPETDPZUSk8Uv8SUAHTfG/SWievXJZsTbg X-Received: by 2002:a05:6870:3284:b0:1b3:e04e:b5c7 with SMTP id q4-20020a056870328400b001b3e04eb5c7mr14234270oac.42.1689637189517; Mon, 17 Jul 2023 16:39:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637189; cv=none; d=google.com; s=arc-20160816; b=AVze8HdG8nWN5+xVD4jhL19RIwgpGU3p3gHSOom4CrpMXE91U9zzNUOvKhUe0f4tPh TZfMvK286li7T+aVMpCNEZ5ysNjM6i24GAp13RRNMvFd+xGNw7X7VPY2hXYja3ANffjW 7oTmB9AE4STm6UpCsSsHvypztGPj8GQvCiJgDQvjGME45rSNzPSvrsMmjzx1mmCoVVZi U+pwP4dnGRfS5rNEfRj5F22YejTJfmaOr3O5H8XQxPg914R3ZYqPsgOpp4VHiJypH0Qb z4ymMs8a+5ZSRKlB6ttYNru0Ar2+E6Iq93o9m1jPtpN7gH1bYC3YN7OL4brt4c6fl4m9 /DAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=t8GuwcLuogoZNuL5wE48WjFzNkePRlo9xZ30OfxA9Cs=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=yIP5F54I5mJq2lv3v4ewbuXsISf21io24HhO8h5h8EDlO4JqinuSWuNcQrV+msdLUE 5cGcRXX7+JHRAbxJJGPZU/6Wc+i37g5mLUX3F6IqG0gdSilz3ey8Qxbs5/2wq0kRw2F/ LX4tatZPUZZkvsS3v3fNIStXf4q8a47iRCOmDJSRp90by0ZKuv+GFdeiQiH+y3QofgOV 06eeihL8AUF9C6tsKRXzofiNWiZnYpX+X/06K1legEwF/GFbACd0iTmW+e3ZHFkBNt3y FNrMAopXiGr+K4U0XN/YZJs54/0VP08RUfypBNUDfIDVfpGWWHaSCh6MxOSZ/5qRgdw7 wCnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p4BdxmwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=76UV29N2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a634543000000b0054ff53233f2si526651pgk.567.2023.07.17.16.39.36; Mon, 17 Jul 2023 16:39:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=p4BdxmwW; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=76UV29N2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbjGQXYR (ORCPT + 99 others); Mon, 17 Jul 2023 19:24:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231598AbjGQXYL (ORCPT ); Mon, 17 Jul 2023 19:24:11 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26301720 for ; Mon, 17 Jul 2023 16:23:32 -0700 (PDT) Message-ID: <20230717223225.693825302@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=t8GuwcLuogoZNuL5wE48WjFzNkePRlo9xZ30OfxA9Cs=; b=p4BdxmwWCPi2A3Pw0DS1RX+tNbD/uCdVagrVujPn1FIlHv0GvEsyrCDy2wlEJ0OtEYqzGN U4j8Axj5PNVd4W417SV48j5cdGjN1t40ZGM+R4YhRY4qDc7No4BDqDCb26zDCcyAAmcwzS GHRxaiXe30xFkfyxSmUwuhduZLomeBBdEZozA7K+Ic9X7aHlaL1w/HMh0rz8pZCnLuN8Hu emTJk8cbBDq4gOQAknZ4NJEmavyhcf/NjnDW1fl2608/DVoVI/kijdlp2ffUivn6cNpPnA wRzqVkv/BARwKCnzTL/MAkGHLDgIZDI21iHROQI5CW2kkyixfUGlC2RFuL979g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=t8GuwcLuogoZNuL5wE48WjFzNkePRlo9xZ30OfxA9Cs=; b=76UV29N2lyvyADzADbg1lMUztNYFYETn9m38rmPNnUuJamiuLY/3/bRI/4t5bVxRGZs7T5 SJ7RqMwEawSBwUDg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 44/58] x86/apic: Sanitize APID ID range validation References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:43 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713005220964985 X-GMAIL-MSGID: 1771713005220964985 Now that everything has apic::max_apic_id set and the eventual update for the x2APIC case is in place, switch the apic_id_valid() helper to use apic::max_apic_id and remove the apic::apic_id_valid() callback. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 3 +-- arch/x86/kernel/apic/apic_common.c | 5 ----- arch/x86/kernel/apic/apic_flat_64.c | 2 -- arch/x86/kernel/apic/apic_noop.c | 2 -- arch/x86/kernel/apic/apic_numachip.c | 8 -------- arch/x86/kernel/apic/bigsmp_32.c | 1 - arch/x86/kernel/apic/local.h | 1 - arch/x86/kernel/apic/probe_32.c | 1 - arch/x86/kernel/apic/x2apic_cluster.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 7 ------- arch/x86/kernel/apic/x2apic_uv_x.c | 6 ------ arch/x86/xen/apic.c | 6 ------ 12 files changed, 1 insertion(+), 42 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -284,7 +284,6 @@ struct apic { /* Probe, setup and smpboot functions */ int (*probe)(void); int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id); - int (*apic_id_valid)(u32 apicid); bool (*apic_id_registered)(void); bool (*check_apicid_used)(physid_mask_t *map, int apicid); @@ -378,7 +377,7 @@ static inline u32 safe_apic_wait_icr_idl static inline bool apic_id_valid(u32 apic_id) { - return apic->apic_id_valid(apic_id); + return apic_id <= apic->max_apic_id; } extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)); --- a/arch/x86/kernel/apic/apic_common.c +++ b/arch/x86/kernel/apic/apic_common.c @@ -37,11 +37,6 @@ int default_cpu_present_to_apicid(int mp } EXPORT_SYMBOL_GPL(default_cpu_present_to_apicid); -int default_apic_id_valid(u32 apicid) -{ - return (apicid < 255); -} - bool default_apic_id_registered(void) { return physid_isset(read_apic_id(), phys_cpu_present_map); --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -80,7 +80,6 @@ static struct apic apic_flat __ro_after_ .name = "flat", .probe = flat_probe, .acpi_madt_oem_check = flat_acpi_madt_oem_check, - .apic_id_valid = default_apic_id_valid, .apic_id_registered = default_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, @@ -158,7 +157,6 @@ static struct apic apic_physflat __ro_af .name = "physical flat", .probe = physflat_probe, .acpi_madt_oem_check = physflat_acpi_madt_oem_check, - .apic_id_valid = default_apic_id_valid, .apic_id_registered = default_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -67,8 +67,6 @@ struct apic apic_noop __ro_after_init = .probe = noop_probe, .acpi_madt_oem_check = NULL, - .apic_id_valid = default_apic_id_valid, - .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -56,12 +56,6 @@ static u32 numachip2_set_apic_id(unsigne return id << 24; } -static int numachip_apic_id_valid(u32 apicid) -{ - /* Trust what bootloader passes in MADT */ - return 1; -} - static int numachip_phys_pkg_id(int initial_apic_id, int index_msb) { return initial_apic_id >> index_msb; @@ -227,7 +221,6 @@ static const struct apic apic_numachip1 .name = "NumaConnect system", .probe = numachip1_probe, .acpi_madt_oem_check = numachip1_acpi_madt_oem_check, - .apic_id_valid = numachip_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, @@ -267,7 +260,6 @@ static const struct apic apic_numachip2 .name = "NumaConnect2 system", .probe = numachip2_probe, .acpi_madt_oem_check = numachip2_acpi_madt_oem_check, - .apic_id_valid = numachip_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -79,7 +79,6 @@ static struct apic apic_bigsmp __ro_afte .name = "bigsmp", .probe = probe_bigsmp, - .apic_id_valid = default_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/local.h +++ b/arch/x86/kernel/apic/local.h @@ -14,7 +14,6 @@ #include /* X2APIC */ -int x2apic_apic_id_valid(u32 apicid); void __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest); unsigned int x2apic_get_apic_id(unsigned long id); u32 x2apic_set_apic_id(unsigned int id); --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -33,7 +33,6 @@ static struct apic apic_default __ro_aft .name = "default", .probe = probe_default, - .apic_id_valid = default_apic_id_valid, .apic_id_registered = default_apic_id_registered, .delivery_mode = APIC_DELIVERY_MODE_FIXED, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -226,7 +226,6 @@ static struct apic apic_x2apic_cluster _ .name = "cluster x2apic", .probe = x2apic_cluster_probe, .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, - .apic_id_valid = x2apic_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -124,12 +124,6 @@ static int x2apic_phys_probe(void) return apic == &apic_x2apic_phys; } -/* Common x2apic functions, also used by x2apic_cluster */ -int x2apic_apic_id_valid(u32 apicid) -{ - return apicid <= x2apic_max_apicid; -} - unsigned int x2apic_get_apic_id(unsigned long id) { return id; @@ -150,7 +144,6 @@ static struct apic apic_x2apic_phys __ro .name = "physical x2apic", .probe = x2apic_phys_probe, .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, - .apic_id_valid = x2apic_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -780,11 +780,6 @@ static void uv_send_IPI_all(int vector) uv_send_IPI_mask(cpu_online_mask, vector); } -static int uv_apic_id_valid(u32 apicid) -{ - return 1; -} - static u32 set_apic_id(unsigned int id) { return id; @@ -810,7 +805,6 @@ static struct apic apic_x2apic_uv_x __ro .name = "UV large system", .probe = uv_probe, .acpi_madt_oem_check = uv_acpi_madt_oem_check, - .apic_id_valid = uv_apic_id_valid, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = false, --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -105,11 +105,6 @@ static int xen_madt_oem_check(char *oem_ return xen_pv_domain(); } -static int xen_id_always_valid(u32 apicid) -{ - return 1; -} - static int xen_phys_pkg_id(int initial_apic_id, int index_msb) { return initial_apic_id >> index_msb; @@ -127,7 +122,6 @@ static struct apic xen_pv_apic = { .name = "Xen PV", .probe = xen_apic_probe_pv, .acpi_madt_oem_check = xen_madt_oem_check, - .apic_id_valid = xen_id_always_valid, /* .delivery_mode and .dest_mode_logical not used by XENPV */ From patchwork Mon Jul 17 23:15:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1428106vqt; Mon, 17 Jul 2023 17:37:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlGh32hvNnOiu6LZztbXPTIpAe0BofrdvCaJbAU4Bmi/JVkZr1HNqVCmcd69hVhelXxZ/3+Y X-Received: by 2002:a67:f991:0:b0:445:872:67ea with SMTP id b17-20020a67f991000000b00445087267eamr733984vsq.34.1689640677402; Mon, 17 Jul 2023 17:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640677; cv=none; d=google.com; s=arc-20160816; b=NgCrRgw9s9w4A0vsN5pkrFVNQV8gA49a9sC5Ap7fig5s60NYhdn+6slk/D39VqAsZE 2Bi3NWo/YSTx94pz6uvNY3uoR3ya1fjR9OyJdqacfk+QUBe5rm45sI6PenGCDv80d4nH v851KawwPd7qnZqMvYijRhT9S15uFfAXWiN02cW+r30/BjnePeD5/eOx5HBLAFz5FPMW tV06duLJOuCal73xaoIxLpBqAJ/7WNCsAUBb0JhanMOwWqYop3iSqGlGUUdkG72/HFO5 dcimkBXDlWIE3xjvu4F2qq0N+3ZsRbZ8wdbIJbRpeU0mZRzi5JNJIxRedtS98bJaj+iZ 39XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=AWaEZw8abvCPdN4y6ge3RbIG2SvdzHbMvIezw0K7Xt4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=qwM1X8B5R8ebyM6FO3G5VbDZ5pvq/vNpfDvDaVBmYKdbYYS0aH+8/DRmXJ7PfdRiwD AbwWWs/RsTz4g60SpWmIm1nsoh72f0jiRQlpiOlj1omI6DXEyxxo4HdArSYaF7q38P7M UxaUx/O3jo3HoJy+V+N57/47x/Xtq5CnaOdqD0Sl/IkGjZmgU3RZWlPowmVSue4v3PE7 +HKwnero7bBFo6lQVpeOnF6+NhUAT7uVjscSxNhq9e4k8if8ZDqwRA7NYQrbbVgMC8ty /Hh/PaEaQm8bfENciMtuPZR0GRCpLwfO2zufc7YnnX73pcD81xmyVkPE6qAk0G4O4Bgi 9T8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xGjM4LiV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mj19-20020a17090b369300b002634977e6e5si6493412pjb.142.2023.07.17.17.37.44; Mon, 17 Jul 2023 17:37:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=xGjM4LiV; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbjGQXnN (ORCPT + 99 others); Mon, 17 Jul 2023 19:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbjGQXk6 (ORCPT ); Mon, 17 Jul 2023 19:40:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78568170A for ; Mon, 17 Jul 2023 16:40:35 -0700 (PDT) Message-ID: <20230717223225.754957545@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=AWaEZw8abvCPdN4y6ge3RbIG2SvdzHbMvIezw0K7Xt4=; b=xGjM4LiVIbDvVJpkJPrQjEaRdgsQZ5akQT26sx1478B5xJtClRWnFpiaKg73W7rzbSZpmu 9cb7VLiK5CNVLJ5SHYsYbijnVeRnYRWCVGZPuPNVABGDN6I316EFSYjcFOKx6ciTTNfR3n a4fJw5/BrbUnbDa1uZqrO3gk2aue9kBShZmUFi4KcEScPYmBEcz39LIzG4h+18Tmw0J+AV plvIkhV8AXnsb6I7C/fh75Q1t84rIyI0vtbIOhwrFOs82rOUbvUDPvhEHNC/Ngmc8B3SqC A8zsj2dI2QBlNMn4UuoXUR4vFt2nDiZeJj3AIF9IOED0DEFurHtRBNJcH2cCEw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635745; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=AWaEZw8abvCPdN4y6ge3RbIG2SvdzHbMvIezw0K7Xt4=; b=h2M38jF60O41a5q3PzJBQp7a2b8q3FvZ1CwUp7sKuTEdAmME2dg2o+DJ2A9C7h8M3Z6mqd JhNoR9No5x4mSIAQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 45/58] x86/apic: Remove pointless NULL initializations References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:44 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716662772710224 X-GMAIL-MSGID: 1771716662772710224 Wasted space for no value. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic_flat_64.c | 2 -- arch/x86/kernel/apic/apic_noop.c | 2 -- arch/x86/kernel/apic/apic_numachip.c | 4 ---- arch/x86/kernel/apic/probe_32.c | 1 - arch/x86/kernel/apic/x2apic_phys.c | 2 -- arch/x86/kernel/apic/x2apic_uv_x.c | 2 -- 6 files changed, 13 deletions(-) --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -87,9 +87,7 @@ static struct apic apic_flat __ro_after_ .disable_esr = 0, - .check_apicid_used = NULL, .init_apic_ldr = default_init_apic_ldr, - .ioapic_phys_id_map = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = flat_phys_pkg_id, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -65,7 +65,6 @@ static void noop_apic_write(u32 reg, u32 struct apic apic_noop __ro_after_init = { .name = "noop", .probe = noop_probe, - .acpi_madt_oem_check = NULL, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, @@ -80,7 +79,6 @@ struct apic apic_noop __ro_after_init = .max_apic_id = 0xFE, .get_apic_id = noop_get_apic_id, - .set_apic_id = NULL, .calc_dest_apicid = apic_flat_calc_apicid, --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -227,8 +227,6 @@ static const struct apic apic_numachip1 .disable_esr = 0, - .check_apicid_used = NULL, - .ioapic_phys_id_map = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, @@ -266,8 +264,6 @@ static const struct apic apic_numachip2 .disable_esr = 0, - .check_apicid_used = NULL, - .ioapic_phys_id_map = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = numachip_phys_pkg_id, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -48,7 +48,6 @@ static struct apic apic_default __ro_aft .max_apic_id = 0xFE, .get_apic_id = default_get_apic_id, - .set_apic_id = NULL, .calc_dest_apicid = apic_flat_calc_apicid, --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -150,8 +150,6 @@ static struct apic apic_x2apic_phys __ro .disable_esr = 0, - .check_apicid_used = NULL, - .ioapic_phys_id_map = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = x2apic_phys_pkg_id, --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -811,8 +811,6 @@ static struct apic apic_x2apic_uv_x __ro .disable_esr = 0, - .check_apicid_used = NULL, - .ioapic_phys_id_map = NULL, .cpu_present_to_apicid = default_cpu_present_to_apicid, .phys_pkg_id = uv_phys_pkg_id, From patchwork Mon Jul 17 23:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121689 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1409041vqt; Mon, 17 Jul 2023 16:47:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGsri+wt2/ORJ4R2zRWBsRPuOMAuaf6HBsAhoam6vrN72Lc8RT2poF63XLOcVSHwBLSIrU9 X-Received: by 2002:a17:903:44c:b0:1b8:abe7:5a80 with SMTP id iw12-20020a170903044c00b001b8abe75a80mr13236688plb.40.1689637628077; Mon, 17 Jul 2023 16:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637628; cv=none; d=google.com; s=arc-20160816; b=tgBLnzqdWovgNeLOAwooe/n5V7qwkxX2neLu8nMHJuzqkb7VdLJqrRrlC8ejZOZ8rF G17T/QP/E/7Gm/N2V3JB0vGdJbwjC/eIAeud+mANCss6VZNguJj6NM0CUgNdwhNMAaPJ VLex6fD245egKxKuvpSBtJo3VFzAEKLkmOI882orsnekv2Yv5n92dTyzu+IlOnbpoPvC Z21JxAMvDrlmgTv3o0kye9sHw5GKcJ1WbDkUtfmcth6qG3rz025gw3p/wD5rEsorM2Rg PAv9T6xv+q5cQl9TXB+iA2HfKPLiO8D6A6yZ8/5PtaDT58Br1kO+HQPgfmA2IL/dY14K Asrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=tK1J3NRXP+lZRakGxXxjlSskh2I2ErwFZpn4/I2Qug8=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=HoejzCjgHwdy+B6TQW71urTqITP0kvg6AfLHVSHhTKAYuWwcWKkVvK8898rpk7LnvT 2g0dDGGGlSSlWcs7Ss7oldbzB7OBxLtbESrfulSYp4Gt6ey5brGeA2Vu/jJlFfS7lhy/ 9kq21wJOa9lOl78Qguh+JZ20+EA3+uMk+2vJgD7zyDJDxk2DOqSte8W2BE5WkQ1ZgWjc BQQC0WpifqCy3tVp69bwlz/455P9dNykJ09tpBGeTl+ccKqXT7XHQlCEvFd6xIwxFw+h 710qqsqSSCzYYkUlmS5Jf+ulXjGFT5piZBEaA8SWmPUOPb1f00q3j4dsck36LNeqRqv/ afLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="z+8xD/Fi"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qQ7Hm4Rc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kh14-20020a170903064e00b001b554cf3a43si590526plb.163.2023.07.17.16.46.55; Mon, 17 Jul 2023 16:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="z+8xD/Fi"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=qQ7Hm4Rc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231676AbjGQXcf (ORCPT + 99 others); Mon, 17 Jul 2023 19:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231649AbjGQXcZ (ORCPT ); Mon, 17 Jul 2023 19:32:25 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C035C173A for ; Mon, 17 Jul 2023 16:31:27 -0700 (PDT) Message-ID: <20230717223225.815511531@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tK1J3NRXP+lZRakGxXxjlSskh2I2ErwFZpn4/I2Qug8=; b=z+8xD/FiHJ9sr/IZ44QFKo65qGiyCig5Yc9pVVKeRxKO5Om5Susr9bNe7gA/wQoR+WSXo1 sIkwkb2ciVPCECWtrGSkoKg4j15iGKWvESRI0sf1I79+p8I/tHGy9OQHO38rLLhgvwFqhP qhPpCBWARB3+wFKelnZ8IVeRQwPYPsrEQpzBpAe985A5er13fJ0f8z/0eiWtYif/HYaCkm yqw+iMUa0PzuwnqtoBEHqlbPlE1YyGjPKvb5RUdDGt9gT/9TXVKR+GzZCGULxJsSlY62Ri MSgWRww7o0hy7eJd4Xi5Mz76uYfVNtZ6gh6r0FnH2NkPmGG7wftxpgNfDce+4A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=tK1J3NRXP+lZRakGxXxjlSskh2I2ErwFZpn4/I2Qug8=; b=qQ7Hm4RcJivTCfhDxjNKiu6l+PxZgwY9s/INSRHRjcQSHhxJnOCdVav5b4/dGHJIE4wQhO w4PkOGEA+hvCNEAg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 46/58] x86/apic/noop: Tidy up the code References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:46 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713465598470432 X-GMAIL-MSGID: 1771713465598470432 First of all apic_noop can't be probed because it's not registered. So there is no point for implementing a probe callback. The machine is rightfully to die when that is invoked. Remove the gunk and tidy up the other space consuming dummy callbacks. This gunk should simply die. Nothing should ever invoke APIC callbacks once this is installed, But that's a differrent story for another round of cleanups. The comment on top of this file which was intentionally left in place tells exactly why this is needed: voodoo programming. In fact the kernel of today should just outright refuse to boot on a system with no (functional) local APIC. That would spare tons of #ifdeffery and other nonsense. Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/apic_noop.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -8,6 +8,10 @@ * Though in case if apic is disabled (for some reason) we try * to not uglify the caller's code and allow to call (some) apic routines * like self-ipi, etc... + * + * FIXME: Remove this gunk. The above argument which was intentionally left + * in place is silly to begin with because none of the callbacks except for + * APIC::read/write() have a WARN_ON_ONCE() in them. Sigh... */ #include #include @@ -21,35 +25,10 @@ static void noop_send_IPI_allbutself(int static void noop_send_IPI_all(int vector) { } static void noop_send_IPI_self(int vector) { } static void noop_apic_icr_write(u32 low, u32 id) { } - -static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) -{ - return -1; -} - -static u64 noop_apic_icr_read(void) -{ - return 0; -} - -static int noop_phys_pkg_id(int cpuid_apic, int index_msb) -{ - return 0; -} - -static unsigned int noop_get_apic_id(unsigned long x) -{ - return 0; -} - -static int noop_probe(void) -{ - /* - * NOOP apic should not ever be - * enabled via probe routine - */ - return 0; -} +static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) { return -1; } +static u64 noop_apic_icr_read(void) { return 0; } +static int noop_phys_pkg_id(int cpuid_apic, int index_msb) { return 0; } +static unsigned int noop_get_apic_id(unsigned long x) { return 0; } static u32 noop_apic_read(u32 reg) { @@ -64,7 +43,6 @@ static void noop_apic_write(u32 reg, u32 struct apic apic_noop __ro_after_init = { .name = "noop", - .probe = noop_probe, .delivery_mode = APIC_DELIVERY_MODE_FIXED, .dest_mode_logical = true, From patchwork Mon Jul 17 23:15:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121690 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1409638vqt; Mon, 17 Jul 2023 16:48:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGBs/rWTi5/TCNgm6gfdUulkJMXWOZAVIk7auH+CfvlDHzs1fumuVEi2QkYGkfPmoBao7j X-Received: by 2002:a05:6358:723:b0:131:94f:b4ff with SMTP id e35-20020a056358072300b00131094fb4ffmr10608811rwj.5.1689637734546; Mon, 17 Jul 2023 16:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637734; cv=none; d=google.com; s=arc-20160816; b=KjElCT6GEmrk6D6OKMhRrVzx8bB5D5EXNf95fcMoqgyyvlz1QG5zZR+KbMeu4ehSC5 xDUCwf4Xw2lqGOr14YF3Qjcrb40sqeTiFHCgyqCMVeVTU5m0vnI/pdXkF6rdBM4KqgIW 4Ovw7nrmXDyTlId46o/hyMOgCNUuML7D3K6dX7bLQDH3PBOjyGZSK4OxkzwlX7dPIpsE d8wQDEXxRuzYm2ykf2+Xe1yF5emy7YBfnmt31SbwXCB8ZHvDU2aQFMmaiVNlx5xdadc3 fn0WmxReabvYoY2ZhI9I5reJ0MH19NhJjwkbAIJt002JcCBF/XGEbTSFUwGc2Tra45b/ KlpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=wxrnNYixn5b66YHMby8R35XHg/cZJKLdob6j5LDKR34=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=z70q9wA5UXiJE1JW/V1Wh5DS5wAtCAW9fRVhZ+1uySakoPeV2kICJrs5ZAqbiO8dwV kEjQJ0lgT4PSfqvgq/yi5woMYvlHW4mSVfRCEc/KtafxxpsiayZvhTECO3YE809utC6v HfDIz69JvoZJi5oGX12tzcne7Zi0zlXUyH0ezESgKgHgl4UmR+ROAdxIdxHhOYApMuqm JsdcQoxwQsRBQOvx2GDNhM8tkPk2HCEf80WFUwbO+OQVe88hsQmyiJMl/QTt2u1NeMoi ZcBQvT5WY0y7y5jGamSoPDo6ZLima9DaPkKNcxualaJzttuer7Ki4WqQlO1MMxVihdY4 eaHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4jbF+loA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a655507000000b0053f228ce43csi585762pgr.547.2023.07.17.16.48.41; Mon, 17 Jul 2023 16:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=4jbF+loA; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbjGQXYd (ORCPT + 99 others); Mon, 17 Jul 2023 19:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbjGQXYc (ORCPT ); Mon, 17 Jul 2023 19:24:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CB4172B for ; Mon, 17 Jul 2023 16:23:54 -0700 (PDT) Message-ID: <20230717223225.875917164@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wxrnNYixn5b66YHMby8R35XHg/cZJKLdob6j5LDKR34=; b=4jbF+loA5MmNcX9xrW2VA1TqlniFCgWOjn2VSmIeFyJROwzIs1VWh7L2OrDZSOKZoTN36a uNU6jSv/ImBp30vC1bCOGXVzjmDpT4D78z9AWgfC5ZJbwIQ3klyiYWmu3tDqO61GdIvo/3 z/MhUoMHIyw1izg+1731m01BxU7wnEw9GKNEh+BP2fPbtJOJVX6RdrSjxyMefwkuufEEws 2x658UcEL/C+zSeBQs1GJJOzKWxTwydOHbjeEaKKAcj9SzngK2tusRhLWx1jYRlNOPL9vb MDtiUYIEy1rRt1gw8FvRDrcgWmQGen618sHW9uDkhq9TKXd6pZB4A52dfO7iaA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wxrnNYixn5b66YHMby8R35XHg/cZJKLdob6j5LDKR34=; b=8xP9mF4TT1//H/ZA9IWRe42Gv7ervYBoGOxm491kMFNItU+Dit9gzN4tbijAnY4hCr+PWf 6U9QVME66wQFvcAg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 47/58] x86/apic: Remove pointless arguments from [native_]eoi_write() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:47 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713577148238361 X-GMAIL-MSGID: 1771713577148238361 Every callsite hands in the same constants which is a pointless exercise and cannot be optimized by the compiler due to the indirect calls. Use the constants in the eoi() callbacks and remove the arguments. Signed-off-by: Thomas Gleixner Reviewed-by: Wei Liu --- arch/x86/hyperv/hv_apic.c | 6 +++--- arch/x86/include/asm/apic.h | 17 +++++++++++------ arch/x86/kernel/apic/apic.c | 8 ++++---- arch/x86/kernel/apic/apic_flat_64.c | 4 ++-- arch/x86/kernel/apic/apic_noop.c | 3 ++- arch/x86/kernel/apic/apic_numachip.c | 4 ++-- arch/x86/kernel/apic/bigsmp_32.c | 2 +- arch/x86/kernel/apic/probe_32.c | 2 +- arch/x86/kernel/apic/x2apic_cluster.c | 2 +- arch/x86/kernel/apic/x2apic_phys.c | 2 +- arch/x86/kernel/apic/x2apic_uv_x.c | 2 +- arch/x86/kernel/kvm.c | 6 +++--- arch/x86/xen/apic.c | 7 ++++++- 13 files changed, 38 insertions(+), 27 deletions(-) --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -86,14 +86,14 @@ static void hv_apic_write(u32 reg, u32 v } } -static void hv_apic_eoi_write(u32 reg, u32 val) +static void hv_apic_eoi_write(void) { struct hv_vp_assist_page *hvp = hv_vp_assist_page[smp_processor_id()]; if (hvp && (xchg(&hvp->apic_assist, 0) & 0x1)) return; - wrmsr(HV_X64_MSR_EOI, val, 0); + wrmsr(HV_X64_MSR_EOI, APIC_EOI_ACK, 0); } static bool cpu_is_self(int cpu) @@ -310,7 +310,7 @@ void __init hv_apic_init(void) * lazy EOI when available, but the same accessor works for * both xapic and x2apic because the field layout is the same. */ - apic_set_eoi_write(hv_apic_eoi_write); + apic_set_eoi_cb(hv_apic_eoi_write); if (!x2apic_enabled()) { apic->read = hv_apic_read; apic->write = hv_apic_write; --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -98,6 +98,11 @@ static inline u32 native_apic_mem_read(u return *((volatile u32 *)(APIC_BASE + reg)); } +static inline void native_apic_mem_eoi(void) +{ + native_apic_mem_write(APIC_EOI, APIC_EOI_ACK); +} + extern void native_apic_icr_write(u32 low, u32 id); extern u64 native_apic_icr_read(void); @@ -189,7 +194,7 @@ static inline void native_apic_msr_write wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0); } -static inline void native_apic_msr_eoi_write(u32 reg, u32 v) +static inline void native_apic_msr_eoi(void) { __wrmsr(APIC_BASE_MSR + (APIC_EOI >> 4), APIC_EOI_ACK, 0); } @@ -250,8 +255,8 @@ struct irq_data; */ struct apic { /* Hotpath functions first */ - void (*eoi_write)(u32 reg, u32 v); - void (*native_eoi_write)(u32 reg, u32 v); + void (*eoi)(void); + void (*native_eoi)(void); void (*write)(u32 reg, u32 v); u32 (*read)(u32 reg); @@ -351,7 +356,7 @@ static inline void apic_write(u32 reg, u static inline void apic_eoi(void) { - apic->eoi_write(APIC_EOI, APIC_EOI_ACK); + apic->eoi(); } static inline u64 apic_icr_read(void) @@ -380,7 +385,7 @@ static inline bool apic_id_valid(u32 api return apic_id <= apic->max_apic_id; } -extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)); +extern void __init apic_set_eoi_cb(void (*eoi)(void)); #else /* CONFIG_X86_LOCAL_APIC */ @@ -391,7 +396,7 @@ static inline u64 apic_icr_read(void) { static inline void apic_icr_write(u32 low, u32 high) { } static inline void apic_wait_icr_idle(void) { } static inline u32 safe_apic_wait_icr_idle(void) { return 0; } -static inline void apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) {} +static inline void apic_set_eoi(void (*eoi)(void)) {} #endif /* CONFIG_X86_LOCAL_APIC */ --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -2501,15 +2501,15 @@ void __init acpi_wake_cpu_handler_update * interrupts disabled, so we know this does not race with actual APIC driver * use. */ -void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) +void __init apic_set_eoi_cb(void (*eoi)(void)) { struct apic **drv; for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { /* Should happen once for each apic */ - WARN_ON((*drv)->eoi_write == eoi_write); - (*drv)->native_eoi_write = (*drv)->eoi_write; - (*drv)->eoi_write = eoi_write; + WARN_ON((*drv)->eoi == eoi); + (*drv)->native_eoi = (*drv)->eoi; + (*drv)->eoi = eoi; } } --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -106,7 +106,7 @@ static struct apic apic_flat __ro_after_ .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, @@ -182,7 +182,7 @@ static struct apic apic_physflat __ro_af .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, --- a/arch/x86/kernel/apic/apic_noop.c +++ b/arch/x86/kernel/apic/apic_noop.c @@ -29,6 +29,7 @@ static int noop_wakeup_secondary_cpu(int static u64 noop_apic_icr_read(void) { return 0; } static int noop_phys_pkg_id(int cpuid_apic, int index_msb) { return 0; } static unsigned int noop_get_apic_id(unsigned long x) { return 0; } +static void noop_apic_eoi(void) { } static u32 noop_apic_read(u32 reg) { @@ -71,7 +72,7 @@ struct apic apic_noop __ro_after_init = .read = noop_apic_read, .write = noop_apic_write, - .eoi_write = noop_apic_write, + .eoi = noop_apic_eoi, .icr_read = noop_apic_icr_read, .icr_write = noop_apic_icr_write, }; --- a/arch/x86/kernel/apic/apic_numachip.c +++ b/arch/x86/kernel/apic/apic_numachip.c @@ -247,7 +247,7 @@ static const struct apic apic_numachip1 .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, }; @@ -284,7 +284,7 @@ static const struct apic apic_numachip2 .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, }; --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -105,7 +105,7 @@ static struct apic apic_bigsmp __ro_afte .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -60,7 +60,7 @@ static struct apic apic_default __ro_aft .read = native_apic_mem_read, .write = native_apic_mem_write, - .eoi_write = native_apic_mem_write, + .eoi = native_apic_mem_eoi, .icr_read = native_apic_icr_read, .icr_write = native_apic_icr_write, .wait_icr_idle = apic_mem_wait_icr_idle, --- a/arch/x86/kernel/apic/x2apic_cluster.c +++ b/arch/x86/kernel/apic/x2apic_cluster.c @@ -254,7 +254,7 @@ static struct apic apic_x2apic_cluster _ .read = native_apic_msr_read, .write = native_apic_msr_write, - .eoi_write = native_apic_msr_eoi_write, + .eoi = native_apic_msr_eoi, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, }; --- a/arch/x86/kernel/apic/x2apic_phys.c +++ b/arch/x86/kernel/apic/x2apic_phys.c @@ -169,7 +169,7 @@ static struct apic apic_x2apic_phys __ro .read = native_apic_msr_read, .write = native_apic_msr_write, - .eoi_write = native_apic_msr_eoi_write, + .eoi = native_apic_msr_eoi, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, }; --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c @@ -831,7 +831,7 @@ static struct apic apic_x2apic_uv_x __ro .read = native_apic_msr_read, .write = native_apic_msr_write, - .eoi_write = native_apic_msr_eoi_write, + .eoi = native_apic_msr_eoi, .icr_read = native_x2apic_icr_read, .icr_write = native_x2apic_icr_write, }; --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -332,7 +332,7 @@ static void kvm_register_steal_time(void static DEFINE_PER_CPU_DECRYPTED(unsigned long, kvm_apic_eoi) = KVM_PV_EOI_DISABLED; -static notrace void kvm_guest_apic_eoi_write(u32 reg, u32 val) +static notrace void kvm_guest_apic_eoi_write(void) { /** * This relies on __test_and_clear_bit to modify the memory @@ -343,7 +343,7 @@ static notrace void kvm_guest_apic_eoi_w */ if (__test_and_clear_bit(KVM_PV_EOI_BIT, this_cpu_ptr(&kvm_apic_eoi))) return; - apic->native_eoi_write(APIC_EOI, APIC_EOI_ACK); + apic->native_eoi(); } static void kvm_guest_cpu_init(void) @@ -825,7 +825,7 @@ static void __init kvm_guest_init(void) } if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) - apic_set_eoi_write(kvm_guest_apic_eoi_write); + apic_set_eoi_cb(kvm_guest_apic_eoi_write); if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_INT) && kvmapf) { static_branch_enable(&kvm_async_pf_enabled); --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -81,6 +81,11 @@ static void xen_apic_write(u32 reg, u32 WARN(1,"register: %x, value: %x\n", reg, val); } +static void xen_apic_eoi(void) +{ + WARN_ON_ONCE(1); +} + static u64 xen_apic_icr_read(void) { return 0; @@ -147,7 +152,7 @@ static struct apic xen_pv_apic = { #endif .read = xen_apic_read, .write = xen_apic_write, - .eoi_write = xen_apic_write, + .eoi = xen_apic_eoi, .icr_read = xen_apic_icr_read, .icr_write = xen_apic_icr_write, From patchwork Mon Jul 17 23:15:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1429186vqt; Mon, 17 Jul 2023 17:41:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGA1Jm0/u/4ODC3YWcBYgifpwQJqN1xqBVcH9wKE2og7QMbNaN0vRd8wzJ6dKeuO48Ik4OH X-Received: by 2002:a17:903:110d:b0:1b8:3936:7b64 with SMTP id n13-20020a170903110d00b001b839367b64mr14373816plh.1.1689640870111; Mon, 17 Jul 2023 17:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640870; cv=none; d=google.com; s=arc-20160816; b=eq89wDbyFKX+pJdfJDdnmr06NBxCAi2vvVIJuwT3CqANoDvimGMyyU9ZYfD11qYUME Hkzoc/DRY4qWDLDm4bzV1bjJ8s+PZDltuAnJOG8HbAYz+ddtwgFtYgoEB+cdiPNglMJI wTDaDjPrSxZVd4qskFq/J0UqBC1yAW2sluJ53xHL4cvFwHC8knvfpWDSxRhMF3E5Rhgc rw82aMb3TaIUsWCG9Lp+3E0ZlZGcRHVCbTDBsVZgT6O6ovNgWf4P0hVtdWs+sYB3Z5Y4 I7uoX8fMUHaUXpDZkGIm9M6LqGq0ESOG2hhZQhuSGfk+GuMS97lKaAWGEdUTIZMW5IpX I3Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=iCsxfuqhz4Fo6ZGAppoqBTBjAoRzkGry7KPBD+0gZyY=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=eYVb4+NasOvYymtSpmPvzafZpbMyOgVz904dvpy3tD289c+txofPlMnEjnZgmMKeL1 4LLurH9tlOYjj/togT5TcZCzEwNr4ZK7TKiPaiem5aEyTsjYjwehk5z/499fSVuCIPgN eaKyBSPZ7pr9e+GS6PXEppchbTWNM+TKnuT0K2pe/cZjqQT7wsLtns8t9c8N7rn88LHk lFF1xLQ1a6a3/NltOn5KGTqWy4LdyA8bbGGjurvp38LFeTwQT3cgW8WEKHCxRyDtQn0l zZw4H9H1NCzwn/9WefYw1PABARNMGgg52sSgG+/I7bBDH/gd6AcMwvYDo/CNwGSqLmtZ Jp2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yrod9RYF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170903024d00b001b864d88d85si684298plh.636.2023.07.17.17.40.55; Mon, 17 Jul 2023 17:41:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=yrod9RYF; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231403AbjGQXgu (ORCPT + 99 others); Mon, 17 Jul 2023 19:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231661AbjGQXgp (ORCPT ); Mon, 17 Jul 2023 19:36:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02EFD170D for ; Mon, 17 Jul 2023 16:35:56 -0700 (PDT) Message-ID: <20230717223225.937554398@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iCsxfuqhz4Fo6ZGAppoqBTBjAoRzkGry7KPBD+0gZyY=; b=yrod9RYFIU1ubI925w14spnCcuCVMcCr4iYLMcuitbmxUYOOCOL1ggyXrpJaVe7OSOMQV/ GyS0JsyZWVl6ksXYnahXR0Abzz8mTq3oAX2/kMtA9s4gTg2OgmczD3ebZ6HweOQJSy4DVw /sS/a0TuD3wO8u31cQBUUkm/fY5WAp7bo3gnXOanrquEecXvFw/NauyD/bId89VhPlG5jI zPmYqfr3lduc60VMumb0j2KVEUxgqwAj/EpHExbehPyLMhIsT7U4yVHRnXNPSIOkQgWHRs ljZca4pdokvOkv89cmNk9aqmAef14s+HdbZI6zAVu+QFL1iCAjLPAh76XVjZsA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=iCsxfuqhz4Fo6ZGAppoqBTBjAoRzkGry7KPBD+0gZyY=; b=KgbgIgIjJ3pCo5ngii+ou3DNwDmhvHcKKy4N4E2rxsuUk4EIhVLtXI3Pph1+1f7vZUrpxD k3gVibrpUT4OIKBA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 48/58] x86/apic: Nuke ack_APIC_irq() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:49 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716864814615994 X-GMAIL-MSGID: 1771716864814615994 Yet another wrapper of a wrapper gone along with the outdated comment that this compiles to a single instruction. Signed-off-by: Thomas Gleixner Reviewed-by: Wei Liu --- arch/x86/hyperv/hv_init.c | 2 +- arch/x86/include/asm/apic.h | 10 ---------- arch/x86/kernel/apic/apic.c | 10 +++++----- arch/x86/kernel/apic/io_apic.c | 4 ++-- arch/x86/kernel/apic/vector.c | 4 ++-- arch/x86/kernel/cpu/acrn.c | 2 +- arch/x86/kernel/cpu/mce/amd.c | 2 +- arch/x86/kernel/cpu/mce/threshold.c | 2 +- arch/x86/kernel/cpu/mshyperv.c | 4 ++-- arch/x86/kernel/irq.c | 14 +++++++------- arch/x86/kernel/irq_work.c | 2 +- arch/x86/kernel/kvm.c | 2 +- arch/x86/kernel/smp.c | 8 ++++---- arch/x86/xen/enlighten_hvm.c | 2 +- 14 files changed, 29 insertions(+), 39 deletions(-) --- a/arch/x86/hyperv/hv_init.c +++ b/arch/x86/hyperv/hv_init.c @@ -161,7 +161,7 @@ static inline bool hv_reenlightenment_av DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_reenlightenment) { - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(irq_hv_reenlightenment_count); schedule_delayed_work(&hv_reenlightenment_work, HZ/10); } --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -402,16 +402,6 @@ static inline void apic_set_eoi(void (*e extern void apic_ack_irq(struct irq_data *data); -static inline void ack_APIC_irq(void) -{ - /* - * ack_APIC_irq() actually gets compiled as a single instruction - * ... yummie. - */ - apic_eoi(); -} - - static inline bool lapic_vector_set_in_irr(unsigned int vector) { u32 irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -1076,7 +1076,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_apic_timer { struct pt_regs *old_regs = set_irq_regs(regs); - ack_APIC_irq(); + apic_eoi(); trace_local_timer_entry(LOCAL_TIMER_VECTOR); local_apic_timer_interrupt(); trace_local_timer_exit(LOCAL_TIMER_VECTOR); @@ -1480,7 +1480,7 @@ static bool apic_check_and_ack(union api * per set bit. */ for_each_set_bit(bit, isr->map, APIC_IR_BITS) - ack_APIC_irq(); + apic_eoi(); return true; } @@ -1492,7 +1492,7 @@ static bool apic_check_and_ack(union api * interrupt from previous kernel might still have ISR bit set. * * Most probably by now the CPU has serviced that pending interrupt and it - * might not have done the ack_APIC_irq() because it thought, interrupt + * might not have done the apic_eoi() because it thought, interrupt * came from i8259 as ExtInt. LAPIC did not get EOI so it does not clear * the ISR bit and cpu thinks it has already serviced the interrupt. Hence * a vector might get locked. It was noticed for timer irq (vector @@ -2146,7 +2146,7 @@ static noinline void handle_spurious_int if (v & (1 << (vector & 0x1f))) { pr_info("Spurious interrupt (vector 0x%02x) on CPU#%d. Acked\n", vector, smp_processor_id()); - ack_APIC_irq(); + apic_eoi(); } else { pr_info("Spurious interrupt (vector 0x%02x) on CPU#%d. Not pending!\n", vector, smp_processor_id()); @@ -2197,7 +2197,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_error_inte if (lapic_get_maxlvt() > 3) /* Due to the Pentium erratum 3AP. */ apic_write(APIC_ESR, 0); v = apic_read(APIC_ESR); - ack_APIC_irq(); + apic_eoi(); atomic_inc(&irq_err_count); apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x", --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -1823,7 +1823,7 @@ static void ioapic_ack_level(struct irq_ * We must acknowledge the irq before we move it or the acknowledge will * not propagate properly. */ - ack_APIC_irq(); + apic_eoi(); /* * Tail end of clearing remote IRR bit (either by delivering the EOI @@ -2046,7 +2046,7 @@ static void unmask_lapic_irq(struct irq_ static void ack_lapic_irq(struct irq_data *data) { - ack_APIC_irq(); + apic_eoi(); } static struct irq_chip lapic_chip __read_mostly = { --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -885,7 +885,7 @@ static int apic_retrigger_irq(struct irq void apic_ack_irq(struct irq_data *irqd) { irq_move_irq(irqd); - ack_APIC_irq(); + apic_eoi(); } void apic_ack_edge(struct irq_data *irqd) @@ -940,7 +940,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_c struct apic_chip_data *apicd; struct hlist_node *tmp; - ack_APIC_irq(); + apic_eoi(); /* Prevent vectors vanishing under us */ raw_spin_lock(&vector_lock); --- a/arch/x86/kernel/cpu/acrn.c +++ b/arch/x86/kernel/cpu/acrn.c @@ -51,7 +51,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_acrn_hv_ca * will block the interrupt whose vector is lower than * HYPERVISOR_CALLBACK_VECTOR. */ - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(irq_hv_callback_count); if (acrn_intr_handler) --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -759,7 +759,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_deferred_e inc_irq_stat(irq_deferred_error_count); deferred_error_int_vector(); trace_deferred_error_apic_exit(DEFERRED_ERROR_VECTOR); - ack_APIC_irq(); + apic_eoi(); } /* --- a/arch/x86/kernel/cpu/mce/threshold.c +++ b/arch/x86/kernel/cpu/mce/threshold.c @@ -27,5 +27,5 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_threshold) inc_irq_stat(irq_threshold_count); mce_threshold_vector(); trace_threshold_apic_exit(THRESHOLD_APIC_VECTOR); - ack_APIC_irq(); + apic_eoi(); } --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c @@ -119,7 +119,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_cal vmbus_handler(); if (ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED) - ack_APIC_irq(); + apic_eoi(); set_irq_regs(old_regs); } @@ -147,7 +147,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_hyperv_sti if (hv_stimer0_handler) hv_stimer0_handler(); add_interrupt_randomness(HYPERV_STIMER0_VECTOR); - ack_APIC_irq(); + apic_eoi(); set_irq_regs(old_regs); } --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -49,7 +49,7 @@ void ack_bad_irq(unsigned int irq) * completely. * But only ack when the APIC is enabled -AK */ - ack_APIC_irq(); + apic_eoi(); } #define irq_stats(x) (&per_cpu(irq_stat, x)) @@ -256,7 +256,7 @@ DEFINE_IDTENTRY_IRQ(common_interrupt) if (likely(!IS_ERR_OR_NULL(desc))) { handle_irq(desc, regs); } else { - ack_APIC_irq(); + apic_eoi(); if (desc == VECTOR_UNUSED) { pr_emerg_ratelimited("%s: %d.%u No irq handler for vector\n", @@ -280,7 +280,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_x86_platfo { struct pt_regs *old_regs = set_irq_regs(regs); - ack_APIC_irq(); + apic_eoi(); trace_x86_platform_ipi_entry(X86_PLATFORM_IPI_VECTOR); inc_irq_stat(x86_platform_ipis); if (x86_platform_ipi_callback) @@ -310,7 +310,7 @@ EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wa */ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm_posted_intr_ipi) { - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(kvm_posted_intr_ipis); } @@ -319,7 +319,7 @@ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm */ DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_posted_intr_wakeup_ipi) { - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(kvm_posted_intr_wakeup_ipis); kvm_posted_intr_wakeup_handler(); } @@ -329,7 +329,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_posted */ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm_posted_intr_nested_ipi) { - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(kvm_posted_intr_nested_ipis); } #endif @@ -401,6 +401,6 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_thermal) inc_irq_stat(irq_thermal_count); smp_thermal_vector(); trace_thermal_apic_exit(THERMAL_APIC_VECTOR); - ack_APIC_irq(); + apic_eoi(); } #endif --- a/arch/x86/kernel/irq_work.c +++ b/arch/x86/kernel/irq_work.c @@ -16,7 +16,7 @@ #ifdef CONFIG_X86_LOCAL_APIC DEFINE_IDTENTRY_SYSVEC(sysvec_irq_work) { - ack_APIC_irq(); + apic_eoi(); trace_irq_work_entry(IRQ_WORK_VECTOR); inc_irq_stat(apic_irq_work_irqs); irq_work_run(); --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -291,7 +291,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_kvm_asyncp struct pt_regs *old_regs = set_irq_regs(regs); u32 token; - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(irq_hv_callback_count); --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -135,7 +135,7 @@ static int smp_stop_nmi_callback(unsigne */ DEFINE_IDTENTRY_SYSVEC(sysvec_reboot) { - ack_APIC_irq(); + apic_eoi(); cpu_emergency_disable_virtualization(); stop_this_cpu(NULL); } @@ -268,7 +268,7 @@ static void native_stop_other_cpus(int w */ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_reschedule_ipi) { - ack_APIC_irq(); + apic_eoi(); trace_reschedule_entry(RESCHEDULE_VECTOR); inc_irq_stat(irq_resched_count); scheduler_ipi(); @@ -277,7 +277,7 @@ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_res DEFINE_IDTENTRY_SYSVEC(sysvec_call_function) { - ack_APIC_irq(); + apic_eoi(); trace_call_function_entry(CALL_FUNCTION_VECTOR); inc_irq_stat(irq_call_count); generic_smp_call_function_interrupt(); @@ -286,7 +286,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_call_funct DEFINE_IDTENTRY_SYSVEC(sysvec_call_function_single) { - ack_APIC_irq(); + apic_eoi(); trace_call_function_single_entry(CALL_FUNCTION_SINGLE_VECTOR); inc_irq_stat(irq_call_count); generic_smp_call_function_single_interrupt(); --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -132,7 +132,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_xen_hvm_ca struct pt_regs *old_regs = set_irq_regs(regs); if (xen_percpu_upcall) - ack_APIC_irq(); + apic_eoi(); inc_irq_stat(irq_hv_callback_count); From patchwork Mon Jul 17 23:15:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1402310vqt; Mon, 17 Jul 2023 16:26:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlG0nvvwDynEbzHbVrU+do37MuKq72XSoV+ktCdUdVgo4GsIXg9qx+zPvQcw2PR0ZcPl64tH X-Received: by 2002:a05:6a20:154:b0:12d:d688:a5dc with SMTP id 20-20020a056a20015400b0012dd688a5dcmr12562379pzs.43.1689636392962; Mon, 17 Jul 2023 16:26:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636392; cv=none; d=google.com; s=arc-20160816; b=nMl8hxPGq4T2Uumh3COV+/cN3qUnu+ZKpx4gzLl12lp4JgZ76mhifL59CmfmkKNfZ4 B+/gFR61fjOiWwr6kGJh7wSaHJhUHBv9WjFAtaDzXzOf6X4b4KtHHYnOmdaueNqIwvfz NshX14w+vwptS73roav/cP2/z46M00+UeqchvUf9xE26XVYEGFfosxf7QhE/Vwymm7UK 6kvV0vRABTIDq0oBfU/jrCSB1nkrRGM2hwEYbxVtK7bwne5FCg2jpwawSsFnZqMliIk4 O8z4g2wcb5trhru6D1dg/q4x/pL01AZJ2iooFBN8c7X7ADFc4H3FBxvamSU2ilTBcqNN Vrsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=9TaSlhjUTakFiVj1azrlzZ2xVg2Xkr4O8C5JrwSXaPY=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=QB+CuHTIXbKw8oovVsLtTFKCJplu54ACz+IBAdA0V0IGZCtmql8EPUaP1zjM3MH0PE ikLpdbMjLgzH1+ME6UpckGAbIfsTPA/YOCbfHXEs5sBXD7Y6pXJ5lG0WwMdut+i1vtVt TDfR4kEsoT3wE2bR2HyP+cW8FGPRQQPJVvUpwLX0lZTtxoP+PWaBV1Me0Q/+7gkStZP6 Z6VloWPEO+EX7wo1CWP9Gq0NZFd07AsafTPc56Mg6sUQEyMOuAP4JIMdt9RLUZMPNlKo s6CJy2Tt2Ma+ysL1hK0Nei6q4aDXNAnzS/uw5wvsg6KynCQao857IFmVlNLv9CUaM/Pm pQ7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=w1ZbVj5J; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020a170903018d00b001b8921fbd87si629665plg.490.2023.07.17.16.26.20; Mon, 17 Jul 2023 16:26:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=w1ZbVj5J; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjGQXUi (ORCPT + 99 others); Mon, 17 Jul 2023 19:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231521AbjGQXUe (ORCPT ); Mon, 17 Jul 2023 19:20:34 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAE591B3 for ; Mon, 17 Jul 2023 16:19:46 -0700 (PDT) Message-ID: <20230717223225.997925757@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9TaSlhjUTakFiVj1azrlzZ2xVg2Xkr4O8C5JrwSXaPY=; b=w1ZbVj5JoX+S2m2HtC951EaBUqWGWCI2c5QAVVr2tUm4sfpNycBLzdjLWi4mmhnbD9OxXN 7zIChhVge0gA93t2mlqOtoO7Ki49d8BhlSQizly6WMUwwYQ5gYuOqqXwbwgwKTImc80hxA ufdLZxuiBV2GYtHcSaAYjMnYT5S2T+BliY3239Qt8Y64MKDQTK9DwtAAlnWGV15n/JS00I ftHfyiwOtSyd+pe38RWMjZakYR+7zrnwLr/FHjC0pI9NwaKAKJKqzvJViqLmHb8h4VJAPi y3KsurgSAS760ihHk6YteCeVkJ327STQa9rCsXOe0Q0BOj6D1U2p6aOpqyzA2A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=9TaSlhjUTakFiVj1azrlzZ2xVg2Xkr4O8C5JrwSXaPY=; b=UyPlwkBARb1hXbyifHDOgDybuzN/RtN64FgVFT9nLzHpECycP0TApiv3hXvGkY1RgpJpps AOsJDS7yQX55yVBw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 49/58] x86/apic: Wrap apic->native_eoi() into a helper References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:51 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712169953521935 X-GMAIL-MSGID: 1771712169953521935 Prepare for converting the hotpath APIC callbacks to static calls. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 5 +++++ arch/x86/kernel/kvm.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -359,6 +359,11 @@ static inline void apic_eoi(void) apic->eoi(); } +static inline void apic_native_eoi(void) +{ + apic->native_eoi(); +} + static inline u64 apic_icr_read(void) { return apic->icr_read(); --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -343,7 +343,7 @@ static notrace void kvm_guest_apic_eoi_w */ if (__test_and_clear_bit(KVM_PV_EOI_BIT, this_cpu_ptr(&kvm_apic_eoi))) return; - apic->native_eoi(); + apic_native_eoi(); } static void kvm_guest_cpu_init(void) From patchwork Mon Jul 17 23:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1428198vqt; Mon, 17 Jul 2023 17:38:16 -0700 (PDT) X-Google-Smtp-Source: APBJJlEbn4ng+FxfHyurA0aFhcvfjOJjtHUIjgpVFt85fn3+aTV9yHlcXtP7PnIasgbqhQ0rUt2a X-Received: by 2002:a17:90a:c20d:b0:263:850a:b49c with SMTP id e13-20020a17090ac20d00b00263850ab49cmr12376156pjt.7.1689640695841; Mon, 17 Jul 2023 17:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640695; cv=none; d=google.com; s=arc-20160816; b=emfI3zDCGD5eEfHJS84RLB8Wd3vtZJzf6Di3dc/hZ+Qg9tXsYGMlqpQGk+Af812Gzg XtbrzMd8Ke2z8VeSoSwNadgjM9ByoeJFKPJC5CGWwBlf+K2axAp3YygwNCDDKLzM9lGi rBzbL7JMNpFRR1hMApF3VjQFnMtlok8qsJpMQHdd3MfUw0hGesSmQTdMSmEqCSmxd7U+ VjQxdknUkg9pQIsPQoP2+ivZ0cFHTrIUMRdg5daRHQU1EzrODXnRPB0ye8nRpKJjLfdi NYxOOpMxJZe26pPVTheBXsONCHXz1MV1KPgbfw31oYkCxcJdA03KvJUyemCpweCY9M0U F7zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=eXPzx8NJQYkjuBlJm5EN8V5tBON4kRyyGhZ2fdxQVSM=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=pgQGv+H3au2imJvaLFa6660wRaYX/A074SY5IpedmViGexX1OZwgD8w4lsadEIMp6Z AKFWAiOy3wl04Od3mW8X7wlIvcT5vJ115oImUbOL2Fkiac1oXdbu3Y9YSxE3cl/zX1gU 1V0q2iANmVEI56trCqK8aeelQHYV3SJv1lSh3EkxqUUx3M6XC0f1596AQKejOrLDeiIA j2mQib+PKU7AUKZfmMIVWiZeKmtLlpq1CiaOLxewU3wV5QkCvEUkp3ufcxwvDLuDTPcR xLNkD6ERfo8/g7YD1EGvtkXXD/6n5ITfYhPTg0p7A/M6jSwOjoe9bPneGJRo2N+IJiYs rEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G7xolB3T; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jPwIVS4X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mj19-20020a17090b369300b002634977e6e5si6493412pjb.142.2023.07.17.17.38.03; Mon, 17 Jul 2023 17:38:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G7xolB3T; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jPwIVS4X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231514AbjGQXU2 (ORCPT + 99 others); Mon, 17 Jul 2023 19:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231512AbjGQXU0 (ORCPT ); Mon, 17 Jul 2023 19:20:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6C31709 for ; Mon, 17 Jul 2023 16:19:40 -0700 (PDT) Message-ID: <20230717223226.058365439@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=eXPzx8NJQYkjuBlJm5EN8V5tBON4kRyyGhZ2fdxQVSM=; b=G7xolB3Tb4xUlMmTwsM/swv8QsQ8macQRaBVs6lHmNCcvTdQCYTrT3NklviK1LTFLj4Gn8 HiG2o8xs307dfc14gAwIzW09rBQjV/itHp6k/P9Ex0J+kJtFVCG1vhS3loXE2wrr5ijrbA D08toNl6KosS2gomVDntd80tcxpn714BhD+y0DXtzOAsR+eS9ndNW7K3RJbqpUp6rFBjPS qGcgq4lkHWIljlwHuXa08I2GRq3A4RS5qZHoPkPAL95UT4qhm2EesGKK49iIy5nhVmv2Lt jYbUz1WWZsuNMyyK8XJoovS8WBdBbDgg2j3qe+ELEIyZ3akiI3qZ3zrNSQ06Tg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=eXPzx8NJQYkjuBlJm5EN8V5tBON4kRyyGhZ2fdxQVSM=; b=jPwIVS4XKP/v+npAc5tlVumfRxehevuONtfWaGqy8Bl6KwoICGE8TDZX/EURHWMx7deC7Y 7cEcCPPwaWx0McDg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 50/58] x86/apic: Provide common init infrastructure References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:52 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716682679124815 X-GMAIL-MSGID: 1771716682679124815 In preparation for converting the hotpath APIC callbacks to static keys, provide common initialization inforastructure. Lift apic_install_drivers() from probe_64.c and convert all places which switch the apic instance by storing the pointer to use apic_install_driver() as a first step. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 2 + arch/x86/kernel/apic/Makefile | 2 - arch/x86/kernel/apic/apic.c | 31 ----------------------- arch/x86/kernel/apic/apic_flat_64.c | 6 ---- arch/x86/kernel/apic/bigsmp_32.c | 6 +--- arch/x86/kernel/apic/init.c | 47 ++++++++++++++++++++++++++++++++++++ arch/x86/kernel/apic/probe_32.c | 5 +-- arch/x86/kernel/apic/probe_64.c | 13 --------- arch/x86/xen/apic.c | 10 ++----- 9 files changed, 59 insertions(+), 63 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -344,6 +344,8 @@ extern int lapic_can_unplug_cpu(void); #ifdef CONFIG_X86_LOCAL_APIC +void __init apic_install_driver(struct apic *driver); + static inline u32 apic_read(u32 reg) { return apic->read(reg); --- a/arch/x86/kernel/apic/Makefile +++ b/arch/x86/kernel/apic/Makefile @@ -7,7 +7,7 @@ # In particualr, smp_apic_timer_interrupt() is called in random places. KCOV_INSTRUMENT := n -obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_common.o apic_noop.o ipi.o vector.o +obj-$(CONFIG_X86_LOCAL_APIC) += apic.o apic_common.o apic_noop.o ipi.o vector.o init.o obj-y += hw_nmi.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -236,8 +236,7 @@ static int modern_apic(void) */ static void __init apic_disable(void) { - pr_info("APIC: switched to apic NOOP\n"); - apic = &apic_noop; + apic_install_driver(&apic_noop); } void native_apic_icr_write(u32 low, u32 id) @@ -2485,34 +2484,6 @@ u32 x86_msi_msg_get_destid(struct msi_ms } EXPORT_SYMBOL_GPL(x86_msi_msg_get_destid); -#ifdef CONFIG_X86_64 -void __init acpi_wake_cpu_handler_update(wakeup_cpu_handler handler) -{ - struct apic **drv; - - for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) - (*drv)->wakeup_secondary_cpu_64 = handler; -} -#endif - -/* - * Override the generic EOI implementation with an optimized version. - * Only called during early boot when only one CPU is active and with - * interrupts disabled, so we know this does not race with actual APIC driver - * use. - */ -void __init apic_set_eoi_cb(void (*eoi)(void)) -{ - struct apic **drv; - - for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { - /* Should happen once for each apic */ - WARN_ON((*drv)->eoi == eoi); - (*drv)->native_eoi = (*drv)->eoi; - (*drv)->eoi = eoi; - } -} - static void __init apic_bsp_up_setup(void) { #ifdef CONFIG_X86_64 --- a/arch/x86/kernel/apic/apic_flat_64.c +++ b/arch/x86/kernel/apic/apic_flat_64.c @@ -143,11 +143,7 @@ static int physflat_acpi_madt_oem_check( static int physflat_probe(void) { - if (apic == &apic_physflat || num_possible_cpus() > 8 || - jailhouse_paravirt()) - return 1; - - return 0; + return apic == &apic_physflat || num_possible_cpus() > 8 || jailhouse_paravirt(); } static struct apic apic_physflat __ro_after_init = { --- a/arch/x86/kernel/apic/bigsmp_32.c +++ b/arch/x86/kernel/apic/bigsmp_32.c @@ -119,10 +119,8 @@ bool __init apic_bigsmp_possible(bool cm void __init apic_bigsmp_force(void) { - if (apic != &apic_bigsmp) { - apic = &apic_bigsmp; - pr_info("Overriding APIC driver with bigsmp\n"); - } + if (apic != &apic_bigsmp) + apic_install_driver(&apic_noop); } apic_driver(apic_bigsmp); --- /dev/null +++ b/arch/x86/kernel/apic/init.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0-only +#define pr_fmt(fmt) "APIC: " fmt + +#include + +#include "local.h" + +void __init apic_install_driver(struct apic *driver) +{ + if (apic == driver) + return; + + apic = driver; + + if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid) + apic->max_apic_id = x2apic_max_apicid; + + pr_info("Switched APIC routing to: %s\n", driver->name); +} + +#ifdef CONFIG_X86_64 +void __init acpi_wake_cpu_handler_update(wakeup_cpu_handler handler) +{ + struct apic **drv; + + for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) + (*drv)->wakeup_secondary_cpu_64 = handler; +} +#endif + +/* + * Override the generic EOI implementation with an optimized version. + * Only called during early boot when only one CPU is active and with + * interrupts disabled, so we know this does not race with actual APIC driver + * use. + */ +void __init apic_set_eoi_cb(void (*eoi)(void)) +{ + struct apic **drv; + + for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { + /* Should happen once for each apic */ + WARN_ON((*drv)->eoi == eoi); + (*drv)->native_eoi = (*drv)->eoi; + (*drv)->eoi = eoi; + } +} --- a/arch/x86/kernel/apic/probe_32.c +++ b/arch/x86/kernel/apic/probe_32.c @@ -82,7 +82,7 @@ static int __init parse_apic(char *arg) for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { if (!strcmp((*drv)->name, arg)) { - apic = *drv; + apic_install_driver(*drv); cmdline_apic = 1; return 0; } @@ -129,7 +129,7 @@ void __init x86_32_probe_apic(void) for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { if ((*drv)->probe()) { - apic = *drv; + apic_install_driver(*drv); break; } } @@ -137,5 +137,4 @@ void __init x86_32_probe_apic(void) if (drv == __apicdrivers_end) panic("Didn't find an APIC driver"); } - printk(KERN_INFO "Using APIC driver %s\n", apic->name); } --- a/arch/x86/kernel/apic/probe_64.c +++ b/arch/x86/kernel/apic/probe_64.c @@ -13,19 +13,6 @@ #include "local.h" -static __init void apic_install_driver(struct apic *driver) -{ - if (apic == driver) - return; - - apic = driver; - - if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid) - apic->max_apic_id = x2apic_max_apicid; - - pr_info("Switched APIC routing to %s:\n", apic->name); -} - /* Select the appropriate APIC driver */ void __init x86_64_probe_apic(void) { --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -160,20 +160,16 @@ static struct apic xen_pv_apic = { static void __init xen_apic_check(void) { - if (apic == &xen_pv_apic) - return; - - pr_info("Switched APIC routing from %s to %s.\n", apic->name, - xen_pv_apic.name); - apic = &xen_pv_apic; + apic_install_driver(&xen_pv_apic); } + void __init xen_init_apic(void) { x86_apic_ops.io_apic_read = xen_io_apic_read; /* On PV guests the APIC CPUID bit is disabled so none of the * routines end up executing. */ if (!xen_initial_domain()) - apic = &xen_pv_apic; + apic_install_driver(&xen_pv_apic); x86_platform.apic_post_init = xen_apic_check; } From patchwork Mon Jul 17 23:15:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121702 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1426667vqt; Mon, 17 Jul 2023 17:33:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGxWUAQY3ituGCSvcoIKY923RPdfaMW2QVXUovMdJ28dk/b/itPsvn8pLRsMg1GjQ6tUjt0 X-Received: by 2002:a05:6a20:3ca0:b0:134:795e:e85 with SMTP id b32-20020a056a203ca000b00134795e0e85mr7079078pzj.52.1689640433306; Mon, 17 Jul 2023 17:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640433; cv=none; d=google.com; s=arc-20160816; b=w5NzMC7c4QFgeswN+T/PWFezB4UajMbpKE1JvmNkQ+dEAaFMUkcNr+VI97vTlJLQLs Bxb5XwNP4I5cST4yHwQwXQ+oCPIWa1xExcijXf963HEvt40JkPT1zjbTjGcIexlWfbDA npDOLZhJ0c+klqeo+PBujE7J1bCOwMUWTg8FQ6oGEQ0sSiSmk9CzCApzKQwCBRd/cYGp 184FBJ3N4EJJ1JfOw7YyS3s85O7S2evw0KzFiTnsNoAjGAQdWnJjqyDQfd43j9EFO4Na 9vq51R5Hw4ZmxDDMsK0ncb+mVCEQfUwHTHMb1Qllb3K9wtajyX6Qycz7rhGMxb8pf/FG fIrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=SE1iSqYJ4ehwEamqhZ1Qn1Xh1qrFRO76iVIsUZ/pjC8=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=AN+77o0LJ6GGQEXaEBJw+fLLN6P4VqwkeX+XfDtFIhAmu9a2UC9G58ibd8HRfVzcXu oVtDyskfTeh2Wh+wVwQ43TntGaqjt0J5bRsxUd3p40RYsOZvRArgSm7y5faiM0bgM6RS 80wMtOjFtb2Z6GLkDkijHJD+b4vQb3jqbiRwbmk2Gv9722y7Qb+UmfeUnKxwouXmCqcJ CDvcYymM5Clp/aw81b+X2oDo16N8GjVH3vEry27vEJqLOM6gNkyDBnaG1kA4h2xsF4gw hUiC7swqkAV9vy6Oc0nPb9we9BMYrSvwb4RwJFtdUbYDHa2SdEyrfH+3hfTsmb8c5DCV cTNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="r9CDm/xw"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cb12-20020a056a00430c00b00666b7377d65si608435pfb.389.2023.07.17.17.33.40; Mon, 17 Jul 2023 17:33:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="r9CDm/xw"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjGQXhF (ORCPT + 99 others); Mon, 17 Jul 2023 19:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231700AbjGQXg6 (ORCPT ); Mon, 17 Jul 2023 19:36:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B72AA171C for ; Mon, 17 Jul 2023 16:36:07 -0700 (PDT) Message-ID: <20230717223226.118922473@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=SE1iSqYJ4ehwEamqhZ1Qn1Xh1qrFRO76iVIsUZ/pjC8=; b=r9CDm/xw+hI5tPivegSVDw2QhU4sENJsdZjGHyVr2s0woGUJ7h5Kl3iPBR9ksvCHNV+j63 JejyxjeVzibJQbwhS8x2/GWk0Sdkl74tUMa+l+lYxuhgxXuzCSjOqTnAhkCOF9VHgOLg33 LnRutsQEJEpwu1V3EHWTvmyWHJTo5a/B+BI1QR08X1GhiNGME3Z2uFMQvIo8SqfvH/v1Fi RcHIE0h24hqvG88KP8MmiSomsz3t+xV1Cf0kJdW7NLDE8okV9VwXT12lXuR+i1pY6l7CKx 6dJfSSKOIQ9qAcV27Aqybp65znOyEfMn2q6QIWkDgbwc61yGzqoFe5cXyZoqGQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=SE1iSqYJ4ehwEamqhZ1Qn1Xh1qrFRO76iVIsUZ/pjC8=; b=09GVELt/GpTAFjbYuMVdaAmm3ybHo2iSKr3KLK11c+j2xxCZJh+c8ziFYaC44xOt7Qb6GJ JWYDzE0WRZG3R0CA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 51/58] x86/apic: Provide apic_update_callback() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:54 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716407140510876 X-GMAIL-MSGID: 1771716407140510876 There are already two variants of update mechanism for particular callbacks and virtualization just writes into the data structure. Provide an interface and use a shadow data structure to preserve callbacks so they can be reapplied when the APIC driver is replaced. The extra data structure is intentional as any new callback needs to be also updated in the core code. This also prepares for static calls. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 25 +++++++++++++++++++++++++ arch/x86/kernel/apic/init.c | 39 ++++++++++++++++++++++++++++++++++++++- arch/x86/kernel/setup.c | 2 ++ 3 files changed, 65 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -308,6 +308,23 @@ struct apic { char *name; }; +struct apic_override { + void (*eoi)(void); + void (*native_eoi)(void); + void (*write)(u32 reg, u32 v); + u32 (*read)(u32 reg); + void (*send_IPI)(int cpu, int vector); + void (*send_IPI_mask)(const struct cpumask *mask, int vector); + void (*send_IPI_mask_allbutself)(const struct cpumask *msk, int vec); + void (*send_IPI_allbutself)(int vector); + void (*send_IPI_all)(int vector); + void (*send_IPI_self)(int vector); + u64 (*icr_read)(void); + void (*icr_write)(u32 low, u32 high); + int (*wakeup_secondary_cpu)(int apicid, unsigned long start_eip); + int (*wakeup_secondary_cpu_64)(int apicid, unsigned long start_eip); +}; + /* * Pointer to the local APIC driver in use on this system (there's * always just one such driver in use - the kernel decides via an @@ -343,9 +360,17 @@ extern int lapic_can_unplug_cpu(void); #endif #ifdef CONFIG_X86_LOCAL_APIC +extern struct apic_override __x86_apic_override; +void __init apic_setup_apic_calls(void); void __init apic_install_driver(struct apic *driver); +#define apic_update_callback(_callback, _fn) { \ + __x86_apic_override._callback = _fn; \ + apic->_callback = _fn; \ + pr_info("APIC::%s() replaced with %ps()\n", #_callback, _fn); \ +} + static inline u32 apic_read(u32 reg) { return apic->read(reg); --- a/arch/x86/kernel/apic/init.c +++ b/arch/x86/kernel/apic/init.c @@ -5,6 +5,37 @@ #include "local.h" +/* The container for function call overrides */ +struct apic_override __x86_apic_override __initdata; + +#define apply_override(__cb) \ + if (__x86_apic_override.__cb) \ + apic->__cb = __x86_apic_override.__cb + +static __init void restore_override_callbacks(void) +{ + apply_override(eoi); + apply_override(native_eoi); + apply_override(write); + apply_override(read); + apply_override(send_IPI); + apply_override(send_IPI_mask); + apply_override(send_IPI_mask_allbutself); + apply_override(send_IPI_allbutself); + apply_override(send_IPI_all); + apply_override(send_IPI_self); + apply_override(icr_read); + apply_override(icr_write); + apply_override(wakeup_secondary_cpu); + apply_override(wakeup_secondary_cpu_64); +} + +void __init apic_setup_apic_calls(void) +{ + /* Ensure that the default APIC has native_eoi populated */ + apic->native_eoi = apic->eoi; +} + void __init apic_install_driver(struct apic *driver) { if (apic == driver) @@ -15,6 +46,13 @@ void __init apic_install_driver(struct a if (IS_ENABLED(CONFIG_X86_X2APIC) && apic->x2apic_set_max_apicid) apic->max_apic_id = x2apic_max_apicid; + /* Copy the original eoi() callback as KVM/HyperV might overwrite it */ + if (!apic->native_eoi) + apic->native_eoi = apic->eoi; + + /* Apply any already installed callback overrides */ + restore_override_callbacks(); + pr_info("Switched APIC routing to: %s\n", driver->name); } @@ -41,7 +79,6 @@ void __init apic_set_eoi_cb(void (*eoi)( for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { /* Should happen once for each apic */ WARN_ON((*drv)->eoi == eoi); - (*drv)->native_eoi = (*drv)->eoi; (*drv)->eoi = eoi; } } --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1018,6 +1018,8 @@ void __init setup_arch(char **cmdline_p) x86_report_nx(); + apic_setup_apic_calls(); + if (acpi_mps_check()) { #ifdef CONFIG_X86_LOCAL_APIC apic_is_disabled = true; From patchwork Mon Jul 17 23:15:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1426050vqt; Mon, 17 Jul 2023 17:32:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHu1vA/MKKjmscWUbPq8sP+I+k30L6r8ZZECIuAUhv/ZJcVxxNDWR3XXQkrjaQXkAbbGcHj X-Received: by 2002:a05:6a20:8f11:b0:134:38e5:d146 with SMTP id b17-20020a056a208f1100b0013438e5d146mr8086327pzk.16.1689640348417; Mon, 17 Jul 2023 17:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640348; cv=none; d=google.com; s=arc-20160816; b=Px/XVsouCX7TvGytxhyfqqY4kB8q9RTfWYQXr7v9P785ZdVZPXU5djDZEPtjhApHfw dxQsEfbr6Ctukv0wtnLjSXUZYNMrYDgMRsOcaxp955xejdGmO4MzxOr4Rr1/b8sXMmXM 3ym2d0U0CGnYUqJ0iMBXGBhaATfBfvBhnpKZal1/GqBZXEegm4GwD3EmI6LpZ+ITPHX4 vRtLDFbhGVahvrn/PNX+Lt3EMvI/PVWPqtNRzgHf0aO5zORRXK4TpPkEIoe9M2f0YqMt fxhrvetVitJetgtOQXNdvHhMent3Ft9qXe8XLIIuaLibzXWuGOJA5o5MK7GlWoJW/cN1 TnFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=UsgerkQJ/HhbA2AbXpANMMQuwJxS8UzMeOUa8nnw3cg=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=DCBTp/r22wVoIoOwJqZfpPHHBE/F7kgkRN21MTYy5DSghMvEEPFBWZxKOVaF/7UUNk cvIDIev+rYrddnrvYhD53Z1IsQdcdSSbldCY1/z0xt8Lh01vSIxdMn8HP3weU30X1FN/ yh6T/Eqz34EVLydvnIoRawVPxQEjoWFEYecNK9YB9OtPcwI+Bwl7D49pHPMtOyJ/WTKv 3V2kWdX9lygxtj3yGNdlrFozqnhX2biN+1hNz5vHbIJvX0Ey66recb/88AAhX7zwVCDH RJo3Ku3CSMfBbP+VMdjuhrqjFLTYW7toe8j21WoYYfz6LDCR19iKC/mq8n1WNXA2mhp+ dK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LHZGeCb7; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020aa7888c000000b00643c4345942si654009pfe.134.2023.07.17.17.32.16; Mon, 17 Jul 2023 17:32:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LHZGeCb7; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231738AbjGQXhI (ORCPT + 99 others); Mon, 17 Jul 2023 19:37:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231709AbjGQXhC (ORCPT ); Mon, 17 Jul 2023 19:37:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99D76171E for ; Mon, 17 Jul 2023 16:36:09 -0700 (PDT) Message-ID: <20230717223226.178478466@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=UsgerkQJ/HhbA2AbXpANMMQuwJxS8UzMeOUa8nnw3cg=; b=LHZGeCb7nf55OTUyQt+8eKj8zeR2DihYQFUGhVGoktuWtOV4acP4pzMDaOeDrygIArkINK mfbXOoiR3rJe69kvbb5gFPf1IlBjn3LUWpMfxkFZPgOfhA60MBz4tkKH6r/RFUuSBewYN3 CqPLE+36Wr/F330F00c2Y6eWkL/91hnlvNh/4zUP3czKP+HbrRDFKvM3cJ8ZxPA+KmdXSo TkQyzZb7cgUzJcOgDETog+Q7XX89wUlS5zzB0ob0p/AqDIrgfGqQPF9+rabFcIDFOshG0W WgTv3RbzBeU08WLY9QUwOvLpDOgOOw2vCvnAJIYCFWRSUJ/vM7e9U8U8gknyMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=UsgerkQJ/HhbA2AbXpANMMQuwJxS8UzMeOUa8nnw3cg=; b=qIM43iQoGCywG4fyfcL0617AiK0I9LgvnRCOzpI5eiGyRFKotQFqSDtvTo36EDtea4GmK0 pxON6r6oR5M491Ag== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 52/58] x86/apic: Replace acpi_wake_cpu_handler_update() and apic_set_eoi_cb() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:55 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716317799115808 X-GMAIL-MSGID: 1771716317799115808 Switch them over to apic_update_callback() and remove the code. Signed-off-by: Thomas Gleixner Reviewed-by: Wei Liu --- arch/x86/hyperv/hv_apic.c | 2 +- arch/x86/hyperv/hv_vtl.c | 2 +- arch/x86/include/asm/apic.h | 3 --- arch/x86/kernel/acpi/boot.c | 2 +- arch/x86/kernel/apic/init.c | 27 --------------------------- arch/x86/kernel/kvm.c | 2 +- 6 files changed, 4 insertions(+), 34 deletions(-) --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -310,7 +310,7 @@ void __init hv_apic_init(void) * lazy EOI when available, but the same accessor works for * both xapic and x2apic because the field layout is the same. */ - apic_set_eoi_cb(hv_apic_eoi_write); + apic_update_callback(eoi, hv_apic_eoi_write); if (!x2apic_enabled()) { apic->read = hv_apic_read; apic->write = hv_apic_write; --- a/arch/x86/hyperv/hv_vtl.c +++ b/arch/x86/hyperv/hv_vtl.c @@ -222,7 +222,7 @@ static int __init hv_vtl_early_init(void "Please add 'noxsave' to the kernel command line.\n"); real_mode_header = &hv_vtl_real_mode_header; - apic->wakeup_secondary_cpu_64 = hv_vtl_wakeup_secondary_cpu; + apic_update_callback(wakeup_secondary_cpu_64, hv_vtl_wakeup_secondary_cpu); return 0; } --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -417,8 +417,6 @@ static inline bool apic_id_valid(u32 api return apic_id <= apic->max_apic_id; } -extern void __init apic_set_eoi_cb(void (*eoi)(void)); - #else /* CONFIG_X86_LOCAL_APIC */ static inline u32 apic_read(u32 reg) { return 0; } @@ -474,7 +472,6 @@ static inline unsigned int read_apic_id( #ifdef CONFIG_X86_64 typedef int (*wakeup_cpu_handler)(int apicid, unsigned long start_eip); -extern void acpi_wake_cpu_handler_update(wakeup_cpu_handler handler); extern int default_acpi_madt_oem_check(char *, char *); extern void x86_64_probe_apic(void); #else --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1174,7 +1174,7 @@ static int __init acpi_parse_mp_wake(uni acpi_mp_wake_mailbox_paddr = mp_wake->base_address; - acpi_wake_cpu_handler_update(acpi_wakeup_cpu); + apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); return 0; } --- a/arch/x86/kernel/apic/init.c +++ b/arch/x86/kernel/apic/init.c @@ -55,30 +55,3 @@ void __init apic_install_driver(struct a pr_info("Switched APIC routing to: %s\n", driver->name); } - -#ifdef CONFIG_X86_64 -void __init acpi_wake_cpu_handler_update(wakeup_cpu_handler handler) -{ - struct apic **drv; - - for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) - (*drv)->wakeup_secondary_cpu_64 = handler; -} -#endif - -/* - * Override the generic EOI implementation with an optimized version. - * Only called during early boot when only one CPU is active and with - * interrupts disabled, so we know this does not race with actual APIC driver - * use. - */ -void __init apic_set_eoi_cb(void (*eoi)(void)) -{ - struct apic **drv; - - for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) { - /* Should happen once for each apic */ - WARN_ON((*drv)->eoi == eoi); - (*drv)->eoi = eoi; - } -} --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -825,7 +825,7 @@ static void __init kvm_guest_init(void) } if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) - apic_set_eoi_cb(kvm_guest_apic_eoi_write); + apic_update_callback(eoi, kvm_guest_apic_eoi_write); if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF_INT) && kvmapf) { static_branch_enable(&kvm_async_pf_enabled); From patchwork Mon Jul 17 23:15:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406850vqt; Mon, 17 Jul 2023 16:39:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzokHVQu8nmtt31BEHdNw0/285T998P5QWOLCIuhcNh9wB5AlNwQrxEG3Os4P/8OCqd0OA X-Received: by 2002:a05:6830:32aa:b0:6b9:27ae:d2fa with SMTP id m42-20020a05683032aa00b006b927aed2famr9549321ott.15.1689637169861; Mon, 17 Jul 2023 16:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637169; cv=none; d=google.com; s=arc-20160816; b=apisfbSyI81vl+NVG1eCsVek+E7vd9W2OmyA/ZKleaQYGGxIvuILk+LKPSVPrYTQcE M029rTm/4Iu866+sGETFm7suiEgh0YOlXXJPAHLivcbore8QmDyfrsKHc7KvtxB4OO5V bGR+UAa/kAteJTchWbTaGZ2k0uLQBQ/3GhZRfzfOub1HW8GtLiPui+vxJbCkE/a/xoq0 D+ByturLFokh1ezYoRBr/S6Pm8rp+OCouI2gcK48InYidQFBiA4SQq2a3E8VhR9Tf0Sa lpVoJAjzMueYjrd7DMdpZ5YVQ+dmvzDxNZJDqWYkA7MrKYkqiDMPaFnuxx3sBTBBjmCY OuIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=wkf9cxbN9yugedivD8sL7QgWMpf0hUBTEyuN6MHJ80U=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=VaFUs41Bqjgs+CWdhF8OJzI1HoG6Y1KPHR3gJ/2EtNagih/HpuenQuy9SGWV04rbuf nuC+Aig04nIuoNin5Cq7yDGXH1paSC5a7kJT6HvfV2mmuyn7ukepqCmDZIahldJeHKYT M7vhL1oZ6eFchBi0+rPGqIF6lzkIK/06OVoEA9J5dMzsOfAiWxW8QryW8na83/KzBegc UdFPeoFuCuU3Hr1FR6m3Ot1o5bCsKSjPONSKmXveVFWKwg/7p6hNL7qDDeigyxopfZDt Y0h9xMnaXPumygj8DGpQqF7D0gnYektZrsuQUa2QYnIrgQLhwr0HEJYTgzE5GTynTxy6 1aWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=coF5HZJV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="y/kUV7th"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 185-20020a6300c2000000b005347c4d09ddsi538054pga.678.2023.07.17.16.39.16; Mon, 17 Jul 2023 16:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=coF5HZJV; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="y/kUV7th"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbjGQXVa (ORCPT + 99 others); Mon, 17 Jul 2023 19:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjGQXV2 (ORCPT ); Mon, 17 Jul 2023 19:21:28 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 718FE10E6 for ; Mon, 17 Jul 2023 16:20:51 -0700 (PDT) Message-ID: <20230717223226.237896259@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wkf9cxbN9yugedivD8sL7QgWMpf0hUBTEyuN6MHJ80U=; b=coF5HZJV4lqAYCOI0x2G+gk1jggvNOUYFRaiSC7p/lKyOLLZKnfZMXpV86Hyn3lXE5+VHp ybatAk06keDr7f3cuz22LBVPV7vGXEC/je7DzSUqVT5cqV/pToJLetgUyeZONbZFsMkXQQ JL0FFUava8lwobIOamFi5GMpID/VSIfgyySgc6iUqWrtByMo43awM7eC4xhuO8THhQgHi+ FDaXyFMES6qzHokM53hTbATJBbpXiB4E3q14zvPXr0qMViaGoC6IFP/pbAFtsXyZ0ScrbL sWQEixc98e+h8HPq6I0pYyHBSX2dY1LzBn8GwatXXzRx/9Wq7xi7uEKgZdOx9Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=wkf9cxbN9yugedivD8sL7QgWMpf0hUBTEyuN6MHJ80U=; b=y/kUV7th0yY9Sc72a2b6dJKP+HSWRlwG2D6jYUjXl1y5Fqw1sVZdtT0jMk4c2hQKvkzOpX BA2Ixn/NetWpRVAg== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 53/58] x86/apic: Convert other overrides to apic_update_callback() References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:57 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712985187308965 X-GMAIL-MSGID: 1771712985187308965 Convert all places which just assign a new function directly to the apic callback to use apic_update_callback() which prepares for using static calls. Signed-off-by: Thomas Gleixner --- arch/x86/hyperv/hv_apic.c | 20 ++++++++++---------- arch/x86/kernel/kvm.c | 4 ++-- arch/x86/kernel/sev.c | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -288,12 +288,12 @@ void __init hv_apic_init(void) */ orig_apic = *apic; - apic->send_IPI = hv_send_ipi; - apic->send_IPI_mask = hv_send_ipi_mask; - apic->send_IPI_mask_allbutself = hv_send_ipi_mask_allbutself; - apic->send_IPI_allbutself = hv_send_ipi_allbutself; - apic->send_IPI_all = hv_send_ipi_all; - apic->send_IPI_self = hv_send_ipi_self; + apic_update_callback(send_IPI, hv_send_ipi); + apic_update_callback(send_IPI_mask, hv_send_ipi_mask); + apic_update_callback(send_IPI_mask_allbutself, hv_send_ipi_mask_allbutself); + apic_update_callback(send_IPI_allbutself, hv_send_ipi_allbutself); + apic_update_callback(send_IPI_all, hv_send_ipi_all); + apic_update_callback(send_IPI_self, hv_send_ipi_self); } if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) { @@ -312,10 +312,10 @@ void __init hv_apic_init(void) */ apic_update_callback(eoi, hv_apic_eoi_write); if (!x2apic_enabled()) { - apic->read = hv_apic_read; - apic->write = hv_apic_write; - apic->icr_write = hv_apic_icr_write; - apic->icr_read = hv_apic_icr_read; + apic_update_callback(read, hv_apic_read); + apic_update_callback(write, hv_apic_write); + apic_update_callback(icr_write, hv_apic_icr_write); + apic_update_callback(icr_read, hv_apic_icr_read); } } } --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -624,8 +624,8 @@ late_initcall(setup_efi_kvm_sev_migratio */ static void kvm_setup_pv_ipi(void) { - apic->send_IPI_mask = kvm_send_ipi_mask; - apic->send_IPI_mask_allbutself = kvm_send_ipi_mask_allbutself; + apic_update_callback(send_IPI_mask, kvm_send_ipi_mask); + apic_update_callback(send_IPI_mask_allbutself, kvm_send_ipi_mask_allbutself); pr_info("setup PV IPIs\n"); } --- a/arch/x86/kernel/sev.c +++ b/arch/x86/kernel/sev.c @@ -1099,7 +1099,7 @@ void snp_set_wakeup_secondary_cpu(void) * required method to start APs under SNP. If the hypervisor does * not support AP creation, then no APs will be started. */ - apic->wakeup_secondary_cpu = wakeup_cpu_via_vmgexit; + apic_update_callback(wakeup_secondary_cpu, wakeup_cpu_via_vmgexit); } int __init sev_es_setup_ap_jump_table(struct real_mode_header *rmh) From patchwork Mon Jul 17 23:15:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406944vqt; Mon, 17 Jul 2023 16:39:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfzW8m2xUqnis9tY7rtOrB02uyoGQNNZwPUS2UwHT7AkIX6ZsmdAvb4Ge4pd75GECh1ofh X-Received: by 2002:a9d:6e0e:0:b0:6b8:9705:5035 with SMTP id e14-20020a9d6e0e000000b006b897055035mr1088656otr.33.1689637185557; Mon, 17 Jul 2023 16:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637185; cv=none; d=google.com; s=arc-20160816; b=xnToWWRPJXgKbIOp/ir23juJ7z35nMxJMT3ktulNrO92nPN5wlkcVtN6q56vgpTrr/ chgh89oNEpM5UH0Pm8Z5Y+gkpGejcv0wEJxETvyQmv1ec+esLvCN6U1ZaNFEyaE8kkdV UbhgK+Ss069zgxJIdwSiyIrlXkjMs066pJ8lDqklQ7SohsyQxDzH2v0emRPm3L4Wc+ze 6h5k1kgyb7xBYhpTArGZun791WYvPj2CUSjTS9A9mY6Mo97/VQ6CW5zkCNzxYaUrScPF om/WPSQdsd6PKZwFXxshXcVYHiLjExREjGkDvKd07PKLh7EQaMpO35yAjpIY4A5FVhkr HQ3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=cOCeYzZlZQBijmmlwD90S/EyiYlmy0xrZba4W3Pw3yw=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=C3u98rLGUqEQqGZICcG5umBMXZsAKsxaR3dKOK1TjgWCfOXzpQ3Ptku4pqp79Imx2G 4y6SgNqIkEmWjlUp7S82bzLQZdkNIn/FQhPqG40YMP1zFhzoHgiIwBeCrbte2zAaWn/Q BKkk9Mi9m6RBr8p5Pmx92Mgx30wXiuDm9teWDcwBxrYjaXH9nJRrqMR2Y6NBelZj+p+B ShhmvVG6zwp+/XnqjTOvBHjxJPM0d92YQgdif+5QTjXf5YJoCuv2ItiHGHCxteHLrjQS wMJvL3skBqBwuBN+bc8FYKIjIZro0OrEYEsoj6XVQdpTlUAoo+LFqoItjoOkrblum3UM CI7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gaLKj7OK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/0Z+SKoU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a631c11000000b0055785aa5282si545540pgc.81.2023.07.17.16.39.32; Mon, 17 Jul 2023 16:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gaLKj7OK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="/0Z+SKoU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231534AbjGQXUq (ORCPT + 99 others); Mon, 17 Jul 2023 19:20:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231526AbjGQXUp (ORCPT ); Mon, 17 Jul 2023 19:20:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D686134 for ; Mon, 17 Jul 2023 16:20:00 -0700 (PDT) Message-ID: <20230717223226.297124390@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cOCeYzZlZQBijmmlwD90S/EyiYlmy0xrZba4W3Pw3yw=; b=gaLKj7OKk74d7dKsCAAq7iQL33bF5KOQHpAirffn2nbDIIuBzBtnshkDVGTF32x1xIVXfT LX3O50t4S2wv9IHgf3zrr5gdye+KbDjqzKwAuwiT0zbljANQHJyiJmNm7Qr1V8hP31xQWa bZbK89/vR5cpBemdihkFd0b+8ZAZ1qKKdgsbMR+/eLUdbZBb5t87k8C6sNYIcnutq3UACy T8YUZMvV7eihKLODdI2+oRaEXmt7rLdAzXfmXxDnAdScRZaIxI4thHsPEY6xJtZ2Qrt8IG yOOK9KXY4jTB02SimLzFHp8GNC45fVqza5ArahhrQjrcAMkODa0OeJAYNCIAxA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=cOCeYzZlZQBijmmlwD90S/EyiYlmy0xrZba4W3Pw3yw=; b=/0Z+SKoUfHQfzCGrNIiYa+mNxhfgHweJlWYXN3rENFQkGK2JhDXuQhwiFm+3p08Oy+yRgU R2Tg+Nr2LiXSuyDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 54/58] x86/xen/apic: Mark apic __ro_after_init References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:15:58 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771713001335446449 X-GMAIL-MSGID: 1771713001335446449 Nothing can change it post init. While at it mop up the whitespace damage which causes eyebleed due to an editor which is highlighting it. Signed-off-by: Thomas Gleixner Cc: Juergen Gross --- arch/x86/xen/apic.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) --- a/arch/x86/xen/apic.c +++ b/arch/x86/xen/apic.c @@ -123,9 +123,9 @@ static int xen_cpu_present_to_apicid(int return BAD_APICID; } -static struct apic xen_pv_apic = { - .name = "Xen PV", - .probe = xen_apic_probe_pv, +static struct apic xen_pv_apic __ro_after_init = { + .name = "Xen PV", + .probe = xen_apic_probe_pv, .acpi_madt_oem_check = xen_madt_oem_check, /* .delivery_mode and .dest_mode_logical not used by XENPV */ @@ -138,24 +138,24 @@ static struct apic xen_pv_apic = { .phys_pkg_id = xen_phys_pkg_id, /* detect_ht */ .max_apic_id = UINT_MAX, - .get_apic_id = xen_get_apic_id, - .set_apic_id = xen_set_apic_id, /* Can be NULL on 32-bit. */ + .get_apic_id = xen_get_apic_id, + .set_apic_id = xen_set_apic_id, /* Can be NULL on 32-bit. */ .calc_dest_apicid = apic_flat_calc_apicid, #ifdef CONFIG_SMP - .send_IPI_mask = xen_send_IPI_mask, - .send_IPI_mask_allbutself = xen_send_IPI_mask_allbutself, - .send_IPI_allbutself = xen_send_IPI_allbutself, - .send_IPI_all = xen_send_IPI_all, - .send_IPI_self = xen_send_IPI_self, + .send_IPI_mask = xen_send_IPI_mask, + .send_IPI_mask_allbutself = xen_send_IPI_mask_allbutself, + .send_IPI_allbutself = xen_send_IPI_allbutself, + .send_IPI_all = xen_send_IPI_all, + .send_IPI_self = xen_send_IPI_self, #endif .read = xen_apic_read, .write = xen_apic_write, .eoi = xen_apic_eoi, - .icr_read = xen_apic_icr_read, - .icr_write = xen_apic_icr_write, + .icr_read = xen_apic_icr_read, + .icr_write = xen_apic_icr_write, }; static void __init xen_apic_check(void) From patchwork Mon Jul 17 23:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121701 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1426449vqt; Mon, 17 Jul 2023 17:33:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlETf7zeg1/rfOpUNQKB1bGeuiYZMuddoDK1OLcLT2WcnXJl7V+zAhDCSEkS/xQrZaSjJOQ+ X-Received: by 2002:a17:90a:c7:b0:25b:d4bc:28d4 with SMTP id v7-20020a17090a00c700b0025bd4bc28d4mr11999425pjd.40.1689640403819; Mon, 17 Jul 2023 17:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640403; cv=none; d=google.com; s=arc-20160816; b=Q4DN2TGgPUQLNofRbU3SWeqBiywhwQOwuEKzJyjni8c9UtvDD+VfR8FuCpCGg+UJYZ LsrjdNpC0D3wHR/q9B1q/I3DY649b9s1nzXNdiTUpXNtPHET92PXD3z5fxb9no8+sIX8 rsrYO0i7qwypbtii0Xl3P+cIkOsbVzBsoN5vImXtZTQJJBT7R00ketyV5AeZTblNqozU kWEo85UVzn00oQJTtCI66iE7qsjvKd1ubbxUKYhhkcV3GXSiAHVzG4eLi4fNZBm9rTzF Ca+NukuJzTHqg2NcGGSKUMGbyeiERf2TpZe2Fxh3/OM98NCgcRAYQGsUHhmikYX2wjIx ccgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=uX/kplLo5CTyEGcDpdLq/uLjlYQ837jWRls5Fa0d2bQ=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=AykVC3j5iqBqNwpsj10Cyc8RVp9fx5qR6R4tC3aT820QFcfqfPnD3b3ma/79HyiDrw mTmJajKVQFHqxG0KCT7gcJgyckhFqQYQkxk6R1MtRQcZRd6fJqaqj7Fi9Zg+O54FdMhE vjRINSpdhodT4IsCONQMeSeLw7BMHUpZOAI7YH9u9ktQSPOsGfUsGyEsGJlEwa6XWcpf ej/Cn3qyXLt7laBm2WKrWJAKOgOmIqN9sbVLvLbzKX8NDfrXnOwpG7KI930QY8QPZWoh zZlAOPRbuIXgqNt7RfUy0wxSmD6gHMZnDOGrZgUDaureLa7T+1XEmHtMkeOnhZ0b3rpn z4kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="V2g8TK5/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gd16-20020a17090b0fd000b0025c0784b6f4si671642pjb.144.2023.07.17.17.33.11; Mon, 17 Jul 2023 17:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="V2g8TK5/"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjGQXhB (ORCPT + 99 others); Mon, 17 Jul 2023 19:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbjGQXgx (ORCPT ); Mon, 17 Jul 2023 19:36:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5047171B for ; Mon, 17 Jul 2023 16:36:07 -0700 (PDT) Message-ID: <20230717223226.358014177@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=uX/kplLo5CTyEGcDpdLq/uLjlYQ837jWRls5Fa0d2bQ=; b=V2g8TK5/irCDXKjbQaXb1r7SKbrw79jOasZOrc22otmaawYm41oZ4SIYN0FoOb0YNp7rBT GBHawf+UV+/eGE0x/Ibnd426wPBM8PnMKgmDkWPpU1u0xd1pPNJJnmAFjJWudkI07Z1qBN AwfO+tH823Q4kD89cPbCZG3yWVHLDW8taIfeioZdloikGhfK9EaWh0KkpoHpqXVup82ZJT aSDoHi3jbBIsOeJt/WSyaMcX++jfPTHLJlXgfgJlcYk4kK8epMcgNwfT75FLfiSdDdTU5Z AipS3khCPFaeLx+j0Cd4sch+8CN00fp3FFf2ALcvZTEw6Zncv9Q3j43krlN9hg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=uX/kplLo5CTyEGcDpdLq/uLjlYQ837jWRls5Fa0d2bQ=; b=n7YW14HMPXk/VX1uLMyjlSyd8+xVN0NXKSd1Rst1vDJXz9Qo+q06d7afU296MK6NMy4Wu/ WedSjnxQNdt/fPDw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 55/58] x86/apic: Mark all hotpath APIC callback wrappers __always_inline References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:16:00 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716375965642466 X-GMAIL-MSGID: 1771716375965642466 There is no value for instrumentation to look at those wrappers and with the upcoming conversion to static calls even less so. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -370,62 +370,62 @@ void __init apic_install_driver(struct a pr_info("APIC::%s() replaced with %ps()\n", #_callback, _fn); \ } -static inline u32 apic_read(u32 reg) +static __always_inline u32 apic_read(u32 reg) { return apic->read(reg); } -static inline void apic_write(u32 reg, u32 val) +static __always_inline void apic_write(u32 reg, u32 val) { apic->write(reg, val); } -static inline void apic_eoi(void) +static __always_inline void apic_eoi(void) { apic->eoi(); } -static inline void apic_native_eoi(void) +static __always_inline void apic_native_eoi(void) { apic->native_eoi(); } -static inline u64 apic_icr_read(void) +static __always_inline u64 apic_icr_read(void) { return apic->icr_read(); } -static inline void apic_icr_write(u32 low, u32 high) +static __always_inline void apic_icr_write(u32 low, u32 high) { apic->icr_write(low, high); } -static inline void apic_wait_icr_idle(void) +static __always_inline void apic_wait_icr_idle(void) { if (apic->wait_icr_idle) apic->wait_icr_idle(); } -static inline u32 safe_apic_wait_icr_idle(void) +static __always_inline u32 safe_apic_wait_icr_idle(void) { return apic->safe_wait_icr_idle ? apic->safe_wait_icr_idle() : 0; } -static inline bool apic_id_valid(u32 apic_id) +static __always_inline bool apic_id_valid(u32 apic_id) { return apic_id <= apic->max_apic_id; } #else /* CONFIG_X86_LOCAL_APIC */ -static inline u32 apic_read(u32 reg) { return 0; } -static inline void apic_write(u32 reg, u32 val) { } -static inline void apic_eoi(void) { } -static inline u64 apic_icr_read(void) { return 0; } -static inline void apic_icr_write(u32 low, u32 high) { } -static inline void apic_wait_icr_idle(void) { } -static inline u32 safe_apic_wait_icr_idle(void) { return 0; } -static inline void apic_set_eoi(void (*eoi)(void)) {} +static __always_inline u32 apic_read(u32 reg) { return 0; } +static __always_inline void apic_write(u32 reg, u32 val) { } +static __always_inline void apic_eoi(void) { } +static __always_inline u64 apic_icr_read(void) { return 0; } +static __always_inline void apic_icr_write(u32 low, u32 high) { } +static __always_inline void apic_wait_icr_idle(void) { } +static __always_inline u32 safe_apic_wait_icr_idle(void) { return 0; } +static __always_inline void apic_set_eoi(void (*eoi)(void)) {} #endif /* CONFIG_X86_LOCAL_APIC */ From patchwork Mon Jul 17 23:16:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121703 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1427703vqt; Mon, 17 Jul 2023 17:36:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEh1BwOpsg8dYVngn18qui+azipNBSM3iFjWYUzeV/Wr0npds5bLnoaZKBm/6bIt9UIBj0f X-Received: by 2002:a17:90a:6349:b0:25e:f696:1cf8 with SMTP id v9-20020a17090a634900b0025ef6961cf8mr14013079pjs.14.1689640608685; Mon, 17 Jul 2023 17:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640608; cv=none; d=google.com; s=arc-20160816; b=E5Yk08vvW61WhgJ1SBCNW0e2XdRNvYiamBsecckE/y9rfNZXn/Gd+H0dAQ359WwAu4 4L/Px1AeZSWGdbxLv4dj3sFPB3865otIOJ2CDtp5bM4PebVs7TJEngkH6GEE6HQJ13t+ 6UZx5v1aG9f1Ug1dY/qIRQXA4dIw7O7yb/aXOhdNIsJ8MeFj2ZUb/QfVnA9WaQGcJSJx iQMu9lIUlIIUuVys6mHJiHgsF8s7p4FEWOu9zjRloZkyKC4aIW3zPEW+2d5kx9ksa5JQ F6YKTzcDNeU0TERV+04Qihr+1ZX1rke73K9Lu4lxx6AgSTSvLylzu+OohiqAw6t6UoZ4 0GHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=yZ0mIAoyX+o+dAiLvWiSm6ygjzxrkLfGxB3sGPnAg2c=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=V3gXuZR3CWB/T36fWWFQcdq62FbBKAgPL+6BCjGS0mcEusLB3yyxQiV6sETW2OEbA/ g/LXdaVaoIFmoHioYvjN6nq62I8pgHrf7AhmS5T6lp+XQ0GNw7bJBXuNy46vLr5IouCb K6zhbgBARnt3WF+DLZp2pklsVNhnCWieASisJWqtkxqx+4IiCo5MkHeEWQ63A63NC+eI /HnC/ffOb5xk0X5SuxT6j5S22EyzlmBs1hHrKOZI+gy1Q2/352bN+sU8iKGM6SD68iYu 3BK13xd7zdsUPFsbZR7RbcuGzbA+nD3BWReg7sPh5FnoNxiPQjOpGAbyBMybW9zFOhv0 +Sog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=j37UAfGl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2ekXGJoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce19-20020a17090aff1300b002613720fcd5si6534139pjb.35.2023.07.17.17.36.35; Mon, 17 Jul 2023 17:36:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=j37UAfGl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=2ekXGJoz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231688AbjGQXgw (ORCPT + 99 others); Mon, 17 Jul 2023 19:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbjGQXgp (ORCPT ); Mon, 17 Jul 2023 19:36:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91E7E48 for ; Mon, 17 Jul 2023 16:35:56 -0700 (PDT) Message-ID: <20230717223226.417564255@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=yZ0mIAoyX+o+dAiLvWiSm6ygjzxrkLfGxB3sGPnAg2c=; b=j37UAfGl4374PyDMfypHyFZr6u6FXj8Ubc7/jU0U6EzVKvE3VQLhnt5OX6sze5a/o9hJrO NBqQ2wsjnb0rg1qKLks034DHjvhiADDLKNFnBT2D88L8vudqk58u/uXS1SrGyPPRe1Mb0D Cc7RI5G1SS7UPZ7F5qS97y24ZyrIw7LKIlnNxMMMnS/DehhdtBCibL0JNs9GSnew8WYPwy 89Tb8dye/mnCrid+CpXC6NFJ4meINN+7LBV1Iio2vs1sck1gfsWngXZ2agOomzLZMkSqcX FZxAXeSeicpu1YjlFkPWNkUoIy1ZywbDRyQKpmGwIJQI+vm77UMniH4GkqsZGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=yZ0mIAoyX+o+dAiLvWiSm6ygjzxrkLfGxB3sGPnAg2c=; b=2ekXGJoztTgdFaxyYJhCvroYnfM6VbnkFbiqK3VbgT2e5qfM8ryqXyv0hO3IlLE8STOBiA 6W68dvkp0I9SiKCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 56/58] x86/apic: Wrap IPI calls into helper functions References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:16:01 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771716590955251379 X-GMAIL-MSGID: 1771716590955251379 Move them to one place so the static call conversion gets simpler. No functional change. Signed-off-by: Thomas Gleixner --- arch/x86/hyperv/hv_spinlock.c | 2 +- arch/x86/include/asm/apic.h | 30 ++++++++++++++++++++++++++++++ arch/x86/kernel/apic/apic.c | 2 +- arch/x86/kernel/apic/hw_nmi.c | 4 +++- arch/x86/kernel/apic/ipi.c | 16 ++++++++-------- arch/x86/kernel/apic/vector.c | 6 +++--- arch/x86/kernel/cpu/mce/inject.c | 3 +-- arch/x86/kernel/irq_work.c | 2 +- arch/x86/kernel/nmi_selftest.c | 2 +- arch/x86/kernel/smp.c | 2 +- arch/x86/kvm/vmx/posted_intr.c | 2 +- arch/x86/kvm/vmx/vmx.c | 2 +- arch/x86/platform/uv/uv_nmi.c | 2 +- 13 files changed, 53 insertions(+), 22 deletions(-) --- a/arch/x86/hyperv/hv_spinlock.c +++ b/arch/x86/hyperv/hv_spinlock.c @@ -20,7 +20,7 @@ static bool __initdata hv_pvspin = true; static void hv_qlock_kick(int cpu) { - apic->send_IPI(cpu, X86_PLATFORM_IPI_VECTOR); + __apic_send_IPI(cpu, X86_PLATFORM_IPI_VECTOR); } static void hv_qlock_wait(u8 *byte, u8 val) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -401,6 +401,36 @@ static __always_inline void apic_icr_wri apic->icr_write(low, high); } +static __always_inline void __apic_send_IPI(int cpu, int vector) +{ + apic->send_IPI(cpu, vector); +} + +static __always_inline void __apic_send_IPI_mask(const struct cpumask *mask, int vector) +{ + apic->send_IPI_mask(mask, vector); +} + +static __always_inline void __apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) +{ + apic->send_IPI_mask_allbutself(mask, vector); +} + +static __always_inline void __apic_send_IPI_allbutself(int vector) +{ + apic->send_IPI_allbutself(vector); +} + +static __always_inline void __apic_send_IPI_all(int vector) +{ + apic->send_IPI_all(vector); +} + +static __always_inline void __apic_send_IPI_self(int vector) +{ + apic->send_IPI_self(vector); +} + static __always_inline void apic_wait_icr_idle(void) { if (apic->wait_icr_idle) --- a/arch/x86/kernel/apic/apic.c +++ b/arch/x86/kernel/apic/apic.c @@ -502,7 +502,7 @@ static int lapic_timer_set_oneshot(struc static void lapic_timer_broadcast(const struct cpumask *mask) { #ifdef CONFIG_SMP - apic->send_IPI_mask(mask, LOCAL_TIMER_VECTOR); + __apic_send_IPI_mask(mask, LOCAL_TIMER_VECTOR); #endif } --- a/arch/x86/kernel/apic/hw_nmi.c +++ b/arch/x86/kernel/apic/hw_nmi.c @@ -21,6 +21,8 @@ #include #include +#include "local.h" + #ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF u64 hw_nmi_get_sample_period(int watchdog_thresh) { @@ -31,7 +33,7 @@ u64 hw_nmi_get_sample_period(int watchdo #ifdef arch_trigger_cpumask_backtrace static void nmi_raise_cpu_backtrace(cpumask_t *mask) { - apic->send_IPI_mask(mask, NMI_VECTOR); + __apic_send_IPI_mask(mask, NMI_VECTOR); } void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) --- a/arch/x86/kernel/apic/ipi.c +++ b/arch/x86/kernel/apic/ipi.c @@ -54,9 +54,9 @@ void apic_send_IPI_allbutself(unsigned i return; if (static_branch_likely(&apic_use_ipi_shorthand)) - apic->send_IPI_allbutself(vector); + __apic_send_IPI_allbutself(vector); else - apic->send_IPI_mask_allbutself(cpu_online_mask, vector); + __apic_send_IPI_mask_allbutself(cpu_online_mask, vector); } /* @@ -70,12 +70,12 @@ void native_smp_send_reschedule(int cpu) WARN(1, "sched: Unexpected reschedule of offline CPU#%d!\n", cpu); return; } - apic->send_IPI(cpu, RESCHEDULE_VECTOR); + __apic_send_IPI(cpu, RESCHEDULE_VECTOR); } void native_send_call_func_single_ipi(int cpu) { - apic->send_IPI(cpu, CALL_FUNCTION_SINGLE_VECTOR); + __apic_send_IPI(cpu, CALL_FUNCTION_SINGLE_VECTOR); } void native_send_call_func_ipi(const struct cpumask *mask) @@ -87,14 +87,14 @@ void native_send_call_func_ipi(const str goto sendmask; if (cpumask_test_cpu(cpu, mask)) - apic->send_IPI_all(CALL_FUNCTION_VECTOR); + __apic_send_IPI_all(CALL_FUNCTION_VECTOR); else if (num_online_cpus() > 1) - apic->send_IPI_allbutself(CALL_FUNCTION_VECTOR); + __apic_send_IPI_allbutself(CALL_FUNCTION_VECTOR); return; } sendmask: - apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR); + __apic_send_IPI_mask(mask, CALL_FUNCTION_VECTOR); } #endif /* CONFIG_SMP */ @@ -221,7 +221,7 @@ void default_send_IPI_mask_allbutself_ph */ void default_send_IPI_single(int cpu, int vector) { - apic->send_IPI_mask(cpumask_of(cpu), vector); + __apic_send_IPI_mask(cpumask_of(cpu), vector); } void default_send_IPI_allbutself(int vector) --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -876,7 +876,7 @@ static int apic_retrigger_irq(struct irq unsigned long flags; raw_spin_lock_irqsave(&vector_lock, flags); - apic->send_IPI(apicd->cpu, apicd->vector); + __apic_send_IPI(apicd->cpu, apicd->vector); raw_spin_unlock_irqrestore(&vector_lock, flags); return 1; @@ -958,7 +958,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_c */ irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); if (irr & (1U << (vector % 32))) { - apic->send_IPI_self(IRQ_MOVE_CLEANUP_VECTOR); + __apic_send_IPI_self(IRQ_MOVE_CLEANUP_VECTOR); continue; } free_moved_vector(apicd); @@ -976,7 +976,7 @@ static void __send_cleanup_vector(struct cpu = apicd->prev_cpu; if (cpu_online(cpu)) { hlist_add_head(&apicd->clist, per_cpu_ptr(&cleanup_list, cpu)); - apic->send_IPI(cpu, IRQ_MOVE_CLEANUP_VECTOR); + __apic_send_IPI(cpu, IRQ_MOVE_CLEANUP_VECTOR); } else { apicd->prev_vector = 0; } --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -270,8 +270,7 @@ static void __maybe_unused raise_mce(str mce_irq_ipi, NULL, 0); preempt_enable(); } else if (m->inject_flags & MCJ_NMI_BROADCAST) - apic->send_IPI_mask(mce_inject_cpumask, - NMI_VECTOR); + __apic_send_IPI_mask(mce_inject_cpumask, NMI_VECTOR); } start = jiffies; while (!cpumask_empty(mce_inject_cpumask)) { --- a/arch/x86/kernel/irq_work.c +++ b/arch/x86/kernel/irq_work.c @@ -28,7 +28,7 @@ void arch_irq_work_raise(void) if (!arch_irq_work_has_interrupt()) return; - apic->send_IPI_self(IRQ_WORK_VECTOR); + __apic_send_IPI_self(IRQ_WORK_VECTOR); apic_wait_icr_idle(); } #endif --- a/arch/x86/kernel/nmi_selftest.c +++ b/arch/x86/kernel/nmi_selftest.c @@ -75,7 +75,7 @@ static void __init test_nmi_ipi(struct c /* sync above data before sending NMI */ wmb(); - apic->send_IPI_mask(mask, NMI_VECTOR); + __apic_send_IPI_mask(mask, NMI_VECTOR); /* Don't wait longer than a second */ timeout = USEC_PER_SEC; --- a/arch/x86/kernel/smp.c +++ b/arch/x86/kernel/smp.c @@ -237,7 +237,7 @@ static void native_stop_other_cpus(int w pr_emerg("Shutting down cpus with NMI\n"); for_each_cpu(cpu, &cpus_stop_mask) - apic->send_IPI(cpu, NMI_VECTOR); + __apic_send_IPI(cpu, NMI_VECTOR); } /* * Don't wait longer than 10 ms if the caller didn't --- a/arch/x86/kvm/vmx/posted_intr.c +++ b/arch/x86/kvm/vmx/posted_intr.c @@ -175,7 +175,7 @@ static void pi_enable_wakeup_handler(str * scheduled out). */ if (pi_test_on(&new)) - apic->send_IPI_self(POSTED_INTR_WAKEUP_VECTOR); + __apic_send_IPI_self(POSTED_INTR_WAKEUP_VECTOR); local_irq_restore(flags); } --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4147,7 +4147,7 @@ static inline void kvm_vcpu_trigger_post */ if (vcpu != kvm_get_running_vcpu()) - apic->send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec); + __apic_send_IPI_mask(get_cpu_mask(vcpu->cpu), pi_vec); return; } #endif --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -601,7 +601,7 @@ static void uv_nmi_nr_cpus_ping(void) for_each_cpu(cpu, uv_nmi_cpu_mask) uv_cpu_nmi_per(cpu).pinging = 1; - apic->send_IPI_mask(uv_nmi_cpu_mask, APIC_DM_NMI); + __apic_send_IPI_mask(uv_nmi_cpu_mask, APIC_DM_NMI); } /* Clean up flags for CPU's that ignored both NMI and ping */ From patchwork Mon Jul 17 23:16:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121661 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1405082vqt; Mon, 17 Jul 2023 16:33:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHdH5rBZFogsbWjxe8Q++EpXbmlXc+WMWAnssz/MRl/yaKZh/WbhzatolKfrCYFnrpqwjT4 X-Received: by 2002:a05:6a21:6da3:b0:135:6ef6:17f with SMTP id wl35-20020a056a216da300b001356ef6017fmr858523pzb.43.1689636831231; Mon, 17 Jul 2023 16:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689636831; cv=none; d=google.com; s=arc-20160816; b=SY75cqvbBwZ+eF0F2+JbYkcNQIE4Zq4bXsxK90wISwl/aJPXNMTeOR4hrB2DYI4uNN Bhf8PiLAaoPOzNAjsJNIWzDVqfaPU3eqHAO4tPEbRNttKQ5iqM50Zizm22UbD2lnK43I Gu+WNeHddpHepl+Ob38VFg79Z8xNtxhRQqYP2zeRjaNHvA/CmmYGtYpD52tqXjHmuvVq jUxPF6J7MdkzFXyY5b/5OUSrTo/Hs5lRWko0K6OpLnyehtjyACtgBASh3IOFTsgW7A3y rA7M9yOx04t9kLM3TzLIeM8phMhAo5VsRN/VDrv/Wzl/zJPfwS7BWrtPHEGPmgyvAnv6 k1og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=uvvFxpQ0CI+6SWZBIuqun6zkxQpCJ5cWHxgeYGNpJp4=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=qpdQtWJJ8xkf9j0JM8JeSrzDFZ+2VFET3cYrMw15vCJEtCmZMk2H05TA+Ryr4U2/Mn C/VkqQc9DGKjWdJqMaQK1DCCAUvoVjOl564VDQ33uQX4H5sVqqaWA7I03V0QIIjhytW7 kwHLm1TjTR7hRYY+upw3l88A7BdoPuWuUU3nXS837bfGSWPh6lt1J2DbNS0Em/9PyDHN JLMtQMGsgnA1QJAj5vT8flxTkIrBb+jfhE+SVfZdv1K/4gqxcqkmyThzp7WVj8i0SbxO RD/hN/cI1AhXBgB3v2UxcMGb9+0Ebz0PFiMtG7EwlGenkx6omWsGicqMoEajyWVvMwR5 1FiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R7XXJFQe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=St1HOkoM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw27-20020a056a00451b00b0068219eb27aesi545794pfb.182.2023.07.17.16.33.38; Mon, 17 Jul 2023 16:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=R7XXJFQe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=St1HOkoM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231549AbjGQXVv (ORCPT + 99 others); Mon, 17 Jul 2023 19:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231512AbjGQXVt (ORCPT ); Mon, 17 Jul 2023 19:21:49 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880A51985 for ; Mon, 17 Jul 2023 16:21:06 -0700 (PDT) Message-ID: <20230717223226.476875329@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=uvvFxpQ0CI+6SWZBIuqun6zkxQpCJ5cWHxgeYGNpJp4=; b=R7XXJFQedNE1ITW18jUJikCpSy2EgGM78+g7kuY4J0NjIBXiFLx9LG13GlCoP9aifrsJMh CkHjg1CL3GAAgS3MmlJwjnONKAxcs+AHjux4Ml2ZebTzy8UdjmoBVBqFH7/ZYm+qb58WAo JezrWWHQrlRDlazcIDxlruB2H4vUTLNxqWjaFf/Mr6SESYel0J229UdBhMXcR3VONNNb77 laMAJV5i92KoX4GLlbS13ZUzyP8DkrdFbp8Isq1LJ6Ov2rrLXcLfz/zYlsToU0XVFhep11 mWSU9XiaM43zP5Ues8OyNzyMHGU9mmEKVZcamIsrzMwGxZTuVwnUx3lihvDhjg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=uvvFxpQ0CI+6SWZBIuqun6zkxQpCJ5cWHxgeYGNpJp4=; b=St1HOkoMMFZWekCyT4k0WO5nKepjmvc+lUlUo1dPEnSWCYqOwWh1wMnaOMExWfWVsBY2uT D29BEcM7++KDrgCQ== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 57/58] x86/apic: Provide static call infrastructure for APIC callbacks References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:16:03 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712629945890932 X-GMAIL-MSGID: 1771712629945890932 Declare and define the static calls for the hotpath APIC callbacks. Note this deliberately uses STATIC_CALL_NULL() because otherwise it would be required to have the definitions in the 32bit and the 64bit default APIC implementations and it's hard to keep the calls in sync. The other option would be to have stub functions for each callback type. Not pretty either So the NULL capable calls are used and filled in during early boot after the static key infrastructure has been initialized. The calls will be static_call() except for the wait_irc_idle() callback which is valid to be NULL for X2APIC systems. Update the calls when a new APIC driver is installed and when a callback override is invoked. Export the trampolines for the two calls which are used in KVM and MCE error inject modules. Test the setup and let the next step convert the inline wrappers to make it effective. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 21 +++++++++++++++++++ arch/x86/kernel/apic/init.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -3,6 +3,7 @@ #define _ASM_X86_APIC_H #include +#include #include #include @@ -368,9 +369,29 @@ void __init apic_install_driver(struct a #define apic_update_callback(_callback, _fn) { \ __x86_apic_override._callback = _fn; \ apic->_callback = _fn; \ + static_call_update(apic_call_##_callback, _fn); \ pr_info("APIC::%s() replaced with %ps()\n", #_callback, _fn); \ } +#define DECLARE_APIC_CALL(__cb) \ + DECLARE_STATIC_CALL(apic_call_##__cb, *apic->__cb) + +DECLARE_APIC_CALL(eoi); +DECLARE_APIC_CALL(native_eoi); +DECLARE_APIC_CALL(icr_read); +DECLARE_APIC_CALL(icr_write); +DECLARE_APIC_CALL(read); +DECLARE_APIC_CALL(send_IPI); +DECLARE_APIC_CALL(send_IPI_mask); +DECLARE_APIC_CALL(send_IPI_mask_allbutself); +DECLARE_APIC_CALL(send_IPI_allbutself); +DECLARE_APIC_CALL(send_IPI_all); +DECLARE_APIC_CALL(send_IPI_self); +DECLARE_APIC_CALL(wait_icr_idle); +DECLARE_APIC_CALL(wakeup_secondary_cpu); +DECLARE_APIC_CALL(wakeup_secondary_cpu_64); +DECLARE_APIC_CALL(write); + static __always_inline u32 apic_read(u32 reg) { return apic->read(reg); --- a/arch/x86/kernel/apic/init.c +++ b/arch/x86/kernel/apic/init.c @@ -5,6 +5,28 @@ #include "local.h" +#define DEFINE_APIC_CALL(__cb) \ + DEFINE_STATIC_CALL_NULL(apic_call_##__cb, *apic->__cb) + +DEFINE_APIC_CALL(eoi); +DEFINE_APIC_CALL(native_eoi); +DEFINE_APIC_CALL(icr_read); +DEFINE_APIC_CALL(icr_write); +DEFINE_APIC_CALL(read); +DEFINE_APIC_CALL(send_IPI); +DEFINE_APIC_CALL(send_IPI_mask); +DEFINE_APIC_CALL(send_IPI_mask_allbutself); +DEFINE_APIC_CALL(send_IPI_allbutself); +DEFINE_APIC_CALL(send_IPI_all); +DEFINE_APIC_CALL(send_IPI_self); +DEFINE_APIC_CALL(wait_icr_idle); +DEFINE_APIC_CALL(wakeup_secondary_cpu); +DEFINE_APIC_CALL(wakeup_secondary_cpu_64); +DEFINE_APIC_CALL(write); + +EXPORT_STATIC_CALL_TRAMP_GPL(apic_call_send_IPI_mask); +EXPORT_STATIC_CALL_TRAMP_GPL(apic_call_send_IPI_self); + /* The container for function call overrides */ struct apic_override __x86_apic_override __initdata; @@ -30,10 +52,34 @@ static __init void restore_override_call apply_override(wakeup_secondary_cpu_64); } +#define update_call(__cb) \ + static_call_update(apic_call_##__cb, *apic->__cb) + +static __init void update_static_calls(void) +{ + update_call(eoi); + update_call(native_eoi); + update_call(write); + update_call(read); + update_call(send_IPI); + update_call(send_IPI_mask); + update_call(send_IPI_mask_allbutself); + update_call(send_IPI_allbutself); + update_call(send_IPI_all); + update_call(send_IPI_self); + update_call(icr_read); + update_call(icr_write); + update_call(wait_icr_idle); + update_call(wakeup_secondary_cpu); + update_call(wakeup_secondary_cpu_64); +} + void __init apic_setup_apic_calls(void) { /* Ensure that the default APIC has native_eoi populated */ apic->native_eoi = apic->eoi; + update_static_calls(); + pr_info("Static calls initialized\n"); } void __init apic_install_driver(struct apic *driver) @@ -52,6 +98,7 @@ void __init apic_install_driver(struct a /* Apply any already installed callback overrides */ restore_override_callbacks(); + update_static_calls(); pr_info("Switched APIC routing to: %s\n", driver->name); } From patchwork Mon Jul 17 23:16:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 121671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1406240vqt; Mon, 17 Jul 2023 16:37:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzqtIXNo/NFcf8SyRIjFctdKw7O8Ty+PzThM0TycrSzMLjgAirdwWwYDB0HzppwFrAkqNU X-Received: by 2002:a05:6a00:a1a:b0:64d:5b4b:8429 with SMTP id p26-20020a056a000a1a00b0064d5b4b8429mr1165203pfh.18.1689637048711; Mon, 17 Jul 2023 16:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689637048; cv=none; d=google.com; s=arc-20160816; b=XPyDoh6j/kJ4tpZ5tTfkBwSIqnud3btm3TKSN+EkWMKD2QkBRwfvpJRWQYkWVMd4hv NDO2kNvYdYYLBcYdA/0u/loI8x5gj1cT5WSgeBppGHmJagDxqIVW8TONMv97YoLYbJu7 PZJcHhkEnW86T0/XkUn+bG33jyP3TEF0ZNKFKsqXkV4sRGn2lma9MlcpD3ZhsXf14wvY 1uce9wDwhq1fc7tnn7XzeZVynojOiH82XNd1cPI2538uqwllNKpQyLc20H6PAmSFM9Ni ZoJaKqan+rmbyrVPgWLub5ApvnrL95HVckqZUiG9xH73ErSZR/Shgy6gLufWCHxxtmvp cIbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=lvMFdpWMYEl6iHAh9VQaIAf2jL32y7ajYh4Uo2YtOzA=; fh=MJzvnywV9/WrN/ASipmGkNx/7jKFHnq83nsgXe/obdc=; b=XkCCPcJQZF3KUs+UZx/UFGqW0z9UzkJ+E3rGBNKxndQACH8c6kSPEB2PnavNVUPF1o YHY56wFd4ag/rXG1lvQ1zlkCBinEaBaFOfSicTvxQ9h7g2qRrHktPkOhYTGHAZIlimXI sCQE6LBUJizKnTZPMPLK/jQR0z9lD9nbVJyp51QDHYECr8xODlPgyffCu58eHTXdCLiY zPRWeU3v4A5pvPvFQgQSF8Z7C526Qib39py3pwTv07d++mk6UDHLBJg+svfDTc4Kv83x Ufq4UJbHh3ZoAYEyiDH0MFhsB9EOfj7L84hyCyWS1IdcGaSFqJ/lPJkKQVSOFCUGs+pn 8lOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zP26Q09t; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1-20020a056a00084100b0065bbe39e1b3si594198pfk.146.2023.07.17.16.37.14; Mon, 17 Jul 2023 16:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=zP26Q09t; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231587AbjGQXXc (ORCPT + 99 others); Mon, 17 Jul 2023 19:23:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231852AbjGQXX2 (ORCPT ); Mon, 17 Jul 2023 19:23:28 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21BCC10D1 for ; Mon, 17 Jul 2023 16:22:44 -0700 (PDT) Message-ID: <20230717223226.538475803@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689635765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=lvMFdpWMYEl6iHAh9VQaIAf2jL32y7ajYh4Uo2YtOzA=; b=zP26Q09tzOOZnXWdUFGaMQFD74L+qpdu5/OQGvyYyiZlRQ5bUEwJc9a8Svzr0wS8GNpvbZ pn24Act9J/RMcTSkWXQtfsI8I+fnlIz8p8i+j0emei5GoLnUzr3k3AoMlqDF1HXGA/v18D vPIMEmawCFpThhaJjspLXUK5kI1WLzA8r2rEf27zychn1pucRO+gONlIWDKebkD+ZXfOmZ t91yZQOsWB6Tc0WFrSG4gp4oETKvug2OuN+JNbnKINIU4u4UByfZJ9461d5hjKjCf5B774 79dlHcsLHI9mdvmMDcfWW0sbmQP7pJ/Ml/NdDhfqoH54tudnOutCc2zqtkkQcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689635765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: references:references; bh=lvMFdpWMYEl6iHAh9VQaIAf2jL32y7ajYh4Uo2YtOzA=; b=7JEu7Jpz1sP45XzkyVnLD6yXyYOgSEsQ+LVyXwPbyLst41zW3d69yIstXz1C78ob3B91dy UZExU6MTiMrW32Cw== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Linus Torvalds , Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross Subject: [patch 58/58] x86/apic: Turn on static calls References: <20230717223049.327865981@linutronix.de> MIME-Version: 1.0 Date: Tue, 18 Jul 2023 01:16:05 +0200 (CEST) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771712858045559786 X-GMAIL-MSGID: 1771712858045559786 Convert all the APIC callback inline wrappers from apic->foo() to static_call(apic_call_foo)(), except for the safe_wait_icr_idle() one which is only used during SMP bringup when sending INIT/SIPI. That really can do the conditional callback. The regular wait_icr_idle() matters as it is used in irq_work_raise(), so X2APIC machines spare the conditional. Signed-off-by: Thomas Gleixner --- arch/x86/include/asm/apic.h | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -397,68 +397,67 @@ EXPORT_STATIC_CALL_TRAMP_GPL(apic_call_s static __always_inline u32 apic_read(u32 reg) { - return apic->read(reg); + return static_call(apic_call_read)(reg); } static __always_inline void apic_write(u32 reg, u32 val) { - apic->write(reg, val); + static_call(apic_call_write)(reg, val); } static __always_inline void apic_eoi(void) { - apic->eoi(); + static_call(apic_call_eoi)(); } static __always_inline void apic_native_eoi(void) { - apic->native_eoi(); + static_call(apic_call_native_eoi)(); } static __always_inline u64 apic_icr_read(void) { - return apic->icr_read(); + return static_call(apic_call_icr_read)(); } static __always_inline void apic_icr_write(u32 low, u32 high) { - apic->icr_write(low, high); + static_call(apic_call_icr_write)(low, high); } static __always_inline void __apic_send_IPI(int cpu, int vector) { - apic->send_IPI(cpu, vector); + static_call(apic_call_send_IPI)(cpu, vector); } static __always_inline void __apic_send_IPI_mask(const struct cpumask *mask, int vector) { - apic->send_IPI_mask(mask, vector); + static_call(apic_call_send_IPI_mask)(mask, vector); } static __always_inline void __apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) { - apic->send_IPI_mask_allbutself(mask, vector); + static_call(apic_call_send_IPI_mask_allbutself)(mask, vector); } static __always_inline void __apic_send_IPI_allbutself(int vector) { - apic->send_IPI_allbutself(vector); + static_call(apic_call_send_IPI_allbutself)(vector); } static __always_inline void __apic_send_IPI_all(int vector) { - apic->send_IPI_all(vector); + static_call(apic_call_send_IPI_all)(vector); } static __always_inline void __apic_send_IPI_self(int vector) { - apic->send_IPI_self(vector); + static_call(apic_call_send_IPI_self)(vector); } static __always_inline void apic_wait_icr_idle(void) { - if (apic->wait_icr_idle) - apic->wait_icr_idle(); + static_call_cond(apic_call_wait_icr_idle)(); } static __always_inline u32 safe_apic_wait_icr_idle(void)