Re: [kvm-devel] [RFC/PATCH 01/15] preparation: provide hook to enable pgstes in user pagetable

2008-03-25 Thread Carsten Otte
Avi Kivity wrote:
 Well, dup_mm() can't work (and now that I think about it, for more 
 reasons -- what if the process has threads?).
We lock out multithreaded users already, -EINVAL.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 01/15] preparation: provide hook to enable pgstes in user pagetable

2008-03-25 Thread Avi Kivity
Carsten Otte wrote:
 Avi Kivity wrote:
 Well, dup_mm() can't work (and now that I think about it, for more 
 reasons -- what if the process has threads?).
 We lock out multithreaded users already, -EINVAL.


Would be much better if this can be avoided.  It's surprising.

-- 
Any sufficiently difficult bug is indistinguishable from a feature.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [GIT PULL] KVM fixes for 2.6.25-rc6

2008-03-25 Thread Avi Kivity
Linus, please pull from the repo and branch

  git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git for-linus

The patches fix a memory leak, ioperm() failures on unrelated processes
on the host, a locking issue, and a host crash when host userspace changes
the memory map.

Diffstat, shortlog and individual patches follow:

 arch/x86/kvm/mmu.c |   18 ++
 arch/x86/kvm/vmx.c |7 ++-
 2 files changed, 16 insertions(+), 9 deletions(-)

Avi Kivity (3):
  KVM: VMX: Restore tss even on x86_64
  KVM: MMU: Fix is_rmap_pte() with io ptes
  KVM: MMU: Fix memory leak on guest demand faults

Marcelo Tosatti (2):
  KVM: MMU: handle page removal with shadow mapping
  KVM: VMX: convert init_rmode_tss() to slots_lock

From 5dc832628229d2736fab10523566855c3cda622d Mon Sep 17 00:00:00 2001
From: Avi Kivity [EMAIL PROTECTED]
Date: Sun, 16 Mar 2008 18:48:26 +0200
Subject: [PATCH] KVM: VMX: Restore tss even on x86_64

The vmx hardware state restore restores the tss selector and base address, but
not its length.  Usually, this does not matter since most of the tss contents
is within the default length of 0x67.  However, if a process is using ioperm()
to grant itself I/O port permissions, an additional bitmap within the tss,
but outside the default length is consulted.  The effect is that the process
will receive a SIGSEGV instead of transparently accessing the port.

Fix by restoring the tss length.  Note that i386 had this working already.

Closes bugzilla 10246.

Signed-off-by: Avi Kivity [EMAIL PROTECTED]

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 94ea724..f2df03c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -349,8 +349,6 @@ static void update_exception_bitmap(struct kvm_vcpu *vcpu)
 
 static void reload_tss(void)
 {
-#ifndef CONFIG_X86_64
-
/*
 * VT restores TR but not its size.  Useless.
 */
@@ -361,7 +359,6 @@ static void reload_tss(void)
descs = (void *)gdt.base;
descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
load_TR_desc();
-#endif
 }
 
 static void load_transition_efer(struct vcpu_vmx *vmx)
-- 
1.5.4.2


From 4b1a80fa65aa9e2ec5696998856136c886385538 Mon Sep 17 00:00:00 2001
From: Avi Kivity [EMAIL PROTECTED]
Date: Sun, 23 Mar 2008 12:18:19 +0200
Subject: [PATCH] KVM: MMU: Fix is_rmap_pte() with io ptes

is_rmap_pte() doesn't take into account io ptes, which have the avail bit set.

Signed-off-by: Avi Kivity [EMAIL PROTECTED]

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index d8172aa..e49c4d4 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -222,8 +222,7 @@ static int is_io_pte(unsigned long pte)
 
 static int is_rmap_pte(u64 pte)
 {
-   return pte != shadow_trap_nonpresent_pte
-pte != shadow_notrap_nonpresent_pte;
+   return is_shadow_present_pte(pte);
 }
 
 static gfn_t pse36_gfn_delta(u32 gpte)
-- 
1.5.4.2


From 15aaa819e20cb183f26392ed8ea16020630ef142 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti [EMAIL PROTECTED]
Date: Mon, 17 Mar 2008 10:08:18 -0300
Subject: [PATCH] KVM: MMU: handle page removal with shadow mapping

Do not assume that a shadow mapping will always point to the same host
frame number.  Fixes crash with madvise(MADV_DONTNEED).

[avi: move after first printk(), add another printk()]

Signed-off-by: Marcelo Tosatti [EMAIL PROTECTED]
Signed-off-by: Avi Kivity [EMAIL PROTECTED]

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index e49c4d4..4ba85d9 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -892,14 +892,25 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 
*shadow_pte,
 int *ptwrite, gfn_t gfn, struct page *page)
 {
u64 spte;
-   int was_rmapped = is_rmap_pte(*shadow_pte);
+   int was_rmapped = 0;
int was_writeble = is_writeble_pte(*shadow_pte);
+   hfn_t host_pfn = (*shadow_pte  PT64_BASE_ADDR_MASK)  PAGE_SHIFT;
 
pgprintk(%s: spte %llx access %x write_fault %d
  user_fault %d gfn %lx\n,
 __FUNCTION__, *shadow_pte, pt_access,
 write_fault, user_fault, gfn);
 
+   if (is_rmap_pte(*shadow_pte)) {
+   if (host_pfn != page_to_pfn(page)) {
+   pgprintk(hfn old %lx new %lx\n,
+host_pfn, page_to_pfn(page));
+   rmap_remove(vcpu-kvm, shadow_pte);
+   }
+   else
+   was_rmapped = 1;
+   }
+
/*
 * We don't set the accessed bit, since we sometimes want to see
 * whether the guest actually used the pte (in order to detect
-- 
1.5.4.2


From 707a18a51d83d9180a63b3cbaad8eda7764a8689 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti [EMAIL PROTECTED]
Date: Tue, 18 Mar 2008 17:42:34 -0300
Subject: [PATCH] KVM: VMX: convert init_rmode_tss() to slots_lock

init_rmode_tss was forgotten during the conversion from mmap_sem to
slots_lock.

INFO: task 

[kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Mohammed Gamal
Hello Everyone,
I was trying to install Ubuntu on a VM and tried to boot the
installation directly from the ISO image, doing that KVM crashes
giving this output:
--
exception 0 (0)
rax 0053 rbx 0080 rcx 0031 rdx
0080
rsi 004c rdi 0008ff53 rsp  rbp

r8   r9   r10  r11

r12  r13  r14  r15

rip fce2 rflags 00033217
cs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ds  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
es  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
ss  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
fs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
gs  (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0)
tr  (0885/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0)
ldt  (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0)
gdt fa580/30
idt 0/3ff
cr0 6010 cr2 0 cr3 0 cr4 0 cr8 0 efer 0
code: f6 fc 1c 43 d5 03 3d 00 d4 03 00 c0 b7 01 00 00 d5 03 08 fd 1c
43 d5 03 3e 00 d4 03 00 c0
--

Is this caused by KVM not supporting real mode on Intel hosts, or is
it caused by some other reason?

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Alexey Eremenko

Is this caused by KVM not supporting real mode on Intel hosts, or is it caused 
by some other reason?

Yes, it is correct. Ubuntu 7.04/7.10 won't work anytime soon.

There are few workarounds:
1. use text-mode bootloader
2. use special patches for KVM (not included in mainline, but in Alexander 
Graf's tree)
  (this is ugly hack, so it was not accepted into mainline KVM)
3. use special patches for Graphical GFX GRUB

But do not worry; newer Linux operating systems 2008 fix this problem with 
solution #3.
i.e. openSUSE 11.x and Ubuntu 8.x won't have this problem (tested with several 
Alphas)

-Alexey Technologov, Qumranet QA Team Member
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Alexey Eremenko
Solution #2 patches:
Any pointers to where I can get these patches.

http://packages.opensuse-community.org/
http://download.opensuse.org/repositories/home:/algraf/openSUSE_10.3/src/

Get the src.RPM, and extract patches from it.

Not sure about solution #3 patches.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Mohammed Gamal
On Tue, Mar 25, 2008 at 11:58 AM, Alexey Eremenko
[EMAIL PROTECTED] wrote:




 Is this caused by KVM not supporting real mode on Intel hosts, or is it
 caused by some other reason?

  Yes, it is correct. Ubuntu 7.04/7.10 won't work anytime soon.

  There are few workarounds:
  1. use text-mode bootloader
  2. use special patches for KVM (not included in mainline, but in Alexander
 Graf's tree)
(this is ugly hack, so it was not accepted into mainline KVM)
  3. use special patches for Graphical GFX GRUB

Any pointers to where I can get these patches.

Thanks,
Mohammed

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Dor Laor

On Tue, 2008-03-25 at 12:35 +0200, Mohammed Gamal wrote:
 On Tue, Mar 25, 2008 at 11:58 AM, Alexey Eremenko
 [EMAIL PROTECTED] wrote:
 
 
 
 
  Is this caused by KVM not supporting real mode on Intel hosts, or is it
  caused by some other reason?
 
   Yes, it is correct. Ubuntu 7.04/7.10 won't work anytime soon.
 
   There are few workarounds:
   1. use text-mode bootloader
   2. use special patches for KVM (not included in mainline, but in Alexander
  Graf's tree)
 (this is ugly hack, so it was not accepted into mainline KVM)
   3. use special patches for Graphical GFX GRUB
 
 Any pointers to where I can get these patches.
 

Get http://codemonkey.ws/gfxboot-disable/ and run it on a copy of the
iso image. It automatically switches to text mode.
btw: the problem is not Ubuntu but KVM over Intel, not being able to
cope with big real mode.

 Thanks,
 Mohammed
 
 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 kvm-devel mailing list
 kvm-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/kvm-devel


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] KVM: register the kvm mmu cache with the shrinker.

2008-03-25 Thread Izik Eidus
this is the shrinker patch with all comments applied beside adding aging 
mechanism
it look like the aging mechanism is not really needed and therefor for now it 
isn't
implemented.

From 8503a57ae88ba819e4eac6371172772c98b485f0 Mon Sep 17 00:00:00 2001
From: Izik Eidus [EMAIL PROTECTED]
Date: Tue, 25 Mar 2008 14:03:27 +0200
Subject: [PATCH] KVM: register the kvm mmu cache with the shrinker.

Signed-off-by: Izik Eidus [EMAIL PROTECTED]
---
 arch/x86/kvm/mmu.c |   54 
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index c67ec62..c42c0db 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1972,6 +1972,57 @@ void kvm_mmu_zap_all(struct kvm *kvm)
kvm_flush_remote_tlbs(kvm);
 }
 
+void kvm_mmu_remove_one_alloc_mmu_page(struct kvm *kvm)
+{
+   struct kvm_mmu_page *page;
+
+   page = container_of(kvm-arch.active_mmu_pages.prev,
+   struct kvm_mmu_page, link);
+   kvm_mmu_zap_page(kvm, page);
+}
+
+static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
+{
+   struct kvm *kvm;
+   struct kvm *kvm_freed = NULL;
+   int cache_count = 0;
+
+   spin_lock(kvm_lock);
+   if (list_empty(vm_list)) {
+   spin_unlock(kvm_lock);
+   return 0;
+   }
+   list_for_each_entry(kvm, vm_list, vm_list) {
+   int npages;
+
+   spin_lock(kvm-mmu_lock);
+   npages = kvm-arch.n_alloc_mmu_pages -
+kvm-arch.n_free_mmu_pages;
+   cache_count += npages - KVM_MIN_ALLOC_MMU_PAGES;
+   if (!kvm_freed  nr_to_scan  0  npages 
+   KVM_MIN_ALLOC_MMU_PAGES) {
+   kvm_mmu_remove_one_alloc_mmu_page(kvm);
+   cache_count--;
+   kvm_freed = kvm;
+   }
+   nr_to_scan--;
+
+   spin_unlock(kvm-mmu_lock);
+   }
+   if (kvm_freed) {
+   list_del(kvm_freed-vm_list);
+   list_add_tail(kvm_freed-vm_list, vm_list);
+   }
+   spin_unlock(kvm_lock);
+
+   return cache_count;
+}
+
+static struct shrinker mmu_shrinker = {
+   .shrink = mmu_shrink,
+   .seeks = DEFAULT_SEEKS * 10,
+};
+
 void kvm_mmu_module_exit(void)
 {
if (pte_chain_cache)
@@ -1980,6 +2031,7 @@ void kvm_mmu_module_exit(void)
kmem_cache_destroy(rmap_desc_cache);
if (mmu_page_header_cache)
kmem_cache_destroy(mmu_page_header_cache);

-- 
woof.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Ведение кассовых операций

2008-03-25 Thread Антонида
Вeдeниe кассoвых oпeраций. Правила, нарушeния, кoнтрoль.

Сeминар прoйдёт 15 апрeля 2008, г. Мoсква

В прoграммe: 

1. oбщиe правила вeдeния кассoвых oпeраций в РФ. Нoрмативная база. 
2. oрганизация наличных расчeтoв на прeдприятии
3. oфoрмлeниe кассoвых дoкумeнтoв
4. Дeнeжная наличнoсть в кассe прeдприятия
5. Дeнeжныe дoкумeнты
6. Лимит расчeтoв наличными
7. Валютная касса
8. Наличная выручка
9. Примeнeниe ККМ
10. Примeнeниe бланкoв стрoгoй oтчeтнoсти при наличных расчeтах. oсoбeннoсти 
признания расхoдoв и вычeта НДС на oснoвании бланкoв стрoгoй oтчeтнoсти. Учeт 
бланкoв и их испoльзoвания в oрганизации. Нoвoe в 2008 г. 
11. Расчeты с примeнeниeм платeжных банкoвских карт. 
12. НДС при наличных расчeтах. Выставлeниe счeтoв-фактур. 
13. Рабoта с пoдoтчeтными суммами
14. Выдача зарабoтнoй платы из кассы прeдприятия
15. oфoрмлeниe выплат пo гражданскo-правoвым дoгoвoрам с физичeскими лицами (в 
тoм числe индивидуальными прeдприниматeлями), oграничeния на расчeты наличными, 
удeржаниe НДФЛ. 
16. Выдача займoв рабoтникам из кассы прeдприятия √ oсoбeннoсти учeта и 
налoгooблoжeния. 
17. oсoбeннoсти труда кассира
18. Трeбoвания к oбoрудoванию кассы, правила хранeния наличных, дeйствия 
рукoвoдства и кассира в случах хищeний и краж из кассы. 
19. Рeвизия кассы и кoнтрoль за сoблюдeниeм кассoвoй дисциплины. 
20. Кoнтрoль пoрядка oсущeствлeния кассoвых oпeраций, пoрядoк сoставлeния 
прoтoкoла oб административнoм нарушeнии, срoки давнoсти. Санкции за нарушeния 
пoрядка вeдeния кассoвых oпeраций. oбжалoваниe налoжeнных взысканий.

Прoдoлжитeльнoсть oбучeния: с 10 дo 17 часoв (с пeрeрывoм на oбeд и кoфe-паузу).
Мeстo oбучeния: г. Мoсква, 5 мин. пeшкoм oт м. Акадeмичeская.
Стoимoсть oбучeния: 4900 руб. (с НДС). 
(В стoимoсть вхoдит: раздатoчный матeриал, кoфe-пауза, oбeд в рeстoранe).

При oтсутствии вoзмoжнoсти пoсeтить сeминар, мы прeдлагаeм приoбрeсти eгo 
видeoвeрсию на DVD/CD дисках или видeoкассeтах (прилагаeтся автoрский 
раздатoчный матeриал). 
Цeна видeoкурса - 3500 рублeй, с учeтoм НДС.

Для рeгистрации на сeминар нeoбхoдимo oтправить нам пo факсу или элeктрoннoй 
пoчтe: рeквизиты oрганизации, тeму и дату сeминара, пoлнoe ФИo участникoв, 
кoнтактный тeлeфoн и факс. 
Для заказа видeoкурса нeoбхoдимo oтправить нам пo факсу или элeктрoннoй пoчтe: 
рeквизиты oрганизации, тeму видeoкурса, указать нoситeль (ДВД или СД диски), 
тeлeфoн, факс, кoнтактнoe лицo и тoчный адрeс дoставки. 
 
Пoлучить дoпoлнитeльную инфoрмацию и зарeгистрирoваться мoжнo:
пo т/ф: (495) 543-88-46
пo элeктрoннoй пoчтe: [EMAIL PROTECTED]



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM: register the kvm mmu cache with the shrinker.

2008-03-25 Thread Avi Kivity
Izik Eidus wrote:
 this is the shrinker patch with all comments applied beside adding aging 
 mechanism
 it look like the aging mechanism is not really needed and therefor for now it 
 isn't
 implemented.

 From 8503a57ae88ba819e4eac6371172772c98b485f0 Mon Sep 17 00:00:00 2001
 From: Izik Eidus [EMAIL PROTECTED]
 Date: Tue, 25 Mar 2008 14:03:27 +0200
 Subject: [PATCH] KVM: register the kvm mmu cache with the shrinker.

 Signed-off-by: Izik Eidus [EMAIL PROTECTED]
 ---
  arch/x86/kvm/mmu.c |   54 
 
  1 files changed, 54 insertions(+), 0 deletions(-)

 diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
 index c67ec62..c42c0db 100644
 --- a/arch/x86/kvm/mmu.c
 +++ b/arch/x86/kvm/mmu.c
 @@ -1972,6 +1972,57 @@ void kvm_mmu_zap_all(struct kvm *kvm)
   kvm_flush_remote_tlbs(kvm);
  }
 +static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
 +{
 + struct kvm *kvm;
 + struct kvm *kvm_freed = NULL;
 + int cache_count = 0;
 +
 + spin_lock(kvm_lock);
 + if (list_empty(vm_list)) {
 + spin_unlock(kvm_lock);
 + return 0;
 + }
   

Unnecessary, if the list is empty the loop below doesn't execute and we 
return 0 anyway.

 + list_for_each_entry(kvm, vm_list, vm_list) {
 + int npages;
 +
 + spin_lock(kvm-mmu_lock);
 + npages = kvm-arch.n_alloc_mmu_pages -
 +  kvm-arch.n_free_mmu_pages;
 + cache_count += npages - KVM_MIN_ALLOC_MMU_PAGES;
   

I think we should allow the shrinker to go below 
KVM_MIN_ALLOC_MMU_PAGES; in particular, if the vm is inactive, we should 
be able to shrink it to nothing.

When the VM starts executing again, it will reallocate those pages.

 + if (!kvm_freed  nr_to_scan  0  npages 
 + KVM_MIN_ALLOC_MMU_PAGES) {
   

Don't split an expression like that; the tightly binding expression 
should stay on the same line:

if (!kvm_freed  nr_to_scan  0 
 npages  KVM_MN_ALLOC_MMU_PAGES) {

 + kvm_mmu_remove_one_alloc_mmu_page(kvm);
 + cache_count--;
 + kvm_freed = kvm;
 + }
 + nr_to_scan--;
 +
 + spin_unlock(kvm-mmu_lock);
 + }
 + if (kvm_freed) {
 + list_del(kvm_freed-vm_list);
 + list_add_tail(kvm_freed-vm_list, vm_list);
 + }
   

list_move_tail()

 + spin_unlock(kvm_lock);
 +
 + return cache_count;
 +}
 +
 +static struct shrinker mmu_shrinker = {
 + .shrink = mmu_shrink,
 + .seeks = DEFAULT_SEEKS * 10,
 +};
 +
  void kvm_mmu_module_exit(void)
  {
   if (pte_chain_cache)
 @@ -1980,6 +2031,7 @@ void kvm_mmu_module_exit(void)
   kmem_cache_destroy(rmap_desc_cache);
   if (mmu_page_header_cache)
   kmem_cache_destroy(mmu_page_header_cache);

   

I believe it is necessary to register the shrinker in order to have any 
observable effect.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH][QEMU] Use a separate device for in-kernel PIT (v2)

2008-03-25 Thread Avi Kivity
Anthony Liguori wrote:
 Part of the feedback we received from Fabrice about the KVM patches for QEMU
 is that we should create a separate device for the in-kernel APIC to avoid
 having lots of if (kvm_enabled()) within the APIC code that were difficult to
 understand why there were needed.

 This patch separates the in-kernel PIT into a separate device.  It also
 introduces some configure logic to only compile in support for the in-kernel
 PIT if it's available.

 The result of this is that we now only need a single if (kvm_enabled()) to
 determine which device to use.  Besides making it more upstream friendly, I
 think this makes the code much easier to understand.

 Since v1=v2, we make sure to use common code for save/restore between
 in-kernel pit and in-qemu pit.

   

Please separate the code movement and changes into separate patches.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM crashes when booting from Ubuntu ISO images.

2008-03-25 Thread Mohammed Gamal
On Tue, Mar 25, 2008 at 1:23 PM, Dor Laor [EMAIL PROTECTED] wrote:


  On Tue, 2008-03-25 at 12:35 +0200, Mohammed Gamal wrote:
   On Tue, Mar 25, 2008 at 11:58 AM, Alexey Eremenko
   [EMAIL PROTECTED] wrote:
   
   
   
   
Is this caused by KVM not supporting real mode on Intel hosts, or is it
caused by some other reason?
   
 Yes, it is correct. Ubuntu 7.04/7.10 won't work anytime soon.
   
 There are few workarounds:
 1. use text-mode bootloader
 2. use special patches for KVM (not included in mainline, but in 
 Alexander
Graf's tree)
   (this is ugly hack, so it was not accepted into mainline KVM)
 3. use special patches for Graphical GFX GRUB
  
   Any pointers to where I can get these patches.
  

  Get http://codemonkey.ws/gfxboot-disable/ and run it on a copy of the
  iso image. It automatically switches to text mode.
  btw: the problem is not Ubuntu but KVM over Intel, not being able to
  cope with big real mode.

   Thanks,
   Mohammed
  
   -
   This SF.net email is sponsored by: Microsoft
   Defy all challenges. Microsoft(R) Visual Studio 2008.
   http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
   ___
   kvm-devel mailing list
   kvm-devel@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/kvm-devel



Thanks Dor. I was also facing another issue. I installed MINIX and
GNU/HURD on other VMs, and when I try to boot from their harddisk
images I get a similar message (but with a different exception number)

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH 0 of 7] [v6] PowerPC kvm-userspace patches

2008-03-25 Thread Avi Kivity
Jerone Young wrote:
 Fix big bug found by Anthony, as well formating comments that he commented on.
 Bombs away!

 This set of patches enables the following:
 -Device tree Support
 - Add libfdt to kvm-userspace
 - Add bamboo device tree to qemu source
 - Detection of host Device Tree attributes
 - Device tree loading
 - Ability to specify initrd on the command line
 - Ability to add kernel arguments on the command line
 - Ability to load compressed uImages
 - Ability to specify memory on the command line

   

Applied all; thanks.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM: register the kvm mmu cache with the shrinker.

2008-03-25 Thread Izik Eidus
Avi Kivity wrote:
 Izik Eidus wrote:
 this is the shrinker patch with all comments applied beside adding
 aging mechanism
 it look like the aging mechanism is not really needed and therefor for
 now it isn't
 implemented.

 From 8503a57ae88ba819e4eac6371172772c98b485f0 Mon Sep 17 00:00:00 2001
 From: Izik Eidus [EMAIL PROTECTED]
 Date: Tue, 25 Mar 2008 14:03:27 +0200
 Subject: [PATCH] KVM: register the kvm mmu cache with the shrinker.

 Signed-off-by: Izik Eidus [EMAIL PROTECTED]
 ---
  arch/x86/kvm/mmu.c |   54
 
  1 files changed, 54 insertions(+), 0 deletions(-)

 diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
 index c67ec62..c42c0db 100644
 --- a/arch/x86/kvm/mmu.c
 +++ b/arch/x86/kvm/mmu.c
 @@ -1972,6 +1972,57 @@ void kvm_mmu_zap_all(struct kvm *kvm)
  kvm_flush_remote_tlbs(kvm);
  }
 +static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
 +{
 +struct kvm *kvm;
 +struct kvm *kvm_freed = NULL;
 +int cache_count = 0;
 +
 +spin_lock(kvm_lock);
 +if (list_empty(vm_list)) {
 +spin_unlock(kvm_lock);
 +return 0;
 +}
   
 
 Unnecessary, if the list is empty the loop below doesn't execute and we
 return 0 anyway.
 
 +list_for_each_entry(kvm, vm_list, vm_list) {
 +int npages;
 +
 +spin_lock(kvm-mmu_lock);
 +npages = kvm-arch.n_alloc_mmu_pages -
 + kvm-arch.n_free_mmu_pages;
 +cache_count += npages - KVM_MIN_ALLOC_MMU_PAGES;
   
 
 I think we should allow the shrinker to go below
 KVM_MIN_ALLOC_MMU_PAGES; in particular, if the vm is inactive, we should
 be able to shrink it to nothing.
 
 When the VM starts executing again, it will reallocate those pages.
 
 +if (!kvm_freed  nr_to_scan  0  npages 
 +KVM_MIN_ALLOC_MMU_PAGES) {
   
 
 Don't split an expression like that; the tightly binding expression
 should stay on the same line:
 
 if (!kvm_freed  nr_to_scan  0 
 npages  KVM_MN_ALLOC_MMU_PAGES) {
 
 +kvm_mmu_remove_one_alloc_mmu_page(kvm);
 +cache_count--;
 +kvm_freed = kvm;
 +}
 +nr_to_scan--;
 +
 +spin_unlock(kvm-mmu_lock);
 +}
 +if (kvm_freed) {
 +list_del(kvm_freed-vm_list);
 +list_add_tail(kvm_freed-vm_list, vm_list);
 +}
   
 
 list_move_tail()
 
 +spin_unlock(kvm_lock);
 +
 +return cache_count;
 +}
 +
 +static struct shrinker mmu_shrinker = {
 +.shrink = mmu_shrink,
 +.seeks = DEFAULT_SEEKS * 10,
 +};
 +
  void kvm_mmu_module_exit(void)
  {
  if (pte_chain_cache)
 @@ -1980,6 +2031,7 @@ void kvm_mmu_module_exit(void)
  kmem_cache_destroy(rmap_desc_cache);
  if (mmu_page_header_cache)
  kmem_cache_destroy(mmu_page_header_cache);

   
 
 I believe it is necessary to register the shrinker in order to have any
 observable effect.
 
sorry, i didnt send the whole patch
here the one with your comments applied.
(btw, i have just saw something weird about the memory, so wait before you 
applies it)

From 989c2f8373d8257e9c2b9a8c6ed8d629cd2a9d74 Mon Sep 17 00:00:00 2001
From: Izik Eidus [EMAIL PROTECTED]
Date: Tue, 25 Mar 2008 14:03:27 +0200
Subject: [PATCH] KVM: register the kvm mmu cache with the shrinker.

Signed-off-by: Izik Eidus [EMAIL PROTECTED]
---
 arch/x86/kvm/mmu.c |   49 +
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index c67ec62..b6c1cb2 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1972,6 +1972,52 @@ void kvm_mmu_zap_all(struct kvm *kvm)
kvm_flush_remote_tlbs(kvm);
 }
 
+void kvm_mmu_remove_one_alloc_mmu_page(struct kvm *kvm)
+{
+   struct kvm_mmu_page *page;
+
+   page = container_of(kvm-arch.active_mmu_pages.prev,
+   struct kvm_mmu_page, link);
+   kvm_mmu_zap_page(kvm, page);
+}
+
+static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
+{
+   struct kvm *kvm;
+   struct kvm *kvm_freed = NULL;
+   int cache_count = 0;
+
+   spin_lock(kvm_lock);
+
+   list_for_each_entry(kvm, vm_list, vm_list) {
+   int npages;
+
+   spin_lock(kvm-mmu_lock);
+   npages = kvm-arch.n_alloc_mmu_pages -
+kvm-arch.n_free_mmu_pages;
+   cache_count += npages;
+   if (!kvm_freed  nr_to_scan  0  npages  0) {
+   kvm_mmu_remove_one_alloc_mmu_page(kvm);
+   cache_count--;
+   kvm_freed = kvm;
+   }
+   nr_to_scan--;
+
+   spin_unlock(kvm-mmu_lock);
+   }
+   if (kvm_freed)
+   list_move_tail(kvm_freed-vm_list, vm_list);
+
+   spin_unlock(kvm_lock);
+
+   return cache_count;
+}
+
+static struct shrinker mmu_shrinker = {
+   .shrink = mmu_shrink,
+   .seeks = DEFAULT_SEEKS * 10,
+};
+
 void kvm_mmu_module_exit(void)
 {
if 

[kvm-devel] [RFC] QEMU/KVM: dedicated IO thread

2008-03-25 Thread Marcelo Tosatti

Avi was concerned that this would cause problems with migration. I
haven't specifically tested it yet, but it seems there will be no
problems introduced by this change: the IO thread will stop all vcpu's
in the same way the vcpu0 thread did before.

QEMU/KVM: separate thread for IO handling

Move IO processing from vcpu0 to a dedicated thread.

This removes load on vcpu0 by allowing better cache locality and also
improves latency.

We can now block signal handling for IO events, so sigtimedwait won't
race with handlers:

- Currently the SIGALRM handler fails to set CPU_INTERRUPT_EXIT because
the next_cpu variable is not initialized in the KVM path, meaning that
processing of timer expiration might be delayed until the next vcpu0 exit.

- Processing of IO events will not be unnecessarily interrupted.


Index: kvm-userspace.io/libkvm/libkvm.c
===
--- kvm-userspace.io.orig/libkvm/libkvm.c
+++ kvm-userspace.io/libkvm/libkvm.c
@@ -388,9 +388,6 @@ int kvm_create(kvm_context_t kvm, unsign
if (r  0)
return r;
kvm_create_irqchip(kvm);
-   r = kvm_create_vcpu(kvm, 0);
-   if (r  0)
-   return r;
 
return 0;
 }
Index: kvm-userspace.io/qemu/qemu-kvm.c
===
--- kvm-userspace.io.orig/qemu/qemu-kvm.c
+++ kvm-userspace.io/qemu/qemu-kvm.c
@@ -38,6 +38,7 @@ struct qemu_kvm_signal_table {
 };
 
 static struct qemu_kvm_signal_table io_signal_table;
+static struct qemu_kvm_signal_table vcpu_signal_table;
 
 #define SIG_IPI (SIGRTMIN+4)
 
@@ -51,6 +52,8 @@ struct vcpu_info {
 int stopped;
 } vcpu_info[256];
 
+pthread_t io_thread;
+
 static inline unsigned long kvm_get_thread_id(void)
 {
 return syscall(SYS_gettid);
@@ -67,12 +70,19 @@ static void sig_ipi_handler(int n)
 
 void kvm_update_interrupt_request(CPUState *env)
 {
-if (env  vcpu  env != vcpu-env) {
-   if (vcpu_info[env-cpu_index].signalled)
-   return;
-   vcpu_info[env-cpu_index].signalled = 1;
-   if (vcpu_info[env-cpu_index].thread)
-   pthread_kill(vcpu_info[env-cpu_index].thread, SIG_IPI);
+int signal = 0;
+
+if (env) {
+if (!vcpu)
+signal = 1;
+if (vcpu  env != vcpu-env  !vcpu_info[env-cpu_index].signalled)
+signal = 1;
+
+if (signal) {
+vcpu_info[env-cpu_index].signalled = 1;
+if (vcpu_info[env-cpu_index].thread)
+pthread_kill(vcpu_info[env-cpu_index].thread, SIG_IPI);
+}
 }
 }
 
@@ -105,7 +115,7 @@ static void post_kvm_run(void *opaque, i
 
 static int pre_kvm_run(void *opaque, int vcpu)
 {
-CPUState *env = cpu_single_env;
+CPUState *env = qemu_kvm_cpu_env(vcpu);
 
 kvm_arch_pre_kvm_run(opaque, vcpu);
 
@@ -151,7 +161,8 @@ static int has_work(CPUState *env)
 return kvm_arch_has_work(env);
 }
 
-static int kvm_eat_signal(CPUState *env, int timeout)
+static int kvm_eat_signal(struct qemu_kvm_signal_table *waitset, CPUState *env,
+  int timeout)
 {
 struct timespec ts;
 int r, e, ret = 0;
@@ -160,12 +171,12 @@ static int kvm_eat_signal(CPUState *env,
 
 ts.tv_sec = timeout / 1000;
 ts.tv_nsec = (timeout % 1000) * 100;
-r = sigtimedwait(io_signal_table.sigset, siginfo, ts);
+r = sigtimedwait(waitset-sigset, siginfo, ts);
 if (r == -1  (errno == EAGAIN || errno == EINTR)  !timeout)
return 0;
 e = errno;
 pthread_mutex_lock(qemu_mutex);
-if (vcpu)
+if (env  vcpu)
 cpu_single_env = vcpu-env;
 if (r == -1  !(errno == EAGAIN || errno == EINTR)) {
printf(sigtimedwait: %s\n, strerror(e));
@@ -181,7 +192,7 @@ static int kvm_eat_signal(CPUState *env,
 if (env  vcpu_info[env-cpu_index].stop) {
vcpu_info[env-cpu_index].stop = 0;
vcpu_info[env-cpu_index].stopped = 1;
-   pthread_kill(vcpu_info[0].thread, SIG_IPI);
+   pthread_kill(io_thread, SIGUSR1);
 }
 pthread_mutex_unlock(qemu_mutex);
 
@@ -192,23 +203,18 @@ static int kvm_eat_signal(CPUState *env,
 static void kvm_eat_signals(CPUState *env, int timeout)
 {
 int r = 0;
+struct qemu_kvm_signal_table *waitset = vcpu_signal_table;
 
-while (kvm_eat_signal(env, 0))
+while (kvm_eat_signal(waitset, env, 0))
r = 1;
 if (!r  timeout) {
-   r = kvm_eat_signal(env, timeout);
+   r = kvm_eat_signal(waitset, env, timeout);
if (r)
-   while (kvm_eat_signal(env, 0))
+   while (kvm_eat_signal(waitset, env, 0))
;
 }
-/*
- * we call select() even if no signal was received, to account for
- * for which there is no signal handler installed.
- */
 pthread_mutex_lock(qemu_mutex);
 cpu_single_env = vcpu-env;
-if (env-cpu_index == 0)
-   main_loop_wait(0);
 pthread_mutex_unlock(qemu_mutex);
 }
 
@@ -225,29 +231,29 @@ static int 

[kvm-devel] Attaching to the virtual console/keyboard/mouse of kvm instance using a unix/socket

2008-03-25 Thread Thomas Glanzmann
Hello,
is it possible to connect to the virtual monitor/keyboard/mouse of
an already running kvm instance using a socket when started without an
x-window system and _not_ using vnc? I have something in the back of my
head using libvirt but I am unable to find it.

Thomas

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] QEMU/KVM: dedicated IO thread

2008-03-25 Thread Avi Kivity
Marcelo Tosatti wrote:
 Avi was concerned that this would cause problems with migration. I
 haven't specifically tested it yet, but it seems there will be no
 problems introduced by this change: the IO thread will stop all vcpu's
 in the same way the vcpu0 thread did before.
   

I believe this is broken for smp_cpus  1, and will with this change 
will be broken even for non smp.  The pause/resume logic is rotten.

 QEMU/KVM: separate thread for IO handling

 Move IO processing from vcpu0 to a dedicated thread.

 This removes load on vcpu0 by allowing better cache locality and also
 improves latency.

 We can now block signal handling for IO events, so sigtimedwait won't
 race with handlers:

 - Currently the SIGALRM handler fails to set CPU_INTERRUPT_EXIT because
 the next_cpu variable is not initialized in the KVM path, meaning that
 processing of timer expiration might be delayed until the next vcpu0 exit.
   

I think we call main_loop_wait() is called unconditionally after every 
signal.

 - Processing of IO events will not be unnecessarily interrupted.


 Index: kvm-userspace.io/libkvm/libkvm.c
 ===
 --- kvm-userspace.io.orig/libkvm/libkvm.c
 +++ kvm-userspace.io/libkvm/libkvm.c
 @@ -388,9 +388,6 @@ int kvm_create(kvm_context_t kvm, unsign
   if (r  0)
   return r;
   kvm_create_irqchip(kvm);
 - r = kvm_create_vcpu(kvm, 0);
 - if (r  0)
 - return r;
  
   return 0;
  }
   

Please put this and the corresponding qemu change in a separate patch.

[...lots more...]

Looks good.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] + kvm-provide-kvmh-for-all-architecture-fixes-headers_install.patch added to -mm tree

2008-03-25 Thread Christian Borntraeger
Am Mittwoch, 12. März 2008 schrieben Sie:
 
 The patch titled
  kvm: provide kvm.h for all architecture: fixes headers_install
 has been added to the -mm tree.  Its filename is
  kvm-provide-kvmh-for-all-architecture-fixes-headers_install.patch
 

Hello Andrew,

is there a chance to submit this patch before 2.6.25? headers_install of 
kvm.h worked with 2.6.24 but is still broken with 2.6.25-rc.
Thanks

Christian

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC/PATCH 01/15] preparation: provide hook to enable pgstes in user pagetable

2008-03-25 Thread Carsten Otte
Am Freitag, den 21.03.2008, 11:29 -0700 schrieb Dave Hansen:
 What you've done with dup_mm() is probably the brute-force way that I
 would have done it had I just been trying to make a proof of concept or
 something.  I'm worried that there are a bunch of corner cases that
 haven't been considered.
 
 What if someone else is poking around with ptrace or something similar
 and they bump the mm_users:
 
 +   if (tsk-mm-context.pgstes)
 +   return 0;
 +   if (!tsk-mm || atomic_read(tsk-mm-mm_users)  1 ||
 +   tsk-mm != tsk-active_mm || tsk-mm-ioctx_list)
 +   return -EINVAL;
 HERE
 +   tsk-mm-context.pgstes = 1;/* dirty little tricks .. */
 +   mm = dup_mm(tsk);
 
 It'll race, possibly fault in some other pages, and those faults will be
 lost during the dup_mm().  I think you need to be able to lock out all
 of the users of access_process_vm() before you go and do this.  You also
 need to make sure that anyone who has looked at task-mm doesn't go and
 get a reference to it and get confused later when it isn't the task-mm
 any more.

Good catch, Dave. We intend to get rid of that race via task_lock().
That should lock out ptrace and all others who modify mm_users via get_task_mm.


See patch below:
---

 arch/s390/Kconfig  |4 ++
 arch/s390/kernel/setup.c   |4 ++
 arch/s390/mm/pgtable.c |   65 +++--
 include/asm-s390/mmu.h |1 
 include/asm-s390/mmu_context.h |8 -
 include/asm-s390/pgtable.h |1 
 include/linux/sched.h  |2 +
 kernel/fork.c  |2 -
 8 files changed, 82 insertions(+), 5 deletions(-)

Index: linux-host/arch/s390/Kconfig
===
--- linux-host.orig/arch/s390/Kconfig
+++ linux-host/arch/s390/Kconfig
@@ -55,6 +55,10 @@ config GENERIC_LOCKBREAK
default y
depends on SMP  PREEMPT
 
+config PGSTE
+   bool
+   default y if KVM
+
 mainmenu Linux Kernel Configuration
 
 config S390
Index: linux-host/arch/s390/kernel/setup.c
===
--- linux-host.orig/arch/s390/kernel/setup.c
+++ linux-host/arch/s390/kernel/setup.c
@@ -315,7 +315,11 @@ static int __init early_parse_ipldelay(c
 early_param(ipldelay, early_parse_ipldelay);
 
 #ifdef CONFIG_S390_SWITCH_AMODE
+#ifdef CONFIG_PGSTE
+unsigned int switch_amode = 1;
+#else
 unsigned int switch_amode = 0;
+#endif
 EXPORT_SYMBOL_GPL(switch_amode);
 
 static void set_amode_and_uaccess(unsigned long user_amode,
Index: linux-host/arch/s390/mm/pgtable.c
===
--- linux-host.orig/arch/s390/mm/pgtable.c
+++ linux-host/arch/s390/mm/pgtable.c
@@ -30,11 +30,27 @@
 #define TABLES_PER_PAGE4
 #define FRAG_MASK  15UL
 #define SECOND_HALVES  10UL
+
+void clear_table_pgstes(unsigned long *table)
+{
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE/4);
+   memset(table + 256, 0, PAGE_SIZE/4);
+   clear_table(table + 512, _PAGE_TYPE_EMPTY, PAGE_SIZE/4);
+   memset(table + 768, 0, PAGE_SIZE/4);
+}
+
 #else
 #define ALLOC_ORDER2
 #define TABLES_PER_PAGE2
 #define FRAG_MASK  3UL
 #define SECOND_HALVES  2UL
+
+void clear_table_pgstes(unsigned long *table)
+{
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE/2);
+   memset(table + 256, 0, PAGE_SIZE/2);
+}
+
 #endif
 
 unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec)
