From nobody Sun Nov 24 15:59:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1729070188; cv=none; d=zohomail.com; s=zohoarc; b=fqXsfIXvo8xL3AgjCc+om6f9fUbg3+dpeTYfwlozBZo9DOiFXcxUHdyFxlY3XWDnzyxyGwdwoqcDtcMRF87rUptxeesxQ5DTk7FREyjWBZzfij3F1akErgOlHvmCrDO8DKsiURWKFMKcXZfI4KNAxumvXUSEW89WzHaCNR7N3L8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729070188; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zTo8wcoBAnZWVL6JY0i7rOCMbKVxaD9bONOTGNKU9j0=; b=PYqpOXsAV/T2BM4GumeLfgM58FbWtG2/829MwabuFOuthY86AiHsqdBFMVdBQuRABJGUJXsAahIpwpVECf7D6w+vbXZk6fqFlmjUaR+sVIZutTcwE5Gq5A7kA3ut28ZR31B/YMjJWIF0ZQFhscKsMCX5JXBRA/f4KNmsvbZgtFY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1729070188556370.09830934822855; Wed, 16 Oct 2024 02:16:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.819723.1233156 (Exim 4.92) (envelope-from ) id 1t108V-0005La-6O; Wed, 16 Oct 2024 09:16:07 +0000 Received: by outflank-mailman (output) from mailman id 819723.1233156; Wed, 16 Oct 2024 09:16:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t108V-0005LR-3f; Wed, 16 Oct 2024 09:16:07 +0000 Received: by outflank-mailman (input) for mailman id 819723; Wed, 16 Oct 2024 09:16:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t108T-0004r9-L4 for xen-devel@lists.xenproject.org; Wed, 16 Oct 2024 09:16:05 +0000 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [2a00:1450:4864:20::136]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 44c55a29-8b9f-11ef-99a3-01e77a169b0f; Wed, 16 Oct 2024 11:16:04 +0200 (CEST) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-539f2b95775so4121713e87.1 for ; Wed, 16 Oct 2024 02:16:04 -0700 (PDT) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-53a000129eesm391451e87.259.2024.10.16.02.16.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 02:16:01 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 44c55a29-8b9f-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729070163; x=1729674963; darn=lists.xenproject.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=zTo8wcoBAnZWVL6JY0i7rOCMbKVxaD9bONOTGNKU9j0=; b=C2cAA6GZr+IRir0BpoKtgIeq9vxBXkASqUuKhHDfWjUW8xpbf619sAIPRX4oh8aQwo 38y9neezO0KcnrmiYbsdzWYwGPLyflyoXBF5KA7UYO1PR/S23nvfBk36kyEiNwYdQWh/ JSKplRCW3zR7e7wOP6Og9tUsK81Jv0RFlmQFObHr/KAoXFF8jYZU5nJJkZSX/FGIQg2+ lG53A0YXTeEipLzj+OsIBbZllTCt1IWTf5rDEL3hDNeKz+5vNT3470/YO3CLzgYZvMFr NODx42L/ojBUgAzrIuzV6jLiTVwoafclyRPd33jtoUyohtW96BiEA/gKcXHG3iI3I30Y V7jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729070163; x=1729674963; 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=zTo8wcoBAnZWVL6JY0i7rOCMbKVxaD9bONOTGNKU9j0=; b=XT/4qknI1gm3xEKUVyk+OpybGkd5ydNMUH8FtXa1plRe7z3PQGgHTp6/RAOa11nn9r PC5qkS9fftJeMTSwyNmcLZihPh1RY0TKOXN/zAur36sKE/Hblwn3cLaiiqqthbLVJf3U sKN4R4QKdBKy/GjwbE2u9HIwRUrBxUpMaYLSDnrSRbDUJPsxKHCtPdz6Nvf7Q1rtjlDk Vv1J2MUKFPCMOt1XmpXwhGyTpzzfeob2HwqFLjMDjGHlEv2oK4JY5AlLueaovrhlP9hl pu5ZZW9eZcN0dI4lU+2qw5w+PJXYbpoL0sHxSCyS0Afh4sXcVKrZSYOJy3h6ZIs46cS0 KuKw== X-Gm-Message-State: AOJu0YyMwYuZLlm8h9KPXsGtAOaauTYrTf9YU72o4YWBK8dZgCK//cLq pot3rcidG8vs96ld7g7bT5DpFueTHHG5IWIEUFdOKrx5v7g86Mke0Z5otA== X-Google-Smtp-Source: AGHT+IGiD8tLBcbs6M/QvfKxQOuo5Zgnq6pEzPkd4C4CIXLglaZ+oIXatCYihqviEWs7KjcKGIUlFA== X-Received: by 2002:a05:6512:220d:b0:539:8a50:6ee8 with SMTP id 2adb3069b0e04-539e57282b1mr9234525e87.57.1729070163190; Wed, 16 Oct 2024 02:16:03 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH v1 2/5] xen/riscv: implement maddr_to_virt() Date: Wed, 16 Oct 2024 11:15:54 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1729070189389116600 Content-Type: text/plain; charset="utf-8" Implement the `maddr_to_virt()` function to convert a machine address to a virtual address. This function is specifically designed to be used only for the DIRECTMAP region, so a check has been added to ensure that the address does not exceed `DIRECTMAP_SIZE`. Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/include/asm/mm.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/riscv/include/asm/mm.h b/xen/arch/riscv/include/asm/m= m.h index ebb142502e..0396e66f47 100644 --- a/xen/arch/riscv/include/asm/mm.h +++ b/xen/arch/riscv/include/asm/mm.h @@ -25,8 +25,12 @@ =20 static inline void *maddr_to_virt(paddr_t ma) { - BUG_ON("unimplemented"); - return NULL; + /* Offset in the direct map, accounting for pdx compression */ + unsigned long va_offset =3D maddr_to_directmapoff(ma); + + ASSERT(va_offset < DIRECTMAP_SIZE); + + return (void *)(DIRECTMAP_VIRT_START + va_offset); } =20 /* --=20 2.47.0