Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752996AbbKQEhO (ORCPT ); Mon, 16 Nov 2015 23:37:14 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:33221 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752131AbbKQEhM (ORCPT ); Mon, 16 Nov 2015 23:37:12 -0500 MIME-Version: 1.0 In-Reply-To: <1447713335-29707-1-git-send-email-yang.shi@linaro.org> References: <1447713335-29707-1-git-send-email-yang.shi@linaro.org> Date: Mon, 16 Nov 2015 20:37:11 -0800 Message-ID: Subject: Re: [PATCH V4 2/2] arm64: bpf: make BPF prologue and epilogue align with ARM64 AAPCS From: Z Lim To: Yang Shi Cc: Alexei Starovoitov , Daniel Borkmann , Catalin Marinas , Will Deacon , "David S. Miller" , Xi Wang , LKML , Network Development , "linux-arm-kernel@lists.infradead.org" , linaro-kernel@lists.linaro.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2055 Lines: 46 On Mon, Nov 16, 2015 at 2:35 PM, Yang Shi wrote: > Save and restore FP/LR in BPF prog prologue and epilogue, save SP to FP > in prologue in order to get the correct stack backtrace. > > However, ARM64 JIT used FP (x29) as eBPF fp register, FP is subjected to > change during function call so it may cause the BPF prog stack base address > change too. > > Use x25 to replace FP as BPF stack base register (fp). Since x25 is callee > saved register, so it will keep intact during function call. > It is initialized in BPF prog prologue when BPF prog is started to run > everytime. Save and restore x25/x26 in BPF prologue and epilogue to keep > them intact for the outside of BPF. Actually, x26 is unnecessary, but SP > requires 16 bytes alignment. > > So, the BPF stack layout looks like: > > high > original A64_SP => 0:+-----+ BPF prologue > |FP/LR| > current A64_FP => -16:+-----+ > | ... | callee saved registers > +-----+ > | | x25/x26 > BPF fp register => -80:+-----+ > | | > | ... | BPF prog stack > | | > | | > current A64_SP => +-----+ > | | > | ... | Function call stack > | | > +-----+ > low > > CC: Zi Shen Lim > CC: Xi Wang > Signed-off-by: Yang Shi Acked-by: Zi Shen Lim -- 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/