lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <a38e51d5-d1dd-b0cc-e02e-a531b0d1d50b@amd.com>
Date:   Mon, 24 Jul 2023 12:14:26 +0200
From:   Michal Simek <michal.simek@....com>
To:     Sai Krishna Potthuri <sai.krishna.potthuri@....com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>,
        Mathieu Poirier <mathieu.poirier@...aro.org>,
        Tanmay Shah <tanmay.shah@....com>,
        Ben Levinsky <ben.levinsky@....com>,
        Marek Vasut <marex@...x.de>,
        Roman Gushchin <roman.gushchin@...ux.dev>,
        Arnd Bergmann <arnd@...db.de>
Cc:     linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        linux-gpio@...r.kernel.org, devicetree@...r.kernel.org,
        saikrishna12468@...il.com, git@....com
Subject: Re: [PATCH v2 1/4] firmware: xilinx: Add support to get platform
 information



On 7/24/23 10:45, Sai Krishna Potthuri wrote:
> From: Dhaval Shah <dhaval.r.shah@....com>
> 
> Add function to get family code and sub family code from the idcode. This
> family code and sub family code helps to identify the platform.
> Family code of any platform is on bits 21 to 27 and Sub family code is on
> bits 19 and 20.
> 
> Signed-off-by: Dhaval Shah <dhaval.r.shah@....com>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@....com>
> ---
>   drivers/firmware/xilinx/zynqmp.c     | 42 ++++++++++++++++++++++++++++
>   include/linux/firmware/xlnx-zynqmp.h | 13 +++++++++
>   2 files changed, 55 insertions(+)
> 
> diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c
> index a736db4a5825..f9498e7ea694 100644
> --- a/drivers/firmware/xilinx/zynqmp.c
> +++ b/drivers/firmware/xilinx/zynqmp.c
> @@ -339,6 +339,8 @@ int zynqmp_pm_invoke_fn(u32 pm_api_id, u32 arg0, u32 arg1,
>   
>   static u32 pm_api_version;
>   static u32 pm_tz_version;
> +static u32 pm_family_code;
> +static u32 pm_sub_family_code;
>   
>   int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset)
>   {
> @@ -404,6 +406,41 @@ int zynqmp_pm_get_chipid(u32 *idcode, u32 *version)
>   }
>   EXPORT_SYMBOL_GPL(zynqmp_pm_get_chipid);
>   
> +/**
> + * zynqmp_pm_get_family_info() - Get family info of platform
> + * @family:	Returned family code value
> + * @subfamily:	Returned sub-family code value
> + *
> + * Return: Returns status, either success or error+reason
> + */
> +static int zynqmp_pm_get_family_info(u32 *family, u32 *subfamily)
> +{
> +	u32 ret_payload[PAYLOAD_ARG_CNT];
> +	u32 idcode;
> +	int ret;
> +
> +	/* Check is family or sub-family code already received */
> +	if (pm_family_code && pm_sub_family_code) {
> +		*family = pm_family_code;
> +		*subfamily = pm_sub_family_code;
> +		return 0;
> +	}
> +
> +	ret = zynqmp_pm_invoke_fn(PM_GET_CHIPID, 0, 0, 0, 0, ret_payload);
> +	if (ret < 0)
> +		return ret;
> +
> +	idcode = ret_payload[1];
> +	pm_family_code = FIELD_GET(GENMASK(FAMILY_CODE_MSB, FAMILY_CODE_LSB),
> +				   idcode);
> +	pm_sub_family_code = FIELD_GET(GENMASK(SUB_FAMILY_CODE_MSB,
> +					       SUB_FAMILY_CODE_LSB), idcode);
> +	*family = pm_family_code;
> +	*subfamily = pm_sub_family_code;
> +
> +	return 0;
> +}
> +
>   /**
>    * zynqmp_pm_get_trustzone_version() - Get secure trustzone firmware version
>    * @version:	Returned version value
> @@ -1911,6 +1948,11 @@ static int zynqmp_firmware_probe(struct platform_device *pdev)
>   	pr_info("%s Platform Management API v%d.%d\n", __func__,
>   		pm_api_version >> 16, pm_api_version & 0xFFFF);
>   
> +	/* Get the Family code and sub family code of platform */
> +	ret = zynqmp_pm_get_family_info(&pm_family_code, &pm_sub_family_code);
> +	if (ret < 0)
> +		return ret;
> +
>   	/* Check trustzone version number */
>   	ret = zynqmp_pm_get_trustzone_version(&pm_tz_version);
>   	if (ret)
> diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h
> index f5da51677069..d7f94b42ad4c 100644
> --- a/include/linux/firmware/xlnx-zynqmp.h
> +++ b/include/linux/firmware/xlnx-zynqmp.h
> @@ -34,6 +34,19 @@
>   /* PM API versions */
>   #define PM_API_VERSION_2	2
>   
> +#define ZYNQMP_FAMILY_CODE 0x23
> +#define VERSAL_FAMILY_CODE 0x26
> +
> +/* When all subfamily of platform need to support */
> +#define ALL_SUB_FAMILY_CODE		0x00
> +#define VERSAL_SUB_FAMILY_CODE		0x01
> +#define VERSALNET_SUB_FAMILY_CODE	0x03
> +
> +#define FAMILY_CODE_LSB	21
> +#define FAMILY_CODE_MSB	27
> +#define SUB_FAMILY_CODE_LSB	19
> +#define SUB_FAMILY_CODE_MSB	20

nit: It was likely easier to do it like below. You can avoid so many defines.

#define FAMILY_CODE_MASK	GENMASK(27, 21)
#define SUB_FAMILY_CODE_MASK	GENMASK(20, 19)


> +
>   /* ATF only commands */
>   #define TF_A_PM_REGISTER_SGI		0xa04
>   #define PM_GET_TRUSTZONE_VERSION	0xa03

Reviewed-by: Michal Simek <michal.simek@....com>

Thanks,
Michal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