Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5527879rwb; Tue, 1 Aug 2023 04:15:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLtyXlAlQLZtwKpYY24HN0qmT4hMxk/Id+naTFQZ4zG5n9SaIK3y8BiBHSWgJ/cadW2jfE X-Received: by 2002:a05:6a00:170a:b0:672:264c:e8cf with SMTP id h10-20020a056a00170a00b00672264ce8cfmr13363675pfc.7.1690888509854; Tue, 01 Aug 2023 04:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690888509; cv=none; d=google.com; s=arc-20160816; b=qM3eRGs//CpH+3rHBpRaDbeD1XCxgdozZIsqYriHlwIbBXzEQGq9N9JVN9GTb7OUCt TgWgXItnt8N0PgVmSgQnos5Y+adMEwKOnDNOwfM6iUvxJWHAbIjxP3btrwn7XSbdvhEO q3kNrpiPQ2YctBp+ZgIisji5875ZB9vEalZp56nekWzclv2YO1KaT4hC7nwQzOIFE2kR oar1AhKpu50MWLZlxqr7fajZxbBGA3oxO3neBruwhaK9eFD4rJ8bQ3kC4j56qNKXl1S6 eKn24QUjBN8ecKL9hbQNTqHtsLOlMTXU4wDEM3UXRE/6oxf0Wq8AZiEMP8lo2AdhNuUW 9xVg== 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=1t5AYKxWBGS5UIcYUily8whdBGpo1cGe3a+nedmnJoI=; fh=mE3iieUIZLcDfOLIULj9X6/p0bMDPZGFSVRsnyRUnTc=; b=wMFGajtMMqsF5e2Y6AOsTTpJ1Ca/D02WYy4FXIvoTMUseJNwTACtUj3OzRT4qCrXYj Vj6y/FyxdLBl5y01z1qo08PT5qMnRAHIPXd0IL4fLU9d1cXiuUgkxhOldsermk5fbUzC oZG1WEGSnJQNWQp9Ymk+zr3067oLdj9KyU6KLthAL/wPZOjHMSDXaSC1kvl/U99xha1m f4+4dXjjJ1JJ1NE75MXlFJt1+J+7G+78zbmQSdWlbD0RB69/Jj75qk9IQbnmeYBQA1Oi wb5coth7lMu/Y5KLCBBRbhOXIzQ6zahKkV0stSJ09FOPvpFgOC6XYAngVekkXTNwx6Zy 49sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ugunpQLe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xb6MTZPu; 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 u189-20020a6385c6000000b0052c419dc8d1si8599308pgd.274.2023.08.01.04.14.55; Tue, 01 Aug 2023 04:15:09 -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=ugunpQLe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=xb6MTZPu; 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 S232268AbjHAKvF (ORCPT + 99 others); Tue, 1 Aug 2023 06:51:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234179AbjHAKuc (ORCPT ); Tue, 1 Aug 2023 06:50:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D784493 for ; Tue, 1 Aug 2023 03:48:20 -0700 (PDT) Message-ID: <20230801103817.514745407@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1690886854; 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=1t5AYKxWBGS5UIcYUily8whdBGpo1cGe3a+nedmnJoI=; b=ugunpQLez4IeCETdM/Imk81NmZS2V0dcD8qWAefO7TK4zD85zEVcQLKuL+Vn4dK+1SO50Q TewwhywfWxpN9I3kA5XEWwyQc9G69vat6KZJTyAN3ZKJ3aVwypmiwqDv6I+aKRAwNzuFoT vgwPb/Su18S8uQi+yKYAPcOf0jk5JZ7KzXHtf3ukEhJ12SaBk5HKyy2OsFtI9o/j/Sc187 VNhjKyGGsFZjiHjSuF9jkIT06FfPqJ33krfUS/YXpX0Z12WLcIIm7o6ne1ox3546Eqw1Fi hvh89Y6L67BurfP9xX/I/eYeLisl7NlMYH4JjYUGcFhWaWLzZahHcoOzZxeJ9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1690886854; 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=1t5AYKxWBGS5UIcYUily8whdBGpo1cGe3a+nedmnJoI=; b=xb6MTZPu1mNmqYhL1B9Gy9GjhJAaFQqS5QO9ZB8eOXXipUlU9C8QK6bK+4pTrWur2RVc3S jamES18/YJ9mWjAw== 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 43/60] x86/apic: Simplify X2APIC ID validation References: <20230801103042.936020332@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Tue, 1 Aug 2023 12:47:34 +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 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 Acked-by: Peter Zijlstra (Intel) --- 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)