Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2509055lqt; Mon, 22 Apr 2024 12:45:45 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWtrPh5QZ2nILwQa9joypYHvWUA3VeCxvaBBSRJcDGkgHpCHXcI5Vs44JtnNv62oZ7Y0WGKWgObKyn6EZCUCvUKDB/hfMhuJD5UQREj/A== X-Google-Smtp-Source: AGHT+IHRoKxID0jZWUgzJx5Y/0Dkqg24BV9HYHUnUGxRJYEL8oqrnDN+iCAYsY2yTlhttrqWCXkO X-Received: by 2002:a17:906:e091:b0:a57:c758:738f with SMTP id gh17-20020a170906e09100b00a57c758738fmr1330967ejb.0.1713815145469; Mon, 22 Apr 2024 12:45:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713815145; cv=pass; d=google.com; s=arc-20160816; b=CaTOhbG/r2SZo2j2N76xxJ/hSLBoYqdlKn/5ewoV2QDI5kRNIZI24jAR6jiZvDGxMY bXTInpl/AE/+UGE739/LSl67LYOqbuiTL9QrZ3VPMMT8n5ojFGNOZ9onAhOzZg8fQYIC QrQ1G73vCEqSURr9Df6y3aTdZ614+FjzdKdRNIul74uDzFfeFM//jTfbw1ACNxzNE++3 4yXNUMnF6nqKhYFw+FFTuA1J6fzw4ZjzOM7ci01CjIEOSlofOx2qqoCSkfm45/DNYBKs 4j8VMnFdcjNvCoMyJWUR2fgbuSghJ6enAByhDySO2uN2/saI84dEizNi35V13L+dPA9g JnMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :from:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=3cAj/hNGYhv+2z4jYPmTSzvNSZGBGYnvaTOAo/z2GUw=; fh=PQh9x28GSs7iKaLfYEppaEeHcuRobSMERDjq4vD8crE=; b=oWIB0ya7KR5fQcmo6WJ19sxeqcm6YQ8kugVl5WrjBK/C9d4aVgGJeQPiWPNy74T3mb IR+Vw6OR3GXU1nR0kPpnDCQiEaqOoofYH8qVxMd7o7OZj5PFkdpzXvGfYwTlS9ySosE4 GznaIig4YbmOAH+P9VQdwyWb9kvMI9TGbQfD6vi/q4BaboWscRdJD9D95qLA/ZpW2IQ5 bdJj9daYJ1xZICii2NlkqmkpLSm4Hgeb9GhbNG9xWVODePfK0TGOw//iMLkmjMS85bGe RNEo+wCO5ER70TOyE/kXLvSqAhK/EIcM1ieJwVqRVW3ny+vtt2d7AJRWWWgRzzO1r5di QM1A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GKVM+2Ih; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ds18-20020a170907725200b00a55ac4e1e5dsi2540585ejc.607.2024.04.22.12.45.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 12:45:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GKVM+2Ih; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-153934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0738B1F225E9 for ; Mon, 22 Apr 2024 19:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A52BE15535B; Mon, 22 Apr 2024 19:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GKVM+2Ih" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B2CF155335; Mon, 22 Apr 2024 19:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713815131; cv=none; b=niuxGwsTcdWU8RBb3+o5xzSoIQjNGt5tVEkBBfV+spiARI9kmGTjSbP+avSdOQ3Mx2VCQrMDja0QLlbHEz0x285PRQ/cQ08MkoC7mc+unJt3hWGS57Ax/E7CwVgiFMCRpGgg4eEJs1tMuBvT2LZEzaFose9OUDsLhE0fBpaIxVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713815131; c=relaxed/simple; bh=jA8EbIxkn0jYEYRo1b3nNwvkaBXoHQ5RVS21ZJPQkQQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZUG7o2hXAspbGQGD0m36DjLsaEq1xggIBf9Jc9j/CVdlHUJY7zlFBhOmEaaHM5RKIxMxXetE+miBTbUHuGrwmXqmqPPeEWGszaFpf8otONJ1syTRtIPIAZmz/cdqinINJ2QroO1amRS/TboASR6UwdFuRx2yicTnqfqD3P6/lBo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GKVM+2Ih; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06B54C113CC; Mon, 22 Apr 2024 19:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713815131; bh=jA8EbIxkn0jYEYRo1b3nNwvkaBXoHQ5RVS21ZJPQkQQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=GKVM+2Ih8rza3HC0WzMydQA0HRN+CpwKn21eo7HS1YMjUv7GUp85v0aPQgY60oLKx 1WrQiuRPMEh/JPcosJkQW/n6T9scAfCit7Zfkgf2qb4KgqrOUcRXf4xkdjJsvq6Ihx T9Gi/0mDC8Yg3yixV2IiZENuuSZDZIGmFXJr/qCqSSX7TXVh+PW3fnUbVh9H2W+k0j znaLq/LFfBTVFtABAC/gCYQH/Wcz06Qr7XFO+tPe94tgywViC47isvdicdPG8JoWL/ cdzEtd+xUDq6aYvklAwzz7XgVMw/be6uJxMOOjEhT6GP50kk51eknFrQM9AbI1ynNX zbwG5ehCPI3LA== Message-ID: <138ac465-1576-4e86-a05d-63f8acc6fb70@kernel.org> Date: Mon, 22 Apr 2024 21:45:22 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 00/14] ASoC: Constify local snd_sof_dsp_ops To: Pierre-Louis Bossart , Liam Girdwood , Peter Ujfalusi , Bard Liao , Ranjani Sridharan , Daniel Baluta , Kai Vehmanen , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Matthias Brugger , AngeloGioacchino Del Regno Cc: sound-open-firmware@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20240414-n-const-ops-var-v1-0-8f53ee5d981c@kernel.org> <89f8f0be-2534-46c8-9058-cabea4f68568@linux.intel.com> <9d1eda85-32a0-4e53-86ca-ce3137439bd7@kernel.org> From: Krzysztof Kozlowski Content-Language: en-US Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kWvN79 cFgcqTTuNHjAvxtUG8pQgGTHAObYs6xeYJtjUH0ZX6ndJ33FJYf5V3yXqqjcZ30FgHzJCFUu JMp7PSyMPzpUXfU12yfcRYVEMQrmplNZssmYhiTeVicuOOypWugZKVLGNm0IweVCaZ/DJDIH gNbpvVwjcKYrx85m9cBVEBUGaQP6AT7qlVCkrf50v8bofSIyVa2xmubbAwwFA1oxoOusjPIE J3iadrwpFvsZjF5uHAKS+7wHLoW9hVzOnLbX6ajk5Hf8Pb1m+VH/E8bPBNNYKkfTtypTDUCj NYcd27tjnXfG+SDs/EXNUAIRefCyvaRG7oRYF3Ec+2RgQDRnmmjCjoQNbFrJvJkFHlPeHaeS BosGY+XWKydnmsfY7SSnjAzLUGAFhLd/XDVpb1Een2XucPpKvt9ORF+48gy12FA5GduRLhQU vK4tU7ojoem/G23PcowM1CwPurC8sAVsQb9KmwTGh7rVz3ks3w/zfGBy3+WmLg++C2Wct6nM Pd8/6CBVjEWqD06/RjI2AnjIq5fSEH/BIfXXfC68nMp9BZoy3So4ZsbOlBmtAPvMYX6U8VwD TNeBxJu5Ex0Izf1NV9CzC3nNaFUYOY8KfN01X5SExAoVTr09ewARAQABzSVLcnp5c3p0b2Yg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6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 22/04/2024 17:52, Pierre-Louis Bossart wrote: > > > On 4/22/24 00:43, Krzysztof Kozlowski wrote: >> On 15/04/2024 16:19, Pierre-Louis Bossart wrote: >>> >>>> The core code does not modify the 'struct snd_sof_dsp_ops' passed via >>>> pointer in various places, so this can be made pointer to const. >>> >>> The structure itself is NOT always const - the initialization itself >>> does have platform-specific changes, so what do we really gain from all >>> this? >> >> In the context of these patches, the structure is *always* const. In >> other drivers, it is not, but they are not really relevant here. >> >>> >>> some commit messages say the code is "a bit safer", but I personally >>> find the 'const' more confusing since the information that the structure >>> can be modified during initialization is lost. >> >> Functions which take some data and do not modify it are easier to read >> if the pointed data is marked as const. Then it is obvious that >> functions for example is re-entrant. Or that it does not affect the >> state of other devices/core structures. >> >> Additionally, the static data is safer when is const, because it cannot >> be used in some attacks. > > agree, but here you are marking as 'const' non-static data. What do you mean? Entire point of this patchset is for static and global data. Which patches are you reviewing? > >> I really do not understand which information you lost here? Core does >> not change the ops, so the data should be passed as const as often as >> possible. If anyone wants to write a driver which does not use static >> ops, but somehow dynamically allocated and changed, nothing stops him. >> This patch did not make it less readable/doable. >> >> The point is that these ops do not differ from other ops or some other >> driver-passed structures, which we have around 100 already in checkpatch. > > I am so old that I remember times where we had to put things in ROM. > That's what 'const' means to me: a dedicated memory space for immutable > values. There are multiple reasons and benefits for const, like compiler optimization, code readability (meaning) up to security improvements, e.g. by some GCC plugins or marking rodata as really non-writeable, so closing some ways of exploits. There are many opportunities here, even if they are not yet enabled. > > that's a different interpretation to the 'software' view you're > describing. "this structure will not modified by this function" is not > the same thing as "this structure CANNOT be modified". Yes, but can we please discuss specific patchset then? Patches which change pointers to const have one "interpretation". Patches which modify static or global data have another. > > I am not going to lay on the tracks, if Mark wants to apply the patches > that's fine. I just wanted to highlight that the reason we did not use > 'const' was that the data is dynamically allocated/modified and not > constant at all. Best regards, Krzysztof