qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v2 11/22] i386/xen: implement HYPERCALL_xen_version


From: Paul Durrant
Subject: Re: [RFC PATCH v2 11/22] i386/xen: implement HYPERCALL_xen_version
Date: Mon, 12 Dec 2022 14:17:33 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

On 09/12/2022 09:56, David Woodhouse wrote:
From: Joao Martins <joao.m.martins@oracle.com>

This is just meant to serve as an example on how we can implement
hypercalls. xen_version specifically since Qemu does all kind of
feature controllability. So handling that here seems appropriate.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
[dwmw2: Implement kvm_gva_rw() safely]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
  target/i386/xen.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++
  1 file changed, 79 insertions(+)

diff --git a/target/i386/xen.c b/target/i386/xen.c
index 708ab908a0..55beed1913 100644
--- a/target/i386/xen.c
+++ b/target/i386/xen.c
@@ -12,9 +12,51 @@
  #include "qemu/osdep.h"
  #include "qemu/log.h"
  #include "kvm/kvm_i386.h"
+#include "exec/address-spaces.h"
  #include "xen.h"
  #include "trace.h"
+#include "standard-headers/xen/version.h"
+
+static int kvm_gva_rw(CPUState *cs, uint64_t gva, void *_buf, size_t sz,
+                      bool is_write)
+{
+    uint8_t *buf = (uint8_t *)_buf;
+    size_t i = 0, len = 0;
+    int ret;
+
+    for (i = 0; i < sz; i+= len) {
+        struct kvm_translation tr = {
+            .linear_address = gva + i,
+        };
+
+        len = TARGET_PAGE_SIZE - (tr.linear_address & ~TARGET_PAGE_MASK);
+        if (len > sz)

Shouldn't this be (sz - i)?

  Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]