Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-04 Thread Pekka Enberg
Hi Sasha,

On Thu, Aug 2, 2012 at 5:29 PM, Sasha Levin  wrote:
> Use the new KVM_SIGNAL_MSI ioctl to inject interrupts directly.
>
> We still create GSIs and keep them for two reasons:
>
>  - They're required by virtio-* devices.
>  - There's not much overhead since we just create them when starting the
> guest, they don't use anything when the guest is running.
>
> Signed-off-by: Sasha Levin 

This patch makes 'make check' hang for me. Full boot log below:

  # lkvm run -k ../../arch/x86/boot/bzImage -m 448 -c 4 --name guest-27916

Decompressing Linux... Parsing ELF... done.
Booting the kernel.
[0.00] Initializing cgroup subsys cpuset
[0.00] Initializing cgroup subsys cpu
[0.00] Linux version 3.5.0+ (penberg@tux) (gcc version 4.6.3
20120306 (Red Hat 4.6.3-2) (GCC) ) #22 SMP Sat Aug 4 12:10:59 EEST
2012
[0.00] Command line: noapic noacpi pci=conf1 reboot=k panic=1
i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 console=ttyS0
earlyprintk=serial i8042.noaux=1 init=init root=/dev/vda rw
[0.00] e820: BIOS-provided physical RAM map:
[0.00] BIOS-e820: [mem 0x-0x0009fbff] usable
[0.00] BIOS-e820: [mem 0x0009fc00-0x0009] reserved
[0.00] BIOS-e820: [mem 0x000f-0x000e] reserved
[0.00] BIOS-e820: [mem 0x0010-0x1bff] usable
[0.00] bootconsole [earlyser0] enabled
[0.00] NX (Execute Disable) protection: active
[0.00] DMI not present or invalid.
[0.00] No AGP bridge found
[0.00] e820: last_pfn = 0x1c000 max_arch_pfn = 0x4
[0.00] x86 PAT enabled: cpu 0, old 0x70106, new 0x7010600070106
[0.00] CPU MTRRs all blank - virtualized system.
[0.00] found SMP MP-table at [mem 0x000f0370-0x000f037f]
mapped at [880f0370]
[0.00] init_memory_mapping: [mem 0x-0x1bff]
[0.00] ACPI Error: A valid RSDP was not found (20120320/tbxfroot-219)
[0.00] No NUMA configuration found
[0.00] Faking a node at [mem 0x-0x1bff]
[0.00] Initmem setup node 0 [mem 0x-0x1bff]
[0.00]   NODE_DATA [mem 0x1bffc000-0x1bff]
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x0001-0x00ff]
[0.00]   DMA32[mem 0x0100-0x]
[0.00]   Normal   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0001-0x0009efff]
[0.00]   node   0: [mem 0x0010-0x1bff]
[0.00] Intel MultiProcessor Specification v1.4
[0.00] MPTABLE: OEM ID: KVMCPU00
[0.00] MPTABLE: Product ID: 0.1
[0.00] MPTABLE: APIC at: 0xFEE0
[0.00] Processor #0 (Bootup-CPU)
[0.00] Processor #1
[0.00] Processor #2
[0.00] Processor #3
[0.00] IOAPIC[0]: apic_id 5, version 17, address 0xfec0, GSI 0-23
[0.00] Processors: 4
[0.00] SMP: Allowing 4 CPUs, 0 hotplug CPUs
[0.00] PM: Registered nosave memory: 0009f000 - 000a
[0.00] PM: Registered nosave memory: 000a - 000f
[0.00] PM: Registered nosave memory: 000f - 000ff000
[0.00] PM: Registered nosave memory: 000ff000 - 0010
[0.00] e820: [mem 0x1c00-0x] available for PCI devices
[0.00] setup_percpu: NR_CPUS:64 nr_cpumask_bits:64
nr_cpu_ids:4 nr_node_ids:1
[0.00] PERCPU: Embedded 26 pages/cpu @88001bc0 s77120
r8192 d21184 u524288
[0.00] Built 1 zonelists in Node order, mobility grouping on.
Total pages: 112777
[0.00] Policy zone: DMA32
[0.00] Kernel command line: noapic noacpi pci=conf1 reboot=k
panic=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 console=ttyS0
earlyprintk=serial i8042.noaux=1 init=init root=/dev/vda rw
[0.00] PID hash table entries: 2048 (order: 2, 16384 bytes)
[0.00] __ex_table already sorted, skipping sort
[0.00] xsave/xrstor: enabled xstate_bv 0x7, cntxt size 0x340
[0.00] Checking aperture...
[0.00] No AGP bridge found
[0.00] Memory: 435020k/458752k available (7228k kernel code,
452k absent, 23280k reserved, 5730k data, 588k init)
[0.00] SLUB: Genslabs=15, HWalign=64, Order=0-3, MinObjects=0,
CPUs=4, Nodes=1
[0.00] Hierarchical RCU implementation.
[0.00] NR_IRQS:4352 nr_irqs:712 16
[0.00] Console: colour *CGA 80x25
[0.00] console [ttyS0] enabled, bootconsole disabled
[0.00] console [ttyS0] enabled, bootconsole disabled
[0.00] Fast TSC calibration using PIT
[0.00] Detected 2691.176 MHz processor.
[0.003002] Calibrating delay loop (skipped), value calculated
using timer frequency.. 5382.35 BogoMIPS (lpj=2691176)
[0.004267] pid_max: default: 32768 minimum: 301
[0.004712] Security Framework i

Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-04 Thread Sasha Levin
On 08/04/2012 11:14 AM, Pekka Enberg wrote:
> Hi Sasha,
> 
> On Thu, Aug 2, 2012 at 5:29 PM, Sasha Levin  wrote:
>> Use the new KVM_SIGNAL_MSI ioctl to inject interrupts directly.
>>
>> We still create GSIs and keep them for two reasons:
>>
>>  - They're required by virtio-* devices.
>>  - There's not much overhead since we just create them when starting the
>> guest, they don't use anything when the guest is running.
>>
>> Signed-off-by: Sasha Levin 
> 
> This patch makes 'make check' hang for me. Full boot log below:

