All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "Alexandre Ghiti" <alex@ghiti.fr>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Justin Stitt" <justinstitt@google.com>,
	linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
	linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org,
	llvm@lists.linux.dev, "Mark Rutland" <mark.rutland@arm.com>,
	"Bill Wendling" <morbo@google.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Will Deacon" <will@kernel.org>,
	linux-integrity@vger.kernel.org, patches@lists.linux.dev,
	"Piotr Król" <piotr.krol@3mdeb.com>,
	"Ross Philipson" <ross.philipson@gmail.com>
Subject: Re: [PATCH v3 09/11] arm64: drtm: Call UNPROTECT_MEMORY
Date: Wed, 2 Dec 2026 11:54:35 -0800	[thread overview]
Message-ID: <20261202115435.0000430c@oss.qualcomm.com> (raw)
In-Reply-To: <9-v3-22d1a1eb7d2e+17de-arm64_drtm_jgg@nvidia.com>

On Fri, 20 Nov 2026 13:52:02 -0400
Jason Gunthorpe <jgg@nvidia.com> wrote:

> The stub always requests ARM_DRTM_LAUNCH_DMA_COMPLETE. On a system
> with an SMMU the COMPLETE option is sanely implemented using the SMMU
> global abort register. DMA_COMPLETE should be mostly a no-op. It
> seems to be designed for the region protection mode that Linux does
> not use.
> 
> However, the FW can still do something interesting under it and we
> should call it. Choose late_initcall as we know the SMMU drivers are
> loaded by then. If some platform does actually block DMA beyond the
> SMMU, then this would result in a noisy failure of built-in driver
> DMA, not a silent security gap.
> 
> The platforms I'm aware of are OK with this placement, and it is a
> reasonable place to start.
> 
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

I didn't comment on 4-8. Whilst they look fine to me, they sit out of
my normal playground so I don't feel tagging would be appropriate.

Given the essay below on when this works and when it doesn't this seems
as good as it can be for now.

Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>

> ---
>  drivers/firmware/drtm/arm64.c | 39 +++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/drivers/firmware/drtm/arm64.c b/drivers/firmware/drtm/arm64.c
> index bf736ceb7f0368..07783d55275fd0 100644
> --- a/drivers/firmware/drtm/arm64.c
> +++ b/drivers/firmware/drtm/arm64.c
> @@ -3,8 +3,47 @@
>   *
>   * Support functions for ARM DEN 0113 "DRTM Architecture for Arm"
>   */
> +#include <linux/bug.h>
>  #include <linux/efi.h>
> +#include <linux/init.h>
> +#include <linux/printk.h>
>  
>  #include <asm/drtm.h>
>  
>  struct arm64_drtm_handoff drtm_handoff __efi_data_handoff;
> +
> +static int __init arm64_drtm_unprotect_memory(void)
> +{
> +	s64 status;
> +
> +	if (!drtm_handoff.drtm_enabled)
> +		return 0;
> +
> +	/*
> +	 * Currently Linux can only fully support a DRTM implementation that
> +	 * relies only on the SMMU. This should be called directly after
> +	 * attaching a driver to every SMMU but before binding any drivers that
> +	 * want to use devices attached to the SMMU. Our boot flow does not have
> +	 * a way to do that, so for now call it here.
> +	 *
> +	 * For SMMU based implementations their UNPROTECT_MEMORY is probably a
> +	 * NOP since touching the SMMU here is forbidden by spec, but they may
> +	 * still do something interesting so be sure to still call it.
> +	 *
> +	 * The stub excludes the most likely case of non-SMMU by only using
> +	 * ARM_DRTM_DMA_PROTECTION_COMPLETE, which is defined as:
> +	 *    Complete DMA protection is hardware-based enforcement at the SMMU
> +	 *    that blocks all DMA from Non- secure devices."
> +	 *
> +	 * For now if people have such systems they cannot include built-in
> +	 * drivers for any DMA devices, those have to be modules to be ordered
> +	 * after this.
> +	 */
> +	status = arm_drtm_unprotect_memory();
> +	WARN(status != ARM_DRTM_SUCCESS,
> +	     "DRTM: failed to unprotect memory (x0=%lld)", status);
> +	if (status == ARM_DRTM_SUCCESS)
> +		pr_info("DRTM: launch completed\n");
> +	return 0;
> +}
> +late_initcall_sync(arm64_drtm_unprotect_memory);


  reply	other threads:[~2026-12-02 19:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:51 [PATCH v3 00/11] arm64: DRTM, boot portion Jason Gunthorpe
2026-11-20 17:51 ` Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 01/11] efi/libstub: Add generic arch callbacks for DRTM Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 02/11] efi/libstub: Use free_addr/size as the arg to handle_kernel_image Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-12-02 19:41   ` Jonathan Cameron
2026-12-02 19:41     ` Jonathan Cameron
2026-11-20 17:51 ` [PATCH v3 03/11] efi/libstub: Have efi_kaslr_relocate_kernel() handle extra_size Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-11-20 23:33   ` Ard Biesheuvel
2026-11-20 23:33     ` Ard Biesheuvel
2026-11-22 14:41     ` Jason Gunthorpe
2026-11-22 14:41       ` Jason Gunthorpe
2026-12-02 19:48   ` Jonathan Cameron
2026-12-02 19:48     ` Jonathan Cameron
2026-11-20 17:51 ` [PATCH v3 04/11] efi: Add a __efi_data_handoff section annotation Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 05/11] efi/libstub: Put the stub's writable data in unique sections for DRTM Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 06/11] arm64: drtm: Add macro definitions for DEN0113 Jason Gunthorpe
2026-11-20 17:51   ` Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 07/11] arm64: drtm: Update the linker script for EFI_STUB_DRTM Jason Gunthorpe
2026-11-20 17:52   ` Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 08/11] arm64: drtm: Add drtm_entry point to head.S Jason Gunthorpe
2026-11-20 17:52   ` Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 09/11] arm64: drtm: Call UNPROTECT_MEMORY Jason Gunthorpe
2026-11-20 17:52   ` Jason Gunthorpe
2026-12-02 19:54   ` Jonathan Cameron [this message]
2026-11-20 17:52 ` [PATCH v3 10/11] efi/arm64: Add a way to detect if SMCC 1.1 can be used Jason Gunthorpe
2026-11-20 17:52   ` Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 11/11] efi/arm64: Implement ARM64 DRTM in the stub Jason Gunthorpe
2026-11-20 17:52   ` Jason Gunthorpe
2026-12-02 19:33 ` [PATCH v3 00/11] arm64: DRTM, boot portion Jason Gunthorpe
2026-12-02 19:33   ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202115435.0000430c@oss.qualcomm.com \
    --to=jonathan.cameron@oss.qualcomm.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jgg@nvidia.com \
    --cc=justinstitt@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=palmer@dabbelt.com \
    --cc=patches@lists.linux.dev \
    --cc=piotr.krol@3mdeb.com \
    --cc=pjw@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=ross.philipson@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.