<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://blog.gmane.org/gmane.comp.emulators.kvm.devel">
    <title>gmane.comp.emulators.kvm.devel</title>
    <link>http://blog.gmane.org/gmane.comp.emulators.kvm.devel</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91589"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91583"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91582"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91576"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91567"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91566"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91565"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91535"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91503"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91457"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91434"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91432"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91395"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91388"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91383"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91379"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91378"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91377"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91365"/>
        <rdf:li rdf:resource="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91332"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91589">
    <title>FROM MRS SUSAN SHABANGU(OPEN THE ATTACH FILES)</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91589</link>
    <description>&lt;pre&gt;&lt;/pre&gt;</description>
    <dc:creator>FROM MRS SUSAN SHABANGU</dc:creator>
    <dc:date>2012-05-26T10:50:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91583">
    <title>UDP problem with virtio...</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91583</link>
    <description>&lt;pre&gt;Hi,


I am running a guest that exposes a NFS share to be used by a TViX box. The TViX box is not that advanced and uses NFS over UDP instead of TCP.
What I am seeing is that when I use the virtio network driver, the TViX box cannot mount the filesystem. However, when I use rtl8139 instead, it can.

The problem is easily reproduced:
1. Create a guest that uses a virtio network interface (bridging setup)
2. Expose an NFS share on the guest
3. mount the NFS share using 'mount -o udp host:/share /localdir'
4. verify that the NFS share cannot be mounted.
5. Modify the guest to use rtl8139 device emulation and stop the guest and start it
6. mount the NFS share using 'mount -o udp host:/share /localdir'
7. Verify tha the NFS share can be mounted

Now the bug reporting guidelines say that I should always use the latest KVM version but compiling KVM from source and using that is not really an option. The server is important enough not to mess around with. Therefore, my question is whether this problem has been seen before or not.

My configuration is as follows:

*Host*

centos 6.2
uname -a gives "Linux falcon.fritz.box 2.6.32-220.17.1.el6.x86_64 #1 SMP Wed May 16 00:01:37 BST 2012 x86_64 x86_64 x86_64 GNU/Linux"

KVM software: qemu-kvm-0.12.1.2-2.209.el6_2.5.x86_64

*Guest*

OpenSuSE 11.3
uname -a gives "Linux shikra 2.6.34.7-0.7-default #1 SMP 2010-12-13 11:13:53 +0100 x86_64 x86_64 x86_64 GNU/Linux"

I also see in the instructions I should try running qemu with some alternative switches, but I am not running qemu directly. I am using virt-manager and a domain.xml to configure how qemu runs. How should I modify the domain.xml to help in troubleshooting this issue?

Cheers
   Erik

PS. the domain.xml is attached.





&lt;/pre&gt;</description>
    <dc:creator>Erik Brakkee</dc:creator>
    <dc:date>2012-05-25T20:55:37</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91582">
    <title>[PATCH v2] KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91582</link>
    <description>&lt;pre&gt;Introduces a couple of print functions, which are essentially wrappers
around standard printk functions, with a KVM: prefix.

Functions introduced or modified are:
 - kvm_err(fmt, ...)
 - kvm_info(fmt, ...)
 - kvm_debug(fmt, ...)
 - kvm_pr_unimpl(fmt, ...)
 - pr_unimpl(vcpu, fmt, ...) -&amp;gt; vcpu_unimpl(vcpu, fmt, ...)

Applies to kvm-next

Changelog[2]:
 - Added PID to print functions
 - Renamed vcpu_pr_unimpl to vcpu_unimpl

 Signed-off-by: Christoffer Dall &amp;lt;c.dall&amp;lt; at &amp;gt;virtualopensystems.com&amp;gt;
---
 arch/x86/kvm/svm.c       |    6 +++--
 arch/x86/kvm/vmx.c       |    2 +-
 arch/x86/kvm/x86.c       |   54 +++++++++++++++++++++++-----------------------
 include/linux/kvm_host.h |   17 +++++++++-----
 4 files changed, 42 insertions(+), 37 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f75af40..7a41878 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -3185,8 +3185,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
 break;
 case MSR_IA32_DEBUGCTLMSR:
 if (!boot_cpu_has(X86_FEATURE_LBRV)) {
-pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
-__func__, data);
+vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTL 0x%llx, nop\n",
+    __func__, data);
 break;
 }
 if (data &amp;amp; DEBUGCTL_RESERVED_BITS)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -3205,7 +3205,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
 case MSR_VM_CR:
 return svm_set_vm_cr(vcpu, data);
 case MSR_VM_IGNNE:
-pr_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
+vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
 break;
 default:
 return kvm_set_msr_common(vcpu, ecx, data);
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 32eb588..c6b2d25 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4489,7 +4489,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int handle_cr(struct kvm_vcpu *vcpu)
 break;
 }
 vcpu-&amp;gt;run-&amp;gt;exit_reason = 0;
-pr_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
+vcpu_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
        (int)(exit_qualification &amp;gt;&amp;gt; 4) &amp;amp; 3, cr);
 return 0;
 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b78f89d..0aac0bc 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1437,8 +1437,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int set_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 break;
 }
 default:
-pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
-  "data 0x%llx\n", msr, data);
+vcpu_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
+    "data 0x%llx\n", msr, data);
 return 1;
 }
 return 0;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1470,8 +1470,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int set_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 case HV_X64_MSR_TPR:
 return kvm_hv_vapic_msr_write(vcpu, APIC_TASKPRI, data);
 default:
-pr_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
-  "data 0x%llx\n", msr, data);
+vcpu_unimpl(vcpu, "HYPER-V unimplemented wrmsr: 0x%x "
+    "data 0x%llx\n", msr, data);
 return 1;
 }
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1551,15 +1551,15 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 data &amp;amp;= ~(u64)0x100;/* ignore ignne emulation enable */
 data &amp;amp;= ~(u64)0x8;/* ignore TLB cache disable */
 if (data != 0) {
-pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",
-data);
+vcpu_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",
+    data);
 return 1;
 }
 break;
 case MSR_FAM10H_MMIO_CONF_BASE:
 if (data != 0) {
-pr_unimpl(vcpu, "unimplemented MMIO_CONF_BASE wrmsr: "
-"0x%llx\n", data);
+vcpu_unimpl(vcpu, "unimplemented MMIO_CONF_BASE wrmsr: "
+    "0x%llx\n", data);
 return 1;
 }
 break;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1574,8 +1574,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
    thus reserved and should throw a #GP */
 return 1;
 }
-pr_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
-__func__, data);
+vcpu_unimpl(vcpu, "%s: MSR_IA32_DEBUGCTLMSR 0x%llx, nop\n",
+    __func__, data);
 break;
 case MSR_IA32_UCODE_REV:
 case MSR_IA32_UCODE_WRITE:
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1671,8 +1671,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 case MSR_K7_EVNTSEL2:
 case MSR_K7_EVNTSEL3:
 if (data != 0)
-pr_unimpl(vcpu, "unimplemented perfctr wrmsr: "
-"0x%x data 0x%llx\n", msr, data);
+vcpu_unimpl(vcpu, "unimplemented perfctr wrmsr: "
+    "0x%x data 0x%llx\n", msr, data);
 break;
 /* at least RHEL 4 unconditionally writes to the perfctr registers,
  * so we ignore writes to make it happy.
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1681,8 +1681,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 case MSR_K7_PERFCTR1:
 case MSR_K7_PERFCTR2:
 case MSR_K7_PERFCTR3:
-pr_unimpl(vcpu, "unimplemented perfctr wrmsr: "
-"0x%x data 0x%llx\n", msr, data);
+vcpu_unimpl(vcpu, "unimplemented perfctr wrmsr: "
+    "0x%x data 0x%llx\n", msr, data);
 break;
 case MSR_P6_PERFCTR0:
 case MSR_P6_PERFCTR1:
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1693,8 +1693,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 return kvm_pmu_set_msr(vcpu, msr, data);
 
 if (pr || data != 0)
-pr_unimpl(vcpu, "disabled perfctr wrmsr: "
-"0x%x data 0x%llx\n", msr, data);
+vcpu_unimpl(vcpu, "disabled perfctr wrmsr: "
+    "0x%x data 0x%llx\n", msr, data);
 break;
 case MSR_K7_CLK_CTL:
 /*
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1720,7 +1720,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 /* Drop writes to this legacy MSR -- see rdmsr
  * counterpart for further detail.
  */
-pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data);
+vcpu_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data);
 break;
 case MSR_AMD64_OSVW_ID_LENGTH:
 if (!guest_cpuid_has_osvw(vcpu))
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1738,12 +1738,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
 if (kvm_pmu_msr(vcpu, msr))
 return kvm_pmu_set_msr(vcpu, msr, data);
 if (!ignore_msrs) {
-pr_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n",
-msr, data);
+vcpu_unimpl(vcpu, "unhandled wrmsr: 0x%x data %llx\n",
+    msr, data);
 return 1;
 } else {
-pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n",
-msr, data);
+vcpu_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n",
+    msr, data);
 break;
 }
 }
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1846,7 +1846,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int get_msr_hyperv_pw(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 data = kvm-&amp;gt;arch.hv_hypercall;
 break;
 default:
-pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
+vcpu_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
 return 1;
 }
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1877,7 +1877,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int get_msr_hyperv(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 data = vcpu-&amp;gt;arch.hv_vapic;
 break;
 default:
-pr_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
+vcpu_unimpl(vcpu, "Hyper-V unhandled rdmsr: 0x%x\n", msr);
 return 1;
 }
 *pdata = data;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2030,10 +2030,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
 if (kvm_pmu_msr(vcpu, msr))
 return kvm_pmu_get_msr(vcpu, msr, pdata);
 if (!ignore_msrs) {
-pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
+vcpu_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
 return 1;
 } else {
-pr_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr);
+vcpu_unimpl(vcpu, "ignored rdmsr: 0x%x\n", msr);
 data = 0;
 }
 break;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4116,7 +4116,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static unsigned long emulator_get_cr(struct x86_emulate_ctxt *ctxt, int cr)
 value = kvm_get_cr8(vcpu);
 break;
 default:
-vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr);
+kvm_err("%s: unexpected cr %u\n", __func__, cr);
 return 0;
 }
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -4145,7 +4145,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int emulator_set_cr(struct x86_emulate_ctxt *ctxt, int cr, ulong val)
 res = kvm_set_cr8(vcpu, val);
 break;
 default:
