]> xenbits.xensource.com Git - pvdrivers/win/xenbus.git/commitdiff
Add a new helper function to make VCPUOP_register_vcpu_info hypercalls
authorPaul Durrant <pdurrant@amazon.com>
Fri, 27 Nov 2020 08:41:33 +0000 (08:41 +0000)
committerPaul Durrant <pdurrant@amazon.com>
Thu, 3 Dec 2020 08:14:22 +0000 (08:14 +0000)
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
include/xen.h
src/xen/vcpu.c

index 89f68867ad5f9606c0f554e13d0bd0ec63cb6418..8fb55c753c5565eb733824a9ae9c310e825086df 100644 (file)
@@ -495,4 +495,13 @@ VcpuSetPeriodicTimer(
     IN  PLARGE_INTEGER  Period
     );
 
+__checkReturn
+XEN_API
+NTSTATUS
+VcpuRegisterVcpuInfo(
+    IN  unsigned int                vcpu_id,
+    IN  PFN_NUMBER                  Pfn,
+    IN  ULONG                       Offset
+    );
+
 #endif  // _XEN_H
index a1881cf37b0ccfce6182545fb10165ba4dd34759..552b3b330878a9d99485cc639429e234e125b897 100644 (file)
@@ -80,3 +80,41 @@ fail1:
 
     return status;
 }
+
+__checkReturn
+XEN_API
+NTSTATUS
+VcpuRegisterVcpuInfo(
+    IN  unsigned int                vcpu_id,
+    IN  PFN_NUMBER                  Pfn,
+    IN  ULONG                       Offset
+    )
+{
+    struct vcpu_register_vcpu_info  op;
+    LONG_PTR                        rc;
+    NTSTATUS                        status;
+
+    op.mfn = (xen_pfn_t)Pfn;
+    op.offset = Offset;
+    op.rsvd = 0;
+
+    //
+    // NOTE: This has to be called on the CPU with the matching vcpu_id
+    //       otherwise Xen will fail the hypercall with -EINVAL.
+    //
+
+    rc = VcpuOp(VCPUOP_register_vcpu_info, vcpu_id, &op);
+
+    if (rc < 0) {
+        ERRNO_TO_STATUS(-rc, status);
+        goto fail1;
+    }
+
+    return STATUS_SUCCESS;
+
+fail1:
+    Error("fail1 (%08x)\n", status);
+
+    return status;
+
+}