@@ -153,7 +169,7 @@ unsigned long *page_table_alloc(struct m
unsigned long *table;
unsigned long bits;
 
-   bits = mm-context.noexec ? 3UL : 1UL;
+   bits = (mm-context.noexec || mm-context.pgstes) ? 3UL : 1UL;
spin_lock(mm-page_table_lock);
page = NULL;
if (!list_empty(mm-context.pgtable_list)) {
@@ -170,7 +186,10 @@ unsigned long *page_table_alloc(struct m
pgtable_page_ctor(page);
page-flags = ~FRAG_MASK;
table = (unsigned long *) page_to_phys(page);
-   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE);
+   if (mm-context.pgstes)
+   clear_table_pgstes(table);
+   else
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE);
spin_lock(mm-page_table_lock);
list_add(page-lru, mm-context.pgtable_list);
}
@@ -191,7 +210,7 @@ void page_table_free(struct mm_struct *m
struct page *page;
unsigned long bits;
 
-   bits = mm-context.noexec ? 3UL : 1UL;
+   bits = (mm-context.noexec || mm-context.pgstes) ? 3UL : 1UL;
bits = (__pa(table)  (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long);
page = pfn_to_page(__pa(table)  PAGE_SHIFT);
spin_lock(mm-page_table_lock);
@@ -228,3 +247,43 @@ void disable_noexec(struct mm_struct *mm
mm-context.noexec = 0;
update_mm(mm, tsk);
 }
+

Re: [kvm-devel] [PATCH] kvm.h: __user requires compiler.h

2008-03-25 Thread Avi Kivity
Christian Borntraeger wrote:
 Am Montag, 24. März 2008 schrieb Avi Kivity:
   
 Christian Borntraeger wrote:
 
 Am Freitag, 21. März 2008 schrieb Anthony Liguori:
   
   
 This patch breaks QEMU build when doing a 'make sync'.  When you do a 
 top-level ./configure, libkvm is built with kerneldir pointing to 
 kvm-userspace/kernel/include.  While linux/kvm.h is present there,
 
 [...] 
   
 Maybe we should generate the 'make sync' headers using 'make 
 headers_install'.
 

 headers_install works because there is 

 # Eliminate the contents of (and inclusions of) compiler.h
 HDRSED  := sed  -e s/ inline / __inline__ /g \
 -e s/[[:space:]]__user[[:space:]]\{1,\}/ /g \
 -e s/(__user[[:space:]]\{1,\}/ (/g \
 -e s/[[:space:]]__force[[:space:]]\{1,\}/ /g \
 -e s/(__force[[:space:]]\{1,\}/ (/g \
 -e s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g \
 -e s/(__iomem[[:space:]]\{1,\}/ (/g \
 -e s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g 
 \
 -e s/[[:space:]]__attribute_const__$$// \
 -e /^\#include linux\/compiler.h/d

 in scripts/Makefile.headersinst

 If you dont want to do something like for make sync, what about providing a 
 dummy compiler.h, which has
 only this line?
 #define __user 
   

I already added something similar, see 
bcb30c8bafc7cac75c38981a57bc1f94521e83f4.


-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add -Werror to libkvm compile

2008-03-25 Thread Jerone Young
It does work with gcc 4.2.3 . Though no idea if gcc-4.3  4.4 would
workout. Though they should. I'll need to to compile them and give them
a try.

On Mon, 2008-03-24 at 20:42 +0100, Segher Boessenkool wrote:
  This patch adds -Werror to CFLAGS for compilation of libkvm. This 
  should stop complaints about Warnings.
 
 Does libkvm build without warnings using GCC-4.3 (or even GCC-4.4)
 on all supported platforms?  If not, please fix that first :-)
 
 
 Segher
 
 
 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2008.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 kvm-devel mailing list
 kvm-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/kvm-devel


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] KVM developer forum 2008 (UPDATED)

2008-03-25 Thread Rami Tamir
We'd like to invite all of you to attend the second annual KVM Forum.
Following the success of the last year's event, we'd like to keep the
format similar. The purpose of the forum is to bring together
developers, testers and other technical individuals from within the
community to discuss the state of KVM today. We will also review and
shape the future roadmap of KVM, examine development challenges, and
agree on modes of collaboration needed for common development.

The KVM Forum 2008 will also give developers an opportunity to update
the community on the work that they are doing and coordinate efforts for
the betterment of KVM and Linux virtualization.

Please reserve these dates, the event will take on June 11th - 13th, at
Marriot Napa Valley, California, USA. For those of you who want to get
there earlier, we will be holding a reception cocktail on June 10th
evening time. For more info and registration please go to
http://kforum.qumranet.com/KVMForum/about_kvmforum.php  

For suggestions and comments please e-mail [EMAIL PROTECTED]

See you all there.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] buliding and testing PowerPC KVM

2008-03-25 Thread Avi Kivity
Hollis Blanchard wrote:
 On Fri, 2008-03-21 at 13:02 +0200, Avi Kivity wrote:
   
 Other than that, and the few minor comments that popped up, this
 (very 
 nice) patchset will be very easy to merge.  IIRC you mentioned it is 
 possible for me to get an s390 account; this will be very useful in 
 avoiding breaking this port, as happens quite often with ppc and
 ia64.  
 I'd like to be able to do both build and run testing.
 

 As for building the PowerPC code, cross-compiling is easy with
 http://kegel.com/crosstool . There are also a number of servers offering
 remote PowerPC ssh access: see http://penguinppc.org/dev/#remote .

   

I now have a ppc account.  Once you point me at the ppc kernel repo I 
can start build testing.

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add -Werror to libkvm compile

2008-03-25 Thread Avi Kivity
Jerone Young wrote:
 It does work with gcc 4.2.3 . Though no idea if gcc-4.3  4.4 would
 workout. Though they should. I'll need to to compile them and give them
 a try.
   

While I'm a fan of -Werror, I have to agree with Anthony it can cause no 
end of pain to users if they have a slightly different configuration.

Maybe enable it conditionally based on ./configure --developer as 
Anthony suggests (but I'll forget to use it myself, I'm sure).

-- 
error compiling committee.c: too many arguments to function


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC/PATCH 01/15 v3] preparation: provide hook to enable pgstes in user pagetable

2008-03-25 Thread Carsten Otte
From: Martin Schwidefsky [EMAIL PROTECTED]
From: Carsten Otte [EMAIL PROTECTED]

The SIE instruction on s390 uses the 2nd half of the page table page to
virtualize the storage keys of a guest. This patch offers the s390_enable_sie
function, which reorganizes the page tables of a single-threaded process to
reserve space in the page table:
s390_enable_sie makes sure that the process is single threaded and then uses
dup_mm to create a new mm with reorganized page tables. The old mm is freed 
and the process has now a page status extended field after every page table.

Code that wants to exploit pgstes should SELECT CONFIG_PGSTE.

This patch has a small common code hit, namely making dup_mm non-static.

Edit (Carsten): I've modified Martin's patch, following Jeremy Fitzhardinge's
review feedback. Now we do have the prototype for dup_mm in
include/linux/sched.h. Following Martin's suggestion, s390_enable_sie() does now
call task_lock() to prevent race against ptrace modification of mm_users.

Signed-off-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---

 arch/s390/Kconfig  |4 ++
 arch/s390/kernel/setup.c   |4 ++
 arch/s390/mm/pgtable.c |   65 +++--
 include/asm-s390/mmu.h |1 
 include/asm-s390/mmu_context.h |8 -
 include/asm-s390/pgtable.h |1 
 include/linux/sched.h  |2 +
 kernel/fork.c  |2 -
 8 files changed, 82 insertions(+), 5 deletions(-)

Index: linux-host/arch/s390/Kconfig
===
--- linux-host.orig/arch/s390/Kconfig
+++ linux-host/arch/s390/Kconfig
@@ -55,6 +55,10 @@ config GENERIC_LOCKBREAK
default y
depends on SMP  PREEMPT
 
+config PGSTE
+   bool
+   default y if KVM
+
 mainmenu Linux Kernel Configuration
 
 config S390
Index: linux-host/arch/s390/kernel/setup.c
===
--- linux-host.orig/arch/s390/kernel/setup.c
+++ linux-host/arch/s390/kernel/setup.c
@@ -315,7 +315,11 @@ static int __init early_parse_ipldelay(c
 early_param(ipldelay, early_parse_ipldelay);
 
 #ifdef CONFIG_S390_SWITCH_AMODE
+#ifdef CONFIG_PGSTE
+unsigned int switch_amode = 1;
+#else
 unsigned int switch_amode = 0;
+#endif
 EXPORT_SYMBOL_GPL(switch_amode);
 
 static void set_amode_and_uaccess(unsigned long user_amode,
Index: linux-host/arch/s390/mm/pgtable.c
===
--- linux-host.orig/arch/s390/mm/pgtable.c
+++ linux-host/arch/s390/mm/pgtable.c
@@ -30,11 +30,27 @@
 #define TABLES_PER_PAGE4
 #define FRAG_MASK  15UL
 #define SECOND_HALVES  10UL
+
+void clear_table_pgstes(unsigned long *table)
+{
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE/4);
+   memset(table + 256, 0, PAGE_SIZE/4);
+   clear_table(table + 512, _PAGE_TYPE_EMPTY, PAGE_SIZE/4);
+   memset(table + 768, 0, PAGE_SIZE/4);
+}
+
 #else
 #define ALLOC_ORDER2
 #define TABLES_PER_PAGE2
 #define FRAG_MASK  3UL
 #define SECOND_HALVES  2UL
+
+void clear_table_pgstes(unsigned long *table)
+{
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE/2);
+   memset(table + 256, 0, PAGE_SIZE/2);
+}
+
 #endif
 
 unsigned long *crst_table_alloc(struct mm_struct *mm, int noexec)
@@ -153,7 +169,7 @@ unsigned long *page_table_alloc(struct m
unsigned long *table;
unsigned long bits;
 
-   bits = mm-context.noexec ? 3UL : 1UL;
+   bits = (mm-context.noexec || mm-context.pgstes) ? 3UL : 1UL;
spin_lock(mm-page_table_lock);
page = NULL;
if (!list_empty(mm-context.pgtable_list)) {
@@ -170,7 +186,10 @@ unsigned long *page_table_alloc(struct m
pgtable_page_ctor(page);
page-flags = ~FRAG_MASK;
table = (unsigned long *) page_to_phys(page);
-   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE);
+   if (mm-context.pgstes)
+   clear_table_pgstes(table);
+   else
+   clear_table(table, _PAGE_TYPE_EMPTY, PAGE_SIZE);
spin_lock(mm-page_table_lock);
list_add(page-lru, mm-context.pgtable_list);
}
@@ -191,7 +210,7 @@ void page_table_free(struct mm_struct *m
struct page *page;
unsigned long bits;
 
-   bits = mm-context.noexec ? 3UL : 1UL;
+   bits = (mm-context.noexec || mm-context.pgstes) ? 3UL : 1UL;
bits = (__pa(table)  (PAGE_SIZE - 1)) / 256 / sizeof(unsigned long);
page = pfn_to_page(__pa(table)  PAGE_SHIFT);
spin_lock(mm-page_table_lock);
@@ -228,3 +247,43 @@ void disable_noexec(struct mm_struct *mm
mm-context.noexec = 0;
update_mm(mm, tsk);
 }
+
+/*
+ * switch on pgstes for its userspace process (for kvm)
+ */
+int s390_enable_sie(void)
+{
+   struct task_struct *tsk = current;
+   struct mm_struct *mm;
+   

[kvm-devel] [RFC/PATCH 00/15 v3] kvm on big iron

2008-03-25 Thread Carsten Otte
Many thanks for the review feedback we have received so far,
and many thanks to Andrew for reviewing our common code memory
management changes. I do greatly appreciate that :-).

All important parts have been reviewed, all review feedback has been
integrated in the code. Therefore we would like to ask for inclusion of
our work into kvm.git.

Changes from Version 1:
- include feedback from Randy Dunlap on the documentation
- include feedback from Jeremy Fitzhardinge, the prototype for dup_mm
  has moved to include/linux/sched.h
- rebase to current kvm.git hash g361be34. Thank you Avi for pulling
  in the fix we need, and for moving KVM_MAX_VCPUS to include/arch :-).

Changes from Version 2:
- include feedback from Rusty Russell on the virtio patch
- include fix for race s390_enable_sie() versus ptrace spotted by Dave 
  Hansen: we now do task_lock() to protect mm_users from update while 
  we're growing the page table. Good catch, Dave :-).
- rebase to current kvm.git hash g680615e

Todo list:
- I've created a patch for Christoph Helwig's feedback about symbolic
names for machine_flags. This change is independent of the kvm port, and
I will submit it for review to Martin.

The patch queue consists of the following patches:
[RFC/PATCH 01/15] preparation: provide hook to enable pgstes in user 
   pagetable
[RFC/PATCH 02/15] preparation: host memory management changes for s390 
   kvm
[RFC/PATCH 03/15] preparation: address of the 64bit extint parm in 
   lowcore
[RFC/PATCH 04/15] preparation: split sysinfo defintions for kvm use
[RFC/PATCH 05/15] kvm-s390: s390 arch backend for the kvm kernel module
[RFC/PATCH 06/15] kvm-s390: sie intercept handling
[RFC/PATCH 07/15] kvm-s390: interrupt subsystem, cpu timer, waitpsw
[RFC/PATCH 08/15] kvm-s390: intercepts for privileged instructions
[RFC/PATCH 09/15] kvm-s390: interprocessor communication via sigp
[RFC/PATCH 10/15] kvm-s390: intercepts for diagnose instructions
[RFC/PATCH 11/15] kvm-s390: add kvm to kconfig on s390
[RFC/PATCH 12/15] kvm-s390: API documentation
[RFC/PATCH 13/15] kvm-s390: update maintainers
[RFC/PATCH 14/15] guest: detect when running on kvm
[RFC/PATCH 15/15] guest: virtio device support, and kvm hypercalls


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC/PATCH 02/15 v3] preparation: host memory management changes for s390 kvm

2008-03-25 Thread Carsten Otte
From: Heiko Carstens [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This patch changes the s390 memory management defintions to use the pgste field
for dirty and reference bit tracking of host and guest code. Usually on s390, 
dirty and referenced are tracked in storage keys, which belong to the physical
page. This changes with virtualization: The guest and host dirty/reference bits
are defined to be the logical OR of the values for the mapping and the physical
page. This patch implements the necessary changes in pgtable.h for s390.


There is a common code change in mm/rmap.c, the call to 
page_test_and_clear_young
must be moved. This is a no-op for all architecture but s390. page_referenced
checks the referenced bits for the physiscal page and for all mappings:
o The physical page is checked with page_test_and_clear_young.
o The mappings are checked with ptep_test_and_clear_young and friends.

Without pgstes (the current implementation on Linux s390) the physical page
check is implemented but the mapping callbacks are no-ops because dirty 
and referenced are not tracked in the s390 page tables. The pgstes introduces 
guest and host dirty and reference bits for s390 in the host mapping. These
mapping must be checked before page_test_and_clear_young resets the reference
bit. 

Signed-off-by: Heiko Carstens [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 include/asm-s390/pgtable.h |   92 +++--
 mm/rmap.c  |7 +--
 2 files changed, 93 insertions(+), 6 deletions(-)

Index: kvm/include/asm-s390/pgtable.h
===
--- kvm.orig/include/asm-s390/pgtable.h
+++ kvm/include/asm-s390/pgtable.h
@@ -30,6 +30,7 @@
  */
 #ifndef __ASSEMBLY__
 #include linux/mm_types.h
+#include asm/bitops.h
 #include asm/bug.h
 #include asm/processor.h
 
@@ -258,6 +259,13 @@ extern char empty_zero_page[PAGE_SIZE];
  * swap pte is 1011 and 0001, 0011, 0101, 0111 are invalid.
  */
 
+/* Page status table bits for virtualization */
+#define RCP_PCL_BIT55
+#define RCP_HR_BIT 54
+#define RCP_HC_BIT 53
+#define RCP_GR_BIT 50
+#define RCP_GC_BIT 49
+
 #ifndef __s390x__
 
 /* Bits in the segment table address-space-control-element */
@@ -513,6 +521,48 @@ static inline int pte_file(pte_t pte)
 #define __HAVE_ARCH_PTE_SAME
 #define pte_same(a,b)  (pte_val(a) == pte_val(b))
 
+static inline void rcp_lock(pte_t *ptep)
+{
+#ifdef CONFIG_PGSTE
+   unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
+   preempt_disable();
+   while (test_and_set_bit(RCP_PCL_BIT, pgste))
+   ;
+#endif
+}
+
+static inline void rcp_unlock(pte_t *ptep)
+{
+#ifdef CONFIG_PGSTE
+   unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
+   clear_bit(RCP_PCL_BIT, pgste);
+   preempt_enable();
+#endif
+}
+
+/* forward declaration for SetPageUptodate in page-flags.h*/
+static inline void page_clear_dirty(struct page *page);
+#include linux/page-flags.h
+
+static inline void ptep_rcp_copy(pte_t *ptep)
+{
+#ifdef CONFIG_PGSTE
+   struct page *page = virt_to_page(pte_val(*ptep));
+   unsigned int skey;
+   unsigned long *pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
+
+   skey = page_get_storage_key(page_to_phys(page));
+   if (skey  _PAGE_CHANGED)
+   set_bit(RCP_GC_BIT, pgste);
+   if (skey  _PAGE_REFERENCED)
+   set_bit(RCP_GR_BIT, pgste);
+   if (test_and_clear_bit(RCP_HC_BIT, pgste))
+   SetPageDirty(page);
+   if (test_and_clear_bit(RCP_HR_BIT, pgste))
+   SetPageReferenced(page);
+#endif
+}
+
 /*
  * query functions pte_write/pte_dirty/pte_young only work if
  * pte_present() is true. Undefined behaviour if not..
@@ -599,6 +649,8 @@ static inline void pmd_clear(pmd_t *pmd)
 
 static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t 
*ptep)
 {
+   if (mm-context.pgstes)
+   ptep_rcp_copy(ptep);
pte_val(*ptep) = _PAGE_TYPE_EMPTY;
if (mm-context.noexec)
pte_val(ptep[PTRS_PER_PTE]) = _PAGE_TYPE_EMPTY;
@@ -667,6 +719,24 @@ static inline pte_t pte_mkyoung(pte_t pt
 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
unsigned long addr, pte_t *ptep)
 {
+#ifdef CONFIG_PGSTE
+   unsigned long physpage;
+   int young;
+   unsigned long *pgste;
+
+   if (!vma-vm_mm-context.pgstes)
+   return 0;
+   physpage = pte_val(*ptep)  PAGE_MASK;
+   pgste = (unsigned long *) (ptep + PTRS_PER_PTE);
+
+   young = ((page_get_storage_key(physpage)  _PAGE_REFERENCED) != 0);
+   rcp_lock(ptep);
+   if (young)
+   set_bit(RCP_GR_BIT, pgste);
+   young |= test_and_clear_bit(RCP_HR_BIT, pgste);
+

[kvm-devel] [RFC/PATCH 03/15 v3] preparation: address of the 64bit extint parm in lowcore

2008-03-25 Thread Carsten Otte
From: Christian Borntraeger [EMAIL PROTECTED]

The address 0x11b8 is used by z/VM for pfault and diag 250 I/O to
provide a 64 bit extint parameter. virtio uses the same address, so
its time to update the lowcore structure.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 include/asm-s390/lowcore.h |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

Index: kvm/include/asm-s390/lowcore.h
===
--- kvm.orig/include/asm-s390/lowcore.h
+++ kvm/include/asm-s390/lowcore.h
@@ -380,27 +380,32 @@ struct _lowcore
 /* whether the kernel died with panic() or not */
 __u32panic_magic;  /* 0xe00 */
 
-   __u8 pad13[0x1200-0xe04];  /* 0xe04 */
+   __u8 pad13[0x11b8-0xe04];  /* 0xe04 */
+
+   /* 64 bit extparam used for pfault, diag 250 etc  */
+   __u64ext_params2;   /* 0x11B8 */
+
+   __u8 pad14[0x1200-0x11C0];  /* 0x11C0 */
 
 /* System info area */ 
 
__u64floating_pt_save_area[16]; /* 0x1200 */
__u64gpregs_save_area[16];  /* 0x1280 */
__u32st_status_fixed_logout[4]; /* 0x1300 */
-   __u8 pad14[0x1318-0x1310];  /* 0x1310 */
+   __u8 pad15[0x1318-0x1310];  /* 0x1310 */
__u32prefixreg_save_area;   /* 0x1318 */
__u32fpt_creg_save_area;/* 0x131c */
-   __u8 pad15[0x1324-0x1320];  /* 0x1320 */
+   __u8 pad16[0x1324-0x1320];  /* 0x1320 */
__u32tod_progreg_save_area; /* 0x1324 */
__u32cpu_timer_save_area[2];/* 0x1328 */
__u32clock_comp_save_area[2];   /* 0x1330 */
-   __u8 pad16[0x1340-0x1338];  /* 0x1338 */ 
+   __u8 pad17[0x1340-0x1338];  /* 0x1338 */
__u32access_regs_save_area[16]; /* 0x1340 */ 
__u64cregs_save_area[16];   /* 0x1380 */
 
/* align to the top of the prefix area */
 
-   __u8 pad17[0x2000-0x1400];  /* 0x1400 */
+   __u8 pad18[0x2000-0x1400];  /* 0x1400 */
 #endif /* !__s390x__ */
 } __attribute__((packed)); /* End structure*/
 



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC/PATCH 04/15 v3] preparation: split sysinfo defintions for kvm use

2008-03-25 Thread Carsten Otte
From: Christian Borntraeger [EMAIL PROTECTED]

drivers/s390/sysinfo.c uses the store system information intruction to query
the system about information of the machine, the LPAR and additional 
hypervisors. KVM has to implement the host part for this instruction. 

To avoid code duplication, this patch splits the common definitions from
sysinfo.c into a separate header file include/asm-s390/sysinfo.h for KVM use.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 drivers/s390/sysinfo.c |  100 
 include/asm-s390/sysinfo.h |  112 +
 2 files changed, 113 insertions(+), 99 deletions(-)

Index: kvm/drivers/s390/sysinfo.c
===
--- kvm.orig/drivers/s390/sysinfo.c
+++ kvm/drivers/s390/sysinfo.c
@@ -11,111 +11,13 @@
 #include linux/init.h
 #include linux/delay.h
 #include asm/ebcdic.h
+#include asm/sysinfo.h
 
 /* Sigh, math-emu. Don't ask. */
 #include asm/sfp-util.h
 #include math-emu/soft-fp.h
 #include math-emu/single.h
 
-struct sysinfo_1_1_1 {
-   char reserved_0[32];
-   char manufacturer[16];
-   char type[4];
-   char reserved_1[12];
-   char model_capacity[16];
-   char sequence[16];
-   char plant[4];
-   char model[16];
-};
-
-struct sysinfo_1_2_1 {
-   char reserved_0[80];
-   char sequence[16];
-   char plant[4];
-   char reserved_1[2];
-   unsigned short cpu_address;
-};
-
-struct sysinfo_1_2_2 {
-   char format;
-   char reserved_0[1];
-   unsigned short acc_offset;
-   char reserved_1[24];
-   unsigned int secondary_capability;
-   unsigned int capability;
-   unsigned short cpus_total;
-   unsigned short cpus_configured;
-   unsigned short cpus_standby;
-   unsigned short cpus_reserved;
-   unsigned short adjustment[0];
-};
-
-struct sysinfo_1_2_2_extension {
-   unsigned int alt_capability;
-   unsigned short alt_adjustment[0];
-};
-
-struct sysinfo_2_2_1 {
-   char reserved_0[80];
-   char sequence[16];
-   char plant[4];
-   unsigned short cpu_id;
-   unsigned short cpu_address;
-};
-
-struct sysinfo_2_2_2 {
-   char reserved_0[32];
-   unsigned short lpar_number;
-   char reserved_1;
-   unsigned char characteristics;
-   unsigned short cpus_total;
-   unsigned short cpus_configured;
-   unsigned short cpus_standby;
-   unsigned short cpus_reserved;
-   char name[8];
-   unsigned int caf;
-   char reserved_2[16];
-   unsigned short cpus_dedicated;
-   unsigned short cpus_shared;
-};
-
-#define LPAR_CHAR_DEDICATED(1  7)
-#define LPAR_CHAR_SHARED   (1  6)
-#define LPAR_CHAR_LIMITED  (1  5)
-
-struct sysinfo_3_2_2 {
-   char reserved_0[31];
-   unsigned char count;
-   struct {
-   char reserved_0[4];
-   unsigned short cpus_total;
-   unsigned short cpus_configured;
-   unsigned short cpus_standby;
-   unsigned short cpus_reserved;
-   char name[8];
-   unsigned int caf;
-   char cpi[16];
-   char reserved_1[24];
-
-   } vm[8];
-};
-
-static inline int stsi(void *sysinfo, int fc, int sel1, int sel2)
-{
-   register int r0 asm(0) = (fc  28) | sel1;
-   register int r1 asm(1) = sel2;
-
-   asm volatile(
-  stsi 0(%2)\n
-   0: jz   2f\n
-   1: lhi  %0,%3\n
-   2:\n
-   EX_TABLE(0b,1b)
-   : +d (r0) : d (r1), a (sysinfo), K (-ENOSYS)
-   : cc, memory );
-   return r0;
-}
-
 static inline int stsi_0(void)
 {
int rc = stsi (NULL, 0, 0, 0);
Index: kvm/include/asm-s390/sysinfo.h
===
--- /dev/null
+++ kvm/include/asm-s390/sysinfo.h
@@ -0,0 +1,112 @@
+/*
+ * definition for store system information stsi
+ *
+ * Copyright IBM Corp. 2001,2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Ulrich Weigand [EMAIL PROTECTED]
+ *   Christian Borntraeger [EMAIL PROTECTED]
+ */
+
+struct sysinfo_1_1_1 {
+   char reserved_0[32];
+   char manufacturer[16];
+   char type[4];
+   char reserved_1[12];
+   char model_capacity[16];
+   char sequence[16];
+   char plant[4];
+   char model[16];
+};
+
+struct sysinfo_1_2_1 {
+   char reserved_0[80];
+   char sequence[16];
+   char plant[4];
+   char reserved_1[2];
+   unsigned short cpu_address;
+};
+
+struct sysinfo_1_2_2 {
+   char format;
+   char reserved_0[1];
+   unsigned short acc_offset;
+   

[kvm-devel] [RFC/PATCH 05/15 v3] kvm-s390: s390 arch backend for the kvm kernel module

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]
From: Heiko Carstens [EMAIL PROTECTED]

This patch contains the port of Qumranet's kvm kernel module to IBM zSeries
 (aka s390x, mainframe) architecture. It uses the mainframe's virtualization
instruction SIE to run virtual machines with up to 64 virtual CPUs each.
This port is only usable on 64bit host kernels, and can only run 64bit guest
kernels. However, running 31bit applications in guest userspace is possible.

The following source files are introduced by this patch
arch/s390/kvm/kvm-s390.csimilar to arch/x86/kvm/x86.c, this implements all
arch callbacks for kvm. __vcpu_run calls back into
sie64a to enter the guest machine context
arch/s390/kvm/sie64a.S  assembler function sie64a, which enters guest
context via SIE, and switches world before and 
afterthat
include/asm-s390/kvm_host.h contains all vital data structures needed to run
virtual machines on the mainframe
include/asm-s390/kvm.h  defines kvm_regs and friends for user access to
guest register content
arch/s390/kvm/gaccess.h functions similar to uaccess to access guest memory
arch/s390/kvm/kvm-s390.hheader file for kvm-s390 internals, extended by
later patches

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Heiko Carstens [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/Makefile  |2 
 arch/s390/kernel/vtime.c|1 
 arch/s390/kvm/Makefile  |   14 +
 arch/s390/kvm/gaccess.h |  280 +
 arch/s390/kvm/kvm-s390.c|  574 
 arch/s390/kvm/kvm-s390.h|   29 ++
 arch/s390/kvm/sie64a.S  |   47 +++
 include/asm-s390/Kbuild |1 
 include/asm-s390/kvm.h  |   44 +++
 include/asm-s390/kvm_host.h |  127 +
 include/asm-s390/kvm_para.h |   30 ++
 include/linux/kvm.h |   15 +
 12 files changed, 1163 insertions(+), 1 deletion(-)

Index: linux-host/arch/s390/Makefile
===
--- linux-host.orig/arch/s390/Makefile
+++ linux-host/arch/s390/Makefile
@@ -87,7 +87,7 @@ LDFLAGS_vmlinux := -e start
 head-y := arch/s390/kernel/head.o arch/s390/kernel/init_task.o
 
 core-y += arch/s390/mm/ arch/s390/kernel/ arch/s390/crypto/ \
-  arch/s390/appldata/ arch/s390/hypfs/
+  arch/s390/appldata/ arch/s390/hypfs/ arch/s390/kvm/
 libs-y += arch/s390/lib/
 drivers-y  += drivers/s390/
 drivers-$(CONFIG_MATHEMU) += arch/s390/math-emu/
Index: linux-host/arch/s390/kernel/vtime.c
===
--- linux-host.orig/arch/s390/kernel/vtime.c
+++ linux-host/arch/s390/kernel/vtime.c
@@ -110,6 +110,7 @@ void account_system_vtime(struct task_st
S390_lowcore.steal_clock -= cputime  12;
account_system_time(tsk, 0, cputime);
 }
+EXPORT_SYMBOL_GPL(account_system_vtime);
 
 static inline void set_vtimer(__u64 expires)
 {
Index: linux-host/arch/s390/kvm/Makefile
===
--- /dev/null
+++ linux-host/arch/s390/kvm/Makefile
@@ -0,0 +1,14 @@
+# Makefile for kernel virtual machines on s390
+#
+# Copyright IBM Corp. 2008
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License (version 2 only)
+# as published by the Free Software Foundation.
+
+common-objs = $(addprefix ../../../virt/kvm/, kvm_main.o)
+
+EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
+
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o
+obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/gaccess.h
===
--- /dev/null
+++ linux-host/arch/s390/kvm/gaccess.h
@@ -0,0 +1,280 @@
+/*
+ * gaccess.h -  access guest memory
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Carsten Otte [EMAIL PROTECTED]
+ */
+
+#ifndef __KVM_S390_GACCESS_H
+#define __KVM_S390_GACCESS_H
+
+#include linux/compiler.h
+#include linux/kvm_host.h
+#include asm/uaccess.h
+
+static inline void __user *__guestaddr_to_user(struct kvm_vcpu *vcpu,
+  u64 guestaddr)
+{
+   u64 prefix  = vcpu-arch.sie_block-prefix;
+   u64 origin  = vcpu-kvm-arch.guest_origin;
+   u64 memsize = vcpu-kvm-arch.guest_memsize;
+
+   if (guestaddr  2 * PAGE_SIZE)
+   guestaddr += prefix;
+   else if ((guestaddr = prefix)  (guestaddr  

[kvm-devel] [RFC/PATCH 07/15 v3] kvm-s390: interrupt subsystem, cpu timer, waitpsw

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]

This patch contains the s390 interrupt subsystem (similar to in kernel apic)
including timer interrupts (similar to in-kernel-pit) and enabled wait
(similar to in kernel hlt).

In order to achieve that, this patch also introduces intercept handling
for instruction intercepts, and it implements load control instructions.

This patch introduces an ioctl KVM_S390_INTERRUPT which is valid for both
the vm file descriptors and the vcpu file descriptors. In case this ioctl is
issued against a vm file descriptor, the interrupt is considered floating.
Floating interrupts may be delivered to any virtual cpu in the configuration.

The following interrupts are supported:
SIGP STOP   - interprocessor signal that stops a remote cpu
SIGP SET PREFIX - interprocessor signal that sets the prefix register of a
  (stopped) remote cpu
INT EMERGENCY   - interprocessor interrupt, usually used to signal need_reshed
  and for smp_call_function() in the guest.
PROGRAM INT - exception during program execution such as page fault, illegal
  instruction and friends
RESTART - interprocessor signal that starts a stopped cpu
INT VIRTIO  - floating interrupt for virtio signalisation
INT SERVICE - floating interrupt for signalisations from the system
  service processor

struct kvm_s390_interrupt, which is submitted as ioctl parameter when injecting
an interrupt, also carrys parameter data for interrupts along with the interrupt
type. Interrupts on s390 usually have a state that represents the current
operation, or identifies which device has caused the interruption on s390.

kvm_s390_handle_wait() does handle waitpsw in two flavors: in case of a
disabled wait (that is, disabled for interrupts), we exit to userspace. In case
of an enabled wait we set up a timer that equals the cpu clock comparator value
and sleep on a wait queue.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/kvm/Makefile  |2 
 arch/s390/kvm/intercept.c   |  123 +
 arch/s390/kvm/interrupt.c   |  583 
 arch/s390/kvm/kvm-s390.c|   48 +++
 arch/s390/kvm/kvm-s390.h|   15 +
 include/asm-s390/kvm_host.h |   75 +
 include/linux/kvm.h |   17 +
 7 files changed, 860 insertions(+), 3 deletions(-)

Index: linux-host/arch/s390/kvm/Makefile
===
--- linux-host.orig/arch/s390/kvm/Makefile
+++ linux-host/arch/s390/kvm/Makefile
@@ -10,5 +10,5 @@ common-objs = $(addprefix ../../../virt/
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
 
-kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o
 obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/intercept.c
===
--- linux-host.orig/arch/s390/kvm/intercept.c
+++ linux-host/arch/s390/kvm/intercept.c
@@ -18,6 +18,91 @@
 #include asm/kvm_host.h
 
 #include kvm-s390.h
+#include gaccess.h
+
+static int handle_lctg(struct kvm_vcpu *vcpu)
+{
+   int reg1 = (vcpu-arch.sie_block-ipa  0x00f0)  4;
+   int reg3 = vcpu-arch.sie_block-ipa  0x000f;
+   int base2 = vcpu-arch.sie_block-ipb  28;
+   int disp2 = ((vcpu-arch.sie_block-ipb  0x0fff)  16) +
+   ((vcpu-arch.sie_block-ipb  0xff00)  4);
+   u64 useraddr;
+   int reg, rc;
+
+   vcpu-stat.instruction_lctg++;
+   if ((vcpu-arch.sie_block-ipb  0xff) != 0x2f)
+   return -ENOTSUPP;
+
+   useraddr = disp2;
+   if (base2)
+   useraddr += vcpu-arch.guest_gprs[base2];
+
+   reg = reg1;
+
+   VCPU_EVENT(vcpu, 5, lctg r1:%x, r3:%x,b2:%x,d2:%x, reg1, reg3, base2,
+  disp2);
+
+   do {
+   rc = get_guest_u64(vcpu, useraddr,
+   vcpu-arch.sie_block-gcr[reg]);
+   if (rc == -EFAULT) {
+   kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
+   break;
+   }
+   useraddr += 8;
+   if (reg == reg3)
+   break;
+   reg = reg + 1;
+   if (reg  15)
+   reg = 0;
+   } while (1);
+   return 0;
+}
+
+static int handle_lctl(struct kvm_vcpu *vcpu)
+{
+   int reg1 = (vcpu-arch.sie_block-ipa  0x00f0)  4;
+   int reg3 = vcpu-arch.sie_block-ipa  0x000f;
+   int base2 = vcpu-arch.sie_block-ipb  28;
+   int disp2 = ((vcpu-arch.sie_block-ipb  0x0fff)  16);
+   u64 useraddr;
+   u32 val = 0;
+   int reg, rc;
+
+   vcpu-stat.instruction_lctl++;
+
+   useraddr = disp2;
+   if (base2)
+   useraddr += vcpu-arch.guest_gprs[base2];
+
+   reg = reg1;
+
+   VCPU_EVENT(vcpu, 5, lctl r1:%x, r3:%x,b2:%x,d2:%x, reg1, 

[kvm-devel] [RFC/PATCH 08/15 v3] kvm-s390: intercepts for privileged instructions

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This patch introduces in-kernel handling of some intercepts for privileged
instructions:
handle_set_prefix()sets the prefix register of the local cpu
handle_store_prefix()  stores the content of the prefix register to memory
handle_store_cpu_address() stores the cpu number of the current cpu to memory
handle_skey()  just decrements the instruction address and retries
handle_stsch() delivers condition code 3 operation not supported
handle_chsc()  same here
handle_stfl()  stores the facility list which contains the
   capabilities of the cpu
handle_stidp() stores cpu type/model/revision and such
handle_stsi()  stores information about the system topology

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/kvm/Makefile  |2 
 arch/s390/kvm/intercept.c   |1 
 arch/s390/kvm/kvm-s390.c|   11 +
 arch/s390/kvm/kvm-s390.h|3 
 arch/s390/kvm/priv.c|  322 
 include/asm-s390/kvm_host.h |   13 +
 6 files changed, 351 insertions(+), 1 deletion(-)

Index: linux-host/arch/s390/kvm/Makefile
===
--- linux-host.orig/arch/s390/kvm/Makefile
+++ linux-host/arch/s390/kvm/Makefile
@@ -10,5 +10,5 @@ common-objs = $(addprefix ../../../virt/
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
 
-kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o priv.o
 obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/intercept.c
===
--- linux-host.orig/arch/s390/kvm/intercept.c
+++ linux-host/arch/s390/kvm/intercept.c
@@ -100,6 +100,7 @@ static int handle_lctl(struct kvm_vcpu *
 }
 
 static intercept_handler_t instruction_handlers[256] = {
+   [0xb2] = kvm_s390_handle_priv,
[0xb7] = handle_lctl,
[0xeb] = handle_lctg,
 };
Index: linux-host/arch/s390/kvm/kvm-s390.c
===
--- linux-host.orig/arch/s390/kvm/kvm-s390.c
+++ linux-host/arch/s390/kvm/kvm-s390.c
@@ -48,6 +48,15 @@ struct kvm_stats_debugfs_item debugfs_en
{ deliver_restart_signal, VCPU_STAT(deliver_restart_signal) },
{ deliver_program_interruption, VCPU_STAT(deliver_program_int) },
{ exit_wait_state, VCPU_STAT(exit_wait_state) },
+   { instruction_stidp, VCPU_STAT(instruction_stidp) },
+   { instruction_spx, VCPU_STAT(instruction_spx) },
+   { instruction_stpx, VCPU_STAT(instruction_stpx) },
+   { instruction_stap, VCPU_STAT(instruction_stap) },
+   { instruction_storage_key, VCPU_STAT(instruction_storage_key) },
+   { instruction_stsch, VCPU_STAT(instruction_stsch) },
+   { instruction_chsc, VCPU_STAT(instruction_chsc) },
+   { instruction_stsi, VCPU_STAT(instruction_stsi) },
+   { instruction_stfl, VCPU_STAT(instruction_stfl) },
{ NULL }
 };
 
@@ -249,6 +258,8 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu 
vcpu-arch.sie_block-eca   = 0xC1002001U;
setup_timer(vcpu-arch.ckc_timer, kvm_s390_idle_wakeup,
 (unsigned long) vcpu);
+   get_cpu_id(vcpu-arch.cpu_id);
+   vcpu-arch.cpu_id.version = 0xfe;
return 0;
 }
 
Index: linux-host/arch/s390/kvm/kvm-s390.h
===
--- linux-host.orig/arch/s390/kvm/kvm-s390.h
+++ linux-host/arch/s390/kvm/kvm-s390.h
@@ -47,4 +47,7 @@ int kvm_s390_inject_vm(struct kvm *kvm,
 int kvm_s390_inject_vcpu(struct kvm_vcpu *vcpu,
struct kvm_s390_interrupt *s390int);
 int kvm_s390_inject_program_int(struct kvm_vcpu *vcpu, u16 code);
+
+/* implemented in priv.c */
+int kvm_s390_handle_priv(struct kvm_vcpu *vcpu);
 #endif
Index: linux-host/arch/s390/kvm/priv.c
===
--- /dev/null
+++ linux-host/arch/s390/kvm/priv.c
@@ -0,0 +1,322 @@
+/*
+ * priv.c - handling privileged instructions
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Carsten Otte [EMAIL PROTECTED]
+ *   Christian Borntraeger [EMAIL PROTECTED]
+ */
+
+#include linux/kvm.h
+#include linux/errno.h
+#include asm/current.h
+#include asm/debug.h
+#include asm/ebcdic.h
+#include asm/sysinfo.h
+#include gaccess.h
+#include kvm-s390.h
+
+static int handle_set_prefix(struct kvm_vcpu *vcpu)
+{
+   int base2 = vcpu-arch.sie_block-ipb  28;
+   int disp2 = ((vcpu-arch.sie_block-ipb  

[kvm-devel] [RFC/PATCH 12/15 v3] kvm-s390: API documentation

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]

This patch adds Documentation/s390/kvm.txt, which describes specifics of kvm's
user interface that are unique to s390 architecture.

Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 Documentation/s390/kvm.txt |  125 +
 1 files changed, 125 insertions(+)

Index: linux-host/Documentation/s390/kvm.txt
===
--- /dev/null
+++ linux-host/Documentation/s390/kvm.txt
@@ -0,0 +1,125 @@
+*** BIG FAT WARNING ***
+The kvm module is currently in EXPERIMENTAL state for s390. This means that
+the interface to the module is not yet considered to remain stable. Thus, be
+prepared that we keep breaking your userspace application and guest
+compatibility over and over again until we feel happy with the result. Make 
sure
+your guest kernel, your host kernel, and your userspace launcher are in a
+consistent state.
+
+This Documentation describes the unique ioctl calls to /dev/kvm, the resulting
+kvm-vm file descriptors, and the kvm-vcpu file descriptors that differ from 
x86.
+
+1. ioctl calls to /dev/kvm
+KVM does support the following ioctls on s390 that are common with other
+architectures and do behave the same:
+KVM_GET_API_VERSION
+KVM_CREATE_VM  (*) see note
+KVM_CHECK_EXTENSION
+KVM_GET_VCPU_MMAP_SIZE
+
+Notes:
+* KVM_CREATE_VM may fail on s390, if the calling process has multiple
+threads and has not called KVM_S390_ENABLE_SIE before.
+
+In addition, on s390 the following architecture specific ioctls are supported:
+ioctl: KVM_S390_ENABLE_SIE
+args:  none
+see also:  include/linux/kvm.h
+This call causes the kernel to switch on PGSTE in the user page table. This
+operation is needed in order to run a virtual machine, and it requires the
+calling process to be single-threaded. Note that the first call to 
KVM_CREATE_VM
+will implicitly try to switch on PGSTE if the user process has not called
+KVM_S390_ENABLE_SIE before. User processes that want to launch multiple threads
+before creating a virtual machine have to call KVM_S390_ENABLE_SIE, or will
+observe an error calling KVM_CREATE_VM. Switching on PGSTE is a one-time
+operation, is not reversible, and will persist over the entire lifetime of
+the calling process. It does not have any user-visible effect other than a 
small
+performance penalty.
+
+2. ioctl calls to the kvm-vm file descriptor
+KVM does support the following ioctls on s390 that are common with other
+architectures and do behave the same:
+KVM_CREATE_VCPU
+KVM_SET_USER_MEMORY_REGION  (*) see note
+KVM_GET_DIRTY_LOG  (**) see note
+
+Notes:
+*  kvm does only allow exactly one memory slot on s390, which has to start
+   at guest absolute address zero and at a user address that is aligned on any
+   page boundary. This hardware limitation allows us to have a few unique
+   optimizations. The memory slot doesn't have to be filled
+   with memory actually, it may contain sparse holes. That said, with different
+   user memory layout this does still allow a large flexibility when
+   doing the guest memory setup.
+** KVM_GET_DIRTY_LOG doesn't work properly yet. The user will receive an empty
+log. This ioctl call is only needed for guest migration, and we intend to
+implement this one in the future.
+
+In addition, on s390 the following architecture specific ioctls for the kvm-vm
+file descriptor are supported:
+ioctl: KVM_S390_INTERRUPT
+args:  struct kvm_s390_interrupt *
+see also:  include/linux/kvm.h
+This ioctl is used to submit a floating interrupt for a virtual machine.
+Floating interrupts may be delivered to any virtual cpu in the configuration.
+Only some interrupt types defined in include/linux/kvm.h make sense when
+submitted as floating interrupts. The following interrupts are not considered
+to be useful as floating interrupts, and a call to inject them will result in
+-EINVAL error code: program interrupts and interprocessor signals. Valid
+floating interrupts are:
+KVM_S390_INT_VIRTIO
+KVM_S390_INT_SERVICE
+
+3. ioctl calls to the kvm-vcpu file descriptor
+KVM does support the following ioctls on s390 that are common with other
+architectures and do behave the same:
+KVM_RUN
+KVM_GET_REGS
+KVM_SET_REGS
+KVM_GET_SREGS
+KVM_SET_SREGS
+KVM_GET_FPU
+KVM_SET_FPU
+
+In addition, on s390 the following architecture specific ioctls for the
+kvm-vcpu file descriptor are supported:
+ioctl: KVM_S390_INTERRUPT
+args:  struct kvm_s390_interrupt *
+see also:  include/linux/kvm.h
+This ioctl is used to submit an interrupt for a specific virtual cpu.
+Only some interrupt types defined in include/linux/kvm.h make sense when
+submitted for a specific cpu. The following interrupts are not considered
+to be useful, and a call to inject them will result in -EINVAL error code:
+service processor calls and virtio interrupts. Valid interrupt types are:
+KVM_S390_PROGRAM_INT

[kvm-devel] [RFC/PATCH 09/15 v3] kvm-s390: interprocessor communication via sigp

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This patch introduces in-kernel handling of _some_ sigp interprocessor
signals (similar to ipi).
kvm_s390_handle_sigp() decodes the sigp instruction and calls individual
handlers depending on the operation requested:
- sigp sense tries to retrieve information such as existence or running state
  of the remote cpu
- sigp emergency sends an external interrupt to the remove cpu
- sigp stop stops a remove cpu
- sigp stop store status stops a remote cpu, and stores its entire internal
  state to the cpus lowcore
- sigp set arch sets the architecture mode of the remote cpu. setting to
  ESAME (s390x 64bit) is accepted, setting to ESA/S390 (s390, 31 or 24 bit) is
  denied, all others are passed to userland
- sigp set prefix sets the prefix register of a remote cpu

For implementation of this, the stop intercept indication starts to get reused
on purpose: a set of action bits defines what to do once a cpu gets stopped:
ACTION_STOP_ON_STOP  really stops the cpu when a stop intercept is recognized
ACTION_STORE_ON_STOP stores the cpu status to lowcore when a stop intercept is
 recognized

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/kvm/Makefile  |2 
 arch/s390/kvm/intercept.c   |   22 +++
 arch/s390/kvm/kvm-s390.c|7 +
 arch/s390/kvm/kvm-s390.h|7 +
 arch/s390/kvm/sigp.c|  289 
 include/asm-s390/kvm_host.h |   12 +
 6 files changed, 336 insertions(+), 3 deletions(-)

Index: linux-host/arch/s390/kvm/Makefile
===
--- linux-host.orig/arch/s390/kvm/Makefile
+++ linux-host/arch/s390/kvm/Makefile
@@ -10,5 +10,5 @@ common-objs = $(addprefix ../../../virt/
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
 
-kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o priv.o
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o priv.o 
sigp.o
 obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/intercept.c
===
--- linux-host.orig/arch/s390/kvm/intercept.c
+++ linux-host/arch/s390/kvm/intercept.c
@@ -100,6 +100,7 @@ static int handle_lctl(struct kvm_vcpu *
 }
 
 static intercept_handler_t instruction_handlers[256] = {
+   [0xae] = kvm_s390_handle_sigp,
[0xb2] = kvm_s390_handle_priv,
[0xb7] = handle_lctl,
[0xeb] = handle_lctg,
@@ -122,10 +123,27 @@ static int handle_noop(struct kvm_vcpu *
 
 static int handle_stop(struct kvm_vcpu *vcpu)
 {
+   int rc;
+
vcpu-stat.exit_stop_request++;
-   VCPU_EVENT(vcpu, 3, %s, cpu stopped);
atomic_clear_mask(CPUSTAT_RUNNING, vcpu-arch.sie_block-cpuflags);
-   return -ENOTSUPP;
+   spin_lock_bh(vcpu-arch.local_int.lock);
+   if (vcpu-arch.local_int.action_bits  ACTION_STORE_ON_STOP) {
+   vcpu-arch.local_int.action_bits = ~ACTION_STORE_ON_STOP;
+   rc = __kvm_s390_vcpu_store_status(vcpu,
+ KVM_S390_STORE_STATUS_NOADDR);
+   if (rc = 0)
+   rc = -ENOTSUPP;
+   }
+
+   if (vcpu-arch.local_int.action_bits  ACTION_STOP_ON_STOP) {
+   vcpu-arch.local_int.action_bits = ~ACTION_STOP_ON_STOP;
+   VCPU_EVENT(vcpu, 3, %s, cpu stopped);
+   rc = -ENOTSUPP;
+   } else
+   rc = 0;
+   spin_unlock_bh(vcpu-arch.local_int.lock);
+   return rc;
 }
 
 static int handle_validity(struct kvm_vcpu *vcpu)
Index: linux-host/arch/s390/kvm/kvm-s390.c
===
--- linux-host.orig/arch/s390/kvm/kvm-s390.c
+++ linux-host/arch/s390/kvm/kvm-s390.c
@@ -57,6 +57,12 @@ struct kvm_stats_debugfs_item debugfs_en
{ instruction_chsc, VCPU_STAT(instruction_chsc) },
{ instruction_stsi, VCPU_STAT(instruction_stsi) },
{ instruction_stfl, VCPU_STAT(instruction_stfl) },
+   { instruction_sigp_sense, VCPU_STAT(instruction_sigp_sense) },
+   { instruction_sigp_emergency, VCPU_STAT(instruction_sigp_emergency) },
+   { instruction_sigp_stop, VCPU_STAT(instruction_sigp_stop) },
+   { instruction_sigp_set_arch, VCPU_STAT(instruction_sigp_arch) },
+   { instruction_sigp_set_prefix, VCPU_STAT(instruction_sigp_prefix) },
+   { instruction_sigp_restart, VCPU_STAT(instruction_sigp_restart) },
{ NULL }
 };
 
@@ -290,6 +296,7 @@ struct kvm_vcpu *kvm_arch_vcpu_create(st
spin_lock_bh(kvm-arch.float_int.lock);
kvm-arch.float_int.local_int[id] = vcpu-arch.local_int;
init_waitqueue_head(vcpu-arch.local_int.wq);
+   vcpu-arch.local_int.cpuflags = vcpu-arch.sie_block-cpuflags;
spin_unlock_bh(kvm-arch.float_int.lock);
 
rc 

[kvm-devel] [RFC/PATCH 06/15 v3] kvm-s390: sie intercept handling

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This path introduces handling of sie intercepts in three flavors: Intercepts
are either handled completely in-kernel by kvm_handle_sie_intercept(),
or passed to userspace with corresponding data in struct kvm_run in case
kvm_handle_sie_intercept() returns -ENOTSUPP.
In case of partial execution in kernel with the need of userspace support,
kvm_handle_sie_intercept() may choose to set up struct kvm_run and return
-EREMOTE.

The trivial intercept reasons are handled in this patch:
handle_noop() just does nothing for intercepts that don't require our support
  at all
handle_stop() is called when a cpu enters stopped state, and it drops out to
  userland after updating our vcpu state
handle_validity() faults in the cpu lowcore if needed, or passes the request
  to userland

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/kvm/Makefile  |2 -
 arch/s390/kvm/intercept.c   |   83 
 arch/s390/kvm/kvm-s390.c|   46 +++-
 arch/s390/kvm/kvm-s390.h|6 +++
 include/asm-s390/kvm_host.h |4 ++
 include/linux/kvm.h |9 
 6 files changed, 148 insertions(+), 2 deletions(-)

Index: linux-host/arch/s390/kvm/Makefile
===
--- linux-host.orig/arch/s390/kvm/Makefile
+++ linux-host/arch/s390/kvm/Makefile
@@ -10,5 +10,5 @@ common-objs = $(addprefix ../../../virt/
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
 
-kvm-objs := $(common-objs) kvm-s390.o sie64a.o
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o
 obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/intercept.c
===
--- /dev/null
+++ linux-host/arch/s390/kvm/intercept.c
@@ -0,0 +1,83 @@
+/*
+ * intercept.c - in-kernel handling for sie intercepts
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Carsten Otte [EMAIL PROTECTED]
+ *   Christian Borntraeger [EMAIL PROTECTED]
+ */
+
+#include linux/kvm_host.h
+#include linux/errno.h
+#include linux/pagemap.h
+
+#include asm/kvm_host.h
+
+#include kvm-s390.h
+
+static int handle_noop(struct kvm_vcpu *vcpu)
+{
+   switch (vcpu-arch.sie_block-icptcode) {
+   case 0x10:
+   vcpu-stat.exit_external_request++;
+   break;
+   case 0x14:
+   vcpu-stat.exit_external_interrupt++;
+   break;
+   default:
+   break; /* nothing */
+   }
+   return 0;
+}
+
+static int handle_stop(struct kvm_vcpu *vcpu)
+{
+   vcpu-stat.exit_stop_request++;
+   VCPU_EVENT(vcpu, 3, %s, cpu stopped);
+   atomic_clear_mask(CPUSTAT_RUNNING, vcpu-arch.sie_block-cpuflags);
+   return -ENOTSUPP;
+}
+
+static int handle_validity(struct kvm_vcpu *vcpu)
+{
+   int viwhy = vcpu-arch.sie_block-ipb  16;
+   vcpu-stat.exit_validity++;
+   if (viwhy == 0x37) {
+   fault_in_pages_writeable((char __user *)
+   vcpu-kvm-arch.guest_origin +
+   vcpu-arch.sie_block-prefix, PAGE_SIZE);
+   return 0;
+   }
+   VCPU_EVENT(vcpu, 2, unhandled validity intercept code %d,
+   viwhy);
+   return -ENOTSUPP;
+}
+
+static const intercept_handler_t intercept_funcs[0x48  2] = {
+   [0x00  2] = handle_noop,
+   [0x10  2] = handle_noop,
+   [0x14  2] = handle_noop,
+   [0x20  2] = handle_validity,
+   [0x28  2] = handle_stop,
+};
+
+int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu)
+{
+   intercept_handler_t func;
+   u8 code = vcpu-arch.sie_block-icptcode;
+
+   if (code  3 || code  0x48)
+   return -ENOTSUPP;
+
+   func = intercept_funcs[code  2];
+
+   if (func)
+   return func(vcpu);
+
+   return -ENOTSUPP;
+}
+
Index: linux-host/arch/s390/kvm/kvm-s390.c
===
--- linux-host.orig/arch/s390/kvm/kvm-s390.c
+++ linux-host/arch/s390/kvm/kvm-s390.c
@@ -23,12 +23,17 @@
 #include asm/lowcore.h
 #include asm/pgtable.h
 
+#include kvm-s390.h
 #include gaccess.h
 
 #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
 
 struct kvm_stats_debugfs_item debugfs_entries[] = {
{ userspace_handled, VCPU_STAT(exit_userspace) },
+   { exit_validity, VCPU_STAT(exit_validity) },
+   { exit_stop_request, VCPU_STAT(exit_stop_request) },
+   { exit_external_request, VCPU_STAT(exit_external_request) },
+   { exit_external_interrupt, VCPU_STAT(exit_external_interrupt) },
{ NULL }

[kvm-devel] [RFC/PATCH 10/15 v3] kvm-s390: intercepts for diagnose instructions

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This patch introduces interpretation of some diagnose instruction intercepts.
Diagnose is our classic architected way of doing a hypercall. This patch
features the following diagnose codes:
- vm storage size, that tells the guest about its memory layout
- time slice end, which is used by the guest to indicate that it waits
  for a lock and thus cannot use up its time slice in a useful way
- ipl functions, which a guest can use to reset and reboot itself

In order to implement ipl functions, we also introduce an exit reason that
causes userspace to perform various resets on the virtual machine. All resets
are described in the principles of operation book, except KVM_S390_RESET_IPL
which causes a reboot of the machine.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/kvm/Makefile  |2 -
 arch/s390/kvm/diag.c|   67 
 arch/s390/kvm/intercept.c   |1 
 arch/s390/kvm/kvm-s390.c|1 
 arch/s390/kvm/kvm-s390.h|2 +
 include/asm-s390/kvm_host.h |5 ++-
 include/linux/kvm.h |8 +
 7 files changed, 84 insertions(+), 2 deletions(-)

Index: linux-host/arch/s390/kvm/Makefile
===
--- linux-host.orig/arch/s390/kvm/Makefile
+++ linux-host/arch/s390/kvm/Makefile
@@ -10,5 +10,5 @@ common-objs = $(addprefix ../../../virt/
 
 EXTRA_CFLAGS += -Ivirt/kvm -Iarch/s390/kvm
 
-kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o priv.o 
sigp.o
+kvm-objs := $(common-objs) kvm-s390.o sie64a.o intercept.o interrupt.o priv.o 
sigp.o diag.o
 obj-$(CONFIG_KVM) += kvm.o
Index: linux-host/arch/s390/kvm/diag.c
===
--- /dev/null
+++ linux-host/arch/s390/kvm/diag.c
@@ -0,0 +1,67 @@
+/*
+ * diag.c - handling diagnose instructions
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Carsten Otte [EMAIL PROTECTED]
+ *   Christian Borntraeger [EMAIL PROTECTED]
+ */
+
+#include linux/kvm.h
+#include linux/kvm_host.h
+#include kvm-s390.h
+
+static int __diag_time_slice_end(struct kvm_vcpu *vcpu)
+{
+   VCPU_EVENT(vcpu, 5, %s, diag time slice end);
+   vcpu-stat.diagnose_44++;
+   vcpu_put(vcpu);
+   schedule();
+   vcpu_load(vcpu);
+   return 0;
+}
+
+static int __diag_ipl_functions(struct kvm_vcpu *vcpu)
+{
+   unsigned int reg = vcpu-arch.sie_block-ipa  0xf;
+   unsigned long subcode = vcpu-arch.guest_gprs[reg]  0x;
+
+   VCPU_EVENT(vcpu, 5, diag ipl functions, subcode %lx, subcode);
+   switch (subcode) {
+   case 3:
+   vcpu-run-s390_reset_flags = KVM_S390_RESET_CLEAR;
+   break;
+   case 4:
+   vcpu-run-s390_reset_flags = 0;
+   break;
+   default:
+   return -ENOTSUPP;
+   }
+
+   atomic_clear_mask(CPUSTAT_RUNNING, vcpu-arch.sie_block-cpuflags);
+   vcpu-run-s390_reset_flags |= KVM_S390_RESET_SUBSYSTEM;
+   vcpu-run-s390_reset_flags |= KVM_S390_RESET_IPL;
+   vcpu-run-s390_reset_flags |= KVM_S390_RESET_CPU_INIT;
+   vcpu-run-exit_reason = KVM_EXIT_S390_RESET;
+   VCPU_EVENT(vcpu, 3, requesting userspace resets %lx,
+ vcpu-run-s390_reset_flags);
+   return -EREMOTE;
+}
+
+int kvm_s390_handle_diag(struct kvm_vcpu *vcpu)
+{
+   int code = (vcpu-arch.sie_block-ipb  0xfff)  16;
+
+   switch (code) {
+   case 0x44:
+   return __diag_time_slice_end(vcpu);
+   case 0x308:
+   return __diag_ipl_functions(vcpu);
+   default:
+   return -ENOTSUPP;
+   }
+}
Index: linux-host/arch/s390/kvm/intercept.c
===
--- linux-host.orig/arch/s390/kvm/intercept.c
+++ linux-host/arch/s390/kvm/intercept.c
@@ -100,6 +100,7 @@ static int handle_lctl(struct kvm_vcpu *
 }
 
 static intercept_handler_t instruction_handlers[256] = {
+   [0x83] = kvm_s390_handle_diag,
[0xae] = kvm_s390_handle_sigp,
[0xb2] = kvm_s390_handle_priv,
[0xb7] = handle_lctl,
Index: linux-host/arch/s390/kvm/kvm-s390.c
===
--- linux-host.orig/arch/s390/kvm/kvm-s390.c
+++ linux-host/arch/s390/kvm/kvm-s390.c
@@ -63,6 +63,7 @@ struct kvm_stats_debugfs_item debugfs_en
{ instruction_sigp_set_arch, VCPU_STAT(instruction_sigp_arch) },
{ instruction_sigp_set_prefix, VCPU_STAT(instruction_sigp_prefix) },
{ instruction_sigp_restart, VCPU_STAT(instruction_sigp_restart) },
+   { 

[kvm-devel] [RFC/PATCH 11/15 v3] kvm-s390: add kvm to kconfig on s390

2008-03-25 Thread Carsten Otte
From: Carsten Otte [EMAIL PROTECTED]
From: Christian Borntraeger [EMAIL PROTECTED]

This patch adds the virtualization submenu and the kvm option to the kernel
config. It also defines HAVE_KVM for 64bit kernels.

Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/Kconfig |3 +++
 arch/s390/kvm/Kconfig |   43 +++
 2 files changed, 46 insertions(+)

Index: kvm/arch/s390/Kconfig
===
--- kvm.orig/arch/s390/Kconfig
+++ kvm/arch/s390/Kconfig
@@ -66,6 +66,7 @@ config S390
select HAVE_OPROFILE
select HAVE_KPROBES
select HAVE_KRETPROBES
+   select HAVE_KVM if 64BIT
 
 source init/Kconfig
 
@@ -553,3 +554,5 @@ source security/Kconfig
 source crypto/Kconfig
 
 source lib/Kconfig
+
+source arch/s390/kvm/Kconfig
Index: kvm/arch/s390/kvm/Kconfig
===
--- /dev/null
+++ kvm/arch/s390/kvm/Kconfig
@@ -0,0 +1,43 @@
+#
+# KVM configuration
+#
+config HAVE_KVM
+   bool
+
+menuconfig VIRTUALIZATION
+   bool Virtualization
+   default y
+   ---help---
+ Say Y here to get to see options for using your Linux host to run 
other
+ operating systems inside virtual machines (guests).
+ This option alone does not add any kernel code.
+
+ If you say N, all options in this submenu will be skipped and 
disabled.
+
+if VIRTUALIZATION
+
+config KVM
+   tristate Kernel-based Virtual Machine (KVM) support
+   depends on HAVE_KVM  EXPERIMENTAL
+   select PREEMPT_NOTIFIERS
+   select ANON_INODES
+   select S390_SWITCH_AMODE
+   select PREEMPT
+   ---help---
+ Support hosting paravirtualized guest machines using the SIE
+ virtualization capability on the mainframe. This should work
+ on any 64bit machine.
+
+ This module provides access to the hardware capabilities through
+ a character device node named /dev/kvm.
+
+ To compile this as a module, choose M here: the module
+ will be called kvm.
+
+ If unsure, say N.
+
+# OK, it's a little counter-intuitive to do this, but it puts it neatly under
+# the virtualization menu.
+source drivers/virtio/Kconfig
+
+endif # VIRTUALIZATION



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC/PATCH 15/15 v3] guest: virtio device support, and kvm hypercalls

2008-03-25 Thread Carsten Otte
From: Christian Borntraeger [EMAIL PROTECTED]

This patch implements kvm guest kernel support for paravirtualized devices
and contains two parts:
o a basic virtio stub using virtio_ring and external interrupts and hypercalls
o full hypercall implementation in kvm_para.h

Currently we dont have PCI on s390. Making virtio_pci usable for s390 seems
more complicated that providing an own stub. This virtio stub is similar to
the lguest one, the memory for the descriptors and the device detection is made
via additional mapped memory on top of the guest storage. We use an external
interrupt with extint code 1237 for host-guest notification. 

The hypercall definition uses the diag instruction for issuing a hypercall. The
parameters are written in R2-R7, the hypercall number is written in R1. This is
similar to the system call ABI (svc) which can use R1 for the number and R2-R6 
for the parameters.


Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 drivers/s390/Makefile |2 
 drivers/s390/kvm/Makefile |9 +
 drivers/s390/kvm/kvm_virtio.c |  332 ++
 include/asm-s390/kvm_para.h   |  124 +++
 include/asm-s390/kvm_virtio.h |   54 ++
 5 files changed, 518 insertions(+), 3 deletions(-)

Index: kvm/drivers/s390/Makefile
===
--- kvm.orig/drivers/s390/Makefile
+++ kvm/drivers/s390/Makefile
@@ -5,7 +5,7 @@
 CFLAGS_sysinfo.o += -Iinclude/math-emu -Iarch/s390/math-emu -w
 
 obj-y += s390mach.o sysinfo.o s390_rdev.o
-obj-y += cio/ block/ char/ crypto/ net/ scsi/
+obj-y += cio/ block/ char/ crypto/ net/ scsi/ kvm/
 
 drivers-y += drivers/s390/built-in.o
 
Index: kvm/drivers/s390/kvm/Makefile
===
--- /dev/null
+++ kvm/drivers/s390/kvm/Makefile
@@ -0,0 +1,9 @@
+# Makefile for kvm guest drivers on s390
+#
+# Copyright IBM Corp. 2008
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License (version 2 only)
+# as published by the Free Software Foundation.
+
+obj-$(CONFIG_VIRTIO) += kvm_virtio.o
Index: kvm/drivers/s390/kvm/kvm_virtio.c
===
--- /dev/null
+++ kvm/drivers/s390/kvm/kvm_virtio.c
@@ -0,0 +1,332 @@
+/*
+ * kvm_virtio.c - virtio for kvm on s390
+ *
+ * Copyright IBM Corp. 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License (version 2 only)
+ * as published by the Free Software Foundation.
+ *
+ *Author(s): Christian Borntraeger [EMAIL PROTECTED]
+ */
+
+#include linux/init.h
+#include linux/bootmem.h
+#include linux/err.h
+#include linux/virtio.h
+#include linux/virtio_config.h
+#include linux/interrupt.h
+#include linux/virtio_ring.h
+#include asm/io.h
+#include asm/kvm_para.h
+#include asm/kvm_virtio.h
+#include asm/setup.h
+#include asm/s390_ext.h
+
+/*
+ * The pointer to our (page) of device descriptions.
+ */
+static void *kvm_devices;
+
+/*
+ * Unique numbering for kvm devices.
+ */
+static unsigned int dev_index;
+
+struct kvm_device {
+   struct virtio_device vdev;
+   struct kvm_device_desc *desc;
+};
+
+#define to_kvmdev(vd) container_of(vd, struct kvm_device, vdev)
+
+/*
+ * memory layout:
+ * - kvm_device_descriptor
+ *struct kvm_device_desc
+ * - configuration
+ *struct kvm_vqconfig
+ * - feature bits
+ * - config space
+ */
+static struct kvm_vqconfig *kvm_vq_config(const struct kvm_device_desc *desc)
+{
+   return (struct kvm_vqconfig *)(desc + 1);
+}
+
+static u8 *kvm_vq_features(const struct kvm_device_desc *desc)
+{
+   return (u8 *)(kvm_vq_config(desc) + desc-num_vq);
+}
+
+static u8 *kvm_vq_configspace(const struct kvm_device_desc *desc)
+{
+   return kvm_vq_features(desc) + desc-feature_len * 2;
+}
+
+/*
+ * The total size of the config page used by this device (incl. desc)
+ */
+static unsigned desc_size(const struct kvm_device_desc *desc)
+{
+   return sizeof(*desc)
+   + desc-num_vq * sizeof(struct kvm_vqconfig)
+   + desc-feature_len * 2
+   + desc-config_len;
+}
+
+/*
+ * This tests (and acknowleges) a feature bit.
+ */
+static bool kvm_feature(struct virtio_device *vdev, unsigned fbit)
+{
+   struct kvm_device_desc *desc = to_kvmdev(vdev)-desc;
+   u8 *features;
+
+   if (fbit / 8  desc-feature_len)
+   return false;
+
+   features = kvm_vq_features(desc);
+   if (!(features[fbit / 8]  (1  (fbit % 8
+   return false;
+
+   /*
+* We set the matching bit in the other half of the bitmap to tell the
+* Host we want to use this feature.
+*/
+   features[desc-feature_len + fbit / 8] |= (1  (fbit % 8));
+   return true;
+}

[kvm-devel] [RFC/PATCH 14/15 v3] guest: detect when running on kvm

2008-03-25 Thread Carsten Otte
From: Christian Borntraeger [EMAIL PROTECTED]
From: Carsten Otte [EMAIL PROTECTED]

This patch adds functionality to detect if the kernel runs under the KVM
hypervisor. A macro MACHINE_IS_KVM is exported for device drivers. This
allows drivers to skip device detection if the systems runs non-virtualized.
We also define a preferred console to avoid having the ttyS0, which is a line
mode only console.

Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Acked-by: Martin Schwidefsky [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 arch/s390/Kconfig|7 +++
 arch/s390/kernel/early.c |4 
 arch/s390/kernel/setup.c |   10 +++---
 include/asm-s390/setup.h |1 +
 4 files changed, 19 insertions(+), 3 deletions(-)

Index: kvm/arch/s390/Kconfig
===
--- kvm.orig/arch/s390/Kconfig
+++ kvm/arch/s390/Kconfig
@@ -533,6 +533,13 @@ config ZFCPDUMP
  Select this option if you want to build an zfcpdump enabled kernel.
  Refer to file:Documentation/s390/zfcpdump.txt for more details on 
this.
 
+config S390_GUEST
+bool s390 guest support (EXPERIMENTAL)
+   depends on 64BIT  EXPERIMENTAL
+   select VIRTIO
+   select VIRTIO_RING
+   help
+ Select this option if you want to run the kernel under s390 linux
 endmenu
 
 source net/Kconfig
Index: kvm/arch/s390/kernel/early.c
===
--- kvm.orig/arch/s390/kernel/early.c
+++ kvm/arch/s390/kernel/early.c
@@ -143,6 +143,10 @@ static noinline __init void detect_machi
/* Running on a P/390 ? */
if (cpuinfo-cpu_id.machine == 0x7490)
machine_flags |= 4;
+
+   /* Running under KVM ? */
+   if (cpuinfo-cpu_id.version == 0xfe)
+   machine_flags |= 64;
 }
 
 #ifdef CONFIG_64BIT
Index: kvm/arch/s390/kernel/setup.c
===
--- kvm.orig/arch/s390/kernel/setup.c
+++ kvm/arch/s390/kernel/setup.c
@@ -793,9 +793,13 @@ setup_arch(char **cmdline_p)
   This machine has an IEEE fpu\n :
   This machine has no IEEE fpu\n);
 #else /* CONFIG_64BIT */
-   printk((MACHINE_IS_VM) ?
-  We are running under VM (64 bit mode)\n :
-  We are running native (64 bit mode)\n);
+   if (MACHINE_IS_VM)
+   printk(We are running under VM (64 bit mode)\n);
+   else if (MACHINE_IS_KVM) {
+   printk(We are running under KVM (64 bit mode)\n);
+   add_preferred_console(ttyS, 1, NULL);
+   } else
+   printk(We are running native (64 bit mode)\n);
 #endif /* CONFIG_64BIT */
 
/* Save unparsed command line copy for /proc/cmdline */
Index: kvm/include/asm-s390/setup.h
===
--- kvm.orig/include/asm-s390/setup.h
+++ kvm/include/asm-s390/setup.h
@@ -62,6 +62,7 @@ extern unsigned long machine_flags;
 #define MACHINE_IS_VM  (machine_flags  1)
 #define MACHINE_IS_P390(machine_flags  4)
 #define MACHINE_HAS_MVPG   (machine_flags  16)
+#define MACHINE_IS_KVM (machine_flags  64)
 #define MACHINE_HAS_IDTE   (machine_flags  128)
 #define MACHINE_HAS_DIAG9C (machine_flags  256)
 



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC/PATCH 13/15 v3] kvm-s390: update maintainers

2008-03-25 Thread Carsten Otte
From: Christian Borntraeger [EMAIL PROTECTED]

This patch adds an entry for kvm on s390 to the MAINTAINERS file :-). We intend
to push all patches regarding this via Avi's kvm.git.

Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Signed-off-by: Carsten Otte [EMAIL PROTECTED]
---
 MAINTAINERS |   10 ++
 1 files changed, 10 insertions(+)

Index: linux-host/MAINTAINERS
===
--- linux-host.orig/MAINTAINERS
+++ linux-host/MAINTAINERS
@@ -2305,6 +2305,16 @@ L:   [EMAIL PROTECTED]
 W: kvm.sourceforge.net
 S: Supported
 
+KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
+P: Carsten Otte
+M: [EMAIL PROTECTED]
+P: Christian Borntraeger
+M: [EMAIL PROTECTED]
+M: [EMAIL PROTECTED]
+L: [EMAIL PROTECTED]
+W: http://www.ibm.com/developerworks/linux/linux390/
+S: Supported
+
 KEXEC
 P: Eric Biederman
 M: [EMAIL PROTECTED]



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Attaching to the virtual console/keyboard/mouse of kvm instance using a unix/socket

2008-03-25 Thread Charles Duffy
Thomas Glanzmann wrote:
 Hello,
 is it possible to connect to the virtual monitor/keyboard/mouse of
 an already running kvm instance using a socket when started without an
 x-window system and _not_ using vnc? I have something in the back of my
 head using libvirt but I am unable to find it.

Well -- if you're not doing anything graphical, you could use the new 
ncurses display mode. Set your scripts up to allocate a new PTY each 
time, connect those PTYs to screen, and you're golden. If your needs are 
simpler, something similar could be done using serial console support.

While libvirt doesn't currently know anything about serial console 
configuration or ncurses display / PTY support, it's just waiting on 
someone with time to implement it -- might eventually be me, if nobody 
else gets there first.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] buliding and testing PowerPC KVM

2008-03-25 Thread Hollis Blanchard
On Tue, 2008-03-25 at 18:56 +0200, Avi Kivity wrote:
 Hollis Blanchard wrote:
  On Fri, 2008-03-21 at 13:02 +0200, Avi Kivity wrote:

  Other than that, and the few minor comments that popped up, this
  (very 
  nice) patchset will be very easy to merge.  IIRC you mentioned it is 
  possible for me to get an s390 account; this will be very useful in 
  avoiding breaking this port, as happens quite often with ppc and
  ia64.  
  I'd like to be able to do both build and run testing.
  
 
  As for building the PowerPC code, cross-compiling is easy with
  http://kegel.com/crosstool . There are also a number of servers offering
  remote PowerPC ssh access: see http://penguinppc.org/dev/#remote .
 
 I now have a ppc account.  Once you point me at the ppc kernel repo I 
 can start build testing.

% cd kvm.git
% curl http://penguinppc.org/~hollisb/kvm/kvmppc.mbox | git-am

That directory also contains tip, which tells you what upstream
changeset the patchqueue is based on.

-- 
Hollis Blanchard
IBM Linux Technology Center


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] buliding and testing PowerPC KVM

2008-03-25 Thread Jerone Young
So it's actually really easy using cross compiler to build everything. I
use my laptop and then copy over to our nfs root that our boards use. 

Here are some instructions I wrote up for someone earlier. Excuse the
fill me parts but it is enough to get you going:







On Tue, 2008-03-25 at 18:56 +0200, Avi Kivity wrote:
 Hollis Blanchard wrote:
  On Fri, 2008-03-21 at 13:02 +0200, Avi Kivity wrote:

  Other than that, and the few minor comments that popped up, this
  (very 
  nice) patchset will be very easy to merge.  IIRC you mentioned it is 
  possible for me to get an s390 account; this will be very useful in 
  avoiding breaking this port, as happens quite often with ppc and
  ia64.  
  I'd like to be able to do both build and run testing.
  
 
  As for building the PowerPC code, cross-compiling is easy with
  http://kegel.com/crosstool . There are also a number of servers offering
  remote PowerPC ssh access: see http://penguinppc.org/dev/#remote .
 

 
 I now have a ppc account.  Once you point me at the ppc kernel repo I 
 can start build testing.
 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] buliding and testing PowerPC KVM

2008-03-25 Thread Jerone Young
* Sorry was going for paste, and somehow hit send.

So it's actually really easy using cross compiler to build everything. I
use my laptop and then copy over to our nfs root that our boards use. 

Here are some instructions I wrote up for someone earlier. Excuse the
fill me parts but it is enough to get you going:

This is a run through of how to build kvmppc kernel  kvm-userspace

You will need (all will have info how to get and install):

- cross tools 
- zlib
- Linux kernel with KVM powerpc patches
- kvm-userspace tools


1) Grabbing need tools
===

1a) Cross Tools

- If you are running on an x86 based machine you need these tools
- cross tools can be found at:
http://www.kegel.com/crosstool/crosstool-0.43.tar.gz
Installation

- Untar tarball and go into folder
- If you are using Ubuntu linux .. replace /bin/sh symlink:
sudo ln -sf /bin/bash /bin/sh
- As root, create folder /opt/crosstool. Then change the
  permissions to allow everyone write access..this can be done
  by running:
  chmod 777 /opt/crosstool
- As a normal user run:
./demo-powerpc-405.sh
- Once done you should have directory in that is something like:
/opt/crosstool/gcc-version-glibc-version
- Now you want to add the bin direcotry to your $PATH
/opt/crosstool/gcc-version-glibc-version/powerpc-405-linux-gnu/bin
- Done

1b) Zlib

- Now you need to compile a version of Zlib for powerpc
- This will be used when building qemu while building kvm-userspace
- zlib source can be found at:
http://www.zlib.net/zlib-1.2.3.tar.gz
Installation

- Untar tarball and go into folder
- Type the following in the follwoing.
  type in:
CC=powerpc405-linux-gnu-gcc ./configure
- The run:
make
- DO NOT INSTALL
- You will now want to keep this directory around for later.

1c) Linux kernel with KVM PPC
-
- Currently patches are not upstream yet. You will need to get source
  from Hollis Blanchard or myself

1d) Kvm-userspace
--
- You will need to get the bleeding edge latest version of
kvm-userspace
  tools to work for powerpc.
- To get these you will have to grab them from the git repository.
- You must first install git tools that can be found here:
http://git.or.cz/
- Now you can grab the folder by running the command:
git clone 
git://git.kernel.org/pub/scm/virt/kvm/kvm-userspace.git



2) Compiling Linux Kernel with kvm powerpc 
==
- Untar and go into directory

2a) Compiling a host kernel
---
- You will first need to copy over the default configuration for the
board
  you are running on.
-For 440EP Bamboo:
cp arch/powerpc/configs/bamboo_defconfig .config
-For 440EPx Sequioa:
cp arch/powerpc/configs/sequoia_defconfig .config
- Now go into the menuconfiguration with the follwoing command:
make ARCH=powerpc CROSS_COMPILE=powerpc405-linux-gnu- menuconfig
- Once in menu, enable menu option  Virtualization
- Then enable Virtualization-Kernel-based Virtual Machine (KVM)
support
- Also enable Virtualization-KVM guest support for PowerPC 440
- Save configuration
- Now to compile your kernel
  -For 440EP Bamboo:
- make ARCH=powerpc CROSS_COMPILE=powerpc405-linux-gnu- 
treeImage
  -For 440EPx Sequioa:
- make ARCH=powerpc CROSS_COMPILE=powerpc440-linux-gnu- cuImage

- Once compilation is done you will find kernel in proper format in
  arch/powerpc/boot/
   -For 440EP Bamboo it will be treeImage
   -For 440EPx Sequioa it will be cuImage

2b) Compiling a guest kernel for KVM

- will fill in, this is in the process of changing


3) Builing kvm-userspace

- you will need a zlib compiled for powerpc
- you will need a complied copy of Linux kernel with kvm powerpc

3a) Compiling kvm-userspace
---
- Go into kvm-userspace directory
- To configure kvm-userspace you need to run the follwing command.
  NOTE to fill in areas where there is ?:
  ./configure --arch=powerpc 

Re: [kvm-devel] [kvm-ppc-devel] [PATCH] Add -Werror to libkvm compile

2008-03-25 Thread Jerone Young
Yeah. This could potentially cause hell for users (non developers)
down the road. I'm just going to keep this patch in my queue for myself,
so no one will complain about warnings from my patches anymore. 

I think having a --developer flag to configure could work, but we would
then need separate file for including the CFLAG, this would just clutter
things more. 

On Tue, 2008-03-25 at 19:08 +0200, Avi Kivity wrote:
 Jerone Young wrote:
  It does work with gcc 4.2.3 . Though no idea if gcc-4.3  4.4 would
  workout. Though they should. I'll need to to compile them and give them
  a try.

 
 While I'm a fan of -Werror, I have to agree with Anthony it can cause no 
 end of pain to users if they have a slightly different configuration.
 
 Maybe enable it conditionally based on ./configure --developer as 
 Anthony suggests (but I'll forget to use it myself, I'm sure).
 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] + kvm-provide-kvmh-for-all-architecture-fixes-headers_install.patch added to -mm tree

2008-03-25 Thread Andrew Morton
On Tue, 25 Mar 2008 16:31:46 +0100
Christian Borntraeger [EMAIL PROTECTED] wrote:

 Am Mittwoch, 12. M__rz 2008 schrieben Sie:
  
  The patch titled
   kvm: provide kvm.h for all architecture: fixes headers_install
  has been added to the -mm tree.  Its filename is
   kvm-provide-kvmh-for-all-architecture-fixes-headers_install.patch
  
 
 Hello Andrew,
 
 is there a chance to submit this patch before 2.6.25? headers_install of 
 kvm.h worked with 2.6.24 but is still broken with 2.6.25-rc.

Sure, I'll merge it.

From: Christian Borntraeger [EMAIL PROTECTED]

Currently include/linux/kvm.h is not considered by make headers_install,
because Kbuild cannot handle  unifdef-$(CONFIG_FOO) += foo.h.  This problem
was introduced by 040922c04cf2c8ac70be2e88a8a9614ecdb41d2e, which makes this
an 2.6.25 regression.

One way of solving the issue is to enhance Kbuild, but Avi and David conviced
me, that changing headers_install is not the way to go.  This patch changes
the definition for linux/kvm.h to unifdef-y.

If _unifdef-y is used for linux/kvm.h make headers_check will fail on all
architectures without asm/kvm.h.  Therefore, this patch also provides
asm/kvm.h on all architectures.

Signed-off-by: Christian Borntraeger [EMAIL PROTECTED]
Acked-by: Avi Kivity [EMAIL PROTECTED]
Cc: Sam Ravnborg [EMAIL PROTECTED]
Cc: David Woodhouse [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
---

 include/asm-alpha/kvm.h|6 ++
 include/asm-arm/kvm.h  |6 ++
 include/asm-avr32/kvm.h|6 ++
 include/asm-blackfin/kvm.h |6 ++
 include/asm-cris/kvm.h |6 ++
 include/asm-frv/kvm.h  |6 ++
 include/asm-generic/Kbuild.asm |2 ++
 include/asm-h8300/kvm.h|6 ++
 include/asm-ia64/kvm.h |6 ++
 include/asm-m32r/kvm.h |6 ++
 include/asm-m68k/kvm.h |6 ++
 include/asm-m68knommu/kvm.h|6 ++
 include/asm-mips/kvm.h |6 ++
 include/asm-mn10300/kvm.h  |6 ++
 include/asm-parisc/kvm.h   |6 ++
 include/asm-powerpc/kvm.h  |6 ++
 include/asm-s390/kvm.h |6 ++
 include/asm-sh/kvm.h   |6 ++
 include/asm-sparc/kvm.h|6 ++
 include/asm-sparc64/kvm.h  |6 ++
 include/asm-um/kvm.h   |6 ++
 include/asm-v850/kvm.h |6 ++
 include/asm-xtensa/kvm.h   |6 ++
 include/linux/Kbuild   |2 +-
 24 files changed, 135 insertions(+), 1 deletion(-)

diff -puN /dev/null include/asm-alpha/kvm.h
--- /dev/null
+++ a/include/asm-alpha/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_ALPHA_H
+#define __LINUX_KVM_ALPHA_H
+
+/* alpha does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-arm/kvm.h
--- /dev/null
+++ a/include/asm-arm/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_ARM_H
+#define __LINUX_KVM_ARM_H
+
+/* arm does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-avr32/kvm.h
--- /dev/null
+++ a/include/asm-avr32/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_AVR32_H
+#define __LINUX_KVM_AVR32_H
+
+/* avr32 does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-blackfin/kvm.h
--- /dev/null
+++ a/include/asm-blackfin/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_BLACKFIN_H
+#define __LINUX_KVM_BLACKFIN_H
+
+/* blackfin does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-cris/kvm.h
--- /dev/null
+++ a/include/asm-cris/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_CRIS_H
+#define __LINUX_KVM_CRIS_H
+
+/* cris does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-frv/kvm.h
--- /dev/null
+++ a/include/asm-frv/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_FRV_H
+#define __LINUX_KVM_FRV_H
+
+/* frv does not support KVM */
+
+#endif
diff -puN 
include/asm-generic/Kbuild.asm~kvm-provide-kvmh-for-all-architecture-fixes-headers_install
 include/asm-generic/Kbuild.asm
--- 
a/include/asm-generic/Kbuild.asm~kvm-provide-kvmh-for-all-architecture-fixes-headers_install
+++ a/include/asm-generic/Kbuild.asm
@@ -1,3 +1,5 @@
+header-y  += kvm.h
+
 ifeq ($(wildcard 
include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h)
 unifdef-y += a.out.h
 endif
diff -puN /dev/null include/asm-h8300/kvm.h
--- /dev/null
+++ a/include/asm-h8300/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_H8300_H
+#define __LINUX_KVM_H8300_H
+
+/* h8300 does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-ia64/kvm.h
--- /dev/null
+++ a/include/asm-ia64/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_IA64_H
+#define __LINUX_KVM_IA64_H
+
+/* ia64 does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-m32r/kvm.h
--- /dev/null
+++ a/include/asm-m32r/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_M32R_H
+#define __LINUX_KVM_M32R_H
+
+/* m32r does not support KVM */
+
+#endif
diff -puN /dev/null include/asm-m68k/kvm.h
--- /dev/null
+++ a/include/asm-m68k/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_M68K_H
+#define 

[kvm-devel] kvm causing memory corruption? ~2.6.25-rc6

2008-03-25 Thread Dave Hansen
I was getting some kvm userspace crashes trying to run a Windows guest.
So, I decided to try a recent kernel (2.6.25-rc6-00333-ga4083c9)  with
the kvm kernel code that shipped with that kernel.

I've had some lockups doing similar things over the last month or two,
but figured it was something really stupid I was doing, and never really
connected the dots.  Now, I've hooked up a serial console and reproduced
it with a fresh boot and not much else going on at all on the machine.

Machine is a Thinkpad T61.  .config is here:

http://sr71.net/~dave/linux/config-2.6.25-rc6-00333-ga4083c9

To trigger it, I first run kvm and see an error (-no-kvm works fine,
btw):

$ ~/src/kvm-userspace/qemu/x86_64-softmmu/qemu-system-x86_64 -hda 
~/projects/qemu/windows-xp-base-runme.img 
kvm_run: Cannot allocate memory
kvm_run returned -12

Then, run it again.  I usually get an oops.  But, the weird part is that
the oops isn't *in* kvm.  It's in some other part of the kernel and in
some *OTHER* process.  One in bash is below.  That's what leads me to
believe it is memory corruption.  The machine also becomes increasingly
unstable after the original oops so there's definitely collateral
damage.

$ addr2line -e vmlinux c01795e4
/home/dave/kernels/linux-2.6.git/mm/filemap.c:1327

int filemap_fault(struct vm_area_struct *vma, struct vm_fault
*vmf)
{
int error;
struct file *file = vma-vm_file;
struct address_space *mapping = file-f_mapping;
struct file_ra_state *ra = file-f_ra;
HERE---struct inode *inode = mapping-host;

Which is a line of code that literally hasn't touched since the
beginning of time (in git terms :).  Full oops is below:

[  435.057922] BUG: unable to handle kernel NULL pointer dereference at 0048
[  435.067275] IP: [c01795e4] filemap_fault+0x34/0x310
[  435.072815] *pdpt = 2a4a7001 *pde =  
[  435.081272] Oops:  [#2] SMP 
[  435.084812] Modules linked in: nls_iso8859_1 vfat fat rfcomm l2cap tun ppdev 
acpi_cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_stats freq_table 
cpufreq_userspace cpufreq_powersave sbs container sbshc af_packet sbp2 lp loop 
usb_storage arc4 ecb crypto_blkcipher pcmcia usbhid libusual hid snd_hda_intel 
snd_pcm_oss snd_mixer_oss snd_pcm snd_seq_dummy snd_seq_oss snd_seq_midi_event 
snd_seq snd_timer snd_seq_device joydev iwl4965 snd serio_raw mac80211 
yenta_socket parport_pc sdhci uhci_hcd ehci_hcd ricoh_mmc ohci1394 
rsrc_nonstatic soundcore cfg80211 parport psmouse mmc_core ieee1394 pcmcia_core 
usbcore snd_page_alloc e1000 button thinkpad_acpi nvram evdev thermal processor 
fan fuse
[  435.084812] 
[  435.084812] Pid: 7691, comm: bash Tainted: G  D  
(2.6.25-rc6-00333-ga4083c9 #144)
[  435.084812] EIP: 0060:[c01795e4] EFLAGS: 00010286 CPU: 0
[  435.084812] EIP is at filemap_fault+0x34/0x310
[  435.084812] EAX: ef83bf48 EBX: 0012 ECX:  EDX: ef83c7e8
[  435.084812] ESI: c04cc248 EDI:  EBP: ef96ee40 ESP: ef96ee00
[  435.084812]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
[  435.084812] Process bash (pid: 7691, ti=ef96e000 task=ef8a2e00 
task.ti=ef96e000)
[  435.084812] Stack: ef96ee2c c0130cbc ef96ee28 c01870bb ef96ee28  
  
[  435.084812]ef83bf48 ef83c7e8 ef83bf00 ef96ee9c ea49f7e8 0012 
c04cc248  
[  435.084812]ef96eeb8 c018ab57 8001 0001 0001  
 eacb6314 
[  435.084812] Call Trace:
[  435.084812]  [c0130cbc] ? kmap_atomic_prot+0x12c/0x150
[  435.084812]  [c01870bb] ? vm_normal_page+0x2b/0xa0
[  435.084812]  [c018ab57] ? __do_fault+0x67/0x4e0
[  435.084812]  [c01a8a70] ? pipe_read+0x1f0/0x290
[  435.084812]  [c018b03d] ? do_linear_fault+0x6d/0x80
[  435.084812]  [c018b570] ? handle_mm_fault+0x1c0/0x4d0
[  435.084812]  [c014d58e] ? do_sigaction+0x16e/0x190
[  435.084812]  [c03b3419] ? do_page_fault+0x169/0x4d0
[  435.084812]  [c01a38b9] ? fput+0x19/0x20
[  435.084812]  [c03b32b0] ? do_page_fault+0x0/0x4d0
[  435.084812]  [c03b187a] ? error_code+0x72/0x78
[  435.084812]  [c03b] ? wait_for_completion_killable+0x10/0x30
[  435.084812]  ===
[  435.084812] Code: 89 45 f0 89 55 ec 8b 40 4c 89 45 e8 8b 50 7c 83 c0 48 89 
45 e0 89 55 e4 8b 0a c7 45 d8 00 00 00 00 c7 45 d4 00 00 00 00 89 4d dc 8b 49 
48 89 f6 8d bc 27 00 00 00 00 89 c8 8b 7d dc 8b 5f 40 8b 
[  435.084812] EIP: [c01795e4] filemap_fault+0x34/0x310 SS:ESP 0068:ef96ee00
[  435.084870] ---[ end trace addcd60623916614 ]---

~/src/kvm-userspace$ git describe
kvm-63-118-g52be1a1

/proc/cpuinfo:

processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model   : 15
model name  : Intel(R) Core(TM)2 Duo CPU T7300  @ 2.00GHz
stepping: 10
cpu MHz : 800.000
cache size  : 4096 KB
physical id : 0
siblings: 2
core id : 0
cpu cores   : 2
fdiv_bug: no
hlt_bug : no

[kvm-devel] [PATCH 0/20] dma_ops for i386

2008-03-25 Thread Glauber Costa
Hello,

Here there is a series of 20 patches that lays the foundations for
using dma_ops in i386 in the very same way x86_64, as well as many other
architectures already do.

The functions themselves for i386 are placed in a pci-base_32.c, but just
a few among them are actually implemented. Most were no-ops anyway.

Also, as I said, this is by no means a complete coverage of dma_ops.
there are still some call sites to be patches in pci-dma_32.c (although I don't
really plan to change them, but to integrate them in a single pci-dma.c).
I intend to have it done progressively.

The granularity is per-operation, meaning each patch moves one specific function
to the common header. This is compiled-tested in both i386 and x86_64 in 
~5 randconfigs each, and boot-tested in my hardware with my default configs

The motivation for that is the ongoing work for pci-passthrough in KVM.
So ingo, avi, what do you think it's the best way to handle these patches 
through?

Thanks



-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 01/20] x86: move dma_ops struct definition to dma-mapping.h

2008-03-25 Thread Glauber Costa
take it off the x86_64 specific header

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|   54 ++
 include/asm-x86/dma-mapping_64.h |   49 --
 2 files changed, 54 insertions(+), 49 deletions(-)

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 58f790f..aebd178 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -1,5 +1,59 @@
+#ifndef _ASM_DMA_MAPPING_H_
+#define _ASM_DMA_MAPPING_H_
+
+/*
+ * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for
+ * documentation.
+ */
+
+#include linux/scatterlist.h
+#include asm/io.h
+#include asm/swiotlb.h
+
+struct dma_mapping_ops {
+   int (*mapping_error)(dma_addr_t dma_addr);
+   void*   (*alloc_coherent)(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t gfp);
+   void(*free_coherent)(struct device *dev, size_t size,
+   void *vaddr, dma_addr_t dma_handle);
+   dma_addr_t  (*map_single)(struct device *hwdev, void *ptr,
+   size_t size, int direction);
+   /* like map_single, but doesn't check the device mask */
+   dma_addr_t  (*map_simple)(struct device *hwdev, char *ptr,
+   size_t size, int direction);
+   void(*unmap_single)(struct device *dev, dma_addr_t addr,
+   size_t size, int direction);
+   void(*sync_single_for_cpu)(struct device *hwdev,
+   dma_addr_t dma_handle, size_t size,
+   int direction);
+   void(*sync_single_for_device)(struct device *hwdev,
+   dma_addr_t dma_handle, size_t size,
+   int direction);
+   void(*sync_single_range_for_cpu)(struct device *hwdev,
+   dma_addr_t dma_handle, unsigned long offset,
+   size_t size, int direction);
+   void(*sync_single_range_for_device)(struct device *hwdev,
+   dma_addr_t dma_handle, unsigned long offset,
+   size_t size, int direction);
+   void(*sync_sg_for_cpu)(struct device *hwdev,
+   struct scatterlist *sg, int nelems,
+   int direction);
+   void(*sync_sg_for_device)(struct device *hwdev,
+   struct scatterlist *sg, int nelems,
+   int direction);
+   int (*map_sg)(struct device *hwdev, struct scatterlist *sg,
+   int nents, int direction);
+   void(*unmap_sg)(struct device *hwdev,
+   struct scatterlist *sg, int nents,
+   int direction);
+   int (*dma_supported)(struct device *hwdev, u64 mask);
+   int is_phys;
+};
+
 #ifdef CONFIG_X86_32
 # include dma-mapping_32.h
 #else
 # include dma-mapping_64.h
 #endif
+
+#endif
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index ecd0f61..369188a 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -1,55 +1,6 @@
 #ifndef _X8664_DMA_MAPPING_H
 #define _X8664_DMA_MAPPING_H 1
 
-/*
- * IOMMU interface. See Documentation/DMA-mapping.txt and DMA-API.txt for
- * documentation.
- */
-
-#include linux/scatterlist.h
-#include asm/io.h
-#include asm/swiotlb.h
-
-struct dma_mapping_ops {
-   int (*mapping_error)(dma_addr_t dma_addr);
-   void*   (*alloc_coherent)(struct device *dev, size_t size,
-dma_addr_t *dma_handle, gfp_t gfp);
-   void(*free_coherent)(struct device *dev, size_t size,
-void *vaddr, dma_addr_t dma_handle);
-   dma_addr_t  (*map_single)(struct device *hwdev, void *ptr,
-size_t size, int direction);
-   /* like map_single, but doesn't check the device mask */
-   dma_addr_t  (*map_simple)(struct device *hwdev, char *ptr,
-size_t size, int direction);
-   void(*unmap_single)(struct device *dev, dma_addr_t addr,
-   size_t size, int direction);
-   void(*sync_single_for_cpu)(struct device *hwdev,
-   dma_addr_t dma_handle, size_t size,
-   int direction);
-   void(*sync_single_for_device)(struct device *hwdev,
-dma_addr_t dma_handle, size_t size,
-   int direction);
-   void

[kvm-devel] [PATCH 04/20] x86: move dma_map_sg to common header

2008-03-25 Thread Glauber Costa
the old i386 implementation is moved to pci-base_32.c

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|   19 +++
 include/asm-x86/dma-mapping.h|8 +++-
 include/asm-x86/dma-mapping_32.h |   20 
 include/asm-x86/dma-mapping_64.h |7 ---
 4 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index a8a7c7f..2474152 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -12,9 +12,28 @@ static dma_addr_t pci32_map_single(struct device *dev, void 
*ptr,
return virt_to_phys(ptr);
 }
 
+static int pci32_dma_map_sg(struct device *dev, struct scatterlist *sglist,
+   int nents, int direction)
+{
+   struct scatterlist *sg;
+   int i;
+
+   WARN_ON(nents == 0 || sglist[0].length == 0);
+
+   for_each_sg(sglist, sg, nents, i) {
+   BUG_ON(!sg_page(sg));
+
+   sg-dma_address = sg_phys(sg);
+   }
+
+   flush_write_buffers();
+   return nents;
+}
+
 static const struct dma_mapping_ops pci32_dma_ops = {
.map_single = pci32_map_single,
.unmap_single = NULL,
+   .map_sg = pci32_dma_map_sg,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index bb0378f..0901154 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -75,5 +75,11 @@ dma_unmap_single(struct device *dev, dma_addr_t addr, size_t 
size,
dma_ops-unmap_single(dev, addr, size, direction);
 }
 
-
+static inline int
+dma_map_sg(struct device *hwdev, struct scatterlist *sg,
+  int nents, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   return dma_ops-map_sg(hwdev, sg, nents, direction);
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 0b27cb0..cdcdeff 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -17,26 +17,6 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 void dma_free_coherent(struct device *dev, size_t size,
 void *vaddr, dma_addr_t dma_handle);
 
-static inline int
-dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
-  enum dma_data_direction direction)
-{
-   struct scatterlist *sg;
-   int i;
-
-   BUG_ON(!valid_dma_direction(direction));
-   WARN_ON(nents == 0 || sglist[0].length == 0);
-
-   for_each_sg(sglist, sg, nents, i) {
-   BUG_ON(!sg_page(sg));
-
-   sg-dma_address = sg_phys(sg);
-   }
-
-   flush_write_buffers();
-   return nents;
-}
-
 static inline dma_addr_t
 dma_map_page(struct device *dev, struct page *page, unsigned long offset,
 size_t size, enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 5d349db..b27527a 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -96,13 +96,6 @@ dma_sync_sg_for_device(struct device *hwdev, struct 
scatterlist *sg,
flush_write_buffers();
 }
 
-static inline int
-dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int 
direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   return dma_ops-map_sg(hwdev, sg, nents, direction);
-}
-
 static inline void
 dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
 int direction)
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 03/20] x86: move dma_unmap_single to common header

2008-03-25 Thread Glauber Costa
i386 base does not need it, so it gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   10 ++
 include/asm-x86/dma-mapping_32.h |7 ---
 include/asm-x86/dma-mapping_64.h |8 
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index b613d73..a8a7c7f 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -14,6 +14,7 @@ static dma_addr_t pci32_map_single(struct device *dev, void 
*ptr,
 
 static const struct dma_mapping_ops pci32_dma_ops = {
.map_single = pci32_map_single,
+   .unmap_single = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index d320244..bb0378f 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -66,4 +66,14 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size,
return dma_ops-map_single(hwdev, ptr, size, direction);
 }
 
+static inline void
+dma_unmap_single(struct device *dev, dma_addr_t addr, size_t size,
+int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-unmap_single)
+   dma_ops-unmap_single(dev, addr, size, direction);
+}
+
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index b496306..0b27cb0 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -17,13 +17,6 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 void dma_free_coherent(struct device *dev, size_t size,
 void *vaddr, dma_addr_t dma_handle);
 
-static inline void
-dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
-enum dma_data_direction direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-}
-
 static inline int
 dma_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
   enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 969a7da..5d349db 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -23,14 +23,6 @@ extern void *dma_alloc_coherent(struct device *dev, size_t 
size,
 extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
  dma_addr_t dma_handle);
 
-static inline void
-dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
-int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   dma_ops-unmap_single(dev, addr, size, direction);
-}
-
 #define dma_map_page(dev,page,offset,size,dir) \
dma_map_single((dev), page_address(page)+(offset), (size), (dir))
 
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 06/20] x86: move dma_sync_single_for_cpu to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   12 
 include/asm-x86/dma-mapping_32.h |6 --
 include/asm-x86/dma-mapping_64.h |   11 ---
 4 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index 9205304..dce03c8 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -35,6 +35,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.unmap_single = NULL,
.map_sg = pci32_dma_map_sg,
.unmap_sg = NULL,
+   .sync_single_for_cpu = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 6e7747a..507069d 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -91,4 +91,16 @@ dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, 
int nents,
if (dma_ops-unmap_sg)
dma_ops-unmap_sg(hwdev, sg, nents, direction);
 }
+
+static inline void
+dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+   size_t size, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_single_for_cpu)
+   dma_ops-sync_single_for_cpu(hwdev, dma_handle, size,
+direction);
+   flush_write_buffers();
+}
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 55445e3..a05b2fc 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -33,12 +33,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
 }
 
 static inline void
-dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
-   enum dma_data_direction direction)
-{
-}
-
-static inline void
 dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t 
size,
enum dma_data_direction direction)
 {
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index ce37efb..b055964 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -29,17 +29,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 #define dma_unmap_page dma_unmap_single
 
 static inline void
-dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
-   size_t size, int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_single_for_cpu)
-   dma_ops-sync_single_for_cpu(hwdev, dma_handle, size,
-direction);
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
   size_t size, int direction)
 {
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 02/20] x86: implement dma_map_single through dma_ops

2008-03-25 Thread Glauber Costa
That's already the name of the game for x86_64. For i386,
we add a pci-base_32.c, that will hold the default operations.
The function call itself goes through dma-mapping.h , the common
header

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/Makefile |1 +
 arch/x86/kernel/pci-base_32.c|   20 
 include/asm-x86/dma-mapping.h|   10 ++
 include/asm-x86/dma-mapping_32.h |   10 --
 include/asm-x86/dma-mapping_64.h |9 -
 5 files changed, 31 insertions(+), 19 deletions(-)
 create mode 100644 arch/x86/kernel/pci-base_32.c

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 340221f..95fbf57 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -27,6 +27,7 @@ obj-y += pci-dma_$(BITS).o  bootflag.o 
e820_$(BITS).o
 obj-y  += quirks.o i8237.o topology.o kdebugfs.o
 obj-y  += alternative.o i8253.o
 obj-$(CONFIG_X86_64)   += pci-nommu_64.o bugs_64.o
+obj-$(CONFIG_X86_32)   += pci-base_32.o
 obj-y  += tsc_$(BITS).o io_delay.o rtc.o
 
 obj-y  += process.o
diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
new file mode 100644
index 000..b613d73
--- /dev/null
+++ b/arch/x86/kernel/pci-base_32.c
@@ -0,0 +1,20 @@
+#include linux/mm.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/dma-mapping.h
+#include asm/dma-mapping.h
+
+static dma_addr_t pci32_map_single(struct device *dev, void *ptr,
+  size_t size, int direction)
+{
+   WARN_ON(size == 0);
+   flush_write_buffers();
+   return virt_to_phys(ptr);
+}
+
+static const struct dma_mapping_ops pci32_dma_ops = {
+   .map_single = pci32_map_single,
+};
+
+const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
+EXPORT_SYMBOL(dma_ops);
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index aebd178..d320244 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -50,10 +50,20 @@ struct dma_mapping_ops {
int is_phys;
 };
 
+extern const struct dma_mapping_ops *dma_ops;
+
 #ifdef CONFIG_X86_32
 # include dma-mapping_32.h
 #else
 # include dma-mapping_64.h
 #endif
 
+static inline dma_addr_t
+dma_map_single(struct device *hwdev, void *ptr, size_t size,
+  int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   return dma_ops-map_single(hwdev, ptr, size, direction);
+}
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 55f01bd..b496306 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -17,16 +17,6 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
 void dma_free_coherent(struct device *dev, size_t size,
 void *vaddr, dma_addr_t dma_handle);
 
-static inline dma_addr_t
-dma_map_single(struct device *dev, void *ptr, size_t size,
-  enum dma_data_direction direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   WARN_ON(size == 0);
-   flush_write_buffers();
-   return virt_to_phys(ptr);
-}
-
 static inline void
 dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
 enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 369188a..969a7da 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -2,7 +2,6 @@
 #define _X8664_DMA_MAPPING_H 1
 
 extern dma_addr_t bad_dma_address;
-extern const struct dma_mapping_ops* dma_ops;
 extern int iommu_merge;
 
 static inline int dma_mapping_error(dma_addr_t dma_addr)
@@ -24,14 +23,6 @@ extern void *dma_alloc_coherent(struct device *dev, size_t 
size,
 extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
  dma_addr_t dma_handle);
 
-static inline dma_addr_t
-dma_map_single(struct device *hwdev, void *ptr, size_t size,
-  int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   return dma_ops-map_single(hwdev, ptr, size, direction);
-}
-
 static inline void
 dma_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
 int direction)
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 07/20] x86: move dma_sync_single_for_device to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   11 +++
 include/asm-x86/dma-mapping_32.h |7 ---
 include/asm-x86/dma-mapping_64.h |   11 ---
 4 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index dce03c8..3648824 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -36,6 +36,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.map_sg = pci32_dma_map_sg,
.unmap_sg = NULL,
.sync_single_for_cpu = NULL,
+   .sync_single_for_device = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 507069d..8ad582c 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -103,4 +103,15 @@ dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t 
dma_handle,
flush_write_buffers();
 }
 
+static inline void
+dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
+  size_t size, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_single_for_device)
+   dma_ops-sync_single_for_device(hwdev, dma_handle, size,
+   direction);
+   flush_write_buffers();
+}
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index a05b2fc..b91771a 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -33,13 +33,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
 }
 
 static inline void
-dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t 
size,
-   enum dma_data_direction direction)
-{
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
  unsigned long offset, size_t size,
  enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index b055964..b539f61 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -29,17 +29,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 #define dma_unmap_page dma_unmap_single
 
 static inline void
-dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
-  size_t size, int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_single_for_device)
-   dma_ops-sync_single_for_device(hwdev, dma_handle, size,
-   direction);
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
  unsigned long offset, size_t size, int direction)
 {
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 05/20] x86: move dma_unmap_sg to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|9 +
 include/asm-x86/dma-mapping_32.h |8 
 include/asm-x86/dma-mapping_64.h |8 
 4 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index 2474152..9205304 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -34,6 +34,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.map_single = pci32_map_single,
.unmap_single = NULL,
.map_sg = pci32_dma_map_sg,
+   .unmap_sg = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 0901154..6e7747a 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -82,4 +82,13 @@ dma_map_sg(struct device *hwdev, struct scatterlist *sg,
BUG_ON(!valid_dma_direction(direction));
return dma_ops-map_sg(hwdev, sg, nents, direction);
 }
