Skip to content

Instantly share code, notes, and snippets.

@deeglaze
Created February 3, 2023 17:55
Show Gist options
  • Save deeglaze/89b092d8834375540bb34ce244766ab3 to your computer and use it in GitHub Desktop.
Save deeglaze/89b092d8834375540bb34ce244766ab3 to your computer and use it in GitHub Desktop.
go-sev-guest client modification to work around throttling without sev-guest device patches
@@ func UseDefaultSevGuest() bool {
}
func message(d Device, command uintptr, req *labi.SnpUserGuestRequest) error {
- result, err := d.Ioctl(command, req)
- if err != nil {
- // The ioctl could have failed with a firmware error that
- // indicates a problem certificate length. We need to
- // communicate that specifically.
- if req.FwErr != 0 {
- return &abi.SevFirmwareErr{Status: abi.SevFirmwareStatus(req.FwErr)}
+ for {
+ result, err := d.Ioctl(command, req)
+ if err != nil {
+ // The ioctl could have failed with a firmware error that
+ // indicates a problem certificate length. We need to
+ // communicate that specifically.
+ if req.FwErr != 0 {
+ if req.FwErr == uint64(abi.GuestRequestThrottled) {
+ continue
+ }
+ return &abi.SevFirmwareErr{Status: abi.SevFirmwareStatus(req.FwErr)}
+ }
+ return err
}
- return err
- }
- if result != uintptr(labi.EsOk) {
- return &labi.SevEsErr{Result: labi.EsResult(result)}
+
+ if result != uintptr(labi.EsOk) {
+ return &labi.SevEsErr{Result: labi.EsResult(result)}
+ }
+ return nil
}
- return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment