diff options
| author | mgorny <mgorny@NetBSD.org> | 2020-10-24 07:14:29 +0000 |
|---|---|---|
| committer | mgorny <mgorny@NetBSD.org> | 2020-10-24 07:14:29 +0000 |
| commit | d1c7a51dbc4495f09e6fd121b6ec87ce7fb76fbc (patch) | |
| tree | 9a33b11bda02f97ed347c9f3a465839d50864730 /sys/dev | |
| parent | dbc8789c7a28eacf97f6bfc082d7cbe9061a6bd3 (diff) | |
Issue 64-bit versions of *XSAVE* for 64-bit amd64 programs
When calling FXSAVE, XSAVE, FXRSTOR, ... for 64-bit programs on amd64
use the 64-suffixed variant in order to include the complete FIP/FDP
registers in the x87 area.
The difference between the two variants is that the FXSAVE64 (new)
variant represents FIP/FDP as 64-bit fields (union fp_addr.fa_64),
while the legacy FXSAVE variant uses split fields: 32-bit offset,
16-bit segment and 16-bit reserved field (union fp_addr.fa_32).
The latter implies that the actual addresses are truncated to 32 bits
which is insufficient in modern programs.
The change is applied only to 64-bit programs on amd64. Plain i386
and compat32 continue using plain FXSAVE. Similarly, NVMM is not
changed as I am not familiar with that code.
This is a potentially breaking change. However, I don't think it likely
to actually break anything because the data provided by the old variant
were not meaningful (because of the truncated pointer).
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/nvmm/x86/nvmm_x86_svm.c | 10 | ||||
| -rw-r--r-- | sys/dev/nvmm/x86/nvmm_x86_vmx.c | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/sys/dev/nvmm/x86/nvmm_x86_svm.c b/sys/dev/nvmm/x86/nvmm_x86_svm.c index 1dab0b27c7b..d5dd8504d8e 100644 --- a/sys/dev/nvmm/x86/nvmm_x86_svm.c +++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.81 2020/09/08 17:02:03 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.82 2020/10/24 07:14:30 mgorny Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.81 2020/09/08 17:02:03 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.82 2020/10/24 07:14:30 mgorny Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1351,7 +1351,8 @@ svm_vcpu_guest_fpu_enter(struct nvmm_cpu *vcpu) struct svm_cpudata *cpudata = vcpu->cpudata; fpu_kern_enter(); - fpu_area_restore(&cpudata->gfpu, svm_xcr0_mask); + /* TODO: should we use *XSAVE64 here? */ + fpu_area_restore(&cpudata->gfpu, svm_xcr0_mask, false); if (svm_xcr0_mask != 0) { cpudata->hxcr0 = rdxcr(0); @@ -1369,7 +1370,8 @@ svm_vcpu_guest_fpu_leave(struct nvmm_cpu *vcpu) wrxcr(0, cpudata->hxcr0); } - fpu_area_save(&cpudata->gfpu, svm_xcr0_mask); + /* TODO: should we use *XSAVE64 here? */ + fpu_area_save(&cpudata->gfpu, svm_xcr0_mask, false); fpu_kern_leave(); } diff --git a/sys/dev/nvmm/x86/nvmm_x86_vmx.c b/sys/dev/nvmm/x86/nvmm_x86_vmx.c index 852aadfd762..ce556e75928 100644 --- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c +++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.80 2020/09/08 17:02:03 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.81 2020/10/24 07:14:30 mgorny Exp $ */ /* * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.80 2020/09/08 17:02:03 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.81 2020/10/24 07:14:30 mgorny Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -2014,7 +2014,8 @@ vmx_vcpu_guest_fpu_enter(struct nvmm_cpu *vcpu) struct vmx_cpudata *cpudata = vcpu->cpudata; fpu_kern_enter(); - fpu_area_restore(&cpudata->gfpu, vmx_xcr0_mask); + /* TODO: should we use *XSAVE64 here? */ + fpu_area_restore(&cpudata->gfpu, vmx_xcr0_mask, false); if (vmx_xcr0_mask != 0) { cpudata->hxcr0 = rdxcr(0); @@ -2032,7 +2033,8 @@ vmx_vcpu_guest_fpu_leave(struct nvmm_cpu *vcpu) wrxcr(0, cpudata->hxcr0); } - fpu_area_save(&cpudata->gfpu, vmx_xcr0_mask); + /* TODO: should we use *XSAVE64 here? */ + fpu_area_save(&cpudata->gfpu, vmx_xcr0_mask, false); fpu_kern_leave(); } |
