All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Dionna Glaze <dionnaglaze@google.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Tom Lendacky <Thomas.Lendacky@amd.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Joerg Roedel <jroedel@suse.de>, Peter Gonda <pgonda@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Venu Busireddy <venu.busireddy@oracle.com>,
	Michael Roth <michael.roth@amd.com>,
	"Kirill A. Shutemov" <kirill@shutemov.name>,
	Michael Sterritt <sterritt@google.com>
Subject: Re: [PATCH v12 2/3] x86/sev: Change snp_guest_issue_request's fw_err
Date: Mon, 23 Jan 2023 21:24:23 +0100	[thread overview]
Message-ID: <Y87s95WNc0QLZ7fn@zn.tnic> (raw)
In-Reply-To: <20230120214857.835931-3-dionnaglaze@google.com>

On Fri, Jan 20, 2023 at 09:48:55PM +0000, Dionna Glaze wrote:
> Since the "fw_err" field is really exitinfo2 split into the upper bits'
> vmm error code and lower bits' firmware error code, sev-guest.h is
> updated to represent the 64 bit value as a union.

Yah, documentation needs update too:

diff --git a/Documentation/virt/coco/sev-guest.rst b/Documentation/virt/coco/sev-guest.rst
index 4f0dcc1d16e8..4f9df24b829f 100644
--- a/Documentation/virt/coco/sev-guest.rst
+++ b/Documentation/virt/coco/sev-guest.rst
@@ -57,9 +57,16 @@ counter (e.g. counter overflow), then -EIO will be returned.
                 __u64 req_data;
                 __u64 resp_data;
 
-                /* firmware error code on failure (see psp-sev.h) */
-                __u64 fw_err;
-        };
+                /* bits[63:32]: VMM error code, bits[31:0] firmware error code (see psp-sev.h) */
+                union {
+                        __u64 exitinfo2;
+                        struct {
+                                __u32 fw_error;
+                                __u32 vmm_error;
+                        };
+                };
+	};
+
 
 2.1 SNP_GET_REPORT
 ------------------

/me goes and looks at patch 3...

Yap, that change adding the union should all belong together in a single patch.

> @@ -366,24 +367,22 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
>  		 * of the VMPCK and the error code being propagated back to the
>  		 * user as an ioctl() return code.
>  		 */
> -		rc = snp_issue_guest_request(exit_code, &snp_dev->input, &err);
> +		rc = snp_issue_guest_request(exit_code, &snp_dev->input,
> +					     &arg->exitinfo2);
>  
>  		/*
>  		 * Override the error to inform callers the given extended
>  		 * request buffer size was too small and give the caller the
>  		 * required buffer size.
>  		 */
> -		err = SNP_GUEST_REQ_INVALID_LEN;
> +		arg->vmm_error = SNP_GUEST_VMM_ERR_INVALID_LEN;
>  		snp_dev->input.data_npages = certs_npages;
>  	}
>  
> -	if (fw_err)
> -		*fw_err = err;
> -
>  	if (rc) {
>  		dev_alert(snp_dev->dev,
> -			  "Detected error from ASP request. rc: %d, fw_err: %llu\n",
> -			  rc, *fw_err);
> +			  "Detected error from ASP request. rc: %d, exitinfo2: %llu\n",
> +			  rc, arg->exitinfo2);

I guess that's better off dumped in binary now:

diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index d4973d2dbc24..a5d6ea3eebe9 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -380,7 +380,7 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code,
 
 	if (rc) {
 		dev_alert(snp_dev->dev,
-			  "Detected error from ASP request. rc: %d, exitinfo2: %llu\n",
+			  "Detected error from ASP request. rc: %d, exitinfo2: 0x%llx\n",
 			  rc, arg->exitinfo2);
 		goto disable_vmpck;
 	}

Anyway, that's a lot of changes for a fix which needs to go to stable. I don't
mind them but not in a minimal fix.

So how is this for a minimal fix to go in now, ontop of your first patch? The
cleanups can then go later...

---
diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c
index 4ec4174e05a3..20b560a45bc1 100644
--- a/drivers/virt/coco/sev-guest/sev-guest.c
+++ b/drivers/virt/coco/sev-guest/sev-guest.c
@@ -322,7 +322,7 @@ static int handle_guest_request(struct snp_guest_dev *snp_dev, u64 exit_code, in
 				u8 type, void *req_buf, size_t req_sz, void *resp_buf,
 				u32 resp_sz, __u64 *fw_err)
 {
-	unsigned long err;
+	unsigned long err = SEV_RET_NO_FW_CALL;
 	u64 seqno;
 	int rc;
 

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  parent reply	other threads:[~2023-01-23 20:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 21:48 [PATCH v12 0/3] Add throttling detection to sev-guest Dionna Glaze
2023-01-20 21:48 ` [PATCH v12 1/3] crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL Dionna Glaze
2023-01-20 21:48 ` [PATCH v12 2/3] x86/sev: Change snp_guest_issue_request's fw_err Dionna Glaze
2023-01-21 17:05   ` Borislav Petkov
2023-01-23 20:24   ` Borislav Petkov [this message]
2023-01-23 21:22     ` Dionna Amalie Glaze
2023-01-24 13:51       ` Borislav Petkov
2023-01-24 16:35         ` Sean Christopherson
2023-01-20 21:48 ` [PATCH v12 3/3] virt: sev-guest: interpret VMM errors from guest request Dionna Glaze

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=Y87s95WNc0QLZ7fn@zn.tnic \
    --to=bp@alien8.de \
    --cc=Thomas.Lendacky@amd.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dionnaglaze@google.com \
    --cc=hpa@zytor.com \
    --cc=jroedel@suse.de \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.roth@amd.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pgonda@google.com \
    --cc=sterritt@google.com \
    --cc=tglx@linutronix.de \
    --cc=venu.busireddy@oracle.com \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.