Closed darius-bluespec closed 9 years ago
Thanks for fixing a long-standing omission in the port. When I have more time later today, I plan to test with a 32-bit userland before merging.
On 12/18/2014 05:58 PM, Albert Ou wrote:
Thanks for fixing a long-standing omission in the port. When I have more time later today, I plan to test with a 32-bit userland before merging.
You're welcome, glad to help. I had success running Busybox compiled with riscv-gnu-toolchain and the RV32 changes I recently pushed.
I have staged an updated patchset on the rv32 branch.
A brief changelog of the more significant refactoring:
I welcome further code review and testing on whatever RV32 implementation you are targeting.
Before merging, however, we must resolve the vexing issue of HTIF, whose current design is tightly coupled to RV64. The assumption that the tohost
CSR can accommodate an entire physical address plus the command field, etc., obviously does not hold for RV32.
For now, I have included commit darius-bluespec/riscv-linux@b57b5310d7dfa25ee09b566b6ecc664c6a92778a ("riscv: Adjust htif device and command shift for 32-bit") for convenience, but constraining HTIF to a <16-bit physical address space is infeasible, as it conflicts with the kernel text segment. Note that anything involving DMA (device enumeration, block transfers) is therefore currently broken. We have discussed either making all HTIF packets 64-bits, with a pair of tohost writes or fromhost reads comprising a transaction, or replacing HTIF altogether on RV32.
On 01/08/2015 04:47 AM, Albert Ou wrote:
I have staged an updated patchset on the rv32 branch.
A brief changelog of the more significant refactoring:
- head, entry, lib: Unify RV32/RV64 assembly implementations for future ease of maintenance.
- uaccess: Improve assembly constraints (base+offset instead of register indirect) and support big-endian ordering.
- bitops: Fix AMO width.
- Adjust pointer size in fixup entries and other places.
I welcome further code review and testing on whatever RV32 implementation you are targeting.
I reviewed your branch and it looks fine to me in general.
I found a few minor issues relating pointer sizes which I submit a pull request to fix. Your branch plus this fix runs successfully on our RV32 implementation.
Before merging, however, we must resolve the vexing issue of HTIF, whose current design is tightly coupled to RV64. The assumption that the |tohost| CSR can accommodate an entire physical address plus the command field, etc., obviously does not hold for RV32.
For now, I have included commit darius-bluespec/riscv-linux@b57b531 https://github.com/darius-bluespec/riscv-linux/commit/b57b5310d7dfa25ee09b566b6ecc664c6a92778a ("riscv: Adjust htif device and command shift for 32-bit") for convenience, but constraining HTIF to a <16-bit physical address space is infeasible, as it conflicts with the kernel text segment. Note that anything involving DMA (device enumeration, block transfers) is therefore currently broken. We have discussed either making all HTIF packets 64-bits, with a pair of tohost writes or fromhost reads comprising a transaction, or replacing HTIF altogether on RV32.
We only use HTIF for the console and intend to remove that eventually. So it really does not matter to me how HTIF on RV32 is handled, if at all.
— Reply to this email directly or view it on GitHub https://github.com/ucb-bar/riscv-linux/pull/9#issuecomment-69157150.
I reviewed your branch and it looks fine to me in general. I found a few minor issues relating pointer sizes which I submit a pull request to fix. Your branch plus this fix runs successfully on our RV32 implementation.
Good to hear. I've just merged everything to master. Thanks for your help!
We only use HTIF for the console and intend to remove that eventually. So it really does not matter to me how HTIF on RV32 is handled, if at all.
We're leaning towards keeping HTIF exclusive to RV64, since none of the UCB test chips are purely 32-bit. It's not clear to me if any third parties care enough about HTIF to warrant a redesign. To avoid confusion, CONFIG_HTIF now depends on 64BIT, but I remain open to other suggestions if that becomes too inconvenient.
Hi, I met some problems building 32 bit linux. Could you please help me out? I am working on a 32 bit Ubuntu server:
Linux ubuntu 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:59 UTC 2016 i686 i686 i686 GNU/Linux
I downloaded linux-4.6.2.tar.xz and tried
make ARCH=riscv defconfig
make ARCH=riscv menuconfig
changed Platform type -> CPU selection from Rocket to Generic RISC-V changed Kernel type -> Kernel code model from 64-bit kernel to 32-bit kernel changed General setup -> Cross-compiler tool prefix from riscv64-unknown-linux-gnu- to riscv32-unknown-linux-gnu- (which I built in riscv-tools) and then
make -j4 ARCH=riscv vmlinux
FAILED with the following message
In file included from arch/riscv/include/generated/asm/div64.h:1:0,
from include/linux/kernel.h:136,
from include/linux/list.h:8,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/uapi/linux/timex.h:56,
from include/linux/timex.h:56,
from include/linux/clocksource.h:12,
from arch/riscv/kernel/time.c:1:
arch/riscv/kernel/time.c: In function 'time_init':
include/asm-generic/div64.h:207:28: warning: comparison of distinct pointer types lacks a cast
(void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
^
arch/riscv/kernel/time.c:81:2: note: in expansion of macro 'do_div'
do_div(lpj_fine, HZ);
^~~~~~
In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from ./include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/linux/clocksource.h:11,
from arch/riscv/kernel/time.c:1:
include/asm-generic/div64.h:220:25: warning: right shift count >= width of type [-Wshift-count-overflow]
} else if (likely(((n) >> 32) == 0)) { \
^
include/linux/compiler.h:169:40: note: in definition of macro 'likely'
# define likely(x) __builtin_expect(!!(x), 1)
^
arch/riscv/kernel/time.c:81:2: note: in expansion of macro 'do_div'
do_div(lpj_fine, HZ);
^~~~~~
In file included from arch/riscv/include/generated/asm/div64.h:1:0,
from include/linux/kernel.h:136,
from include/linux/list.h:8,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/uapi/linux/timex.h:56,
from include/linux/timex.h:56,
from include/linux/clocksource.h:12,
from arch/riscv/kernel/time.c:1:
include/asm-generic/div64.h:224:22: error: passing argument 1 of '__div64_32' from incompatible pointer type [-Werror=incompatible-pointer-types]
__rem = __div64_32(&(n), __base); \
^
arch/riscv/kernel/time.c:81:2: note: in expansion of macro 'do_div'
do_div(lpj_fine, HZ);
^~~~~~
include/asm-generic/div64.h:198:17: note: expected 'uint64_t * {aka long long unsigned int *}' but argument is of type 'long unsigned int *'
extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
^~~~~~~~~~
cc1: some warnings being treated as errors
scripts/Makefile.build:291: recipe for target 'arch/riscv/kernel/time.o' failed
make[1]: *** [arch/riscv/kernel/time.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC kernel/sys.o
CC fs/open.o
Makefile:963: recipe for target 'arch/riscv/kernel' failed
make: *** [arch/riscv/kernel] Error 2
make: *** Waiting for unfinished jobs....
CC kernel/kmod.o
CC kernel/workqueue.o
CC fs/read_write.o
CC kernel/pid.o
In file included from ./arch/riscv/include/asm/bug.h:4:0,
from include/linux/bug.h:4,
from include/linux/mmdebug.h:4,
from include/linux/gfp.h:4,
from include/linux/slab.h:14,
from kernel/signal.c:13:
kernel/signal.c: In function 'signals_init':
include/linux/compiler.h:506:38: error: call to '__compiletime_assert_3590' declared with attribute error: BUILD_BUG_ON failed: __ARCH_SI_PREAMBLE_SIZE != offsetof(struct siginfo, _sifields._pad)
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^
include/linux/compiler.h:489:4: note: in definition of macro '__compiletime_assert'
prefix ## suffix(); \
^~~~~~
include/linux/compiler.h:506:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __LINE__)
^~~~~~~~~~~~~~~~~~~
include/linux/bug.h:51:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~
include/linux/bug.h:75:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^~~~~~~~~~~~~~~~
kernel/signal.c:3589:2: note: in expansion of macro 'BUILD_BUG_ON'
BUILD_BUG_ON(__ARCH_SI_PREAMBLE_SIZE
^~~~~~~~~~~~
scripts/Makefile.build:291: recipe for target 'kernel/signal.o' failed
make[1]: *** [kernel/signal.o] Error 1
make[1]: *** Waiting for unfinished jobs....
CC fs/file_table.o
CC fs/super.o
CC fs/char_dev.o
CC fs/stat.o
Makefile:963: recipe for target 'kernel' failed
make: *** [kernel] Error 2
I think deleting -Werror in CFLAGS can solve the first error, but I've no idea how to fix the second one. Can you be kind enough to share any thoughts?
@adux6991 The solution is described here https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/o_zmyrpsTdo
Changes from prior pull request: Use unsigned comparison for valid syscall number in entry_32.S