From 96d3159d62eab8a4c86c42b2a3afd2d47ce86162 Mon Sep 17 00:00:00 2001 From: Dmitry Ermakov Date: Mon, 14 Feb 2022 16:57:38 +0300 Subject: [PATCH] Remove CONFIG_VT for FH8852V100 to avoid kernel crash && apply pty patch --- .../kernel/fh8833v100.generic.config | 4 +- .../kernel/fh8852v100.generic.config | 4 +- .../kernel/fh8856v100.generic.config | 4 +- .../kernel/patches/13_fix_openpty.patch | 144 ++++++++++++++++++ 4 files changed, 150 insertions(+), 6 deletions(-) create mode 100644 br-ext-chip-fullhan/board/fh8852v100/kernel/patches/13_fix_openpty.patch diff --git a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8833v100.generic.config b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8833v100.generic.config index f3b921ad..0dc5fbd7 100644 --- a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8833v100.generic.config +++ b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8833v100.generic.config @@ -825,8 +825,8 @@ CONFIG_INPUT=y # # Character devices # -CONFIG_VT=y -CONFIG_CONSOLE_TRANSLATIONS=y +# CONFIG_VT is not set +# CONFIG_CONSOLE_TRANSLATIONS is not set # CONFIG_VT_CONSOLE is not set CONFIG_HW_CONSOLE=y # CONFIG_VT_HW_CONSOLE_BINDING is not set diff --git a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8852v100.generic.config b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8852v100.generic.config index ae50e766..9d7fad14 100644 --- a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8852v100.generic.config +++ b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8852v100.generic.config @@ -826,8 +826,8 @@ CONFIG_INPUT=y # # Character devices # -CONFIG_VT=y -CONFIG_CONSOLE_TRANSLATIONS=y +# CONFIG_VT is not set +# CONFIG_CONSOLE_TRANSLATIONS is not set # CONFIG_VT_CONSOLE is not set CONFIG_HW_CONSOLE=y # CONFIG_VT_HW_CONSOLE_BINDING is not set diff --git a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8856v100.generic.config b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8856v100.generic.config index acd1e044..4e22b440 100644 --- a/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8856v100.generic.config +++ b/br-ext-chip-fullhan/board/fh8852v100/kernel/fh8856v100.generic.config @@ -826,8 +826,8 @@ CONFIG_INPUT=y # # Character devices # -CONFIG_VT=y -CONFIG_CONSOLE_TRANSLATIONS=y +# CONFIG_VT is not set +# CONFIG_CONSOLE_TRANSLATIONS is not set # CONFIG_VT_CONSOLE is not set CONFIG_HW_CONSOLE=y # CONFIG_VT_HW_CONSOLE_BINDING is not set diff --git a/br-ext-chip-fullhan/board/fh8852v100/kernel/patches/13_fix_openpty.patch b/br-ext-chip-fullhan/board/fh8852v100/kernel/patches/13_fix_openpty.patch new file mode 100644 index 00000000..e00b7157 --- /dev/null +++ b/br-ext-chip-fullhan/board/fh8852v100/kernel/patches/13_fix_openpty.patch @@ -0,0 +1,144 @@ +--- a/drivers/tty/pty.c ++++ b/drivers/tty/pty.c +@@ -721,7 +721,18 @@ err_file: + return retval; + } + +-static struct file_operations ptmx_fops; ++static const struct file_operations ptmx_fops = ++{ ++ .llseek = no_llseek, ++ .read = tty_read, ++ .write = tty_write, ++ .poll = tty_poll, ++ .unlocked_ioctl = tty_ioctl, ++ .compat_ioctl = tty_compat_ioctl, ++ .open = ptmx_open, ++ .release = tty_release, ++ .fasync = tty_fasync, ++}; + + static void __init unix98_pty_init(void) + { +@@ -775,9 +786,6 @@ static void __init unix98_pty_init(void) + register_sysctl_table(pty_root_table); + + /* Now create the /dev/ptmx special device */ +- tty_default_fops(&ptmx_fops); +- ptmx_fops.open = ptmx_open; +- + cdev_init(&ptmx_cdev, &ptmx_fops); + if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) || + register_chrdev_region(MKDEV(TTYAUX_MAJOR, 2), 1, "/dev/ptmx") < 0) + +--- a/drivers/tty/tty_io.c ++++ b/drivers/tty/tty_io.c +@@ -137,21 +137,10 @@ EXPORT_SYMBOL(tty_mutex); + /* Spinlock to protect the tty->tty_files list */ + DEFINE_SPINLOCK(tty_files_lock); + +-static ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); +-static ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); + ssize_t redirected_tty_write(struct file *, const char __user *, + size_t, loff_t *); +-static unsigned int tty_poll(struct file *, poll_table *); + static int tty_open(struct inode *, struct file *); +-long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg); +-#ifdef CONFIG_COMPAT +-static long tty_compat_ioctl(struct file *file, unsigned int cmd, +- unsigned long arg); +-#else +-#define tty_compat_ioctl NULL +-#endif + static int __tty_fasync(int fd, struct file *filp, int on); +-static int tty_fasync(int fd, struct file *filp, int on); + static void release_tty(struct tty_struct *tty, int idx); + static void __proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); + static void proc_set_tty(struct task_struct *tsk, struct tty_struct *tty); +@@ -962,7 +951,7 @@ static void tty_update_time(struct timespec *time) + * read calls may be outstanding in parallel. + */ + +-static ssize_t tty_read(struct file *file, char __user *buf, size_t count, ++ssize_t tty_read(struct file *file, char __user *buf, size_t count, + loff_t *ppos) + { + int i; +@@ -1141,7 +1130,7 @@ void tty_write_message(struct tty_struct *tty, char *msg) + * write method will not be invoked in parallel for each device. + */ + +-static ssize_t tty_write(struct file *file, const char __user *buf, ++ssize_t tty_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) + { + struct inode *inode = file->f_path.dentry->d_inode; +@@ -2002,7 +1991,7 @@ got_driver: + * may be re-entered freely by other callers. + */ + +-static unsigned int tty_poll(struct file *filp, poll_table *wait) ++unsigned int tty_poll(struct file *filp, poll_table *wait) + { + struct tty_struct *tty = file_tty(filp); + struct tty_ldisc *ld; +@@ -2059,7 +2048,7 @@ out: + return retval; + } + +-static int tty_fasync(int fd, struct file *filp, int on) ++int tty_fasync(int fd, struct file *filp, int on) + { + int retval; + tty_lock(); +@@ -3246,11 +3235,6 @@ struct tty_struct *get_current_tty(void) + } + EXPORT_SYMBOL_GPL(get_current_tty); + +-void tty_default_fops(struct file_operations *fops) +-{ +- *fops = tty_fops; +-} +- + /* + * Initialize the console device. This is called *early*, so + * we can't necessarily depend on lots of kernel help here. + +--- a/include/linux/tty.h ++++ b/include/linux/tty.h +@@ -13,6 +13,7 @@ + #include + #include + #include ++#include + + #include + +@@ -470,7 +471,6 @@ extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg); + extern dev_t tty_devnum(struct tty_struct *tty); + extern void proc_clear_tty(struct task_struct *p); + extern struct tty_struct *get_current_tty(void); +-extern void tty_default_fops(struct file_operations *fops); + extern struct tty_struct *alloc_tty_struct(void); + extern int tty_alloc_file(struct file *file); + extern void tty_add_file(struct tty_struct *tty, struct file *file); +@@ -482,6 +482,19 @@ extern void deinitialize_tty_struct(struct tty_struct *tty); + extern struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx, + int first_ok); + extern int tty_release(struct inode *inode, struct file *filp); ++extern ssize_t tty_read(struct file *, char __user *, size_t, loff_t *); ++extern ssize_t tty_write(struct file *, const char __user *, size_t, loff_t *); ++extern unsigned int tty_poll(struct file *, poll_table *); ++ ++#ifdef CONFIG_COMPAT ++extern long tty_compat_ioctl(struct file *file, unsigned int cmd, ++ unsigned long arg); ++#else ++#define tty_compat_ioctl NULL ++#endif ++extern int tty_fasync(int fd, struct file *filp, int on); ++ ++ + extern int tty_init_termios(struct tty_struct *tty); + + extern struct tty_struct *tty_pair_get_tty(struct tty_struct *tty);