From patchwork Tue Oct 27 15:44:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 55632 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1871581lbq; Tue, 27 Oct 2015 08:44:32 -0700 (PDT) X-Received: by 10.68.221.133 with SMTP id qe5mr29062297pbc.93.1445960672681; Tue, 27 Oct 2015 08:44:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id if3si62661605pbc.192.2015.10.27.08.44.32; Tue, 27 Oct 2015 08:44:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964950AbbJ0Poa (ORCPT + 28 others); Tue, 27 Oct 2015 11:44:30 -0400 Received: from foss.arm.com ([217.140.101.70]:57156 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932550AbbJ0Po3 (ORCPT ); Tue, 27 Oct 2015 11:44:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CA1854A; Tue, 27 Oct 2015 08:44:21 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50F773F21A; Tue, 27 Oct 2015 08:44:27 -0700 (PDT) Date: Tue, 27 Oct 2015 15:44:24 +0000 From: Will Deacon To: Catalin Marinas Cc: Vladimir Murzin , Shengjiu Wang , Russell King - ARM Linux , "ard.biesheuvel@linaro.org" , Punit Agrawal , "linux-kernel@vger.kernel.org" , "nico@linaro.org" , "linux-arm-kernel@lists.infradead.org" Subject: Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Message-ID: <20151027154424.GG1689@arm.com> References: <1444791077-26020-1-git-send-email-shengjiu.wang@freescale.com> <20151015082417.GX32532@n2100.arm.linux.org.uk> <20151015083629.GA32630@shlinux2> <20151015085700.GY32532@n2100.arm.linux.org.uk> <561F6F3B.6030607@arm.com> <20151015130247.GB29301@arm.com> <561FA948.5080505@arm.com> <5620ACB8.20908@arm.com> <20151016103729.GA6613@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151016103729.GA6613@e104818-lin.cambridge.arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2015 at 11:37:29AM +0100, Catalin Marinas wrote: > On Fri, Oct 16, 2015 at 08:52:24AM +0100, Vladimir Murzin wrote: > > > On 15/10/15 14:02, Will Deacon wrote: > > >> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c > > >> index bcee7abac68e..6039d1eb5912 100644 > > >> --- a/arch/arm64/kernel/armv8_deprecated.c > > >> +++ b/arch/arm64/kernel/armv8_deprecated.c > > >> @@ -284,12 +284,12 @@ static void register_insn_emulation_sysctl(struct ctl_table *table) > > >> __asm__ __volatile__( \ > > >> ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN, \ > > >> CONFIG_ARM64_PAN) \ > > >> - " mov %w2, %w1\n" \ > > >> - "0: ldxr"B" %w1, [%3]\n" \ > > >> - "1: stxr"B" %w0, %w2, [%3]\n" \ > > >> + "0: ldxr"B" %w2, [%3]\n" \ > > >> + "1: stxr"B" %w0, %w1, [%3]\n" \ > > >> " cbz %w0, 2f\n" \ > > >> " mov %w0, %w4\n" \ > > >> "2:\n" \ > > >> + " mov %w1, %w2\n" \ > > >> " .pushsection .fixup,\"ax\"\n" \ > > >> " .align 2\n" \ > > >> "3: mov %w0, %w5\n" \ > > > > On the second thought looks like we still update *data in case stxr > > fails (or I need more coffee). > > I'm on the second cup and I see the same problem. Even if stxr fails, we > fall back through "mov %w1, %w2", so *data is always updated with the > loaded value. Maybe something like below on top of Will's patch: Yeah, sorry, my original patch was an untested mess. I think we can avoid the "cc" clobber by adding a branch to the slow-path, as below. Still needs testing, mind. Will --->8 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 6039d1eb5912..937f5e58a4d3 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -288,17 +288,19 @@ static void register_insn_emulation_sysctl(struct ctl_table *table) "1: stxr"B" %w0, %w1, [%3]\n" \ " cbz %w0, 2f\n" \ " mov %w0, %w4\n" \ + " b 3f\n" \ "2:\n" \ " mov %w1, %w2\n" \ + "3:\n" \ " .pushsection .fixup,\"ax\"\n" \ " .align 2\n" \ - "3: mov %w0, %w5\n" \ - " b 2b\n" \ + "4: mov %w0, %w5\n" \ + " b 3b\n" \ " .popsection" \ " .pushsection __ex_table,\"a\"\n" \ " .align 3\n" \ - " .quad 0b, 3b\n" \ - " .quad 1b, 3b\n" \ + " .quad 0b, 4b\n" \ + " .quad 1b, 4b\n" \ " .popsection\n" \ ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, \ CONFIG_ARM64_PAN) \