mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Richter <rrichter@amd.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Ben Widawsky <bwidawsk@kernel.org>,
	Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cxl/mbox: Fix Payload Length check for Get Log command
Date: Wed, 4 Jan 2023 12:31:54 +0100	[thread overview]
Message-ID: <Y7VjfRZlBDnHewAd@rric.localdomain> (raw)
In-Reply-To: <63b4a8153d6b6_517412948a@dwillia2-xfh.jf.intel.com.notmuch>

On 03.01.23 14:11:33, Dan Williams wrote:
> Robert Richter wrote:
> > Commit 2aeaf663b85e introduced strict checking for variable length
> > payload size validation. The payload length of received data must
> > match the size of the requested data by the caller except for the case
> > where the min_out value is set.
> > 
> > The Get Log command does not have a header with a length field set.
> > The Log size is determined by the Get Supported Logs command (CXL 3.0,
> > 8.2.9.5.1). However, the actual size can be smaller and the number of
> > valid bytes in the payload output must be determined reading the
> > Payload Length field (CXL 3.0, Table 8-36, Note 2).
> > 
> > Two issues arise: The command can successfully complete with a payload
> > length of zero. And, the valid payload length must then also be
> > consumed by the caller.
> 
> Perhaps this is confusion about what the "Log Size" field of Get
> Supported Logs means? My reading is that the "Log Size" field indicates
> the data "currently available" in the log. Correct me if I am wrong, but
> it seems your reading is that it is the "possibly available" data and
> software can not assume anything is available until it actually goes to
> read the log.

> Are you sure that this is not a device-side implementation issue where
> it needs to make sure that Get Supported Logs indicates what Get Log can
> expect?

The spec is not really clear here and I have seen a CXL device
firmware implementation that interprets it like that. We could demand
a firmware fix for that, but the kernel driver would be more robust if
we lower the strictness here.

Reading the spec again I just found that "the maximum size of each
Log" is mentioned in the description:

"""
8.2.9.5.1 Get Supported Logs (Opcode 0400h)

Retrieve the list of device specific logs (identified by UUID) and
the maximum size of each Log.
"""

With that and the note in Table 8-36 stating that the exact payload of
a variable length command should be determined using the Payload
Length field, I think the commands can return different payload
lengths.

> > There could be other variable payloads commands affected by this
> > strict check, the implementation of GET_LSA and SET_LSA in this kernel
> > could possibly be broken too. A fix of this is not scope of this
> > patch.
> 
> SET_LSA cannot be broken because SET_LSA does not return an output
> payload, and GET_LSA never expects short reads.

Ok, I haven't checked the details here but thought it is worth to
note.

> Now, if short reads need to be supported on production devices for any
> variable length output payload command, I would rather see that handled
> as a cxl_internal_send_cmd() special case where mbox_cmd->size_out is
> consulted when cxl_internal_send_cmd() returns -EIO.

I will prepare a v2 with that change included.

Thanks,

-Robert

  reply	other threads:[~2023-01-04 11:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 20:59 Robert Richter
2023-01-03 22:11 ` Dan Williams
2023-01-04 11:31   ` Robert Richter [this message]
2023-01-13 13:28     ` Robert Richter

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=Y7VjfRZlBDnHewAd@rric.localdomain \
    --to=rrichter@amd.com \
    --cc=alison.schofield@intel.com \
    --cc=bwidawsk@kernel.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vishal.l.verma@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®