+
+static inline void
+dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
+int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-unmap_sg)
+   dma_ops-unmap_sg(hwdev, sg, nents, direction);
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index cdcdeff..55445e3 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -32,14 +32,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
BUG_ON(!valid_dma_direction(direction));
 }
 
-
-static inline void
-dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
-enum dma_data_direction direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-}
-
 static inline void
 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index b27527a..ce37efb 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -96,14 +96,6 @@ dma_sync_sg_for_device(struct device *hwdev, struct 
scatterlist *sg,
flush_write_buffers();
 }
 
-static inline void
-dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
-int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   dma_ops-unmap_sg(hwdev, sg, nents, direction);
-}
-
 extern int dma_supported(struct device *hwdev, u64 mask);
 
 /* same for gart, swiotlb, and nommu */
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 09/20] x86: move dma_sync_single_range_for_device to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   14 ++
 include/asm-x86/dma-mapping_32.h |8 
 include/asm-x86/dma-mapping_64.h |   12 
 4 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index c501599..4512c30 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -38,6 +38,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.sync_single_for_cpu = NULL,
.sync_single_for_device = NULL,
.sync_single_range_for_cpu = NULL,
+   .sync_single_range_for_device = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index a466470..260538b 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -125,4 +125,18 @@ dma_sync_single_range_for_cpu(struct device *hwdev, 
dma_addr_t dma_handle,
 
flush_write_buffers();
 }
