Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1648422rdb; Sat, 3 Feb 2024 16:22:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbJ12lO3ahwJunyqTLqgWE2lMzFuCkRwJiXrHxh2muPbvkoy9LNqFaUFZfc+IT+u4PVbCI X-Received: by 2002:a17:902:c94b:b0:1d9:8e37:56d6 with SMTP id i11-20020a170902c94b00b001d98e3756d6mr2516411pla.40.1707006168950; Sat, 03 Feb 2024 16:22:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707006168; cv=pass; d=google.com; s=arc-20160816; b=YXW9WjrMdZHEzRIyOt4pjNwJO31CeAQ5pTbaZ7mlRaOwBG9P1zyD8cSTmFgpl9IXe2 ZwyunHdUvMEm6LArJ9iUDT5u+WKsR+VhCxiSigcrWGelh94zLTpdp8cuz3GdtuYfh+xC vEJ38b/DVExMVJXOngnT/MVk4miBzyLzY1jZtARGzp8YB7SrpgTlN8fBdtroFiuSIcnF woyLpfH9JLVYafNOwyxDjpsBhffn5mXqWjdUQhmNUNXO+2kTPsz8a57d43LN/IVApMfe viw9/lGOiUvmBoWugKmmtd95zZib8/DjX0STGsQtWQTXKGNk5cDcQouamDzDPjb1fX3i PbGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=TfmI2ewltHRJMYO5mo5fFwZc+1SV7LuHqUomT5kdRyc=; fh=w4pRT2TuO3d2xLxV4DHEAbG4YnnfwZBClxEfyCR6m/Q=; b=yPX3Gd0u8bRExFrk/bQPIjUER8LoA65mD9FWfj2ZMwrp/BCUMilGn790lzIICYuBAV 5pM2XTEs2WzaTIZFfI1SWYgv2EaYJinoTra3UNeZgQmexM9VemuGdv/Un3w13kMUKhPf LSvytp9Y2K0H4c57QDXjdQQSPWWfSdzAEYDDdY07qDgcUhKag1kvOdSyfQlwfz+EIKqn OPKkKDtiTAIBBYfj+88xRtWx9yFOw2tQ3EsrrM94aAL94V+cMX6Gqg4S71PIoOEQIUNC OH3oCXcWEfQ6P0A6eoO1rYBxxI6lFoyI+doHHJ1nztXsAvAqStUKLdMZokM9bi17EYX4 etpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=gE+5TW3D; arc=pass (i=1 spf=pass spfdomain=jrtc27.com dkim=pass dkdomain=jrtc27.com); spf=pass (google.com: domain of linux-kernel+bounces-51330-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51330-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXvV1S1TAj23Ndd7UyrkcVv6hmMEjw/+0atVlEXH6pMHfScSfcOH1KzcXTP/9egblQaU0aH+1XhWcdtFYmiW5PX8DkZO19zh0dnYb7U1g== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c9-20020a170902d48900b001d8dbb867a5si3958374plg.592.2024.02.03.16.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 16:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51330-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=gE+5TW3D; arc=pass (i=1 spf=pass spfdomain=jrtc27.com dkim=pass dkdomain=jrtc27.com); spf=pass (google.com: domain of linux-kernel+bounces-51330-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51330-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7BA9A2856E3 for ; Sun, 4 Feb 2024 00:22:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74B7A816; Sun, 4 Feb 2024 00:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b="gE+5TW3D" Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 75B8538C for ; Sun, 4 Feb 2024 00:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707006160; cv=none; b=Zd7KnkKntCC4sLoyxk8Df3JLkl6UOR3ipVxTiPafLjBDVydrTzTW2PLCahDMnhl/bp5BSyIsD+gMKJXv+zK895nGl9qmngmDhSC5CetEmj19pstYZs/SjgENf4830TJOnqkoZqePMfv01WG1KUKDOk2bl2xxg0TQiedA4NG7dy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707006160; c=relaxed/simple; bh=czkfpW61lAXFdsguakOz0Yvzzd1nD9b8p8YAJzKHBq0=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=YIKn+gopHpQBZ8NgxZGbiqlekkU2077upplhgwQZzSCQJWn+RCmplRE1cv4xHSg4JS/5NQjAi0/c1qS1qIjQvff2Ci3kToHbYWbluCHAIshw0cGKDV0KFUniZ1/HW8p3DZxKxRkOKT3orZ3MtqW6e1LcQ8JnzWqCU1OHyvrin/k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jrtc27.com; spf=pass smtp.mailfrom=jrtc27.com; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b=gE+5TW3D; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=jrtc27.com Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40fb804e330so29813695e9.0 for ; Sat, 03 Feb 2024 16:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; t=1707006156; x=1707610956; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TfmI2ewltHRJMYO5mo5fFwZc+1SV7LuHqUomT5kdRyc=; b=gE+5TW3DktoPPS5gBD8eylS2CiliBultrDat5wN+17ZfOz9deSbSHR8JKx/kVrLUu/ mY50uYc09LIH6SQJmMmjQhJemB9qfi9e4KeMQz/aWswRIdBSSbiojFlAkPvNFLlzPFNB oNlGh9Vmg2Jt+LiU8cBniDwWRx6fUMigZR2QizPmO2MHm0lOktGaShUqc2lNq3De5f7/ KAdPRBLbiWHat7HUzZqq92+VX5qm7zrW1zVRcw+94JcmCVVML0TjK9AirelQMrmovKfh rszptZqyKiWVlLDIhb/VmbSz8njW+jtArbGLkCURDyUxFw6ozdb+gXWM9OVXEoBiLHNz a86g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707006156; x=1707610956; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TfmI2ewltHRJMYO5mo5fFwZc+1SV7LuHqUomT5kdRyc=; b=aBiMgQDVoCOki9gDAsApvwZRMN3dxfoad+ayOw3/QrbgS97PXuorV1UUwK9AroiKlq e94OP3hRB1WtfzmEDTFh2dbsiA0VvUzxfISG3Jifr080sSJH9KJ1vglv3fQMr5cxskOO TY52YGxac2J1S5NH9Z0lB6HjWhOLNjobahRj0WiUhSgoz869tX60eR12FkN7+LQRfjmC lL3+csRhx9caQ6s8hHhCzc7k3BKtRtS6kloCIf1J43gL1+kAisK7NyKuWjuP4umBcuSr 1bIjHXZH24iRybv2Xf/OlA625O44HGNqDd78FqHYWHIiBninfRDJKtjIBFbtHntgaFpf UrEA== X-Gm-Message-State: AOJu0YxYvbigCnHWFe9BYfsTRYn4H6GB3DZ4kEBSfAYmaGcn7cJcZETo es7idCGXEdSx2wkEqHS/yjUbHSCHQpa9qeoksFh9HLwtzXA2TpX4hMKqA+W8ouM= X-Received: by 2002:a05:600c:458a:b0:40f:d3bd:b222 with SMTP id r10-20020a05600c458a00b0040fd3bdb222mr1413414wmo.38.1707006156368; Sat, 03 Feb 2024 16:22:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWJTmKxGNH/ofKVvL73KTRZlg0mpziW2SONM+lih4pUDUXze0Pudw4a1sccT9ryZqBsoL7pFDIP7gcQG0h5kprVUqwPZsmtyd5/4WCR9wwSbK3d96ikGt21oE2QcjHfIkB8j1I++xn65wWXI3HgsSzY2E7+unG4QFRBDvUWgdkoEgn18caH8K5iO++HQ+Gve8TcUqqvvFKIYSyldA7JaAaM0erFh+AEoihv47VtdWvnsNsqKesxAmoZrybLyOF0+DjlLFl3N3IZKOcMXRl92deUuotAozXDEx9j2NCMTGo9hbImGql1w8U6m59XC9rt+l3xwfdg6BvgSXED10Qmcw2RvtKjfeYQ Received: from smtpclient.apple ([131.111.5.246]) by smtp.gmail.com with ESMTPSA id p4-20020a05600c358400b0040fb7c87c73sm4250081wmq.45.2024.02.03.16.22.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Feb 2024 16:22:35 -0800 (PST) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) Subject: Re: [PATCH] riscv: hwprobe: export VA_BITS From: Jessica Clarke In-Reply-To: <5657c211-531b-4890-8c52-182b7b4eae7c@app.fastmail.com> Date: Sun, 4 Feb 2024 00:22:25 +0000 Cc: =?utf-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , Charlie Jenkins , Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-doc@vger.kernel.org, linux-riscv , linux-kernel@vger.kernel.org, Robin Ehn Content-Transfer-Encoding: quoted-printable Message-Id: <5A2420B9-6039-445B-B2C3-77F13EDD77BA@jrtc27.com> References: <20240201140319.360088-1-cleger@rivosinc.com> <701d3350-93d3-4235-aaf7-04c6492420a7@rivosinc.com> <5657c211-531b-4890-8c52-182b7b4eae7c@app.fastmail.com> To: Stefan O'Rear X-Mailer: Apple Mail (2.3774.200.91.1.1) On 3 Feb 2024, at 10:40, Stefan O'Rear wrote: >=20 > On Fri, Feb 2, 2024, at 3:22 AM, Cl=C3=A9ment L=C3=A9ger wrote: >> On 02/02/2024 03:32, Charlie Jenkins wrote: >>> On Thu, Feb 01, 2024 at 03:02:45PM +0100, Cl=C3=A9ment L=C3=A9ger = wrote: >>>> Some userspace applications (OpenJDK for instance) uses the free = bits >>>> in pointers to insert additional information for their own logic. >>>> Currently they rely on parsing /proc/cpuinfo to obtain the current = value >>>> of virtual address used bits [1]. Exporting VA_BITS through hwprobe = will >>>> allow for a more stable interface to be used. >>>=20 >>> mmap already supports this without a need for applications to know = the >>> underlying hardware. If a hint address is passed into mmap, it will = never >>> return an address that uses more bits than the hint address. I = designed >>> it that way so that something like this wasn't necessary. >>=20 >> Ok even though probing this kind of thing is probably not what mmap = is >> meant to do. IMHO, probing this through the regular hwprobe interface = is >> probably more coherent but maybe Robin (which needs this information) >> can rely on that. >=20 > Both of these are useful, separately and in conjunction. >=20 > hwprobe allows applications which can adapt to different VA sizes to = learn > which is in use prior to allocating memory. >=20 > mmap hints allow applications which require a fixed limit on the VA = size to > express that limit at the point of requirement, the hint can be set = based on > the hwprobe result to explicitly indicate its use. Neither is an architecture-specific concept though. If you want to expose a notion of VA bits to userspace then it should probably be done in a more generic manner than the RISC-V-specific hwprobe syscall, probably as two numbers, low and high bits (ia64=E2=80=99s regions may = be gone, but sparc64 still has both halves of the address space presented to userspace, with the stack in high/negative memory). Jess > -s >=20 >> Cl=C3=A9ment >>=20 >>>=20 >>> - Charlie >>>=20 >>>>=20 >>>> Link: = https://github.com/openjdk/jdk/blob/master/src/hotspot/os_cpu/linux_riscv/= vm_version_linux_riscv.cpp#L171 [1] >>>> Signed-off-by: Cl=C3=A9ment L=C3=A9ger >>>>=20 >>>> --- >>>> Documentation/arch/riscv/hwprobe.rst | 3 +++ >>>> arch/riscv/include/asm/hwprobe.h | 2 +- >>>> arch/riscv/include/uapi/asm/hwprobe.h | 1 + >>>> arch/riscv/kernel/sys_hwprobe.c | 3 +++ >>>> 4 files changed, 8 insertions(+), 1 deletion(-) >>>>=20 >>>> diff --git a/Documentation/arch/riscv/hwprobe.rst = b/Documentation/arch/riscv/hwprobe.rst >>>> index b2bcc9eed9aa..6f198c6ed4f0 100644 >>>> --- a/Documentation/arch/riscv/hwprobe.rst >>>> +++ b/Documentation/arch/riscv/hwprobe.rst >>>> @@ -210,3 +210,6 @@ The following keys are defined: >>>>=20 >>>> * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int = which >>>> represents the size of the Zicboz block in bytes. >>>> + >>>> +* :c:macro:`RISCV_HWPROBE_KEY_VA_BITS`: An unsigned long which >>>> + represent the number of bits used to store virtual addresses. >>>> diff --git a/arch/riscv/include/asm/hwprobe.h = b/arch/riscv/include/asm/hwprobe.h >>>> index 630507dff5ea..150a9877b0af 100644 >>>> --- a/arch/riscv/include/asm/hwprobe.h >>>> +++ b/arch/riscv/include/asm/hwprobe.h >>>> @@ -8,7 +8,7 @@ >>>>=20 >>>> #include >>>>=20 >>>> -#define RISCV_HWPROBE_MAX_KEY 6 >>>> +#define RISCV_HWPROBE_MAX_KEY 7 >>>>=20 >>>> static inline bool riscv_hwprobe_key_is_valid(__s64 key) >>>> { >>>> diff --git a/arch/riscv/include/uapi/asm/hwprobe.h = b/arch/riscv/include/uapi/asm/hwprobe.h >>>> index 9f2a8e3ff204..2a5006cddb7b 100644 >>>> --- a/arch/riscv/include/uapi/asm/hwprobe.h >>>> +++ b/arch/riscv/include/uapi/asm/hwprobe.h >>>> @@ -67,6 +67,7 @@ struct riscv_hwprobe { >>>> #define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0) >>>> #define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) >>>> #define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6 >>>> +#define RISCV_HWPROBE_KEY_VA_BITS 7 >>>> /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ >>>>=20 >>>> /* Flags */ >>>> diff --git a/arch/riscv/kernel/sys_hwprobe.c = b/arch/riscv/kernel/sys_hwprobe.c >>>> index a7c56b41efd2..328435836e36 100644 >>>> --- a/arch/riscv/kernel/sys_hwprobe.c >>>> +++ b/arch/riscv/kernel/sys_hwprobe.c >>>> @@ -202,6 +202,9 @@ static void hwprobe_one_pair(struct = riscv_hwprobe *pair, >>>> if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ)) >>>> pair->value =3D riscv_cboz_block_size; >>>> break; >>>> + case RISCV_HWPROBE_KEY_VA_BITS: >>>> + pair->value =3D VA_BITS; >>>> + break; >>>>=20 >>>> /* >>>> * For forward compatibility, unknown keys don't fail the whole >>>> --=20 >>>> 2.43.0 >>>>=20 >>>>=20 >>>> _______________________________________________ >>>> linux-riscv mailing list >>>> linux-riscv@lists.infradead.org >>>> http://lists.infradead.org/mailman/listinfo/linux-riscv >>=20 >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv >=20 > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv