i386/sev/igvm: do not reset guest policy if IGVM does not set it
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 runstate: handle return code of EOPNOTSUPP properly from rebuild_guest()
If rebuild_guest() accelerator callback returns EOPNOTSUPP, this means that the accelerator does not support rebuilding the guest state. Handle this case properly and separately from other error return codes.
--- system/runstate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
system/runstate.c +3 -1
@@ -531,10 +531,12 @@ void qemu_system_reset(ShutdownCause reason) (current_machine->new_accel_vmfd_on_reset || !cpus_are_resettable())) {if (ac->rebuild_guest) { ret = ac->rebuild_guest (current_machine); -if (ret <0 ) { +if (ret <0 && ret != -EOPNOTSUPP ) {error_report ("unable to rebuild guest: %s(%d)" ,strerror (-ret), ret);vm_stop (RUN_STATE_INTERNAL_ERROR ); + }else if (ret == -EOPNOTSUPP ) { +error_report ("accelerator does not support reset!" ); }else {info_report ("virtual machine state has been rebuilt with new " "guest file handle." );
Signature · 1 line
2.42.0
PATCH 2/2 i386/sev/igvm: do not reset guest policy if IGVM does not set it
In reply to a message not in the archiveThe guest policy is set either through command-line or through IGVM. If none of the above applies, default guest policy applies. However, if IGVM does not set the guest policy, currently the policy gets set to 0 regardless of whether it was previously set to default value or command line. This change fixes this by checking if IGVM indeed has set a policy value. If not, do not reset existing value.
This avoids guest crashes such as the following during reset when the IGVM has not explicitly set any guest policies:
qemu-system-x86_64: sev_snp_launch_start: SNP_LAUNCH_START ret=-22 fw_error=0 ''
qemu-system-x86_64: sev_common_kvm_init: failed to create encryption context
qemu-system-x86_64: unable to rebuild guest: Operation not permitted(-1)
--- target/i386/sev.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
target/i386/sev.c +10 -2
@@ -2760,7 +2760,11 @@ static int cgs_set_guest_policy(ConfidentialGuestPolicyType policy_type, id_auth->author_key[0 ] ?1 :0 ; finish->id_block_en =1 ; } - sev_snp_guest->kvm_start_conf.policy = policy; + +/* do not reset existing policy if policy was not set in IGVM */ +if (policy !=0 ) { + sev_snp_guest->kvm_start_conf.policy = policy; + } }else {SevGuestState *sev_guest =SEV_GUEST (MACHINE (qdev_get_machine ())->cgs);/* Only the policy flags are supported for SEV and SEV-ES */
@@ -2769,7 +2773,11 @@ static int cgs_set_guest_policy(ConfidentialGuestPolicyType policy_type, "but SEV-SNP is not enabled", __func__);return -1 ; } - sev_guest->policy = policy; + +/* do not reset existing policy if policy was not set in IGVM */ +if (policy !=0 ) { + sev_guest->policy = policy; + } }return 0 ; }
Signature · 1 line
2.42.0