generated from deepin-community/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aab3cbd
commit ff3e489
Showing
21 changed files
with
1,934 additions
and
43 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# | ||
# Makefile for LoongArch old-world syscall compatible layer. | ||
# | ||
|
||
ifdef KBUILD_EXTMOD | ||
CONFIG_LOONGARCH_OW_SYSCALL := m | ||
endif | ||
|
||
obj-$(CONFIG_LOONGARCH_OW_SYSCALL) += la_ow_syscall.o | ||
la_ow_syscall-y += fsstat.o la_ow_syscall_main.o signal.o | ||
|
||
ifndef KBUILD_EXTMOD | ||
ifdef CONFIG_KALLSYMS | ||
ifndef CONFIG_RANDOMIZE_BASE | ||
$(obj)/ksym_addr.h: System.map | ||
@$(kecho) ' GEN $@' | ||
$(Q)grep ' sys_call_table$$' $< >/dev/null | ||
$(Q)grep ' kallsyms_lookup_name$$' $< >/dev/null | ||
$(Q)echo "#define LAOWSYS_SYS_CALL_TABLE_ADDR 0x$$(grep ' sys_call_table$$' $< | cut -d ' ' -f 1)" > $@ | ||
$(Q)echo "#define LAOWSYS_KALLSYMS_LOOKUP_NAME_ADDR 0x$$(grep ' kallsyms_lookup_name$$' $< | cut -d ' ' -f 1)" >> $@ | ||
ccflags-y += -DHAVE_KSYM_ADDR | ||
$(obj)/$(la_ow_syscall-y): $(obj)/ksym_addr.h | ||
endif | ||
endif | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
obj-m += la_ow_syscall.o fsstat.o la_ow_syscall_main.o signal.o | ||
|
||
KVER ?= $(shell uname -r) | ||
KDIR ?= /lib/modules/$(KVER)/build | ||
VERSION ?= $(shell cat VERSION) | ||
|
||
default: | ||
$(MAKE) -C $(KDIR) M=$(CURDIR) modules | ||
|
||
clean: | ||
$(MAKE) -C $(KDIR) M=$(CURDIR) clean | ||
|
||
install: | ||
$(MAKE) -C $(KDIR) M=$(CURDIR) modules_install | ||
|
||
dkms.conf: dkms.conf.in | ||
m4 -DVERSION=$(VERSION) $^ > $@ | ||
|
||
dkms-add: dkms.conf | ||
/usr/sbin/dkms add $(CURDIR) | ||
|
||
dkms-build: dkms.conf | ||
/usr/sbin/dkms build la_ow_syscall/$(VERSION) | ||
|
||
dkms-install: dkms.conf | ||
/usr/sbin/dkms install la_ow_syscall/$(VERSION) | ||
|
||
dkms-remove: dkms.conf | ||
/usr/sbin/dkms remove la_ow_syscall/$(VERSION) --all | ||
|
||
modprobe-install: | ||
modprobe la_ow_syscall | ||
|
||
modprobe-remove: | ||
modprobe -r la_ow_syscall | ||
|
||
dev: modprobe-remove dkms-remove dkms-add dkms-build dkms-install modprobe-install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,77 @@ | ||
# template-repository | ||
la\_ow\_syscall | ||
==== | ||
|
||
This kernel modules provides compatibility with LoongArch's old-world ABI, | ||
making it possible to run old-world applications (such as Kingsoft's WPS Office | ||
and Tencent QQ) transparently on new-world (ABI 2.0) kernels and userspaces. | ||
|
||
Requirements | ||
---- | ||
|
||
Linux Kernel >= 6.1.0 for `loongarch64` with the following option(s) set: | ||
|
||
- `CONFIG_KALLSYMS=y` (for reading kernel symbol addresses). | ||
- `CONFIG_KPROBES=y` (for probing kernel symbol addresses using kernels where | ||
base address randomisation - `CONFIG_RANDOMIZE_BASE` - is enabled). | ||
|
||
Installation | ||
---- | ||
|
||
You may install this kernel both as an in-tree module, an out-of-tree DKMS | ||
dynamic module, or a version-specific module. You may pick any option that best | ||
suits your needs. | ||
|
||
### In-tree module | ||
|
||
Copy this source tree as `arch/loongarch/ow_syscall` in your kernel tree and | ||
append the following to `arch/loongarch/Kbuild`: | ||
|
||
``` | ||
obj-y += ow_syscall/ | ||
``` | ||
|
||
After building the kernel with `make`, run the following command to build the | ||
kernel module: | ||
|
||
``` | ||
# $PWD is containing built objects | ||
# /path/to/source_dir is containing Linux source code | ||
make \ | ||
-C /path/to/source_dir \ | ||
ARCH=loongarch \ | ||
O="$PWD" \ | ||
arch/loongarch/ow_syscall/la_ow_syscall.ko \ | ||
CONFIG_LOONGARCH_OW_SYSCALL=m | ||
``` | ||
|
||
Upon completion, copy the kernel module in place | ||
(`/lib/modules/.../arch/loongarch/ow_syscall/la_ow_syscall.ko`) and | ||
re-generate modules.dep and map files: | ||
|
||
``` | ||
depmod | ||
``` | ||
|
||
### DKMS dynamic module | ||
|
||
Generate a `dkms.conf`: | ||
|
||
``` | ||
make dkms.conf | ||
``` | ||
|
||
For installation and version management, refer to dkms(8) for details. | ||
|
||
### Version-specific module | ||
|
||
Build the kernel module: | ||
|
||
``` | ||
make | ||
``` | ||
|
||
Load the module with super user or root privilege: | ||
|
||
``` | ||
insmod la_ow_syscall.ko | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
template-repository (1.0-1) unstable; urgency=medium | ||
liblol-dkms (0.1.0) unstable; urgency=low | ||
|
||
* Initial release | ||
* Initial build | ||
|
||
-- Tsic404 <[email protected]> Sat, 28 Jan 2023 13:46:49 +0800 | ||
-- Miao Wang <[email protected]> Sun, 28 Jan 2024 09:12:00 +0800 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
Source: template-repository | ||
Section: unknown | ||
Priority: optional | ||
Maintainer: Tsic404 <[email protected]> | ||
Build-Depends: debhelper (>= 11) | ||
Standards-Version: 4.1.3 | ||
Homepage: https://github.com/deepin-community/template-repository | ||
#Vcs-Browser: https://salsa.debian.org/debian/deepin-community-template-repository | ||
#Vcs-Git: https://salsa.debian.org/debian/deepin-community-template-repository.git | ||
Source: liblol-dkms | ||
Section: kernel | ||
Priority: extra | ||
Maintainer: Miao Wang <[email protected]> | ||
Build-Depends: debhelper-compat (= 13), | ||
dkms, dh-dkms, | ||
Standards-Version: 4.6.2 | ||
Homepage: https://github.com/AOSC-Dev/la_ow_syscall | ||
|
||
Package: template-repository | ||
Architecture: any | ||
Depends: ${shlibs:Depends}, ${misc:Depends} | ||
Description: <insert up to 60 chars description> | ||
<insert long description, indented with spaces> | ||
Package: liblol-dkms | ||
Architecture: loong64 | ||
Depends: ${misc:Depends}, dkms | ||
Conflicts: glibc | ||
Description: Compatibility layer kmod for old world applications | ||
This package contains a compatibility layer for old world | ||
applications on new world loongarch64 platform. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dkms.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/usr/src/la_ow_syscall-*/* | ||
/usr/lib/modules-load.d/liblol.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Load the la_ow_syscall kernel module for old-world compatibility. | ||
la_ow_syscall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
#!/usr/bin/make -f | ||
|
||
include /usr/share/dpkg/pkg-info.mk | ||
|
||
%: | ||
dh $@ | ||
dh $@ --with dkms | ||
|
||
override_dh_auto_build: | ||
make dkms.conf VERSION="#MODULE_VERSION#" | ||
|
||
override_dh_auto_clean: | ||
rm -rf dkms.conf | ||
|
||
TMPDIR ?= debian/tmp | ||
|
||
override_dh_auto_install: | ||
install -Dvm644 \ | ||
Kbuild \ | ||
Makefile \ | ||
fsstat.c \ | ||
fsstat.h \ | ||
la_ow_syscall_main.c \ | ||
signal.c \ | ||
signal.h \ | ||
-t $(TMPDIR)/usr/src/la_ow_syscall-$(DEB_VERSION_UPSTREAM) | ||
install -Dvm644 \ | ||
debian/kmod-autoload.conf \ | ||
$(TMPDIR)/usr/lib/modules-load.d/liblol.conf | ||
|
||
override_dh_dkms: | ||
dh_dkms -V $(DEB_VERSION_UPSTREAM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.0 (quilt) | ||
3.0 (native) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
PACKAGE_NAME="la_ow_syscall" | ||
PACKAGE_VERSION="VERSION" | ||
|
||
BUILD_EXCLUSIVE_KERNEL_MIN="5.19" | ||
BUILD_EXCLUSIVE_CONFIG="CONFIG_KALLSYMS" | ||
|
||
MAKE="KDIR=/lib/modules/${kernelver}/build make" | ||
CLEAN="make clean" | ||
BUILT_MODULE_NAME[0]="$PACKAGE_NAME" | ||
AUTOINSTALL="yes" | ||
DEST_MODULE_LOCATION[0]="/extra" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <linux/syscalls.h> | ||
#include <linux/uaccess.h> | ||
#include <linux/errno.h> | ||
#include <linux/file.h> | ||
#include <linux/mm.h> | ||
#include "fsstat.h" | ||
|
||
#define INIT_STRUCT_STAT_PADDING(st) memset(&st, 0, sizeof(st)) | ||
|
||
struct __old_kernel_stat { | ||
unsigned short st_dev; | ||
unsigned short st_ino; | ||
unsigned short st_mode; | ||
unsigned short st_nlink; | ||
unsigned short st_uid; | ||
unsigned short st_gid; | ||
unsigned short st_rdev; | ||
unsigned int st_size; | ||
unsigned int st_atime; | ||
unsigned int st_mtime; | ||
unsigned int st_ctime; | ||
}; | ||
|
||
static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf) | ||
{ | ||
struct stat tmp; | ||
|
||
if (sizeof(tmp.st_dev) < 4 && !old_valid_dev(stat->dev)) | ||
return -EOVERFLOW; | ||
if (sizeof(tmp.st_rdev) < 4 && !old_valid_dev(stat->rdev)) | ||
return -EOVERFLOW; | ||
#if BITS_PER_LONG == 32 | ||
if (stat->size > MAX_NON_LFS) | ||
return -EOVERFLOW; | ||
#endif | ||
|
||
INIT_STRUCT_STAT_PADDING(tmp); | ||
tmp.st_dev = new_encode_dev(stat->dev); | ||
tmp.st_ino = stat->ino; | ||
if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) | ||
return -EOVERFLOW; | ||
tmp.st_mode = stat->mode; | ||
tmp.st_nlink = stat->nlink; | ||
if (tmp.st_nlink != stat->nlink) | ||
return -EOVERFLOW; | ||
SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid)); | ||
SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid)); | ||
tmp.st_rdev = new_encode_dev(stat->rdev); | ||
tmp.st_size = stat->size; | ||
tmp.st_atime = stat->atime.tv_sec; | ||
tmp.st_mtime = stat->mtime.tv_sec; | ||
tmp.st_ctime = stat->ctime.tv_sec; | ||
#ifdef STAT_HAVE_NSEC | ||
tmp.st_atime_nsec = stat->atime.tv_nsec; | ||
tmp.st_mtime_nsec = stat->mtime.tv_nsec; | ||
tmp.st_ctime_nsec = stat->ctime.tv_nsec; | ||
#endif | ||
tmp.st_blocks = stat->blocks; | ||
tmp.st_blksize = stat->blksize; | ||
return copy_to_user(statbuf, &tmp, sizeof(tmp)) ? -EFAULT : 0; | ||
} | ||
|
||
__SYSCALL_DEFINEx(2, _newfstat, unsigned int, fd, struct stat __user *, statbuf) | ||
{ | ||
struct kstat stat; | ||
int error = p_vfs_fstat(fd, &stat); | ||
|
||
if (!error) | ||
error = cp_new_stat(&stat, statbuf); | ||
|
||
return error; | ||
} | ||
|
||
__SYSCALL_DEFINEx(4, _newfstatat, int, dfd, const char __user *, filename, | ||
struct stat __user *, statbuf, int, flag) | ||
{ | ||
struct kstat stat; | ||
int error; | ||
|
||
error = p_vfs_fstatat(dfd, filename, &stat, flag); | ||
if (error) | ||
return error; | ||
return cp_new_stat(&stat, statbuf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern int (*p_vfs_fstatat)(int dfd, const char __user *filename, | ||
struct kstat *stat, int flags); | ||
extern int (*p_vfs_fstat)(int fd, struct kstat *stat); |
Oops, something went wrong.