+
+static inline void
+dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
+unsigned long offset, size_t size,
+int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_single_range_for_device)
+   dma_ops-sync_single_range_for_device(hwdev, dma_handle,
+ offset, size, direction);
+
+   flush_write_buffers();
+}
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index e24c59d..60d5371 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -33,14 +33,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
 }
 
 static inline void
-dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
-unsigned long offset, size_t size,
-enum dma_data_direction direction)
-{
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
 {
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 6ecafad..dfa66cc 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -29,18 +29,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 #define dma_unmap_page dma_unmap_single
 
 static inline void
-dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
-unsigned long offset, size_t size, int 
direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_single_range_for_device)
-   dma_ops-sync_single_range_for_device(hwdev, dma_handle,
- offset, size, direction);
-
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
int nelems, int direction)
 {
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 11/20] x86: move dma_sync_sg_for_device to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   11 +++
 include/asm-x86/dma-mapping_32.h |7 ---
 include/asm-x86/dma-mapping_64.h |   12 
 4 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index d876600..033d94e 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -40,6 +40,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.sync_single_range_for_cpu = NULL,
.sync_single_range_for_device = NULL,
.sync_sg_for_cpu = NULL,
+   .sync_sg_for_device = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 1a301d7..53a404b 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -148,4 +148,15 @@ dma_sync_sg_for_cpu(struct device *hwdev, struct 
scatterlist *sg,
dma_ops-sync_sg_for_cpu(hwdev, sg, nelems, direction);
flush_write_buffers();
 }