Is your host kernel running 3.5? The new MSI injection ioctl is a new 3.5 
feature.

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


Re: [PATCH 2/2] kvm tools: inject MSI directly without going through a GSI

2012-08-04 Thread Pekka Enberg
On 08/04/2012 11:14 AM, Pekka Enberg wrote:
>> This patch makes 'make check' hang for me. Full boot log below:

On Sat, Aug 4, 2012 at 12:30 PM, Sasha Levin  wrote:
> Is your host kernel running 3.5? The new MSI injection ioctl is a new 3.5 
> feature.

No, it's not running 3.5. We need to support older *host* kernels, though.

Pekka
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [PATCH v2] configure: Don't implicitly hardcode list of KVM architectures

2012-08-04 Thread Andreas Färber
Am 03.08.2012 14:51, schrieb Peter Maydell:
> The code creating the symlink from linux-headers/asm to the
> architecture specific linux-headers/asm-$arch directory was
> implicitly hardcoding a list of KVM supporting architectures.
> Add a default case for the common "Linux architecture name and
> QEMU CPU name match" case, so future architectures will only
> need to add code if they've managed to get mismatched names.
> 
> Signed-off-by: Peter Maydell 
> ---
> v1->v2 changes: conform to same indent rules as surrounding code

Did you send the wrong patch? ;)

Andreas

> 
>  configure |   14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index 9f071b7..eafb81f 100755
> --- a/configure
> +++ b/configure
> @@ -3485,15 +3485,23 @@ if test "$linux" = "yes" ; then
>mkdir -p linux-headers
>case "$cpu" in
>i386|x86_64)
> -symlink "$source_path/linux-headers/asm-x86" linux-headers/asm
> +linux_arch=x86
>  ;;
>ppcemb|ppc|ppc64)
> -symlink "$source_path/linux-headers/asm-powerpc" linux-headers/asm
> +linux_arch=powerpc
>  ;;
>s390x)
> -symlink "$source_path/linux-headers/asm-s390" linux-headers/asm
> +linux_arch=s390
> +;;
> +  *)
> +# For most CPUs the kernel architecture name and QEMU CPU name match.
> +linux_arch="$cpu"
>  ;;
>esac
> +# For non-KVM architectures we will not have asm headers
> +if [ -e "$source_path/linux-headers/asm-$linux_arch" ]; then
> +  symlink "$source_path/linux-headers/asm-$linux_arch" linux-headers/asm
> +fi
>  fi
>  
>  for target in $target_list; do
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [Qemu-devel] [PATCH v4] Fixes related to processing of qemu's -numa option

2012-08-04 Thread Blue Swirl
Thanks, applied.

