Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB11C433FE for ; Thu, 11 Nov 2021 06:31:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C19D761267 for ; Thu, 11 Nov 2021 06:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbhKKGd6 (ORCPT ); Thu, 11 Nov 2021 01:33:58 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:58230 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229533AbhKKGd4 (ORCPT ); Thu, 11 Nov 2021 01:33:56 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C2E461FD3E; Thu, 11 Nov 2021 06:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1636612266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=69ymtPsNq/3eZDHfNUePOVSowkMa13fiJITlUV6+ofo=; b=UIdAWqj2GbiR3JP0DlmAgOiRts0q3wfu8W39R7vb72BY435rFWoCYs0vFk1p9qlQkZqahq XFpsxg3YKyun94YhEhk+bI+857Vn6Np8uL2dyJWs4uVi2zULmzp9YnIqEL5cTnWhQ29Rh0 i3pw5Iod0nbWSAfdSBbVvHqtvvOvcEA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1636612266; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=69ymtPsNq/3eZDHfNUePOVSowkMa13fiJITlUV6+ofo=; b=l6P9dnK0rd62R8j/D5puDWymcUHYY6hY1tTbgDZBfObJ5QfcNhW+mMJBhNUFZX8nMNMYak FvRNDl2XwL0ErhCA== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id B2170A3B81; Thu, 11 Nov 2021 06:31:06 +0000 (UTC) Date: Thu, 11 Nov 2021 07:31:06 +0100 Message-ID: From: Takashi Iwai To: Pkshih Cc: Takashi Iwai , "kvalo@codeaurora.org" , "linux-wireless@vger.kernel.org" , "Larry.Finger@gmail.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] rtw89: Fix crash by loading compressed firmware file In-Reply-To: <68f61525b26f46578a62b2a54d775c17@realtek.com> References: <20211105071725.31539-1-tiwai@suse.de> <87zgqjqaae.fsf@codeaurora.org> <87v917q8hw.fsf@codeaurora.org> <68f61525b26f46578a62b2a54d775c17@realtek.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Nov 2021 03:28:09 +0100, Pkshih wrote: > > > > -----Original Message----- > > From: Takashi Iwai > > Sent: Friday, November 5, 2021 11:07 PM > > To: Pkshih > > Cc: kvalo@codeaurora.org; linux-wireless@vger.kernel.org; Larry.Finger@gmail.com; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH] rtw89: Fix crash by loading compressed firmware file > > > > > > You should put const in the cast in le32_get_bits() invocations, at > > least. > > > > For the le32_replace_bits(), ideally it should be rewritten in some > > better way the compiler can catch. e.g. use an inline function to > > take a void * argument without const, > > > > static inline void RTW89_SET_FWCMD_CXRFK_TYPE(void *cmd, unsigned int val) > > { > > le32p_replace_bits((__le32 *)((u8 *)(cmd) + 2), val, GENMASK(17, 10)); > > } > > > > Then the compiler will warn when you pass a const pointer there. > > > > I have sent a patchset [1] to do these two things by patch 2 and 3. > > > > > BTW, while reading your reply, I noticed that it's an unaligned access > > to a 32bit value, which is another potential breakage on some > > architectures. So the whole stuff has to be rewritten in anyway... > > > > We use these macros/inline function on skb->data mostly, and I > suppose skb->data is a 32bit aligned address. Since I don't have > this kind of machine on hand, I would like to defer this work until > I have one. I actually misread the code. The register offset is applied to __le32 pointer, so this should be fine. > > > partition size we are going to download, and it is only used > > > by rtw89_fw_download_hdr(). So, I will set the partition size > > > after copying constant firmware header into skb->data. > > > > Sounds good. > > > > Please check if my patch works on your platform. > Thanks you. > > [1] https://lore.kernel.org/linux-wireless/20211111021457.13776-1-pkshih@realtek.com/T/#t Thanks. I'll ask people testing those patches. Takashi