From mboxrd@z Thu Jan 1 00:00:00 1970 From: Greentime Hu Subject: Re: [PATCH v6 07/36] nds32: Exception handling Date: Tue, 30 Jan 2018 22:49:32 +0800 Message-ID: References: <28c2c9da4da4c8b07473e97cd4a6cb953f4b507c.1515766253.git.green.hu@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Arnd Bergmann Cc: Vincent Chen , Greentime , Linux Kernel Mailing List , linux-arch , Thomas Gleixner , Jason Cooper , Marc Zyngier , Rob Herring , Networking , DTML , Al Viro , David Howells , Will Deacon , Daniel Lezcano , linux-serial@vger.kernel.org, Geert Uytterhoeven , Linus Walleij , Mark Rutland , Greg KH , Guo Ren List-Id: devicetree@vger.kernel.org Hi, Arnd: 2018-01-30 21:33 GMT+08:00 Arnd Bergmann : > On Tue, Jan 30, 2018 at 11:01 AM, Vincent Chen wrote: >> 2018-01-24 19:10 GMT+08:00 Arnd Bergmann : >>> On Wed, Jan 24, 2018 at 12:09 PM, Arnd Bergmann wrote: >>>> On Wed, Jan 24, 2018 at 11:53 AM, Vincent Chen wrote: >>>>> 2018-01-18 18:14 GMT+08:00 Arnd Bergmann : >>> >>>> Ok. I still wonder about the kernel part of this though: is it a good idea >>>> for user space to configure whether the kernel does unaligned >>>> accesses? I would think that the kernel should just be fixed in such >>>> a case. >>> >>> To clarify: I'm asking only about unaligned accesses from kernel code itself, >>> which is generally considered a bug when >>> CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is disabled. >>> >>> Arnd >> >> Thanks for your comments. >> >> For performance, we decide always disable >> CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS even if hardware supports >> unaligned accessing. Therefore, I will remove kernel unaligned accessing from >> nds32/mm/alignment.c. In other words, alignment.c only addresses unaligned >> accessing for user space. > > I'm not really following that logic, let's go through that again so I understand > the situation better. > > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS should be set if and > only if you have a CPU that does not need to trap on unaligned accesses. > > What are the hardware capabilities on nds32? Do you have all three > categories: > > a) some CPUs that always trap on unaligned access > b) some CPUs that never trap on unaligned access > c) some CPUs that can be configured to either trap or not trap by > the kernel? > We have type a and c. We use CONFIG_ALIGNMENT_TRAP for a and CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS for c. Since unaligned access in kernel code itself should be considered as a bug, we will remove the emulation code to handle the kernel code unaligned accessed case. We think CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS and CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS have different purposes because it will still be more efficient to access by byte even if hardware support unaligned access. CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS is used to prevent generating unaligned access exception. Thus, we will 1. treat unaligned access in kernel code itself as a bug 2. don't select CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 3. disable CONFIG_HW_SUPPORT_UNALIGNMENT_ACCESS as default