Netdev List
 help / color / mirror / Atom feed
From: "Daniel Zahka" <daniel.zahka@gmail.com>
To: "Stan Iliev" <stani@google.com>,
	"Tony Nguyen" <anthony.l.nguyen@intel.com>,
	"Przemek Kitszel" <przemyslaw.kitszel@intel.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	<intel-wired-lan@lists.osuosl.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"David Decotigny" <decot@google.com>,
	"Madhu Chittim" <madhu.chittim@intel.com>,
	"Emil Tantilov" <emil.s.tantilov@intel.com>,
	"Sridhar Samudrala" <sridhar.samudrala@intel.com>,
	"Brian Vazquez" <brianvv@google.com>, "Li Li" <boolli@google.com>,
	"Alexander Lobakin" <aleksander.lobakin@intel.com>,
	"Daniel Zahka" <daniel.zahka@gmail.com>,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
	"Kees Cook" <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH iwl-next 08/15] idpf: psp: add support for psp rx key allocation
Date: Tue, 17 Nov 2026 15:57:17 -0500	[thread overview]
Message-ID: <DMXSBWB0425F.1NVVQK5JZ4IIW@gmail.com> (raw)
In-Reply-To: <20261117145522.1910636-9-stani@google.com>

On Tue Nov 17, 2026 at 9:55 AM EST, Stan Iliev wrote:
> Add support for allocating PSP RX keys on demand:
> - Introduce VIRTCHNL2_OP_PSP_ALLOCATE_KEYS (560),
>   enum virtchnl2_psp_allocate_response_flags,
>   struct virtchnl2_psp_allocate_keys_request/_response and
>   struct virtchnl2_allocate_psp_key_v0/_v1.
> - Implement idpf_send_allocate_psp_key(), which allocates one V0 RX
>   key with a synchronous request, validates the reply (key type,
>   keys_size_bytes, length, and an SPI with a key ID, which the PSP core
>   requires) and wipes the key from the mailbox buffer. The key, its SPI
>   and its master key generation are returned in struct idpf_psp_rx_key.
> - Implement the rx_spi_alloc PSP device op. It gets the adapter from
>   the netdev of the PSP device, as the vports can be freed while the
>   PSP device is registered.
> - Keep a copy of the vport ID in adapter->psp.vport_id, for the same
>   reason.
> - Wipe the RX keys of late replies, which libie passes to
>   idpf_recv_event_msg() after the request timed out.
>
> Signed-off-by: Stan Iliev <stani@google.com>
> ---

[...]

> +int idpf_send_allocate_psp_key(struct idpf_adapter *adapter,
> +			       struct idpf_psp_rx_key *key)
> +{
> +	struct libie_ctlq_xn_send_params xn_params = {
> +		.chnl_opcode	= VIRTCHNL2_OP_PSP_ALLOCATE_KEYS,
> +		.timeout_ms	= IDPF_VC_XN_DEFAULT_TIMEOUT_MSEC,
> +	};
> +	const struct virtchnl2_psp_allocate_keys_response *vc_reply;
> +	struct virtchnl2_psp_allocate_keys_request key_req = { };
> +	const struct virtchnl2_allocate_psp_key_v0 *v0_key;
> +	size_t reply_sz;
> +	u32 spi;
> +	int err;
> +
> +	BUILD_BUG_ON(sizeof(key->key) != sizeof(v0_key->v0_key));
> +
> +	key_req.vport_id = cpu_to_le32(READ_ONCE(adapter->psp.vport_id));
> +	key_req.num_keys = cpu_to_le32(1);
> +	key_req.key_type = VIRTCHNL2_PSP_KEY_TYPE_V0;
> +	/* key_req.domain stays zeroed: VIRTCHNL2_PSP_DOMAIN_NONE */
> +
> +	err = idpf_send_mb_msg_stack(adapter, &xn_params, &key_req);
> +	if (err)
> +		return err;
> +
> +	reply_sz = xn_params.recv_mem.iov_len;
> +	vc_reply = xn_params.recv_mem.iov_base;
> +	if (reply_sz < sizeof(*vc_reply) + sizeof(*v0_key) ||
> +	    vc_reply->key_type != VIRTCHNL2_PSP_KEY_TYPE_V0 ||
> +	    le32_to_cpu(vc_reply->keys_size_bytes) != sizeof(*v0_key)) {
> +		net_warn_ratelimited("%s: invalid reply of %zu bytes\n",
> +				     __func__, reply_sz);
> +		err = -EIO;
> +		goto release_rx;
> +	}
> +
> +	v0_key = (const struct virtchnl2_allocate_psp_key_v0 *)vc_reply->keys;
> +	spi = le32_to_cpu(v0_key->spi);
> +	if (!(spi & PSP_SPI_KEY_ID)) {
> +		net_warn_ratelimited("%s: invalid SPI %#x\n", __func__, spi);
> +		err = -EIO;

nit: seems a bit defensive not to trust the fw to provide a valid SPI.
No issues with keeping it around though. 

> +		goto release_rx;
> +	}
> +
> +	key->spi = cpu_to_be32(spi);
> +	key->generation = le32_to_cpu(vc_reply->master_key_generation);
> +	memcpy(key->key, v0_key->v0_key, sizeof(key->key));
> +	atomic_inc(&adapter->psp.keys_allocated);
> +
> +release_rx:
> +	/* Don't leave the RX key in the recycled mailbox buffer */
> +	memzero_explicit(xn_params.recv_mem.iov_base, reply_sz);
> +	libie_ctlq_release_rx_buf(&xn_params.recv_mem);
> +	return err;
> +}
> +

  reply	other threads:[~2026-11-17 20:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:55 [PATCH iwl-next 00/15] idpf: add PSP offload support, part 1 Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 01/15] libie: wipe copied small send buffers on release Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 02/15] idpf: wipe mailbox " Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 03/15] idpf: make the mailbox workqueue visible in sysfs Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 04/15] idpf: psp: add psp offload initialization Stan Iliev
2026-11-17 17:34   ` Daniel Zahka
2026-11-17 14:55 ` [PATCH iwl-next 05/15] idpf: psp: add support for crypto capabilities Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 06/15] idpf: psp: add support for psp capabilities Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 07/15] idpf: psp: add support for fips compliance status Stan Iliev
2026-11-17 20:40   ` Daniel Zahka
2026-11-17 14:55 ` [PATCH iwl-next 08/15] idpf: psp: add support for psp rx key allocation Stan Iliev
2026-11-17 20:57   ` Daniel Zahka [this message]
2026-11-17 14:55 ` [PATCH iwl-next 09/15] idpf: psp: add support for psp key rotation Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 10/15] idpf: psp: add support for psp statistics Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 11/15] idpf: psp: add psp tx key state Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 12/15] idpf: psp: add support for psp tx key deletion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 13/15] idpf: psp: add psp work and tx key insertion completion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 14/15] idpf: psp: add support for psp tx key insertion Stan Iliev
2026-11-17 14:55 ` [PATCH iwl-next 15/15] idpf: psp: add psp tx key registration Stan Iliev

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=DMXSBWB0425F.1NVVQK5JZ4IIW@gmail.com \
    --to=daniel.zahka@gmail.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=boolli@google.com \
    --cc=brianvv@google.com \
    --cc=davem@davemloft.net \
    --cc=decot@google.com \
    --cc=edumazet@kernel.org \
    --cc=emil.s.tantilov@intel.com \
    --cc=gustavoars@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madhu.chittim@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sridhar.samudrala@intel.com \
    --cc=stani@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox