Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C345C6FD1D for ; Mon, 20 Mar 2023 17:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232913AbjCTRVJ convert rfc822-to-8bit (ORCPT ); Mon, 20 Mar 2023 13:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbjCTRUr (ORCPT ); Mon, 20 Mar 2023 13:20:47 -0400 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0160C31E33; Mon, 20 Mar 2023 10:16:36 -0700 (PDT) Received: by mail-ed1-f46.google.com with SMTP id x3so49577734edb.10; Mon, 20 Mar 2023 10:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679332544; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k87jmpjlNLfn6Eu0wWSVrI81rlQ/q/jsPiIAGLWAuyA=; b=Pb6NaKdbPR6zXij/zmyd3+Gxu0xpeguQARTNicpsRXG/TRP2eoBCW0ANT6xURxFu4J x+189dYnP6pEFgkOdnLcja3bzx3w1gKV13trA2omx6oI/yfYN7XFJ0Mx13Bx+YQvHGkL aQkm/LJLPIuPeCObGxbQQ0mC/71/l1Shs/hvXAuCZc2gj//xv0jeY6XBqXtr8PWepUxo MijahzKf8myMa6u+ZqaMyagmIB3xg/1TN08kZGS1lp2S4Dkn2wlkJDv0s+yKMJYc1pPb WWPPwO9odrmmFeHe8X1oixnsthq9MI26Xih6isuMUYSMYT4lSgbgQS+YXpzxCZEFSJjo BWHg== X-Gm-Message-State: AO0yUKV2KnmgECXkqSF9eAuC2U4s4mK5wygW1lJfxyLLpZaQeoVdddhO T5ON5MSvZmeTZPELJnJdg2MYNlVYivVsr+x/AWY= X-Google-Smtp-Source: AK7set9KDcXIH6JRWcUJXsHj6hNrkEL2ZM830wmLgVeOVdVzvlpOwMsIPDvNyLssiFAy9ageTzPSCFJ1P5Zpq8qN8w4= X-Received: by 2002:a17:906:228b:b0:931:6921:bdbb with SMTP id p11-20020a170906228b00b009316921bdbbmr4081391eja.2.1679332543822; Mon, 20 Mar 2023 10:15:43 -0700 (PDT) MIME-Version: 1.0 References: <20230302071327.557734-1-sathyanarayanan.kuppuswamy@linux.intel.com> In-Reply-To: <20230302071327.557734-1-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Rafael J. Wysocki" Date: Mon, 20 Mar 2023 18:15:32 +0100 Message-ID: Subject: Re: [PATCH v1] ACPI: sysfs: Enable ACPI sysfs support for CCEL records To: Kuppuswamy Sathyanarayanan Cc: Rafael J Wysocki , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 2, 2023 at 8:13 AM Kuppuswamy Sathyanarayanan wrote: > > 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 > [Original patch is for TDEL table, modified it for CCEL support] > Signed-off-by: Kuppuswamy Sathyanarayanan > --- > drivers/acpi/sysfs.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c > index 7db3b530279b..afeac925b31b 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)) { The inner parens in this line are not necessary AFAICS. Otherwise I have no objections. > + 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) > --