Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1473976rwj; Sun, 18 Dec 2022 08:53:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf74c/tQ++blVmGtNnhlha9ZHHbh4bcagbLU9HZFPgt0oN1d4khHfeJEVlS5vQm2gNfq0w4L X-Received: by 2002:a17:907:a64a:b0:7c1:64dc:ac25 with SMTP id vu10-20020a170907a64a00b007c164dcac25mr28579209ejc.23.1671382433443; Sun, 18 Dec 2022 08:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671382433; cv=none; d=google.com; s=arc-20160816; b=bJL4CqfQZvz8tG8z2IAUsu210/Isiab6FScKMEE8moK/q7CQYcHz5w5WNjx+HgXpuV 7srXCy91Wux0f9gusDRWDR468FbK1754NxVZsYqDfhtWly6Fxtzw51Ngvha5DP7DYkjM lV5Vo1mp8tz0jX3popRG/5MNbxhdhiHQkO4mLUTJFz3QviNb3w2eB8jsz8aoXzvrSSHv XeX9xIFyNFGOo9GcLQvnY6BRMnj1tQTIGm29DHe5Jzv1InPFKOl5ZQhcoPBmh0EBr6Cx KTPqlBcc2yXFMDbFTt+IXF1247ZSrnRMnmJs87lpsePRteGkhLkf9UtSEMO14pJUREDq 4Ocg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nm/ScOfudjCdz3K8gmIX91YVUfv+qYFfz5Bw4ELLeVg=; b=YFkgSaso+C5/9sYuqhFQwQ5NPEgBrf8+cA1syCJ2jhmJ8BapPEFRcwGxZnjDRDQFoy sGF9wV+9kPVWRf8X77/e0pMcPjSUDggxsA+5MhbGcFBAowZ+MkmSw5HSMyJxvduIQwRV y6LNHKciGLR3RvDvK/gIlrPBuqdTQ41uLgUcIfw9KXUilXyIkoy8LhQyZF9KRZF1ZdQ+ Ho20GV/SMaUt7qsXtuNfteTToyJn2txTOx4GWVkKxx6HXi/tR+rs84hy0WeolEni1xoo NLvmT5gC4pXTW4yl7IY+JA1ZUUt9+MYuj6wFVYnOpSzW+4K4Jryp8Bm833Eckj84FkZd aj9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dawR3Ehk; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a1709060a8900b007aea5ae3956si5160532ejf.820.2022.12.18.08.53.36; Sun, 18 Dec 2022 08:53:53 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=dawR3Ehk; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232547AbiLRQk4 (ORCPT + 70 others); Sun, 18 Dec 2022 11:40:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbiLRQkR (ORCPT ); Sun, 18 Dec 2022 11:40:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DC32186FD; Sun, 18 Dec 2022 08:14:15 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CAF33B80B43; Sun, 18 Dec 2022 16:14:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A10C433F0; Sun, 18 Dec 2022 16:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380046; bh=2GkK5YJnqS2K8+x4XjShdS4yf6xmc9uTVGnxYH8807A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dawR3EhkG0EznPUgT4O68/GM9dNsMT1yeeGOXbbZrEVYnTCyvrHvs3hks1SrG7Cim wEiKbgnZ+GJlhauKPyp0chtZfD3lhNKtMNpcy3IUsiP80vUMBOyMrcRyZASYFXCfIh 28jt0SdnathGPwAiGgIMZDwwUPFsBSkyvaVZ0bkE+FKdlk6KQ1wHsldJdNdLGOXtE4 EG0kNHZ1azaq8Ms6eeC76+i6l68UBoW35uIbwr8f7cuwsPmVTO7ETyRswC6txSBwKN 3aJlUaJMOotA4p47XVWqUVBWzQRgigSy20IR0N+Iqp7RGMktMq32dNlK3sbyNW5mL/ mUHaGzJXH36Ng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Sami Tolvanen , Kees Cook , Alex Deucher , Sasha Levin , christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, evan.quan@amd.com, ndesaulniers@google.com, lijo.lazar@amd.com, kevinyang.wang@amd.com, kenneth.feng@amd.com, darren.powell@amd.com, li.ma@amd.com, floridsleeves@gmail.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 5.15 17/46] drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback Date: Sun, 18 Dec 2022 11:12:15 -0500 Message-Id: <20221218161244.930785-17-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221218161244.930785-1-sashal@kernel.org> References: <20221218161244.930785-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Nathan Chancellor [ Upstream commit e4d0ef752081e7aa6ffb7ccac11c499c732a2e05 ] With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals: drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] .odn_edit_dpm_table = smu_od_edit_dpm_table, ^~~~~~~~~~~~~~~~~~~~~ 1 error generated. There are only two implementations of ->odn_edit_dpm_table() in 'struct amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls ->od_edit_dpm_table() from 'struct pptable_funcs' and pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct pp_hwmgr_func', which both have a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND'. Update the type parameter in both the prototype in 'struct amd_pm_funcs' and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which cleans up the warning. Link: https://github.com/ClangBuiltLinux/linux/issues/1750 Reported-by: Sami Tolvanen Reviewed-by: Kees Cook Signed-off-by: Nathan Chancellor Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 3 ++- drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h index bac15c466733..6e27c8b16391 100644 --- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h @@ -341,7 +341,8 @@ struct amd_pm_funcs { int (*get_power_profile_mode)(void *handle, char *buf); int (*set_power_profile_mode)(void *handle, long *input, uint32_t size); int (*set_fine_grain_clk_vol)(void *handle, uint32_t type, long *input, uint32_t size); - int (*odn_edit_dpm_table)(void *handle, uint32_t type, long *input, uint32_t size); + int (*odn_edit_dpm_table)(void *handle, enum PP_OD_DPM_TABLE_COMMAND type, + long *input, uint32_t size); int (*set_mp1_state)(void *handle, enum pp_mp1_state mp1_state); int (*smu_i2c_bus_access)(void *handle, bool acquire); int (*gfx_state_change_set)(void *handle, uint32_t state); diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c index 321215003643..0f5930e797bd 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c @@ -924,7 +924,8 @@ static int pp_set_fine_grain_clk_vol(void *handle, uint32_t type, long *input, u return hwmgr->hwmgr_func->set_fine_grain_clk_vol(hwmgr, type, input, size); } -static int pp_odn_edit_dpm_table(void *handle, uint32_t type, long *input, uint32_t size) +static int pp_odn_edit_dpm_table(void *handle, enum PP_OD_DPM_TABLE_COMMAND type, + long *input, uint32_t size) { struct pp_hwmgr *hwmgr = handle; -- 2.35.1