FROMGIT: arm64: sve: Provide a conditional update accessor for ZCR_ELx
A common pattern is to conditionally update ZCR_ELx in order to avoid the "self-synchronizing" effect that writing to this register has. Let's provide an accessor that does exactly this. Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> (cherry picked from commit 71ce1ae56e4d43a0c568e2d4bfb154cd15306a82 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next) Signed-off-by: Will Deacon <willdeacon@google.com> Bug: 178098380 Test: atest VirtualizationHostTestCases on an EL2-enabled device Change-Id: I50af5ed0a57182d038f26c12a6ca9e733ac97ba4
This commit is contained in:

committed by
Quentin Perret

parent
ac5f5708bb
commit
57171b3636
@@ -130,6 +130,15 @@ static inline void sve_user_enable(void)
|
|||||||
sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN);
|
sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define sve_cond_update_zcr_vq(val, reg) \
|
||||||
|
do { \
|
||||||
|
u64 __zcr = read_sysreg_s((reg)); \
|
||||||
|
u64 __new = __zcr & ~ZCR_ELx_LEN_MASK; \
|
||||||
|
__new |= (val) & ZCR_ELx_LEN_MASK; \
|
||||||
|
if (__zcr != __new) \
|
||||||
|
write_sysreg_s(__new, (reg)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Probing and setup functions.
|
* Probing and setup functions.
|
||||||
* Calls to these functions must be serialised with one another.
|
* Calls to these functions must be serialised with one another.
|
||||||
|
Reference in New Issue
Block a user