From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tony Luck Subject: Re: [PATCH v2 2/5] firmware: Basic dmi-sysfs support Date: Wed, 23 Feb 2011 13:29:46 -0800 Message-ID: References: <20110223015307.13068.14063.stgit@mike.mtv.corp.google.com> <20110223015320.13068.77428.stgit@mike.mtv.corp.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mike Waychison Cc: Greg KH , Olof Johansson , Andi Kleen , Alan Cox , Robert Lippert , Jon Mayer , Duncan Laurie , Aaron Durbin , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Tim Hockin , David Hendrix , linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-api@vger.kernel.org On Wed, Feb 23, 2011 at 12:28 PM, Mike Waychison wro= te: > Ya, I don't think there is anything that guarantees that dmi_header i= s > aligned. =A0 The access is probably the struct copy I did here: > > =A0 =A0 =A0 =A0/* Set the key */ > =A0 =A0 =A0 =A0entry->dh =3D *dh; Yup - looking back at the assembly I see that one of the 2-byte accesses is offset 2 (picking up ->handle), but the second is offset 0 (picking up ->type and ->length). The compiler assumed the structure was 2-byte aligned because of ->handle. > What if we changed that guy to use memcpy? =A0We'd probably need to > memcpy the dmi_system_event_log as well. =A0Patch attached (applies o= n > top of the entire patchset). With the patch, all the unaligned accesses go away. Tested-by: Tony Luck -Tony