linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records
@ 2023-03-20 21:20 Kuppuswamy Sathyanarayanan
  2023-03-22 18:31 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2023-03-20 21:20 UTC (permalink / raw)
  To: Rafael J Wysocki
  Cc: Len Brown, linux-acpi, linux-kernel, Kuppuswamy Sathyanarayanan

The Confidential Computing Event Log (CCEL) table provides the address
and length of the CCEL records area in UEFI reserved memory. To access
these records, userspace can use /dev/mem to retrieve them. But
'/dev/mem' is not enabled on many systems for security reasons.

So to allow user space access these event log records without the
/dev/mem interface, add support to access it via sysfs interface. The
ACPI driver has provided read only access to BERT records area via
'/sys/firmware/acpi/tables/data/BERT' in sysfs. So follow the same way,
and add support for /sys/firmware/acpi/tables/data/CCEL to enable
read-only access to the CCEL recorids area.

More details about the CCEL table can be found in ACPI specification
r6.5, sec titled "CC Event Log ACPI Table".

Original-patch-by: Haibo Xu <haibo1.xu@intel.com>
[Original patch is for TDEL table, modified it for CCEL support]
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---

Changes since v1:
 * Removed unnecessary parenthesis as per Rafael's suggestion..

 drivers/acpi/sysfs.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index 7f4ff56c9d42..687524b50085 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -458,11 +458,28 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
 	return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
 }
 
+static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
+{
+	struct acpi_table_ccel *ccel = th;
+
+	if (ccel->header.length < sizeof(struct acpi_table_ccel) ||
+	    !ccel->log_area_start_address || !ccel->log_area_minimum_length) {
+		kfree(data_attr);
+		return -EINVAL;
+	}
+	data_attr->addr = ccel->log_area_start_address;
+	data_attr->attr.size = ccel->log_area_minimum_length;
+	data_attr->attr.attr.name = "CCEL";
+
+	return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
+}
+
 static struct acpi_data_obj {
 	char *name;
 	int (*fn)(void *, struct acpi_data_attr *);
 } acpi_data_objs[] = {
 	{ ACPI_SIG_BERT, acpi_bert_data_init },
+	{ ACPI_SIG_CCEL, acpi_ccel_data_init },
 };
 
 #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records
  2023-03-20 21:20 [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records Kuppuswamy Sathyanarayanan
@ 2023-03-22 18:31 ` Rafael J. Wysocki
  2023-03-22 19:00   ` Sathyanarayanan Kuppuswamy
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-03-22 18:31 UTC (permalink / raw)
  To: Kuppuswamy Sathyanarayanan
  Cc: Rafael J Wysocki, Len Brown, linux-acpi, linux-kernel

On Mon, Mar 20, 2023 at 10:21 PM Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>
> The Confidential Computing Event Log (CCEL) table provides the address
> and length of the CCEL records area in UEFI reserved memory.

The rest of this paragraph can be omitted.

> To access
> these records, userspace can use /dev/mem to retrieve them. But
> '/dev/mem' is not enabled on many systems for security reasons.
>
> So to allow user space access these event log records without the
> /dev/mem interface, add support to access it via sysfs interface. The
> ACPI driver has provided read only access to BERT records area via
> '/sys/firmware/acpi/tables/data/BERT' in sysfs. So follow the same way,
> and add support for /sys/firmware/acpi/tables/data/CCEL to enable
> read-only access to the CCEL recorids area.
>
> More details about the CCEL table can be found in ACPI specification
> r6.5, sec titled "CC Event Log ACPI Table".

Please provide a proper section number here and a Link: tag pointing
to the relevant section of the spec (which is
https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table
I think).

> Original-patch-by: Haibo Xu <haibo1.xu@intel.com>

If the original patch has been signed-off by that developer, you can
use a Co-developed-by: along with the original S-o-b tag here.

> [Original patch is for TDEL table, modified it for CCEL support]
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> ---
>
> Changes since v1:
>  * Removed unnecessary parenthesis as per Rafael's suggestion..
>
>  drivers/acpi/sysfs.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> index 7f4ff56c9d42..687524b50085 100644
> --- a/drivers/acpi/sysfs.c
> +++ b/drivers/acpi/sysfs.c
> @@ -458,11 +458,28 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
>         return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
>  }
>
> +static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
> +{
> +       struct acpi_table_ccel *ccel = th;
> +
> +       if (ccel->header.length < sizeof(struct acpi_table_ccel) ||
> +           !ccel->log_area_start_address || !ccel->log_area_minimum_length) {
> +               kfree(data_attr);
> +               return -EINVAL;
> +       }
> +       data_attr->addr = ccel->log_area_start_address;
> +       data_attr->attr.size = ccel->log_area_minimum_length;
> +       data_attr->attr.attr.name = "CCEL";
> +
> +       return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
> +}
> +
>  static struct acpi_data_obj {
>         char *name;
>         int (*fn)(void *, struct acpi_data_attr *);
>  } acpi_data_objs[] = {
>         { ACPI_SIG_BERT, acpi_bert_data_init },
> +       { ACPI_SIG_CCEL, acpi_ccel_data_init },
>  };
>
>  #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records
  2023-03-22 18:31 ` Rafael J. Wysocki
@ 2023-03-22 19:00   ` Sathyanarayanan Kuppuswamy
  2023-03-22 19:06     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Sathyanarayanan Kuppuswamy @ 2023-03-22 19:00 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Rafael J Wysocki, Len Brown, linux-acpi, linux-kernel

