Re: [PATCH v15 06/13] x86/sev: Prevent GUEST_TSC_FREQ MSR interception for Secure TSC enabled guests

Borislav Petkov
2025-01-02T14:54:56Z

On Thu, Jan 02, 2025 at 08:45:36AM -0600, Tom Lendacky wrote:
> >> @@ -1477,7 +1477,9 @@ static enum es_result vc_handle_msr(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
> >> case MSR_IA32_TSC:
> >> case MSR_AMD64_GUEST_TSC_FREQ:
> >> if (sev_status & MSR_AMD64_SNP_SECURE_TSC)
> >> - return __vc_handle_msr_tsc(regs, write);
> >> + return __vc_handle_secure_tsc_msrs(regs, write);
> >> + else
> >> + break;
>
> There's a return as part of the if, so no reason for the else. Just put
> the break in the normal place and it reads much clearer.

I guess that's in the eye of the beholder. I prefer a balanced

if
foo
else
bar

as it is as obvious and clear as it gets. Especially if it is interwoven in
a switch-case like here.

--
Regards/Gruss,
Boris.