Post Reply 
 
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hyper-V Gen 2
2017-05-31, 18:00
Post: #6
RE: Hyper-V Gen 2
So my reversions, from what i can tell, didn't impact any functionality, it just made it so the functions returned as int's and used the values returned to perform the same feats as earlier. I didn't change large segments of code.

Can you explain, more directly, what the repercussions of the reversions I made had on the whole process?

Of note: here's the exact diff:

Code:
--- a/src/arch/x86/drivers/hyperv/hyperv.c
+++ b/src/arch/x86/drivers/hyperv/hyperv.c
@@ -225,7 +225,7 @@ static int hv_check_features ( struct hv_hypervisor *hv ) {
  *
  * @v hv               Hyper-V hypervisor
  */
-static void hv_map_hypercall ( struct hv_hypervisor *hv ) {
+static int hv_map_hypercall ( struct hv_hypervisor *hv ) {
        union {
                struct {
                        uint32_t ebx;
@@ -247,6 +247,7 @@ static void hv_map_hypercall ( struct hv_hypervisor *hv ) {
        if ( guest_os_id != 0 ) {
                DBGC ( hv, "HV %p guest OS ID MSR was %#08llx\n",
                       hv, guest_os_id );
+               return -EBUSY;
        }
        guest_os_id = HV_GUEST_OS_ID_IPXE;
        DBGC2 ( hv, "HV %p guest OS ID MSR is %#08llx\n", hv, guest_os_id );
@@ -267,6 +268,8 @@ static void hv_map_hypercall ( struct hv_hypervisor *hv ) {
        hypercall |= ( virt_to_phys ( hv->hypercall ) | HV_HYPERCALL_ENABLE );
        DBGC2 ( hv, "HV %p hypercall MSR is %#08llx\n", hv, hypercall );
        wrmsr ( HV_X64_MSR_HYPERCALL, hypercall );
+
+       return 0;
}

/**
@@ -295,7 +298,7 @@ static void hv_unmap_hypercall ( struct hv_hypervisor *hv ) {
  *
  * @v hv               Hyper-V hypervisor
  */
-static void hv_map_synic ( struct hv_hypervisor *hv ) {
+static int hv_map_synic ( struct hv_hypervisor *hv ) {
        uint64_t simp;
        uint64_t siefp;
        uint64_t scontrol;
@@ -323,6 +326,8 @@ static void hv_map_synic ( struct hv_hypervisor *hv ) {
        scontrol |= HV_SCONTROL_ENABLE;
        DBGC2 ( hv, "HV %p SCONTROL MSR is %#08llx\n", hv, scontrol );
        wrmsr ( HV_X64_MSR_SCONTROL, scontrol );
+
+       return 0;
}

/**
@@ -566,10 +571,14 @@ static int hv_probe ( struct root_device *rootdev ) {
                goto err_alloc_message;

        /* Map hypercall page */
-       hv_map_hypercall ( hv );
+       if ( ( rc = hv_map_hypercall ( hv ) ) != 0 )
+               goto err_map_hypercall
+       //hv_map_hypercall ( hv );

        /* Map synthetic interrupt controller */
-       hv_map_synic ( hv );
+       if ( ( rc = hv_map_synic ( hv ) ) != 0 )
+               goto err_map_synic
+       //hv_map_synic ( hv );

        /* Probe Hyper-V devices */
        if ( ( rc = vmbus_probe ( hv, &rootdev->dev ) ) != 0 )
@@ -581,7 +590,9 @@ static int hv_probe ( struct root_device *rootdev ) {
        vmbus_remove ( hv, &rootdev->dev );
  err_vmbus_probe:
        hv_unmap_synic ( hv );
+ err_map_synic:
        hv_unmap_hypercall ( hv );
+ err_map_hypercall:
        hv_free_message ( hv );
  err_alloc_message:
        hv_free_pages ( hv, hv->hypercall, hv->synic.message, hv->synic.event,

I did not do a full on code reversion, just updated things to try to get them functional again. It would seem the -EBUSY was needed, in my head.

I did not lose the functionality of the calls, just reintegrated what was removed. And this seems to work, even with the head state, where without these things it seems to not work for Hyper-V Gen 2. I don't have Hyper-V VM's so I'm not a good test subject, but I know people who can get us information as needed.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Hyper-V Gen 2 - mastacontrola - 2017-05-25, 17:40
RE: Hyper-V Gen 2 - mcb30 - 2017-05-26, 10:59
RE: Hyper-V Gen 2 - mastacontrola - 2017-05-26, 12:23
RE: Hyper-V Gen 2 - mcb30 - 2017-05-26, 13:38
RE: Hyper-V Gen 2 - mastacontrola - 2017-05-27, 01:35
RE: Hyper-V Gen 2 - mastacontrola - 2017-05-31 18:00
RE: Hyper-V Gen 2 - mcb30 - 2017-05-31, 18:05
RE: Hyper-V Gen 2 - mastacontrola - 2017-05-31, 18:48
RE: Hyper-V Gen 2 - mhiroaki - 2017-06-08, 13:57
RE: Hyper-V Gen 2 - mastacontrola - 2017-06-13, 14:45
RE: Hyper-V Gen 2 - NiKiZe - 2017-07-25, 16:35
RE: Hyper-V Gen 2 - NiKiZe - 2017-07-27, 10:58
RE: Hyper-V Gen 2 - mcb30 - 2017-07-28, 21:32
RE: Hyper-V Gen 2 - mastacontrola - 2017-07-31, 00:25



User(s) browsing this thread: 1 Guest(s)