From mboxrd@z Thu Jan 1 00:00:00 1970 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 DEF2CCD5BAF for ; Thu, 21 May 2026 15:45:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vzMwaKUCYZrjExjFXqlMIJhz+c0JIX9Zgl0OIKx1oEU=; b=tx71FhS2A6JBCasofOy6HkGIx5 UIRPNEIGL6+cBYFm/fX7h5UYCV2MIfeXeEEEUq6Cas8DMIcy8hPsds8ccCzIb1T9oKYSupHFGm9fl Ld6lyhuGOzRZbeOZJri7YrcOFDgE8FZKlvEVTbrB8efHBeOl0oQ6qhwdNCRRh8LoI60jRWCMV6xEB ugQQWEe/f2i4qBwvYzs94ZjmqyJpTHhhW/5MfaWyW+QIGjZfQIKC37pg9woWacY2op9t40BHoMzeA Yierdijxzmkedx91heBnz4hrNiewOSDAnMvqHtBRGQXWJaTjrIgAGXs5PUutTA3Dhry5JDfau/EAV Avp4wt/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ5a6-00000008Nhn-0hZQ; Thu, 21 May 2026 15:45:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wQ5a3-00000008Nfz-0Lv4 for linux-arm-kernel@lists.infradead.org; Thu, 21 May 2026 15:45:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 297A43D42; Thu, 21 May 2026 08:44:57 -0700 (PDT) Received: from [10.1.32.22] (e122027.cambridge.arm.com [10.1.32.22]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A2D93F632; Thu, 21 May 2026 08:44:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1779378302; bh=QF68rTb5Q+J5M5tadzuOVbWRc8TvXFXjwcG27utu4As=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=nwnfIIi38PHTdUkuOtqwyuB2KBFbfOgzNq+J/ZusfxI3GaJBwHsQZTOJE/kyJGXd4 1WEsuJlB2bfkTFkAJpCRoLj0yhZO0jEDfzYgMHNHfjduUzsCHS5qQXJzWKA4ouj5y1 SxI+y2k8OSePhhuZ5ZCDMeMccIfDdesc3sOzjZhE= Message-ID: <1b577c26-5a59-4786-9c3a-d72847cc0c86@arm.com> Date: Thu, 21 May 2026 16:44:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v14 05/44] arm64: RMI: Add wrappers for RMI calls To: Marc Zyngier Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, Catalin Marinas , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve , WeiLin.Chang@arm.com, Lorenzo.Pieralisi2@arm.com References: <20260513131757.116630-1-steven.price@arm.com> <20260513131757.116630-6-steven.price@arm.com> <86cxypvsfy.wl-maz@kernel.org> From: Steven Price Content-Language: en-GB In-Reply-To: <86cxypvsfy.wl-maz@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260521_084503_213096_122F22FA X-CRM114-Status: GOOD ( 22.65 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 21/05/2026 13:49, Marc Zyngier wrote: > On Wed, 13 May 2026 14:17:13 +0100, > Steven Price wrote: >> >> The wrappers make the call sites easier to read and deal with the >> boiler plate of handling the error codes from the RMM. >> >> Signed-off-by: Steven Price >> --- >> Changes from v13: >> * Update to RMM v2.0-bet1 spec including some SRO support (there still >> some FIXMEs where SRO support is incomplete). >> Changes from v12: >> * Update to RMM v2.0 specification >> Changes from v8: >> * Switch from arm_smccc_1_2_smc() to arm_smccc_1_2_invoke() in >> rmi_rtt_read_entry() for consistency. >> Changes from v7: >> * Minor renaming of parameters and updated comments >> Changes from v5: >> * Further improve comments >> Changes from v4: >> * Improve comments >> Changes from v2: >> * Make output arguments optional. >> * Mask RIPAS value rmi_rtt_read_entry() >> * Drop unused rmi_rtt_get_phys() >> --- >> arch/arm64/include/asm/rmi_cmds.h | 661 ++++++++++++++++++++++++++++++ >> 1 file changed, 661 insertions(+) >> create mode 100644 arch/arm64/include/asm/rmi_cmds.h >> >> diff --git a/arch/arm64/include/asm/rmi_cmds.h b/arch/arm64/include/asm/rmi_cmds.h >> new file mode 100644 >> index 000000000000..04f7066894e9 >> --- /dev/null >> +++ b/arch/arm64/include/asm/rmi_cmds.h >> @@ -0,0 +1,661 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* >> + * Copyright (C) 2023 ARM Ltd. >> + */ >> + >> +#ifndef __ASM_RMI_CMDS_H >> +#define __ASM_RMI_CMDS_H >> + >> +#include >> + >> +#include >> + >> +struct rtt_entry { >> + unsigned long walk_level; >> + unsigned long desc; >> + int state; >> + int ripas; >> +}; >> + >> +#define RMI_MAX_ADDR_LIST 256 >> + >> +struct rmi_sro_state { >> + struct arm_smccc_1_2_regs regs; >> + unsigned long addr_count; >> + unsigned long addr_list[RMI_MAX_ADDR_LIST]; >> +}; >> + >> +#define rmi_smccc(...) do { \ >> + arm_smccc_1_1_invoke(__VA_ARGS__); \ >> +} while (RMI_RETURN_STATUS(res.a0) == RMI_BUSY || \ >> + RMI_RETURN_STATUS(res.a0) == RMI_BLOCKED) >> + >> +unsigned long rmi_sro_execute(struct rmi_sro_state *sro, gfp_t gfp); >> +void rmi_sro_free(struct rmi_sro_state *sro); >> + >> +/** >> + * rmi_rmm_config_set() - Configure the RMM >> + * @cfg_ptr: PA of a struct rmm_config >> + * >> + * Sets configuration options on the RMM. >> + * >> + * Return: RMI return code >> + */ >> +static inline int rmi_rmm_config_set(unsigned long cfg_ptr) >> +{ >> + struct arm_smccc_res res; >> + >> + arm_smccc_1_1_invoke(SMC_RMI_RMM_CONFIG_SET, cfg_ptr, &res); >> + >> + return res.a0; >> +} >> + >> +/** >> + * rmi_rmm_activate() - Activate the RMM >> + * >> + * Return: RMI return code >> + */ >> +static inline int rmi_rmm_activate(void) >> +{ >> + struct arm_smccc_res res; >> + >> + arm_smccc_1_1_invoke(SMC_RMI_RMM_ACTIVATE, &res); >> + >> + return res.a0; >> +} >> + >> +/** >> + * rmi_granule_tracking_get() - Get configuration of a Granule tracking region >> + * @start: Base PA of the tracking region >> + * @end: End of the PA region >> + * @out_category: Memory category >> + * @out_state: Tracking region state >> + * @out_top: Top of the memory region >> + * >> + * Return: RMI return code >> + */ >> +static inline int rmi_granule_tracking_get(unsigned long start, >> + unsigned long end, >> + unsigned long *out_category, >> + unsigned long *out_state, >> + unsigned long *out_top) >> +{ >> + struct arm_smccc_res res; >> + >> + arm_smccc_1_1_invoke(SMC_RMI_GRANULE_TRACKING_GET, start, end, &res); >> + >> + if (out_category) >> + *out_category = res.a1; >> + if (out_state) >> + *out_state = res.a2; >> + if (out_top) >> + *out_top = res.a3; >> + >> + return res.a0; >> +} >> + >> +/** >> + * rmi_gpt_l1_create() - Create a Level 1 GPT >> + * @addr: Base of physical address region described by the L1GPT >> + * >> + * Return: RMI return code >> + */ >> +static inline int rmi_gpt_l1_create(unsigned long addr) >> +{ >> + struct arm_smccc_res res; >> + >> + arm_smccc_1_1_invoke(SMC_RMI_GPT_L1_CREATE, addr, &res); >> + >> + if (RMI_RETURN_STATUS(res.a0) == RMI_INCOMPLETE) { >> + /* FIXME */ > > Is that part of the SRO stuff you're talking about in the notes? > What is the ETA for fixing all these FIXMEs? Yes, RMI_INCOMPLETE is the return for SRO. Fixing all this up is on the plan for my next posting which I expect to be after 7.2-rc1 (so July). There were some changes in the beta 2 spec and the RMM doesn't implement most of this yet so I didn't want to rush out completely untested code which might change. Thanks, Steve > Thanks, > > M. >