[PATCH v2 0/7] Streamline arithmetic instruction emulation

2013-01-04 Thread Avi Kivity
The current arithmetic instruction emulation is fairly clumsy: after decode, each instruction gets a switch (size), and for every size we fetch the operands, prepare flags, emulate the instruction, then store back the flags and operands. This patchset simplifies things by moving everything into

[PATCH v2 1/7] KVM: x86 emulator: framework for streamlining arithmetic opcodes

2013-01-04 Thread Avi Kivity
We emulate arithmetic opcodes by executing a similar (same operation, different operands) on the cpu. This ensures accurate emulation, esp. wrt. eflags. However, the prologue and epilogue around the opcode is fairly long, consisting of a switch (for the operand size) and code to load and save

[PATCH v2 2/7] KVM: x86 emulator: Support for declaring single operand fastops

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 25 + 1 file changed, 25 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index dd71567..42c53c8 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -24,6

[PATCH v2 4/7] KVM: x86 emulator: mark CMP, CMPS, SCAS, TEST as NoWrite

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index fe113fb..2af0c44 100644 --- a/arch/x86/kvm/emulate.c +++

[PATCH v2 5/7] KVM: x86 emulator: convert NOT, NEG to fastop

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 2af0c44..09dbdc5 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c

[PATCH v2 3/7] KVM: x86 emulator: introduce NoWrite flag

2013-01-04 Thread Avi Kivity
Instead of disabling writeback via OP_NONE, just specify NoWrite. Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 42c53c8..fe113fb 100644 ---

[PATCH v2 7/7] KVM: x86 emulator: convert basic ALU ops to fastop

2013-01-04 Thread Avi Kivity
Opcodes: TEST CMP ADD ADC SUB SBB XOR OR AND Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 112 +++-- 1 file changed, 34 insertions(+), 78

[PATCH v2 6/7] KVM: x86 emulator: add macros for defining 2-operand fastop emulation

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 09dbdc5..9a39689 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -465,6 +465,17 @@

Re: KVM: VMX: fix incorrect cached cpl value with real/v8086 modes

2013-01-04 Thread Gleb Natapov
On Thu, Jan 03, 2013 at 11:19:18AM -0200, Marcelo Tosatti wrote: On Thu, Jan 03, 2013 at 10:11:53AM +0200, Gleb Natapov wrote: FreeBSD 9.1 with -smp 2. I cannot reproduce. I do see boot failure on the next branch with 9.[01] 64 bit -smp 2 here, but it is caused but segment registers been

Re: [PATCH v2 6/7] KVM: x86 emulator: add macros for defining 2-operand fastop emulation

2013-01-04 Thread Avi Kivity
On 01/04/2013 12:47 PM, Avi Kivity wrote: Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 09dbdc5..9a39689 100644 --- a/arch/x86/kvm/emulate.c

[PATCH v4 0/5] KVM: x86: improve reexecute_instruction

2013-01-04 Thread Xiao Guangrong
There are some changes from Gleb's review: - poss the point of target_gfn_is_pt into FNAME(is_self_change_mapping) to let the return value be more clearer - fold some changes of patch 5 into patch 4 - remove vcpu.arch.fault_addr There are some test cases to trigger the bugs which are fixed in

[PATCH v4 1/5] KVM: MMU: fix Dirty bit missed if CR0.WP = 0

2013-01-04 Thread Xiao Guangrong
If the write-fault access is from supervisor and CR0.WP is not set on the vcpu, kvm will fix it by adjusting pte access - it sets the W bit on pte and clears U bit. This is the chance that kvm can change pte access from readonly to writable Unfortunately, the pte access is the access of 'direct'

[PATCH v4 2/5] KVM: MMU: fix infinite fault access retry

2013-01-04 Thread Xiao Guangrong
We have two issues in current code: - if target gfn is used as its page table, guest will refault then kvm will use small page size to map it. We need two #PF to fix its shadow page table - sometimes, say a exception is triggered during vm-exit caused by #PF (see handle_exception() in vmx.c),

[PATCH v4 3/5] KVM: x86: clean up reexecute_instruction

2013-01-04 Thread Xiao Guangrong
Little cleanup for reexecute_instruction, also use gpa_to_gfn in retry_instruction Signed-off-by: Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com --- arch/x86/kvm/x86.c | 13 ++--- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c

