a11c33863f
5281fad4-numa-sched-leave-node-affinity-alone-if-not-in-auto-mode.patch 52820823-nested-SVM-adjust-guest-handling-of-structure-mappings.patch 52820863-VMX-don-t-crash-processing-d-debug-key.patch 5282492f-x86-eliminate-has_arch_mmios.patch 52864df2-credit-Update-other-parameters-when-setting-tslice_ms.patch 52864f30-fix-leaking-of-v-cpu_affinity_saved-on-domain-destruction.patch 5289d225-nested-VMX-don-t-ignore-mapping-errors.patch 528a0eb0-x86-consider-modules-when-cutting-off-memory.patch 528f606c-x86-hvm-reset-TSC-to-0-after-domain-resume-from-S3.patch 528f609c-x86-crash-disable-the-watchdog-NMIs-on-the-crashing-cpu.patch 52932418-x86-xsave-fix-nonlazy-state-handling.patch - Add missing requires to pciutils package for xend-tools - bnc#851749 - Xen service file does not call xend properly xend.service - bnc#851386 - VUL-0: xen: XSA-78: Insufficient TLB flushing in VT-d (iommu) code 528a0e5b-TLB-flushing-in-dma_pte_clear_one.patch - bnc#849667 - VUL-0: xen: XSA-74: Lock order reversal between page_alloc_lock and mm_rwlock CVE-2013-4553-xsa74.patch - bnc#849665 - VUL-0: CVE-2013-4551: xen: XSA-75: Host crash due to guest VMX instruction execution 52809208-nested-VMX-VMLANUCH-VMRESUME-emulation-must-check-permission-1st.patch - bnc#849668 - VUL-0: xen: XSA-76: Hypercalls exposed to privilege rings 1 and 2 of HVM guests OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=279
133 lines
4.4 KiB
Diff
133 lines
4.4 KiB
Diff
# Commit b1e87805bf37b446dade93a7eb922bb7d1269756
|
|
# Date 2013-11-12 11:51:15 +0100
|
|
# Author Jan Beulich <jbeulich@suse.com>
|
|
# Committer Jan Beulich <jbeulich@suse.com>
|
|
nested SVM: adjust guest handling of structure mappings
|
|
|
|
For one, nestedsvm_vmcb_map() error checking must not consist of using
|
|
assertions: Global (permanent) mappings can fail, and hence failure
|
|
needs to be dealt with properly. And non-global (transient) mappings
|
|
can't fail anyway.
|
|
|
|
And then the I/O port access bitmap handling was broken: It checked
|
|
only to first of the accessed ports rather than each of them.
|
|
|
|
Signed-off-by: Jan Beulich <jbeulich@suse.com>
|
|
Reviewed-by: Christoph Egger <chegger@amazon.de>
|
|
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
Acked-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
|
|
|
|
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
|
|
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
|
|
@@ -342,7 +342,7 @@ static int nsvm_vmrun_permissionmap(stru
|
|
unsigned int i;
|
|
enum hvm_copy_result ret;
|
|
unsigned long *ns_viomap;
|
|
- bool_t ioport_80, ioport_ed;
|
|
+ bool_t ioport_80 = 1, ioport_ed = 1;
|
|
|
|
ns_msrpm_ptr = (unsigned long *)svm->ns_cached_msrpm;
|
|
|
|
@@ -360,10 +360,12 @@ static int nsvm_vmrun_permissionmap(stru
|
|
svm->ns_iomap_pa = ns_vmcb->_iopm_base_pa;
|
|
|
|
ns_viomap = hvm_map_guest_frame_ro(svm->ns_iomap_pa >> PAGE_SHIFT, 0);
|
|
- ASSERT(ns_viomap != NULL);
|
|
- ioport_80 = test_bit(0x80, ns_viomap);
|
|
- ioport_ed = test_bit(0xed, ns_viomap);
|
|
- hvm_unmap_guest_frame(ns_viomap, 0);
|
|
+ if ( ns_viomap )
|
|
+ {
|
|
+ ioport_80 = test_bit(0x80, ns_viomap);
|
|
+ ioport_ed = test_bit(0xed, ns_viomap);
|
|
+ hvm_unmap_guest_frame(ns_viomap, 0);
|
|
+ }
|
|
|
|
svm->ns_iomap = nestedhvm_vcpu_iomap_get(ioport_80, ioport_ed);
|
|
|
|
@@ -866,40 +868,45 @@ nsvm_vmcb_guest_intercepts_msr(unsigned
|
|
static int
|
|
nsvm_vmcb_guest_intercepts_ioio(paddr_t iopm_pa, uint64_t exitinfo1)
|
|
{
|
|
- unsigned long iopm_gfn = iopm_pa >> PAGE_SHIFT;
|
|
- unsigned long *io_bitmap = NULL;
|
|
+ unsigned long gfn = iopm_pa >> PAGE_SHIFT;
|
|
+ unsigned long *io_bitmap;
|
|
ioio_info_t ioinfo;
|
|
uint16_t port;
|
|
+ unsigned int size;
|
|
bool_t enabled;
|
|
- unsigned long gfn = 0; /* gcc ... */
|
|
|
|
ioinfo.bytes = exitinfo1;
|
|
port = ioinfo.fields.port;
|
|
+ size = ioinfo.fields.sz32 ? 4 : ioinfo.fields.sz16 ? 2 : 1;
|
|
|
|
- switch (port) {
|
|
- case 0 ... 32767: /* first 4KB page */
|
|
- gfn = iopm_gfn;
|
|
+ switch ( port )
|
|
+ {
|
|
+ case 0 ... 8 * PAGE_SIZE - 1: /* first 4KB page */
|
|
break;
|
|
- case 32768 ... 65535: /* second 4KB page */
|
|
- port -= 32768;
|
|
- gfn = iopm_gfn + 1;
|
|
+ case 8 * PAGE_SIZE ... 2 * 8 * PAGE_SIZE - 1: /* second 4KB page */
|
|
+ port -= 8 * PAGE_SIZE;
|
|
+ ++gfn;
|
|
break;
|
|
default:
|
|
BUG();
|
|
break;
|
|
}
|
|
|
|
- io_bitmap = hvm_map_guest_frame_ro(gfn, 0);
|
|
- if (io_bitmap == NULL) {
|
|
- gdprintk(XENLOG_ERR,
|
|
- "IOIO intercept: mapping of permission map failed\n");
|
|
- return NESTEDHVM_VMEXIT_ERROR;
|
|
+ for ( io_bitmap = hvm_map_guest_frame_ro(gfn, 0); ; )
|
|
+ {
|
|
+ enabled = io_bitmap && test_bit(port, io_bitmap);
|
|
+ if ( !enabled || !--size )
|
|
+ break;
|
|
+ if ( unlikely(++port == 8 * PAGE_SIZE) )
|
|
+ {
|
|
+ hvm_unmap_guest_frame(io_bitmap, 0);
|
|
+ io_bitmap = hvm_map_guest_frame_ro(++gfn, 0);
|
|
+ port -= 8 * PAGE_SIZE;
|
|
+ }
|
|
}
|
|
-
|
|
- enabled = test_bit(port, io_bitmap);
|
|
hvm_unmap_guest_frame(io_bitmap, 0);
|
|
|
|
- if (!enabled)
|
|
+ if ( !enabled )
|
|
return NESTEDHVM_VMEXIT_HOST;
|
|
|
|
return NESTEDHVM_VMEXIT_INJECT;
|
|
@@ -966,8 +973,8 @@ nsvm_vmcb_guest_intercepts_exitcode(stru
|
|
switch (exitcode) {
|
|
case VMEXIT_MSR:
|
|
ASSERT(regs != NULL);
|
|
- nestedsvm_vmcb_map(v, nv->nv_vvmcxaddr);
|
|
- ASSERT(nv->nv_vvmcx != NULL);
|
|
+ if ( !nestedsvm_vmcb_map(v, nv->nv_vvmcxaddr) )
|
|
+ break;
|
|
ns_vmcb = nv->nv_vvmcx;
|
|
vmexits = nsvm_vmcb_guest_intercepts_msr(svm->ns_cached_msrpm,
|
|
regs->ecx, ns_vmcb->exitinfo1 != 0);
|
|
@@ -975,8 +982,8 @@ nsvm_vmcb_guest_intercepts_exitcode(stru
|
|
return 0;
|
|
break;
|
|
case VMEXIT_IOIO:
|
|
- nestedsvm_vmcb_map(v, nv->nv_vvmcxaddr);
|
|
- ASSERT(nv->nv_vvmcx != NULL);
|
|
+ if ( !nestedsvm_vmcb_map(v, nv->nv_vvmcxaddr) )
|
|
+ break;
|
|
ns_vmcb = nv->nv_vvmcx;
|
|
vmexits = nsvm_vmcb_guest_intercepts_ioio(ns_vmcb->_iopm_base_pa,
|
|
ns_vmcb->exitinfo1);
|