Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3485267pxf; Mon, 29 Mar 2021 03:39:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPyORQOVGbeNaXLjsqbsCe+P9dXhhov2GtSZXD7PVxeD0Ud5Sffz+nGKYQP4tXQDxMbuJD X-Received: by 2002:a05:6402:5244:: with SMTP id t4mr27870786edd.87.1617014361947; Mon, 29 Mar 2021 03:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617014361; cv=none; d=google.com; s=arc-20160816; b=kekHjEetGxFudAmh4iQRRmnZA+obuAU2XLVaPxDHPzxM4uzhLJ70deKGflbdTolG9k F0Z+gem4Hc+Ojw/KHHvsfY8UglMg/hRHgPqgH6S3J78Wx/Il2tQbiniWqF8TBTu76cEC UYMCdSWUzh1SGvfWueUrmqOaSV7Fvkk1/ZfZT4P+6umT/BXkY2c5/dU3az1VttUooLfk EQyMOr0KlWGWSG/OcVKlZS2nthVfZqPvQND1GOac9tb3NDIHi/ILyTdy26lqTCro/Vbb KX45PPan7gAB/sRKLoA7Os0LbMEHLOvMBgdlOtuEhqPV6WO5hqmROXx/z6JTqEKuDxFS rBvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kUAni46OXsdXe91Yvj1K/ejqdCxDZkiCmZ/vKQgVHo8=; b=vCyudLh4rIOq9qQbkN2zKFbAXafs1qQvE/4Zre5fLG9mQoAjVKsiOyAC3Vg8PXQUpx rdgMxT5KuVKzFw61uCJNmHIEbtmA2WFVV8GvwuBxdsQiaVKKhux/h6V4JgU8YpiOfvT/ hlm+WPHTTdvveMxuWMCp31nO02lPjUjVYu+v7W7r7xBzRbADuG3L81SWmlg+SGqsiwxH +WbV94mYlhRl/2B/JRBj8nQIzulyPhdyEu88FkaIYmbAlmgd2h52t8Qp8ZW7AzEbwRJ4 rBzohDEymz5YZ4MduAw5gYt5kpxP6Qevi+3ONknco8v6NyITVAdlwVuLoerDyo+69QkF UURA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="k/bnsNBV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u10si8024980ejg.204.2021.03.29.03.38.57; Mon, 29 Mar 2021 03:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="k/bnsNBV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233793AbhC2I37 (ORCPT + 99 others); Mon, 29 Mar 2021 04:29:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232800AbhC2ITG (ORCPT ); Mon, 29 Mar 2021 04:19:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 248066044F; Mon, 29 Mar 2021 08:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005945; bh=B22kD/XnsYNocZglVpNcOJIKq0At9U2B2UD0+lqKMmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k/bnsNBVFigbuGpFOCQ3UIJUdLfjYXDgS7JkBmwfdkTHmzscPP0kvdPOwAyfCLo8t xIcyNDluAmsHdOLwIWRfp7Mrd0KFsxVszb+sjjZgJfZL7jOUPSDunpNAJ1lQQb43/V d3J4YtuxM52cq8V4oins6ulS1TQG9hGGambOmBoQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sumit Garg , "Peter Zijlstra (Intel)" , Jarkko Sakkinen , Sasha Levin Subject: [PATCH 5.10 060/221] static_call: Fix static_call_set_init() Date: Mon, 29 Mar 2021 09:56:31 +0200 Message-Id: <20210329075631.189242024@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 68b1eddd421d2b16c6655eceb48918a1e896bbbc ] It turns out that static_call_set_init() does not preserve the other flags; IOW. it clears TAIL if it was set. Fixes: 9183c3f9ed710 ("static_call: Add inline static call infrastructure") Reported-by: Sumit Garg Signed-off-by: Peter Zijlstra (Intel) Acked-by: Jarkko Sakkinen Tested-by: Sumit Garg Link: https://lkml.kernel.org/r/20210318113610.519406371@infradead.org Signed-off-by: Sasha Levin --- kernel/static_call.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/kernel/static_call.c b/kernel/static_call.c index 5d53c354fbe7..49efbdc5b480 100644 --- a/kernel/static_call.c +++ b/kernel/static_call.c @@ -35,27 +35,30 @@ static inline void *static_call_addr(struct static_call_site *site) return (void *)((long)site->addr + (long)&site->addr); } +static inline unsigned long __static_call_key(const struct static_call_site *site) +{ + return (long)site->key + (long)&site->key; +} static inline struct static_call_key *static_call_key(const struct static_call_site *site) { - return (struct static_call_key *) - (((long)site->key + (long)&site->key) & ~STATIC_CALL_SITE_FLAGS); + return (void *)(__static_call_key(site) & ~STATIC_CALL_SITE_FLAGS); } /* These assume the key is word-aligned. */ static inline bool static_call_is_init(struct static_call_site *site) { - return ((long)site->key + (long)&site->key) & STATIC_CALL_SITE_INIT; + return __static_call_key(site) & STATIC_CALL_SITE_INIT; } static inline bool static_call_is_tail(struct static_call_site *site) { - return ((long)site->key + (long)&site->key) & STATIC_CALL_SITE_TAIL; + return __static_call_key(site) & STATIC_CALL_SITE_TAIL; } static inline void static_call_set_init(struct static_call_site *site) { - site->key = ((long)static_call_key(site) | STATIC_CALL_SITE_INIT) - + site->key = (__static_call_key(site) | STATIC_CALL_SITE_INIT) - (long)&site->key; } @@ -199,7 +202,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func) } arch_static_call_transform(site_addr, NULL, func, - static_call_is_tail(site)); + static_call_is_tail(site)); } } @@ -358,7 +361,7 @@ static int static_call_add_module(struct module *mod) struct static_call_site *site; for (site = start; site != stop; site++) { - unsigned long s_key = (long)site->key + (long)&site->key; + unsigned long s_key = __static_call_key(site); unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS; unsigned long key; -- 2.30.1