RISC-V Patches for 4.20-rc4
This week is a bit bigger than I expected. That's my fault, as I missed a few patches while I was at Plumbers last week. We have: * A fix to a quite embarassing issue where raw_copy_to_user() was implemented with asm_copy_from_user() (and vice versa). * Improvements to our makefile to allow flat binaries to be generated. * A build fix that predeclares "struct module" at the top of <asm/module.h>, which triggers warnings later in that header. * The addition of our own <uapi/asm/unistd> header, which is necessary to align our stat ABI on 32-bit systems. * A fix to avoid printing a warning when the S or U bits are set in print_isa(). I already have one patch in the queue for next week. -----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEAM520YNJYN/OiG3470yhUCzLq0EFAlv0TPYTHHBhbG1lckBk YWJiZWx0LmNvbQAKCRDvTKFQLMurQbdLD/9B5m4rAgYKLTtxNNGs0WJWsTyODjq+ OTK/PPq+AAhRBtnUeERtcHLs3EEyRN6NVA/KS+j4D02H+cu1/3q3xO6h/+r+ACv3 jOe+vJT7vs/ziTG3YK4VI7gZUu9qUbYUlAObCCWo2k5PnA4kH0HTsI95X4+tizN4 B+vmx21XksppwQ9I74czbp7nbFpZdXYOewm4lCv1PPRTsHQCxQbxgvv+JW24xher KECnlUInFYelUUF6tRYWWVP9WcVrxrZFxQRP8yf2WmK3WGIXy5q4+HvM3TLfW29E aAwNYd0Ohs57VstCGwSAQ/tgIKcDOFKd3NyChGep7/g6CrFeiQ9hk+9A4bTQRtiJ Zv+WmQjEyh0g9oWaEgdFcHthfOvi9QknLJkWjv2SkgIwKISom+tICtcDsabx2279 fAhqV0bKuzFhmihOBbDE4Kp0lY+kwVUUncvG/P8aPBdFjUXjRudxefdZ1cjOgL44 oeOdvhwCJrf3lBoGmAEhj2vtQ//xKF+PI2a8ei6Oum32yLgkqiDLLpXONq5wvpxm /Qrc/6W9UFoQAM6NPTaoBPUu6QG2rt4QVyahSWKHPsOLK0jLQITi0P00pW/oRSs0 yDx/sdHi95DBDSpj7zgkyDGgZIfHG4IVncipplXuSBb9vrlTa7LckAPBSUo6KFeg i+9xKcrf3fhmHg== =xGZd -----END PGP SIGNATURE----- Merge tag 'riscv-for-linus-4.20-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux Pull RISC-V fixes from Palmer Dabbelt: "This week is a bit bigger than I expected. That's my fault, as I missed a few patches while I was at Plumbers last week. We have: - A fix to a quite embarassing issue where raw_copy_to_user() was implemented with asm_copy_from_user() (and vice versa). - Improvements to our makefile to allow flat binaries to be generated. - A build fix that predeclares "struct module" at the top of <asm/module.h>, which triggers warnings later in that header. - The addition of our own <uapi/asm/unistd> header, which is necessary to align our stat ABI on 32-bit systems. - A fix to avoid printing a warning when the S or U bits are set in print_isa(). I already have one patch in the queue for next week" * tag 'riscv-for-linus-4.20-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux: RISC-V: recognize S/U mode bits in print_isa riscv: add asm/unistd.h UAPI header riscv: fix warning in arch/riscv/include/asm/module.h RISC-V: Build flat and compressed kernel images RISC-V: Fix raw_copy_{to,from}_user()
This commit is contained in:
commit
92b419289c
@ -71,6 +71,10 @@ KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
|
||||
# arch specific predefines for sparse
|
||||
CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
|
||||
|
||||
# Default target when executing plain make
|
||||
boot := arch/riscv/boot
|
||||
KBUILD_IMAGE := $(boot)/Image.gz
|
||||
|
||||
head-y := arch/riscv/kernel/head.o
|
||||
|
||||
core-y += arch/riscv/kernel/ arch/riscv/mm/
|
||||
@ -81,4 +85,13 @@ PHONY += vdso_install
|
||||
vdso_install:
|
||||
$(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso $@
|
||||
|
||||
all: vmlinux
|
||||
all: Image.gz
|
||||
|
||||
Image: vmlinux
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
Image.%: Image
|
||||
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
|
||||
|
||||
zinstall install:
|
||||
$(Q)$(MAKE) $(build)=$(boot) $@
|
||||
|
2
arch/riscv/boot/.gitignore
vendored
Normal file
2
arch/riscv/boot/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Image
|
||||
Image.gz
|
33
arch/riscv/boot/Makefile
Normal file
33
arch/riscv/boot/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
#
|
||||
# arch/riscv/boot/Makefile
|
||||
#
|
||||
# This file is included by the global makefile so that you can add your own
|
||||
# architecture-specific flags and dependencies.
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU General Public
|
||||
# License. See the file "COPYING" in the main directory of this archive
|
||||
# for more details.
|
||||
#
|
||||
# Copyright (C) 2018, Anup Patel.
|
||||
# Author: Anup Patel <anup@brainfault.org>
|
||||
#
|
||||
# Based on the ia64 and arm64 boot/Makefile.
|
||||
#
|
||||
|
||||
OBJCOPYFLAGS_Image :=-O binary -R .note -R .note.gnu.build-id -R .comment -S
|
||||
|
||||
targets := Image
|
||||
|
||||
$(obj)/Image: vmlinux FORCE
|
||||
$(call if_changed,objcopy)
|
||||
|
||||
$(obj)/Image.gz: $(obj)/Image FORCE
|
||||
$(call if_changed,gzip)
|
||||
|
||||
install:
|
||||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
|
||||
$(obj)/Image System.map "$(INSTALL_PATH)"
|
||||
|
||||
zinstall:
|
||||
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
|
||||
$(obj)/Image.gz System.map "$(INSTALL_PATH)"
|
60
arch/riscv/boot/install.sh
Normal file
60
arch/riscv/boot/install.sh
Normal file
@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# arch/riscv/boot/install.sh
|
||||
#
|
||||
# This file is subject to the terms and conditions of the GNU General Public
|
||||
# License. See the file "COPYING" in the main directory of this archive
|
||||
# for more details.
|
||||
#
|
||||
# Copyright (C) 1995 by Linus Torvalds
|
||||
#
|
||||
# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin
|
||||
# Adapted from code in arch/i386/boot/install.sh by Russell King
|
||||
#
|
||||
# "make install" script for the RISC-V Linux port
|
||||
#
|
||||
# Arguments:
|
||||
# $1 - kernel version
|
||||
# $2 - kernel image file
|
||||
# $3 - kernel map file
|
||||
# $4 - default install path (blank if root directory)
|
||||
#
|
||||
|
||||
verify () {
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "" 1>&2
|
||||
echo " *** Missing file: $1" 1>&2
|
||||
echo ' *** You need to run "make" before "make install".' 1>&2
|
||||
echo "" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Make sure the files actually exist
|
||||
verify "$2"
|
||||
verify "$3"
|
||||
|
||||
# User may have a custom install script
|
||||
if [ -x ~/bin/${INSTALLKERNEL} ]; then exec ~/bin/${INSTALLKERNEL} "$@"; fi
|
||||
if [ -x /sbin/${INSTALLKERNEL} ]; then exec /sbin/${INSTALLKERNEL} "$@"; fi
|
||||
|
||||
if [ "$(basename $2)" = "Image.gz" ]; then
|
||||
# Compressed install
|
||||
echo "Installing compressed kernel"
|
||||
base=vmlinuz
|
||||
else
|
||||
# Normal install
|
||||
echo "Installing normal kernel"
|
||||
base=vmlinux
|
||||
fi
|
||||
|
||||
if [ -f $4/$base-$1 ]; then
|
||||
mv $4/$base-$1 $4/$base-$1.old
|
||||
fi
|
||||
cat $2 > $4/$base-$1
|
||||
|
||||
# Install system map file
|
||||
if [ -f $4/System.map-$1 ]; then
|
||||
mv $4/System.map-$1 $4/System.map-$1.old
|
||||
fi
|
||||
cp $3 $4/System.map-$1
|
@ -8,6 +8,7 @@
|
||||
|
||||
#define MODULE_ARCH_VERMAGIC "riscv"
|
||||
|
||||
struct module;
|
||||
u64 module_emit_got_entry(struct module *mod, u64 val);
|
||||
u64 module_emit_plt_entry(struct module *mod, u64 val);
|
||||
|
||||
|
@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to,
|
||||
static inline unsigned long
|
||||
raw_copy_from_user(void *to, const void __user *from, unsigned long n)
|
||||
{
|
||||
return __asm_copy_to_user(to, from, n);
|
||||
return __asm_copy_from_user(to, from, n);
|
||||
}
|
||||
|
||||
static inline unsigned long
|
||||
raw_copy_to_user(void __user *to, const void *from, unsigned long n)
|
||||
{
|
||||
return __asm_copy_from_user(to, from, n);
|
||||
return __asm_copy_to_user(to, from, n);
|
||||
}
|
||||
|
||||
extern long strncpy_from_user(char *dest, const char __user *src, long count);
|
||||
|
@ -13,10 +13,9 @@
|
||||
|
||||
/*
|
||||
* There is explicitly no include guard here because this file is expected to
|
||||
* be included multiple times. See uapi/asm/syscalls.h for more info.
|
||||
* be included multiple times.
|
||||
*/
|
||||
|
||||
#define __ARCH_WANT_NEW_STAT
|
||||
#define __ARCH_WANT_SYS_CLONE
|
||||
|
||||
#include <uapi/asm/unistd.h>
|
||||
#include <uapi/asm/syscalls.h>
|
||||
|
@ -1,13 +1,25 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
||||
/*
|
||||
* Copyright (C) 2017-2018 SiFive
|
||||
* Copyright (C) 2018 David Abdurachmanov <david.abdurachmanov@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* There is explicitly no include guard here because this file is expected to
|
||||
* be included multiple times in order to define the syscall macros via
|
||||
* __SYSCALL.
|
||||
*/
|
||||
#ifdef __LP64__
|
||||
#define __ARCH_WANT_NEW_STAT
|
||||
#endif /* __LP64__ */
|
||||
|
||||
#include <asm-generic/unistd.h>
|
||||
|
||||
/*
|
||||
* Allows the instruction cache to be flushed from userspace. Despite RISC-V
|
@ -64,7 +64,7 @@ int riscv_of_processor_hartid(struct device_node *node)
|
||||
|
||||
static void print_isa(struct seq_file *f, const char *orig_isa)
|
||||
{
|
||||
static const char *ext = "mafdc";
|
||||
static const char *ext = "mafdcsu";
|
||||
const char *isa = orig_isa;
|
||||
const char *e;
|
||||
|
||||
@ -88,11 +88,14 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
|
||||
/*
|
||||
* Check the rest of the ISA string for valid extensions, printing those
|
||||
* we find. RISC-V ISA strings define an order, so we only print the
|
||||
* extension bits when they're in order.
|
||||
* extension bits when they're in order. Hide the supervisor (S)
|
||||
* extension from userspace as it's not accessible from there.
|
||||
*/
|
||||
for (e = ext; *e != '\0'; ++e) {
|
||||
if (isa[0] == e[0]) {
|
||||
seq_write(f, isa, 1);
|
||||
if (isa[0] != 's')
|
||||
seq_write(f, isa, 1);
|
||||
|
||||
isa++;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,16 @@ ENTRY(_start)
|
||||
amoadd.w a3, a2, (a3)
|
||||
bnez a3, .Lsecondary_start
|
||||
|
||||
/* Clear BSS for flat non-ELF images */
|
||||
la a3, __bss_start
|
||||
la a4, __bss_stop
|
||||
ble a4, a3, clear_bss_done
|
||||
clear_bss:
|
||||
REG_S zero, (a3)
|
||||
add a3, a3, RISCV_SZPTR
|
||||
blt a3, a4, clear_bss
|
||||
clear_bss_done:
|
||||
|
||||
/* Save hart ID and DTB physical address */
|
||||
mv s0, a0
|
||||
mv s1, a1
|
||||
|
@ -74,7 +74,7 @@ SECTIONS
|
||||
*(.sbss*)
|
||||
}
|
||||
|
||||
BSS_SECTION(0, 0, 0)
|
||||
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
|
||||
|
||||
EXCEPTION_TABLE(0x10)
|
||||
NOTES
|
||||
|
Loading…
Reference in New Issue
Block a user