@@ -59,6 +59,7 @@ HII_VENDOR_DEVICE_PATH mSecureBootHiiVendorDevicePath = {
59
59
};
60
60
61
61
BOOLEAN mIsEnterSecureBootForm = FALSE;
62
+ BOOLEAN mResetSvBootState = FALSE;
62
63
63
64
//
64
65
// OID ASN.1 Value for Hash Algorithms
@@ -301,7 +302,7 @@ SaveSecureBootVariable (
301
302
/**
302
303
Set Sovereign Boot configuration into variable space.
303
304
304
- @param[in] SvBootEnable The satte of Sovereign Boot.
305
+ @param[in] SvBootEnable The state of Sovereign Boot.
305
306
306
307
@retval EFI_SUCCESS The operation is finished successfully.
307
308
@retval Others Other errors as indicated.
@@ -350,6 +351,53 @@ SaveSovereignBootVariable (
350
351
return Status ;
351
352
}
352
353
354
+ /**
355
+ Resets Sovereign Boot configuration and saves it into variable space.
356
+
357
+ @retval EFI_SUCCESS The operation is finished successfully.
358
+ @retval Others Other errors as indicated.
359
+
360
+ **/
361
+ EFI_STATUS
362
+ ResetSovereignBootState (
363
+ SECUREBOOT_CONFIG_PRIVATE_DATA * Private
364
+ )
365
+ {
366
+ SOVEREIGN_BOOT_WIZARD_NV_CONFIG SvBootConfig ;
367
+ EFI_STATUS Status ;
368
+ UINT32 Attrs ;
369
+ UINTN VarSize ;
370
+
371
+ VarSize = sizeof (SOVEREIGN_BOOT_WIZARD_NV_CONFIG );
372
+
373
+ Status = gRT -> GetVariable (
374
+ SV_BOOT_CONFIG_VAR ,
375
+ & gSovereignBootWizardFormSetGuid ,
376
+ & Attrs ,
377
+ & VarSize ,
378
+ & SvBootConfig
379
+ );
380
+
381
+ if (EFI_ERROR (Status ) ||
382
+ Attrs != (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS ) ||
383
+ VarSize != sizeof (SOVEREIGN_BOOT_WIZARD_NV_CONFIG )
384
+ ) {
385
+ SvBootConfig .SvBootEnabled = FixedPcdGetBool (PcdSovereignBootDefaultState );
386
+ }
387
+
388
+ SvBootConfig .SvBootProvisioned = FALSE;
389
+
390
+ Status = gRT -> SetVariable (
391
+ SV_BOOT_CONFIG_VAR ,
392
+ & gSovereignBootWizardFormSetGuid ,
393
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS ,
394
+ sizeof (SOVEREIGN_BOOT_WIZARD_NV_CONFIG ),
395
+ & SvBootConfig
396
+ );
397
+
398
+ return Status ;
399
+ }
400
+
353
401
/**
354
402
This code checks if the encode type and key strength of X.509
355
403
certificate is qualified.
@@ -3528,6 +3576,12 @@ SecureBootExtractConfigFromVariable (
3528
3576
ConfigData -> SvBootProvisioned = SvBootConfig -> SvBootProvisioned ;
3529
3577
FreePool (SvBootConfig );
3530
3578
}
3579
+
3580
+ HiiSetString (
3581
+ Private -> HiiHandle ,
3582
+ STRING_TOKEN (STR_SOVEREIGN_BOOT_STATE_CONTENT ),
3583
+ ConfigData -> SvBootProvisioned ? L"Yes" : L"No" ,
3584
+ NULL );
3531
3585
}
3532
3586
3533
3587
if (SecureBootEnable != NULL ) {
@@ -4989,6 +5043,21 @@ SecureBootCallback (
4989
5043
goto EXIT ;
4990
5044
}
4991
5045
5046
+ if (Action == EFI_BROWSER_ACTION_SUBMITTED ) {
5047
+ Status = EFI_UNSUPPORTED ;
5048
+ if (QuestionId == KEY_SOVEREIGN_BOOT_PROVISIONED ) {
5049
+ Status = EFI_SUCCESS ;
5050
+ if (mResetSvBootState && !Value -> b ) {
5051
+ Status = ResetSovereignBootState (Private );
5052
+ if (GetBrowserDataResult ) {
5053
+ SecureBootExtractConfigFromVariable (Private , IfrNvData );
5054
+ }
5055
+ mResetSvBootState = FALSE;
5056
+ }
5057
+ }
5058
+ goto EXIT ;
5059
+ }
5060
+
4992
5061
if ((Action != EFI_BROWSER_ACTION_CHANGED ) &&
4993
5062
(Action != EFI_BROWSER_ACTION_CHANGING ) &&
4994
5063
(Action != EFI_BROWSER_ACTION_FORM_CLOSE ) &&
@@ -5589,12 +5658,19 @@ SecureBootCallback (
5589
5658
// If disabling, we need to restore Secure Boot keys
5590
5659
if (!Value -> b ) {
5591
5660
Status = KeyEnrollReset ();
5592
-
5661
+ if (EFI_ERROR (Status )) {
5662
+ break ;
5663
+ }
5664
+ // Reset the Sovereign Boot provisioning state
5665
+ Status = ResetSovereignBootState (Private );
5666
+ if (EFI_ERROR (Status )) {
5667
+ break ;
5668
+ }
5593
5669
//
5594
5670
// Update secure boot strings after key reset
5595
5671
//
5596
- if ( Status == EFI_SUCCESS ) {
5597
- Status = UpdateSecureBootString ( Private );
5672
+ Status = UpdateSecureBootString ( Private );
5673
+ if ( GetBrowserDataResult ) {
5598
5674
SecureBootExtractConfigFromVariable (Private , IfrNvData );
5599
5675
}
5600
5676
}
@@ -5647,6 +5723,13 @@ SecureBootCallback (
5647
5723
}
5648
5724
break ;
5649
5725
}
5726
+ case KEY_SOVEREIGN_BOOT_PROVISIONED :
5727
+ {
5728
+ Status = EFI_SUCCESS ;
5729
+ Value -> b = FALSE;
5730
+ mResetSvBootState = TRUE;
5731
+ break ;
5732
+ }
5650
5733
default :
5651
5734
break ;
5652
5735
}
0 commit comments