From patchwork Thu Oct 15 13:02:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 54999 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f70.google.com (mail-lf0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id C7A4C23069 for ; Thu, 15 Oct 2015 13:02:54 +0000 (UTC) Received: by lfaz124 with SMTP id z124sf2043129lfa.0 for ; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:user-agent:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=VTptZ9lfx6ak+Z8XQQJmlpbzVLvi59CkgxuN9I5W8zc=; b=G7qqoCl/kKQRilVFx7qwn7g8WiI9wOBY7aIDOvimIWtaW5YQvRbwWyIETU48uItZNi 0K9YpcSi1Rx99Pn/fAhNeHYTFLhGqkJRiO/5YKcE2kz53JIMfb1BuRxQvN9+eN67hwQ/ j8UyD92aSwNo6lk3AUKByOSRfWOVnMmW9Div/N3UktFdETeDNpXNQ7F+I7lhxD+suuJt vcty5ms1X4cbcCeAfp7gZ2Z2BHcQ6oHOemUKixJ21r/eJuZiwwXPXZTM8/YsRvR6QETi 3hHaNhpVEI6Do9hoJSsFcTvZP6exyDFH21Iu61eplV8v+Wv7Ass1jkCqAynm/vZKTuK/ Aszg== X-Gm-Message-State: ALoCoQl0z8ATvDVKuN+1ZMWhcHEneeVxQr2UEEXatSDRhvjDPd15rTaJldh4Nh2ORR0bVme4bElz X-Received: by 10.180.9.104 with SMTP id y8mr6891565wia.7.1444914173717; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.166.82 with SMTP id p79ls163329lfe.99.gmail; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Received: by 10.112.17.34 with SMTP id l2mr4429096lbd.117.1444914173500; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id p76si9076508lfp.100.2015.10.15.06.02.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Oct 2015 06:02:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbbwb3 with SMTP id wb3so6204926lbb.1 for ; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Received: by 10.112.180.230 with SMTP id dr6mr4427471lbc.72.1444914173087; Thu, 15 Oct 2015 06:02:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp619751lbq; Thu, 15 Oct 2015 06:02:51 -0700 (PDT) X-Received: by 10.107.151.70 with SMTP id z67mr6817578iod.73.1444914171270; Thu, 15 Oct 2015 06:02:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hu2si11491949igb.32.2015.10.15.06.02.50; Thu, 15 Oct 2015 06:02:51 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752748AbbJONCs (ORCPT + 30 others); Thu, 15 Oct 2015 09:02:48 -0400 Received: from foss.arm.com ([217.140.101.70]:35520 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750774AbbJONCr (ORCPT ); Thu, 15 Oct 2015 09:02:47 -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 8CB2F3C; Thu, 15 Oct 2015 06:02:44 -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 D906D3F21A; Thu, 15 Oct 2015 06:02:45 -0700 (PDT) Date: Thu, 15 Oct 2015 14:02:47 +0100 From: Will Deacon To: Vladimir Murzin Cc: Russell King - ARM Linux , Shengjiu Wang , "ard.biesheuvel@linaro.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "nico@linaro.org" , Punit Agrawal , Catalin Marinas Subject: Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Message-ID: <20151015130247.GB29301@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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <561F6F3B.6030607@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On Thu, Oct 15, 2015 at 10:17:47AM +0100, Vladimir Murzin wrote: > We might need the same change for arm64 counterpart (see > arch/arm64/kernel/armv8_deprecated.c). Something like below? Will >From 63c3e83073cfac2e011adf0ed6f335275cc977a7 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Thu, 15 Oct 2015 13:55:53 +0100 Subject: [PATCH] arm64: compat: fix stxr failure case in SWP emulation If the STXR instruction fails in the SWP emulation code, we leave *data overwritten with the loaded value, therefore corrupting the data written by a subsequent, successful attempt. This patch re-jigs the code so that we only write back to *data once we know that the update has happened. Reported-by: Shengjiu Wang Reported-by: Vladimir Murzin Signed-off-by: Will Deacon --- arch/arm64/kernel/armv8_deprecated.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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" \