* KVM: Miscellaneous updates
@ 2006-12-11 10:14 Avi Kivity
2006-12-11 10:15 ` [PATCH 1/5] KVM: Make the GET_SREGS and SET_SREGS ioctls symmetric Avi Kivity
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:14 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, Andrew Morton, Ingo Molnar
In today's episode:
- two old patches that were accidentally dropped (by me)
- a fix for CONFIG_PREEMPT
- an mmu fix to ignore the cache control bits provided by the guest
- a MAINTAINERS entry to point the finger at the perpetrators
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] KVM: Make the GET_SREGS and SET_SREGS ioctls symmetric
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
@ 2006-12-11 10:15 ` Avi Kivity
2006-12-11 10:16 ` [PATCH 2/5] KVM: Move find_vmx_entry() to vmx.c Avi Kivity
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:15 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
This makes the SET_SREGS ioctl behave symmetrically to the GET_SREGS
ioctl wrt the segment access rights flag.
From: Uri Lublin <uril@qumranet.com>
Signed-off-by: Uri Lublin <uril@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -884,6 +884,8 @@ static void vmx_set_segment(struct kvm_v
ar |= (var->db & 1) << 14;
ar |= (var->g & 1) << 15;
}
+ if (ar == 0) /* a 0 value means unusable */
+ ar = AR_UNUSABLE_MASK;
vmcs_write32(sf->ar_bytes, ar);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/5] KVM: Move find_vmx_entry() to vmx.c
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
2006-12-11 10:15 ` [PATCH 1/5] KVM: Make the GET_SREGS and SET_SREGS ioctls symmetric Avi Kivity
@ 2006-12-11 10:16 ` Avi Kivity
2006-12-11 10:17 ` [PATCH 3/5] KVM: Remove extranous put_cpu() from vcpu_put() Avi Kivity
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:16 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -72,17 +72,6 @@ static struct dentry *debugfs_dir;
#define CR8_RESEVED_BITS (~0x0fULL)
#define EFER_RESERVED_BITS 0xfffffffffffff2fe
-struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr)
-{
- int i;
-
- for (i = 0; i < vcpu->nmsrs; ++i)
- if (vcpu->guest_msrs[i].index == msr)
- return &vcpu->guest_msrs[i];
- return 0;
-}
-EXPORT_SYMBOL_GPL(find_msr_entry);
-
#ifdef CONFIG_X86_64
// LDT or TSS descriptor in the GDT. 16 bytes.
struct segment_descriptor_64 {
@@ -1124,8 +1113,6 @@ static int get_msr(struct kvm_vcpu *vcpu
void set_efer(struct kvm_vcpu *vcpu, u64 efer)
{
- struct vmx_msr_entry *msr;
-
if (efer & EFER_RESERVED_BITS) {
printk(KERN_DEBUG "set_efer: 0x%llx #GP, reserved bits\n",
efer);
@@ -1140,16 +1127,12 @@ void set_efer(struct kvm_vcpu *vcpu, u64
return;
}
+ kvm_arch_ops->set_efer(vcpu, efer);
+
efer &= ~EFER_LMA;
efer |= vcpu->shadow_efer & EFER_LMA;
vcpu->shadow_efer = efer;
-
- msr = find_msr_entry(vcpu, MSR_EFER);
-
- if (!(efer & EFER_LMA))
- efer &= ~EFER_LME;
- msr->data = efer;
}
EXPORT_SYMBOL_GPL(set_efer);
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -78,8 +78,6 @@ static const u32 vmx_msr_index[] = {
};
#define NR_VMX_MSR (sizeof(vmx_msr_index) / sizeof(*vmx_msr_index))
-struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr);
-
static inline int is_page_fault(u32 intr_info)
{
return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK |
@@ -93,6 +91,16 @@ static inline int is_external_interrupt(
== (INTR_TYPE_EXT_INTR | INTR_INFO_VALID_MASK);
}
+static struct vmx_msr_entry *find_msr_entry(struct kvm_vcpu *vcpu, u32 msr)
+{
+ int i;
+
+ for (i = 0; i < vcpu->nmsrs; ++i)
+ if (vcpu->guest_msrs[i].index == msr)
+ return &vcpu->guest_msrs[i];
+ return 0;
+}
+
static void vmcs_clear(struct vmcs *vmcs)
{
u64 phys_addr = __pa(vmcs);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/5] KVM: Remove extranous put_cpu() from vcpu_put()
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
2006-12-11 10:15 ` [PATCH 1/5] KVM: Make the GET_SREGS and SET_SREGS ioctls symmetric Avi Kivity
2006-12-11 10:16 ` [PATCH 2/5] KVM: Move find_vmx_entry() to vmx.c Avi Kivity
@ 2006-12-11 10:17 ` Avi Kivity
2006-12-11 10:18 ` [PATCH 4/5] KVM: MMU: Ignore pcd, pwt, and pat bits on ptes Avi Kivity
2006-12-11 10:19 ` [PATCH 5/5] KVM: Add MAINTAINERS entry Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:17 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
The arch splitting patchset left an extra put_cpu() in core code, where
it can cause trouble for CONFIG_PREEMPT kernels.
Reported by: Huihong Luo <huisinro@yahoo.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -205,7 +205,6 @@ static struct kvm_vcpu *vcpu_load(struct
static void vcpu_put(struct kvm_vcpu *vcpu)
{
kvm_arch_ops->vcpu_put(vcpu);
- put_cpu();
mutex_unlock(&vcpu->mutex);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/5] KVM: MMU: Ignore pcd, pwt, and pat bits on ptes
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
` (2 preceding siblings ...)
2006-12-11 10:17 ` [PATCH 3/5] KVM: Remove extranous put_cpu() from vcpu_put() Avi Kivity
@ 2006-12-11 10:18 ` Avi Kivity
2006-12-11 10:19 ` [PATCH 5/5] KVM: Add MAINTAINERS entry Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:18 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
The pcd, pwt, and pat bits on page table entries affect the cpu cache. Since
the cache is a host resource, the guest should not be able to control it.
Moreover, the meaning of these bits changes depending on whether pat is
enabled or not.
So, force these bits to zero on shadow page table entries at all times.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/drivers/kvm/mmu.c
===================================================================
--- linux-2.6.orig/drivers/kvm/mmu.c
+++ linux-2.6/drivers/kvm/mmu.c
@@ -61,22 +61,9 @@
#define PT32_PTE_COPY_MASK \
- (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \
- PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_PAT_MASK | \
- PT_GLOBAL_MASK )
-
-#define PT32_NON_PTE_COPY_MASK \
- (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK | \
- PT_ACCESSED_MASK | PT_DIRTY_MASK)
-
-
-#define PT64_PTE_COPY_MASK \
- (PT64_NX_MASK | PT32_PTE_COPY_MASK)
-
-#define PT64_NON_PTE_COPY_MASK \
- (PT64_NX_MASK | PT32_NON_PTE_COPY_MASK)
-
+ (PT_PRESENT_MASK | PT_ACCESSED_MASK | PT_DIRTY_MASK | PT_GLOBAL_MASK)
+#define PT64_PTE_COPY_MASK (PT64_NX_MASK | PT32_PTE_COPY_MASK)
#define PT_FIRST_AVAIL_BITS_SHIFT 9
#define PT64_SECOND_AVAIL_BITS_SHIFT 52
Index: linux-2.6/drivers/kvm/paging_tmpl.h
===================================================================
--- linux-2.6.orig/drivers/kvm/paging_tmpl.h
+++ linux-2.6/drivers/kvm/paging_tmpl.h
@@ -32,7 +32,6 @@
#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
#define PT_LEVEL_MASK(level) PT64_LEVEL_MASK(level)
#define PT_PTE_COPY_MASK PT64_PTE_COPY_MASK
- #define PT_NON_PTE_COPY_MASK PT64_NON_PTE_COPY_MASK
#elif PTTYPE == 32
#define pt_element_t u32
#define guest_walker guest_walker32
@@ -43,7 +42,6 @@
#define SHADOW_PT_INDEX(addr, level) PT64_INDEX(addr, level)
#define PT_LEVEL_MASK(level) PT32_LEVEL_MASK(level)
#define PT_PTE_COPY_MASK PT32_PTE_COPY_MASK
- #define PT_NON_PTE_COPY_MASK PT32_NON_PTE_COPY_MASK
#else
#error Invalid PTTYPE value
#endif
@@ -105,9 +103,7 @@ static void FNAME(set_pde)(struct kvm_vc
if (PTTYPE == 32 && is_cpuid_PSE36())
gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) <<
(32 - PT32_DIR_PSE36_SHIFT);
- *shadow_pte = (guest_pde & (PT_NON_PTE_COPY_MASK | PT_GLOBAL_MASK)) |
- ((guest_pde & PT_DIR_PAT_MASK) >>
- (PT_DIR_PAT_SHIFT - PT_PAT_SHIFT));
+ *shadow_pte = guest_pde & PT_PTE_COPY_MASK;
set_pte_common(vcpu, shadow_pte, gaddr,
guest_pde & PT_DIRTY_MASK, access_bits);
}
@@ -162,6 +158,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu
u32 index = SHADOW_PT_INDEX(addr, level);
u64 *shadow_ent = ((u64 *)__va(shadow_addr)) + index;
pt_element_t *guest_ent;
+ u64 shadow_pte;
if (is_present_pte(*shadow_ent) || is_io_pte(*shadow_ent)) {
if (level == PT_PAGE_TABLE_LEVEL)
@@ -204,14 +201,11 @@ static u64 *FNAME(fetch)(struct kvm_vcpu
shadow_addr = kvm_mmu_alloc_page(vcpu, shadow_ent);
if (!VALID_PAGE(shadow_addr))
return ERR_PTR(-ENOMEM);
- if (!kvm_arch_ops->is_long_mode(vcpu) && level == 3)
- *shadow_ent = shadow_addr |
- (*guest_ent & (PT_PRESENT_MASK | PT_PWT_MASK | PT_PCD_MASK));
- else {
- *shadow_ent = shadow_addr |
- (*guest_ent & PT_NON_PTE_COPY_MASK);
- *shadow_ent |= (PT_WRITABLE_MASK | PT_USER_MASK);
- }
+ shadow_pte = shadow_addr | PT_PRESENT_MASK;
+ if (vcpu->mmu.root_level > 3 || level != 3)
+ shadow_pte |= PT_ACCESSED_MASK
+ | PT_WRITABLE_MASK | PT_USER_MASK;
+ *shadow_ent = shadow_pte;
prev_shadow_ent = shadow_ent;
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 5/5] KVM: Add MAINTAINERS entry
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
` (3 preceding siblings ...)
2006-12-11 10:18 ` [PATCH 4/5] KVM: MMU: Ignore pcd, pwt, and pat bits on ptes Avi Kivity
@ 2006-12-11 10:19 ` Avi Kivity
4 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2006-12-11 10:19 UTC (permalink / raw)
To: kvm-devel; +Cc: linux-kernel, akpm, mingo
Signed-off-by: Avi Kivity <avi@qumranet.com>
Index: linux-2.6/MAINTAINERS
===================================================================
--- linux-2.6.orig/MAINTAINERS
+++ linux-2.6/MAINTAINERS
@@ -1745,6 +1745,13 @@ W: http://nfs.sourceforge.net/
W: http://www.cse.unsw.edu.au/~neilb/patches/linux-devel/
S: Maintained
+KERNEL VIRTUAL MACHINE (KVM)
+P: Avi Kivity
+M: avi@qumranet.com
+L: kvm-devel@lists.sourceforge.net
+W: kvm.sourceforge.net
+S: Supported
+
KEXEC
P: Eric Biederman
M: ebiederm@xmission.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-12-11 10:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-11 10:14 KVM: Miscellaneous updates Avi Kivity
2006-12-11 10:15 ` [PATCH 1/5] KVM: Make the GET_SREGS and SET_SREGS ioctls symmetric Avi Kivity
2006-12-11 10:16 ` [PATCH 2/5] KVM: Move find_vmx_entry() to vmx.c Avi Kivity
2006-12-11 10:17 ` [PATCH 3/5] KVM: Remove extranous put_cpu() from vcpu_put() Avi Kivity
2006-12-11 10:18 ` [PATCH 4/5] KVM: MMU: Ignore pcd, pwt, and pat bits on ptes Avi Kivity
2006-12-11 10:19 ` [PATCH 5/5] KVM: Add MAINTAINERS entry Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox