Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3530114pxb; Mon, 4 Apr 2022 20:05:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDzr/ALfPgDtqplgtvwbVdppHEPcDdOmcBMqlrhc/DFzCpN8cO0BLbRGHy9ihtbZUTjOZm X-Received: by 2002:a05:6a00:10c7:b0:4fd:9ee6:4130 with SMTP id d7-20020a056a0010c700b004fd9ee64130mr1520400pfu.84.1649127942434; Mon, 04 Apr 2022 20:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127942; cv=none; d=google.com; s=arc-20160816; b=DOnWGOfL56sHHbvCvedrt0inW+5mfuN5JxSVKpgAiejExhgFupKxp7vMEcCJUV2bjx qr1UO8PWmfJF1izDeMGYvNxPFYzUt3SdLhGQxQVhWUuNllhVZ31NMylgzJV2baq80ysB fP35tD9ZA7czSu4wDe7wb9vjT70trXI3dG63TYLOG5bKa+l5YMYPWBsiO+oWgNI8yknB HioEvXUBNc/y+Sb53GmDDYer0dOJa/Pesh6N+EiMK79mrp7N7MGNnLGcu5QM+lqnnw4f niOUY0JKU3yTqg6T8NvgFSzg7wiKMQYe+USPoxnQwayK9i2dL4RdD2SKBXpQRH6DOrKF jSkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2vAojo5hYXmYjCKQiuEeKOkohn772GTgKXZNnt+U4dI=; b=ZOax71ZlaZGY5xxbQ+ywsYw6eCmTYYNZwj0qBT773QqSuaO1YpuuSJyxaVcBB7B7DL S3vtvQ5LPiifMuE0+aRccCBym+3rG344negq0LYnf16xTMLlnWVbS+tWdbu3NwseaIBW dUiTtGNNMubg8qub378jmlsAB9sgg8H3qGvvvnOGB2LMt/1haK3WOI01n4nj+mVFM7hr uPqQ02mlKpC9F4RM44EsIX56rZqnTlTfh9kUFo0vQHWvp/bucImsf3QOjZUGcvwgE1W4 McTGcGURXJmu3yeGMsHNF5LDopa4TC8yk0ubBNPdU3Nqzsz80Mif0hXm19Vy4w/ZopZ3 hxxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="d/q/YFw1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id me17-20020a17090b17d100b001c6edf679b4si842988pjb.46.2022.04.04.20.05.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 20:05:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="d/q/YFw1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8978435276F; Mon, 4 Apr 2022 18:29:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347871AbiDAOgX (ORCPT + 99 others); Fri, 1 Apr 2022 10:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347411AbiDAOcb (ORCPT ); Fri, 1 Apr 2022 10:32:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7257B1EC617; Fri, 1 Apr 2022 07:28:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1C48BB8250D; Fri, 1 Apr 2022 14:28:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6B04C3410F; Fri, 1 Apr 2022 14:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823334; bh=VxRjH+yePUztBpyRJiPML7F1J4TddIPIrzTvUM1JGE0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/q/YFw14T6YKzP7qYP/MhYEhYguTJsuDGMIPZtZEhmI4/FloN0JBIrTvdvt/QKQF yhySXqiIwD2u6ioQvuwqucbN5K5XiwOWWWgpRs8yBCTnYByBH2u3bSjOE4mQWl2s5Z R/TyYMDHL65BBI5wCcpoB8sR+yWN7DMd9BqEtha0d1ZrbgSbDBphw+zDliCSj4jmhp K7vS/L1s0uK5UjENmcQVEgT/nPom3LGFyCisGLbr1na98wVvBaChUE7d3UB+ltgyuK 9ggBTQJdtMCJtktMyzZBIhCbskYGLPqKha67E6qA2glTDDDFwl+fujP4PLSytdasnn bvGF5OG2+fG/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ilya Leoshkevich , Andrii Nakryiko , Sasha Levin , ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.17 062/149] libbpf: Fix accessing the first syscall argument on s390 Date: Fri, 1 Apr 2022 10:24:09 -0400 Message-Id: <20220401142536.1948161-62-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401142536.1948161-1-sashal@kernel.org> References: <20220401142536.1948161-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Leoshkevich [ Upstream commit 1f22a6f9f9a0f50218a11a0554709fd34a821fa3 ] On s390, the first syscall argument should be accessed via orig_gpr2 (see arch/s390/include/asm/syscall.h). Currently gpr[2] is used instead, leading to bpf_syscall_macro test failure. orig_gpr2 cannot be added to user_pt_regs, since its layout is a part of the ABI. Therefore provide access to it only through PT_REGS_PARM1_CORE_SYSCALL() by using a struct pt_regs flavor. Reported-by: Andrii Nakryiko Signed-off-by: Ilya Leoshkevich Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220209021745.2215452-11-iii@linux.ibm.com Signed-off-by: Sasha Levin --- tools/lib/bpf/bpf_tracing.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index ad62c17919cf..92bf90e716ea 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -112,6 +112,10 @@ #elif defined(bpf_target_s390) +struct pt_regs___s390 { + unsigned long orig_gpr2; +}; + /* s390 provides user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const user_pt_regs *)(x)) #define __PT_PARM1_REG gprs[2] @@ -124,6 +128,8 @@ #define __PT_RC_REG gprs[2] #define __PT_SP_REG gprs[15] #define __PT_IP_REG psw.addr +#define PT_REGS_PARM1_SYSCALL(x) ({ _Pragma("GCC error \"use PT_REGS_PARM1_CORE_SYSCALL() instead\""); 0l; }) +#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs___s390 *)(x), orig_gpr2) #elif defined(bpf_target_arm) -- 2.34.1