Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1521497rwj; Sun, 18 Dec 2022 09:46:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XaIGpnPhoVd4suLT9UI91b2Ic3KTA7c3dPn1GRLgiThfcwmE7CljLyFCksy80urEPC6lc X-Received: by 2002:a05:6a21:1084:b0:a5:c5ed:6469 with SMTP id nl4-20020a056a21108400b000a5c5ed6469mr40359344pzb.31.1671385608998; Sun, 18 Dec 2022 09:46:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671385608; cv=none; d=google.com; s=arc-20160816; b=QUkUXeUEpiOMkxyopj1xUBA4IofrebdKWXUNNGcnnAZNzM0yuWvckH0HQmrXzyNEMm VglD47LW1dK1pLFjjpl6ij0QTZIxfU4C605g4cbbpDxcFiUyWXqSj5PIF2g6lP0C21R4 73SrXVd7U7oE/oHEvxWhPKjoK4jU6YwtkKFk2e+mYNZvGoZEdijwh87obKQubM2Th0Mn uVRYxzVLijQgF8jCGddqH1g+nUwCCh7c6cD++RXUAUIAVkupMw0MVhpCBYw1w/bGomJA MvTUh+DSXxw2fNapgKd3zC8rF5bOEvPVGPXtJDRYPFupJjwWwucfwiLzQx+LWRu3iz6m mCsA== 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=uAo8zLC5jX1pWf+dsChbCVTkQhtn14KFiG6qIODd2BU=; b=jVxlioqBfHHpVPALAsmVsMrqn8n5i+7K0/5lxDiLe2ZjZboj1oXYj+63FlAvV+1adC pHNjjOx0uK3xJiSsO22utzL2jpuhTscfFy3/jve8oxpQ0CAjOgTthL2zHi+CxjiB1vyo bIQOWg6ilAfDMzBz+gP69YBrMmjSU765ve1oBrtYxWiofm1xvT02Xx02yLJbsvulp7J3 KQik1SP67S1JAYrZW+1WumYJw+LYhIYPlWQcxkWt9R+dNT6hT9oReGcU+BdioDVQbqs/ URv0Fl/aa8JjGMRoK/BTCS1hzNVwohnNQiFlLHwKJ30RoYicHtynVFsccniz2mNIrlGT F82A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="B7ZVhEn/"; 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 l63-20020a638842000000b00477bf7b0c43si9027607pgd.458.2022.12.18.09.46.40; Sun, 18 Dec 2022 09:46:48 -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="B7ZVhEn/"; 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 S232233AbiLRQk1 (ORCPT + 70 others); Sun, 18 Dec 2022 11:40:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232020AbiLRQjZ (ORCPT ); Sun, 18 Dec 2022 11:39:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744345FF3; Sun, 18 Dec 2022 08:14:06 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 13C4160DCF; Sun, 18 Dec 2022 16:13:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64679C433F0; Sun, 18 Dec 2022 16:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671380035; bh=To1zNpXD0KVKRva4FzasldUmR2gCcvIZD+yhSo2fdVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7ZVhEn/56yleAd5THNPOAfPBv6U9fQa7u5xl0fcpWbRNLepqMO83xmD9fKJ/giap iZu0g6Wsb1a1QypVgUKRf92DLONGMLpadKAPX+axFgwyZu4FrN8oXZCjnea60nfSuO ziNzjym57IS5DwLpjhAhruETBgVIkSGRvnLtvj0FCOdGl3lWgxdOg/0fu0BH++m1E2 tiGgrwN0+NCXHnF9NRSEI8pFoS/EgkvNzklwlkm+CmvmigHrYRbDqyN3HvsjDiWhOE OOqsSGAvZlJcdf3G6Tsbfo/C9RVPNH2fHi0lVLzR4lz1bQYWiZPLlLaaPOA1jZDOQ0 b2kj2VE7Cp4XA== 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, ndesaulniers@google.com, Hawking.Zhang@amd.com, PengJu.Zhou@amd.com, lijo.lazar@amd.com, horace.chen@amd.com, danijel.slivka@amd.com, Victor.Zhao@amd.com, victor.skvortsov@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 5.15 16/46] drm/amdgpu: Fix type of second parameter in trans_msg() callback Date: Sun, 18 Dec 2022 11:12:14 -0500 Message-Id: <20221218161244.930785-16-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 f0d0f1087333714ee683cc134a95afe331d7ddd9 ] 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/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] .trans_msg = xgpu_ai_mailbox_trans_msg, ^~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict] .trans_msg = xgpu_nv_mailbox_trans_msg, ^~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. The type of the second parameter in the prototype should be 'enum idh_request' instead of 'u32'. Update it to clear up the warnings. 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/amdgpu/amdgpu_virt.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h index ce31d4fdee93..4af3610f4a82 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h @@ -62,6 +62,8 @@ struct amdgpu_vf_error_buffer { uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE]; }; +enum idh_request; + /** * struct amdgpu_virt_ops - amdgpu device virt operations */ @@ -71,7 +73,8 @@ struct amdgpu_virt_ops { int (*req_init_data)(struct amdgpu_device *adev); int (*reset_gpu)(struct amdgpu_device *adev); int (*wait_reset)(struct amdgpu_device *adev); - void (*trans_msg)(struct amdgpu_device *adev, u32 req, u32 data1, u32 data2, u32 data3); + void (*trans_msg)(struct amdgpu_device *adev, enum idh_request req, + u32 data1, u32 data2, u32 data3); }; /* -- 2.35.1