[COMMIT master] Merge branch 'upstream-merge'
From: Marcelo Tosatti mtosa...@redhat.com * upstream-merge: (108 commits) Add cpu model configuration support.. add close callback for tty-based char device Fix lost serial TX interrupts. Report receive overruns. tcg/ppc: Fix typo apc_pci: simplify using rwhandler apb_pci: minor cleanup Update OpenBIOS images to r683 Fix arm-softmmu compile tcg/ppc64: Use C90 style comments tcg/ppc: Implement some of the optional ops tcg: fix build on 32-bit hppa, ppc and sparc hosts PL181 write fix kvm: consume internal signal with sigtimedwait kvm specific wait_io_event block SIGCHLD in vcpu thread(s) Allow const QemuOptDesc kvm: Kill CR3_CACHE feature references kvm: Fix eflags corruption in kvm mode cris: Add CRISv10 gdbstub support. cris: Mask interrupts on dslots for CRISv10. ... Signed-off-by: Marcelo Tosatti mtosa...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] Merge commit 'v2.6.33'
From: Avi Kivity a...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Check for nested intercepts on NMI injection
From: Joerg Roedel joerg.roe...@amd.com This patch implements the NMI intercept checking for nested svm. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index b821b2f..7773cea 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1480,6 +1480,21 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm) return true; } +/* This function returns true if it is save to enable the nmi window */ +static inline bool nested_svm_nmi(struct vcpu_svm *svm) +{ + if (!is_nested(svm)) + return true; + + if (!(svm-nested.intercept (1ULL INTERCEPT_NMI))) + return true; + + svm-vmcb-control.exit_code = SVM_EXIT_NMI; + svm-nested.exit_required = true; + + return false; +} + static void *nested_svm_map(struct vcpu_svm *svm, u64 gpa, struct page **_page) { struct page *page; @@ -2681,9 +2696,11 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) * Something prevents NMI from been injected. Single step over possible * problem (IRET or exception injection or interrupt shadow) */ - svm-nmi_singlestep = true; - svm-vmcb-save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); - update_db_intercept(vcpu); + if (gif_set(svm) nested_svm_nmi(svm)) { + svm-nmi_singlestep = true; + svm-vmcb-save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); + update_db_intercept(vcpu); + } } static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr) -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Reset MMU on nested_svm_vmrun for NPT too
From: Joerg Roedel joerg.roe...@amd.com Without resetting the MMU the gva_to_pga function will not work reliably when the vcpu is running in nested context. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 217b8b0..b821b2f 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1871,10 +1871,12 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) if (npt_enabled) { svm-vmcb-save.cr3 = nested_vmcb-save.cr3; svm-vcpu.arch.cr3 = nested_vmcb-save.cr3; - } else { + } else kvm_set_cr3(svm-vcpu, nested_vmcb-save.cr3); - kvm_mmu_reset_context(svm-vcpu); - } + + /* Guest paging mode is active - reset mmu */ + kvm_mmu_reset_context(svm-vcpu); + svm-vmcb-save.cr2 = svm-vcpu.arch.cr2 = nested_vmcb-save.cr2; kvm_register_write(svm-vcpu, VCPU_REGS_RAX, nested_vmcb-save.rax); kvm_register_write(svm-vcpu, VCPU_REGS_RSP, nested_vmcb-save.rsp); -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Restore tracing of nested vmcb address
From: Joerg Roedel joerg.roe...@amd.com A recent change broke tracing of the nested vmcb address. It was reported as 0 all the time. This patch fixes it. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 7773cea..30a386a 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1833,7 +1833,7 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) if (!nested_vmcb) return false; - trace_kvm_nested_vmrun(svm-vmcb-save.rip - 3, svm-nested.vmcb, + trace_kvm_nested_vmrun(svm-vmcb-save.rip - 3, vmcb_gpa, nested_vmcb-save.rip, nested_vmcb-control.int_ctl, nested_vmcb-control.event_inj, -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Coding style cleanup
From: Joerg Roedel joerg.roe...@amd.com This patch removes whitespace errors, fixes comment formats and most of checkpatch warnings. Now vim does not show c-space-errors anymore. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d11ff46..217b8b0 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -119,7 +119,7 @@ struct vcpu_svm { #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) static bool npt_enabled = true; #else -static bool npt_enabled = false; +static bool npt_enabled; #endif static int npt = 1; @@ -167,8 +167,8 @@ static unsigned long iopm_base; struct kvm_ldttss_desc { u16 limit0; u16 base0; - unsigned base1 : 8, type : 5, dpl : 2, p : 1; - unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8; + unsigned base1:8, type:5, dpl:2, p:1; + unsigned limit1:4, zero0:3, g:1, base2:8; u32 base3; u32 zero1; } __attribute__((packed)); @@ -217,7 +217,7 @@ static inline void stgi(void) static inline void invlpga(unsigned long addr, u32 asid) { - asm volatile (__ex(SVM_INVLPGA) :: a(addr), c(asid)); + asm volatile (__ex(SVM_INVLPGA) : : a(addr), c(asid)); } static inline void force_new_asid(struct kvm_vcpu *vcpu) @@ -289,8 +289,10 @@ static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, { struct vcpu_svm *svm = to_svm(vcpu); - /* If we are within a nested VM we'd better #VMEXIT and let the - guest handle the exception */ + /* +* If we are within a nested VM we'd better #VMEXIT and let the guest +* handle the exception +*/ if (nested_svm_check_exception(svm, nr, has_error_code, error_code)) return; @@ -543,7 +545,7 @@ static void init_seg(struct vmcb_seg *seg) { seg-selector = 0; seg-attrib = SVM_SELECTOR_P_MASK | SVM_SELECTOR_S_MASK | - SVM_SELECTOR_WRITE_MASK; /* Read/Write Data Segment */ + SVM_SELECTOR_WRITE_MASK; /* Read/Write Data Segment */ seg-limit = 0x; seg-base = 0; } @@ -563,16 +565,16 @@ static void init_vmcb(struct vcpu_svm *svm) svm-vcpu.fpu_active = 1; - control-intercept_cr_read =INTERCEPT_CR0_MASK | + control-intercept_cr_read =INTERCEPT_CR0_MASK | INTERCEPT_CR3_MASK | INTERCEPT_CR4_MASK; - control-intercept_cr_write = INTERCEPT_CR0_MASK | + control-intercept_cr_write = INTERCEPT_CR0_MASK | INTERCEPT_CR3_MASK | INTERCEPT_CR4_MASK | INTERCEPT_CR8_MASK; - control-intercept_dr_read =INTERCEPT_DR0_MASK | + control-intercept_dr_read =INTERCEPT_DR0_MASK | INTERCEPT_DR1_MASK | INTERCEPT_DR2_MASK | INTERCEPT_DR3_MASK | @@ -581,7 +583,7 @@ static void init_vmcb(struct vcpu_svm *svm) INTERCEPT_DR6_MASK | INTERCEPT_DR7_MASK; - control-intercept_dr_write = INTERCEPT_DR0_MASK | + control-intercept_dr_write = INTERCEPT_DR0_MASK | INTERCEPT_DR1_MASK | INTERCEPT_DR2_MASK | INTERCEPT_DR3_MASK | @@ -595,7 +597,7 @@ static void init_vmcb(struct vcpu_svm *svm) (1 MC_VECTOR); - control-intercept =(1ULL INTERCEPT_INTR) | + control-intercept =(1ULL INTERCEPT_INTR) | (1ULL INTERCEPT_NMI) | (1ULL INTERCEPT_SMI) | (1ULL INTERCEPT_SELECTIVE_CR0) | @@ -656,7 +658,8 @@ static void init_vmcb(struct vcpu_svm *svm) save-rip = 0xfff0; svm-vcpu.arch.regs[VCPU_REGS_RIP] = save-rip; - /* This is the guest-visible cr0 value. + /* +* This is the guest-visible cr0 value. * svm_set_cr0() sets PG and WP and clears NW and CD on save-cr0. */ svm-vcpu.arch.cr0 = X86_CR0_NW | X86_CR0_CD | X86_CR0_ET; @@ -897,7 +900,8 @@ static void svm_get_segment(struct kvm_vcpu *vcpu, var-db = (s-attrib SVM_SELECTOR_DB_SHIFT) 1; var-g = (s-attrib SVM_SELECTOR_G_SHIFT) 1; - /* AMD's VMCB does not have an explicit unusable field, so emulate it + /* +* AMD's VMCB does not have an explicit unusable field, so emulate it * for cross vendor migration purposes by not present */ var-unusable = !var-present || (var-type == 0); @@ -933,7 +937,8 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
[COMMIT master] KVM: SVM: Add kvm_nested_intercepts tracepoint
From: Joerg Roedel joerg.roe...@amd.com This patch adds a tracepoint to get information about the most important intercept bitmasks from the nested vmcb. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 30a386a..1e68e56 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1839,6 +1839,11 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) nested_vmcb-control.event_inj, nested_vmcb-control.nested_ctl); + trace_kvm_nested_intercepts(nested_vmcb-control.intercept_cr_read, + nested_vmcb-control.intercept_cr_write, + nested_vmcb-control.intercept_exceptions, + nested_vmcb-control.intercept); + /* Clear internal status */ kvm_clear_exception_queue(svm-vcpu); kvm_clear_interrupt_queue(svm-vcpu); diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h index 12f8d2d..17b52cc 100644 --- a/arch/x86/kvm/trace.h +++ b/arch/x86/kvm/trace.h @@ -419,6 +419,28 @@ TRACE_EVENT(kvm_nested_vmrun, __entry-npt ? on : off) ); +TRACE_EVENT(kvm_nested_intercepts, + TP_PROTO(__u16 cr_read, __u16 cr_write, __u32 exceptions, __u64 intercept), + TP_ARGS(cr_read, cr_write, exceptions, intercept), + + TP_STRUCT__entry( + __field(__u16, cr_read ) + __field(__u16, cr_write) + __field(__u32, exceptions ) + __field(__u64, intercept ) + ), + + TP_fast_assign( + __entry-cr_read= cr_read; + __entry-cr_write = cr_write; + __entry-exceptions = exceptions; + __entry-intercept = intercept; + ), + + TP_printk(cr_read: %04x cr_write: %04x excp: %08x intercept: %016llx, + __entry-cr_read, __entry-cr_write, __entry-exceptions, + __entry-intercept) +); /* * Tracepoint for #VMEXIT while nested */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 7b436c8..2c24cb5 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5924,3 +5924,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_vmexit_inject); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_intr_vmexit); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_invlpga); EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_skinit); +EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_nested_intercepts); -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Ignore write of hwcr.ignne
From: Joerg Roedel joerg.roe...@amd.com Hyper-V as a guest wants to write this bit. This patch ignores it. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2c24cb5..31d44c1 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1112,6 +1112,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data) break; case MSR_K7_HWCR: data = ~(u64)0x40; /* ignore flush filter disable */ + data = ~(u64)0x100;/* ignore ignne emulation enable */ if (data != 0) { pr_unimpl(vcpu, unimplemented HWCR wrmsr: 0x%llx\n, data); -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Clear exit_info for injected INTR exits
From: Joerg Roedel joerg.roe...@amd.com When injecting an vmexit.intr into the nested hypervisor there might be leftover values in the exit_info fields. Clear them to not confuse nested hypervisors. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2b987f2..df6f491 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1485,7 +1485,9 @@ static inline bool nested_svm_intr(struct vcpu_svm *svm) if (!(svm-vcpu.arch.hflags HF_HIF_MASK)) return false; - svm-vmcb-control.exit_code = SVM_EXIT_INTR; + svm-vmcb-control.exit_code = SVM_EXIT_INTR; + svm-vmcb-control.exit_info_1 = 0; + svm-vmcb-control.exit_info_2 = 0; if (svm-nested.intercept 1ULL) { /* -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: SVM: Handle nested selective_cr0 intercept correctly
From: Joerg Roedel joerg.roe...@amd.com If we have the following situation with nested svm: 1. Host KVM intercepts cr0 writes 2. Guest hypervisor intercepts only selective cr0 writes Then we get an cr0 write intercept which is handled on the host. But that intercepts may actually be a selective cr0 intercept for the guest. This patch checks for this condition and injects a selective cr0 intercept if needed. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index e3b53dc..2b987f2 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1037,6 +1037,27 @@ static void svm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) { struct vcpu_svm *svm = to_svm(vcpu); + if (is_nested(svm)) { + /* +* We are here because we run in nested mode, the host kvm +* intercepts cr0 writes but the l1 hypervisor does not. +* But the L1 hypervisor may intercept selective cr0 writes. +* This needs to be checked here. +*/ + unsigned long old, new; + + /* Remove bits that would trigger a real cr0 write intercept */ + old = vcpu-arch.cr0 SVM_CR0_SELECTIVE_MASK; + new = cr0 SVM_CR0_SELECTIVE_MASK; + + if (old == new) { + /* cr0 write with ts and mp unchanged */ + svm-vmcb-control.exit_code = SVM_EXIT_CR0_SEL_WRITE; + if (nested_svm_exit_handled(svm) == NESTED_EXIT_DONE) + return; + } + } + #ifdef CONFIG_X86_64 if (vcpu-arch.efer EFER_LME) { if (!is_paging(vcpu) (cr0 X86_CR0_PG)) { -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: update gfn_to_hva() to use gfn_to_hva_memslot()
From: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp Marcelo introduced gfn_to_hva_memslot() when he implemented gfn_to_pfn_memslot(). Let's use this for gfn_to_hva() too. Note: also remove parentheses next to return as checkpatch said to do. Signed-off-by: Takuya Yoshikawa yoshikawa.tak...@oss.ntt.co.jp Signed-off-by: Avi Kivity a...@redhat.com diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 548f925..e758ef7 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -910,6 +910,11 @@ int memslot_id(struct kvm *kvm, gfn_t gfn) return memslot - slots-memslots; } +static unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn) +{ + return slot-userspace_addr + (gfn - slot-base_gfn) * PAGE_SIZE; +} + unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn) { struct kvm_memory_slot *slot; @@ -918,7 +923,7 @@ unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn) slot = gfn_to_memslot_unaliased(kvm, gfn); if (!slot || slot-flags KVM_MEMSLOT_INVALID) return bad_hva(); - return (slot-userspace_addr + (gfn - slot-base_gfn) * PAGE_SIZE); + return gfn_to_hva_memslot(slot, gfn); } EXPORT_SYMBOL_GPL(gfn_to_hva); @@ -968,11 +973,6 @@ pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn) } EXPORT_SYMBOL_GPL(gfn_to_pfn); -static unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn) -{ - return (slot-userspace_addr + (gfn - slot-base_gfn) * PAGE_SIZE); -} - pfn_t gfn_to_pfn_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, gfn_t gfn) { -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: x86: Don't set arch.cr0 in kvm_set_cr0
From: Joerg Roedel joerg.roe...@amd.com The vcpu-arch.cr0 variable is already set in the architecture specific set_cr0 callbacks. There is no need to set it in the common code. This allows the architecture code to keep the old arch.cr0 value if it wants. This is required for nested svm to decide if a selective_cr0 exit needs to be injected. Signed-off-by: Joerg Roedel joerg.roe...@amd.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 31d44c1..a81046b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -485,7 +485,6 @@ void kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) } kvm_x86_ops-set_cr0(vcpu, cr0); - vcpu-arch.cr0 = cr0; kvm_mmu_reset_context(vcpu); return; -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: x86 emulator: Add decoding of 16bit second in memory argument
From: Gleb Natapov g...@redhat.com Add decoding of Ep type of argument used by callf/jmpf. Signed-off-by: Gleb Natapov g...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index c9f604b..97a7403 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -85,6 +85,9 @@ #define Src2ImmByte (229) #define Src2One (329) #define Src2Imm16 (429) +#define Src2Mem16 (529) /* Used for Ep encoding. First argument has to be + in memory and second argument is located + immediately after the first one in memory. */ #define Src2Mask(729) enum { @@ -1163,6 +1166,10 @@ done_prefixes: c-src2.bytes = 1; c-src2.val = 1; break; + case Src2Mem16: + c-src2.bytes = 2; + c-src2.type = OP_MEM; + break; } /* Decode and fetch the destination operand: register or memory. */ @@ -1881,6 +1888,17 @@ x86_emulate_insn(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) c-src.orig_val = c-src.val; } + if (c-src2.type == OP_MEM) { + c-src2.ptr = (unsigned long *)(memop + c-src.bytes); + c-src2.val = 0; + rc = ops-read_emulated((unsigned long)c-src2.ptr, + c-src2.val, + c-src2.bytes, + ctxt-vcpu); + if (rc != X86EMUL_CONTINUE) + goto done; + } + if ((c-d DstMask) == ImplicitOps) goto special_insn; -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: Drop kvm_get_gdt() in favor of generic linux function
From: Gleb Natapov g...@redhat.com Linux now has native_store_gdt() to do the same. Use it instead of kvm local version. Signed-off-by: Gleb Natapov g...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 502fff1..e316722 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -723,11 +723,6 @@ static inline void kvm_get_idt(struct desc_ptr *table) asm(sidt %0 : =m(*table)); } -static inline void kvm_get_gdt(struct desc_ptr *table) -{ - asm(sgdt %0 : =m(*table)); -} - static inline unsigned long kvm_read_tr_base(void) { u16 tr; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index df6f491..1397877 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -367,7 +367,7 @@ static int svm_hardware_enable(void *garbage) sd-max_asid = cpuid_ebx(SVM_CPUID_FUNC) - 1; sd-next_asid = sd-max_asid + 1; - kvm_get_gdt(gdt_descr); + native_store_gdt(gdt_descr); gdt = (struct desc_struct *)gdt_descr.address; sd-tss_desc = (struct kvm_ldttss_desc *)(gdt + GDT_ENTRY_TSS); diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d772476..fa48e8c 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -600,7 +600,7 @@ static void reload_tss(void) struct desc_ptr gdt; struct desc_struct *descs; - kvm_get_gdt(gdt); + native_store_gdt(gdt); descs = (void *)gdt.address; descs[GDT_ENTRY_TSS].type = 9; /* available TSS */ load_TR_desc(); @@ -764,7 +764,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) * processors. */ vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */ - kvm_get_gdt(dt); + native_store_gdt(dt); vmcs_writel(HOST_GDTR_BASE, dt.address); /* 22.2.4 */ rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a81046b..5e20805 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -232,7 +232,7 @@ unsigned long segment_base(u16 selector) if (selector == 0) return 0; - kvm_get_gdt(gdt); + native_store_gdt(gdt); table_base = gdt.address; if (selector 4) { /* from ldt */ -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[COMMIT master] KVM: fix segment_base() error checking
From: Gleb Natapov g...@redhat.com fix segment_base() to properly check for null segment selector and avoid accessing NULL pointer if ldt selector in null. Signed-off-by: Gleb Natapov g...@redhat.com Signed-off-by: Avi Kivity a...@redhat.com diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5e20805..d5e8437 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -229,7 +229,7 @@ unsigned long segment_base(u16 selector) unsigned long table_base; unsigned long v; - if (selector == 0) + if (!(selector ~3)) return 0; native_store_gdt(gdt); @@ -238,6 +238,8 @@ unsigned long segment_base(u16 selector) if (selector 4) { /* from ldt */ u16 ldt_selector = kvm_read_ldt(); + if (!(ldt_selector ~3)) + return 0; table_base = segment_base(ldt_selector); } d = (struct desc_struct *)(table_base + (selector ~7)); -- To unsubscribe from this list: send the line unsubscribe kvm-commits in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html