Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1621370rdb; Wed, 31 Jan 2024 04:28:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQ+Wa2/8V7zTkPTdadpsaou1I234HmnbDudbbqoSpqODn1Z8nCd8iNnHwcvEsN8vDRHAw6 X-Received: by 2002:a05:622a:1a90:b0:42a:b346:747a with SMTP id s16-20020a05622a1a9000b0042ab346747amr1365667qtc.91.1706704117626; Wed, 31 Jan 2024 04:28:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706704117; cv=pass; d=google.com; s=arc-20160816; b=VKX2YGPnGBtGANgZqhiNsZR67aS9xmkbE4faYm/7t2w4bN1NQNf9NMQ8ir3Ct8a0GE kbTFmN28CSsRKjWyq1y+HYZ9Mjfw+7/a4GlSpTO32hPsj0EwXgP4sjzHEyqTD0Lv0UEg S3oQTgXuaB6t63YpJueAEu7FL0OxlF41URmro/9lPuJKkdYQef6+Gh8n8kdbKxP5LUXm PZYTyCLkUnGEIOYbmfYiKd7gRJ906pIzzCs+70phF2CX2nh8Bsz4FREtKNhbJOrqO0s6 v3R2RPm4Hsg/YF0j7CamcuvO9DJkDjG5VpyWbW1FYmehghwxNgXw/c2vqP8MSQyKIZfr 0zrw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=qlGNCjse7g8LCZD9qtXQK2gNaCE3H5gYqdGBEI7Qruo=; fh=vXAAqELpR0+/CNq3sibmQiSYpDDJUrqm2y3cRoJr0OY=; b=XmnngAWRiDxEeHak6SdlBrLE7DSge/IFQLmPFDdI1NG7SsQx2b43GY73ebXyqYdY+R qJEFjcTCGJZDVGXuj/DR10EQNG3BIHyQSOL3t70HMHXAXlrC/jn8JSR6olURO5B3yABs cb3Q01U/7klmh6v8C/f4XU2WublPqZNq9n/f6x83is2F5CG1z4MWmZv6LFUaKt8eMzE/ SNQ4plKKfHXyN0wvV0nLypdNFFJNtUVpoHWOL81TAoN2RdgjhLegFn+3dmD0ln82NbMz zK9KShjK1nSU6z97ZXbXavsvSFqQc5K5HNe23k3jZZ2kSAYsIwth8ML0kacfDfKy5fYb XqgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gsgPwjvN; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-46421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org X-Forwarded-Encrypted: i=1; AJvYcCUL4+ts6Ag67ipeUi+/cLX5UymS2Q7M6XG9+TPD6/1XgdrBRDTO0ZbnKUownnMBxVhJXsigfyu63GGAeWUdP01sdAoJqY1Ij9w0YG83yw== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u6-20020ac858c6000000b0042a8c838639si9805717qta.205.2024.01.31.04.28.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 04:28:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gsgPwjvN; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-46421-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2983A1C2AA59 for ; Wed, 31 Jan 2024 12:27:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E93BD78B6D; Wed, 31 Jan 2024 12:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gsgPwjvN" Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 171C47868D for ; Wed, 31 Jan 2024 12:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706704021; cv=none; b=UMDwa0PNbRfvXW44O8rWrvtgsZkMhcsamBed3RT/fMvi/nsF0vopsue3YV5QeoAdDRAhCbjJ1corSePEGGbET3Kz9x/0MigXbm1EhgOIMyDZJH4zQeiy6WQ4Wn/Y09zfnrYlTqQIFH4/EOmTOOMWPCPHmlhf/E7/7YxEcuK30lU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706704021; c=relaxed/simple; bh=hoRPS/CFTxqilSN/EifpmGCTsMtOu0/5zOuX6Y/BVoo=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=d53roFn6eXtNIZ+HU5+lLiiPs0im7PqxZo25hKtZ5Y1ZvMrLM298dnuHllET8wcbOlVudX960zOcT7Ag8/aM+Ql/xHxBcMtMaJgnwpIuyLHy6ZdDUFGm88RDP4xsvQH9U73EVB3QYtnXGzAvBUWfiNsU+gcLN+bmiAF/dv5jB4M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gsgPwjvN; arc=none smtp.client-ip=209.85.128.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-60407e7a6caso10624687b3.1 for ; Wed, 31 Jan 2024 04:26:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706704019; x=1707308819; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qlGNCjse7g8LCZD9qtXQK2gNaCE3H5gYqdGBEI7Qruo=; b=gsgPwjvNoq504+OMEIruXOIVqLWkox06dWk3qYBRQ7SM3BwwXubz/5wLP4tVJwgi0O VubcirP2HLpadPXshiokyNDIMEN3OR0lWJ6Tt4vZN4CS0kp1C0HaDb2L84z3z28G9+y7 E5wSBY1VZF22ezP9e0LfhaPQqbKlNnkiKz62yZaS7lD0uioEMWNSTmMMvNNmg4waSYX3 sv6BzyO0mkVGSGWEUfeXpW+Q8VNmy64+NA2jOFLgRo4PwzWkMw4ONxBLtHfVDCzLdglS cnpAaBqXJmf5rsEfFJr0SSjqjn0UUhJTFLJyHNaDgFK7srYpmx4PximRs4NlqeuG9yrK ggWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706704019; x=1707308819; h=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=qlGNCjse7g8LCZD9qtXQK2gNaCE3H5gYqdGBEI7Qruo=; b=J7joQHqkUbE09JeH6kcubP33VSRHeV09CLE/Xyb1ILz4gORNsORQyK8pLWE2pWxUSB Yh/PpmtKWou6k8ybOazccPB3UgjW8Fn/y83LpR7mp+25lEAEk0Bh3q9X45vOGYaVidnb lNyGg5hRnESsIUxv8B9I8qCxYWmgCitHTFg9Chd6ZCd2/VBS+z5Wy81d/2EzH4NFvHJY DoQ9M4dA0aORAZPA59dVQ47vp7w4jrHUpWO0j6iRfT9ce3NwN7k3x8yMQIAfTNhPuO6k ihPinjQEMmTxe/c8qP4ejWOMdkkDTXGq+LZiQTeTXL7/AQXRLWKZRlP3pJ8ulGvFktgO ks5Q== X-Gm-Message-State: AOJu0YxlVXx3yhdWtunxUgMVGVoRhL4pLWkCqZo7qXYhrGuWaT1tixMC LXZgpLYTKj745W9whq+Nn/Fm5DlKwj1YdpU//DBpPpeD8Ll4qslgIeRaoKyw7rGY9nS/GUL2P1B qWuBZxu2SixUjeBPjZ10emsQcdiH7juJG2sJIHQ== X-Received: by 2002:a0d:e857:0:b0:5f6:4f5a:8bd2 with SMTP id r84-20020a0de857000000b005f64f5a8bd2mr936824ywe.0.1706704019025; Wed, 31 Jan 2024 04:26:59 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240125191756.868860-1-cristian.marussi@arm.com> <20240131115304.35hmjgq2xbmzw2v4@bogus> In-Reply-To: <20240131115304.35hmjgq2xbmzw2v4@bogus> From: Ulf Hansson Date: Wed, 31 Jan 2024 13:26:22 +0100 Message-ID: Subject: Re: [PATCH] pmdomain: arm: Fix NULL dereference on scmi_perf_domain removal To: Sudeep Holla Cc: Cristian Marussi , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Wed, 31 Jan 2024 at 12:53, Sudeep Holla wrote: > > On Wed, Jan 31, 2024 at 12:35:56PM +0100, Ulf Hansson wrote: > > On Tue, 30 Jan 2024 at 21:07, Cristian Marussi wrote: > > > > > > On Tue, Jan 30, 2024 at 02:09:20PM +0100, Ulf Hansson wrote: > > > > On Thu, 25 Jan 2024 at 20:18, Cristian Marussi wrote: > > > > > > > > > > On unloading of the scmi_perf_domain module got the below splat, when in > > > > > the DT provided to the system under test the '#power-domain-cells' property > > > > > was missing. > > > > > Indeed, this particular setup causes the probe to bail out early without > > > > > giving any error, so that, then, the removal code is run on unload, but > > > > > without all the expected initialized structures in place. > > > > > > > > > > Add a check and bail out early on remove too. > > > > > > > > Thanks for spotting this! > > > > > > > > > > > > > > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 > > > > > Mem abort info: > > > > > ESR = 0x0000000096000004 > > > > > EC = 0x25: DABT (current EL), IL = 32 bits > > > > > SET = 0, FnV = 0 > > > > > EA = 0, S1PTW = 0 > > > > > FSC = 0x04: level 0 translation fault > > > > > Data abort info: > > > > > ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000 > > > > > CM = 0, WnR = 0, TnD = 0, TagAccess = 0 > > > > > GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 > > > > > user pgtable: 4k pages, 48-bit VAs, pgdp=00000001076e5000 > > > > > [0000000000000008] pgd=0000000000000000, p4d=0000000000000000 > > > > > Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP > > > > > Modules linked in: scmi_perf_domain(-) scmi_module scmi_core > > > > > CPU: 0 PID: 231 Comm: rmmod Not tainted 6.7.0-00084-gb4b1f27d3b83-dirty #15 > > > > > Hardware name: linux,dummy-virt (DT) > > > > > pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) > > > > > pc : scmi_perf_domain_remove+0x28/0x70 [scmi_perf_domain] > > > > > lr : scmi_perf_domain_remove+0x28/0x70 [scmi_perf_domain] > > > > > sp : ffff80008393bc10 > > > > > x29: ffff80008393bc10 x28: ffff0000875a8000 x27: 0000000000000000 > > > > > x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 > > > > > x23: ffff00008030c090 x22: ffff00008032d490 x21: ffff80007b287050 > > > > > x20: 0000000000000000 x19: ffff00008032d410 x18: 0000000000000000 > > > > > x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 > > > > > x14: 8ba0696d05013a2f x13: 0000000000000000 x12: 0000000000000002 > > > > > x11: 0101010101010101 x10: ffff00008510cff8 x9 : ffff800080a6797c > > > > > x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff6364626d > > > > > x5 : 8080808000000000 x4 : 0000000000000020 x3 : 00000000553a3dc1 > > > > > x2 : ffff0000875a8000 x1 : ffff0000875a8000 x0 : ffff800082ffa048 > > > > > Call trace: > > > > > scmi_perf_domain_remove+0x28/0x70 [scmi_perf_domain] > > > > > scmi_dev_remove+0x28/0x40 [scmi_core] > > > > > device_remove+0x54/0x90 > > > > > device_release_driver_internal+0x1dc/0x240 > > > > > driver_detach+0x58/0xa8 > > > > > bus_remove_driver+0x78/0x108 > > > > > driver_unregister+0x38/0x70 > > > > > scmi_driver_unregister+0x28/0x180 [scmi_core] > > > > > scmi_perf_domain_driver_exit+0x18/0xb78 [scmi_perf_domain] > > > > > __arm64_sys_delete_module+0x1a8/0x2c0 > > > > > invoke_syscall+0x50/0x128 > > > > > el0_svc_common.constprop.0+0x48/0xf0 > > > > > do_el0_svc+0x24/0x38 > > > > > el0_svc+0x34/0xb8 > > > > > el0t_64_sync_handler+0x100/0x130 > > > > > el0t_64_sync+0x190/0x198 > > > > > Code: a90153f3 f9403c14 f9414800 955f8a05 (b9400a80) > > > > > ---[ end trace 0000000000000000 ]--- > > > > > > > > > > Cc: Sudeep Holla > > > > > Cc: Ulf Hansson > > > > > Fixes: 2af23ceb8624 ("pmdomain: arm: Add the SCMI performance domain") > > > > > Signed-off-by: Cristian Marussi > > > > > --- > > > > > I suppose the probe does NOT bail out with an error because this DT config has > > > > > to be supported, right ? > > > > > > > > Actually, no. It's a mistake by me, the probe should bail out with an > > > > error code. > > > > > > > > > > Ok. I suppose any old platform like JUNO that missed this will have to > > > update their DT to use the new scmi_perf_domain...well it should have > > > anyway really, it is just that now it is silently failing. > > > > I don't think it's failing. The old binding for SCMI perf (using > > clock-cells) is still supported the way they were before, which is > > only for cpufreq. > > > > But, yes you are right, both the DT and the consumer driver would need > > to be updated to support SCMI perf. > > > > Not sure if you want to flag an error on platforms that doesn't use this. > IMO probe succeeding doing nothing seems right. Won't returning the error > from probe gets flagged as error during boot or module loading though > it is harmless on the platform since it doesn't use it. > > > In fact, there is also one additional similar problem in probe, when > > the number of perf-domains are zero. In that case, we should also > > return an error code, rather than returning 0. > > > > > > > > > In fact, there is also one additional similar problem in probe, when > > > > the number of perf-domains are zero. In that case, we should also > > > > return an error code, rather than returning 0. > > > > > > > > Would you mind updating the patch to cover both problems - or if you > > > > are too busy, just let me know and I can help out. > > > > > > No problem, I can do it next week, but regarding the zero domain case, > > > I remember I used to do the same on regulator/voltage driver and bail out > > > when no domains were found, but we were asked by some customer to support > > > instead the very useless and funny case of zero domains for some of their > > > testing setup scenarios .. i.e. allowing the driver to load with zero domains > > > (and do nothing) and then unload cleanly avoiding harms while unloading ...) > > > > > > Thoughts about this ? Can fix as you prefer . > > > > In my opinion, there is no point having a module/driver loaded to do > > nothing. I would prefer to just return an error code. > > > > IIRC we had this in one of the driver but there was a request to keep it > this way as it is useful in SCMI f/w bringup/testing. Not all info/features > need to be ready. That said I am fine if pmdomain prefers to flag 0 domains > as error. Well, I don't have a strong opinion around this particular case. My opinion is more generic, keeping modules loaded wastes memory for no good reason. On the other hand, it may not be a problem in this case, as you suggested above. Perhaps a consistent behaviour is better? Kind regards Uffe