mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 16:53:55 -06:00
target-i386: Add NPT support
This implements NPT suport for SVM by hooking into x86_cpu_handle_mmu_fault where it reads the stage-1 page table. Whether we need to perform this 2nd stage translation, and how, is decided during vmrun and stored in hflags2, along with nested_cr3 and nested_pg_mode. As get_hphys performs a direct cpu_vmexit in case of NPT faults, we need retaddr in that function. To avoid changing the signature of cpu_handle_mmu_fault, this passes the value from tlb_fill to get_hphys via the CPU state. This was tested successfully via the Jailhouse hypervisor. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Message-Id: <567473a0-6005-5843-4c73-951f476085ca@web.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
76b004d10d
commit
fe441054bb
7 changed files with 281 additions and 6 deletions
|
@ -935,6 +935,26 @@ static const VMStateDescription vmstate_msr_virt_ssbd = {
|
|||
}
|
||||
};
|
||||
|
||||
static bool svm_npt_needed(void *opaque)
|
||||
{
|
||||
X86CPU *cpu = opaque;
|
||||
CPUX86State *env = &cpu->env;
|
||||
|
||||
return !!(env->hflags2 & HF2_NPT_MASK);
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_svm_npt = {
|
||||
.name = "cpu/svn_npt",
|
||||
.version_id = 1,
|
||||
.minimum_version_id = 1,
|
||||
.needed = svm_npt_needed,
|
||||
.fields = (VMStateField[]){
|
||||
VMSTATE_UINT64(env.nested_cr3, X86CPU),
|
||||
VMSTATE_UINT32(env.nested_pg_mode, X86CPU),
|
||||
VMSTATE_END_OF_LIST()
|
||||
}
|
||||
};
|
||||
|
||||
VMStateDescription vmstate_x86_cpu = {
|
||||
.name = "cpu",
|
||||
.version_id = 12,
|
||||
|
@ -1059,6 +1079,7 @@ VMStateDescription vmstate_x86_cpu = {
|
|||
&vmstate_mcg_ext_ctl,
|
||||
&vmstate_msr_intel_pt,
|
||||
&vmstate_msr_virt_ssbd,
|
||||
&vmstate_svm_npt,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue