Re: [PATCHv4 10/30] x86/tdx: Handle CPUID via #VE

Dave Hansen
2022-02-24T19:04:15Z

On 2/24/22 07:56, Kirill A. Shutemov wrote:
> static bool virt_exception_user(struct pt_regs *regs, struct ve_info *ve)
> {
> - pr_warn("Unexpected #VE: %lld\n", ve->exit_reason);
> - return false;
> + switch (ve->exit_reason) {
> + case EXIT_REASON_CPUID:
> + return handle_cpuid(regs);
> + default:
> + pr_warn("Unexpected #VE: %lld\n", ve->exit_reason);
> + return false;
> + }
> }

What does this mean for userspace? What kinds of things are we ceding
to the (untrusted) VMM to supply to userspace?

> /* Handle the kernel #VE */
> @@ -200,6 +235,8 @@ static bool virt_exception_kernel(struct pt_regs *regs, struct ve_info *ve)
> return read_msr(regs);
> case EXIT_REASON_MSR_WRITE:
> return write_msr(regs);
> + case EXIT_REASON_CPUID:
> + return handle_cpuid(regs);
> default:
> pr_warn("Unexpected #VE: %lld\n", ve->exit_reason);
> return false;
What kinds of random CPUID uses in the kernel at runtime need this
handling? Is it really OK that we let the VMM inject arbitrary CPUID
values into random CPUID uses in the kernel... silently?

Is this better than just returning 0's, for instance?