From patchwork Sat May 30 17:42:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 478481 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 74B40140F97 for ; Sun, 31 May 2015 03:42:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757426AbbE3Rma (ORCPT ); Sat, 30 May 2015 13:42:30 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35958 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755670AbbE3RmW (ORCPT ); Sat, 30 May 2015 13:42:22 -0400 Received: by pacux9 with SMTP id ux9so39343907pac.3 for ; Sat, 30 May 2015 10:42:22 -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=c5KCJ1HEL8WOY6Y/hFK8ybxNbXf8uwir2zew23C1KxM=; b=BQs8a++yc73yMc6i8v9cvmiciCF+VapIBt2BVEMFOjbWgStqtqDn9/ooWS8hGUVxoi aHPHNG7VWlHRYRGAFBUBDRdeI+CtwvkIGiKGXchwasGirgeLGwpf4JPyrFn35alAaJ+f HMlT+Yx3qXIDWVQornDpqrJHPp30zmcRoBrdMxnuFMLGRrt4wJDFIr7nmZwNrYuL9M6F 7asLgLU8YMvqaFkhrQtFpv8b3w3um6Ct4wCVFax9YqOTBAwyA2MLXTz5xUUzd3nvzpAS /U4i8u7/PJS4pb5T/GxoJqZenjR0wOrQe22bFfQNCplwFisXfUrfodMw31DOi+Po0saE uq2Q== X-Gm-Message-State: ALoCoQnUcB7D+zJUHoB/dIH8CQnsEugWjalDF0EpF7yaHBxwRgqo4kVdbuMu9qqjQs+ry2Puv2KQ X-Received: by 10.69.19.129 with SMTP id gu1mr25794362pbd.162.1433007742057; Sat, 30 May 2015 10:42:22 -0700 (PDT) Received: from localhost.localdomain ([12.229.56.227]) by mx.google.com with ESMTPSA id da3sm9308939pdb.8.2015.05.30.10.42.20 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 May 2015 10:42:21 -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-next 1/3] s390/bpf: fix stack allocation Date: Sat, 30 May 2015 10:42:09 -0700 Message-Id: <1433007731-16992-2-git-send-email-ast@plumgrid.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1433007731-16992-1-git-send-email-ast@plumgrid.com> References: <1433007731-16992-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 On s390x we have to provide 160 bytes stack space before we can call the next function. From the 160 bytes that we got from the previous function we only use 11 * 8 bytes and have 160 - 11 * 8 bytes left. Currently for BPF we allocate additional 160 - 11 * 8 bytes for the next function. This is wrong because then the next function only gets: (160 - 11 * 8) + (160 - 11 * 8) = 2 * 72 = 144 bytes Fix this and allocate enough memory for the next function. Cc: stable@vger.kernel.org # 4.0+ Signed-off-by: Michael Holzheu Acked-by: Heiko Carstens Signed-off-by: Alexei Starovoitov --- arch/s390/net/bpf_jit.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/s390/net/bpf_jit.h b/arch/s390/net/bpf_jit.h index ba8593a515ba..de156ba3bd71 100644 --- a/arch/s390/net/bpf_jit.h +++ b/arch/s390/net/bpf_jit.h @@ -48,7 +48,9 @@ extern u8 sk_load_word[], sk_load_half[], sk_load_byte[]; * We get 160 bytes stack space from calling function, but only use * 11 * 8 byte (old backchain + r15 - r6) for storing registers. */ -#define STK_OFF (MAX_BPF_STACK + 8 + 4 + 4 + (160 - 11 * 8)) +#define STK_SPACE (MAX_BPF_STACK + 8 + 4 + 4 + 160) +#define STK_160_UNUSED (160 - 11 * 8) +#define STK_OFF (STK_SPACE - STK_160_UNUSED) #define STK_OFF_TMP 160 /* Offset of tmp buffer on stack */ #define STK_OFF_HLEN 168 /* Offset of SKB header length on stack */