From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Dan Williams <dan.j.williams@intel.com>, linux-coco@lists.linux.dev
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Lukas Wunner <lukas@wunner.de>, Samuel Ortiz <sameo@rivosinc.com>,
Alexey Kardashevskiy <aik@amd.com>,
Xu Yilun <yilun.xu@linux.intel.com>,
gregkh@linuxfoundation.org, linux-pci@vger.kernel.org,
aik@amd.com, lukas@wunner.de
Subject: Re: [PATCH v2 08/11] PCI/IDE: Add IDE establishment helpers
Date: Mon, 21 Apr 2025 11:43:58 +0530 [thread overview]
Message-ID: <yq5a7c3edot5.fsf@kernel.org> (raw)
In-Reply-To: <174107250147.1288555.16948528371146013276.stgit@dwillia2-xfh.jf.intel.com>
Dan Williams <dan.j.williams@intel.com> writes:
> There are two components to establishing an encrypted link, provisioning
> the stream in Partner Port config-space, and programming the keys into
> the link layer via IDE_KM (IDE Key Management). This new library,
> drivers/pci/ide.c, enables the former. IDE_KM, via a TSM low-level
> driver, is saved for later.
>
....
> +/**
> + * pci_ide_stream_setup() - program settings to Selective IDE Stream registers
> + * @pdev: PCIe device object for either a Root Port or Endpoint Partner Port
> + * @ide: registered IDE settings descriptor
> + *
> + * When @pdev is a PCI_EXP_TYPE_ENDPOINT then the PCI_IDE_EP partner
> + * settings are written to @pdev's Selective IDE Stream register block,
> + * and when @pdev is a PCI_EXP_TYPE_ROOT_PORT, the PCI_IDE_RP settings
> + * are selected.
> + */
> +void pci_ide_stream_setup(struct pci_dev *pdev, struct pci_ide *ide)
> +{
> + struct pci_ide_partner *settings = to_settings(pdev, ide);
> + int pos;
> + u32 val;
> +
> + if (!settings)
> + return;
> +
> + pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
> + pdev->nr_ide_mem);
>
This and the similar offset caclulation below needs the EXT_CAP_ID_IDE offset
modified drivers/pci/ide.c
@@ -10,11 +10,13 @@
#include <linux/bitfield.h>
#include "pci.h"
-static int sel_ide_offset(int nr_link_ide, int stream_index, int nr_ide_mem)
+static int sel_ide_offset(struct pci_dev *pdev, int nr_link_ide,
+ int stream_index, int nr_ide_mem)
{
int offset;
- offset = PCI_IDE_LINK_STREAM_0 + nr_link_ide * PCI_IDE_LINK_BLOCK_SIZE;
+ offset = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_IDE);
+ offset += PCI_IDE_LINK_STREAM_0 + nr_link_ide * PCI_IDE_LINK_BLOCK_SIZE;
/*
* Assume a constant number of address association resources per
@@ -66,7 +68,7 @@ void pci_ide_init(struct pci_dev *pdev)
nr_streams = min(1 + FIELD_GET(PCI_IDE_CAP_SEL_NUM_MASK, val),
CONFIG_PCI_IDE_STREAM_MAX);
for (int i = 0; i < nr_streams; i++) {
- int offset = sel_ide_offset(nr_link_ide, i, nr_ide_mem);
+ int offset = sel_ide_offset(pdev, nr_link_ide, i, nr_ide_mem);
int nr_assoc;
u32 val;
@@ -352,8 +354,7 @@ void pci_ide_stream_setup(struct pci_dev *pdev, struct pci_ide *ide)
if (!settings)
return;
-
- pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
+ pos = sel_ide_offset(pdev, pdev->nr_link_ide, settings->stream_index,
pdev->nr_ide_mem);
val = FIELD_PREP(PCI_IDE_SEL_RID_1_LIMIT_MASK, settings->rid_end);
@@ -381,7 +382,7 @@ void pci_ide_stream_teardown(struct pci_dev *pdev, struct pci_ide *ide)
if (!settings)
return;
- pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
+ pos = sel_ide_offset(pdev, pdev->nr_link_ide, settings->stream_index,
pdev->nr_ide_mem);
pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, 0);
@@ -406,7 +407,7 @@ void pci_ide_stream_enable(struct pci_dev *pdev, struct pci_ide *ide)
if (!settings)
return;
- pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
+ pos = sel_ide_offset(pdev, pdev->nr_link_ide, settings->stream_index,
pdev->nr_ide_mem);
val = FIELD_PREP(PCI_IDE_SEL_CTL_ID_MASK, ide->stream_id) |
@@ -434,7 +435,7 @@ void pci_ide_stream_disable(struct pci_dev *pdev, struct pci_ide *ide)
if (!settings)
return;
- pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
+ pos = sel_ide_offset(pdev, pdev->nr_link_ide, settings->stream_index,
pdev->nr_ide_mem);
pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, 0);
> +
> + val = FIELD_PREP(PCI_IDE_SEL_RID_1_LIMIT_MASK, settings->rid_end);
> + pci_write_config_dword(pdev, pos + PCI_IDE_SEL_RID_1, val);
> +
> + val = PREP_PCI_IDE_SEL_RID_2(settings->rid_start, ide_domain(pdev));
> + pci_write_config_dword(pdev, pos + PCI_IDE_SEL_RID_2, val);
> +}
> +EXPORT_SYMBOL_GPL(pci_ide_stream_setup);
> +
>
....
> +/**
> + * pci_ide_stream_enable() - after setup, enable the stream
> + * @pdev: PCIe device object for either a Root Port or Endpoint Partner Port
> + * @ide: registered and setup IDE settings descriptor
> + *
> + * Activate the stream by writing to the Selective IDE Stream Control Register.
> + */
> +void pci_ide_stream_enable(struct pci_dev *pdev, struct pci_ide *ide)
> +{
> + struct pci_ide_partner *settings = to_settings(pdev, ide);
> + int pos;
> + u32 val;
> +
> + if (!settings)
> + return;
> +
> + pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
> + pdev->nr_ide_mem);
> +
>
> + val = FIELD_PREP(PCI_IDE_SEL_CTL_ID_MASK, ide->stream_id) |
> + FIELD_PREP(PCI_IDE_SEL_CTL_DEFAULT, 1) |
> + FIELD_PREP(PCI_IDE_SEL_CTL_CFG_EN, pdev->ide_cfg) |
> + FIELD_PREP(PCI_IDE_SEL_CTL_TEE_LIMITED, pdev->ide_tee_limit) |
>
Does enabling pdev->ide_tee_limit here will prevent a device from operating
as expected before we get to TDISP RUN state?
TEE-Limited Stream – When Set, requires that, for Requests, only those that have the T bit Set are
permitted to be associated with this Stream
> + FIELD_PREP(PCI_IDE_SEL_CTL_EN, 1);
> + pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, val);
> +}
> +EXPORT_SYMBOL_GPL(pci_ide_stream_enable);
> +
> +/**
> + * pci_ide_stream_disable() - disable the given stream
> + * @pdev: PCIe device object for either a Root Port or Endpoint Partner Port
> + * @ide: registered and setup IDE settings descriptor
> + *
> + * Clear the Selective IDE Stream Control Register, but leave all other
> + * registers untouched.
> + */
> +void pci_ide_stream_disable(struct pci_dev *pdev, struct pci_ide *ide)
> +{
> + struct pci_ide_partner *settings = to_settings(pdev, ide);
> + int pos;
> +
> + if (!settings)
> + return;
> +
> + pos = sel_ide_offset(pdev->nr_link_ide, settings->stream_index,
> + pdev->nr_ide_mem);
>
here
> +
> + pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, 0);
> +}
> +EXPORT_SYMBOL_GPL(pci_ide_stream_disable);
-aneesh
next prev parent reply other threads:[~2025-04-21 6:20 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 7:14 [PATCH v2 00/11] PCI/TSM: Core infrastructure for PCI device security (TDISP) Dan Williams
2025-03-04 7:14 ` [PATCH v2 01/11] configfs-tsm: Namespace TSM report symbols Dan Williams
2025-03-05 10:11 ` Steven Price
2025-03-10 16:26 ` Sathyanarayanan Kuppuswamy
2025-03-10 22:19 ` Huang, Kai
2025-03-04 7:14 ` [PATCH v2 02/11] coco/guest: Move shared guest CC infrastructure to drivers/virt/coco/guest/ Dan Williams
2025-03-10 16:26 ` Sathyanarayanan Kuppuswamy
2025-03-10 22:57 ` Huang, Kai
2025-04-18 23:28 ` Dan Williams
2025-03-04 7:14 ` [PATCH v2 03/11] coco/tsm: Introduce a core device for TEE Security Managers Dan Williams
2025-03-04 7:14 ` [PATCH v2 04/11] PCI/IDE: Enumerate Selective Stream IDE capabilities Dan Williams
2025-03-11 5:46 ` Aneesh Kumar K.V
2025-03-11 6:33 ` Alexey Kardashevskiy
2025-04-25 21:03 ` Dan Williams
2025-03-04 7:14 ` [PATCH v2 05/11] PCI/TSM: Authenticate devices via platform TSM Dan Williams
2025-04-16 5:33 ` Aneesh Kumar K.V
2025-04-25 22:51 ` Dan Williams
2025-03-04 7:14 ` [PATCH v2 06/11] samples/devsec: Introduce a PCI device-security bus + endpoint sample Dan Williams
2025-03-11 14:17 ` [PATCH v2 06/11] samples/devsec: Introduce a PCI device-security Suzuki K Poulose
2025-03-11 14:45 ` [RESEND RFC PATCH 1/3] pci: ide: Fix build failure Suzuki K Poulose
2025-03-11 14:46 ` [RESEND RFC PATCH 2/3] pci: generic-domains: Add helpers to alloc/free dynamic bus numbers Suzuki K Poulose
2025-03-11 14:46 ` [RESEND RFC PATCH 3/3] samples: devsec: Add support for PCI_DOMAINS_GENERIC Suzuki K Poulose
2025-04-20 18:29 ` Dan Williams
2025-04-22 15:45 ` Suzuki K Poulose
2025-04-24 12:39 ` [tip: irq/urgent] irqchip/gic-v2m: Prevent use after free of gicv2m_get_fwnode() tip-bot2 for Suzuki K Poulose
2025-04-24 13:01 ` tip-bot2 for Suzuki K Poulose
2025-05-13 10:18 ` [PATCH v2 06/11] samples/devsec: Introduce a PCI device-security bus + endpoint sample Zhi Wang
2025-03-04 7:14 ` [PATCH v2 07/11] PCI: Add PCIe Device 3 Extended Capability enumeration Dan Williams
2025-03-04 7:15 ` [PATCH v2 08/11] PCI/IDE: Add IDE establishment helpers Dan Williams
2025-03-04 20:44 ` kernel test robot
2025-03-05 12:32 ` kernel test robot
2025-03-11 10:51 ` Suzuki K Poulose
2025-04-19 17:50 ` Dan Williams
2025-03-18 3:18 ` Alexey Kardashevskiy
2025-04-25 21:42 ` Dan Williams
2025-04-21 6:13 ` Aneesh Kumar K.V [this message]
2025-04-25 16:29 ` Xu Yilun
2025-04-25 23:31 ` Dan Williams
2025-04-27 9:33 ` Aneesh Kumar K.V
2025-03-04 7:15 ` [PATCH v2 09/11] PCI/IDE: Report available IDE streams Dan Williams
2025-03-04 13:49 ` kernel test robot
2025-03-04 16:54 ` Dionna Amalie Glaze
2025-04-25 20:42 ` Dan Williams
2025-03-04 7:15 ` [PATCH v2 10/11] PCI/TSM: Report active " Dan Williams
2025-03-04 7:15 ` [PATCH v2 11/11] samples/devsec: Add sample IDE establishment Dan Williams
2025-05-07 10:47 ` [PATCH v2 00/11] PCI/TSM: Core infrastructure for PCI device security (TDISP) Zhi Wang
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=yq5a7c3edot5.fsf@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=aik@amd.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=sameo@rivosinc.com \
--cc=yilun.xu@linux.intel.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 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.