-vcpu_printf(vcpu, "%s: unexpected cr %u\n", __func__, cr);
+kvm_err("%s: unexpected cr %u\n", __func__, cr);
 res = -1;
 }
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c446435..7825f1d 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -314,13 +314,18 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct kvm {
 long tlbs_dirty;
 };
 
-/* The guest did something we don't support. */
-#define pr_unimpl(vcpu, fmt, ...)\
-pr_err_ratelimited("kvm: %i: cpu%i " fmt,\
-   current-&amp;gt;tgid, (vcpu)-&amp;gt;vcpu_id , ## __VA_ARGS__)
+#define kvm_err(fmt, ...) \
+pr_err("kvm [%i]: " fmt, current-&amp;gt;pid, ## __VA_ARGS__)
+#define kvm_info(fmt, ...) \
+pr_info("kvm [%i]: " fmt, current-&amp;gt;pid, ## __VA_ARGS__)
+#define kvm_debug(fmt, ...) \
+pr_debug("kvm [%i]: " fmt, current-&amp;gt;pid, ## __VA_ARGS__)
+#define kvm_pr_unimpl(fmt, ...) \
+pr_err_ratelimited("kvm [%i]: " fmt, current-&amp;gt;tgid, ## __VA_ARGS__)
 
-#define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
-#define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu-&amp;gt;kvm, fmt)
+/* The guest did something we don't support. */
+#define vcpu_unimpl(vcpu, fmt, ...)\
+kvm_pr_unimpl("cpu%i " fmt, (vcpu)-&amp;gt;vcpu_id, ## __VA_ARGS__)
 
 static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
 {

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Christoffer Dall</dc:creator>
    <dc:date>2012-05-25T16:22:59</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91576">
    <title>[PATCH v4] uq/master: Expose CPUID leaf 7 only for -cpu host</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91576</link>
    <description>&lt;pre&gt;Changes v3 -&amp;gt; v4:
  - Wrap line at cpu_x86_fill_host() to make checkpatch.pl happy

Changes v2 -&amp;gt; v3;
  - Check for kvm_enabled() before setting cpuid_7_0_ebx_features

Changes v1 -&amp;gt; v2:
  - Use kvm_arch_get_supported_cpuid() instead of host_cpuid() on
    cpu_x86_fill_host().

  We should use GET_SUPPORTED_CPUID for all bits on "-cpu host"
  eventually, but I am not changing all the other CPUID leaves because
  we may not be able to test such an intrusive change in time for 1.1.

Description of the bug:

Since QEMU 0.15, the CPUID information on CPUID[EAX=7,ECX=0] is being
returned unfiltered to the guest, directly from the GET_SUPPORTED_CPUID
return value.

The problem is that this makes the resulting CPU feature flags
unpredictable and dependent on the host CPU and kernel version. This
breaks live-migration badly if migrating from a host CPU that supports
some features on that CPUID leaf (running a recent kernel) to a kernel
or host CPU that doesn't support it.

Migration also is incorrect (the virtual CPU changes under the guest's
feet) if you migrate in the opposite direction (from an old CPU/kernel
to a new CPU/kernel), but with less serious consequences (guests
normally query CPUID information only once on boot).

Fortunately, the bug affects only users using cpudefs with level &amp;gt;= 7.

The right behavior should be to explicitly enable those features on
[cpudef] config sections or on the "-cpu" command-line arguments. Right
now there is no predefined CPU model on QEMU that has those features:
the latest Intel model we have is Sandy Bridge.

I would like to get this fixed on 1.1, so I am submitting this patch,
that enables those features only if "-cpu host" is being used (as we
don't have any pre-defined CPU model that actually have those features).
After 1.1 is released, we can make those features properly configurable
on [cpudef] and -cpu configuration.

One problem is: with this patch, users with the following setup:
- Running QEMU 1.0;
- Using a cpudef having level &amp;gt;= 7;
- Running a kernel that supports the features on CPUID leaf 7; and
- Running on a CPU that supports some features on CPUID leaf 7
won't be able to live-migrate to QEMU 1.1. But for these users
live-migration is already broken (they can't live-migrate to hosts with
older CPUs or older kernels, already), I don't see how to avoid this
problem.

Signed-off-by: Eduardo Habkost &amp;lt;ehabkost&amp;lt; at &amp;gt;redhat.com&amp;gt;
---
 target-i386/cpu.c |   23 ++++++++++++++++-------
 target-i386/cpu.h |    2 ++
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 65d9af6..2a1c24b 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -238,6 +238,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; typedef struct x86_def_t {
     /* Store the results of Centaur's CPUID instructions */
     uint32_t ext4_features;
     uint32_t xlevel2;
+    /* The feature bits on CPUID[EAX=7,ECX=0].EBX */
+    uint32_t cpuid_7_0_ebx_features;
 } x86_def_t;
 
 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -521,6 +523,13 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int cpu_x86_fill_host(x86_def_t *x86_cpu_def)
     x86_cpu_def-&amp;gt;ext_features = ecx;
     x86_cpu_def-&amp;gt;features = edx;
 
+    if (kvm_enabled() &amp;amp;&amp;amp; x86_cpu_def-&amp;gt;level &amp;gt;= 7) {
+        x86_cpu_def-&amp;gt;cpuid_7_0_ebx_features =
+                kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
+    } else {
+        x86_cpu_def-&amp;gt;cpuid_7_0_ebx_features = 0;
+    }
+
     host_cpuid(0x80000000, 0, &amp;amp;eax, &amp;amp;ebx, &amp;amp;ecx, &amp;amp;edx);
     x86_cpu_def-&amp;gt;xlevel = eax;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1185,6 +1194,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
     env-&amp;gt;cpuid_kvm_features = def-&amp;gt;kvm_features;
     env-&amp;gt;cpuid_svm_features = def-&amp;gt;svm_features;
     env-&amp;gt;cpuid_ext4_features = def-&amp;gt;ext4_features;
+    env-&amp;gt;cpuid_7_0_ebx = def-&amp;gt;cpuid_7_0_ebx_features;
     env-&amp;gt;cpuid_xlevel2 = def-&amp;gt;xlevel2;
     object_property_set_int(OBJECT(cpu), (int64_t)def-&amp;gt;tsc_khz * 1000,
                             "tsc-frequency", &amp;amp;error);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1451,13 +1461,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *edx = 0;
         break;
     case 7:
-        if (kvm_enabled()) {
-            KVMState *s = env-&amp;gt;kvm_state;
-
-            *eax = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EAX);
-            *ebx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EBX);
-            *ecx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_ECX);
-            *edx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EDX);
+        /* Structured Extended Feature Flags Enumeration Leaf */
+        if (count == 0) {
+            *eax = 0; /* Maximum ECX value for sub-leaves */
+            *ebx = env-&amp;gt;cpuid_7_0_ebx; /* Feature flags */
+            *ecx = 0; /* Reserved */
+            *edx = 0; /* Reserved */
         } else {
             *eax = 0;
             *ebx = 0;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index b5b9a50..2460f63 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -741,6 +741,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; typedef struct CPUX86State {
     /* Store the results of Centaur's CPUID instructions */
     uint32_t cpuid_xlevel2;
     uint32_t cpuid_ext4_features;
+    /* Flags from CPUID[EAX=7,ECX=0].EBX */
+    uint32_t cpuid_7_0_ebx;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
&lt;/pre&gt;</description>
    <dc:creator>Eduardo Habkost</dc:creator>
    <dc:date>2012-05-25T14:55:09</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91567">
    <title>[PATCH v4 13/16] net: Make "info network" output more readable info</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91567</link>
    <description>&lt;pre&gt;From: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;

Reviewed-by:   Jan Kiszka  &amp;lt;jan.kiszka&amp;lt; at &amp;gt;siemens.com&amp;gt;
Signed-off-by: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;
---
 net.c     |   18 ++++++++++++++----
 net.h     |    1 +
 net/hub.c |   23 +++++++++++++++++++++--
 net/hub.h |    1 +
 4 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/net.c b/net.c
index 61dc28d..ae0deec 100644
--- a/net.c
+++ b/net.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -887,6 +887,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static const struct {
         },
     },
 #endif /* CONFIG_NET_BRIDGE */
+    [NET_CLIENT_TYPE_HUB] = {
+        .type = "hubport",
+        .desc = {
+            { /* end of list */ }
+        },
+    },
 };
 
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1068,7 +1074,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
     return 0;
 }
 
-static void print_net_client(Monitor *mon, NetClientState *vc)
+void print_net_client(Monitor *mon, NetClientState *vc)
 {
     monitor_printf(mon, "%s: type=%s,%s\n", vc-&amp;gt;name,
                    net_client_types[vc-&amp;gt;info-&amp;gt;type].type, vc-&amp;gt;info_str);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1079,12 +1085,17 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void do_info_network(Monitor *mon)
     NetClientState *nc, *peer;
     net_client_type type;
 
-    monitor_printf(mon, "Devices not on any VLAN:\n");
+    net_hub_info(mon);
+
     QTAILQ_FOREACH(nc, &amp;amp;net_clients, next) {
         peer = nc-&amp;gt;peer;
         type = nc-&amp;gt;info-&amp;gt;type;
+
+        if (net_hub_port_peer_nc(nc)) {
+            continue;
+        }
+
         if (!peer || type == NET_CLIENT_TYPE_NIC) {
-            monitor_printf(mon, "  ");
             print_net_client(mon, nc);
         } /* else it's a netdev connected to a NIC, printed with the NIC */
         if (peer &amp;amp;&amp;amp; type == NET_CLIENT_TYPE_NIC) {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1092,7 +1103,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void do_info_network(Monitor *mon)
             print_net_client(mon, peer);
         }
     }
-    net_hub_info(mon);
 }
 
 void qmp_set_link(const char *name, bool up, Error **errp)
diff --git a/net.h b/net.h
index 250669a..0692283 100644
--- a/net.h
+++ b/net.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -112,6 +112,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void qemu_check_nic_model(NICInfo *nd, const char *model);
 int qemu_find_nic_model(NICInfo *nd, const char * const *models,
                         const char *default_model);
 
+void print_net_client(Monitor *mon, NetClientState *vc);
 void do_info_network(Monitor *mon);
 
 /* NIC info */
diff --git a/net/hub.c b/net/hub.c
index 122de69..8c77d03 100644
--- a/net/hub.c
+++ b/net/hub.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -184,6 +184,25 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; NetClientState *net_hub_find_client_by_name(unsigned int hub_id,
 }
 
 /**
+ * Determine if one nc peers with one hub port
+ */
+bool net_hub_port_peer_nc(NetClientState *nc)
+{
+    NetHub *hub;
+    NetHubPort *port;
+
+    QLIST_FOREACH(hub, &amp;amp;hubs, next) {
+        QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
+            if (nc == port-&amp;gt;nc.peer) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+/**
  * Print hub configuration
  */
 void net_hub_info(Monitor *mon)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -194,8 +213,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void net_hub_info(Monitor *mon)
     QLIST_FOREACH(hub, &amp;amp;hubs, next) {
         monitor_printf(mon, "hub %u\n", hub-&amp;gt;id);
         QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
-            monitor_printf(mon, "    port %u peer %s\n", port-&amp;gt;id,
-                           port-&amp;gt;nc.peer ? port-&amp;gt;nc.peer-&amp;gt;name : "&amp;lt;none&amp;gt;");
+            monitor_printf(mon, "   \\ ");
+            print_net_client(mon, port-&amp;gt;nc.peer);
         }
     }
 }
diff --git a/net/hub.h b/net/hub.h
index ff5024a..550189b 100644
--- a/net/hub.h
+++ b/net/hub.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -23,5 +23,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; NetClientState *net_hub_find_client_by_name(unsigned int hub_id,
 void net_hub_info(Monitor *mon);
 int net_hub_id_for_client(NetClientState *nc, unsigned int *id);
 void net_hub_check_clients(void);
+bool net_hub_port_peer_nc(NetClientState *nc);
 
 #endif /* NET_HUB_H */
&lt;/pre&gt;</description>
    <dc:creator>zwu.kernel&lt; at &gt;gmail.com</dc:creator>
    <dc:date>2012-05-25T14:11:04</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91566">
    <title>[PATCH v3] uq/master: Expose CPUID leaf 7 only for -cpu host</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91566</link>
    <description>&lt;pre&gt;[re-submitting to get this in through uq/master]

Changes v2 -&amp;gt; v3;
  - Check for kvm_enabled() before setting cpuid_7_0_ebx_features

Changes v1 -&amp;gt; v2:
  - Use kvm_arch_get_supported_cpuid() instead of host_cpuid() on
    cpu_x86_fill_host().

  We should use GET_SUPPORTED_CPUID for all bits on "-cpu host"
  eventually, but I am not changing all the other CPUID leaves because
  we may not be able to test such an intrusive change in time for 1.1.

Description of the bug:

Since QEMU 0.15, the CPUID information on CPUID[EAX=7,ECX=0] is being
returned unfiltered to the guest, directly from the GET_SUPPORTED_CPUID
return value.

The problem is that this makes the resulting CPU feature flags
unpredictable and dependent on the host CPU and kernel version. This
breaks live-migration badly if migrating from a host CPU that supports
some features on that CPUID leaf (running a recent kernel) to a kernel
or host CPU that doesn't support it.

Migration also is incorrect (the virtual CPU changes under the guest's
feet) if you migrate in the opposite direction (from an old CPU/kernel
to a new CPU/kernel), but with less serious consequences (guests
normally query CPUID information only once on boot).

Fortunately, the bug affects only users using cpudefs with level &amp;gt;= 7.

The right behavior should be to explicitly enable those features on
[cpudef] config sections or on the "-cpu" command-line arguments. Right
now there is no predefined CPU model on QEMU that has those features:
the latest Intel model we have is Sandy Bridge.

I would like to get this fixed on 1.1, so I am submitting this patch,
that enables those features only if "-cpu host" is being used (as we
don't have any pre-defined CPU model that actually have those features).
After 1.1 is released, we can make those features properly configurable
on [cpudef] and -cpu configuration.

One problem is: with this patch, users with the following setup:
- Running QEMU 1.0;
- Using a cpudef having level &amp;gt;= 7;
- Running a kernel that supports the features on CPUID leaf 7; and
- Running on a CPU that supports some features on CPUID leaf 7
won't be able to live-migrate to QEMU 1.1. But for these users
live-migration is already broken (they can't live-migrate to hosts with
older CPUs or older kernels, already), I don't see how to avoid this
problem.

Signed-off-by: Eduardo Habkost &amp;lt;ehabkost&amp;lt; at &amp;gt;redhat.com&amp;gt;
---
 target-i386/cpu.c |   22 +++++++++++++++-------
 target-i386/cpu.h |    2 ++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 65d9af6..91a657a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -238,6 +238,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; typedef struct x86_def_t {
     /* Store the results of Centaur's CPUID instructions */
     uint32_t ext4_features;
     uint32_t xlevel2;
+    /* The feature bits on CPUID[EAX=7,ECX=0].EBX */
+    uint32_t cpuid_7_0_ebx_features;
 } x86_def_t;
 
 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -521,6 +523,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int cpu_x86_fill_host(x86_def_t *x86_cpu_def)
     x86_cpu_def-&amp;gt;ext_features = ecx;
     x86_cpu_def-&amp;gt;features = edx;
 
+    if (kvm_enabled() &amp;amp;&amp;amp; x86_cpu_def-&amp;gt;level &amp;gt;= 7) {
+        x86_cpu_def-&amp;gt;cpuid_7_0_ebx_features = kvm_arch_get_supported_cpuid(kvm_state, 0x7, 0, R_EBX);
+    } else {
+        x86_cpu_def-&amp;gt;cpuid_7_0_ebx_features = 0;
+    }
+
     host_cpuid(0x80000000, 0, &amp;amp;eax, &amp;amp;ebx, &amp;amp;ecx, &amp;amp;edx);
     x86_cpu_def-&amp;gt;xlevel = eax;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1185,6 +1193,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
     env-&amp;gt;cpuid_kvm_features = def-&amp;gt;kvm_features;
     env-&amp;gt;cpuid_svm_features = def-&amp;gt;svm_features;
     env-&amp;gt;cpuid_ext4_features = def-&amp;gt;ext4_features;
+    env-&amp;gt;cpuid_7_0_ebx = def-&amp;gt;cpuid_7_0_ebx_features;
     env-&amp;gt;cpuid_xlevel2 = def-&amp;gt;xlevel2;
     object_property_set_int(OBJECT(cpu), (int64_t)def-&amp;gt;tsc_khz * 1000,
                             "tsc-frequency", &amp;amp;error);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1451,13 +1460,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *edx = 0;
         break;
     case 7:
-        if (kvm_enabled()) {
-            KVMState *s = env-&amp;gt;kvm_state;
-
-            *eax = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EAX);
-            *ebx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EBX);
-            *ecx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_ECX);
-            *edx = kvm_arch_get_supported_cpuid(s, 0x7, count, R_EDX);
+        /* Structured Extended Feature Flags Enumeration Leaf */
+        if (count == 0) {
+            *eax = 0; /* Maximum ECX value for sub-leaves */
+            *ebx = env-&amp;gt;cpuid_7_0_ebx; /* Feature flags */
+            *ecx = 0; /* Reserved */
+            *edx = 0; /* Reserved */
         } else {
             *eax = 0;
             *ebx = 0;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index b5b9a50..2460f63 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -741,6 +741,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; typedef struct CPUX86State {
     /* Store the results of Centaur's CPUID instructions */
     uint32_t cpuid_xlevel2;
     uint32_t cpuid_ext4_features;
+    /* Flags from CPUID[EAX=7,ECX=0].EBX */
+    uint32_t cpuid_7_0_ebx;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
&lt;/pre&gt;</description>
    <dc:creator>Eduardo Habkost</dc:creator>
    <dc:date>2012-05-25T14:12:05</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91565">
    <title>[PATCH v4 13/16] net: Make "info network" output more readable info</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91565</link>
    <description>&lt;pre&gt;From: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;

Reviewed-by:   Jan Kiszka  &amp;lt;jan.kiszka&amp;lt; at &amp;gt;siemens.com&amp;gt;
Signed-off-by: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;
---
 net.c     |   18 ++++++++++++++----
 net.h     |   12 ++++++++++++
 net/hub.c |   23 +++++++++++++++++++++--
 net/hub.h |    1 +
 4 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/net.c b/net.c
index 61dc28d..ae0deec 100644
--- a/net.c
+++ b/net.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -887,6 +887,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static const struct {
         },
     },
 #endif /* CONFIG_NET_BRIDGE */
+    [NET_CLIENT_TYPE_HUB] = {
+        .type = "hubport",
+        .desc = {
+            { /* end of list */ }
+        },
+    },
 };
 
 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1068,7 +1074,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
     return 0;
 }
 
-static void print_net_client(Monitor *mon, NetClientState *vc)
+void print_net_client(Monitor *mon, NetClientState *vc)
 {
     monitor_printf(mon, "%s: type=%s,%s\n", vc-&amp;gt;name,
                    net_client_types[vc-&amp;gt;info-&amp;gt;type].type, vc-&amp;gt;info_str);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1079,12 +1085,17 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void do_info_network(Monitor *mon)
     NetClientState *nc, *peer;
     net_client_type type;
 
-    monitor_printf(mon, "Devices not on any VLAN:\n");
+    net_hub_info(mon);
+
     QTAILQ_FOREACH(nc, &amp;amp;net_clients, next) {
         peer = nc-&amp;gt;peer;
         type = nc-&amp;gt;info-&amp;gt;type;
+
+        if (net_hub_port_peer_nc(nc)) {
+            continue;
+        }
+
         if (!peer || type == NET_CLIENT_TYPE_NIC) {
-            monitor_printf(mon, "  ");
             print_net_client(mon, nc);
         } /* else it's a netdev connected to a NIC, printed with the NIC */
         if (peer &amp;amp;&amp;amp; type == NET_CLIENT_TYPE_NIC) {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1092,7 +1103,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void do_info_network(Monitor *mon)
             print_net_client(mon, peer);
         }
     }
-    net_hub_info(mon);
 }
 
 void qmp_set_link(const char *name, bool up, Error **errp)
diff --git a/net.h b/net.h
index 250669a..08306a4 100644
--- a/net.h
+++ b/net.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -112,6 +112,18 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void qemu_check_nic_model(NICInfo *nd, const char *model);
 int qemu_find_nic_model(NICInfo *nd, const char * const *models,
                         const char *default_model);
 
+ssize_t qemu_deliver_packet(NetClientState *sender,
+                            unsigned flags,
+                            const uint8_t *data,
+                            size_t size,
+                            void *opaque);
+ssize_t qemu_deliver_packet_iov(NetClientState *sender,
+                            unsigned flags,
+                            const struct iovec *iov,
+                            int iovcnt,
+                            void *opaque);
+
+void print_net_client(Monitor *mon, NetClientState *vc);
 void do_info_network(Monitor *mon);
 
 /* NIC info */
diff --git a/net/hub.c b/net/hub.c
index 122de69..8c77d03 100644
--- a/net/hub.c
+++ b/net/hub.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -184,6 +184,25 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; NetClientState *net_hub_find_client_by_name(unsigned int hub_id,
 }
 
 /**
+ * Determine if one nc peers with one hub port
+ */
+bool net_hub_port_peer_nc(NetClientState *nc)
+{
+    NetHub *hub;
+    NetHubPort *port;
+
+    QLIST_FOREACH(hub, &amp;amp;hubs, next) {
+        QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
+            if (nc == port-&amp;gt;nc.peer) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+/**
  * Print hub configuration
  */
 void net_hub_info(Monitor *mon)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -194,8 +213,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void net_hub_info(Monitor *mon)
     QLIST_FOREACH(hub, &amp;amp;hubs, next) {
         monitor_printf(mon, "hub %u\n", hub-&amp;gt;id);
         QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
-            monitor_printf(mon, "    port %u peer %s\n", port-&amp;gt;id,
-                           port-&amp;gt;nc.peer ? port-&amp;gt;nc.peer-&amp;gt;name : "&amp;lt;none&amp;gt;");
+            monitor_printf(mon, "   \\ ");
+            print_net_client(mon, port-&amp;gt;nc.peer);
         }
     }
 }
diff --git a/net/hub.h b/net/hub.h
index ff5024a..550189b 100644
--- a/net/hub.h
+++ b/net/hub.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -23,5 +23,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; NetClientState *net_hub_find_client_by_name(unsigned int hub_id,
 void net_hub_info(Monitor *mon);
 int net_hub_id_for_client(NetClientState *nc, unsigned int *id);
 void net_hub_check_clients(void);
+bool net_hub_port_peer_nc(NetClientState *nc);
 
 #endif /* NET_HUB_H */
&lt;/pre&gt;</description>
    <dc:creator>zwu.kernel&lt; at &gt;gmail.com</dc:creator>
    <dc:date>2012-05-25T14:02:09</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91535">
    <title>[PATCH v4 16/16] hub: add the support for hub own flow control</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91535</link>
    <description>&lt;pre&gt;From: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;

Only when all other hub port's *peer* .can_receive() all return 1, the source hub port .can_receive() return 1.

Signed-off-by: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;
---
 net/hub.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/net/hub.c b/net/hub.c
index 357ca87..478cce1 100644
--- a/net/hub.c
+++ b/net/hub.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -15,6 +15,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #include "monitor.h"
 #include "net.h"
 #include "hub.h"
+#include "iov.h"
 
 /*
  * A hub broadcasts incoming packets to all its ports except the source port.
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -59,16 +60,16 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static ssize_t net_hub_receive_iov(NetHub *hub, NetHubPort *source_port,
                                    const struct iovec *iov, int iovcnt)
 {
     NetHubPort *port;
-    ssize_t ret = 0;
+    ssize_t len = iov_size(iov, iovcnt);
 
     QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
         if (port == source_port) {
             continue;
         }
 
-        ret = qemu_sendv_packet(&amp;amp;port-&amp;gt;nc, iov, iovcnt);
+        qemu_sendv_packet(&amp;amp;port-&amp;gt;nc, iov, iovcnt);
     }
-    return ret;
+    return len;
 }
 
 static NetHub *net_hub_new(unsigned int id)
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -85,6 +86,25 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static NetHub *net_hub_new(unsigned int id)
     return hub;
 }
 
+static int net_hub_port_can_receive(NetClientState *nc)
+{
+    NetHubPort *port;
+    NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
+    NetHub *hub = src_port-&amp;gt;hub;
+
+    QLIST_FOREACH(port, &amp;amp;hub-&amp;gt;ports, next) {
+        if (port == src_port) {
+            continue;
+        }
+
+        if (!qemu_can_send_packet(&amp;amp;port-&amp;gt;nc)) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
 static ssize_t net_hub_port_receive(NetClientState *nc,
                                     const uint8_t *buf, size_t len)
 {
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -111,6 +131,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void net_hub_port_cleanup(NetClientState *nc)
 static NetClientInfo net_hub_port_info = {
     .type = NET_CLIENT_TYPE_HUB,
     .size = sizeof(NetHubPort),
+    .can_receive = net_hub_port_can_receive,
     .receive = net_hub_port_receive,
     .receive_iov = net_hub_port_receive_iov,
     .cleanup = net_hub_port_cleanup,
&lt;/pre&gt;</description>
    <dc:creator>zwu.kernel&lt; at &gt;gmail.com</dc:creator>
    <dc:date>2012-05-25T10:52:14</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91503">
    <title>[RFC PATCH] vfio: add fixup for broken PCI devices</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91503</link>
    <description>&lt;pre&gt;Some adapters (like NEC PCI USB controller) do not flush their config
on a sioftware reset and remember DMA config, etc.

If we use such an adapter with QEMU, then crash QEMU (stop it with
ctrl-A ctrl-X), and try to use it in QEMU again, it may start working
immediately with previous config when pci_enable_device() is called
on that PCI function.

To eliminate such effect, some quirk should be called. The proposed
pci_fixup_final does its job well for mentioned NEC PCI USB but not
sure if it is 100% correct.

Signed-off-by: Alexey Kardashevskiy &amp;lt;aik&amp;lt; at &amp;gt;ozlabs.ru&amp;gt;
---
 drivers/vfio/pci/vfio_pci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 1e5315c..6e7c12d 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -88,6 +88,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void vfio_pci_disable(struct vfio_pci_device *vdev)
 {
 int bar;
 
+pci_fixup_device(pci_fixup_final, vdev-&amp;gt;pdev);
+
 pci_disable_device(vdev-&amp;gt;pdev);
 
 vfio_pci_set_irqs_ioctl(vdev, VFIO_IRQ_SET_DATA_NONE |
&lt;/pre&gt;</description>
    <dc:creator>Alexey Kardashevskiy</dc:creator>
    <dc:date>2012-05-25T07:35:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91457">
    <title>Date: 24/05/2012.</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91457</link>
    <description>&lt;pre&gt;Dear friend                                 24/05/2012.
I am Dr Raymond Chien Independent Non-executive Director of Hang Seng
Bank Hong Kong I have a business transaction of $44.5 million USD
to share with you,If interested contact me for more details via my
personal email:  draymndch8&amp;lt; at &amp;gt;yahoo.co.jp
Full names:Address:Age:Occupation:Phone/Fax
Regards: Date: 24/05/2012.
Dr Raymond Chien Kuo Fung 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>From Hang Seng Bank</dc:creator>
    <dc:date>2012-05-24T20:47:24</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91434">
    <title>[PATCH v3 00/16] net: hub-based networking</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91434</link>
    <description>&lt;pre&gt;From: Zhi Yong Wu &amp;lt;wuzhy&amp;lt; at &amp;gt;linux.vnet.ibm.com&amp;gt;

The patchset implements network hub stead of vlan. The main work was done by stefan, and i rebased it to latest QEMU upstream, did some testings and am responsible for pushing it to QEMU upstream.

Changelog from v2:
  1.) add the support for hub own flow control [paolo]
  2.) make the monitor output more reasonable hub info [jan kiszka]

v2:
  1.) cleanup some obsolete vlan info
  2.) cleanup deliver/deliver_iov func pointers [paolo]
  3.) support more flexible flow control [paolo]

Stefan Hajnoczi (12):
  net: Add a hub net client
  net: Use hubs for the vlan feature
  net: Look up 'vlan' net clients using hubs
  hub: Check that hubs are configured correctly
  net: Drop vlan argument to qemu_new_net_client()
  net: Remove vlan qdev property
  net: Remove vlan code from net.c
  net: Remove VLANState
  net: Rename non_vlan_clients to net_clients
  net: Rename VLANClientState to NetClientState
  net: Rename vc local variables to nc
  net: Rename qemu_del_vlan_client() to qemu_del_net_client()

Zhi Yong Wu (4):
  net: Make the monitor output more reasonable hub info
  net: cleanup deliver/deliver_iov func pointers
  net: determine if packets can be sent before net queue deliver
    packets
  hub: add the support for hub own flow control

 Makefile.objs           |    2 +-
 hw/cadence_gem.c        |    8 +-
 hw/dp8393x.c            |    6 +-
 hw/e1000.c              |   10 +-
 hw/eepro100.c           |    8 +-
 hw/etraxfs_eth.c        |    8 +-
 hw/lan9118.c            |    8 +-
 hw/lance.c              |    2 +-
 hw/mcf_fec.c            |    6 +-
 hw/milkymist-minimac2.c |    6 +-
 hw/mipsnet.c            |    6 +-
 hw/musicpal.c           |    6 +-
 hw/ne2000-isa.c         |    2 +-
 hw/ne2000.c             |    8 +-
 hw/ne2000.h             |    4 +-
 hw/opencores_eth.c      |    8 +-
 hw/pcnet-pci.c          |    4 +-
 hw/pcnet.c              |    6 +-
 hw/pcnet.h              |    6 +-
 hw/qdev-properties.c    |   78 +------
 hw/qdev.c               |    2 -
 hw/qdev.h               |    8 +-
 hw/rtl8139.c            |   10 +-
 hw/smc91c111.c          |    6 +-
 hw/spapr_llan.c         |    4 +-
 hw/stellaris_enet.c     |    6 +-
 hw/usb/dev-network.c    |    8 +-
 hw/vhost_net.c          |   24 +-
 hw/vhost_net.h          |    2 +-
 hw/virtio-net.c         |   12 +-
 hw/xen_nic.c            |    7 +-
 hw/xgmac.c              |    6 +-
 hw/xilinx_axienet.c     |    6 +-
 hw/xilinx_ethlite.c     |    6 +-
 net.c                   |  606 ++++++++++++++---------------------------------
 net.h                   |   85 ++++----
 net/dump.c              |   28 ++-
 net/dump.h              |    2 +-
 net/hub.c               |  298 +++++++++++++++++++++++
 net/hub.h               |   28 +++
 net/queue.c             |   42 ++--
 net/queue.h             |   25 +--
 net/slirp.c             |   32 +--
 net/slirp.h             |    2 +-
 net/socket.c            |   66 +++---
 net/socket.h            |    2 +-
 net/tap-win32.c         |   27 +-
 net/tap.c               |   45 ++--
 net/tap.h               |   21 +-
 net/vde.c               |   17 +-
 net/vde.h               |    3 +-
 qemu-common.h           |    3 +-
 slirp/if.c              |    5 -
 slirp/libslirp.h        |    1 -
 54 files changed, 811 insertions(+), 826 deletions(-)
 create mode 100644 net/hub.c
 create mode 100644 net/hub.h

&lt;/pre&gt;</description>
    <dc:creator>zwu.kernel&lt; at &gt;gmail.com</dc:creator>
    <dc:date>2012-05-24T17:59:06</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91432">
    <title>[PATCH 1/2] Remove kvm_commit_irq_routes from error messages</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91432</link>
    <description>&lt;pre&gt;Make my life a bit easier and report the correct function names.
s/kvm_commit_irq_routes/kvm_irqchip_commit_routes

Signed-off-by: Richard Weinberger &amp;lt;richard&amp;lt; at &amp;gt;nod.at&amp;gt;
---
 hw/device-assignment.c |    4 ++--
 hw/msi.c               |    2 +-
 hw/msix.c              |    4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 1daadb9..09726f9 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -958,7 +958,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void assigned_dev_update_msi(PCIDevice *pci_dev)
 
         kvm_add_routing_entry(kvm_state, assigned_dev-&amp;gt;entry);
         if (kvm_irqchip_commit_routes(kvm_state) &amp;lt; 0) {
-            perror("assigned_dev_update_msi: kvm_commit_irq_routes");
+            perror("assigned_dev_update_msi: kvm_irqchip_commit_routes");
             assigned_dev-&amp;gt;cap.state &amp;amp;= ~ASSIGNED_DEVICE_MSI_ENABLED;
             return;
         }
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -1053,7 +1053,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int assigned_dev_update_msix_mmio(PCIDevice *pci_dev)
     }
 
     if (r == 0 &amp;amp;&amp;amp; kvm_irqchip_commit_routes(kvm_state) &amp;lt; 0) {
-    perror("assigned_dev_update_msix_mmio: kvm_commit_irq_routes");
+    perror("assigned_dev_update_msix_mmio: kvm_irqchip_commit_routes");
     return -EINVAL;
     }
 
diff --git a/hw/msi.c b/hw/msi.c
index 4fcf769..1a20e83 100644
--- a/hw/msi.c
+++ b/hw/msi.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -180,7 +180,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void kvm_msi_update(PCIDevice *dev)
     if (changed) {
         r = kvm_irqchip_commit_routes(kvm_state);
         if (r) {
-            fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__,
+            fprintf(stderr, "%s: kvm_irqchip_commit_routes failed: %s\n", __func__,
                     strerror(-r));
             exit(1);
         }
diff --git a/hw/msix.c b/hw/msix.c
index 5515a32..34b7455 100644
--- a/hw/msix.c
+++ b/hw/msix.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -91,7 +91,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void kvm_msix_update(PCIDevice *dev, int vector,
         *entry = new_entry;
         r = kvm_irqchip_commit_routes(kvm_state);
         if (r) {
-            fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__,
+            fprintf(stderr, "%s: kvm_irqchip_commit_routes failed: %s\n", __func__,
     strerror(-r));
             exit(1);
         }
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -112,7 +112,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static int kvm_msix_vector_add(PCIDevice *dev, unsigned vector)
 
     r = kvm_irqchip_commit_routes(kvm_state);
     if (r &amp;lt; 0) {
-        fprintf(stderr, "%s: kvm_commit_irq_routes failed: %s\n", __func__, strerror(-r));
+        fprintf(stderr, "%s: kvm_irqchip_commit_routes failed: %s\n", __func__, strerror(-r));
         return r;
     }
     return 0;
&lt;/pre&gt;</description>
    <dc:creator>Richard Weinberger</dc:creator>
    <dc:date>2012-05-24T17:02:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91395">
    <title>which branch of kvm.git should I do regular testing against?</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91395</link>
    <description>&lt;pre&gt;Hi Avi,
Our team spare some effort in regular nightly testing against KVM upstream.
We're using master branch now and all the test reports I sent out are based on master branch.
Which branch of kvm.git should we do regular testing against?
Your suggestion?

I know next branch contains latest KVM patches. 
But I found some recent KVM patches in master branch never existed in next branch.
And, the next branch is based on linux3.4-rc3, while master branch is based on linux3.4-rc7.
Another question is whether the patches in next branch will be finally merged into master branch?


Best Regards,
     Yongjie (Jay)

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Ren, Yongjie</dc:creator>
    <dc:date>2012-05-24T09:24:34</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91388">
    <title>[RFC PATCH] PCI: Introduce INTx check &amp; mask API</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91388</link>
    <description>&lt;pre&gt;[Found while debugging VFIO on POWER but it is platform independent]

There is a feature in PCI (&amp;gt;=2.3?) to mask/unmask INTx via PCI_COMMAND and
PCI_STATUS registers.

And there is some API to support that (commit a2e27787f893621c5a6b865acf6b7766f8671328).

I have a network adapter:
0001:00:01.0 Ethernet controller: Chelsio Communications Inc T310 10GbE Single Port Adapter
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast &amp;gt;TAbort- &amp;lt;TAbort- &amp;lt;MAbort- &amp;gt;SERR- &amp;lt;PERR- INTx-

pci_intx_mask_supported() reports that the feature is supported for this adapter
BUT the adapter does not set PCI_STATUS_INTERRUPT so pci_check_and_set_intx_mask()
never changes PCI_COMMAND and INTx does not work on it when we use it as VFIO-PCI device.

If I remove the check of this bit, it works fine as it is called from an interrupt handler and
Status bit check is redundant.

Opened a spec:
PCI LOCAL BUS SPECIFICATION, REV. 3.0, Table 6-2: Status Register Bits
===
3This read-only bit reflects the state of the interrupt in the
device/function. Only when the Interrupt Disable bit in the command
register is a 0 and this Interrupt Status bit is a 1, will the
device’s/function’s INTx# signal be asserted. Setting the Interrupt
   Disable bit to a 1 has no effect on the state of this bit.
===
With this adapter, INTx# is asserted but Status bit is still 0.

Is it mandatory for a device to set Status bit if it supports INTx masking?

2 Alex: if it is mandatory, then we need to be able to disable pci_2_3 in VFIO-PCI
somehow.


Signed-off-by: Alexey Kardashevskiy &amp;lt;aik&amp;lt; at &amp;gt;ozlabs.ru&amp;gt;
---
 drivers/pci/pci.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ab6c2a6..ee4c804 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -2978,60 +2978,60 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; EXPORT_SYMBOL_GPL(pci_intx_mask_supported);
 
 static bool pci_check_and_set_intx_mask(struct pci_dev *dev, bool mask)
 {
 struct pci_bus *bus = dev-&amp;gt;bus;
 bool mask_updated = true;
 u32 cmd_status_dword;
 u16 origcmd, newcmd;
 unsigned long flags;
 bool irq_pending;
 
 /*
  * We do a single dword read to retrieve both command and status.
  * Document assumptions that make this possible.
  */
 BUILD_BUG_ON(PCI_COMMAND % 4);
 BUILD_BUG_ON(PCI_COMMAND + 2 != PCI_STATUS);
 
 raw_spin_lock_irqsave(&amp;amp;pci_lock, flags);
 
 bus-&amp;gt;ops-&amp;gt;read(bus, dev-&amp;gt;devfn, PCI_COMMAND, 4, &amp;amp;cmd_status_dword);
 
 irq_pending = (cmd_status_dword &amp;gt;&amp;gt; 16) &amp;amp; PCI_STATUS_INTERRUPT;
 
 /*
  * Check interrupt status register to see whether our device
  * triggered the interrupt (when masking) or the next IRQ is
  * already pending (when unmasking).
  */
-if (mask != irq_pending) {
+/*if (mask != irq_pending) {
 mask_updated = false;
 goto done;
-}
+}*/
 
 origcmd = cmd_status_dword;
 newcmd = origcmd &amp;amp; ~PCI_COMMAND_INTX_DISABLE;
 if (mask)
 newcmd |= PCI_COMMAND_INTX_DISABLE;
 if (newcmd != origcmd)
 bus-&amp;gt;ops-&amp;gt;write(bus, dev-&amp;gt;devfn, PCI_COMMAND, 2, newcmd);
 
 done:
 raw_spin_unlock_irqrestore(&amp;amp;pci_lock, flags);
 
 return mask_updated;
 }
 
 /**
  * pci_check_and_mask_intx - mask INTx on pending interrupt
  * &amp;lt; at &amp;gt;dev: the PCI device to operate on
  *
  * Check if the device dev has its INTx line asserted, mask it and
  * return true in that case. False is returned if not interrupt was
  * pending.
  */
 bool pci_check_and_mask_intx(struct pci_dev *dev)
 {
 return pci_check_and_set_intx_mask(dev, true);
 }
 EXPORT_SYMBOL_GPL(pci_check_and_mask_intx);
 
&lt;/pre&gt;</description>
    <dc:creator>Alexey Kardashevskiy</dc:creator>
    <dc:date>2012-05-24T07:44:22</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91383">
    <title>[PATCH] vfio-powerpc: enabled and supported on power</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91383</link>
    <description>&lt;pre&gt;The patch introduces support of VFIO on POWER.

The patch consists of:

1. IOMMU driver for VFIO.
It does not use IOMMU API at all, instead it calls POWER
IOMMU API directly (ppc_md callbacks).

2. A piece of code (module_init) which creates IOMMU groups.
TBD: what is a better place for it?

The patch is made on top of
git://github.com/awilliam/linux-vfio.git iommu-group-vfio-20120523
(which is iommu-group-vfio-20120521 + some fixes)

Signed-off-by: Alexey Kardashevskiy &amp;lt;aik&amp;lt; at &amp;gt;ozlabs.ru&amp;gt;
---
 arch/powerpc/Kconfig             |    6 +
 arch/powerpc/include/asm/iommu.h |    3 +
 arch/powerpc/kernel/Makefile     |    1 +
 arch/powerpc/kernel/iommu_vfio.c |  371 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 381 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/kernel/iommu_vfio.c

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index feab3ba..13d12ac 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -319,6 +319,12 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; config 8XX_MINIMAL_FPEMU
 config IOMMU_HELPER
 def_bool PPC64
 
+config IOMMU_VFIO
+select IOMMU_API
+depends on PPC64
+tristate "Enable IOMMU chardev to support user-space PCI"
+default n
+
 config SWIOTLB
 bool "SWIOTLB support"
 default n
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index 957a83f..c64bce7 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -66,6 +66,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct iommu_table {
 unsigned long  it_halfpoint; /* Breaking point for small/large allocs */
 spinlock_t     it_lock;      /* Protects it_map */
 unsigned long *it_map;       /* A simple allocation bitmap for now */
+#ifdef CONFIG_IOMMU_API
+struct iommu_group *it_group;
+#endif
 };
 
 struct scatterlist;
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index f5808a3..7cfd68e 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -90,6 +90,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; obj-$(CONFIG_RELOCATABLE_PPC32)+= reloc_32.o
 
 obj-$(CONFIG_PPC32)+= entry_32.o setup_32.o
 obj-$(CONFIG_PPC64)+= dma-iommu.o iommu.o
+obj-$(CONFIG_IOMMU_VFIO)+= iommu_vfio.o
 obj-$(CONFIG_KGDB)+= kgdb.o
 obj-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)+= prom_init.o
 obj-$(CONFIG_MODULES)+= ppc_ksyms.o
diff --git a/arch/powerpc/kernel/iommu_vfio.c b/arch/powerpc/kernel/iommu_vfio.c
new file mode 100644
index 0000000..68a93dd
--- /dev/null
+++ b/arch/powerpc/kernel/iommu_vfio.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -0,0 +1,371 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
+/*
+ * VFIO: IOMMU DMA mapping support for TCE on POWER
+ *
+ * Copyright (C) 2012 IBM Corp.  All rights reserved.
+ *     Author: Alexey Kardashevskiy &amp;lt;aik&amp;lt; at &amp;gt;ozlabs.ru&amp;gt;
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Derived from original vfio_iommu_x86.c:
+ * Copyright (C) 2012 Red Hat, Inc.  All rights reserved.
+ *     Author: Alex Williamson &amp;lt;alex.williamson&amp;lt; at &amp;gt;redhat.com&amp;gt;
+ */
+
+#include &amp;lt;linux/module.h&amp;gt;
+#include &amp;lt;linux/pci.h&amp;gt;
+#include &amp;lt;linux/slab.h&amp;gt;
+#include &amp;lt;linux/uaccess.h&amp;gt;
+#include &amp;lt;linux/vfio.h&amp;gt;
+#include &amp;lt;linux/err.h&amp;gt;
+#include &amp;lt;linux/spinlock.h&amp;gt;
+#include &amp;lt;asm/iommu.h&amp;gt;
+
+#define DRIVER_VERSION  "0.1"
+#define DRIVER_AUTHOR   "aik&amp;lt; at &amp;gt;ozlabs.ru"
+#define DRIVER_DESC     "POWER IOMMU chardev for VFIO"
+
+#define IOMMU_CHECK_EXTENSION_IO(VFIO_TYPE, VFIO_BASE + 1)
+
+/* -------- API for POWERPC IOMMU -------- */
+
+#define POWERPC_IOMMU2
+
+struct tce_iommu_info {
+__u32 argsz;
+__u32 dma32_window_start;
+__u32 dma32_window_size;
+};
+
+#define POWERPC_IOMMU_GET_INFO_IO(VFIO_TYPE, VFIO_BASE + 12)
+
+struct tce_iommu_dma_map {
+__u32 argsz;
+__u64 va;
+__u64 dmaaddr;
+};
+
+#define POWERPC_IOMMU_MAP_DMA_IO(VFIO_TYPE, VFIO_BASE + 13)
+#define POWERPC_IOMMU_UNMAP_DMA_IO(VFIO_TYPE, VFIO_BASE + 14)
+
+/* ***************************************************************** */
+
+struct tce_iommu {
+struct iommu_table *tbl;
+};
+
+static int tce_iommu_attach_group(void *iommu_data,
+struct iommu_group *iommu_group)
+{
+struct tce_iommu *tceiommu = iommu_data;
+
+if (tceiommu-&amp;gt;tbl) {
+printk(KERN_ERR "Only one group per IOMMU instance is allowed\n");
+return -EFAULT;
+}
+tceiommu-&amp;gt;tbl = iommu_group_get_iommudata(iommu_group);
+
+return 0;
+}
+
+static void tce_iommu_detach_group(void *iommu_data,
+struct iommu_group *iommu_group)
+{
+struct tce_iommu *tceiommu = iommu_data;
+
+if (!tceiommu-&amp;gt;tbl) {
+printk(KERN_ERR "IOMMU already released\n");
+return;
+}
+tceiommu-&amp;gt;tbl = NULL;
+}
+
+static void *tce_iommu_open(unsigned long arg)
+{
+struct tce_iommu *tceiommu;
+
+if (arg != POWERPC_IOMMU)
+return ERR_PTR(-EINVAL);
+
+tceiommu = kzalloc(sizeof(*tceiommu), GFP_KERNEL);
+if (!tceiommu)
+return ERR_PTR(-ENOMEM);
+
+return tceiommu;
+}
+
+static void tce_iommu_release(void *iommu_data)
+{
+struct tce_iommu *tceiommu = iommu_data;
+kfree(tceiommu);
+}
+
+static int tce_iommu_map(struct iommu_table *tbl, unsigned long iova,
+   phys_addr_t paddr)
+{
+unsigned long entry, flags;
+int build_fail;
+
+spin_lock_irqsave(&amp;amp;(tbl-&amp;gt;it_lock), flags);
+entry = iova &amp;gt;&amp;gt; IOMMU_PAGE_SHIFT;
+build_fail = ppc_md.tce_build(tbl, entry, 1/*pages*/,
+(unsigned long)paddr &amp;amp; IOMMU_PAGE_MASK,
+DMA_BIDIRECTIONAL, NULL/*attrs*/);
+
+/* ppc_md.tce_build() only returns non-zero for transient errors.
+ * Clean up the table bitmap in this case and return
+ * DMA_ERROR_CODE. For all other errors the functionality is
+ * not altered.
+ */
+if (unlikely(build_fail)) {
+printk("Failed to add TCE\n");
+spin_unlock_irqrestore(&amp;amp;(tbl-&amp;gt;it_lock), flags);
+return -EFAULT;
+}
+/* Flush/invalidate TLB caches if necessary */
+if (ppc_md.tce_flush)
+ppc_md.tce_flush(tbl);
+
+spin_unlock_irqrestore(&amp;amp;(tbl-&amp;gt;it_lock), flags);
+
+/* Make sure updates are seen by hardware */
+mb();
+
+return 0;
+}
+
+static void tce_iommu_unmap(struct iommu_table *tbl, unsigned long iova)
+{
+unsigned long entry, flags;
+entry = iova &amp;gt;&amp;gt; IOMMU_PAGE_SHIFT;
+
+spin_lock_irqsave(&amp;amp;(tbl-&amp;gt;it_lock), flags);
+ppc_md.tce_free(tbl, entry, 1);
+/* Flush/invalidate TLB caches if necessary */
+if (ppc_md.tce_flush)
+ppc_md.tce_flush(tbl);
+
+spin_unlock_irqrestore(&amp;amp;(tbl-&amp;gt;it_lock), flags);
+
+/* Make sure updates are seen by hardware */
+mb();
+}
+
+static phys_addr_t tce_iommu_iova_to_va(struct iommu_table *tbl,
+unsigned long iova)
+{
+unsigned long entry = iova &amp;gt;&amp;gt; IOMMU_PAGE_SHIFT;
+phys_addr_t ret = 0;
+
+if (ppc_md.tce_get)
+ret = ppc_md.tce_get(tbl, entry);
+
+return ret;
+}
+
+static struct page *tceaddr_to_page(void *addr)
+{
+return pfn_to_page(__pa(addr) &amp;gt;&amp;gt; PAGE_SHIFT);
+}
+
+static long tce_dmamap_page(struct iommu_table *tbl,
+uint64_t va, uint64_t dmaaddr)
+{
+int ret = -EFAULT;
+phys_addr_t addr;
+struct page *page[1];
+int iswrite = 1;
+void *kva;
+
+if (NULL == tbl) {
+printk(KERN_ERR"tce_iommu: (map) IOMMU table has not "
+"been initialized yet!\n");
+return -EFAULT;
+}
+addr = tce_iommu_iova_to_va(tbl, dmaaddr);
+if (addr) {
+printk(KERN_WARNING"tce_iommu: already mapped va=%llx "
+"da=%llx addr=%llx\n",
+va, dmaaddr, addr);
+/*TODO: unmap! */
+}
+
+ret = get_user_pages_fast(va, 1, iswrite, page);
+if (1 != ret) {
+printk(KERN_ERR"tce_iommu: get_user_pages_fast failed "
+"va=%llx da=%llx addr=%llx ret=%d\n",
+va, dmaaddr, addr, ret);
+return -EFAULT;
+}
+ret = -EFAULT;
+kva = (void *) page_address(page[0]);
+if (kva) {
+ret = tce_iommu_map(tbl, dmaaddr, (phys_addr_t) kva);
+}
+if (ret) {
+printk(KERN_ERR"tce_iommu: tce_iommu_map va=%llx "
+"da=%llx kva=%p\n",
+va, dmaaddr, kva);
+if (iswrite)
+SetPageDirty(page[0]);
+put_page(page[0]);
+}
+
+return ret;
+}
+
+static long tce_dmaunmap_page(struct iommu_table *tbl, uint64_t dmaaddr)
+{
+int ret = 0;
+phys_addr_t addr;
+struct page *page;
+
+if (NULL == tbl) {
+printk(KERN_ERR"tce_iommu: (unmap) IOMMU table has not been "
+"initialized yet!\n");
+return -EFAULT;
+}
+addr = tce_iommu_iova_to_va(tbl, dmaaddr);
+if (addr) {
+page = tceaddr_to_page((void*)addr);
+if (!page) {
+printk(KERN_ERR"DMAUNMAP error: pfn_to_page(%llx) "
+"failed\n", addr);
+ret = -EFAULT;
+} else {
+SetPageDirty(page);
+put_page(page);
+}
+}
+tce_iommu_unmap(tbl, dmaaddr);
+if (ret)
+printk(KERN_ERR"Failed to DMAUNMAP: da=%llx pfn=%llx\n",
+dmaaddr, addr);
+return ret;
+}
+
+
+static long tce_iommu_ioctl(void *iommu_data,
+ unsigned int cmd, unsigned long arg)
+{
+struct tce_iommu *tceiommu = iommu_data;
+unsigned long minsz;
+
+if (cmd == IOMMU_CHECK_EXTENSION) {
+switch (arg) {
+case POWERPC_IOMMU:
+return 1;
+default:
+return 0;
+}
+} else if (cmd == POWERPC_IOMMU_GET_INFO) {
+struct tce_iommu_info info;
+
+minsz = offsetofend(struct tce_iommu_info, dma32_window_size);
+
+if (copy_from_user(&amp;amp;info, (void __user *)arg, minsz))
+return -EFAULT;
+
+if (info.argsz &amp;lt; minsz)
+return -EINVAL;
+
+info.dma32_window_start =
+tceiommu-&amp;gt;tbl-&amp;gt;it_offset &amp;lt;&amp;lt; IOMMU_PAGE_SHIFT;
+info.dma32_window_size =
+tceiommu-&amp;gt;tbl-&amp;gt;it_size &amp;lt;&amp;lt; IOMMU_PAGE_SHIFT;
+
+return copy_to_user((void __user *)arg, &amp;amp;info, minsz);
+
+} else if (cmd == POWERPC_IOMMU_MAP_DMA) {
+struct tce_iommu_dma_map map;
+
+minsz = offsetofend(struct tce_iommu_dma_map, dmaaddr);
+
+if (copy_from_user(&amp;amp;map, (void __user *)arg, minsz))
+return -EFAULT;
+
+if (map.argsz &amp;lt; minsz)
+return -EINVAL;
+
+return tce_dmamap_page(tceiommu-&amp;gt;tbl, map.va, map.dmaaddr);
+
+} else if (cmd == POWERPC_IOMMU_UNMAP_DMA) {
+struct tce_iommu_dma_map unmap;
+
+minsz = offsetofend(struct tce_iommu_dma_map, dmaaddr);
+
+if (copy_from_user(&amp;amp;unmap, (void __user *)arg, minsz))
+return -EFAULT;
+
+if (unmap.argsz &amp;lt; minsz)
+return -EINVAL;
+
+return tce_dmaunmap_page(tceiommu-&amp;gt;tbl, unmap.dmaaddr);
+}
+
+return -ENOTTY;
+}
+
+const struct vfio_iommu_driver_ops tce_iommu_driver_ops = {
+.name= "vfio-iommu-powerpc",
+.owner= THIS_MODULE,
+.open= tce_iommu_open,
+.release= tce_iommu_release,
+.ioctl= tce_iommu_ioctl,
+.attach_group= tce_iommu_attach_group,
+.detach_group= tce_iommu_detach_group,
+};
+
+static int __init tce_iommu_init(void)
+{
+struct pci_dev *pdev = NULL;
+struct iommu_table *tbl = NULL;
+struct iommu_group *grp = NULL;
+int ret = 0;
+
+/* TODO: Do this for all devices, not just for PCI */
+for_each_pci_dev(pdev) {
+
+tbl = get_iommu_table_base(&amp;amp;pdev-&amp;gt;dev);
+if (NULL == tbl) {
+printk("Skipping device %s\n", pdev-&amp;gt;dev.kobj.name);
+continue;
+}
+if (!tbl-&amp;gt;it_group) {
+struct iommu_group *tmp = iommu_group_alloc();
+if (IS_ERR(tmp)) {
+printk("Failed to create new IOMMU group, "
+"ret = %ld\n", PTR_ERR(tmp));
+break;
+}
+tbl-&amp;gt;it_group = tmp;
+iommu_group_set_iommudata(tmp, tbl, NULL);
+}
+
+grp = iommu_group_get(&amp;amp;pdev-&amp;gt;dev);
+if (!grp) {
+ret = iommu_group_add_device(tbl-&amp;gt;it_group, &amp;amp;pdev-&amp;gt;dev);
+if (ret &amp;lt; 0)
+printk("iommu_group_add_device(%s) failed "
+"with %d\n",
+pdev-&amp;gt;dev.kobj.name, ret);
+}
+}
+
+return vfio_register_iommu_driver(&amp;amp;tce_iommu_driver_ops);
+}
+
+static void __exit tce_iommu_cleanup(void)
+{
+vfio_unregister_iommu_driver(&amp;amp;tce_iommu_driver_ops);
+}
+
+module_init(tce_iommu_init);
+module_exit(tce_iommu_cleanup);
+
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+

&lt;/pre&gt;</description>
    <dc:creator>Alexey Kardashevskiy</dc:creator>
    <dc:date>2012-05-24T03:10:03</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91379">
    <title>[PATCH 1/3 - qemu-kvm stable-1.0] Fix conditional build of various x86 specific bits</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91379</link>
    <description>&lt;pre&gt;This adds/modifies ifdefs etc. and moves code to make sure that
x86-specific code doesn't get compiled on non-x86 platforms.
These changes all relate to code that is in the qemu-kvm tree and
not in the qemu tree.

The change from KVM_CAP_IRQCHIP to KVM_IRQCHIP_PIC_MASTER is because
the KVM_CAP_IRQCHIP symbol is defined on all platforms (though the
capability only exists on x86), whereas KVM_IRQCHIP_PIC_MASTER is
only defined on x86.  (If a better symbol exists it could be used
instead.)

Signed-off-by: Benjamin Herrenschmidt &amp;lt;benh&amp;lt; at &amp;gt;kernel.crashing.org&amp;gt;
---

An equivalent of this is already in qemu-kvm master as commit id
20ad1def644494f5055d129961d46b050c0a6158

 Makefile.target |    2 ++
 configure       |    6 ++++--
 hw/i8259.c      |    6 ++++--
 qemu-kvm-x86.c  |   16 ++++++++++++++++
 qemu-kvm.c      |   30 ++++++++++++++----------------
 5 files changed, 40 insertions(+), 20 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 29eaa68..0d0baf4 100644
--- a/Makefile.target
+++ b/Makefile.target
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -80,7 +80,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; endif
 libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 
+ifeq ($(TARGET_BASE_ARCH), i386)
 libobj-$(CONFIG_KVM) += kvm-tpr-opt.o
+endif
 
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
diff --git a/configure b/configure
index 4b7faec..79a49a9 100755
--- a/configure
+++ b/configure
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -3579,8 +3579,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; case "$target_arch2" in
       if test $kvm_cap_pit = "yes" ; then
         echo "CONFIG_KVM_PIT=y" &amp;gt;&amp;gt; $config_target_mak
       fi
-      if test $kvm_cap_device_assignment = "yes" ; then
-        echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" &amp;gt;&amp;gt; $config_target_mak
+      if test "$cpu" = "i386" -o "$cpu" = "x86_64" ; then
+        if test $kvm_cap_device_assignment = "yes" ; then
+          echo "CONFIG_KVM_DEVICE_ASSIGNMENT=y" &amp;gt;&amp;gt; $config_target_mak
+        fi
       fi
     fi
 esac
diff --git a/hw/i8259.c b/hw/i8259.c
index a9ea9c9..c5841c0 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -635,7 +635,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void pic_register(void)
 
 static void kvm_kernel_pic_save_to_user(PicState *s)
 {
-#ifdef KVM_CAP_IRQCHIP
+#ifdef KVM_IRQCHIP_PIC_MASTER
     struct kvm_irqchip chip;
     struct kvm_pic_state *kpic;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -666,7 +666,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void kvm_kernel_pic_save_to_user(PicState *s)
 
 static int kvm_kernel_pic_load_from_user(PicState *s)
 {
-#ifdef KVM_CAP_IRQCHIP
+#ifdef KVM_IRQCHIP_PIC_MASTER
     struct kvm_irqchip chip;
     struct kvm_pic_state *kpic;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -701,8 +701,10 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void kvm_i8259_set_irq(void *opaque, int irq, int level)
 {
     int pic_ret;
     if (kvm_set_irq(irq, level, &amp;amp;pic_ret)) {
+#ifdef KVM_IRQCHIP_PIC_MASTER
         if (pic_ret != 0)
             apic_set_irq_delivered();
+#endif
         return;
     }
 }
diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index a7981b1..f1db968 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -23,6 +23,22 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt;
 #include "kvm.h"
 #include "hw/apic.h"
 
+int kvm_reinject_control(KVMState *s, int pit_reinject)
+{
+#ifdef KVM_CAP_REINJECT_CONTROL
+    int r;
+    struct kvm_reinject_control control;
+
+    control.pit_reinject = pit_reinject;
+
+    r = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_REINJECT_CONTROL);
+    if (r &amp;gt; 0) {
+        return kvm_vm_ioctl(s, KVM_REINJECT_CONTROL, &amp;amp;control);
+    }
+#endif
+    return -ENOSYS;
+}
+
 static int kvm_create_pit(KVMState *s)
 {
     int r;
diff --git a/qemu-kvm.c b/qemu-kvm.c
index 8d68545..f37535d 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -222,22 +222,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_deassign_pci_device(KVMState *s,
 }
 #endif
 
-int kvm_reinject_control(KVMState *s, int pit_reinject)
-{
-#ifdef KVM_CAP_REINJECT_CONTROL
-    int r;
-    struct kvm_reinject_control control;
-
-    control.pit_reinject = pit_reinject;
-
-    r = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_REINJECT_CONTROL);
-    if (r &amp;gt; 0) {
-        return kvm_vm_ioctl(s, KVM_REINJECT_CONTROL, &amp;amp;control);
-    }
-#endif
-    return -ENOSYS;
-}
-
 int kvm_has_gsi_routing(void)
 {
     int r = 0;
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -463,6 +447,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_get_irq_route_gsi(void)
     return -ENOSPC;
 }
 
+#ifdef KVM_CAP_IRQ_ROUTING
 static void kvm_msi_routing_entry(struct kvm_irq_routing_entry *e,
                                   KVMMsiMessage *msg)
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -474,9 +459,11 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void kvm_msi_routing_entry(struct kvm_irq_routing_entry *e,
     e-&amp;gt;u.msi.address_hi = msg-&amp;gt;addr_hi;
     e-&amp;gt;u.msi.data = msg-&amp;gt;data;
 }
+#endif
 
 int kvm_msi_message_add(KVMMsiMessage *msg)
 {
+#ifdef KVM_CAP_IRQ_ROUTING
     struct kvm_irq_routing_entry e;
     int ret;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -488,18 +475,26 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_msi_message_add(KVMMsiMessage *msg)
 
     kvm_msi_routing_entry(&amp;amp;e, msg);
     return kvm_add_routing_entry(&amp;amp;e);
+#else
+    return -ENOSYS;
+#endif
 }
 
 int kvm_msi_message_del(KVMMsiMessage *msg)
 {
+#ifdef KVM_CAP_IRQ_ROUTING
     struct kvm_irq_routing_entry e;
 
     kvm_msi_routing_entry(&amp;amp;e, msg);
     return kvm_del_routing_entry(&amp;amp;e);
+#else
+    return -ENOSYS;
+#endif
 }
 
 int kvm_msi_message_update(KVMMsiMessage *old, KVMMsiMessage *new)
 {
+#ifdef KVM_CAP_IRQ_ROUTING
     struct kvm_irq_routing_entry e1, e2;
     int ret;
 
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -517,6 +512,9 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; int kvm_msi_message_update(KVMMsiMessage *old, KVMMsiMessage *new)
     }
 
     return 1;
+#else
+    return -ENOSYS;
+#endif
 }
 
 


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Benjamin Herrenschmidt</dc:creator>
    <dc:date>2012-05-24T02:14:50</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91378">
    <title>[PATCH 3/3 - qemu-kvm stable-1.0] Fix kVM_GET_ONE_REG interface</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91378</link>
    <description>&lt;pre&gt;Qemu-1.0 included some code to use a new get/set one register interface
to KVM which unfortunately hadn't settled, and in the end the code that
went into the kernel provides a different interface.  This updates qemu
to use the new interface.

Since the 3.3 kernel doesn't provide this interface, in either the new
or the old form, this removes the check that caused qemu to bail out
if the ioctl returns an error.  In fact we don't even print a message,
since it got printed once per vcpu, which gets a bit tedious with more
than a few vcpus.

Signed-off-by: Benjamin Herrenschmidt &amp;lt;benh&amp;lt; at &amp;gt;kernel.crashing.org&amp;gt;
---

This is unnecessary in qemu-master and the main qemu as both have already
been updated with the correct interfaces.

 linux-headers/asm-powerpc/kvm.h |    2 +-
 linux-headers/linux/kvm.h       |   35 +++++++++++++++++++----------------
 target-ppc/kvm.c                |   12 ++++++++----
 3 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kvm.h
index fb3fddc..dea2156 100644
--- a/linux-headers/asm-powerpc/kvm.h
+++ b/linux-headers/asm-powerpc/kvm.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -327,6 +327,6 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct kvm_book3e_206_tlb_params {
 __u32 reserved[8];
 };
 
-#define KVM_ONE_REG_PPC_HIORKVM_ONE_REG_PPC | 0x100
+#define KVM_REG_PPC_HIOR(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)
 
 #endif /* __LINUX_KVM_POWERPC_H */
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index a8761d3..8c33a57 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -654,30 +654,33 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct kvm_dirty_tlb {
 
 /* Available with KVM_CAP_ONE_REG */
 
-#define KVM_ONE_REG_GENERIC0x0000000000000000ULL
+#define KVM_REG_ARCH_MASK0xff00000000000000ULL
+#define KVM_REG_GENERIC0x0000000000000000ULL
 
 /*
  * Architecture specific registers are to be defined in arch headers and
  * ORed with the arch identifier.
  */
-#define KVM_ONE_REG_PPC0x1000000000000000ULL
-#define KVM_ONE_REG_X860x2000000000000000ULL
-#define KVM_ONE_REG_IA640x3000000000000000ULL
-#define KVM_ONE_REG_ARM0x4000000000000000ULL
-#define KVM_ONE_REG_S3900x5000000000000000ULL
+#define KVM_REG_PPC0x1000000000000000ULL
+#define KVM_REG_X860x2000000000000000ULL
+#define KVM_REG_IA640x3000000000000000ULL
+#define KVM_REG_ARM0x4000000000000000ULL
+#define KVM_REG_S3900x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT52
+#define KVM_REG_SIZE_MASK0x00f0000000000000ULL
+#define KVM_REG_SIZE_U80x0000000000000000ULL
+#define KVM_REG_SIZE_U160x0010000000000000ULL
+#define KVM_REG_SIZE_U320x0020000000000000ULL
+#define KVM_REG_SIZE_U640x0030000000000000ULL
+#define KVM_REG_SIZE_U1280x0040000000000000ULL
+#define KVM_REG_SIZE_U2560x0050000000000000ULL
+#define KVM_REG_SIZE_U5120x0060000000000000ULL
+#define KVM_REG_SIZE_U10240x0070000000000000ULL
 
 struct kvm_one_reg {
 __u64 id;
-union {
-__u8 reg8;
-__u16 reg16;
-__u32 reg32;
-__u64 reg64;
-__u8 reg128[16];
-__u8 reg256[32];
-__u8 reg512[64];
-__u8 reg1024[128];
-} u;
+__u64 addr;
 };
 
 /*
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 0410901..f7c986c 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -740,6 +740,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void kvmppc_set_papr(CPUState *env)
     struct kvm_one_reg reg = {};
     struct kvm_sregs sregs = {};
     int ret;
+    uint64_t hior = env-&amp;gt;spr[SPR_HIOR];
 
     cap.cap = KVM_CAP_PPC_PAPR;
     ret = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &amp;amp;cap);
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -755,11 +756,14 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; void kvmppc_set_papr(CPUState *env)
      *     Once we have qdev CPUs, move HIOR to a qdev property and
      *     remove this chunk.
      */
-    reg.id = KVM_ONE_REG_PPC_HIOR;
-    reg.u.reg64 = env-&amp;gt;spr[SPR_HIOR];
+    reg.id = KVM_REG_PPC_HIOR;
+    reg.addr = (uintptr_t)&amp;amp;hior;
     ret = kvm_vcpu_ioctl(env, KVM_SET_ONE_REG, &amp;amp;reg);
-    if (ret) {
-        goto fail;
+    if (ret &amp;amp;&amp;amp; 0) {
+        fprintf(stderr, "Couldn't set HIOR. Maybe you're running an old \n"
+                        "kernel with support for HV KVM but no PAPR PR \n"
+                        "KVM in which case things will work. If they don't \n"
+                        "please update your host kernel!\n");
     }
 
     /* Set SDR1 so kernel space finds the HTAB */


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Benjamin Herrenschmidt</dc:creator>
    <dc:date>2012-05-24T02:15:36</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91377">
    <title>[PATCH 2/3 - qemu-kvm stable-1.0] Allow i8259 to build without i8254</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91377</link>
    <description>&lt;pre&gt;This allows the i8259 emulation to be compiled without the i8254
emulation.

Currently the i8259 emulation code references some variables defined
in i8254.c for the "time-drift fix".  This moves the definitions from
i8254.c to i8259.c so that i8259.c becomes independent of i8254.c.

Signed-off-by: Benjamin Herrenschmidt &amp;lt;benh&amp;lt; at &amp;gt;kernel.crashing.org&amp;gt;
---

This appears to be unnecessary on qemu-kvm master or the main qemu

 hw/i8254.c |    3 ++-
 hw/i8259.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/i8254.c b/hw/i8254.c
index 019c7b8..878a47b 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -348,7 +348,8 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static uint32_t pit_ioport_read(void *opaque, uint32_t addr)
 }
 
 /* global counters for time-drift fix */
-int64_t timer_acks=0, timer_interrupts=0, timer_ints_to_push=0;
+extern int64_t timer_acks, timer_ints_to_push;
+int64_t timer_interrupts=0;
 
 extern int time_drift_fix;
 
diff --git a/hw/i8259.c b/hw/i8259.c
index c5841c0..f33a25d 100644
--- a/hw/i8259.c
+++ b/hw/i8259.c
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -211,7 +211,7 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; static void pic_intack(PicState *s, int irq)
 }
 
 extern int time_drift_fix;
-extern int64_t timer_acks, timer_ints_to_push;
+int64_t timer_acks=0, timer_ints_to_push=0;
 
 int pic_read_irq(PicState *s)
 {


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Benjamin Herrenschmidt</dc:creator>
    <dc:date>2012-05-24T02:15:10</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91365">
    <title>[PATCH] kvm: document lapic regs field</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91365</link>
    <description>&lt;pre&gt;The logic in find_highest_vector looks
strange until you realize the reason for the
weird memory layout, which is because this is
what the CPU microcode expects.

Add a comment so this stops tripping people up.

Signed-off-by: Michael S. Tsirkin &amp;lt;mst&amp;lt; at &amp;gt;redhat.com&amp;gt;
---
 arch/x86/kvm/lapic.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 41c62c7..1d1ec08 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
&amp;lt; at &amp;gt;&amp;lt; at &amp;gt; -15,6 +15,11 &amp;lt; at &amp;gt;&amp;lt; at &amp;gt; struct kvm_lapic {
 bool irr_pending;
 s16 isr_count;
 int isr_cache;
+/**
+ * APIC register page.  The layout matches the register layout seen by
+ * the guest 1:1, because it is accessed by the vmx microcode.
+ * Note: Only one register, the TPR, is used by the microcode.
+ */
 void *regs;
 gpa_t vapic_addr;
 struct page *vapic_page;
&lt;/pre&gt;</description>
    <dc:creator>Michael S. Tsirkin</dc:creator>
    <dc:date>2012-05-23T16:16:14</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91332">
    <title>[PATCH 0/2] improve speed of "rep ins" emulation</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91332</link>
    <description>&lt;pre&gt;With this patches loading 100M initrd takes ~10s instead of ~40s without.

Gleb Natapov (2):
  Provide userspace IO exit completion callback.
  Provide fast path for "rep ins" emulation if possible.

 arch/x86/include/asm/kvm_host.h |    6 ++
 arch/x86/kvm/svm.c              |   20 +++-
 arch/x86/kvm/vmx.c              |   25 ++++--
 arch/x86/kvm/x86.c              |  187 +++++++++++++++++++++++++++++++--------
 4 files changed, 189 insertions(+), 49 deletions(-)

&lt;/pre&gt;</description>
    <dc:creator>Gleb Natapov</dc:creator>
    <dc:date>2012-05-23T14:08:13</dc:date>
  </item>
  <item rdf:about="http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91329">
    <title>Is kvm-guest-drivers-linux.git still live? Is virtio-serial included?</title>
    <link>http://comments.gmane.org/gmane.comp.emulators.kvm.devel/91329</link>
    <description>&lt;pre&gt;Hi,
To support linux guests with old kernel version, vitio driver backport
is needed. But I cannot find kvm-guest-drivers-linux.git now.
From linux distributions' virtio backport versions, such as
virtio-0.1-18.el3.src.rpm for RHEl3 hat and
novell-virtio-drivers-2.6.27-sle10sp3.iso for SLES 10 sp3, virtio-serial
driver is not included.
Any advice is welcome.
Thanks in advance.

Regards,
Hongyong

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo&amp;lt; at &amp;gt;vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

&lt;/pre&gt;</description>
    <dc:creator>Zang Hongyong</dc:creator>
    <dc:date>2012-05-23T12:03:55</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.emulators.kvm.devel">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.emulators.kvm.devel</link>
  </textinput>
</rdf:RDF>

