From patchwork Tue Jun 2 05:48:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 479292 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3CD111412E3 for ; Tue, 2 Jun 2015 15:48:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755565AbbFBFsu (ORCPT ); Tue, 2 Jun 2015 01:48:50 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:34590 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755536AbbFBFso (ORCPT ); Tue, 2 Jun 2015 01:48:44 -0400 Received: by payr10 with SMTP id r10so43123895pay.1 for ; Mon, 01 Jun 2015 22:48:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CrSBV2o+5kTVNWdzwVHNlSgRFtI3SFNeNXlDXBMzQlA=; b=OLVIsZdmC8Xii4azi7N65muk6Sy9fxa+fpri4B/ZoBGX2KoZUzVxUf8sEH3RxjQk37 ZTfqa8DMSFl+tUeQHUSe/FpgSSYnq8E75NkzPjsMMnLyHrOgXtgDM8jFWKzIkxFxIAOS PJ+urdESDnXUzPlV/2L3a1sRRIW2lOJBFNiGEjxBw3NNGw3Su6I9PiNaHu9zEelUL000 HXqP3b8ZSmKIWIGc5FGu6XQkasRfuPmgWWWTons6QzeJKqQkR7LhIbUHp118JQAJ0JoK 0tY3sl9Pbs5Uauo7PclqcOy8SHLWXNgAIddSmEA14izzDolLlj1yrjl/biOsbbARbmVq ntHQ== X-Gm-Message-State: ALoCoQn3ytVZdANb5mFV5QCZpUm3ILUIjGQ66Bh5obKmHHWy7ryPH3bnAAQGqj5zKWRRIqkHiMI0 X-Received: by 10.70.41.78 with SMTP id d14mr20396246pdl.35.1433224124051; Mon, 01 Jun 2015 22:48:44 -0700 (PDT) Received: from localhost.localdomain ([12.229.56.227]) by mx.google.com with ESMTPSA id ph4sm16422763pdb.43.2015.06.01.22.48.42 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jun 2015 22:48:43 -0700 (PDT) From: Alexei Starovoitov To: "David S. Miller" Cc: Michael Holzheu , Martin Schwidefsky , Heiko Carstens , Daniel Borkmann , netdev@vger.kernel.org Subject: [PATCH net 2/2] s390/bpf: fix bpf frame pointer setup Date: Mon, 1 Jun 2015 22:48:35 -0700 Message-Id: <1433224115-28411-2-git-send-email-ast@plumgrid.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1433224115-28411-1-git-send-email-ast@plumgrid.com> References: <1433224115-28411-1-git-send-email-ast@plumgrid.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Michael Holzheu Currently the bpf frame pointer is set to the old r15. This is wrong because of packed stack. Fix this and adjust the frame pointer to respect packed stack. This now generates a prolog like the following: 3ff8001c3fa: eb67f0480024 stmg %r6,%r7,72(%r15) 3ff8001c400: ebcff0780024 stmg %r12,%r15,120(%r15) 3ff8001c406: b904001f lgr %r1,%r15 <- load backchain 3ff8001c40a: 41d0f048 la %r13,72(%r15) <- load adjusted bfp 3ff8001c40e: a7fbfd98 aghi %r15,-616 3ff8001c412: e310f0980024 stg %r1,152(%r15) <- save backchain Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend") Signed-off-by: Michael Holzheu Acked-by: Heiko Carstens Signed-off-by: Alexei Starovoitov --- arch/s390/net/bpf_jit_comp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 20c146d1251a..55423d8be580 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -384,13 +384,16 @@ static void bpf_jit_prologue(struct bpf_jit *jit) } /* Setup stack and backchain */ if (jit->seen & SEEN_STACK) { - /* lgr %bfp,%r15 (BPF frame pointer) */ - EMIT4(0xb9040000, BPF_REG_FP, REG_15); + if (jit->seen & SEEN_FUNC) + /* lgr %w1,%r15 (backchain) */ + EMIT4(0xb9040000, REG_W1, REG_15); + /* la %bfp,STK_160_UNUSED(%r15) (BPF frame pointer) */ + EMIT4_DISP(0x41000000, BPF_REG_FP, REG_15, STK_160_UNUSED); /* aghi %r15,-STK_OFF */ EMIT4_IMM(0xa70b0000, REG_15, -STK_OFF); if (jit->seen & SEEN_FUNC) - /* stg %bfp,152(%r15) (backchain) */ - EMIT6_DISP_LH(0xe3000000, 0x0024, BPF_REG_FP, REG_0, + /* stg %w1,152(%r15) (backchain) */ + EMIT6_DISP_LH(0xe3000000, 0x0024, REG_W1, REG_0, REG_15, 152); } /*