Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6207715rwp; Mon, 17 Jul 2023 17:29:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlGSrys1xMDsozNj3CjgQ8Johnd9jMZWL8r216S3QLeAw5L0u13KE3wIAYuvz/pq1PB3fnsi X-Received: by 2002:a92:c70a:0:b0:348:8541:d969 with SMTP id a10-20020a92c70a000000b003488541d969mr1184339ilp.12.1689640142457; Mon, 17 Jul 2023 17:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689640142; cv=none; d=google.com; s=arc-20160816; b=XIWK10VMTu/AzHU8pR1rPCINJLimcpvNGicDCNHkDYb5o4Cw3tJ/1W92+No1LaT8Ep m0U2lda3GQTmKnuI4aAKxOuReFMtlzLSsGXJbTnNquSCHwnmcgwBAh2gWu6EEX3WGyZQ 2FN9duLAdvIsNtIm6ctMhRkg1HnVjMxo7Nac8PLP1ajgZtufQh1GB2Lw/6RVQvPKHv/i 1wxZl0YJF2Kdx36Y6iMA8K5Xh0EeTcrrwFzJU8ocAT7KOiTTWKAQWvoTpGN4FtkZ8kol FZOtA99ODPtlqRu0rDvZVbwYJ51knD9xwzsc6nf5yMbCOUddcl1sFA8ayZgCeXgDMAax 3s9g== 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; 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 Return-Path: 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.28.50; Mon, 17 Jul 2023 17:29:02 -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; 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 S229995AbjGQXkZ (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 Content-Type: text/plain; charset=UTF-8 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 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)