[PATCH v4 4/5] KVM: x86: let reexecute_instruction work for tdp

2013-01-04 Thread Xiao Guangrong
Currently, reexecute_instruction refused to retry all instructions. If nested npt is used, the emulation may be caused by shadow page, it can be fixed by dropping the shadow page Signed-off-by: Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com --- arch/x86/kvm/x86.c | 28

[PATCH v4 5/5] KVM: x86: improve reexecute_instruction

2013-01-04 Thread Xiao Guangrong
The current reexecute_instruction can not well detect the failed instruction emulation. It allows guest to retry all the instructions except it accesses on error pfn For example, some cases are nested-write-protect - if the page we want to write is used as PDE but it chains to itself. Under this

[PATCH] emulator: simple ALU tests

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- x86/emulator.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/x86/emulator.c b/x86/emulator.c index c39027a..a128e13 100644 --- a/x86/emulator.c +++ b/x86/emulator.c @@ -863,6 +863,31 @@ static void

[PATCH v3 0/7] Streamline arithmetic instruction emulation

2013-01-04 Thread Avi Kivity
The current arithmetic instruction emulation is fairly clumsy: after decode, each instruction gets a switch (size), and for every size we fetch the operands, prepare flags, emulate the instruction, then store back the flags and operands. This patchset simplifies things by moving everything into

[PATCH v3 1/7] KVM: x86 emulator: framework for streamlining arithmetic opcodes

2013-01-04 Thread Avi Kivity
We emulate arithmetic opcodes by executing a similar (same operation, different operands) on the cpu. This ensures accurate emulation, esp. wrt. eflags. However, the prologue and epilogue around the opcode is fairly long, consisting of a switch (for the operand size) and code to load and save

[PATCH v3 2/7] KVM: x86 emulator: Support for declaring single operand fastops

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 25 + 1 file changed, 25 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index dd71567..42c53c8 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -24,6

[PATCH v3 3/7] KVM: x86 emulator: introduce NoWrite flag

2013-01-04 Thread Avi Kivity
Instead of disabling writeback via OP_NONE, just specify NoWrite. Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 4 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 42c53c8..fe113fb 100644 ---

[PATCH v3 4/7] KVM: x86 emulator: mark CMP, CMPS, SCAS, TEST as NoWrite

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 20 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index fe113fb..2af0c44 100644 --- a/arch/x86/kvm/emulate.c +++

[PATCH v3 5/7] KVM: x86 emulator: convert NOT, NEG to fastop

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 2af0c44..09dbdc5 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c

[PATCH v3 6/7] KVM: x86 emulator: add macros for defining 2-operand fastop emulation

2013-01-04 Thread Avi Kivity
Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 09dbdc5..3b5d4dd 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -465,6 +465,17 @@

[PATCH v3 7/7] KVM: x86 emulator: convert basic ALU ops to fastop

2013-01-04 Thread Avi Kivity
Opcodes: TEST CMP ADD ADC SUB SBB XOR OR AND Signed-off-by: Avi Kivity avi.kiv...@gmail.com --- arch/x86/kvm/emulate.c | 112 +++-- 1 file changed, 34 insertions(+), 78

[PATCH 2/2] target-i386: Disable kvm_mmu_op by default on pc-1.4

2013-01-04 Thread Eduardo Habkost
The kvm_mmu_op feature was removed from the kernel since v3.3 (released in March 2012), it was marked for removal since January 2011 and it's slower than shadow or hardware assisted paging (see kernel commit fb92045843). It doesn't make sense to keep it enabled by default. Also, keeping it

[PATCH 0/2] Disable kvm_mmu_op by default on pc-1.4

2013-01-04 Thread Eduardo Habkost
The kvm_mmu_op feature was removed from the kernel since v3.3 (released in March 2012), it was marked for removal since January 2011 and it's slower than shadow or hardware assisted paging (see kernel commit fb92045843). It doesn't make sense to keep it enabled by default. Also, keeping it

[PATCH 3/9] target-i386: check/enforce: Fix CPUID leaf numbers on error messages

2013-01-04 Thread Eduardo Habkost
The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x8000, but there were references to 0 and 0x8000 in the table at kvm_check_features_against_host(). This changes the model_features_t struct to

