Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp990355ybi; Fri, 12 Jul 2019 07:54:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdFR/QwTdmcCbpmG8Hg8CRGT9r4ve+92gvs836G9IHI03hlqnJpwzDWw54IxY3Dw86RiWW X-Received: by 2002:a63:4e58:: with SMTP id o24mr11068013pgl.366.1562943268458; Fri, 12 Jul 2019 07:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562943268; cv=none; d=google.com; s=arc-20160816; b=YIne4T6QHJp6q9BRKzRUWGweSVNMjvrlmYHnSsdiVVWgQeOM4CcduadmNlXtR0/VKf juHm6s+k9SMuRHaptaoarCsa3mdVuKYc68zgaMn5Jg43yAVjaDanPy+AQqexc2I87Onf 0qQPOLhN7b42Fkd0lFRDjOAx2UObnkExPViZbl46WDbBrerVqDzRm8Ha42LLnpOm3oXx KqFszIxFduELNzpZlb/IRHhmmgPh3tXIVXVQbt7XK5FbMfutSt+zOisb3BpBKk1mOO/l CNbcMZDR6FM+xRPtj63PQ8Vi3PgVNGeLBCtMKdzVpdaYPYh6tmhZ3rXs3hYA5ZHfnGW9 Jr/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Lz8/KFkjzGYulk50ryCD+r9zAoQjGclyVgJMik8OBWo=; b=LXTGJa1+SIexqMyuO0FuBpNvuPO8ABV3Zyl8qzGqvjW8wN7mqKjFoxLjhdLJvhTkt8 UzlO0wdN1Sy9JpcT93hUts4d2OKgqMHnyg27wRkzhEKJzG80NoT5vYy+r+vo1sBnOOlf NuPb7fNYezam/Pb7AjXsBw+7F7MSWKKSYtdZPyAVw0CUbLScGqmo7jZKV2EpR4ExycOL fX4fPhwsummD8Kr4LuvxAvgJwDu91NWobahk6mNdrO//74wlLOdPa+F8GI0EqKa97IQh zLytNPr8c9yC4XlQmtzPypzljuQuNBLr75Vz837+mN5vKlSuGyMOBx5tMQgCckhLu/ET wGIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si8244638pfd.156.2019.07.12.07.54.13; Fri, 12 Jul 2019 07:54:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbfGLOwZ (ORCPT + 99 others); Fri, 12 Jul 2019 10:52:25 -0400 Received: from foss.arm.com ([217.140.110.172]:58764 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbfGLOwZ (ORCPT ); Fri, 12 Jul 2019 10:52:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 321FD2B; Fri, 12 Jul 2019 07:52:24 -0700 (PDT) Received: from [10.1.34.155] (e110723.arm.com [10.1.34.155]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 306493F59C; Fri, 12 Jul 2019 07:52:23 -0700 (PDT) Subject: Re: [PATCH 17/17] riscv: add nommu support To: Christoph Hellwig , Palmer Dabbelt , Paul Walmsley Cc: Damien Le Moal , linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20190624054311.30256-1-hch@lst.de> <20190624054311.30256-18-hch@lst.de> From: Vladimir Murzin Message-ID: <7b382b7a-41b6-62a5-02ab-189b3da9df70@arm.com> Date: Fri, 12 Jul 2019 15:52:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190624054311.30256-18-hch@lst.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph, On 6/24/19 6:43 AM, Christoph Hellwig wrote: > The kernel runs in M-mode without using page tables, and thus can't run > bare metal without help from additional firmware. > > Most of the patch is just stubbing out code not needed without page > tables, but there is an interesting detail in the signals implementation: > > - The normal RISC-V syscall ABI only implements rt_sigreturn as VDSO > entry point, but the ELF VDSO is not supported for nommu Linux. > We instead copy the code to call the syscall onto the stack. > > In addition to enabling the nommu code a new defconfig for a small > kernel image that can run in nommu mode on qemu is also provided, to run > a kernel in qemu you can use the following command line: > > qemu-system-riscv64 -smp 2 -m 64 -machine virt -nographic \ > -kernel arch/riscv/boot/loader \ > -drive file=rootfs.ext2,format=raw,id=hd0 \ > -device virtio-blk-device,drive=hd0 > > Contains contributions from Damien Le Moal . > > Signed-off-by: Christoph Hellwig > --- > arch/riscv/Kconfig | 24 +++++--- > arch/riscv/configs/nommu_virt_defconfig | 78 +++++++++++++++++++++++++ > arch/riscv/include/asm/elf.h | 4 +- > arch/riscv/include/asm/futex.h | 6 ++ > arch/riscv/include/asm/io.h | 4 ++ > arch/riscv/include/asm/mmu.h | 3 + > arch/riscv/include/asm/page.h | 12 +++- > arch/riscv/include/asm/pgalloc.h | 2 + > arch/riscv/include/asm/pgtable.h | 38 ++++++++---- > arch/riscv/include/asm/tlbflush.h | 7 ++- > arch/riscv/include/asm/uaccess.h | 4 ++ > arch/riscv/kernel/Makefile | 3 +- > arch/riscv/kernel/entry.S | 11 ++++ > arch/riscv/kernel/head.S | 6 ++ > arch/riscv/kernel/signal.c | 17 +++++- > arch/riscv/lib/Makefile | 8 +-- > arch/riscv/mm/Makefile | 3 +- > arch/riscv/mm/cacheflush.c | 2 + > arch/riscv/mm/context.c | 2 + > arch/riscv/mm/init.c | 2 + > 20 files changed, 200 insertions(+), 36 deletions(-) > create mode 100644 arch/riscv/configs/nommu_virt_defconfig > snip... > > diff --git a/arch/riscv/configs/nommu_virt_defconfig b/arch/riscv/configs/nommu_virt_defconfig > new file mode 100644 > index 000000000000..cf74e179bf90 > --- /dev/null > +++ b/arch/riscv/configs/nommu_virt_defconfig > @@ -0,0 +1,78 @@ > +# CONFIG_CPU_ISOLATION is not set > +CONFIG_LOG_BUF_SHIFT=16 > +CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12 > +CONFIG_BLK_DEV_INITRD=y > +# CONFIG_RD_BZIP2 is not set > +# CONFIG_RD_LZMA is not set > +# CONFIG_RD_XZ is not set > +# CONFIG_RD_LZO is not set > +# CONFIG_RD_LZ4 is not set > +CONFIG_CC_OPTIMIZE_FOR_SIZE=y > +CONFIG_EXPERT=y > +# CONFIG_SYSFS_SYSCALL is not set > +# CONFIG_FHANDLE is not set > +# CONFIG_BASE_FULL is not set > +# CONFIG_EPOLL is not set > +# CONFIG_SIGNALFD is not set > +# CONFIG_TIMERFD is not set > +# CONFIG_EVENTFD is not set > +# CONFIG_AIO is not set > +# CONFIG_IO_URING is not set > +# CONFIG_ADVISE_SYSCALLS is not set > +# CONFIG_MEMBARRIER is not set > +# CONFIG_KALLSYMS is not set > +# CONFIG_VM_EVENT_COUNTERS is not set > +# CONFIG_COMPAT_BRK is not set > +CONFIG_SLOB=y > +# CONFIG_SLAB_MERGE_DEFAULT is not set > +# CONFIG_MMU is not set > +CONFIG_MAXPHYSMEM_2GB=y > +CONFIG_SMP=y > +CONFIG_CMDLINE="root=/dev/vda rw earlycon=uart8250,mmio,0x10000000,115200n8 console=ttyS0" > +CONFIG_CMDLINE_FORCE=y > +# CONFIG_BLK_DEV_BSG is not set > +CONFIG_PARTITION_ADVANCED=y > +# CONFIG_MSDOS_PARTITION is not set > +# CONFIG_EFI_PARTITION is not set > +# CONFIG_MQ_IOSCHED_DEADLINE is not set > +# CONFIG_MQ_IOSCHED_KYBER is not set > +CONFIG_BINFMT_FLAT=y IIUC, RISC-V requires stack pointer to be 16 byte aligned, but flat loader would align stack pointer to max(sizeof(void *), ARCH_SLAB_MINALIGN). So, I think you might want to define ARCH_SLAB_MINALIGN. Cheers Vladimir