Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1478734rdh; Mon, 25 Sep 2023 14:13:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHo+EpFKG2Zi8U5f/5SuBML7hBuH8LqlrCo3qkfPsRFWxn8QIHbflzUyg2lqWyLg0QZgP86 X-Received: by 2002:a17:902:e889:b0:1c5:ecfc:2650 with SMTP id w9-20020a170902e88900b001c5ecfc2650mr1312951plg.14.1695676402083; Mon, 25 Sep 2023 14:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695676402; cv=none; d=google.com; s=arc-20160816; b=Rcsz//fihJ3C2H8uUSXiQV6znPASlgbvY9SwmIi946ZRMn1Ja7MAh/OY1bhs+9sYMF /WsYbRJFDr7AVYxe1T0e1nQ/4fDPqNAse1sBPFbWgZMxzVFYuODvs6fO3qXOpYrshB8e pFs3JWo5ECys0VR88h7ySW5cAnw7FmMVnl1RW3wfSBs1kZA9nQXZu1ReX5lYEK0W4hZ2 bIhn7tPnNcNQgn0kCrf5qtK7PpaQvdE40yLAHsvNRxIrwx6MR1rUE+dJKQigrAPPg4qM qPrxR1WQDykX7TJO/sfc+MYialVuQAIOLEjVD4bTT82VI0KFiZf/xE1sqQJfPQyoeD3N AF9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MJfyUt1ShfjZl6t8cnVtNZYV0Rqi3aBl3H7mr80x/Gw=; fh=VKNUWMhUgup1qhjMNkz7u27ReMfGREL4LfMTtAfFjFA=; b=xHfGEUg36K2KFdZKaQhNgqNlp3eWsd0hSGrHelOwzbJjoK6YNzjNb55kQSXx3cTstj tcUYfjAcFMk1Wf6Lw/vUvvjFt3T+zxTNGHKbbYN6s4TijgjsySAR33hT8OIiw2cm2X6u pwOEayokG318+VxGlVHvRcysy4W56QjjFX43yGlDLFJC4TM6DJc0fzRh9Ghnqi9WF8W/ XIN19Esjk++QoBOz3CPUg13oBESAf3J93Le5aV/VRdpaOKGpt3Z3ec5shN7Ge1PVNKi8 AH0b2cNxyIzFAfe9SjS9BqBH1FT+c+hiUowfuN5xik2wSZ0p//hsME0+sJpW6HLJikTD G/jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="JbWQ5Iz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id lq13-20020a170903144d00b001b9fb1a0465si10124087plb.385.2023.09.25.14.13.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 14:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="JbWQ5Iz/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BCD0B80293D3; Mon, 25 Sep 2023 07:14:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbjIYOOu (ORCPT + 99 others); Mon, 25 Sep 2023 10:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbjIYOOq (ORCPT ); Mon, 25 Sep 2023 10:14:46 -0400 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 366D8CE; Mon, 25 Sep 2023 07:14:40 -0700 (PDT) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3add255c88aso4061859b6e.1; Mon, 25 Sep 2023 07:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695651279; x=1696256079; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MJfyUt1ShfjZl6t8cnVtNZYV0Rqi3aBl3H7mr80x/Gw=; b=JbWQ5Iz/GUZz9GMC8qoI3gy9GFRjgwCAZ4qS84sY4F9B+a/8vDDRrFDUpyGBNMmtYI Fc6wfuRYySfTSfDhM9KnOs/6k0QxO9XL8bQnVXZQaQ4WIyKV+yx8fPoSRGSJ8OOC7nCO 2gd4j97YohuNZGLOnBuDVNmfHSJrBdzjCReQpIhwVxdemgNHmqP7AQhaww7ZkH/Sf1ze B+7EU6/1FDBDYP4Shrzj42np3547VTJfcwqj6dMnl3zx/t02nheTJG9iLJuD+iQ2i7bi olWG/yAeK6T4x9ggobE8nrByRrYuuXeRLHfFLTvSdtVmre4c2ENeBwh0TcLrc1sCDsWe D2GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695651279; x=1696256079; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MJfyUt1ShfjZl6t8cnVtNZYV0Rqi3aBl3H7mr80x/Gw=; b=TJtdqz9qahgu/Vd9GVYX5gspgktM7sQi+OLl4H4fIaoARYBt01NHsa+x1DfVWDIio0 9hoZOajFRzTY9Hq7NHkX0UQag3i8e3HMSsNQ1ZnQ21zjbcyxRR2jAQsICN2KV50XqN1F Gtay9Olrsgh5SM/6NybBSPX05SaJqMZJr/Zh9r8OazCKXaK6bCGMA5DfG/81dNufohgl dj4d+deONp+ylbwnJZDvvpyjlHiSV7qM4k0JNviR1/KMKn3QZV6W0FpbhYfXBLG2+aSL iR0OEtnxqLWGfGGf0x6Up94B01zLLERSFe6z73fddgDp4B0yCtRwlZFBOLkP4W0QTZBE gC8Q== X-Gm-Message-State: AOJu0YzoSCghnomtSDg3nDneI1CRjnf6sJ30wMuJj8CT2K3lZIXO6pWz aJ7x8vDO0KpyQHPBXX/Jebh63GrnBz8YJJyVgZk= X-Received: by 2002:a05:6871:c10:b0:1dc:dcf9:18d8 with SMTP id ve16-20020a0568710c1000b001dcdcf918d8mr4061353oab.24.1695651279489; Mon, 25 Sep 2023 07:14:39 -0700 (PDT) MIME-Version: 1.0 References: <20230922173110.work.084-kees@kernel.org> <20230922173216.3823169-1-keescook@chromium.org> <2635922e-f52a-4e91-40c6-4f1358972786@amd.com> In-Reply-To: From: Alex Deucher Date: Mon, 25 Sep 2023 10:14:28 -0400 Message-ID: Subject: Re: [PATCH 1/9] drm/amd/pm: Annotate struct smu10_voltage_dependency_table with __counted_by To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Kees Cook , David Airlie , Tejas Upadhyay , Emma Anholt , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , Matthew Brost , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , Nathan Chancellor , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, linux-hardening@vger.kernel.org, Lijo Lazar , Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Melissa Wen , Dmitry Baryshkov , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Tvrtko Ursulin , Xiaojian Du , Le Ma , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Alex Deucher , Nirmoy Das , Lang Yu , John Harrison , Hawking Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 25 Sep 2023 07:14:48 -0700 (PDT) On Mon, Sep 25, 2023 at 10:07=E2=80=AFAM Alex Deucher wrote: > > On Mon, Sep 25, 2023 at 2:30=E2=80=AFAM Christian K=C3=B6nig > wrote: > > > > Am 22.09.23 um 19:41 schrieb Alex Deucher: > > > On Fri, Sep 22, 2023 at 1:32=E2=80=AFPM Kees Cook wrote: > > >> Prepare for the coming implementation by GCC and Clang of the __coun= ted_by > > >> attribute. Flexible array members annotated with __counted_by can ha= ve > > >> their accesses bounds-checked at run-time checking via CONFIG_UBSAN_= BOUNDS > > >> (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-fa= mily > > >> functions). > > >> > > >> As found with Coccinelle[1], add __counted_by for struct smu10_volta= ge_dependency_table. > > >> > > >> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examp= les/counted_by.cocci > > >> > > >> Cc: Evan Quan > > >> Cc: Alex Deucher > > >> Cc: "Christian K=C3=B6nig" > > >> Cc: "Pan, Xinhui" > > >> Cc: David Airlie > > >> Cc: Daniel Vetter > > >> Cc: Xiaojian Du > > >> Cc: Huang Rui > > >> Cc: Kevin Wang > > >> Cc: amd-gfx@lists.freedesktop.org > > >> Cc: dri-devel@lists.freedesktop.org > > >> Signed-off-by: Kees Cook > > > Acked-by: Alex Deucher > > > > Mhm, I'm not sure if this is a good idea. That is a structure filled in > > by the firmware, isn't it? > > > > That would imply that we might need to byte swap count before it is > > checkable. > > True. Good point. Same for the other amdgpu patch. Actually the other patch is fine. That's just a local structure. Alex > > Alex > > > > > Regards, > > Christian. > > > > > > > >> --- > > >> drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.h | 2 +- > > >> 1 file changed, 1 insertion(+), 1 deletion(-) > > >> > > >> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.h b/= drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.h > > >> index 808e0ecbe1f0..42adc2a3dcbc 100644 > > >> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.h > > >> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu10_hwmgr.h > > >> @@ -192,7 +192,7 @@ struct smu10_clock_voltage_dependency_record { > > >> > > >> struct smu10_voltage_dependency_table { > > >> uint32_t count; > > >> - struct smu10_clock_voltage_dependency_record entries[]; > > >> + struct smu10_clock_voltage_dependency_record entries[] __cou= nted_by(count); > > >> }; > > >> > > >> struct smu10_clock_voltage_information { > > >> -- > > >> 2.34.1 > > >> > >