+
+static inline void
+dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
+  int nelems, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_sg_for_device)
+   dma_ops-sync_sg_for_device(hwdev, sg, nelems, direction);
+
+   flush_write_buffers();
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index e7c82e3..eff42f4 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -32,13 +32,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
BUG_ON(!valid_dma_direction(direction));
 }
 
-static inline void
-dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
-   enum dma_data_direction direction)
-{
-   flush_write_buffers();
-}
-
 static inline int
 dma_mapping_error(dma_addr_t dma_addr)
 {
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 804b154..707dbbe 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -27,18 +27,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
dma_map_single((dev), page_address(page)+(offset), (size), (dir))
 
 #define dma_unmap_page dma_unmap_single
-static inline void
-dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
-  int nelems, int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_sg_for_device) {
-   dma_ops-sync_sg_for_device(hwdev, sg, nelems, direction);
-   }
-
-   flush_write_buffers();
-}
-
 extern int dma_supported(struct device *hwdev, u64 mask);
 
 /* same for gart, swiotlb, and nommu */
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 10/20] x86: move dma_sync_sg_for_cpu to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|9 +
 include/asm-x86/dma-mapping_32.h |6 --
 include/asm-x86/dma-mapping_64.h |   11 ---
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index 4512c30..d876600 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -39,6 +39,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.sync_single_for_device = NULL,
.sync_single_range_for_cpu = NULL,
.sync_single_range_for_device = NULL,
+   .sync_sg_for_cpu = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 260538b..1a301d7 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -139,4 +139,13 @@ dma_sync_single_range_for_device(struct device *hwdev, 
dma_addr_t dma_handle,
flush_write_buffers();
 }
 
+static inline void
+dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
+   int nelems, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_sg_for_cpu)
+   dma_ops-sync_sg_for_cpu(hwdev, sg, nelems, direction);
+   flush_write_buffers();
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 60d5371..e7c82e3 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -33,12 +33,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
 }
 
 static inline void
-dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg, int nelems,
-   enum dma_data_direction direction)
-{
-}
-
-static inline void
 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
enum dma_data_direction direction)
 {
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index dfa66cc..804b154 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -27,17 +27,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
dma_map_single((dev), page_address(page)+(offset), (size), (dir))
 
 #define dma_unmap_page dma_unmap_single
-
-static inline void
-dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
-   int nelems, int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_sg_for_cpu)
-   dma_ops-sync_sg_for_cpu(hwdev, sg, nelems, direction);
-   flush_write_buffers();
-}
-
 static inline void
 dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
   int nelems, int direction)
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 12/20] x86: move alloc and free coherent to common header

2008-03-25 Thread Glauber Costa
they are the same between architectures (except for the fact
that x86_64 has duplicate code)

move them to dma-mapping.h

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|   10 ++
 include/asm-x86/dma-mapping_32.h |9 -
 include/asm-x86/dma-mapping_64.h |   11 ---
 3 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 53a404b..3ea3802 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -52,6 +52,16 @@ struct dma_mapping_ops {
 
 extern const struct dma_mapping_ops *dma_ops;
 
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+
+void *dma_alloc_coherent(struct device *dev, size_t size,
+  dma_addr_t *dma_handle, gfp_t flag);
+
+void dma_free_coherent(struct device *dev, size_t size,
+void *vaddr, dma_addr_t dma_handle);
+
+
 #ifdef CONFIG_X86_32
 # include dma-mapping_32.h
 #else
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index eff42f4..d8f6420 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -8,15 +8,6 @@
 #include asm/io.h
 #include asm/bug.h
 
-#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
-#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-
-void *dma_alloc_coherent(struct device *dev, size_t size,
-  dma_addr_t *dma_handle, gfp_t flag);
-
-void dma_free_coherent(struct device *dev, size_t size,
-void *vaddr, dma_addr_t dma_handle);
-
 static inline dma_addr_t
 dma_map_page(struct device *dev, struct page *page, unsigned long offset,
 size_t size, enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 707dbbe..ce881d9 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -12,17 +12,6 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
return (dma_addr == bad_dma_address);
 }
 
-#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
-#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-
-#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
-#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
-
-extern void *dma_alloc_coherent(struct device *dev, size_t size,
-   dma_addr_t *dma_handle, gfp_t gfp);
-extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
- dma_addr_t dma_handle);
-
 #define dma_map_page(dev,page,offset,size,dir) \
dma_map_single((dev), page_address(page)+(offset), (size), (dir))
 
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 16/20] x86: align to clflush size

2008-03-25 Thread Glauber Costa
Do it instead of using the conservative approach we're currently
doing. This is the way x86_64 does, and this patch makes this piece
of code the same between them, ready to be integrated

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping_32.h |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index fd7246d..d0512c9 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -21,7 +21,7 @@ dma_get_cache_alignment(void)
 {
/* no easy way to get cache size on all x86, so return the
 * maximum possible, to be safe */
-   return (1  INTERNODE_CACHE_SHIFT);
+   return boot_cpu_data.x86_clflush_size;
 }
 
 #define dma_is_consistent(d, h)(1)
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 08/20] x86: move dma_sync_single_range_for_cpu to common header

2008-03-25 Thread Glauber Costa
i386 gets an empty function

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|1 +
 include/asm-x86/dma-mapping.h|   11 +++
 include/asm-x86/dma-mapping_32.h |7 ---
 include/asm-x86/dma-mapping_64.h |   12 
 4 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index 3648824..c501599 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -37,6 +37,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.unmap_sg = NULL,
.sync_single_for_cpu = NULL,
.sync_single_for_device = NULL,
+   .sync_single_range_for_cpu = NULL,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 8ad582c..a466470 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -114,4 +114,15 @@ dma_sync_single_for_device(struct device *hwdev, 
dma_addr_t dma_handle,
flush_write_buffers();
 }
 
+static inline void
+dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
+ unsigned long offset, size_t size, int direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   if (dma_ops-sync_single_range_for_cpu)
+   dma_ops-sync_single_range_for_cpu(hwdev, dma_handle, offset,
+  size, direction);
+
+   flush_write_buffers();
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index b91771a..e24c59d 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -33,13 +33,6 @@ dma_unmap_page(struct device *dev, dma_addr_t dma_address, 
size_t size,
 }
 
 static inline void
-dma_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
- unsigned long offset, size_t size,
- enum dma_data_direction direction)
-{
-}
-
-static inline void
 dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
 unsigned long offset, size_t size,
 enum dma_data_direction direction)
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index b539f61..6ecafad 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -29,18 +29,6 @@ extern void dma_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 #define dma_unmap_page dma_unmap_single
 
 static inline void
-dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
- unsigned long offset, size_t size, int direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   if (dma_ops-sync_single_range_for_cpu) {
-   dma_ops-sync_single_range_for_cpu(hwdev, dma_handle, offset, 
size, direction);
-   }
-
-   flush_write_buffers();
-}
-
-static inline void
 dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
 unsigned long offset, size_t size, int 
direction)
 {
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 20/20] x86: delete the arch-specific dma-mapping headers.

2008-03-25 Thread Glauber Costa
all the code that is left is ready to be merged as-is
in dma-mapping.h

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|   19 +--
 include/asm-x86/dma-mapping_32.h |   23 ---
 include/asm-x86/dma-mapping_64.h |   17 -
 3 files changed, 13 insertions(+), 46 deletions(-)
 delete mode 100644 include/asm-x86/dma-mapping_32.h
 delete mode 100644 include/asm-x86/dma-mapping_64.h

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 9548b19..3809b35 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -11,6 +11,9 @@
 #include asm/swiotlb.h
 
 extern dma_addr_t bad_dma_address;
+extern int iommu_merge;
+extern struct device fallback_dev;
+extern int panic_on_overflow;
 
 struct dma_mapping_ops {
int (*mapping_error)(dma_addr_t dma_addr);
@@ -75,12 +78,6 @@ void dma_free_coherent(struct device *dev, size_t size,
 extern int dma_supported(struct device *hwdev, u64 mask);
 extern int dma_set_mask(struct device *dev, u64 mask);
 
-#ifdef CONFIG_X86_32
-# include dma-mapping_32.h
-#else
-# include dma-mapping_64.h
-#endif
-
 static inline dma_addr_t
 dma_map_single(struct device *hwdev, void *ptr, size_t size,
   int direction)
@@ -203,6 +200,15 @@ dma_cache_sync(struct device *dev, void *vaddr, size_t 
size,
flush_write_buffers();
 }
 
+static inline int dma_get_cache_alignment(void)
+{
+   /* no easy way to get cache size on all x86, so return the
+* maximum possible, to be safe */
+   return boot_cpu_data.x86_clflush_size;
+}
+
+#define dma_is_consistent(d, h)(1)
+
 #ifdef CONFIG_X86_32
 #  define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 extern int
@@ -215,5 +221,6 @@ dma_release_declared_memory(struct device *dev);
 extern void *
 dma_mark_declared_memory_occupied(struct device *dev,
  dma_addr_t device_addr, size_t size);
+extern int forbid_dac;
 #endif /* CONFIG_X86_32 */
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
deleted file mode 100644
index 4ec4f45..000
--- a/include/asm-x86/dma-mapping_32.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef _ASM_I386_DMA_MAPPING_H
-#define _ASM_I386_DMA_MAPPING_H
-
-#include linux/mm.h
-#include linux/scatterlist.h
-
-#include asm/cache.h
-#include asm/io.h
-#include asm/bug.h
-
-extern int forbid_dac;
-
-static inline int
-dma_get_cache_alignment(void)
-{
-   /* no easy way to get cache size on all x86, so return the
-* maximum possible, to be safe */
-   return boot_cpu_data.x86_clflush_size;
-}
-
-#define dma_is_consistent(d, h)(1)
-
-#endif
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
deleted file mode 100644
index 8353025..000
--- a/include/asm-x86/dma-mapping_64.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _X8664_DMA_MAPPING_H
-#define _X8664_DMA_MAPPING_H 1
-
-extern int iommu_merge;
-
-/* same for gart, swiotlb, and nommu */
-static inline int dma_get_cache_alignment(void)
-{
-   return boot_cpu_data.x86_clflush_size;
-}
-
-#define dma_is_consistent(d, h) 1
-
-extern struct device fallback_dev;
-extern int panic_on_overflow;
-
-#endif /* _X8664_DMA_MAPPING_H */
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 14/20] x86: move dma_cache_sync to common header

2008-03-25 Thread Glauber Costa
they are the same in both architectures.

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|6 ++
 include/asm-x86/dma-mapping_32.h |7 ---
 include/asm-x86/dma-mapping_64.h |7 ---
 3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index b5a413a..70a5ede 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -183,4 +183,10 @@ static inline void dma_unmap_page(struct device *dev, 
dma_addr_t addr,
dma_unmap_single(dev, addr, size, direction);
 }
 
+static inline void
+dma_cache_sync(struct device *dev, void *vaddr, size_t size,
+   enum dma_data_direction dir)
+{
+   flush_write_buffers();
+}
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index c61ae7f..e60c30a 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -55,13 +55,6 @@ dma_get_cache_alignment(void)
 
 #define dma_is_consistent(d, h)(1)
 
-static inline void
-dma_cache_sync(struct device *dev, void *vaddr, size_t size,
-  enum dma_data_direction direction)
-{
-   flush_write_buffers();
-}
-
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 extern int
 dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 2b4a430..b1bc6ca 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -24,13 +24,6 @@ static inline int dma_get_cache_alignment(void)
 
 extern int dma_set_mask(struct device *dev, u64 mask);
 
-static inline void
-dma_cache_sync(struct device *dev, void *vaddr, size_t size,
-   enum dma_data_direction dir)
-{
-   flush_write_buffers();
-}
-
 extern struct device fallback_dev;
 extern int panic_on_overflow;
 
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 13/20] x86: move dma_map_page and dma_unmap_page to common header

2008-03-25 Thread Glauber Costa
They are similar enough to do this move.
the macro version is ugly, and we use inline functions instead

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|   14 ++
 include/asm-x86/dma-mapping_32.h |   15 ---
 include/asm-x86/dma-mapping_64.h |4 
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 3ea3802..b5a413a 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -169,4 +169,18 @@ dma_sync_sg_for_device(struct device *hwdev, struct 
scatterlist *sg,
 
flush_write_buffers();
 }
+
+static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
+ size_t offset, size_t size,
+ int direction)
+{
+   return dma_map_single(dev, page_address(page)+offset, size, direction);
+}
+
+static inline void dma_unmap_page(struct device *dev, dma_addr_t addr,
+ size_t size, int direction)
+{
+   dma_unmap_single(dev, addr, size, direction);
+}
+
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index d8f6420..c61ae7f 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -8,21 +8,6 @@
 #include asm/io.h
 #include asm/bug.h
 
-static inline dma_addr_t
-dma_map_page(struct device *dev, struct page *page, unsigned long offset,
-size_t size, enum dma_data_direction direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-   return page_to_phys(page) + offset;
-}
-
-static inline void
-dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
-  enum dma_data_direction direction)
-{
-   BUG_ON(!valid_dma_direction(direction));
-}
-
 static inline int
 dma_mapping_error(dma_addr_t dma_addr)
 {
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index ce881d9..2b4a430 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -12,10 +12,6 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
return (dma_addr == bad_dma_address);
 }
 
-#define dma_map_page(dev,page,offset,size,dir) \
-   dma_map_single((dev), page_address(page)+(offset), (size), (dir))
-
-#define dma_unmap_page dma_unmap_single
 extern int dma_supported(struct device *hwdev, u64 mask);
 
 /* same for gart, swiotlb, and nommu */
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 15/20] x86: move dma_supported and dma_set_mask to pci-dma_32.c

2008-03-25 Thread Glauber Costa
This is the way x86_64 does, so this make them equal. They have
to be extern now in the header, and the extern definition is moved to
the common dma-mapping.h header

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-dma_32.c |   33 +
 include/asm-x86/dma-mapping.h|3 +++
 include/asm-x86/dma-mapping_32.h |   29 -
 include/asm-x86/dma-mapping_64.h |4 
 4 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 5133032..453b4bd 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -156,6 +156,39 @@ EXPORT_SYMBOL(dma_mark_declared_memory_occupied);
 int forbid_dac;
 EXPORT_SYMBOL(forbid_dac);
 
