Re: [RFC 05/33] KVM: x86: hyper-v: Introduce VTL call/return prologues in hypercall page
From: Nicolas Saenz Julienne
Date: Wed Nov 08 2023 - 09:10:34 EST
On Wed Nov 8, 2023 at 11:53 AM UTC, Alexander Graf wrote:
[...]
> > @@ -285,6 +286,81 @@ static int patch_hypercall_page(struct kvm_vcpu *vcpu, u64 data)
> > /* ret */
> > ((unsigned char *)instructions)[i++] = 0xc3;
> >
> > + /* VTL call/return entries */
> > + if (!kvm_xen_hypercall_enabled(kvm) && kvm_hv_vsm_enabled(kvm)) {
>
>
> You don't introduce kvm_hv_vsm_enabled() before. Please do a quick test
> build of all individual commits of your patch set for v1 :).
Yes, sorry for that. This happens for a couple of helpers, I'll fix it.
> Why do you need the ifdef here? is_long_mode() already has an ifdef that
> will always return false for is_64_bit_mode() on 32bit hosts.
Noted, will remove.
> > + if (is_64_bit_mode(vcpu)) {
> > + /*
> > + * VTL call 64-bit entry prologue:
> > + * mov %rcx, %rax
> > + * mov $0x11, %ecx
> > + * jmp 0:
> > + */
> > + hv->vsm_code_page_offsets.vtl_call_offset = i;
> > + instructions[i++] = 0x48;
> > + instructions[i++] = 0x89;
> > + instructions[i++] = 0xc8;
> > + instructions[i++] = 0xb9;
> > + instructions[i++] = 0x11;
> > + instructions[i++] = 0x00;
> > + instructions[i++] = 0x00;
> > + instructions[i++] = 0x00;
> > + instructions[i++] = 0xeb;
> > + instructions[i++] = 0xe0;
>
>
> I think it would be a lot easier to read (because it's denser) if you
> move the opcodes into a character array:
>
> char vtl_entry[] = { 0x48, 0x89, 0xc8, 0xb9, 0x11, 0x00, 0x00, 0x00.
> 0xeb, 0xe0 };
>
> and then just memcpy().
Works for me, I'll rework it.
Nicolas