From patchwork Thu Feb 1 14:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 13541107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1B0DC4828F for ; Thu, 1 Feb 2024 14:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=P2aVzyiMZix5/P3W+83uiGOFh1t/zZX9tggUW3NoBNo=; b=kL69rOb0vTf3CX Lu/TxrpD+qGyDrDWCaCNC4Li9vVy9iDfqOC6BjRYHmBUwR6HO7EsUZvhBgXIxlHaOCYp8nMxOPG2H oDwsqBkwtp8B73RKwJfYF6i7DDNeGXU6gTD5F2OsNEuJorMhlXAlUpm89p8g/O5UbVDcFCh2Ku8tY NZnM6yRajmp9+E2DU4Zp9x22SlguDDwIdyk+lagmGYz3ouRks4oPp86ezi28b8MDznLm8cMkpjRPC gJyHmGKwOqzUMlQbnr3YynKu8AF/9wCDyToQ3Ih7CMdgNpgTDgEI+X+w96Npix6szXAnrh2x/sRlf qUXJu1poIg0mBzXvhY1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVXhF-00000008DbF-2jLf; Thu, 01 Feb 2024 14:05:41 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVXhB-00000008DZ2-35V0 for linux-riscv@lists.infradead.org; Thu, 01 Feb 2024 14:05:39 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1d8b2f392b3so739875ad.1 for ; Thu, 01 Feb 2024 06:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1706796336; x=1707401136; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JiEpcBE0z8Q5t3JWdIgJHWEI2G0S1HPZ9ikeHZvifi4=; b=F+IeFLP3I+WacMX7Yl6FM07VUpooxKO+CWbvbkd5CpPAsX41BKKOEVND8CP3xc4yLG HZ0KUi20cOLSwsydc1WsYr5sbcPulge61t5nVV3W0cComPCHJFRc/G8lcd5pSohPS+QA I3v6A2PQDXDwbDbjD7nOD2rYBaCIWmnsjwmrIa9F0ua5uI0guCHyPb98lRf0N4Px4iu4 WjuBEtRYZSJu0vTjAZqEP3PHAtGIy1UOh4vXjmjkBBDiRubEtPJLy+T4qPAnq3LUOt7i Pkg/ENGbIXzt/d213M6d1suZbtKPv2mx+Hjlhl69A2Qu1e/Ron7TMdj0LYueyfFE+IF1 R16g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706796336; x=1707401136; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JiEpcBE0z8Q5t3JWdIgJHWEI2G0S1HPZ9ikeHZvifi4=; b=kC33Xki2556oxR81FTw6S3fEFarblFJZFy+FHx281XFsJZaDZoGK/Ssa58Ct7xNBk3 AwTdU8FQr63QFI0c/bJuzLBl+aLJV5AY678uh9ZnQffPD37EgqPfCmxUvzn2W8HsypnV lE8h+zCRqEnjRcR7fC/A7IXru6gEzo2+DH5V2LA4NShU/CTNyyby8V8Gj29zIhRIi4vg LrolpqZRl8zsn+lI0GrkX+nUq+PrWh7wJBLEl0fj4U7tX/83uW9QkbRnEpMGsXTWfFV7 ISioG8hRSz6d/3v5Mtv2xjZ/AZIjTWAwKEvpHhWhlYvyfYH/zjo/LpKkU+gnbm0b2iJk /mpA== X-Forwarded-Encrypted: i=0; AJvYcCWD862sZKGeufTdYqBtiY+sOoZipQfRBbsxQHpfpGgA9S0gj7GT68+AS4CAvU31V4Sg8AWYo4SUUzYgLM3V1TsPK8dlUZZgM9dC3IM+dOmZ X-Gm-Message-State: AOJu0YyOqy6XcVxljaS/SSFtu7TN79NE8MI7cD9aCCHLPZCvnnoafy0c Da+4b/CfqMS4y2U1ukZqgOHjVChJR1fzr1VM4LLEoCq3Pa5ZUTBlHS9NVyrqH3Y= X-Google-Smtp-Source: AGHT+IH8tWdldiYSjIIvCar+NyjyZ+8lWYi2wVCMLRjX2BxVq2M9ONUwvbyZ78JOaLsGgI8+DCI/jQ== X-Received: by 2002:a17:902:ea08:b0:1d8:d1f5:e5d with SMTP id s8-20020a170902ea0800b001d8d1f50e5dmr2801264plg.0.1706796335668; Thu, 01 Feb 2024 06:05:35 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU25vJ3ilONQ5+/2C4Wo2EpHNVQs3nHC9z6Guhj5ymJAU6kxBvc3F//8Q+scr/hLvk8cIRUNkuurwXW45PCazS3ATmw/SnLm77EZOQ5TLzQaZxwVz9beY1BoTbofuwYSOjNSrYouvlGBRh5WS9oj0ANDmSCutNP3ZHt5m2gCwJHrnuFGlHgQ6bdn6QSPWEnbdFWb8Z4mFT50NQABIOvwob+iHVHb8iq7tM4FZPxfNIUz1GmPKdRDJ5JiWaqnVA+S6yu+q2wH3eQ2GPTLoh4+tFD4tCseVmgacj20XaeMvCa9g== Received: from carbon-x1.. ([2a01:e0a:999:a3a0:189:f9cd:e10f:7a3f]) by smtp.gmail.com with ESMTPSA id kb16-20020a170903339000b001d8ec844fe7sm6914308plb.283.2024.02.01.06.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 06:05:35 -0800 (PST) From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Jonathan Corbet , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Robin Ehn Subject: [PATCH] riscv: hwprobe: export VA_BITS Date: Thu, 1 Feb 2024 15:02:45 +0100 Message-ID: <20240201140319.360088-1-cleger@rivosinc.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_060537_903095_504DB56F X-CRM114-Status: GOOD ( 15.01 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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. 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ément Léger --- 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(-) 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: * :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 @@ #include -#define RISCV_HWPROBE_MAX_KEY 6 +#define RISCV_HWPROBE_MAX_KEY 7 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. */ /* 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 = riscv_cboz_block_size; break; + case RISCV_HWPROBE_KEY_VA_BITS: + pair->value = VA_BITS; + break; /* * For forward compatibility, unknown keys don't fail the whole