Re: [PATCH v5 10/12] x86/tdx: Add MSR support for TDX guest
From: Borislav Petkov
Date: Tue Aug 24 2021 - 12:54:54 EST
On Wed, Aug 04, 2021 at 11:13:27AM -0700, Kuppuswamy Sathyanarayanan wrote:
> int tdg_handle_virtualization_exception(struct pt_regs *regs,
> struct ve_info *ve)
> {
> + unsigned long val;
> + int ret = 0;
> +
> switch (ve->exit_reason) {
> case EXIT_REASON_HLT:
> tdg_halt();
> break;
> + case EXIT_REASON_MSR_READ:
> + val = tdg_read_msr_safe(regs->cx, (unsigned int *)&ret);
> + if (!ret) {
> + regs->ax = val & UINT_MAX;
regs->ax = (u32)val;
> + regs->dx = val >> 32;
> + }
> + break;
> + case EXIT_REASON_MSR_WRITE:
> + ret = tdg_write_msr_safe(regs->cx, regs->ax, regs->dx);
> + break;
> default:
> pr_warn("Unexpected #VE: %lld\n", ve->exit_reason);
> return -EFAULT;
> }
>
> /* After successful #VE handling, move the IP */
> - regs->ip += ve->instr_len;
> + if (!ret)
> + regs->ip += ve->instr_len;
>
> - return 0;
> + return ret;
> }
>
> void __init tdx_early_init(void)
> --
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette