This series of patches enables nfs rootfs support on the Morello board.
Patch 01 is fixing the inital kernel build error associated with a wrong function pointer type within the sunrpc modules due to the unlocked_ioctl fp, the error occurs upon enabling nfs within the defconfig.
Patch 02 deals with the fallout caused by changes inferred by patches 01. See details in the description of the patch.
Patch 03 is enabling nfs rootfs by default in the kernel.
It was confirmed that the kernel can boot with a nfs rootfs.
V3 changes: - fix commit title @ patch 2 - align the change in proc.c
Pawel Zalewski (3): net: sunrpc: fix unlocked_ioctl handler signature proc: change proc_ops.proc_ioct handler signature arm64: morello: enable nfs rootfs by default
arch/arm64/configs/morello_transitional_pcuabi_defconfig | 2 ++ drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 6 +++--- net/sunrpc/rpc_pipe.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
The function pointer file_operations.unlocked_ioctl requires the use of user_uintptr_t type as argument to pass CHERI capabilities so change the argument type from unsigned long to user_uintptr_t.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- net/sunrpc/cache.c | 4 ++-- net/sunrpc/rpc_pipe.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index f075a9fb5ccc..c4aaef5430f1 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -991,7 +991,7 @@ static __poll_t cache_poll(struct file *filp, poll_table *wait, }
static int cache_ioctl(struct inode *ino, struct file *filp, - unsigned int cmd, unsigned long arg, + unsigned int cmd, user_uintptr_t arg, struct cache_detail *cd) { int len = 0; @@ -1791,7 +1791,7 @@ static __poll_t cache_poll_pipefs(struct file *filp, poll_table *wait) }
static long cache_ioctl_pipefs(struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct cache_detail *cd = RPC_I(inode)->private; diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 0b6034fab9ab..1259e1e863f1 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -354,7 +354,7 @@ rpc_pipe_poll(struct file *filp, struct poll_table_struct *wait) }
static long -rpc_pipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) +rpc_pipe_ioctl(struct file *filp, unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct rpc_pipe *pipe;
The module net:sunrpc:cache.c will effectively use the same callback cache_ioctl for pointers passed from file_operations.unlocked_ioctl and proc_ops.proc_ioctl and it will expect pointers as the argument. Thus to be able to pass CHERI capabilities, the .proc_ioctl fp's arg input variable should also be of user_uintptr_t type.
The proc_compat_ioctl handler in the pci/proc.c module is replaced with compat_noptr_ioctl as the arg is not being passed as a pointer into the proc_bus_pci_ioctl handler.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index f967709082d6..a3cb37e49ab3 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -192,7 +192,7 @@ struct pci_filp_private { #endif /* HAVE_PCI_MMAP */
static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) + user_uintptr_t arg) { struct pci_dev *dev = pde_data(file_inode(file)); #ifdef HAVE_PCI_MMAP @@ -322,7 +322,7 @@ static const struct proc_ops proc_bus_pci_ops = { .proc_write = proc_bus_pci_write, .proc_ioctl = proc_bus_pci_ioctl, #ifdef CONFIG_COMPAT - .proc_compat_ioctl = proc_bus_pci_ioctl, + .proc_compat_ioctl = compat_noptr_ioctl, #endif #ifdef HAVE_PCI_MMAP .proc_open = proc_bus_pci_open, diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 81d6e4ec2294..11d6c3620175 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -36,7 +36,7 @@ struct proc_ops { loff_t (*proc_lseek)(struct file *, loff_t, int); int (*proc_release)(struct inode *, struct file *); __poll_t (*proc_poll)(struct file *, struct poll_table_struct *); - long (*proc_ioctl)(struct file *, unsigned int, unsigned long); + long (*proc_ioctl)(struct file *, unsigned int, user_uintptr_t); #ifdef CONFIG_COMPAT long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long); #endif diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index c4aaef5430f1..b682aa223bd6 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1573,7 +1573,7 @@ static __poll_t cache_poll_procfs(struct file *filp, poll_table *wait) }
static long cache_ioctl_procfs(struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, user_uintptr_t arg) { struct inode *inode = file_inode(filp); struct cache_detail *cd = pde_data(inode);
Gah, this is getting a bit silly. I did it again, will post this patch -V4 separately.
On Tue, 30 May 2023 at 10:01, Pawel Zalewski pzalewski@thegoodpenguin.co.uk wrote:
The module net:sunrpc:cache.c will effectively use the same callback cache_ioctl for pointers passed from file_operations.unlocked_ioctl and proc_ops.proc_ioctl and it will expect pointers as the argument. Thus to be able to pass CHERI capabilities, the .proc_ioctl fp's arg input variable should also be of user_uintptr_t type.
The proc_compat_ioctl handler in the pci/proc.c module is replaced with compat_noptr_ioctl as the arg is not being passed as a pointer into the proc_bus_pci_ioctl handler.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk
drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c index f967709082d6..a3cb37e49ab3 100644 --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -192,7 +192,7 @@ struct pci_filp_private { #endif /* HAVE_PCI_MMAP */
static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
user_uintptr_t arg)
{ struct pci_dev *dev = pde_data(file_inode(file)); #ifdef HAVE_PCI_MMAP @@ -322,7 +322,7 @@ static const struct proc_ops proc_bus_pci_ops = { .proc_write = proc_bus_pci_write, .proc_ioctl = proc_bus_pci_ioctl, #ifdef CONFIG_COMPAT
.proc_compat_ioctl = proc_bus_pci_ioctl,
.proc_compat_ioctl = compat_noptr_ioctl,
#endif #ifdef HAVE_PCI_MMAP .proc_open = proc_bus_pci_open, diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 81d6e4ec2294..11d6c3620175 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h @@ -36,7 +36,7 @@ struct proc_ops { loff_t (*proc_lseek)(struct file *, loff_t, int); int (*proc_release)(struct inode *, struct file *); __poll_t (*proc_poll)(struct file *, struct poll_table_struct *);
long (*proc_ioctl)(struct file *, unsigned int, unsigned long);
long (*proc_ioctl)(struct file *, unsigned int, user_uintptr_t);
#ifdef CONFIG_COMPAT long (*proc_compat_ioctl)(struct file *, unsigned int, unsigned long); #endif diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index c4aaef5430f1..b682aa223bd6 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1573,7 +1573,7 @@ static __poll_t cache_poll_procfs(struct file *filp, poll_table *wait) }
static long cache_ioctl_procfs(struct file *filp,
unsigned int cmd, unsigned long arg)
unsigned int cmd, user_uintptr_t arg)
{ struct inode *inode = file_inode(filp); struct cache_detail *cd = pde_data(inode); -- 2.34.1
It is very useful to be able to boot from a remote rootfs, especially during the development and due to the nature of the Morello project development will be the most often encountered use case.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- arch/arm64/configs/morello_transitional_pcuabi_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/arch/arm64/configs/morello_transitional_pcuabi_defconfig b/arch/arm64/configs/morello_transitional_pcuabi_defconfig index 856806652bac..40b74494980c 100644 --- a/arch/arm64/configs/morello_transitional_pcuabi_defconfig +++ b/arch/arm64/configs/morello_transitional_pcuabi_defconfig @@ -146,6 +146,8 @@ CONFIG_PROC_KCORE=y CONFIG_TMPFS=y CONFIG_HUGETLBFS=y # CONFIG_EFIVAR_FS is not set +CONFIG_NFS_FS=y +CONFIG_ROOT_NFS=y CONFIG_9P_FS=y CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y
On 30/05/2023 11:01, Pawel Zalewski wrote:
This series of patches enables nfs rootfs support on the Morello board.
Patch 01 is fixing the inital kernel build error associated with a wrong function pointer type within the sunrpc modules due to the unlocked_ioctl fp, the error occurs upon enabling nfs within the defconfig.
Patch 02 deals with the fallout caused by changes inferred by patches 01. See details in the description of the patch.
Patch 03 is enabling nfs rootfs by default in the kernel.
It was confirmed that the kernel can boot with a nfs rootfs.
V3 changes:
- fix commit title @ patch 2
- align the change in proc.c
Pawel Zalewski (3): net: sunrpc: fix unlocked_ioctl handler signature proc: change proc_ops.proc_ioct handler signature arm64: morello: enable nfs rootfs by default
Applied on next (using the v4 you posted just after for patch 2). Thanks again for your contribution!
Kevin
arch/arm64/configs/morello_transitional_pcuabi_defconfig | 2 ++ drivers/pci/proc.c | 4 ++-- include/linux/proc_fs.h | 2 +- net/sunrpc/cache.c | 6 +++--- net/sunrpc/rpc_pipe.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-)
Hi Pawel,
Can you please describe how you created the initramfs/initrd with the NFS modules etc. in order to actually mount the remote filesystem as rootfs?
I can confirm that NFS works correctly on the morello board, since I can mount NFS directories once the full kernel image is booted with the local filesystem as rootfs.
I can also confirm that I have PXE/Grub working correctly in order to download and boot into a remote initramfs that I provide (I currently just provide a copy of the initramfs that is in the boot partition on the local morello box).
However, I am struggling to generate my own initramfs with NFS included. It appears that NFS support is not included in the busybox version that is included in the morello software stack (at least I cannot see it in menuconfig).
Can you please explain how you did this?
Many thanks,
Joshua Lant
linux-morello@op-lists.linaro.org