Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2116131rbb; Tue, 27 Feb 2024 11:04:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU72+ga1eOCDA7/gY/tUBc51z+OHGNujO334vGgnFlcbxhW7rvIL6co0tBtPHjksUD9kBMqpg0m5CBFHuQq2vsCRTSwcuGc9MpVAkUDNg== X-Google-Smtp-Source: AGHT+IGMgwPWH8e8lgUhLRyp/A7K1gfICC2hocTTz5Wq1KXWX0FjnAKc06xJx7nZnFxKqXfWTJnB X-Received: by 2002:a05:6512:3f04:b0:512:d5c7:60d9 with SMTP id y4-20020a0565123f0400b00512d5c760d9mr9246257lfa.3.1709060689266; Tue, 27 Feb 2024 11:04:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709060689; cv=pass; d=google.com; s=arc-20160816; b=CTcxU5zNtaXy7x3AS5ckrrWJVK9Y2v0vFYHZ4NMGjNDqShdMd7jmtZbAqNqwjCJAL9 KEU/zigSIr7cgz+yo0N6bi7eardaOHQBfE7mtx0Jq453vcD0EfyGbpj7hSMeP4GPEqAN 6dPeo8zsW0BMimh+fjUBCtdcEVIr4EZZF7BY6u3Bap1QqvB2rak/G66YxU8Ru5p4f8QD M/XbK0xqHyzJ3qx73gyrsaBshxRLFXIuzQiM14s5m8BrFiKVgnzc39KV9sI7rZDuzkCS CcLQhbGKINvtA/r1qWAj6xvY1tg5DJLTysXCu1Z+7bwLbQDsPXs9o44rbI0I4bvFc8H/ MD5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=eCMYN1p2M2SlsOhGzE1chvN/98rPlLh7qBG5ujmIAMc=; fh=QQMKct0TqxO5VSZC8ZtI4egytq/HvOskCHOQKP+5WXw=; b=yCqlbw2/RV+TF2lehERzEvmyexjisJQig2nkxtmV6LP4qNlkehQNrUuvd26NkLXCXh kbvg+4Xa5X6k1WP0TOweSe+4AFz7kZSORFNsn32T9HkAGFjDrmH1wgbtGYKgp1XhPsRL 8pURsbqOJeIYDm5TuwJnG7aWuS3SuBVlStAVScXh6OE3BoxJFTCi+8ItNCmsGlsA6c3l g3sQLv1HGWn2QYU57lsy79vU364Vk1hNRGJk4fCqJdQ0iAGSL62z7rulB6IbO1Bmb1R4 kOESTKqGBvxG+WaEKZ0njZ0locHZ0E+hZLONZzhLBlsbHr9eMcZ/DlUR3W6u/TnT/bM4 7iAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=irQNWFEo; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-83888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id w4-20020a056402268400b00565af2eaccfsi946661edd.280.2024.02.27.11.04.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 11:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=irQNWFEo; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-83888-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83888-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 15A6E1F2FE64 for ; Tue, 27 Feb 2024 19:04:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E7F814830C; Tue, 27 Feb 2024 19:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="irQNWFEo" Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3916B51021 for ; Tue, 27 Feb 2024 19:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060535; cv=none; b=k7v/f0LGrlL8oDkHugsc00CqqvgU5zqyVBT+gWZ+nG/Lu3YouvJAsWX5MwuCswVdf84adufRXHsre4a8TMpJktwAaTN22htoy8ZQi7Vz0vwDqMzsrCWSJUKyUmHj9J+gcnkbMhHK+j7yqO5Q22AgD6isCQpzInRSZKS/gSlPmWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060535; c=relaxed/simple; bh=OsYvzHtYJs8UyH6QzhhdhTaVbCu1IPB2JAIf4rNii00=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ujuJN6U72571hz3Soc/4oh9Lq2Xv/WlDnsJcQn9ka5knAn5H933Nya8s6XKw7RuHsikZwsYS/wLlO3QhJPBiLJMsDmQaU8r3PUE6LwukN8ZdYZDTC38Aax6wqye4uGqtkf7oGpASQuB+ryNjFEJWxZrOljZEoX8mNNgvadRAO1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=irQNWFEo; arc=none smtp.client-ip=209.85.166.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-il1-f180.google.com with SMTP id e9e14a558f8ab-3650b558a8cso14455015ab.3 for ; Tue, 27 Feb 2024 11:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1709060533; x=1709665333; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=eCMYN1p2M2SlsOhGzE1chvN/98rPlLh7qBG5ujmIAMc=; b=irQNWFEoXSa//woICHW8fscv/rH3JP0YjEmEgCsSa9jHf5x47jqUFIrg48uq4ThnHP 0UpsQvGUmdjCLmQ5kjXpIEUfIIxL3u/joiwEFosE12PzvkLwwJLRfkCBEx2G4XDQ+afD OFJnYJG+mR+EHe0lhuG5glVQn+2FvZax0/vtAQhEXym4oVLzu2lq24CXK4UX4YDlBmfk zFoTUwfpDfHHpAxCM+0PKC2eK9KL2Ao67XpMNkRbDQYFo2smgtEAbMvlxNtpApl5VQwj D5BRPMwKVIb5GoVTeTjoznAYjqrKaTuBwCqHTEFKgdogagNjZu//EO2/vMKlN+kjzRY2 IJQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709060533; x=1709665333; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eCMYN1p2M2SlsOhGzE1chvN/98rPlLh7qBG5ujmIAMc=; b=Xjn8/6pkDZJx975cmpsgCQS/eaZMqyQL/hVsLVACAQC/hbDUjCPfn/dtBPaYAPK3N/ PAuW8CpgvtoqGcswF6PgmdZpVIo09TX5tHDp5nqeojG543HJzFrsxoT/anQA4JrxG2pd ihrvCLO7fdQnIZwxPyCIAlxBu7lrMIr19rzY/tYy7rnhnwh4chAES7L92RfDmdxcOB8W OFGxl65tZdxI1ANacxlnOcbT8seO3s5i/Mfwz3Q9mBklx8PnArZ+Y9ABpoFBkEnhhoWD 0iacM7R+aGiqRg3vmw4rWMHeXPli0Fhmc1pOAhvPz7mA3QZlrF14tlWZmZb+5xGeEPQs WbAA== X-Forwarded-Encrypted: i=1; AJvYcCWuZ/L9ZkQH1H/1kZc2QbIz7d4u5k7QxXahDmwnvYXUZ2Cf4SDBOT7O2X/Ukh5XCBurBiNzINWurjCPKvveck0ZYh8xWATINErsjLG4 X-Gm-Message-State: AOJu0Yz46x9qSGSaoyEzq5yHPltat4GIkIYP0PKB7i7PsICxxsJtKXjG HIj8X3Z9j0bsrfyDKvI/WOSDNh1HQiK9tG/SLgHJsYrChFRd/p49wdNXYTsKIlOXfkwjTTpNWNP 7 X-Received: by 2002:a05:6e02:20c7:b0:365:c8:7a15 with SMTP id 7-20020a056e0220c700b0036500c87a15mr13956481ilq.20.1709060533327; Tue, 27 Feb 2024 11:02:13 -0800 (PST) Received: from [100.64.0.1] ([170.85.6.200]) by smtp.gmail.com with ESMTPSA id l4-20020a922804000000b00364f14861ffsm2248458ilf.76.2024.02.27.11.02.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Feb 2024 11:02:12 -0800 (PST) Message-ID: <21e03db9-efb7-4e26-9b0d-4931afd62194@sifive.com> Date: Tue, 27 Feb 2024 13:02:11 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 4/4] riscv: Allow NOMMU kernels to run in S-mode Content-Language: en-US To: Conor Dooley Cc: Palmer Dabbelt , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240227003630.3634533-1-samuel.holland@sifive.com> <20240227003630.3634533-5-samuel.holland@sifive.com> <20240227-seventh-overgrown-2fa453e8a775@wendy> From: Samuel Holland In-Reply-To: <20240227-seventh-overgrown-2fa453e8a775@wendy> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Conor, On 2024-02-27 6:24 AM, Conor Dooley wrote: > On Mon, Feb 26, 2024 at 04:34:49PM -0800, Samuel Holland wrote: >> For ease of testing, it is convenient to run NOMMU kernels in supervisor >> mode. The only required change is to offset the kernel load address, >> since the beginning of RAM is usually reserved for M-mode firmware. >> >> Signed-off-by: Samuel Holland >> --- >> >> arch/riscv/Kconfig | 15 ++++++++++----- >> 1 file changed, 10 insertions(+), 5 deletions(-) >> >> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig >> index ef53c00470d6..0dc09b2ac2f6 100644 >> --- a/arch/riscv/Kconfig >> +++ b/arch/riscv/Kconfig >> @@ -64,7 +64,7 @@ config RISCV >> select ARCH_WANTS_THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE >> select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU >> select BUILDTIME_TABLE_SORT if MMU >> - select CLINT_TIMER if !MMU >> + select CLINT_TIMER if RISCV_M_MODE >> select CLONE_BACKWARDS >> select COMMON_CLK >> select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND >> @@ -220,8 +220,12 @@ config ARCH_MMAP_RND_COMPAT_BITS_MAX >> >> # set if we run in machine mode, cleared if we run in supervisor mode >> config RISCV_M_MODE >> - bool >> - default !MMU >> + bool "Build a kernel that runs in machine mode" >> + depends on !MMU >> + default y >> + help >> + Select this option if you want to run the kernel in M-mode, >> + without the assistance of any other firmware. >> >> # set if we are running in S-mode and can use SBI calls >> config RISCV_SBI >> @@ -238,8 +242,9 @@ config MMU >> >> config PAGE_OFFSET >> hex >> - default 0xC0000000 if 32BIT && MMU >> - default 0x80000000 if !MMU >> + default 0x80000000 if !MMU && RISCV_M_MODE >> + default 0x80200000 if !MMU >> + default 0xc0000000 if 32BIT >> default 0xff60000000000000 if 64BIT > > The first default seen with a passing condition is the default chosen, > right? Yes, exactly. It's not required for the conditions to all be disjoint. Regards, Samuel