+int
+dma_supported(struct device *dev, u64 mask)
+{
+   /*
+* we fall back to GFP_DMA when the mask isn't all 1s,
+* so we can't guarantee allocations that must be
+* within a tighter range than GFP_DMA..
+*/
+   if (mask  0x00ff)
+   return 0;
+
+   /* Work around chipset bugs */
+   if (forbid_dac  0  mask  0xULL)
+   return 0;
+
+   if (dma_ops-dma_supported)
+   return dma_ops-dma_supported(dev, mask);
+
+   return 1;
+}
+
+int
+dma_set_mask(struct device *dev, u64 mask)
+{
+   if (!dev-dma_mask || !dma_supported(dev, mask))
+   return -EIO;
+
+   *dev-dma_mask = mask;
+
+   return 0;
+}
+
+
 static __devinit void via_no_dac(struct pci_dev *dev)
 {
if ((dev-class  8) == PCI_CLASS_BRIDGE_PCI  forbid_dac == 0) {
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 70a5ede..06eb448 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -62,6 +62,9 @@ void dma_free_coherent(struct device *dev, size_t size,
 void *vaddr, dma_addr_t dma_handle);
 
 
+extern int dma_supported(struct device *hwdev, u64 mask);
+extern int dma_set_mask(struct device *dev, u64 mask);
+
 #ifdef CONFIG_X86_32
 # include dma-mapping_32.h
 #else
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index e60c30a..fd7246d 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -17,35 +17,6 @@ dma_mapping_error(dma_addr_t dma_addr)
 extern int forbid_dac;
 
 static inline int
-dma_supported(struct device *dev, u64 mask)
-{
-/*
- * we fall back to GFP_DMA when the mask isn't all 1s,
- * so we can't guarantee allocations that must be
- * within a tighter range than GFP_DMA..
- */
-if(mask  0x00ff)
-return 0;
-
-   /* Work around chipset bugs */
-   if (forbid_dac  0  mask  0xULL)
-   return 0;
-
-   return 1;
-}
-
-static inline int
-dma_set_mask(struct device *dev, u64 mask)
-{
-   if(!dev-dma_mask || !dma_supported(dev, mask))
-   return -EIO;
-
-   *dev-dma_mask = mask;
-
-   return 0;
-}
-
-static inline int
 dma_get_cache_alignment(void)
 {
/* no easy way to get cache size on all x86, so return the
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index b1bc6ca..9674dac 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -12,8 +12,6 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
return (dma_addr == bad_dma_address);
 }
 
-extern int dma_supported(struct device *hwdev, u64 mask);
-
 /* same for gart, swiotlb, and nommu */
 static inline int dma_get_cache_alignment(void)
 {
@@ -22,8 +20,6 @@ static inline int dma_get_cache_alignment(void)
 
 #define dma_is_consistent(d, h) 1
 
-extern int dma_set_mask(struct device *dev, u64 mask);
-
 extern struct device fallback_dev;
 extern int panic_on_overflow;
 
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 18/20] x86: unify dma_mapping_error

2008-03-25 Thread Glauber Costa
We provide a map_error function in pci-base_32.c to make
sure i386 keeps with the same behaviour it used to.

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-base_32.c|7 +++
 include/asm-x86/dma-mapping.h|8 
 include/asm-x86/dma-mapping_32.h |6 --
 include/asm-x86/dma-mapping_64.h |8 
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c
index 033d94e..89d3587 100644
--- a/arch/x86/kernel/pci-base_32.c
+++ b/arch/x86/kernel/pci-base_32.c
@@ -30,6 +30,12 @@ static int pci32_dma_map_sg(struct device *dev, struct 
scatterlist *sglist,
return nents;
 }
 
+/* Make sure we keep the same behaviour */
+static int pci32_map_error(dma_addr_t dma_addr)
+{
+   return 0;
+}
+
 static const struct dma_mapping_ops pci32_dma_ops = {
.map_single = pci32_map_single,
.unmap_single = NULL,
@@ -41,6 +47,7 @@ static const struct dma_mapping_ops pci32_dma_ops = {
.sync_single_range_for_device = NULL,
.sync_sg_for_cpu = NULL,
.sync_sg_for_device = NULL,
+   .mapping_error = pci32_map_error,
 };
 
 const struct dma_mapping_ops *dma_ops = pci32_dma_ops;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 908fcaa..352433b 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -54,6 +54,14 @@ struct dma_mapping_ops {
 
 extern const struct dma_mapping_ops *dma_ops;
 
+static inline int dma_mapping_error(dma_addr_t dma_addr)
+{
+   if (dma_ops-mapping_error)
+   return dma_ops-mapping_error(dma_addr);
+
+   return (dma_addr == bad_dma_address);
+}
+
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
 
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index d0512c9..03a75f8 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -8,12 +8,6 @@
 #include asm/io.h
 #include asm/bug.h
 
-static inline int
-dma_mapping_error(dma_addr_t dma_addr)
-{
-   return 0;
-}
-
 extern int forbid_dac;
 
 static inline int
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 352bf41..8353025 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -3,14 +3,6 @@
 
 extern int iommu_merge;
 
-static inline int dma_mapping_error(dma_addr_t dma_addr)
-{
-   if (dma_ops-mapping_error)
-   return dma_ops-mapping_error(dma_addr);
-
-   return (dma_addr == bad_dma_address);
-}
-
 /* same for gart, swiotlb, and nommu */
 static inline int dma_get_cache_alignment(void)
 {
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 17/20] x86: provide a bad_dma_address symbol for i386

2008-03-25 Thread Glauber Costa
It's initially 0, since we don't expect any DMA there.

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 arch/x86/kernel/pci-dma_32.c |4 
 include/asm-x86/dma-mapping.h|2 ++
 include/asm-x86/dma-mapping_64.h |1 -
 3 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/pci-dma_32.c b/arch/x86/kernel/pci-dma_32.c
index 453b4bd..55ab3c8 100644
--- a/arch/x86/kernel/pci-dma_32.c
+++ b/arch/x86/kernel/pci-dma_32.c
@@ -14,6 +14,10 @@
 #include linux/module.h
 #include asm/io.h
 
+/* For i386, we make it point to the NULL address */
+dma_addr_t bad_dma_address __read_mostly = 0x0;
+EXPORT_SYMBOL(bad_dma_address);
+
 struct dma_coherent_mem {
void*virt_base;
u32 device_base;
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 06eb448..908fcaa 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -10,6 +10,8 @@
 #include asm/io.h
 #include asm/swiotlb.h
 
+extern dma_addr_t bad_dma_address;
+
 struct dma_mapping_ops {
int (*mapping_error)(dma_addr_t dma_addr);
void*   (*alloc_coherent)(struct device *dev, size_t size,
diff --git a/include/asm-x86/dma-mapping_64.h b/include/asm-x86/dma-mapping_64.h
index 9674dac..352bf41 100644
--- a/include/asm-x86/dma-mapping_64.h
+++ b/include/asm-x86/dma-mapping_64.h
@@ -1,7 +1,6 @@
 #ifndef _X8664_DMA_MAPPING_H
 #define _X8664_DMA_MAPPING_H 1
 
-extern dma_addr_t bad_dma_address;
 extern int iommu_merge;
 
 static inline int dma_mapping_error(dma_addr_t dma_addr)
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 19/20] x86: move ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY to dma-mapping.h

2008-03-25 Thread Glauber Costa
define it conditionally to i386

Signed-off-by: Glauber Costa [EMAIL PROTECTED]
---
 include/asm-x86/dma-mapping.h|   14 ++
 include/asm-x86/dma-mapping_32.h |   12 
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h
index 352433b..9548b19 100644
--- a/include/asm-x86/dma-mapping.h
+++ b/include/asm-x86/dma-mapping.h
@@ -202,4 +202,18 @@ dma_cache_sync(struct device *dev, void *vaddr, size_t 
size,
 {
flush_write_buffers();
 }
+
+#ifdef CONFIG_X86_32
+#  define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+extern int
+dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+   dma_addr_t device_addr, size_t size, int flags);
+
+extern void
+dma_release_declared_memory(struct device *dev);
+
+extern void *
+dma_mark_declared_memory_occupied(struct device *dev,
+ dma_addr_t device_addr, size_t size);
+#endif /* CONFIG_X86_32 */
 #endif
diff --git a/include/asm-x86/dma-mapping_32.h b/include/asm-x86/dma-mapping_32.h
index 03a75f8..4ec4f45 100644
--- a/include/asm-x86/dma-mapping_32.h
+++ b/include/asm-x86/dma-mapping_32.h
@@ -20,16 +20,4 @@ dma_get_cache_alignment(void)
 
 #define dma_is_consistent(d, h)(1)
 
-#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
-extern int
-dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
-   dma_addr_t device_addr, size_t size, int flags);
-
-extern void
-dma_release_declared_memory(struct device *dev);
-
-extern void *
-dma_mark_declared_memory_occupied(struct device *dev,
- dma_addr_t device_addr, size_t size);
-
 #endif
-- 
1.5.0.6


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH] Use QEMU functions to access guest memory for virtio

2008-03-25 Thread Anthony Liguori
virtio is currently pretty sloppy about accessing guest memory directly.  This
is problematic both because phys_ram_base + PA is not only valid but also
because it requires the host and guest both be of the same endianness.

This patch converts virtio to use the QEMU st/ld functions to manipulate the
ring queues.  I've tested both virtio-blk and virtio-net.  I've also confirm
that performance doesn't regress with virtio-net.

We still use phys_ram_base to create the struct iovec to handle IO operations.
I'm still trying to think of a way to eliminate that that doesn't involve an
unnecessary copy or a full blown DMA API.

This patch should make it easier to use virtio with QEMU (in the absence of
KVM).

Signed-off-by: Anthony Liguori [EMAIL PROTECTED]

diff --git a/qemu/hw/virtio-net.c b/qemu/hw/virtio-net.c
index 3d54c4e..e1b0aad 100644
--- a/qemu/hw/virtio-net.c
+++ b/qemu/hw/virtio-net.c
@@ -114,7 +114,7 @@ static void virtio_net_receive(void *opaque, const uint8_t 
*buf, int size)
 int offset, i;
 
 /* FIXME: the drivers really need to set their status better */
-if (n-rx_vq-vring.avail == NULL) {
+if (!virtio_ring_inited(n-rx_vq)) {
n-can_receive = 0;
return;
 }
@@ -174,7 +174,7 @@ void virtio_net_poll(void)
 continue;
 
 /* FIXME: the drivers really need to set their status better */
-if (vnet-rx_vq-vring.avail == NULL) {
+if (!virtio_ring_inited(vnet-rx_vq)) {
 vnet-can_receive = 0;
 continue;
 }
@@ -257,8 +257,8 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, 
VirtQueue *vq)
 VirtIONet *n = to_virtio_net(vdev);
 
 if (n-tx_timer_active 
-   (vq-vring.avail-idx - vq-last_avail_idx) == 64) {
-   vq-vring.used-flags = ~VRING_USED_F_NO_NOTIFY;
+   virtio_ring_avail_size(vq) == 64) {
+   virtio_ring_set_used_notify(vq, 0);
qemu_del_timer(n-tx_timer);
n-tx_timer_active = 0;
virtio_net_flush_tx(n, vq);
@@ -266,7 +266,7 @@ static void virtio_net_handle_tx(VirtIODevice *vdev, 
VirtQueue *vq)
qemu_mod_timer(n-tx_timer,
   qemu_get_clock(vm_clock) + TX_TIMER_INTERVAL);
n-tx_timer_active = 1;
-   vq-vring.used-flags |= VRING_USED_F_NO_NOTIFY;
+   virtio_ring_set_used_notify(vq, 1);
 }
 }
 
@@ -280,7 +280,7 @@ static void virtio_net_tx_timer(void *opaque)
 if (!(n-vdev.status  VIRTIO_CONFIG_S_DRIVER_OK))
 return;
 
-n-tx_vq-vring.used-flags = ~VRING_USED_F_NO_NOTIFY;
+virtio_ring_set_used_notify(n-tx_vq, 0);
 virtio_net_flush_tx(n, n-tx_vq);
 }
 
diff --git a/qemu/hw/virtio.c b/qemu/hw/virtio.c
index 9100bb1..5a905b1 100644
--- a/qemu/hw/virtio.c
+++ b/qemu/hw/virtio.c
@@ -17,6 +17,37 @@
 #include virtio.h
 #include sysemu.h
 
+/* from Linux's linux/virtio_ring.h */
+
+/* This marks a buffer as continuing via the next field. */
+#define VRING_DESC_F_NEXT  1
+/* This marks a buffer as write-only (otherwise read-only). */
+#define VRING_DESC_F_WRITE 2
+
+/* This means don't notify other side when buffer added. */
+#define VRING_USED_F_NO_NOTIFY 1
+/* This means don't interrupt guest when buffer consumed. */
+#define VRING_AVAIL_F_NO_INTERRUPT 1
+
+#define VIRTIO_PCI_QUEUE_MAX   16
+
+typedef struct VRing
+{
+unsigned int num;
+target_phys_addr_t desc;
+target_phys_addr_t avail;
+target_phys_addr_t used;
+} VRing;
+
+struct VirtQueue
+{
+VRing vring;
+uint32_t pfn;
+uint16_t last_avail_idx;
+void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq);
+int index;
+};
+
 /* from Linux's linux/virtio_pci.h */
 
 /* A 32-bit r/o bitmask of the features supported by the host */
@@ -58,11 +89,74 @@
 
 /* virt queue functions */
 
-static void virtqueue_init(VirtQueue *vq, void *p)
+static void virtqueue_init(VirtQueue *vq, target_phys_addr_t p)
 {
 vq-vring.desc = p;
-vq-vring.avail = p + vq-vring.num * sizeof(VRingDesc);
-vq-vring.used = (void *)TARGET_PAGE_ALIGN((unsigned 
long)vq-vring.avail-ring[vq-vring.num]);
+vq-vring.avail = p + vq-vring.num * 16;
+vq-vring.used = vq-vring.avail + 2 * (2 + vq-vring.num);
+vq-vring.used = TARGET_PAGE_ALIGN(vq-vring.used);
+}
+
+static uint64_t vring_desc_addr(VirtQueue *vq, unsigned int i)
+{
+return ldq_phys(vq-vring.desc + i * 16 + 0);
+}
+
+static uint32_t vring_desc_len(VirtQueue *vq, unsigned int i)
+{
+return ldl_phys(vq-vring.desc + i * 16 + 8);
+}
+
+static uint16_t vring_desc_flags(VirtQueue *vq, unsigned int i)
+{
+return lduw_phys(vq-vring.desc + i * 16 + 12);
+}
+
+static uint16_t vring_desc_next(VirtQueue *vq, unsigned int i)
+{
+return lduw_phys(vq-vring.desc + i * 16 + 14);
+}
+
+static uint16_t vring_avail_flags(VirtQueue *vq)
+{
+return lduw_phys(vq-vring.avail + 0);
+}
+
+static uint16_t vring_avail_idx(VirtQueue *vq)
+{
+return lduw_phys(vq-vring.avail + 2);
+}
+
+static uint16_t vring_avail_ring(VirtQueue *vq, 

Re: [kvm-devel] [PATCH][QEMU] Use a separate device for in-kernel PIT (v2)

2008-03-25 Thread Anthony Liguori
Avi Kivity wrote:

 Please separate the code movement and changes into separate patches.

I'm not sure there's a great way to do this that preserves bisectability 
and results in meaningful history.  I could leave the #ifdef's in 
i8254-kvm.c and then have a second patch that removes them.  That 
doesn't seem to be terribly valuable though from a history perspective 
as it still requires a bit of code change to keep things working.  Were 
you thinking of something else?

Regards,

Anthony Liguori



-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Virtio and LVM

2008-03-25 Thread Dennis Jacobfeuerborn
I'm trying to get a Fedora 9 Beta guest to use the virtio block device. 
I've included virtio_blk and virtio_pci in the initrd on the guest and when 
booting virtio_blk detects vda1 and vda2 correctly but when the system 
tries to find the volume groups it doesn't find any. Is there something 
special that needs to be done to get the kernel to detect the volume group 
on vda2?

Regards,
   Dennis

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [RFC] QEMU/KVM: dedicated IO thread

2008-03-25 Thread Marcelo Tosatti
On Tue, Mar 25, 2008 at 04:58:06PM +0200, Avi Kivity wrote:
 Marcelo Tosatti wrote:
 Avi was concerned that this would cause problems with migration. I
 haven't specifically tested it yet, but it seems there will be no
 problems introduced by this change: the IO thread will stop all vcpu's
 in the same way the vcpu0 thread did before.
   
 
 I believe this is broken for smp_cpus  1, and will with this change 
 will be broken even for non smp.  The pause/resume logic is rotten.

Ok, I'll look into it in more detail.

 QEMU/KVM: separate thread for IO handling
 
 Move IO processing from vcpu0 to a dedicated thread.
 
 This removes load on vcpu0 by allowing better cache locality and also
 improves latency.
 
 We can now block signal handling for IO events, so sigtimedwait won't
 race with handlers:
 
 - Currently the SIGALRM handler fails to set CPU_INTERRUPT_EXIT because
 the next_cpu variable is not initialized in the KVM path, meaning that
 processing of timer expiration might be delayed until the next vcpu0 exit.
   
 
 I think we call main_loop_wait() is called unconditionally after every 
 signal.

We exit the kvm_run() loop if CPU_INTERRUPT_EXIT is detected by pre_kvm_run().

But the SIGALRM handler won't set it:

static void host_alarm_handler(int host_signum)
{
...
CPUState *env = next_cpu;

alarm_timer-flags |= ALARM_FLAG_EXPIRED;

if (env) {
/* stop the currently executing cpu because a timer occured */
cpu_interrupt(env, CPU_INTERRUPT_EXIT);
#ifdef USE_KQEMU
if (env-kqemu_enabled) {
kqemu_cpu_interrupt(env);
}
#endif

Because the KVM path does not initialize next_cpu:

static int main_loop(void)
{
int ret, timeout;
#ifdef CONFIG_PROFILER
int64_t ti;
#endif
CPUState *env;


if (kvm_enabled()) {
kvm_main_loop();
cpu_disable_ticks();
return 0;
}

cur_cpu = first_cpu;
next_cpu = cur_cpu-next_cpu ?: first_cpu;


 
 - Processing of IO events will not be unnecessarily interrupted.
 
 
 Index: kvm-userspace.io/libkvm/libkvm.c
 ===
 --- kvm-userspace.io.orig/libkvm/libkvm.c
 +++ kvm-userspace.io/libkvm/libkvm.c
 @@ -388,9 +388,6 @@ int kvm_create(kvm_context_t kvm, unsign
  if (r  0)
  return r;
  kvm_create_irqchip(kvm);
 -r = kvm_create_vcpu(kvm, 0);
 -if (r  0)
 -return r;
  
  return 0;
  }
   
 
 Please put this and the corresponding qemu change in a separate patch.
 
 [...lots more...]
 
 Looks good.

Will do.

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH v2] x86: don't allow KVM_CLOCK on Voyager or Visual WS

2008-03-25 Thread Randy Dunlap
From: Randy Dunlap [EMAIL PROTECTED]

Prevent failed randconfig builds with KVM_CLOCK being enabled
on Voyager or VISWS.

build-rand9.out:  Using /local/linsrc/next-20080325 as source for kernel
build-rand9.out: from 
/local/linsrc/next-20080325/include/linux/irqflags.h:46,
build-rand9.out: from include2/asm/system.h:11,
build-rand9.out: from include2/asm/processor.h:21,
build-rand9.out: from include2/asm/atomic_32.h:5,
build-rand9.out: from include2/asm/atomic.h:2,
build-rand9.out: from 
/local/linsrc/next-20080325/include/linux/crypto.h:20,
build-rand9.out: from 
/local/linsrc/next-20080325/arch/x86/kernel/asm-offsets_32.c:7,
build-rand9.out: from 
/local/linsrc/next-20080325/arch/x86/kernel/asm-offsets.c:2:
build-rand9.out:include2/asm/paravirt.h:856: error: 'struct pv_apic_ops' has no 
member named 'startup_ipi_hook'
build-rand9.out:include2/asm/paravirt.h:856: error: 'struct pv_apic_ops' has no 
member named 'startup_ipi_hook'
build-rand9.out:include2/asm/paravirt.h:856: error: memory input 4 is not 
directly addressable
build-rand9.out:make[2]: *** [arch/x86/kernel/asm-offsets.s] Error 1

Signed-off-by: Randy Dunlap [EMAIL PROTECTED]
---
 arch/x86/Kconfig |1 +
 1 file changed, 1 insertion(+)

--- next-20080325.orig/arch/x86/Kconfig
+++ next-20080325/arch/x86/Kconfig
@@ -370,6 +370,7 @@ config VMI
 config KVM_CLOCK
bool KVM paravirtualized clock
select PARAVIRT
+   depends on !(X86_VISWS || X86_VOYAGER)
help
  Turning on this option will allow you to run a paravirtualized clock
  when running over the KVM hypervisor. Instead of relying on a PIT

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Управление финансами

2008-03-25 Thread Финансовый директор
  :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:
  : :
  : Эффeктивнoe yпpавлeниe финансами:
  : :
  :~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:~:

   Пpиглашаются:
  Pyкoвogитeли пpegпpиятий, pyкoвogитeли и вegyщиe спeциалисты
  финансoвых geпаpтамeнтoв, oтgeлoв и слyжб
  
  7 - 9 апpeля, Cанкт - Пeтepбypг
  
   Оснoвныe пyнкты пpoгpаммы кypса:
  
  Эффeктивная финансoвая машина в кopпopативнoм
  yпpавлeнии сoвpeмeнных кoмпаний
  ∙ Coгласoваниe цeлeй акциoнepoв и мeнegжмeнта
  ∙ Финансoвый мeнegжмeнт с тoчки зpeния yпpавлeния кoмпаниeй
  
  Инфopмация gля yпpавлeния финансами и финансoвая
  инфopмация gля yпpавлeния
  ∙ Пpинципы бyхгалтepскoгo yчeта
  ∙ Виgы и систeмы yчeта: финансoвый, налoгoвый и yпpавлeнчeский
  
  Финансoвая oтчeтнoсть gля пpинятия yпpавлeнчeских peшeний
  ∙ Kакая oтчeтнoсть пoлeзна gля пpинятия yпpавлeнчeских peшeний?
  ∙ Отчeт o пpибылях и yбытках
  ∙ Паpаgoксы бyхгалтepскoгo yчeта
  
  Koнтpoллинг затpат и финансoвых peзyльтатoв gля pyкoвogитeля
  ∙ Kлассификация затpат gля цeлeй yпpавлeния
  ∙ Pазличныe пogхogы к oпpegeлeнию сeбeстoимoсти
  
  Пpактика планиpoвания и бюgжeтиpoвания
  ∙ Пpактичeскиe аспeкты пoстpoeния бюgжeтнoгo yпpавлeния в кoмпаниях
  ∙ Пpoблeмныe вoпpoсы планиpoвания и бюgжeтиpoвания
  
  Cтpатeгичeскиe финансы gля pyкoвogитeля
  ∙ Упpавлeниe, opиeнтиpoваннoe на стoимoсть
  ∙ Cбалансиpoванная систeма пoказатeлeй 
  
  Дoпoлнитeльная инфopмация мoжeт быть выслана Вам пo запpoсy
  т. (...812...) 983...03...15




-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Support for Sangoma A200 card using pci_add?

2008-03-25 Thread Randy Terbush
I've been sifting through docs and code to try to figure out if I can
actually expose this Sangoma card to a virtual container running Asterisk.

I've found reference to pci_add, but have yet to figure out what it takes to
build my kvm with pci_add function.

Is it possible to do what I am attempting with pci_add? Or other method?

Appreciate any help.
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel