lkml.org 
[lkml]   [2022]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH v12 43/46] virt: Add SEV-SNP guest driver
    Apologies for the necropost, but I noticed strange behavior testing my
    own Golang-based wrapper around the /dev/sev-guest driver.

    > +
    > +static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, int msg_ver,
    > + u8 type, void *req_buf, size_t req_sz, void *resp_buf,
    > + u32 resp_sz, __u64 *fw_err)
    > +{
    > + unsigned long err;
    > + u64 seqno;
    > + int rc;
    > +
    > + /* Get message sequence and verify that its a non-zero */
    > + seqno = snp_get_msg_seqno(snp_dev);
    > + if (!seqno)
    > + return -EIO;
    > +
    > + memset(snp_dev->response, 0, sizeof(struct snp_guest_msg));
    > +
    > + /* Encrypt the userspace provided payload */
    > + rc = enc_payload(snp_dev, seqno, msg_ver, type, req_buf, req_sz);
    > + if (rc)
    > + return rc;
    > +
    > + /* Call firmware to process the request */
    > + rc = snp_issue_guest_request(exit_code, &snp_dev->input, &err);
    > + if (fw_err)
    > + *fw_err = err;
    > +
    > + if (rc)
    > + return rc;
    > +

    The fw_err is written back regardless of rc, so since err is
    uninitialized, you can end up with garbage written back. I've worked
    around this by only caring about fw_err when the result is -EIO, but
    thought that I should bring this up.

    --
    -Dionna Glaze, PhD (she/her)

    \
     
     \ /
      Last update: 2022-08-24 20:03    [W:4.081 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site