All of lore.kernel.org
 help / color / mirror / Atom feed
From: <mjaggi@caviumnetworks.com>
To: "Jaggi, Manish" <Manish.Jaggi@cavium.com>,
	"quintela@redhat.com" <quintela@redhat.com>,
	"dgilbert@redhat.com" <dgilbert@redhat.com>,
	"eric.auger@redhat.com" <eric.auger@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"Nair, Jayachandran" <Jayachandran.Nair@cavium.com>,
	"Nowicki, Tomasz" <Tomasz.Nowicki@cavium.com>
Subject: [Qemu-devel] [PATCH v2 2/2] [RFC] arm: program migrated guests' invariant registers with host ones
Date: Tue, 23 Oct 2018 09:31:19 +0000	[thread overview]
Message-ID: <492d066a988d7f22c9438c19f312c2e1f2b3d473.1536948621.git.manish.jaggi@cavium.com> (raw)
In-Reply-To: <cover.1536948621.git.manish.jaggi@cavium.com>

From: Manish Jaggi <manish.jaggi@cavium.com>

When KVM_SET_ONE_REG returns KVM_EINVARIANT call KVM_GET_ONE_REG to query
and then replace the particular guest invariant register value with destination
hosts register.

Signed-off-by: Manish Jaggi <manish.jaggi@cavium.com>

diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 65f867d..8cf4dc9 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -19,6 +19,7 @@
 #include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "kvm_arm.h"
+#include "standard-headers/asm-arm/kvm_para.h"
 #include "cpu.h"
 #include "trace.h"
 #include "internals.h"
@@ -37,6 +38,8 @@ static bool cap_has_mp_state;
 
 static ARMHostCPUFeatures arm_host_cpu_features;
 
+extern bool enable_hostinvariant;
+
 int kvm_arm_vcpu_init(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
@@ -451,8 +454,16 @@ bool write_list_to_kvmstate(ARMCPU *cpu, int level)
         default:
             abort();
         }
-        ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
-        if (ret) {
+	ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &r);
+	if (enable_hostinvariant && ret == -KVM_EINVARIANT) {
+		/* Update Guest invariant to match with migrated host regs*/
+		ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &r);
+		if (ret)
+			ok = false;
+		else
+                	cpu->cpreg_values[i] = r.addr;
+        }
+        else if (ret) {
             /* We might fail for "unknown register" and also for
              * "you tried to set a register which is constant with
              * a different value from what it actually contains".
-- 
1.8.3.1

      parent reply	other threads:[~2018-10-23  9:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23  9:31 [Qemu-devel] [PATCH v2 0/2] [RFC] qemu: arm: Migration between machines with different MIDR values mjaggi
2018-10-23  9:31 ` [Qemu-devel] [PATCH v2 1/2] [RFC] arm: Introduce hostinvariant command line option mjaggi
2018-10-24 10:02   ` Juan Quintela
2018-10-23  9:31 ` mjaggi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=492d066a988d7f22c9438c19f312c2e1f2b3d473.1536948621.git.manish.jaggi@cavium.com \
    --to=mjaggi@caviumnetworks.com \
    --cc=Jayachandran.Nair@cavium.com \
    --cc=Manish.Jaggi@cavium.com \
    --cc=Tomasz.Nowicki@cavium.com \
    --cc=dgilbert@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.