Skip to content

Commit fc04838

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Update and fix FGT register masks
New trap bits have been defined since the latest update to this patch. Moreover, the existing definitions of some of the mask and the RES0 bits overlap, which could be wrong, confusing, or both. Update the bits based on DDI0601 2023-09, and ensure that the existing bits are consistent. Subsequent patches will use the generated RES0 fields instead of specifying them manually. This patch keeps the manual encoding of the bits to make it easier to review the series. Fixes: 0fd7686 ("KVM: arm64: Add nPIR{E0}_EL1 to HFG traps") Signed-off-by: Fuad Tabba <tabba@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20231214100158.2305400-11-tabba@google.com
1 parent 676f482 commit fc04838

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

arch/arm64/include/asm/kvm_arm.h

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,40 +344,49 @@
344344
* Once we get to a point where the two describe the same thing, we'll
345345
* merge the definitions. One day.
346346
*/
347-
#define __HFGRTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51))
347+
#define __HFGRTR_EL2_RES0 BIT(51)
348348
#define __HFGRTR_EL2_MASK GENMASK(49, 0)
349-
#define __HFGRTR_EL2_nMASK (GENMASK(58, 57) | GENMASK(55, 54) | BIT(50))
349+
#define __HFGRTR_EL2_nMASK (GENMASK(63, 52) | BIT(50))
350350

351-
#define __HFGWTR_EL2_RES0 (GENMASK(63, 56) | GENMASK(53, 51) | \
352-
BIT(46) | BIT(42) | BIT(40) | BIT(28) | \
353-
GENMASK(26, 25) | BIT(21) | BIT(18) | \
351+
#define __HFGWTR_EL2_RES0 (BIT(51) | BIT(46) | BIT(42) | BIT(40) | \
352+
BIT(28) | GENMASK(26, 25) | BIT(21) | BIT(18) | \
354353
GENMASK(15, 14) | GENMASK(10, 9) | BIT(2))
355-
#define __HFGWTR_EL2_MASK GENMASK(49, 0)
356-
#define __HFGWTR_EL2_nMASK (GENMASK(58, 57) | GENMASK(55, 54) | BIT(50))
354+
#define __HFGWTR_EL2_MASK (GENMASK(49, 47) | GENMASK(45, 43) | \
355+
BIT(41) | GENMASK(39, 29) | BIT(27) | \
356+
GENMASK(24, 22) | GENMASK(20, 19) | \
357+
GENMASK(17, 16) | GENMASK(13, 11) | \
358+
GENMASK(8, 3) | GENMASK(1, 0))
359+
#define __HFGWTR_EL2_nMASK (GENMASK(63, 52) | BIT(50))
357360

358-
#define __HFGITR_EL2_RES0 GENMASK(63, 57)
359-
#define __HFGITR_EL2_MASK GENMASK(54, 0)
360-
#define __HFGITR_EL2_nMASK GENMASK(56, 55)
361+
#define __HFGITR_EL2_RES0 (BIT(63) | BIT(61))
362+
#define __HFGITR_EL2_MASK (BIT(62) | BIT(60) | GENMASK(54, 0))
363+
#define __HFGITR_EL2_nMASK GENMASK(59, 55)
361364

362365
#define __HDFGRTR_EL2_RES0 (BIT(49) | BIT(42) | GENMASK(39, 38) | \
363366
GENMASK(21, 20) | BIT(8))
364-
#define __HDFGRTR_EL2_MASK ~__HDFGRTR_EL2_nMASK
367+
#define __HDFGRTR_EL2_MASK (BIT(63) | GENMASK(58, 50) | GENMASK(48, 43) | \
368+
GENMASK(41, 40) | GENMASK(37, 22) | \
369+
GENMASK(19, 9) | GENMASK(7, 0))
365370
#define __HDFGRTR_EL2_nMASK GENMASK(62, 59)
366371

367372
#define __HDFGWTR_EL2_RES0 (BIT(63) | GENMASK(59, 58) | BIT(51) | BIT(47) | \
368373
BIT(43) | GENMASK(40, 38) | BIT(34) | BIT(30) | \
369374
BIT(22) | BIT(9) | BIT(6))
370-
#define __HDFGWTR_EL2_MASK ~__HDFGWTR_EL2_nMASK
375+
#define __HDFGWTR_EL2_MASK (GENMASK(57, 52) | GENMASK(50, 48) | \
376+
GENMASK(46, 44) | GENMASK(42, 41) | \
377+
GENMASK(37, 35) | GENMASK(33, 31) | \
378+
GENMASK(29, 23) | GENMASK(21, 10) | \
379+
GENMASK(8, 7) | GENMASK(5, 0))
371380
#define __HDFGWTR_EL2_nMASK GENMASK(62, 60)
372381

373382
#define __HAFGRTR_EL2_RES0 (GENMASK(63, 50) | GENMASK(16, 5))
374383
#define __HAFGRTR_EL2_MASK (GENMASK(49, 17) | GENMASK(4, 0))
375384
#define __HAFGRTR_EL2_nMASK 0UL
376385

377386
/* Similar definitions for HCRX_EL2 */
378-
#define __HCRX_EL2_RES0 (GENMASK(63, 16) | GENMASK(13, 12))
379-
#define __HCRX_EL2_MASK (0)
380-
#define __HCRX_EL2_nMASK (GENMASK(15, 14) | GENMASK(4, 0))
387+
#define __HCRX_EL2_RES0 (GENMASK(63, 25) | GENMASK(13, 12))
388+
#define __HCRX_EL2_MASK (BIT(6))
389+
#define __HCRX_EL2_nMASK (GENMASK(24, 14) | GENMASK(11, 7) | GENMASK(5, 0))
381390

382391
/* Hyp Prefetch Fault Address Register (HPFAR/HDFAR) */
383392
#define HPFAR_MASK (~UL(0xf))

0 commit comments

Comments
 (0)