[PATCH 8/9] target-i386: Call kvm_check_features_against_host() only if CONFIG_KVM is set

2013-01-04 Thread Eduardo Habkost
This will be necessary once kvm_check_features_against_host() starts using KVM-specific definitions (so it won't compile anymore if CONFIG_KVM is not set). Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- target-i386/cpu.c | 4 1 file changed, 4 insertions(+) diff --git

[PATCH 0/9] target-i386: make enforce flag work as it should

2013-01-04 Thread Eduardo Habkost
This changes the -cpu check/enforce code to work as it should: it will check every single CPUID bit to make sure it is supported by the host. The changes are a bit intrusive, but: - The longer we take to make enforce strict as it should (and make libvirt finally use it), more users will have

[PATCH 9/9] target-i386: check/enforce: Check all feature words

2013-01-04 Thread Eduardo Habkost
This adds the following feature words to the list of flags to be checked by kvm_check_features_against_host(): - cpuid_7_0_ebx_features - ext4_features - kvm_features - svm_features This will ensure the enforce flag works as it should: it won't allow QEMU to be started unless every flag that

[PATCH 2/9] target-i386: kvm: Enable all supported KVM features for -cpu host

2013-01-04 Thread Eduardo Habkost
When using -cpu host, we don't need to use the kvm_default_features variable, as the user is explicitly asking QEMU to enable all feature supported by the host. This changes the kvm_cpu_fill_host() code to use GET_SUPPORTED_CPUID to initialize the kvm_features field, so we get all host KVM

[PATCH 5/9] target-i386: check/enforce: Check all CPUID.80000001H.EDX bits

2013-01-04 Thread Eduardo Habkost
I have no idea why PPRO_FEATURES was being ignored on the check of the CPUID.8001H.EDX bits. I believe it was a mistake, and it was supposed to be ~(PPRO_FEATURES CPUID_EXT2_AMD_ALIASES) or just ~CPUID_EXT2_AMD_ALIASES, because some time ago kvm_cpu_fill_host() used the CPUID instruction

[PATCH 4/9] target-i386: check/enforce: Do not ignore hypervisor flag

2013-01-04 Thread Eduardo Habkost
We don't need any hack to ignore CPUID_EXT_HYPERVISOR anymore, because kvm_arch_get_supported_cpuid() now set CPUID_EXT_HYPERVISOR properly. So, this shouldn't introduce any behavior change, but it makes the code simpler. Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- My goal is to

[PATCH 6/9] target-i386: check/enforce: Check SVM flag support as well

2013-01-04 Thread Eduardo Habkost
When nested SVM is supported, the kernel returns the SVM flag on GET_SUPPORTED_CPUID[1], so we can check the SVM flag safely on kvm_check_features_against_host(). I don't know why the original code ignored the SVM flag. Maybe it was because kvm_cpu_fill_host() used the CPUID instruction directly

[PATCH 1/9] target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features

2013-01-04 Thread Eduardo Habkost
The existing -cpu host code simply set every bit inside svm_features (initializing it to -1), and that makes it impossible to make the enforce/check options work properly when the user asks for SVM features explicitly in the command-line. So, instead of initializing svm_features to -1, use

[PATCH 7/9] target-i386: check/enforce: Eliminate check_feat field

2013-01-04 Thread Eduardo Habkost
Now that all entries have check_feat=~0 on kvm_check_features_against_host(), we can eliminate check_feat entirely and make the code check all bits. This patch shouldn't introduce any behavior change, as check_feat is set to ~0 on all entries. Signed-off-by: Eduardo Habkost ehabk...@redhat.com

[PATCH 1/2] target-i386: Don't set any KVM flag by default if KVM is disabled

2013-01-04 Thread Eduardo Habkost
This is a cleanup that tries to solve two small issues: - We don't need a separate kvm_pv_eoi_features variable just to keep a constant calculated at compile-time, and this style would require adding a separate variable (that's declared twice because of the CONFIG_KVM ifdef) for each

[PATCH 0/4] KVM: PPC: BookE: Add EPR user space support

2013-01-04 Thread Alexander Graf
The FSL MPIC implementation contains a feature called external proxy facility which allows for interrupts to be acknowledged in the MPIC as soon as a core accepts its pending external interrupt. This patch set implements all the necessary pieces to support this from the kernel space side.

[PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external interrupt though. So we need to prepare the interrupt

[PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3 +++ 1 files changed, 3 insertions(+), 0

[PATCH 3/4] KVM: PPC: BookE: Implement EPR exit

2013-01-04 Thread Alexander Graf
The External Proxy Facility in FSL BookE chips allows the interrupt controller to automatically acknowledge an interrupt as soon as a core gets its pending external interrupt delivered. Today, user space implements the interrupt controller, so we need to check on it during such a cycle. This

[PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart as deprecated. Signed-off-by: Alexander Graf ag...@suse.de --- Documentation/virtual/kvm/api.txt

Re: [PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Scott Wood
On 01/04/2013 11:36:37 AM, Alexander Graf wrote: When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external

Re: [PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Scott Wood
On 01/04/2013 11:36:38 AM, Alexander Graf wrote: The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Scott Wood
On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart as deprecated. QEMU already uses SREGS to

Re: [PATCH 3/4] KVM: PPC: BookE: Implement EPR exit

2013-01-04 Thread Scott Wood
On 01/04/2013 11:36:39 AM, Alexander Graf wrote: diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c index 4ae83f9..363301f 100644 --- a/arch/powerpc/kvm/booke.c +++ b/arch/powerpc/kvm/booke.c @@ -306,7 +306,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu, {

Re: [Qemu-devel] [PATCH 10/12] virtio-net: multiqueue support

2013-01-04 Thread Blue Swirl
On Fri, Jan 4, 2013 at 5:12 AM, Jason Wang jasow...@redhat.com wrote: On 12/29/2012 01:52 AM, Blue Swirl wrote: On Fri, Dec 28, 2012 at 10:32 AM, Jason Wang jasow...@redhat.com wrote: This patch implements both userspace and vhost support for multiple queue virtio-net (VIRTIO_NET_F_MQ). This

Re: [Qemu-devel] [PATCH 1/2] target-i386: Don't set any KVM flag by default if KVM is disabled

2013-01-04 Thread Blue Swirl
On Fri, Jan 4, 2013 at 2:52 PM, Eduardo Habkost ehabk...@redhat.com wrote: This is a cleanup that tries to solve two small issues: - We don't need a separate kvm_pv_eoi_features variable just to keep a constant calculated at compile-time, and this style would require adding a separate

Re: [Qemu-devel] [PATCH 2/2] target-i386: Disable kvm_mmu_op by default on pc-1.4

2013-01-04 Thread Blue Swirl
On Fri, Jan 4, 2013 at 2:52 PM, Eduardo Habkost ehabk...@redhat.com wrote: The kvm_mmu_op feature was removed from the kernel since v3.3 (released in March 2012), it was marked for removal since January 2011 and it's slower than shadow or hardware assisted paging (see kernel commit

Re: [PATCH 0/9] target-i386: make enforce flag work as it should

2013-01-04 Thread Anthony Liguori
Hi, This is an automated message generated from the QEMU Patches. Thank you for submitting this patch. This patch no longer applies to qemu.git. This may have occurred due to: 1) Changes in mainline requiring your patch to be rebased and re-tested. 2) Sending the mail using a tool other

Re: [Qemu-devel] [PATCH 1/2] target-i386: Don't set any KVM flag by default if KVM is disabled

2013-01-04 Thread Eduardo Habkost
On Fri, Jan 04, 2013 at 08:47:07PM +, Blue Swirl wrote: { -kvm_default_features |= kvm_pv_eoi_features; +#ifdef CONFIG_KVM +if (kvm_enabled()) Missing braces, please read CODING_STYLE and use checkpatch.pl to find problems in patches. Sorry (again). I will soon send a new

Re: [Qemu-devel] [PATCH 3/9] target-i386: check/enforce: Fix CPUID leaf numbers on error messages

2013-01-04 Thread Blue Swirl
On Fri, Jan 4, 2013 at 3:37 PM, Eduardo Habkost ehabk...@redhat.com wrote: The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x8000, but there were references to 0 and 0x8000 in the table at

Re: [Qemu-devel] [PATCH 1/2] target-i386: Don't set any KVM flag by default if KVM is disabled

2013-01-04 Thread Eduardo Habkost
On Fri, Jan 04, 2013 at 07:02:17PM -0200, Eduardo Habkost wrote: On Fri, Jan 04, 2013 at 08:47:07PM +, Blue Swirl wrote: { -kvm_default_features |= kvm_pv_eoi_features; +#ifdef CONFIG_KVM +if (kvm_enabled()) Missing braces, please read CODING_STYLE and use

Re: [Qemu-devel] [PATCH 2/2] target-i386: Disable kvm_mmu_op by default on pc-1.4

2013-01-04 Thread Eduardo Habkost
On Fri, Jan 04, 2013 at 08:48:42PM +, Blue Swirl wrote: [...] +/* machine init function for pc-0.14 - pc-1.2 */ static void pc_init_pci(QEMUMachineInitArgs *args) { ram_addr_t ram_size = args-ram_size; @@ -232,12 +233,20 @@ static void pc_init_pci(QEMUMachineInitArgs *args)

Installation of Windows 8 hangs with KVM

2013-01-04 Thread Stefan Pietsch
Hi all, when I run KVM with this command the Windows 8 installation stops with error code 0x005D: kvm -m 1024 -hda win8.img -cdrom windows_8_x86.iso After adding the option -cpu host the installation proceeds to a black screen and hangs. With Virtualbox the installation succeeds. The host

[PATCH qom-cpu 05/11] target-i386: check/enforce: Fix CPUID leaf numbers on error messages

2013-01-04 Thread Eduardo Habkost
The -cpu check/enforce warnings are printing incorrect information about the missing flags. There are no feature flags on CPUID leaves 0 and 0x8000, but there were references to 0 and 0x8000 in the table at kvm_check_features_against_host(). This changes the model_features_t struct to

[PATCH qom-cpu 11/11] target-i386: check/enforce: Check all feature words

2013-01-04 Thread Eduardo Habkost
This adds the following feature words to the list of flags to be checked by kvm_check_features_against_host(): - cpuid_7_0_ebx_features - ext4_features - kvm_features - svm_features This will ensure the enforce flag works as it should: it won't allow QEMU to be started unless every flag that

Re: [PATCH v4 3/5] KVM: x86: clean up reexecute_instruction

2013-01-04 Thread Marcelo Tosatti
On Fri, Jan 04, 2013 at 09:55:40PM +0800, Xiao Guangrong wrote: Little cleanup for reexecute_instruction, also use gpa_to_gfn in retry_instruction Signed-off-by: Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com --- arch/x86/kvm/x86.c | 13 ++--- 1 files changed, 6 insertions(+),

Re: [PATCH v4 5/5] KVM: x86: improve reexecute_instruction

2013-01-04 Thread Marcelo Tosatti
On Fri, Jan 04, 2013 at 09:56:59PM +0800, Xiao Guangrong wrote: The current reexecute_instruction can not well detect the failed instruction emulation. It allows guest to retry all the instructions except it accesses on error pfn For example, some cases are nested-write-protect - if the page

[PATCH qom-cpu 04/11] target-i386: kvm: Enable all supported KVM features for -cpu host

2013-01-04 Thread Eduardo Habkost
When using -cpu host, we don't need to use the kvm_default_features variable, as the user is explicitly asking QEMU to enable all feature supported by the host. This changes the kvm_cpu_fill_host() code to use GET_SUPPORTED_CPUID to initialize the kvm_features field, so we get all host KVM

[PATCH qom-cpu 01/11] target-i386: Don't set any KVM flag by default if KVM is disabled

2013-01-04 Thread Eduardo Habkost
This is a cleanup that tries to solve two small issues: - We don't need a separate kvm_pv_eoi_features variable just to keep a constant calculated at compile-time, and this style would require adding a separate variable (that's declared twice because of the CONFIG_KVM ifdef) for each

[PATCH qom-cpu 03/11] target-i386: kvm: -cpu host: Use GET_SUPPORTED_CPUID for SVM features

2013-01-04 Thread Eduardo Habkost
The existing -cpu host code simply set every bit inside svm_features (initializing it to -1), and that makes it impossible to make the enforce/check options work properly when the user asks for SVM features explicitly in the command-line. So, instead of initializing svm_features to -1, use

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart

[PATCH qom-cpu 10/11] target-i386: Call kvm_check_features_against_host() only if CONFIG_KVM is set

2013-01-04 Thread Eduardo Habkost
This will be necessary once kvm_check_features_against_host() starts using KVM-specific definitions (so it won't compile anymore if CONFIG_KVM is not set). Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- target-i386/cpu.c | 4 1 file changed, 4 insertions(+) diff --git

[PATCH qom-cpu 06/11] target-i386: check/enforce: Do not ignore hypervisor flag

2013-01-04 Thread Eduardo Habkost
We don't need any hack to ignore CPUID_EXT_HYPERVISOR anymore, because kvm_arch_get_supported_cpuid() now set CPUID_EXT_HYPERVISOR properly. So, this shouldn't introduce any behavior change, but it makes the code simpler. Signed-off-by: Eduardo Habkost ehabk...@redhat.com --- My goal is to

[PATCH qom-cpu 00/11] disable-kvm_mmu + -cpu check/enforce fixes (v2)

2013-01-04 Thread Eduardo Habkost
Changes on v2: - Now both the kvm_mmu-disable and -cpu enforce changes are on the same series - Coding style fixes Git tree for reference: git://github.com/ehabkost/qemu-hacks.git cpu-enforce-all.v2 https://github.com/ehabkost/qemu-hacks/tree/cpu-enforce-all.v2 Patches 1-2 disable the

Re: [PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 20:40, Scott Wood wrote: On 01/04/2013 11:36:37 AM, Alexander Graf wrote: When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Scott Wood
On 01/04/2013 04:55:34 PM, Alexander Graf wrote: On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
On 05.01.2013, at 00:03, Scott Wood wrote: On 01/04/2013 04:55:34 PM, Alexander Graf wrote: On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch

Re: [PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 20:50, Scott Wood wrote: On 01/04/2013 11:36:38 AM, Alexander Graf wrote: The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf

[PATCH 0/4] KVM: PPC: BookE: Add EPR user space support v2

2013-01-04 Thread Alexander Graf
The FSL MPIC implementation contains a feature called external proxy facility which allows for interrupts to be acknowledged in the MPIC as soon as a core accepts its pending external interrupt. This patch set implements all the necessary pieces to support this from the kernel space side. v1 -

[PATCH 3/4] KVM: PPC: BookE: Implement EPR exit

2013-01-04 Thread Alexander Graf
The External Proxy Facility in FSL BookE chips allows the interrupt controller to automatically acknowledge an interrupt as soon as a core gets its pending external interrupt delivered. Today, user space implements the interrupt controller, so we need to check on it during such a cycle. This

[PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3 +++ 1 files changed, 3 insertions(+), 0

[PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart as deprecated. Signed-off-by: Alexander Graf ag...@suse.de --- Documentation/virtual/kvm/api.txt

[PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external

[PATCH qom-cpu 07/11] target-i386: check/enforce: Check all CPUID.80000001H.EDX bits

2013-01-04 Thread Eduardo Habkost
I have no idea why PPRO_FEATURES was being ignored on the check of the CPUID.8001H.EDX bits. I believe it was a mistake, and it was supposed to be ~(PPRO_FEATURES CPUID_EXT2_AMD_ALIASES) or just ~CPUID_EXT2_AMD_ALIASES, because some time ago kvm_cpu_fill_host() used the CPUID instruction

[PATCH qom-cpu 09/11] target-i386: check/enforce: Eliminate check_feat field

2013-01-04 Thread Eduardo Habkost
Now that all entries have check_feat=~0 on kvm_check_features_against_host(), we can eliminate check_feat entirely and make the code check all bits. This patch shouldn't introduce any behavior change, as check_feat is set to ~0 on all entries. Signed-off-by: Eduardo Habkost ehabk...@redhat.com

[PATCH qom-cpu 02/11] target-i386: Disable kvm_mmu_op by default on pc-1.4

2013-01-04 Thread Eduardo Habkost
The kvm_mmu_op feature was removed from the kernel since v3.3 (released in March 2012), it was marked for removal since January 2011 and it's slower than shadow or hardware assisted paging (see kernel commit fb92045843). It doesn't make sense to keep it enabled by default. Also, keeping it

[PATCH qom-cpu 08/11] target-i386: check/enforce: Check SVM flag support as well

2013-01-04 Thread Eduardo Habkost
When nested SVM is supported, the kernel returns the SVM flag on GET_SUPPORTED_CPUID[1], so we can check the SVM flag safely on kvm_check_features_against_host(). I don't know why the original code ignored the SVM flag. Maybe it was because kvm_cpu_fill_host() used the CPUID instruction directly

Re: [PATCH v4 3/5] KVM: x86: clean up reexecute_instruction

2013-01-04 Thread Xiao Guangrong
On 01/05/2013 06:21 AM, Marcelo Tosatti wrote: On Fri, Jan 04, 2013 at 09:55:40PM +0800, Xiao Guangrong wrote: Little cleanup for reexecute_instruction, also use gpa_to_gfn in retry_instruction Signed-off-by: Xiao Guangrong xiaoguangr...@linux.vnet.ibm.com --- arch/x86/kvm/x86.c | 13

[PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external interrupt though. So we need to prepare the interrupt

[PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3 +++ 1 files changed, 3 insertions(+), 0

[PATCH 3/4] KVM: PPC: BookE: Implement EPR exit

2013-01-04 Thread Alexander Graf
The External Proxy Facility in FSL BookE chips allows the interrupt controller to automatically acknowledge an interrupt as soon as a core gets its pending external interrupt delivered. Today, user space implements the interrupt controller, so we need to check on it during such a cycle. This

[PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart as deprecated. Signed-off-by: Alexander Graf ag...@suse.de --- Documentation/virtual/kvm/api.txt

Re: [PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Scott Wood
On 01/04/2013 11:36:38 AM, Alexander Graf wrote: The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API and declares its (never implemented) SREGS counterpart

Re: [PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 20:40, Scott Wood wrote: On 01/04/2013 11:36:37 AM, Alexander Graf wrote: When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Scott Wood
On 01/04/2013 04:55:34 PM, Alexander Graf wrote: On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch implements that logic through the ONE_REG API

Re: [PATCH 4/4] KVM: PPC: BookE: Add EPR ONE_REG sync

2013-01-04 Thread Alexander Graf
On 05.01.2013, at 00:03, Scott Wood wrote: On 01/04/2013 04:55:34 PM, Alexander Graf wrote: On 04.01.2013, at 21:08, Scott Wood wrote: On 01/04/2013 11:36:40 AM, Alexander Graf wrote: We need to be able to read and write the contents of the EPR register from user space. This patch

Re: [PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
On 04.01.2013, at 20:50, Scott Wood wrote: On 01/04/2013 11:36:38 AM, Alexander Graf wrote: The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf

[PATCH 0/4] KVM: PPC: BookE: Add EPR user space support v2

2013-01-04 Thread Alexander Graf
The FSL MPIC implementation contains a feature called external proxy facility which allows for interrupts to be acknowledged in the MPIC as soon as a core accepts its pending external interrupt. This patch set implements all the necessary pieces to support this from the kernel space side. v1 -

[PATCH 2/4] KVM: PPC: BookE: Emulate mfspr on EPR

2013-01-04 Thread Alexander Graf
The EPR register is potentially valid for PR KVM as well, so we need to emulate accesses to it. It's only defined for reading, so only handle the mfspr case. Signed-off-by: Alexander Graf ag...@suse.de --- arch/powerpc/kvm/booke_emulate.c |3 +++ 1 files changed, 3 insertions(+), 0

[PATCH 1/4] KVM: PPC: BookE: Allow irq deliveries to inject requests

2013-01-04 Thread Alexander Graf
From: Mihai Caraman mihai.cara...@freescale.com When injecting an interrupt into guest context, we usually don't need to check for requests anymore. At least not until today. With the introduction of EPR, we will have to create a request when the guest has successfully accepted an external

[PATCH 3/4] KVM: PPC: BookE: Implement EPR exit

2013-01-04 Thread Alexander Graf
The External Proxy Facility in FSL BookE chips allows the interrupt controller to automatically acknowledge an interrupt as soon as a core gets its pending external interrupt delivered. Today, user space implements the interrupt controller, so we need to check on it during such a cycle. This