[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250730152613.00006693@huawei.com>
Date: Wed, 30 Jul 2025 15:26:13 +0100
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@...nel.org>
CC: <linux-coco@...ts.linux.dev>, <kvmarm@...ts.linux.dev>,
<linux-pci@...r.kernel.org>, <linux-kernel@...r.kernel.org>, <aik@....com>,
<lukas@...ner.de>, Samuel Ortiz <sameo@...osinc.com>, Xu Yilun
<yilun.xu@...ux.intel.com>, Jason Gunthorpe <jgg@...pe.ca>, "Suzuki K
Poulose" <Suzuki.Poulose@....com>, Steven Price <steven.price@....com>,
Catalin Marinas <catalin.marinas@....com>, Marc Zyngier <maz@...nel.org>,
Will Deacon <will@...nel.org>, Oliver Upton <oliver.upton@...ux.dev>
Subject: Re: [RFC PATCH v1 24/38] arm64: CCA: Register guest tsm callback
On Mon, 28 Jul 2025 19:22:01 +0530
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@...nel.org> wrote:
> Register the TSM callback if the DA feature is supported by RSI.
>
> Additionally, adjust the build order so that the TSM class is created
> before the arm-cca-guest driver initialization.
>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@...nel.org>
See below.
> diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
> index bf9ea99e2aa1..ef06c083990a 100644
> --- a/arch/arm64/kernel/rsi.c
> +++ b/arch/arm64/kernel/rsi.c
> @@ -15,6 +15,7 @@
> #include <asm/rsi.h>
>
> static struct realm_config config;
> +static unsigned long rsi_feat_reg0;
>
> unsigned long prot_ns_shared;
> EXPORT_SYMBOL(prot_ns_shared);
> @@ -22,6 +23,12 @@ EXPORT_SYMBOL(prot_ns_shared);
> DEFINE_STATIC_KEY_FALSE_RO(rsi_present);
> EXPORT_SYMBOL(rsi_present);
>
> +bool rsi_has_da_feature(void)
> +{
> + return !!u64_get_bits(rsi_feat_reg0, RSI_FEATURE_REGISTER_0_DA);
!! not needed.
> +}
> +EXPORT_SYMBOL_GPL(rsi_has_da_feature);
> diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca.c b/drivers/virt/coco/arm-cca-guest/arm-cca.c
> index 547fc2c79f7d..3adbbd67e06e 100644
> --- a/drivers/virt/coco/arm-cca-guest/arm-cca.c
> +++ b/drivers/virt/coco/arm-cca-guest/arm-cca.c
> @@ -1,6 +1,6 @@
> static int cca_guest_probe(struct platform_device *pdev)
> {
> int ret;
> @@ -200,11 +256,22 @@ static int cca_guest_probe(struct platform_device *pdev)
> return -ENODEV;
>
> ret = tsm_report_register(&arm_cca_tsm_report_ops, NULL);
> - if (ret < 0)
> + if (ret < 0) {
> pr_err("Error %d registering with TSM\n", ret);
> + goto err_out;
> + }
>
> ret = devm_add_action_or_reset(&pdev->dev, unregister_cca_tsm_report, NULL);
> + if (ret < 0) {
> + pr_err("Error %d registering devm action\n", ret);
> + unregister_cca_tsm_report(NULL);
> + goto err_out;
> + }
> +
> + if (rsi_has_da_feature())
> + ret = cca_tsm_register(pdev);
Why do we not need to call unregister_cca_tsm_report()
if this fails?
>
> +err_out:
I'd just return above.
> return ret;
> }
>
> diff --git a/drivers/virt/coco/arm-cca-guest/rsi-da.h b/drivers/virt/coco/arm-cca-guest/rsi-da.h
> new file mode 100644
> index 000000000000..8a4d5f1b0263
> --- /dev/null
> +++ b/drivers/virt/coco/arm-cca-guest/rsi-da.h
> @@ -0,0 +1,27 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (C) 2025 ARM Ltd.
> + */
> +
> +#ifndef RSI_DA_H_
> +#define RSI_DA_H_
> +
> +#include <linux/pci.h>
> +#include <linux/pci-tsm.h>
> +#include <asm/rsi_smc.h>
> +
One blank line probably enough.
> +
> +struct cca_guest_dsc {
> + struct pci_tsm_pf0 pci;
> +};
> +
> +static inline struct cca_guest_dsc *to_cca_guest_dsc(struct pci_dev *pdev)
> +{
> + struct pci_tsm *tsm = pdev->tsm;
> +
> + if (!tsm)
> + return NULL;
> + return container_of(tsm, struct cca_guest_dsc, pci.tsm);
> +}
> +
> +#endif
Powered by blists - more mailing lists