Thread (20 messages) 20 messages, 3 authors, 2020-05-08

Re: [PATCH v2 0/1] x86/kvm/hyper-v: Add support to SYNIC exit on EOM

From: Jon Doron <hidden>
Date: 2020-05-05 10:38:26
Also in: kvm

On 05/05/2020, Roman Kagan wrote:
On Mon, May 04, 2020 at 05:55:10PM +0200, Vitaly Kuznetsov wrote:
quoted
Roman Kagan [off-list ref] writes:
quoted
On Sat, Apr 25, 2020 at 09:16:37AM +0300, Jon Doron wrote:
quoted
If that's indeed the case then probably the only thing needs fixing in my
scenario is in QEMU where it should not really care for the SCONTROL if it's
enabled or not.
Right.  However, even this shouldn't be necessary as SeaBIOS from that
branch would enable SCONTROL and leave it that way when passing the
control over to the bootloader, so, unless something explicitly clears
SCONTROL, it should remain set thereafter.  I'd rather try going ahead
with that scheme first, because making QEMU ignore SCONTROL appears to
violate the spec.
FWIW, I just checked 'genuine' Hyper-V 2016 with
diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index fd51bac11b46..c5ea759728d9 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -314,10 +314,14 @@ void __init hyperv_init(void)
        u64 guest_id, required_msrs;
        union hv_x64_msr_hypercall_contents hypercall_msr;
        int cpuhp, i;
+       u64 val;

        if (x86_hyper_type != X86_HYPER_MS_HYPERV)
                return;

+       hv_get_synic_state(val);
+       printk("Hyper-V: SCONTROL state: %llx\n", val);
+
        /* Absolutely required MSRs */
        required_msrs = HV_X64_MSR_HYPERCALL_AVAILABLE |
                HV_X64_MSR_VP_INDEX_AVAILABLE;
Thanks for having done this check!
quoted
and it seems the default state of HV_X64_MSR_SCONTROL is '1', we should
probably do the same.
This is the state the OS sees, after the firmware.  You'd see the same
with QEMU/KVM if you used Hyper-V-aware SeaBIOS or OVMF.
quoted
Is there any reason to *not* do this in KVM when
KVM_CAP_HYPERV_SYNIC[,2] is enabled?
Yes there is: quoting Hyper-V TLFS v6.0 11.8.1:

 At virtual processor creation time and upon processor reset, the value
 of this SCONTROL (SynIC control register) is 0x0000000000000000. Thus,
 message queuing and event flag notifications will be disabled.

And, even if we decide to violate the spec it's better done in
userspace, loading the initial value and adjusting the synic state at
vcpu reset.

However leaving it up to the guest (firmware or OS) looks more natural
to me.

Thanks,
Roman.
I under where you are coming from in the idea of leaving it to the OS 
but I think in this specific case it does not make much sense, after all 
HyperV has it's own proprietary BIOS which Windows assumes has setup 
some of the MSRs, since we dont have that BIOS we need to "emulate" it's 
behaviour.

I also feel like the best approach should be in QEMU in case VMBus 
device exists it will also setup the SCONTROL to ENABLED, this way you 
are not bound to have a special BIOS in case you have decided to use 
HyperV advanced features like VMBus.

Cheers,
-- Jon.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help