From: Huaitong Han <huaitong.han@intel.com>
To: pbonzini@redhat.com, rth@twiddle.net, afaerber@suse.de,
ehabkost@redhat.com
Cc: Huaitong Han <huaitong.han@intel.com>,
qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 2/3] qemu, pkeys: add pkeys support for qemu xsave state handling
Date: Mon, 9 Nov 2015 19:55:33 +0800 [thread overview]
Message-ID: <1447070134-4324-3-git-send-email-huaitong.han@intel.com> (raw)
In-Reply-To: <1447070134-4324-1-git-send-email-huaitong.han@intel.com>
This patch adds pkeys support for qemu xsave state handling.
Signed-off-by: Huaitong Han <huaitong.han@intel.com>
---
target-i386/cpu.c | 2 ++
target-i386/cpu.h | 3 +++
target-i386/kvm.c | 3 +++
3 files changed, 8 insertions(+)
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 575ad8d..7a6a3f8 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -487,6 +487,8 @@ static const ExtSaveArea ext_save_areas[] = {
.offset = 0x480, .size = 0x200 },
[7] = { .feature = FEAT_7_0_EBX, .bits = CPUID_7_0_EBX_AVX512F,
.offset = 0x680, .size = 0x400 },
+ [9] = { .feature = FEAT_7_0_ECX, .bits = CPUID_7_0_ECX_PKU,
+ .offset = 0xA80, .size = 0x8 },
};
const char *get_register_name_32(unsigned int reg)
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index c2e7501..2230b3e 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -401,6 +401,7 @@
#define XSTATE_OPMASK (1ULL << 5)
#define XSTATE_ZMM_Hi256 (1ULL << 6)
#define XSTATE_Hi16_ZMM (1ULL << 7)
+#define XSTATE_PKRU (1ULL << 9)
/* CPUID feature words */
@@ -984,6 +985,8 @@ typedef struct CPUX86State {
uint64_t xcr0;
uint64_t xss;
+ uint32_t pkru;
+
TPRAccess tpr_access_type;
} CPUX86State;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 066d03d..12164a6 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -1092,6 +1092,7 @@ static int kvm_put_fpu(X86CPU *cpu)
#define XSAVE_OPMASK 272
#define XSAVE_ZMM_Hi256 288
#define XSAVE_Hi16_ZMM 416
+#define XSAVE_PKRU 672
static int kvm_put_xsave(X86CPU *cpu)
{
@@ -1145,6 +1146,7 @@ static int kvm_put_xsave(X86CPU *cpu)
#ifdef TARGET_X86_64
memcpy(&xsave->region[XSAVE_Hi16_ZMM], &env->xmm_regs[16],
16 * sizeof env->xmm_regs[16]);
+ memcpy(&xsave->region[XSAVE_PKRU], &env->pkru, sizeof env->pkru);
#endif
r = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave);
return r;
@@ -1516,6 +1518,7 @@ static int kvm_get_xsave(X86CPU *cpu)
#ifdef TARGET_X86_64
memcpy(&env->xmm_regs[16], &xsave->region[XSAVE_Hi16_ZMM],
16 * sizeof env->xmm_regs[16]);
+ memcpy(&xsave->region[XSAVE_PKRU], &env->pkru, sizeof env->pkru);
#endif
return 0;
}
--
2.4.3
next prev parent reply other threads:[~2015-11-09 11:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 11:55 [Qemu-devel] [PATCH 0/3] qemu, pkeys: add memory protection-key support Huaitong Han
2015-11-09 11:55 ` [Qemu-devel] [PATCH 1/3] qemu, pkeys: add pkeys support for qemu cpuid handling Huaitong Han
2015-11-09 12:24 ` Paolo Bonzini
2015-11-09 15:19 ` Andreas Färber
2015-11-09 11:55 ` Huaitong Han [this message]
2015-11-09 18:49 ` [Qemu-devel] [PATCH 2/3] qemu, pkeys: add pkeys support for qemu xsave state handling Eduardo Habkost
2015-11-09 11:55 ` [Qemu-devel] [PATCH 3/3] qemu, pkeys: add pkeys support for qemu migration Huaitong Han
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=1447070134-4324-3-git-send-email-huaitong.han@intel.com \
--to=huaitong.han@intel.com \
--cc=afaerber@suse.de \
--cc=ehabkost@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).