Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1631956rbb; Mon, 26 Feb 2024 16:37:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX7AKW4p3aUB1zYT/W0v0v53ra4zAUnmO7TwX6LHSe4qiOV7R4HIPhFt1AhmYi82xhXRGkzzxFWY9VTvRMJKcisMuV3lQiIsgoSXL/sIg== X-Google-Smtp-Source: AGHT+IH6hiclHgX8Pxwh403c2GIFiNPwJftyh4PqSXt4+wXTnEdFsxcgeVXDBjzQyd0KjDIs+xai X-Received: by 2002:a17:906:52cb:b0:a3f:b6f8:3969 with SMTP id w11-20020a17090652cb00b00a3fb6f83969mr5290771ejn.9.1708994264465; Mon, 26 Feb 2024 16:37:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708994264; cv=pass; d=google.com; s=arc-20160816; b=lMYtrvTSfuWB2+cIYtXQNs9zsn3aRM+l0ByMbVZiZz8GPhoH1WMraX0kQsyrv21hgw xbNxcBjP3Iq73wBvMCm5zvytv7Fn80O+FWgrbngDyQBjoAbKKfWUUR7ajNbiIUehfIEo /CDRcRzz1SqF4iYfwx6inVDjJKFHmQpPJZD3d9tUoL6H5jr70RyfeglJBL3OisY2aqsU N+xKpKDnmGK6zg6s/oVdf9VZe/Ok6mSJtQ3GeyTLayS/IzWUZfXOr3RNOJIE1dbITs4D EudzgmhFujL783TAwGGmay6caTAdSLp4WKH8RGk7FnuS6CNnTGHFUpgKC9TdyegyLwIR BEfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9IhytZLl3RHTt2r80xPYLkB9iZxHThEoH75QMIzrbQ8=; fh=qgALqhvBfwh64qlTOA5xcM4euFCRJESH/+60UMp8eRY=; b=knOujLpkKdyFbc+M7tBXQ/bW9p3PcyCHS3kRZEICGbskMCqMGtLoZrRSXFVWi11yhW zkaBpBXtGbaJql/yPmsk9aP9nTdjbWXq/uf6EzYOP+hQWnRdQ/iODrjBUk1NraJ/OE1h sQ+KlOaRSHmbnFyfFmgSeo07Ptk1Nndyh6YMeajOFEHNUmscPiAm3bGjir7RU2Hcsrc3 BOKOqwuRCVUNkWd3uJGPL6J8o9k2SK91QyOF+trCZ4mAnCwHsNP+rSih16FZTJxiDhkT PDM9X6NF5Ob6mhVy7IiF1LobMZN+10LY4jHGtizFZm1T/cEzWR+Jgn2T6rooDIw7hAQa Vr/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=LYBBrYFC; 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-82472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82472-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 m13-20020a17090607cd00b00a43205596b9si222342ejc.21.2024.02.26.16.37.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:37:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82472-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=LYBBrYFC; 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-82472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82472-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 3F1291F22193 for ; Tue, 27 Feb 2024 00:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 143D2E56E; Tue, 27 Feb 2024 00:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="LYBBrYFC" Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (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 AF8D25223 for ; Tue, 27 Feb 2024 00:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708994200; cv=none; b=Qw/XCOUjm+AngDUtA0GU+lVuRH/AnIuDKAI+kUp0GCJcWxtnNaI+enuLoqAn2oaV5QupfHE3JH4O2vKWFGZnsrDx9awLSzzKN71FPTcj2FMAalG0k8KsL0O3iDWHJjbwQY8Y964NlRE+8XE1+YYkgdZCsWLPWAbT5P4fFnRCcR4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708994200; c=relaxed/simple; bh=pjl4fEaMJkh7DZc3EiKaxaa2HCJZf6Iu0TXjya2kYwU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BxUWu7FeYP6vDW6sy6mhPRI49Lw/t8yARwrTpdQXB5iVr4jyECTMLIc0Lg7Eb7Eciz6w8xeCYFpqlvtobBbTv7cFdIFiNrTYivVL1tD3xSf5l7w8D4h7TQNQcWR1QoND2JGV0KQnd7Ghy/O4WgA+IRwbhpW16Sq+xq5HvcdX5TE= 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=LYBBrYFC; arc=none smtp.client-ip=209.85.160.54 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-oa1-f54.google.com with SMTP id 586e51a60fabf-204235d0913so2574305fac.1 for ; Mon, 26 Feb 2024 16:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1708994198; x=1709598998; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9IhytZLl3RHTt2r80xPYLkB9iZxHThEoH75QMIzrbQ8=; b=LYBBrYFCBqmHYY4jYJk04eL9VVtk9pCYpc/tRIs4YN+e6YuCQL3ON6on7+aPNyd0qG ZNyL/a7ZuMgzrGZv8qjI97BOCl5/TygDsOCkWlC3p7iE6dWGn8e8dVQGxdza2SH9/0rG sS0nW7M8+SnBglAyMopliXeBZLewRoLzd2KebRVcOADKKh8c/2NbmC9452l+i5HN0gyz T/AstmFQdAZ3IdGwu+Xh7/5VogMqB/3cCJBj6HLP8/QFc65O/lymtuW8nwj2LNa0ISGV gGWPV6tCSFSIZhzr1kPODoeFkus9cgN+qK5cxN1xhqm4P9Q9L2ugI9Rief3ZtsvfDwHm sEbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708994198; x=1709598998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9IhytZLl3RHTt2r80xPYLkB9iZxHThEoH75QMIzrbQ8=; b=C9U/DdeBG4DobvcwKbjF1nCYFfARfb4W5ABdLmxcC8dv+qKintIXG9CypJIYhjCfum vA8sSXNR3IaqEt8sT0269heKU6Mg3QRaZp21hlhUOrHPJ5a0sFcfiIOPTlHboG+1m1w5 3i3lU7FL1uJUiFgUbGBtF4YqEB+bQ612m+1C3CmNvYjOdK5acKasdNTP9Q0i5zwC+ecN HtBK7q4JGU03fInWDAGbdGsIdhNcqmMhQOZWCOuLfElbmkDCULb8VzK6DPAi7+3n6lbB 3QSerI9R40TPWkN2fjtE+Xt3QfVEJCOUYCFcDgwJbz3bZt6AcRAqXqBVTSU1ng5RXJXF OmzA== X-Gm-Message-State: AOJu0YwcqACjzKyFFa6ZgI424cnuQXERSsjlpqYbTaBIxGUCKLh1ecr5 C3+yPtvrEs/QJHyHK+V3Xmf34/obh0g7ij7JEwrlZ4VKBIhQbCKwLY8plSyXdRI= X-Received: by 2002:a05:6871:230f:b0:21f:a4ce:d532 with SMTP id sf15-20020a056871230f00b0021fa4ced532mr9485542oab.31.1708994197885; Mon, 26 Feb 2024 16:36:37 -0800 (PST) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id z25-20020a631919000000b005dc85821c80sm4504117pgl.12.2024.02.26.16.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:36:37 -0800 (PST) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 4/4] riscv: Allow NOMMU kernels to run in S-mode Date: Mon, 26 Feb 2024 16:34:49 -0800 Message-ID: <20240227003630.3634533-5-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240227003630.3634533-1-samuel.holland@sifive.com> References: <20240227003630.3634533-1-samuel.holland@sifive.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 config KASAN_SHADOW_OFFSET -- 2.43.0