From owner-svn-src-all@freebsd.org Mon Jun 25 22:36:27 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1AD34102361D; Mon, 25 Jun 2018 22:36:27 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B83BD7112D; Mon, 25 Jun 2018 22:36:26 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9A00D38CA; Mon, 25 Jun 2018 22:36:26 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5PMaQaQ069612; Mon, 25 Jun 2018 22:36:26 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5PMaQNP069610; Mon, 25 Jun 2018 22:36:26 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201806252236.w5PMaQNP069610@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 25 Jun 2018 22:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335649 - in head/sys/arm64: arm64 linux X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys/arm64: arm64 linux X-SVN-Commit-Revision: 335649 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jun 2018 22:36:27 -0000 Author: andrew Date: Mon Jun 25 22:36:25 2018 New Revision: 335649 URL: https://svnweb.freebsd.org/changeset/base/335649 Log: Make cpu_set_syscall_retval common between the existing FreeBSD ABI and the Linuxulator. We need to translate error values onto Linux errno values and return them to userspace when a syscall fails. We also need to preserve x1 as all registers are preserved other than the return value. Reviewed by: emaste Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D16008 Modified: head/sys/arm64/arm64/vm_machdep.c head/sys/arm64/linux/linux_sysvec.c Modified: head/sys/arm64/arm64/vm_machdep.c ============================================================================== --- head/sys/arm64/arm64/vm_machdep.c Mon Jun 25 22:05:33 2018 (r335648) +++ head/sys/arm64/arm64/vm_machdep.c Mon Jun 25 22:36:25 2018 (r335649) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -154,7 +155,7 @@ cpu_set_syscall_retval(struct thread *td, int error) break; default: frame->tf_spsr |= PSR_C; /* carry bit */ - frame->tf_x[0] = error; + frame->tf_x[0] = SV_ABI_ERRNO(td->td_proc, error); break; } } Modified: head/sys/arm64/linux/linux_sysvec.c ============================================================================== --- head/sys/arm64/linux/linux_sysvec.c Mon Jun 25 22:05:33 2018 (r335648) +++ head/sys/arm64/linux/linux_sysvec.c Mon Jun 25 22:36:25 2018 (r335649) @@ -143,25 +143,9 @@ linux_fetch_syscall_args(struct thread *td) static void linux_set_syscall_retval(struct thread *td, int error) { - struct trapframe *frame; - frame = td->td_frame; - - switch (error) { - case 0: - frame->tf_x[0] = td->td_retval[0]; - frame->tf_x[1] = td->td_retval[1]; - break; - case ERESTART: - /* LINUXTODO: verify */ - frame->tf_elr -= 4; - break; - case EJUSTRETURN: - break; - default: - frame->tf_x[0] = error; - break; - } + td->td_retval[1] = td->td_frame->tf_x[1]; + cpu_set_syscall_retval(td, error); } static int