On Tue, Jul 17, 2012 at 4:31 AM, Chegu Vinod  wrote:
> Changes since v3:
>- using bitmap_set() instead of set_bit() in numa_add() routine.
>- removed call to bitmak_zero() since bitmap_new() also zeros' the bitmap.
>- Rebased to the latest qemu.
>
> Changes since v2:
>- Using "unsigned long *" for the node_cpumask[].
>- Use bitmap_new() instead of g_malloc0() for allocation.
>- Don't rely on "max_cpus" since it may not be initialized
>  before the numa related qemu options are parsed & processed.
>
> Note: Continuing to use a new constant for allocation of
>   the mask (This constant is currently set to 255 since
>   with an 8bit APIC ID VCPUs can range from 0-254 in a
>   guest. The APIC ID 255 (0xFF) is reserved for broadcast).
>
> Changes since v1:
>
>- Use bitmap functions that are already in qemu (instead
>  of cpu_set_t macro's from sched.h)
>- Added a check for endvalue >= max_cpus.
>- Fix to address the round-robbing assignment when
>  cpu's are not explicitly specified.
> ---
>
> v1:
> --
>
> The -numa option to qemu is used to create [fake] numa nodes
> and expose them to the guest OS instance.
>
> There are a couple of issues with the -numa option:
>
> a) Max VCPU's that can be specified for a guest while using
>the qemu's -numa option is 64. Due to a typecasting issue
>when the number of VCPUs is > 32 the VCPUs don't show up
>under the specified [fake] numa nodes.
>
> b) KVM currently has support for 160VCPUs per guest. The
>qemu's -numa option has only support for upto 64VCPUs
>per guest.
> This patch addresses these two issues.
>
> Below are examples of (a) and (b)
>
> a) >32 VCPUs are specified with the -numa option:
>
> /usr/local/bin/qemu-system-x86_64 \
> -enable-kvm \
> 71:01:01 \
> -net tap,ifname=tap0,script=no,downscript=no \
> -vnc :4
>
> ...
> Upstream qemu :
> --
>
> QEMU 1.1.50 monitor - type 'help' for more information
> (qemu) info numa
> 6 nodes
> node 0 cpus: 0 1 2 3 4 5 6 7 8 9 32 33 34 35 36 37 38 39 40 41
> node 0 size: 131072 MB
> node 1 cpus: 10 11 12 13 14 15 16 17 18 19 42 43 44 45 46 47 48 49 50 51
> node 1 size: 131072 MB
> node 2 cpus: 20 21 22 23 24 25 26 27 28 29 52 53 54 55 56 57 58 59
> node 2 size: 131072 MB
> node 3 cpus: 30
> node 3 size: 131072 MB
> node 4 cpus:
> node 4 size: 131072 MB
> node 5 cpus: 31
> node 5 size: 131072 MB
>
> With the patch applied :
> ---
>
> QEMU 1.1.50 monitor - type 'help' for more information
> (qemu) info numa
> 6 nodes
> node 0 cpus: 0 1 2 3 4 5 6 7 8 9
> node 0 size: 131072 MB
> node 1 cpus: 10 11 12 13 14 15 16 17 18 19
> node 1 size: 131072 MB
> node 2 cpus: 20 21 22 23 24 25 26 27 28 29
> node 2 size: 131072 MB
> node 3 cpus: 30 31 32 33 34 35 36 37 38 39
> node 3 size: 131072 MB
> node 4 cpus: 40 41 42 43 44 45 46 47 48 49
> node 4 size: 131072 MB
> node 5 cpus: 50 51 52 53 54 55 56 57 58 59
> node 5 size: 131072 MB
>
> b) >64 VCPUs specified with -numa option:
>
> /usr/local/bin/qemu-system-x86_64 \
> -enable-kvm \
> -cpu 
> Westmere,+rdtscp,+pdpe1gb,+dca,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pclmuldq,+pbe,+tm,+ht,+ss,+acpi,+d-vnc
>  :4
>
> ...
>
> Upstream qemu :
> --
>
> only 63 CPUs in NUMA mode supported.
> only 64 CPUs in NUMA mode supported.
> QEMU 1.1.50 monitor - type 'help' for more information
> (qemu) info numa
> 8 nodes
> node 0 cpus: 6 7 8 9 38 39 40 41 70 71 72 73
> node 0 size: 65536 MB
> node 1 cpus: 10 11 12 13 14 15 16 17 18 19 42 43 44 45 46 47 48 49 50 51 74 
> 75 76 77 78 79
> node 1 size: 65536 MB
> node 2 cpus: 20 21 22 23 24 25 26 27 28 29 52 53 54 55 56 57 58 59 60 61
> node 2 size: 65536 MB
> node 3 cpus: 30 62
> node 3 size: 65536 MB
> node 4 cpus:
> node 4 size: 65536 MB
> node 5 cpus:
> node 5 size: 65536 MB
> node 6 cpus: 31 63
> node 6 size: 65536 MB
> node 7 cpus: 0 1 2 3 4 5 32 33 34 35 36 37 64 65 66 67 68 69
> node 7 size: 65536 MB
>
> With the patch applied :
> ---
>
> QEMU 1.1.50 monitor - type 'help' for more information
> (qemu) info numa
> 8 nodes
> node 0 cpus: 0 1 2 3 4 5 6 7 8 9
> node 0 size: 65536 MB
> node 1 cpus: 10 11 12 13 14 15 16 17 18 19
> node 1 size: 65536 MB
> node 2 cpus: 20 21 22 23 24 25 26 27 28 29
> node 2 size: 65536 MB
> node 3 cpus: 30 31 32 33 34 35 36 37 38 39
> node 3 size: 65536 MB
> node 4 cpus: 40 41 42 43 44 45 46 47 48 49
> node 4 size: 65536 MB
> node 5 cpus: 50 51 52 53 54 55 56 57 58 59
> node 5 size: 65536 MB
> node 6 cpus: 60 61 62 63 64 65 66 67 68 69
> node 6 size: 65536 MB
> node 7 cpus: 70 71 72 73 74 75 76 77 78 79
>
> Signed-off-by: Chegu Vinod , Jim Hull , 
> Craig Hada 
> ---
>  cpus.c   |3 ++-
>  hw/pc.c  |3 ++-
>  sysemu.h |3 ++-
>  vl.c |   43 +--
>  4 files changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index b182b3d..acccd08 100

