Skip to content

Commit 3ce9bbb

Browse files
author
Marc Zyngier
committed
KVM: arm64: Remove hand-crafted masks for FGT registers
These masks are now useless, and can be removed. Signed-off-by: Marc Zyngier <[email protected]>
1 parent aed34b6 commit 3ce9bbb

File tree

2 files changed

+1
-67
lines changed

2 files changed

+1
-67
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -315,54 +315,7 @@
315315
GENMASK(19, 18) | \
316316
GENMASK(15, 0))
317317

318-
/*
319-
* FGT register definitions
320-
*
321-
* RES0 and polarity masks as of DDI0487J.a, to be updated as needed.
322-
* We're not using the generated masks as they are usually ahead of
323-
* the published ARM ARM, which we use as a reference.
324-
*
325-
* Once we get to a point where the two describe the same thing, we'll
326-
* merge the definitions. One day.
327-
*/
328-
#define __HFGRTR_EL2_RES0 HFGRTR_EL2_RES0
329-
#define __HFGRTR_EL2_MASK GENMASK(49, 0)
330-
#define __HFGRTR_EL2_nMASK ~(__HFGRTR_EL2_RES0 | __HFGRTR_EL2_MASK)
331-
332-
/*
333-
* The HFGWTR bits are a subset of HFGRTR bits. To ensure we don't miss any
334-
* future additions, define __HFGWTR* macros relative to __HFGRTR* ones.
335-
*/
336-
#define __HFGRTR_ONLY_MASK (BIT(46) | BIT(42) | BIT(40) | BIT(28) | \
337-
GENMASK(26, 25) | BIT(21) | BIT(18) | \
338-
GENMASK(15, 14) | GENMASK(10, 9) | BIT(2))
339-
#define __HFGWTR_EL2_RES0 HFGWTR_EL2_RES0
340-
#define __HFGWTR_EL2_MASK (__HFGRTR_EL2_MASK & ~__HFGRTR_ONLY_MASK)
341-
#define __HFGWTR_EL2_nMASK ~(__HFGWTR_EL2_RES0 | __HFGWTR_EL2_MASK)
342-
343-
#define __HFGITR_EL2_RES0 HFGITR_EL2_RES0
344-
#define __HFGITR_EL2_MASK (BIT(62) | BIT(60) | GENMASK(54, 0))
345-
#define __HFGITR_EL2_nMASK ~(__HFGITR_EL2_RES0 | __HFGITR_EL2_MASK)
346-
347-
#define __HDFGRTR_EL2_RES0 HDFGRTR_EL2_RES0
348-
#define __HDFGRTR_EL2_MASK (BIT(63) | GENMASK(58, 50) | GENMASK(48, 43) | \
349-
GENMASK(41, 40) | GENMASK(37, 22) | \
350-
GENMASK(19, 9) | GENMASK(7, 0))
351-
#define __HDFGRTR_EL2_nMASK ~(__HDFGRTR_EL2_RES0 | __HDFGRTR_EL2_MASK)
352-
353-
#define __HDFGWTR_EL2_RES0 HDFGWTR_EL2_RES0
354-
#define __HDFGWTR_EL2_MASK (GENMASK(57, 52) | GENMASK(50, 48) | \
355-
GENMASK(46, 44) | GENMASK(42, 41) | \
356-
GENMASK(37, 35) | GENMASK(33, 31) | \
357-
GENMASK(29, 23) | GENMASK(21, 10) | \
358-
GENMASK(8, 7) | GENMASK(5, 0))
359-
#define __HDFGWTR_EL2_nMASK ~(__HDFGWTR_EL2_RES0 | __HDFGWTR_EL2_MASK)
360-
361-
#define __HAFGRTR_EL2_RES0 HAFGRTR_EL2_RES0
362-
#define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0))
363-
#define __HAFGRTR_EL2_nMASK ~(__HAFGRTR_EL2_RES0 | __HAFGRTR_EL2_MASK)
364-
365-
/* Similar definitions for HCRX_EL2 */
318+
/* Polarity masks for HCRX_EL2 */
366319
#define __HCRX_EL2_RES0 HCRX_EL2_RES0
367320
#define __HCRX_EL2_MASK (BIT(6))
368321
#define __HCRX_EL2_nMASK ~(__HCRX_EL2_RES0 | __HCRX_EL2_MASK)

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,6 @@ static inline void __activate_traps_fpsimd32(struct kvm_vcpu *vcpu)
156156
#define update_fgt_traps(hctxt, vcpu, kvm, reg) \
157157
update_fgt_traps_cs(hctxt, vcpu, kvm, reg, 0, 0)
158158

159-
/*
160-
* Validate the fine grain trap masks.
161-
* Check that the masks do not overlap and that all bits are accounted for.
162-
*/
163-
#define CHECK_FGT_MASKS(reg) \
164-
do { \
165-
BUILD_BUG_ON((__ ## reg ## _MASK) & (__ ## reg ## _nMASK)); \
166-
BUILD_BUG_ON(~((__ ## reg ## _RES0) ^ (__ ## reg ## _MASK) ^ \
167-
(__ ## reg ## _nMASK))); \
168-
} while(0)
169-
170159
static inline bool cpu_has_amu(void)
171160
{
172161
u64 pfr0 = read_sysreg_s(SYS_ID_AA64PFR0_EL1);
@@ -180,14 +169,6 @@ static inline void __activate_traps_hfgxtr(struct kvm_vcpu *vcpu)
180169
struct kvm_cpu_context *hctxt = host_data_ptr(host_ctxt);
181170
struct kvm *kvm = kern_hyp_va(vcpu->kvm);
182171

183-
CHECK_FGT_MASKS(HFGRTR_EL2);
184-
CHECK_FGT_MASKS(HFGWTR_EL2);
185-
CHECK_FGT_MASKS(HFGITR_EL2);
186-
CHECK_FGT_MASKS(HDFGRTR_EL2);
187-
CHECK_FGT_MASKS(HDFGWTR_EL2);
188-
CHECK_FGT_MASKS(HAFGRTR_EL2);
189-
CHECK_FGT_MASKS(HCRX_EL2);
190-
191172
if (!cpus_have_final_cap(ARM64_HAS_FGT))
192173
return;
193174

0 commit comments

Comments
 (0)