From patchwork Mon Jan 20 17:05:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Pihet X-Patchwork-Id: 23408 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 60500203C6 for ; Mon, 20 Jan 2014 17:05:16 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf6112506pbc.8 for ; Mon, 20 Jan 2014 09:05:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=8KqZU1yCFLNZBE8DTSNj8P+o2s/HBQfSVA7FV3XVT8M=; b=NBz7j0PM2Pu9XvaBRrlCowpThx7Rm+Z7LsOSKi/ROrKl0jd7sqEgyj6EFCBQH5XkBE jKADBoeyf3Zx9M1+bfbbMImGno9w2ZjHG6/Q/7U7Yr6Ty9MvlkgcXj2rypyIB4h6QMTA nsx1+qO0VPV2kPmkzDNMHic23Wb+cVX3Vub+q217Ka2rzJXuoibTPFQvtGH59KBMfEts Eh7SyRaLShtRneX4Lli/pSl557B258veE+jEps9kxVGu24QyWotLm4HDHBLKiCerv0hT XgtqByPHcqxexLLGnnnbqhH/PDCO2TV7v8PEZ/Ky0zTaXznlwAMvdojuTBLfhLUYnYu+ r8Ow== X-Gm-Message-State: ALoCoQmAJxDNp5ZuBObq9b4zdQ83v5wpjVBkpRa2a0fdMb7AYtrLaGou4pukI88jX5aHlxrwQ6yN X-Received: by 10.68.223.202 with SMTP id qw10mr7036099pbc.6.1390237515571; Mon, 20 Jan 2014 09:05:15 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.72 with SMTP id li8ls100845qeb.32.gmail; Mon, 20 Jan 2014 09:05:15 -0800 (PST) X-Received: by 10.52.227.193 with SMTP id sc1mr9132796vdc.1.1390237515434; Mon, 20 Jan 2014 09:05:15 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id fv9si557873vcb.20.2014.01.20.09.05.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 09:05:15 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so1802769veb.7 for ; Mon, 20 Jan 2014 09:05:15 -0800 (PST) X-Received: by 10.53.12.236 with SMTP id et12mr123486vdd.46.1390237515353; Mon, 20 Jan 2014 09:05:15 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp67681vcz; Mon, 20 Jan 2014 09:05:14 -0800 (PST) X-Received: by 10.58.67.9 with SMTP id j9mr10979373vet.3.1390237514699; Mon, 20 Jan 2014 09:05:14 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id eo4si541435vdb.147.2014.01.20.09.05.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 09:05:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of jean.pihet@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id g10so2935758vbg.14 for ; Mon, 20 Jan 2014 09:05:14 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.58.248.198 with SMTP id yo6mr3184vec.40.1390237514555; Mon, 20 Jan 2014 09:05:14 -0800 (PST) Received: by 10.58.100.79 with HTTP; Mon, 20 Jan 2014 09:05:14 -0800 (PST) In-Reply-To: <20140117100723.GB16003@mudshark.cambridge.arm.com> References: <1389869123-5884-1-git-send-email-jean.pihet@linaro.org> <20140116115634.GE30257@mudshark.cambridge.arm.com> <20140116125727.GI30257@mudshark.cambridge.arm.com> <20140117100723.GB16003@mudshark.cambridge.arm.com> Date: Mon, 20 Jan 2014 18:05:14 +0100 Message-ID: Subject: Re: [PATCH] ARM64: perf: support dwarf unwinding in compat mode From: Jean Pihet To: Will Deacon Cc: "linux-kernel@vger.kernel.org" , "linaro-kernel@lists.linaro.org" , "linux-arm-kernel@lists.infradead.org" , Arnaldo , "patches@linaro.org" , Jiri Olsa , Ingo Molnar , Steve Capper X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jean.pihet@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi Will, Here is an updated version of the change, which uses compat_sp at only one place. The drawback is that compat_user_mode is checked when calling compat_user_stack_pointer, which seems unnecessary. Unfortunately the check is not optimized out by the complier as I could check with objdump -S. What do you think? Regards, Jean On 17 January 2014 11:07, Will Deacon wrote: > On Fri, Jan 17, 2014 at 09:00:09AM +0000, Jean Pihet wrote: >> On 16 January 2014 14:47, Jean Pihet wrote: >> >> So the simplest thing would be to make compat_user_stack_pointer expand to >> >> user_stack_pointer(current_pt_regs()) on arm64 and merge that in with your >> >> original patch fixing user_stack_pointer. >> >> I see 2 issues in your proposal: >> >> 1) user_stack_pointer(regs) calls compat_user_stack_pointer if >> compat_user_mode(regs)) and compat_user_stack_pointer expands to >> user_stack_pointer. I see a circular dependency in the macros. > > Not today it doesn't, so you just need to avoid writing the circular > dependency and instead make user_stack_pointer access (regs)->compat_sp > instead. > >> 2) current_pt_regs() returns the current task regs although perf >> passes a regs struct that had been recorded previously. > > Yes, but compat_user_stack_pointer doesn't take a regs paramater anyway, so > there's no change in behaviour here. > > Will diff --git a/arch/arm64/include/asm/compat.h b/arch/arm64/include/asm/compat.h index fda2704..e71f81f 100644 --- a/arch/arm64/include/asm/compat.h +++ b/arch/arm64/include/asm/compat.h @@ -228,7 +228,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr) return (u32)(unsigned long)uptr; } -#define compat_user_stack_pointer() (current_pt_regs()->compat_sp) +#define compat_user_stack_pointer() (user_stack_pointer(current_pt_regs())) static inline void __user *arch_compat_alloc_user_space(long len) { diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h index fbb0020..86d5b54 100644 --- a/arch/arm64/include/asm/ptrace.h +++ b/arch/arm64/include/asm/ptrace.h @@ -133,7 +133,7 @@ struct pt_regs { (!((regs)->pstate & PSR_F_BIT)) #define user_stack_pointer(regs) \ - ((regs)->sp) + (!compat_user_mode(regs)) ? ((regs)->sp) : ((regs)->compat_sp) /* * Are the current registers suitable for user mode? (used to maintain