Re: [PATCH v3 4/8] KVM-HV: Add VCPU running/pre-empted state for guest

2012-08-04 Thread Nikunj A Dadhania
On Fri, 3 Aug 2012 14:31:22 -0300, Marcelo Tosatti  wrote:
> On Fri, Aug 03, 2012 at 11:25:44AM +0530, Nikunj A Dadhania wrote:
> > On Thu, 2 Aug 2012 16:56:28 -0300, Marcelo Tosatti  
> > wrote:
> > > >  
> > > > +   case MSR_KVM_VCPU_STATE:
> > > > +   vcpu->arch.v_state.vs_page = gfn_to_page(vcpu->kvm, 
> > > > data >> PAGE_SHIFT);
> > > > +   vcpu->arch.v_state.vs_offset = data & ~(PAGE_MASK | 
> > > > KVM_MSR_ENABLED);
> > > 
> > > Assign vs_offset after success.
> > > 
> > > > +
> > > > +   if (is_error_page(vcpu->arch.v_state.vs_page)) {
> > > > +   kvm_release_page_clean(vcpu->arch.time_page);
> > > > +   vcpu->arch.v_state.vs_page = NULL;
> > > > +   pr_info("KVM: VCPU_STATE - Unable to pin the 
> > > > page\n");
> > > 
> > > Missing break or return;
> > > 
> > > > +   }
> > > > +   vcpu->arch.v_state.msr_val = data;
> > > > +   break;
> > > > +
> > > > case MSR_IA32_MCG_CTL:
> > > 
> > > Please verify this code carefully again.
> > > 
> > > Also leaking the page reference.
> > > 
> > > > vcpu->arch.apf.msr_val = 0;
> > > > vcpu->arch.st.msr_val = 0;
> > > > +   vcpu->arch.v_state.msr_val = 0;
> > > 
> > > Add a newline and comment (or even better a new helper).
> > > >  
> > > > kvmclock_reset(vcpu);
> > > 
> > 
> > How about something like the below. I have tried to look at time_page
> > for reference:
> > 
> > 
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index 580abcf..c82cc12 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -1604,6 +1604,16 @@ static void kvm_clear_vcpu_state(struct kvm_vcpu 
> > *vcpu)
> > kunmap_atomic(kaddr);
> >  }
> >  
> > +static void kvm_vcpu_state_reset(struct kvm_vcpu *vcpu)
> > +{
> > +   vcpu->arch.v_state.msr_val = 0;
> > +   vcpu->arch.v_state.vs_offset = 0;
> > +   if (vcpu->arch.v_state.vs_page) {
> > +   kvm_release_page_dirty(vcpu->arch.v_state.vs_page);
> > +   vcpu->arch.v_state.vs_page = NULL;
> > +   }
> > +}
> > +
> >  int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
> >  {
> > bool pr = false;
> > @@ -1724,14 +1734,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 
> > msr, u64 data)
> > break;
> >  
> > case MSR_KVM_VCPU_STATE:
> > +   kvm_vcpu_state_reset(vcpu);
> > +
> > vcpu->arch.v_state.vs_page = gfn_to_page(vcpu->kvm, data >> 
> > PAGE_SHIFT);
> > -   vcpu->arch.v_state.vs_offset = data & ~(PAGE_MASK | 
> > KVM_MSR_ENABLED);
> 
> Should also fail if its not enabled (KVM_MSR_ENABLED bit).
> 
> What is the point of having non-NULL vs_page pointer if KVM_MSR_ENABLED
> bit is not set?
> 
Yes, will do that.

> The rest is fine, thanks.
> 

Thanks
Nikunj

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