From nobody Thu Feb 02 14:59:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P724C3b7pz3fkWD; Thu, 2 Feb 2023 14:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P724C2Qrsz3FHJ; Thu, 2 Feb 2023 14:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uP5R896jY4JGSUpwzjMcAhTyH25AzIEg4FAHlSK8VbU=; b=TshsbbyoRzG0Y0Harnf65P36uX7plXOM8QpTnYRxzxMiSA4hZPa0asffFkpiwfaQyBqxDs MBff8WzbtE8sp0svWzennTN+tot/VA3Rwi8IqNwqYau8geRXN1IRN5RV7wEW7Z2ycu62i3 2TGw3uqi90lebNfIq0fPEYJxcC3i7+tTof5D7pvD1ihPvuBmR7hZw1B8fk5dNKnQXmDLgg HpKR4vgSq8f3/Gf0i+O9lTcXcz+NyeuABHrqGxbdO3q0R+Ne66gZZFdAmtaGvg0S2SLelN NAL+2MEHIujOPCHB1c3eYE0IIJa+uzsnrdRHGiDDmUwFxYKwu+TqPXjUjxAzgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675349947; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uP5R896jY4JGSUpwzjMcAhTyH25AzIEg4FAHlSK8VbU=; b=TbZdLNXqaE3ACw4wte2Fdd3VKcbwgU72gUPhKsewCfxP5d4gMS3TN2LtK+f+eGhth+xIuj YuX2dGcUgBOLDj3MLIpvMQoplKqcsw8wguBA7Dz+nCHSwx828PWK1J0auZXVmEyFuWieso fDozKY8jojILT1eKqAjJcauYFmVkZLWtwCWWryabFOuYGERIakS5gjVVx2raMrnLKzs1m1 lXLLEQbQWP0HIP6H/QOUv+2e+PevY9B5d8jjkC+XlEE6TySViJB/mMmzOyLa6I/254JPFF z4EBWITnvJ+n2oO3KBci2FmuAPtQPz7j9aQFMxsq3vre50sLUSpKTWW3jPX7qA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675349947; a=rsa-sha256; cv=none; b=SbYgsocO8MH5M5neyi03mIqUzJQwBOwkax+mITehHWrz/2LSkrfYU9u5X3nV4G0iVScdhZ pyfS55mKHuw0IcFUsW9PC8xF1jI9fUais4iAG2UREvLDodZkE5fN+g4TSjs/TzhWxW/xt2 LMqNsS/4msLPiuj8PM/bTZojCyur1i3uGHrcDNsgu3yLC1SKbmFDqe6XO/c+kDPnLzZ6NA EUBHeVbimURdq7bXwGbdyOlUhdi4zhDgiHchxZcT5E/tj6HLfHV+vUUlsB0whkyHrrqQYm KrxoNLlHFouHR56kUzDUIjhd0z+LBoaw6l0daFlwpIw32NB6VioalH1uENO3FQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P724C1GMpzyQB; Thu, 2 Feb 2023 14:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 312Ex7pY092086; Thu, 2 Feb 2023 14:59:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312Ex78F092085; Thu, 2 Feb 2023 14:59:07 GMT (envelope-from git) Date: Thu, 2 Feb 2023 14:59:07 GMT Message-Id: <202302021459.312Ex78F092085@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: cc1b0f7d9626 - main - linux(4): Add coredump support to i386. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cc1b0f7d9626bbd116429014444cbf61edf708a2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=cc1b0f7d9626bbd116429014444cbf61edf708a2 commit cc1b0f7d9626bbd116429014444cbf61edf708a2 Author: Dmitry Chagin AuthorDate: 2023-02-02 14:58:06 +0000 Commit: Dmitry Chagin CommitDate: 2023-02-02 14:58:06 +0000 linux(4): Add coredump support to i386. MFC after: 1 week --- sys/i386/linux/linux.h | 28 ++++++++++++++++++++++++++++ sys/i386/linux/linux_machdep.c | 26 ++++++++++++++++++++++++++ sys/i386/linux/linux_sysvec.c | 9 ++++++--- sys/modules/linux/Makefile | 2 +- 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h index c651da6b5857..43bf3ca126b6 100644 --- a/sys/i386/linux/linux.h +++ b/sys/i386/linux/linux.h @@ -395,4 +395,32 @@ struct l_desc_struct { #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) +/* This corresponds to 'struct user_regs_struct' in Linux. */ +struct linux_pt_regset { + l_uint ebx; + l_uint ecx; + l_uint edx; + l_uint esi; + l_uint edi; + l_uint ebp; + l_uint eax; + l_uint ds; + l_uint es; + l_uint fs; + l_uint gs; + l_uint orig_eax; + l_uint eip; + l_uint cs; + l_uint eflags; + l_uint esp; + l_uint ss; +}; + +#ifdef _KERNEL +struct reg; + +void bsd_to_linux_regset(const struct reg *b_reg, + struct linux_pt_regset *l_regset); +#endif /* _KERNEL */ + #endif /* !_I386_LINUX_H_ */ diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c index dc156dbd673d..fb42c3e9df84 100644 --- a/sys/i386/linux/linux_machdep.c +++ b/sys/i386/linux/linux_machdep.c @@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include #include @@ -675,3 +677,27 @@ linux_mq_getsetattr(struct thread *td, struct linux_mq_getsetattr_args *args) return (ENOSYS); #endif } + +void +bsd_to_linux_regset(const struct reg *b_reg, + struct linux_pt_regset *l_regset) +{ + + l_regset->ebx = b_reg->r_ebx; + l_regset->ecx = b_reg->r_ecx; + l_regset->edx = b_reg->r_edx; + l_regset->esi = b_reg->r_esi; + l_regset->edi = b_reg->r_edi; + l_regset->ebp = b_reg->r_ebp; + l_regset->eax = b_reg->r_eax; + l_regset->ds = b_reg->r_ds; + l_regset->es = b_reg->r_es; + l_regset->fs = b_reg->r_fs; + l_regset->gs = b_reg->r_gs; + l_regset->orig_eax = b_reg->r_eax; + l_regset->eip = b_reg->r_eip; + l_regset->cs = b_reg->r_cs; + l_regset->eflags = b_reg->r_eflags; + l_regset->esp = b_reg->r_esp; + l_regset->ss = b_reg->r_ss; +} diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index f67b19725cdf..f478255dff69 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -29,6 +29,8 @@ #include __FBSDID("$FreeBSD$"); +#define __ELF_WORD_SIZE 32 + #include #include #include @@ -65,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -804,9 +807,9 @@ struct sysentvec elf_linux_sysvec = { .sv_szsigcode = &linux_szsigcode, .sv_name = "Linux ELF32", .sv_coredump = elf32_coredump, - .sv_elf_core_osabi = ELFOSABI_FREEBSD, - .sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR, - .sv_elf_core_prepare_notes = elf32_prepare_notes, + .sv_elf_core_osabi = ELFOSABI_NONE, + .sv_elf_core_abi_vendor = LINUX_ABI_VENDOR, + .sv_elf_core_prepare_notes = __linuxN(prepare_notes), .sv_imgact_try = linux_exec_imgact_try, .sv_minsigstksz = LINUX_MINSIGSTKSZ, .sv_minuser = VM_MIN_ADDRESS, diff --git a/sys/modules/linux/Makefile b/sys/modules/linux/Makefile index ac5b30b19265..db87f66474b5 100644 --- a/sys/modules/linux/Makefile +++ b/sys/modules/linux/Makefile @@ -12,6 +12,7 @@ CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 KMOD= linux SRCS= linux${SFX}_dummy_machdep.c \ + linux_elf32.c \ linux_event.c \ linux_file.c \ linux_fork.c \ @@ -47,7 +48,6 @@ VDSODEPS=linux_vdso_gettc_x86.inc .endif .if ${MACHINE_CPUARCH} == "amd64" SRCS+= linux${SFX}_support.S -SRCS+= linux_elf32.c .else SRCS+= linux_copyout.c .endif