lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK7BL0GIPgr3alVr@smile.fi.intel.com>
Date:   Wed, 12 Jul 2023 18:05:19 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>
Cc:     hdegoede@...hat.com, markgross@...nel.org,
        ilpo.jarvinen@...ux.intel.com, platform-driver-x86@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/3] platform/x86/intel/tpmi: Read feature control
 status

On Tue, Jul 11, 2023 at 03:09:47PM -0700, Srinivas Pandruvada wrote:
> Some of the PM features can be locked or disabled. In that case, write
> interface can be locked.
> 
> This status is read via a mailbox. There is one TPMI ID which provides
> base address for interface and data register for mail box operation.
> The mailbox operations is defined in the TPMI specification. Refer to
> https://github.com/intel/tpmi_power_management/ for TPMI specifications.
> 
> An API is exposed to feature drivers to read feature control status.

...

> +/*
> + * TPMI PFS and per feature memory size can't exceed 4K.
> + * Also PFS start and feature memory is 4K aligned.
> + */
> +#define TPMI_MAX_BUFFER_SIZE    (4 * 1024)

SZ_4K from sizes.h?

...

> +#define TPMI_CONTROL_TIMEOUT_MAX_US	USEC_PER_SEC

> +#define TPMI_RB_TIMEOUT_MAX_US		USEC_PER_SEC

I think it's easier to get in a form (1 * ..._SEC)

...

> +static int tpmi_wait_for_owner(struct intel_tpmi_info *tpmi_info, u8 owner)
> +{
> +	u64 control;
> +
> +	return read_poll_timeout(readq, control,
> +				 owner == FIELD_GET(TPMI_CONTROL_STATUS_OWNER, control),
> +				 TPMI_CONTROL_TIMEOUT_US, TPMI_CONTROL_TIMEOUT_MAX_US, false,
> +				 tpmi_info->tpmi_control_mem + TPMI_CONTROL_STATUS_OFFSET);

Since you have "false" why not use readq_poll_timeout()?

> +}

...

> +	/* Wait for Run Busy clear */
> +	ret = read_poll_timeout(readq, control, !(control & TPMI_CONTROL_STATUS_RB),
> +				TPMI_RB_TIMEOUT_US, TPMI_RB_TIMEOUT_MAX_US, false,
> +				tpmi_info->tpmi_control_mem + TPMI_CONTROL_STATUS_OFFSET);

Ditto.

> +	if (ret)
> +		goto done_proc;

...

> +	size = pfs->pfs_header.num_entries * pfs->pfs_header.entry_size * sizeof(u32);
> +	/* This size is coming from trusted hardware, but verify anyway */

I would move this comment before size assignment that we already know that it's
from the trusted hw.

> +	if (size > TPMI_MAX_BUFFER_SIZE)
> +		return;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