From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E945C67839 for ; Thu, 13 Dec 2018 17:24:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 201CA20870 for ; Thu, 13 Dec 2018 17:24:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 201CA20870 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729736AbeLMRYQ (ORCPT ); Thu, 13 Dec 2018 12:24:16 -0500 Received: from vmicros1.altlinux.org ([194.107.17.57]:40370 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728075AbeLMRYP (ORCPT ); Thu, 13 Dec 2018 12:24:15 -0500 Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id EE80272CC6C; Thu, 13 Dec 2018 20:24:12 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id E0A9B964E82; Thu, 13 Dec 2018 20:24:12 +0300 (MSK) Date: Thu, 13 Dec 2018 20:24:12 +0300 From: "Dmitry V. Levin" To: Guan Xuetao , Paul Moore , Eric Paris , Oleg Nesterov , Andy Lutomirski Cc: Elvira Khabirova , Eugene Syromyatnikov , linux-audit@redhat.com, linux-kernel@vger.kernel.org Subject: [PATCH v6 23/27] unicore32: add asm/syscall.h Message-ID: <20181213172412.GW6024@altlinux.org> References: <20181213171833.GA5240@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org syscall_get_* functions are required to be implemented on all architectures in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request. This introduces asm/syscall.h on unicore32 implementing all 5 syscall_get_* functions as documented in asm-generic/syscall.h: syscall_get_nr, syscall_get_arguments, syscall_get_error, syscall_get_return_value, and syscall_get_arch. A note for the unicore32 architecture maintainer: I have no idea about the syscall semantics on this architecture, and the code is of little help here. All I could infer from the code is that it looks very similar to ARM, so the implementation of syscall_get_* functions is also similar to ARM. Cc: Guan Xuetao Cc: Paul Moore Cc: Eric Paris Cc: Oleg Nesterov Cc: Andy Lutomirski Cc: Elvira Khabirova Cc: Eugene Syromyatnikov Cc: linux-audit@redhat.com Signed-off-by: Dmitry V. Levin --- Notes: v6: made use of asm-generic/syscall.h v5: added syscall_get_nr, syscall_get_arguments, syscall_get_error, and syscall_get_return_value v1: added syscall_get_arch arch/unicore32/include/asm/syscall.h | 46 ++++++++++++++++++++++++++++ include/uapi/linux/audit.h | 1 + 2 files changed, 47 insertions(+) create mode 100644 arch/unicore32/include/asm/syscall.h diff --git a/arch/unicore32/include/asm/syscall.h b/arch/unicore32/include/asm/syscall.h new file mode 100644 index 000000000000..267e97e256bd --- /dev/null +++ b/arch/unicore32/include/asm/syscall.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_UNICORE_SYSCALL_H +#define _ASM_UNICORE_SYSCALL_H + +#include +#include +#include +#include + +static inline int +syscall_get_nr(struct task_struct *task, struct pt_regs *regs) +{ + return task_thread_info(task)->syscall; +} + +static inline void +__syscall_get_arguments(struct task_struct *task, struct pt_regs *regs, + unsigned int i, unsigned int n, unsigned long *args) +{ + if (i == 0) { + args[0] = regs->UCreg_ORIG_00; + args++; + i++; + n--; + } + memcpy(args, ®s->UCreg_00 + i, n * sizeof(args[0])); +} + +static inline long +syscall_get_error(struct task_struct *task, struct pt_regs *regs) +{ + return IS_ERR_VALUE(regs->UCreg_00) ? regs->UCreg_00 : 0; +} + +static inline long +syscall_get_return_value(struct task_struct *task, struct pt_regs *regs) +{ + return regs->UCreg_00; +} + +static inline int +syscall_get_arch(void) +{ + return AUDIT_ARCH_UNICORE; +} + +#endif /* _ASM_UNICORE_SYSCALL_H */ diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index bcc0619b046f..3901c51c0b93 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h @@ -424,6 +424,7 @@ enum { #define AUDIT_ARCH_TILEGX (EM_TILEGX|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #define AUDIT_ARCH_TILEGX32 (EM_TILEGX|__AUDIT_ARCH_LE) #define AUDIT_ARCH_TILEPRO (EM_TILEPRO|__AUDIT_ARCH_LE) +#define AUDIT_ARCH_UNICORE (EM_UNICORE|__AUDIT_ARCH_LE) #define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) #define AUDIT_ARCH_XTENSA (EM_XTENSA) -- ldv