From nobody Mon Dec 15 18:01:25 2025 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=1747843460; cv=none; d=zohomail.com; s=zohoarc; b=ezV4RLgr3bHEEe7AsNdVXlQt0RoJ2YVeSGRMGA2KMp3obXXUaHrBCaAmM9mLKSwk04OgqNqEuzbd5eXVzgsscHqezFpXhZXp1XiR6obNejogIOqDGJhj6mTu+2mbAKv/MmUchRsEPJDcfO4C9LeqKnmwBLoDBOajyiE9ox16Fk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747843460; 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=GTDxJdlWqyBuUYAssfRiBPJ9qN2ELiVYcf2RQUhFW1U=; b=ZZKxmiyLoaumttoM9cWDQgtegi4KJAReKZUVRAES1mmguHQemX5Ytf9gwCE1bjjptqvVDKDUyOWuXS88sN1qaTglZjDF36zka8Gq1Zd9U1sRlktN9w0Yvf1P/UsZJ2nxJJPImIxkFPlMAT4P/kQ9LQ89Tru+vlZ6P1GzBdFZvJ4= 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 1747843459907865.3594235753989; Wed, 21 May 2025 09:04:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.992140.1375946 (Exim 4.92) (envelope-from ) id 1uHlvJ-0005DC-HR; Wed, 21 May 2025 16:04:05 +0000 Received: by outflank-mailman (output) from mailman id 992140.1375946; Wed, 21 May 2025 16:04:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uHlvJ-0005D0-DZ; Wed, 21 May 2025 16:04:05 +0000 Received: by outflank-mailman (input) for mailman id 992140; Wed, 21 May 2025 16:04:03 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uHlvH-0004XB-On for xen-devel@lists.xenproject.org; Wed, 21 May 2025 16:04:03 +0000 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [2a00:1450:4864:20::531]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 36e88ac4-365d-11f0-a2fa-13f23c93f187; Wed, 21 May 2025 18:04:03 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-601d66f8cafso5698071a12.3 for ; Wed, 21 May 2025 09:04:03 -0700 (PDT) Received: from fedora.. (user-109-243-64-38.play-internet.pl. [109.243.64.38]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6004d502736sm9152513a12.25.2025.05.21.09.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 May 2025 09:04: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: 36e88ac4-365d-11f0-a2fa-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747843442; x=1748448242; 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=GTDxJdlWqyBuUYAssfRiBPJ9qN2ELiVYcf2RQUhFW1U=; b=cjcrTPPoqTY+uKyaNYt9GvbRuj4cwz0GKWt0P9Fzdjgo2N5ZNbWF2mcdfCdq8WbxbP YxnfjKSdFS8HeW1PRX5gqGHNHGPgVfPcHGA2v7pU7tvF/3HQ2rQgLIGUdf0l2/ySUcy3 kN43AkjuiwsNmPXMSzLnPGEitJIf1WED8k0oAdcwgiqX9RI5FJ7SvqZOf0ZaRzBFGipZ u2r3MSiZ+FGfoyHaG0FlXFyVUQyAN8mfl0D4f9EaOzcx10ko0NED3hgRbKYMWRWtMWMu JptW6lgXxD77khgnQ6jq/XjlPOHJj0Oq6rAFr34FfaYRl/qKB9+bSLSbOE8xUFLNv87Y Lx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747843442; x=1748448242; 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=GTDxJdlWqyBuUYAssfRiBPJ9qN2ELiVYcf2RQUhFW1U=; b=MhVAktMsTYAWJD48VdCDuh7h6KnBkupMEWMl1OLUliq4R2hOJC2NajIbSxLuHG78yj 5ZfZtv/c7WT8axmyhoPxZ3MaMBeQdZODphC1ydP+awtNg7GweDrFwfpKYSuhPuMBIWTF cIGpUVTitlmAv2+nqoqorVHqohdL97D9leOX+Re09j8VAS79TnwOEio1PpP7ioKuR+L8 CzmDaxDHcplkNXCgsUZU1avW+RLqSW6Uf2thnfyhspFXr+cRVSPvjGWCD+2nRGVH3zAk rLlriJAO72ywOqyTyfUgOR4ep2CpvP8j260wKLb3HunZZsoMEgwLoi+tj3NeBZ4V2kJp QwVg== X-Gm-Message-State: AOJu0YxSlZIAuBUALfi5kS+TWpSufOENR9+uFH+pyeMYhAAq+LVffBiz 0WA7AURUrh01vlW+15Vv7NjiVDFciG/LCqKMI9gTVlwAAyRnja8BfMcNS/rIzA== X-Gm-Gg: ASbGncvGKKXbq7SGWaWqzAC/zqGkgPGlPI+Ar4fjzdcw1FHlbp8fqHg9NCo3Pb2wCoX cTcNxPoZOmq+zrM5YflX8J7Ifr5sWhgGdw8DNXIzWT+pfN2qF1ECUppmNZKJUVV2CnXheouHZun 5uLRvwP2n5uIYoF1an4HO5z/1uWXfc1d6ixKik+X7Au8v9jfexVyOTX3tlJUcLQK1f7DY1guMX0 H1DRAjQiU42JiYAHnKH6900og6p4lQCb4Bpi5fT/vD0krpGhruLPauIFQ2GLz8rLUL6mNBqysyI Ln2o05QEM0FMjs5+ouiRIF5xpwai6N31Inha0KTcH0oXiwzK8JEAXy8EzfWvCX0lI76vCtdDfDn stiaW4njR0jrKFpGk9g== X-Google-Smtp-Source: AGHT+IHvMVemtY/rVmjCbwswGEM7HqhP6r5qb6LnqJDAtjjjAajYDr3TUYO5Abv8PQ6/cuQUXCR7zg== X-Received: by 2002:a05:6402:4304:b0:602:1d01:2869 with SMTP id 4fb4d7f45d1cf-6021d012c1cmr5908930a12.28.1747843441958; Wed, 21 May 2025 09:04:01 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v3 03/14] xen/riscv: add ioremap_*() variants using ioremap_attr() Date: Wed, 21 May 2025 18:03:43 +0200 Message-ID: <2bdbb98adf5246cd1a10e1575b8bf0aa2bdb5f6d.1747843009.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1747843460881116600 Content-Type: text/plain; charset="utf-8" Introduce ioremap_attr() as a shared helper to implement architecture-speci= fic ioremap variants: - ioremap_cache() - ioremap_wc() These functions use __vmap() internally and apply appropriate memory attrib= utes for RISC-V. These functions are implemned not as static inline function or macros as it= will require to include asm/page.h into asm/io.h what will lead to compilation issue. Also, remove the unused ioremap_wt() macro from asm/io.h, as write-through mappings are not expected to be used on RISC-V. Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich --- Changes in v3: - Drop ioremap_nocache() as ioremap() duplicates functionality of ioremap_nocache(). - Add __iomem to defintion of ioremap(), ioremap_attr(). - Rename start to pa for all ioremap*() functions. - Update the commit message ioremap_nocache(). --- Changes in v2: - Update the commit subject + message. =20 - move out Svpbmt changes to separate patch. - Drop #ifdef SVPBMT for ioremap(). - Redefine ioremap_* in io.h. - Introduce ioremap_attr(). --- xen/arch/riscv/include/asm/io.h | 10 ++-------- xen/arch/riscv/mm.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/xen/arch/riscv/include/asm/io.h b/xen/arch/riscv/include/asm/i= o.h index 8bab4ffa03..9aeafd6b3b 100644 --- a/xen/arch/riscv/include/asm/io.h +++ b/xen/arch/riscv/include/asm/io.h @@ -41,14 +41,8 @@ #include #include =20 -/* - * The RISC-V ISA doesn't yet specify how to query or modify PMAs, so we c= an't - * change the properties of memory regions. This should be fixed by the - * upcoming platform spec. - */ -#define ioremap_nocache(addr, size) ioremap(addr, size) -#define ioremap_wc(addr, size) ioremap(addr, size) -#define ioremap_wt(addr, size) ioremap(addr, size) +void __iomem *ioremap_cache(paddr_t pa, size_t len); +void __iomem *ioremap_wc(paddr_t pa, size_t len); =20 /* Generic IO read/write. These perform native-endian accesses. */ static inline void __raw_writeb(uint8_t val, volatile void __iomem *addr) diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c index d3ece9f132..4047d67c0e 100644 --- a/xen/arch/riscv/mm.c +++ b/xen/arch/riscv/mm.c @@ -11,6 +11,7 @@ #include #include #include +#include =20 #include #include @@ -583,3 +584,32 @@ void *__init arch_vmap_virt_end(void) { return (void *)(VMAP_VIRT_START + VMAP_VIRT_SIZE); } + +static void __iomem *ioremap_attr(paddr_t pa, size_t len, + pte_attr_t attributes) +{ + mfn_t mfn =3D _mfn(PFN_DOWN(pa)); + unsigned int offs =3D pa & (PAGE_SIZE - 1); + unsigned int nr =3D PFN_UP(offs + len); + void *ptr =3D __vmap(&mfn, nr, 1, 1, attributes, VMAP_DEFAULT); + + if ( ptr =3D=3D NULL ) + return NULL; + + return ptr + offs; +} + +void __iomem *ioremap_cache(paddr_t pa, size_t len) +{ + return ioremap_attr(pa, len, PAGE_HYPERVISOR); +} + +void __iomem *ioremap_wc(paddr_t pa, size_t len) +{ + return ioremap_attr(pa, len, PAGE_HYPERVISOR_WC); +} + +void __iomem *ioremap(paddr_t pa, size_t len) +{ + return ioremap_attr(pa, len, PAGE_HYPERVISOR_NOCACHE); +} --=20 2.49.0