Re: KVM: pvmmu breakage with gcc 4.3.0

Anthony Liguori
2008-06-26T03:11:34Z

[-- Attachment #1: Type: text/plain, Size: 1269 bytes --]

Marcelo Tosatti wrote:
> Some pvmmu functions store their commands on stack, and newer GCC
> versions conclude that these commands are unused.
>
> So stick an inline asm statement to convince the compiler otherwise.
>

I think a better fix is to add a "memory " clobber to the hypercalls.
This isn't really a GCC bug since it doesn't realize that hypercalls can
touch memory.

See the attached patch.

Avi: please push this for 2.6.26 if possible.

Regards,

Anthony Liguori

> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
>
> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
> index 8b7a3cf..c892752 100644
> --- a/arch/x86/kernel/kvm.c
> +++ b/arch/x86/kernel/kvm.c
> @@ -55,6 +55,12 @@ static void kvm_mmu_op(void *buffer, unsigned len)
> int r;
> unsigned long a1, a2;
>
> + /*
> + * GCC 4.3.0 concludes that on-stack kvm_mmu_op* is unused and
> + * optimizes its initialization away.
> + */
> + asm ("" : : "p" (buffer));
> +
> do {
> a1 = __pa(buffer);
> a2 = 0; /* on i386 __pa() always returns <4G */
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

[-- Attachment #2: hypercall-memory-clobber.patch --]
[-- Type: application/mbox, Size: 1866 bytes --]