Hi Rafael,

On 3/22/23 11:31 AM, Rafael J. Wysocki wrote:
> On Mon, Mar 20, 2023 at 10:21 PM Kuppuswamy Sathyanarayanan
> <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>>
>> The Confidential Computing Event Log (CCEL) table provides the address
>> and length of the CCEL records area in UEFI reserved memory.
> 
> The rest of this paragraph can be omitted.
> 
>> To access
>> these records, userspace can use /dev/mem to retrieve them. But
>> '/dev/mem' is not enabled on many systems for security reasons.
>>
>> So to allow user space access these event log records without the
>> /dev/mem interface, add support to access it via sysfs interface. The
>> ACPI driver has provided read only access to BERT records area via
>> '/sys/firmware/acpi/tables/data/BERT' in sysfs. So follow the same way,
>> and add support for /sys/firmware/acpi/tables/data/CCEL to enable
>> read-only access to the CCEL recorids area.
>>
>> More details about the CCEL table can be found in ACPI specification
>> r6.5, sec titled "CC Event Log ACPI Table".
> 
> Please provide a proper section number here and a Link: tag pointing
> to the relevant section of the spec (which is
> https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table
> I think).
> 
>> Original-patch-by: Haibo Xu <haibo1.xu@intel.com>
> 
> If the original patch has been signed-off by that developer, you can
> use a Co-developed-by: along with the original S-o-b tag here.
> 
>> [Original patch is for TDEL table, modified it for CCEL support]
>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>> ---
>>

How about the following version?

ACPI: sysfs: Enable ACPI sysfs support for CCEL records

The Confidential Computing Event Log (CCEL) table provides the address
and length of the CCEL records area in UEFI reserved memory.

To allow user space access to these records, expose a sysfs interface
similar to the BERT table.

More details about the CCEL table can be found in the ACPI specification
r6.5 [1], sec 5.2.34.

Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table # [1]
Co-developed-by: Haibo Xu <haibo1.xu@intel.com>
Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>



