Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp5602rwi; Wed, 2 Nov 2022 08:44:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+5aKLsvfJPinkQjZjLF7UrVZIleimBDDEOGcSHU6ZxINOB4K9zrn6ACmdJZEFFJWPdQ6q X-Received: by 2002:a17:902:d1d3:b0:187:3d23:3490 with SMTP id g19-20020a170902d1d300b001873d233490mr7418847plb.149.1667403898966; Wed, 02 Nov 2022 08:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667403898; cv=none; d=google.com; s=arc-20160816; b=UxpY0mLOgFTkik/EMpSr1lES4WCnrzYcXNAkVN8EAmNdkdRrFYhbH3bJEjPm5EhHbK LBdN3xeTH1FPwrayMX/5rHNS4mA9WRgxaEspvr25MbblDF5OJ3oTEqR7u+VF3q/GLy2i bfK/er0Eadiadu1UT1AgekMCs164yP4M7AOnvP4jH1MpaZGFZAV8+K2hIehoFpdLr/Pq M3fPLY+uWeYFdB5GDx/Pf/V+99ARpKJLFWo69PnXrPN2t5zT2/qL9Bn6BWyOyLnwibj+ KXlb9UYKx+ocvlSb3HlzUGwS4w4ViK8blWcEKNMnG1Vl9fSt9XsYZr0JlPzFeuPLel6p R0Zg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3bi3uZ85tOrBotZPkPK+DHZefyNQ4HOrG8iiPNJHpgk=; b=Po0Jst6m1VfDVN2v1kfcQoOVAMK/lfBi6tJ4sPI0kqLrpPESuqSqeVP7U5NsnG5O/R XnndY/YpKyACuw5+DWCZhKjinVe8UbiJTJ+ZfpPi8JGgNKIviQ4rmndbJtnUo2LgvuGr kgvyFwgAB4UqDef8pEswsuO0OSqpVvG5Ee87HTjlqJF5s4q401nCP1VNCFpblO52BKNk GqzaD1cFvyKvdlckDELNZVMOeeHYSnqk6fPjJnzwSXi4TcBQQOPBTTeR9wxqYKpH+gJD BGl7c6h0buIpYRR95g0Jm936RBcUvLrMNfo8bRmyNL42L6LU7G3RbNzMAQPMtD0qA8BC l4mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bkmbP53S; 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 h18-20020a170902f71200b0016d2f548842si15544199plo.105.2022.11.02.08.44.45; Wed, 02 Nov 2022 08:44:58 -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=@kernel.org header.s=k20201202 header.b=bkmbP53S; 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 S230232AbiKBP0B (ORCPT + 98 others); Wed, 2 Nov 2022 11:26:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiKBPZ7 (ORCPT ); Wed, 2 Nov 2022 11:25:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1C41409A for ; Wed, 2 Nov 2022 08:25:58 -0700 (PDT) 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 630E8B8233E for ; Wed, 2 Nov 2022 15:25:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33201C433D7; Wed, 2 Nov 2022 15:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667402756; bh=QqCq9FzEZmwrlGUBhYrSUWsSyKinysXKHWy0D5tQtL4=; h=From:To:Cc:Subject:Date:From; b=bkmbP53Ss3pbEvxROWjwMOfrtTPAoXHyH7DZbjcZSPO5149qw+yo4OoSRbXpgz1Hz wgJA5J2axERwrL6jS30ImQny7gt9cSBwhYch5rOR7jJJIcJbRIcBOl3ia1JJrFZE2a z+Yyo2Wf80QzzzLM7UpMn8kpxIPRogJALrwXuw8XyRsw0/KMdAq5aVJZ2bO90zjrMV o5hBDP2AXXEWdrDJDepWmQBLBZ/2h1HFXjqR1Dh89DJhwMUxFcwdSvIXmM94QbSufC G+DPnXVJP+SVnVNO7IJ5JIXluGDbCMMpD29BK4twyzqa/ze8i5x+t9U5Dqdt7KP+JL NaZT48+juTG+Q== From: Nathan Chancellor To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Nick Desaulniers , Tom Rix , Kees Cook , Sami Tolvanen , llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor Subject: [PATCH 1/2] drm/amdgpu: Fix type of second parameter in trans_msg() callback Date: Wed, 2 Nov 2022 08:25:39 -0700 Message-Id: <20221102152540.2389891-1-nathan@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.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 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 Signed-off-by: Nathan Chancellor --- 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 d94c31e68a14..bc4f079fd48c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h @@ -74,6 +74,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 */ @@ -83,7 +85,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); }; /* base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780 -- 2.38.1