From patchwork Tue Aug 1 10:47: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: 129244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2619599vqg; Tue, 1 Aug 2023 05:05:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnjkElEAPwCCvBTtGK/WSg3hlf341GYSgS8HUKyGfzwtpNDdwEGNPwHER/I2dbUzQsh6Va X-Received: by 2002:a05:6a21:71c1:b0:13d:f217:d318 with SMTP id ay1-20020a056a2171c100b0013df217d318mr4949890pzc.49.1690891549112; Tue, 01 Aug 2023 05:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690891549; cv=none; d=google.com; s=arc-20160816; b=ljBDY2xup06/dJB87gU41kaDWIAnuiq7JNGKanKgjnDNBeadyFNX6pVzDiDQ33K7xG hDp8BsHZW8PuvJqPZtblalPfuMs+KWsxpVkCU4rs30MHzG/lHqTXGRCGtftRMVD+S69v UVHdku8PNZUu7UbN5DUBkTCaCluqLfVE45837AthAd2xzhsxE4x9WtEHzGvrWjTCYR7g M92o8lSXQrsqbxFcRaPjjzHm7w4NQy5e0vZxTNY4fzfiZlTwiQGg7WzbjZwcGnpyOxLn 2QaaFSzaa9FlulVw3JztTQHNpiRytrfsoeRG7XMfP6NBWfxtb0f/1Mk3RYbcTP5RstKv pNjA== 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=TA8RTRP76/X19cT18S7neKhRCl/b+EEGzlCWZ6ao1A4=; fh=mE3iieUIZLcDfOLIULj9X6/p0bMDPZGFSVRsnyRUnTc=; b=WWTPulHE40jUmpW/Nm8f+jztuQmih9KSFCx1I/VG71pvLgYk/L9WLmykyD1lxobRJm +oJQgHixJLh9ME2XUDFpAlf+LE5PWga0un+XKBAhaYbEpbAn0EwPZPOwetgZXMAAFFb9 Ms4Jx78g14yetkqseieL4zlbAQ6vFzKUOxfQ3SuDFvx3HGX+EfoX3Fsrh4lXfBja4YFK +hq7zAYhb2GFfBh3tBFVsOjxMUEoYog/htv35QZkggoi00TGuhlsB2crvC5KyqQOF191 VHD4eE05kiIkDMvKsczn090abZTSjuUkJuh421sS0pzz6fxcwxVZM+JgWxi09MB+kZxR 2MCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q7HmM1Ta; 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 s7-20020a637707000000b005576ebe803fsi8918899pgc.318.2023.08.01.05.05.35; Tue, 01 Aug 2023 05:05: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=Q7HmM1Ta; 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 S232535AbjHAKu5 (ORCPT + 99 others); Tue, 1 Aug 2023 06:50:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbjHAKu1 (ORCPT ); Tue, 1 Aug 2023 06:50:27 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4598F4217 for ; Tue, 1 Aug 2023 03:48:17 -0700 (PDT) Message-ID: <20230801103817.404695655@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690886852; 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=TA8RTRP76/X19cT18S7neKhRCl/b+EEGzlCWZ6ao1A4=; b=Q7HmM1TaKQjwNSSbocOLtyBXBadEO8vNPv5HwWURc5KkWs3nN0i+WcgQ0+3cGf8FIRwq4L Lr1ajhoZJiOVDJILgDbV1qR5sjeFx1DJA9IV6bbZ4XszqHdSGQzUWE4KkXxUrQwrj/Vtrl GkWqV7zm25XYhc9pvIuIe22j4PdvCy922G7+yK35xD/ywu0rYek7vXy057hvBxXH2MOsi0 XWPy9pewf/DbSSQBdoiJW0M3lOEMhwXErIMP3lqzgx7ac7xaXNDfWFNUhtZRkNezNODflj Oeik13ckZW6vMXqDZC1KGDZeM/h0jKEkLLzaydVGHB5s7GfVFmCGWPLJwv9htw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690886852; 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=TA8RTRP76/X19cT18S7neKhRCl/b+EEGzlCWZ6ao1A4=; b=3q1AiKVhJTvaVVpCiomKz+41fwdizJHnCdbGh/Qbnc2D4Fga4Rp5eEOHJsfhLo8erWmqPX YnAQYuFufRYnzkBA== From: Thomas Gleixner To: LKML Cc: x86@kernel.org, Andrew Cooper , Tom Lendacky , Paolo Bonzini , Wei Liu , Arjan van de Ven , Juergen Gross , Michael Kelley , Peter Keresztes Schmidt , "Peter Zijlstra (Intel)" Subject: [patch V3 41/60] x86/apic: Wrap APIC ID validation into an inline References: <20230801103042.936020332@linutronix.de> MIME-Version: 1.0 Date: Tue, 1 Aug 2023 12:47:31 +0200 (CEST) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: 1773028296603102084 X-GMAIL-MSGID: 1773028296603102084 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 Acked-by: Peter Zijlstra (Intel) --- 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);