>> Changes since v1:
>>  * Removed unnecessary parenthesis as per Rafael's suggestion..
>>
>>  drivers/acpi/sysfs.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
>> index 7f4ff56c9d42..687524b50085 100644
>> --- a/drivers/acpi/sysfs.c
>> +++ b/drivers/acpi/sysfs.c
>> @@ -458,11 +458,28 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
>>         return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
>>  }
>>
>> +static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
>> +{
>> +       struct acpi_table_ccel *ccel = th;
>> +
>> +       if (ccel->header.length < sizeof(struct acpi_table_ccel) ||
>> +           !ccel->log_area_start_address || !ccel->log_area_minimum_length) {
>> +               kfree(data_attr);
>> +               return -EINVAL;
>> +       }
>> +       data_attr->addr = ccel->log_area_start_address;
>> +       data_attr->attr.size = ccel->log_area_minimum_length;
>> +       data_attr->attr.attr.name = "CCEL";
>> +
>> +       return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
>> +}
>> +
>>  static struct acpi_data_obj {
>>         char *name;
>>         int (*fn)(void *, struct acpi_data_attr *);
>>  } acpi_data_objs[] = {
>>         { ACPI_SIG_BERT, acpi_bert_data_init },
>> +       { ACPI_SIG_CCEL, acpi_ccel_data_init },
>>  };
>>
>>  #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)
>> --
>> 2.34.1
>>

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records
  2023-03-22 19:00   ` Sathyanarayanan Kuppuswamy
@ 2023-03-22 19:06     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2023-03-22 19:06 UTC (permalink / raw)
  To: Sathyanarayanan Kuppuswamy
  Cc: Rafael J. Wysocki, Rafael J Wysocki, Len Brown, linux-acpi, linux-kernel

On Wed, Mar 22, 2023 at 8:00 PM Sathyanarayanan Kuppuswamy
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>
> Hi Rafael,
>
> On 3/22/23 11:31 AM, Rafael J. Wysocki wrote:
> > On Mon, Mar 20, 2023 at 10:21 PM Kuppuswamy Sathyanarayanan
> > <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
> >>
> >> The Confidential Computing Event Log (CCEL) table provides the address
> >> and length of the CCEL records area in UEFI reserved memory.
> >
> > The rest of this paragraph can be omitted.
> >
> >> To access
> >> these records, userspace can use /dev/mem to retrieve them. But
> >> '/dev/mem' is not enabled on many systems for security reasons.
> >>
> >> So to allow user space access these event log records without the
> >> /dev/mem interface, add support to access it via sysfs interface. The
> >> ACPI driver has provided read only access to BERT records area via
> >> '/sys/firmware/acpi/tables/data/BERT' in sysfs. So follow the same way,
> >> and add support for /sys/firmware/acpi/tables/data/CCEL to enable
> >> read-only access to the CCEL recorids area.
> >>
> >> More details about the CCEL table can be found in ACPI specification
> >> r6.5, sec titled "CC Event Log ACPI Table".
> >
> > Please provide a proper section number here and a Link: tag pointing
> > to the relevant section of the spec (which is
> > https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table
> > I think).
> >
> >> Original-patch-by: Haibo Xu <haibo1.xu@intel.com>
> >
> > If the original patch has been signed-off by that developer, you can
> > use a Co-developed-by: along with the original S-o-b tag here.
> >
> >> [Original patch is for TDEL table, modified it for CCEL support]
> >> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> >> ---
> >>
>
> How about the following version?

Looks good to me, thanks!

> ACPI: sysfs: Enable ACPI sysfs support for CCEL records
>
> The Confidential Computing Event Log (CCEL) table provides the address
> and length of the CCEL records area in UEFI reserved memory.
>
> To allow user space access to these records, expose a sysfs interface
> similar to the BERT table.
>
> More details about the CCEL table can be found in the ACPI specification
> r6.5 [1], sec 5.2.34.
>
> Link: https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table # [1]
> Co-developed-by: Haibo Xu <haibo1.xu@intel.com>
> Signed-off-by: Haibo Xu <haibo1.xu@intel.com>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
>
>
> >> Changes since v1:
> >>  * Removed unnecessary parenthesis as per Rafael's suggestion..
> >>
> >>  drivers/acpi/sysfs.c | 17 +++++++++++++++++
> >>  1 file changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> >> index 7f4ff56c9d42..687524b50085 100644
> >> --- a/drivers/acpi/sysfs.c
> >> +++ b/drivers/acpi/sysfs.c
> >> @@ -458,11 +458,28 @@ static int acpi_bert_data_init(void *th, struct acpi_data_attr *data_attr)
> >>         return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
> >>  }
> >>
> >> +static int acpi_ccel_data_init(void *th, struct acpi_data_attr *data_attr)
> >> +{
> >> +       struct acpi_table_ccel *ccel = th;
> >> +
> >> +       if (ccel->header.length < sizeof(struct acpi_table_ccel) ||
> >> +           !ccel->log_area_start_address || !ccel->log_area_minimum_length) {
> >> +               kfree(data_attr);
> >> +               return -EINVAL;
> >> +       }
> >> +       data_attr->addr = ccel->log_area_start_address;
> >> +       data_attr->attr.size = ccel->log_area_minimum_length;
> >> +       data_attr->attr.attr.name = "CCEL";
> >> +
> >> +       return sysfs_create_bin_file(tables_data_kobj, &data_attr->attr);
> >> +}
> >> +
> >>  static struct acpi_data_obj {
> >>         char *name;
> >>         int (*fn)(void *, struct acpi_data_attr *);
> >>  } acpi_data_objs[] = {
> >>         { ACPI_SIG_BERT, acpi_bert_data_init },
> >> +       { ACPI_SIG_CCEL, acpi_ccel_data_init },
> >>  };
> >>
> >>  #define NUM_ACPI_DATA_OBJS ARRAY_SIZE(acpi_data_objs)
> >> --
> >> 2.34.1
> >>
>
> --
> Sathyanarayanan Kuppuswamy
> Linux Kernel Developer

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-22 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-20 21:20 [PATCH v2] ACPI: sysfs: Enable ACPI sysfs support for CCEL records Kuppuswamy Sathyanarayanan
2023-03-22 18:31 ` Rafael J. Wysocki
2023-03-22 19:00   ` Sathyanarayanan Kuppuswamy
2023-03-22 19:06     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).