Re: Bug with KVM: arm64: Avoid setting the upper 32 bits of TCR_EL2 and CPTR_EL2 to 1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marc,

> Am 16.12.2021 um 09:43 schrieb Marc Zyngier <maz@xxxxxxxxxx>:
> 
> Hi Nikolaus,
> 
> On 2021-12-16 06:58, H. Nikolaus Schaller wrote:
>> Hi Catalin,
>>> Am 15.12.2021 um 19:40 schrieb H. Nikolaus Schaller <hns@xxxxxxxxxxxxx>:
>>> this seems to break build of 5.10.y (and maybe earlier) for me:
>>> CALL    scripts/checksyscalls.sh - due to target missing
>>> CALL    scripts/atomic/check-atomics.sh - due to target missing
>>> CHK     include/generated/compile.h
>>> AS      arch/arm64/kvm/hyp/nvhe/hyp-init.nvhe.o - due to target missing
>>> arch/arm64/kvm/hyp/nvhe/hyp-init.S: Assembler messages:
>>> arch/arm64/kvm/hyp/nvhe/hyp-init.S:87: Error: missing ')'
>>> arch/arm64/kvm/hyp/nvhe/hyp-init.S:87: Error: missing ')'
>>> arch/arm64/kvm/hyp/nvhe/hyp-init.S:87: Error: missing ')'This should somehow be fixed so that arch/arm64/include/asm/kvm_arm.h
>>> can be included by older assemblers.
> 
> GCC versions prior to 5.1 are known to miscompile the kernel,
> and the minimal GCC version was bumped in dca5244d2f5b.

> I am surprised this requirement wasn't backported to 5.10-stable,
> as this results in all sorts of terrible bugs that are hard to
> diagnose (see the horror story in the commit message).

Indeed.

My build system checks for existence of scripts/min-tool-version.sh
and if it exists it chooses the right gcc version. If it does not exist
it assumes that gcc 4.9 is still good enough...

> 
> As for the issue you describe, does the following help?

> 
> Thanks,
> 
>        M.
> 
> diff --git a/arch/arm64/include/asm/kvm_arm.h b/arch/arm64/include/asm/kvm_arm.h
> index 01d47c5886dc..d03087308ab5 100644
> --- a/arch/arm64/include/asm/kvm_arm.h
> +++ b/arch/arm64/include/asm/kvm_arm.h
> @@ -91,7 +91,7 @@
> #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H)
> 
> /* TCR_EL2 Registers bits */
> -#define TCR_EL2_RES1		((1U << 31) | (1 << 23))
> +#define TCR_EL2_RES1		((UL(1) << 31) | (UL(1) << 23))
> #define TCR_EL2_TBI		(1 << 20)
> #define TCR_EL2_PS_SHIFT	16
> #define TCR_EL2_PS_MASK		(7 << TCR_EL2_PS_SHIFT)
> 
> -- 
> Jazz is not dead. It just smells funny...


Yes, it does! This can be compiled with gcc 4.9 (resp. binutils).

So IMHO there are 3 different ways to solve it:
a) your fix applied to 5.10.y
b) someone backports scripts/min-tool-version.sh
to allow for dependable automation...
c) we leave 5.10.y unfixed and I just add a special
rule for arm64 to choose a newer gcc (it is no problem to
use 4.9 for other architectures) in my build setup.

BR and thanks,
Nikolaus






[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux