From patchwork Fri Apr 13 21:24:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10340775 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7AAB60329 for ; Fri, 13 Apr 2018 21:24:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70FF428A1A for ; Fri, 13 Apr 2018 21:24:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 657CE28A1E; Fri, 13 Apr 2018 21:24:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 8CA2D28A1A for ; Fri, 13 Apr 2018 21:24:35 +0000 (UTC) Received: (qmail 28035 invoked by uid 550); 13 Apr 2018 21:24:33 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 28010 invoked from network); 13 Apr 2018 21:24:33 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=t+NMc3wTSPqTRlc4wymVw8yLH7odihMta2WDEKBjms8=; b=svWU3KuO45LlrwHP4SfkjAOO/igoqLMoo3WqfszOC4kf5c9At+Gf7PwHSAUjGLHPlj jPtWS1iM4EGUceJ/o6oVckHrHvIl4wUh9HsfCrt7UJZS4IGOC8NSRnnnYXUfwS0CwDJ7 3YBA6xRZvxEEdyugDCn3yAL0ylny3x9CCTc6WZRRDCAQaH0cnpDEecN5E2AURgxmCQDS P12kJeg7kRyK7QV7kRMAVic8CUy3mAqXX03mcDWTzzPa/ohoRpi4cr+WhPzQHGMqavM9 eN3VOW4HUzk3XDsQzq9fQQgWyHy4MHGno5dovycnPt1mzlBED+1WP1gbaMQW2te0AVKb rZYg== X-Gm-Message-State: ALQs6tBI1LdZWvcLTDULKDINRTjDijtPbIrPNtyZkkYgAMbiu1UxATWl J06Af1xMCXEPBke+6dfTGmWQtA== X-Google-Smtp-Source: AIpwx4+16bK14OIr/z++GUONcsfXlwLRck2HZJRhzOHltHn8SS3ot8Fov66Kat4nwV10Lkg7h4f2Ag== X-Received: by 2002:a9d:38b2:: with SMTP id p47-v6mr4473818otc.171.1523654661558; Fri, 13 Apr 2018 14:24:21 -0700 (PDT) From: Laura Abbott To: Oded Gabbay , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "David (ChunMing) Zhou" , Felix Kuehling Cc: Laura Abbott , David Airlie , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kees Cook Subject: [PATCHv3] drm/amdkfd: Remove vla Date: Fri, 13 Apr 2018 14:24:12 -0700 Message-Id: <20180413212412.18205-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a constant value that covers all hardware. [1] https://lkml.org/lkml/2018/3/7/621 Reviewed-by: Felix Kuehling Acked-by: Christian König Signed-off-by: Laura Abbott --- v3: Introduced a #define for the max value, switched to pr_err_once to avoid log flood, switched to sizeof(array) per private suggestion. --- drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 8 +++++--- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c index 035c351f47c5..db6d9336b80d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c @@ -139,10 +139,12 @@ static void interrupt_wq(struct work_struct *work) { struct kfd_dev *dev = container_of(work, struct kfd_dev, interrupt_work); + uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE]; - uint32_t ih_ring_entry[DIV_ROUND_UP( - dev->device_info->ih_ring_entry_size, - sizeof(uint32_t))]; + if (dev->device_info->ih_ring_entry_size > sizeof(ih_ring_entry)) { + dev_err_once(kfd_chardev(), "Ring entry too small\n"); + return; + } while (dequeue_ih_ring_entry(dev, ih_ring_entry)) dev->device_info->event_interrupt_class->interrupt_wq(dev, diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 96a9cc0f02c9..a90db05dfe61 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -39,6 +39,8 @@ #include "amd_shared.h" +#define KFD_MAX_RING_ENTRY_SIZE 8 + #define KFD_SYSFS_FILE_MODE 0444 #define KFD_MMAP_DOORBELL_MASK 0x8000000000000ull