[PATCH 1/2] powerpc: Fix definition of PCR bits to work with old binutils

Alexey Kardashevskiy aik at ozlabs.ru
Mon Sep 30 19:56:16 AEST 2019



On 25/09/2019 21:05, Michael Ellerman wrote:
> On Tue, 2019-09-17 at 00:46:04 UTC, Alistair Popple wrote:
>> Commit 388cc6e133132 ("KVM: PPC: Book3S HV: Support POWER6
>> compatibility mode on POWER7") introduced new macros defining the PCR
>> bits. When used from assembly files these definitions lead to build
>> errors using older versions of binutils that don't support the 'ul'
>> suffix. This fixes the build errors by updating the definitions to use
>> the __MASK() macro which selects the appropriate suffix.
>>
>> Signed-off-by: Alistair Popple <alistair at popple.id.au>
> 
> Series applied to powerpc fixes, thanks.
> 
> https://git.kernel.org/powerpc/c/c6fadabb2868f817299ddb338ac15885e25d12d2


It breaks KVM on POWER8's garrison:
===
KVM: CPU 1 seems to be stuck
KVM: CPU 2 seems to be stuck
KVM: CPU 3 seems to be stuck
KVM: CPU 4 seems to be stuck
KVM: CPU 5 seems to be stuck
KVM: CPU 6 seems to be stuck
KVM: CPU 7 seems to be stuck
===
in a loop.


Run as: "taskset -c 0 qemu-system-ppc64 -smp 8,threads=8"


The patch below fixes it and I have no idea why. 0x1ffffffffffffff1 is the PCR after the mask applied to it.



diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 709cf1fd4cf4..9df9865b2e5b 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -406,6 +406,7 @@ static int kvmppc_set_arch_compat(struct kvm_vcpu *vcpu, u32 arch_compat)
         * Also set all reserved PCR bits
         */
        vc->pcr = (host_pcr_bit - guest_pcr_bit) | PCR_MASK;
+       vc->pcr &= 0xffffffffffffff00UL;
        spin_unlock(&vc->lock);

        return 0;
@@ -3413,7 +3414,7 @@ static int kvmhv_load_hv_regs_and_go(struct kvm_vcpu *vcpu, u64 time_limit,
        }

        if (vc->pcr)
-               mtspr(SPRN_PCR, vc->pcr | PCR_MASK);
+               mtspr(SPRN_PCR, vc->pcr);
        mtspr(SPRN_DPDES, vc->dpdes);
        mtspr(SPRN_VTB, vc->vtb);


-- 
Alexey


More information about the Linuxppc-dev mailing list