[PATCH v3 16/23] KVM: s390: arm64: Implement arm sysreg managing infrastructure

Andreas Grapentin gra at linux.ibm.com
Sat Nov 7 06:08:28 PST 2026


On Nov 06 26, Steffen Eiden wrote:
> +/**
> + * _vcpu_read_sys_reg() - read a guest sysreg with easr
> + * @C: vcpu to read from; if loaded, may only be called from its own thread
> + * @R: sysreg id; must be readable by easr; must be compile time constant
> + *
> + *   if SYSREGS_ON_CPU: proceed with flags = 0
> + *   otherwise:         proceed with flags = EASR_FLAG_SA
> + *
> + */
> +#define _vcpu_read_sys_reg(C, R) \
> +	({	BUILD_BUG_ON(!__builtin_constant_p((R))); \
> +		KVM_BUG_ON(vcpu_is_loaded(C) && smp_processor_id() != (C)->cpu, (C)->kvm); \

ah, this slipped through. the condition checked here was supposed to be:

    vcpu_is_loaded(C) && kvm_get_running_vcpu() == (C)

same for _vcpu_write_sys_reg below.

> +		(vcpu_is_loaded(C)) \
> +			? __vcpu_read_sr((C), (R), 0) \
> +			: __vcpu_read_sr((C), (R), EASR_FLAG_SA); })
> +
> +/**
> + * _vcpu_write_sys_reg() - write a guest sysreg with sasr
> + *
> + * @C: vcpu to write to; if loaded, may only be called from its own thread
> + * @V: value to write
> + * @R: sysreg id; must be writable by sasr; must be compile time constant
> +
> + *   if SYSREGS_ON_CPU: proceed with flags = 0
> + *   otherwise:         proceed with flags = SASR_FLAG_INITIALIZED
> + */
> +#define _vcpu_write_sys_reg(C, V, R) \
> +	({	BUILD_BUG_ON(!__builtin_constant_p((R))); \
> +		KVM_BUG_ON(vcpu_is_loaded(C) && smp_processor_id() != (C)->cpu, (C)->kvm); \
> +		(vcpu_is_loaded(C)) \
> +			? __vcpu_write_sr((C), (V), (R), 0) \
> +			: __vcpu_write_sr((C), (V), (R), SASR_FLAG_INITIALIZED); })
> +
> -- 
> 2.56.0



More information about the linux-arm-kernel mailing list