From af0bd66187545a26d5b136eb29a0bf7b877a1b5c Mon Sep 17 00:00:00 2001 From: Paul Durrant Date: Fri, 27 Nov 2020 08:41:33 +0000 Subject: [PATCH] Add a new helper function to make VCPUOP_register_vcpu_info hypercalls Signed-off-by: Paul Durrant --- include/xen.h | 9 +++++++++ src/xen/vcpu.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/xen.h b/include/xen.h index 89f6886..8fb55c7 100644 --- a/include/xen.h +++ b/include/xen.h @@ -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 diff --git a/src/xen/vcpu.c b/src/xen/vcpu.c index a1881cf..552b3b3 100644 --- a/src/xen/vcpu.c +++ b/src/xen/vcpu.c @@ -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; + +} -- 2.39.5