Skip to content

Commit 1df3f01

Browse files
author
Marc Zyngier
committed
Merge branch kvm-arm64/resx into kvmarm-master/next
* kvm-arm64/resx: : . : Add infrastructure to deal with the full gamut of RESx bits : for NV. As a result, it is now possible to have the expected : semantics for some bits such as SCTLR_EL2.SPAN. : . KVM: arm64: Add debugfs file dumping computed RESx values KVM: arm64: Add sanitisation to SCTLR_EL2 KVM: arm64: Remove all traces of HCR_EL2.MIOCNCE KVM: arm64: Remove all traces of FEAT_TME KVM: arm64: Simplify handling of full register invalid constraint KVM: arm64: Get rid of FIXED_VALUE altogether KVM: arm64: Simplify handling of HCR_EL2.E2H RESx KVM: arm64: Move RESx into individual register descriptors KVM: arm64: Add RES1_WHEN_E2Hx constraints as configuration flags KVM: arm64: Add REQUIRES_E2H1 constraint as configuration flags KVM: arm64: Simplify FIXED_VALUE handling KVM: arm64: Convert HCR_EL2.RW to AS_RES1 KVM: arm64: Correctly handle SCTLR_EL1 RES1 bits for unsupported features KVM: arm64: Allow RES1 bits to be inferred from configuration KVM: arm64: Inherit RESx bits from FGT register descriptors KVM: arm64: Extend unified RESx handling to runtime sanitisation KVM: arm64: Introduce data structure tracking both RES0 and RES1 bits KVM: arm64: Introduce standalone FGU computing primitive KVM: arm64: Remove duplicate configuration for SCTLR_EL1.{EE,E0E} arm64: Convert SCTLR_EL2 to sysreg infrastructure Signed-off-by: Marc Zyngier <maz@kernel.org>
2 parents 3ef5ba6 + edba407 commit 1df3f01

File tree

10 files changed

+478
-313
lines changed

10 files changed

+478
-313
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ enum vcpu_sysreg {
492492
DBGVCR32_EL2, /* Debug Vector Catch Register */
493493

494494
/* EL2 registers */
495-
SCTLR_EL2, /* System Control Register (EL2) */
496495
ACTLR_EL2, /* Auxiliary Control Register (EL2) */
497496
CPTR_EL2, /* Architectural Feature Trap Register (EL2) */
498497
HACR_EL2, /* Hypervisor Auxiliary Control Register */
@@ -523,6 +522,7 @@ enum vcpu_sysreg {
523522

524523
/* Anything from this can be RES0/RES1 sanitised */
525524
MARKER(__SANITISED_REG_START__),
525+
SCTLR_EL2, /* System Control Register (EL2) */
526526
TCR2_EL2, /* Extended Translation Control Register (EL2) */
527527
SCTLR2_EL2, /* System Control Register 2 (EL2) */
528528
MDCR_EL2, /* Monitor Debug Configuration Register (EL2) */
@@ -623,13 +623,39 @@ enum vcpu_sysreg {
623623
NR_SYS_REGS /* Nothing after this line! */
624624
};
625625

626+
struct resx {
627+
u64 res0;
628+
u64 res1;
629+
};
630+
626631
struct kvm_sysreg_masks {
627-
struct {
628-
u64 res0;
629-
u64 res1;
630-
} mask[NR_SYS_REGS - __SANITISED_REG_START__];
632+
struct resx mask[NR_SYS_REGS - __SANITISED_REG_START__];
631633
};
632634

635+
static inline struct resx __kvm_get_sysreg_resx(struct kvm_arch *arch,
636+
enum vcpu_sysreg sr)
637+
{
638+
struct kvm_sysreg_masks *masks;
639+
640+
masks = arch->sysreg_masks;
641+
if (likely(masks &&
642+
sr >= __SANITISED_REG_START__ && sr < NR_SYS_REGS))
643+
return masks->mask[sr - __SANITISED_REG_START__];
644+
645+
return (struct resx){};
646+
}
647+
648+
#define kvm_get_sysreg_resx(k, sr) __kvm_get_sysreg_resx(&(k)->arch, (sr))
649+
650+
static inline void __kvm_set_sysreg_resx(struct kvm_arch *arch,
651+
enum vcpu_sysreg sr, struct resx resx)
652+
{
653+
arch->sysreg_masks->mask[sr - __SANITISED_REG_START__] = resx;
654+
}
655+
656+
#define kvm_set_sysreg_resx(k, sr, resx) \
657+
__kvm_set_sysreg_resx(&(k)->arch, (sr), (resx))
658+
633659
struct fgt_masks {
634660
const char *str;
635661
u64 mask;
@@ -1604,7 +1630,7 @@ static inline bool kvm_arch_has_irq_bypass(void)
16041630
}
16051631

16061632
void compute_fgu(struct kvm *kvm, enum fgt_group_id fgt);
1607-
void get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg, u64 *res0, u64 *res1);
1633+
struct resx get_reg_fixed_bits(struct kvm *kvm, enum vcpu_sysreg reg);
16081634
void check_feature_map(void);
16091635
void kvm_vcpu_load_fgt(struct kvm_vcpu *vcpu);
16101636

arch/arm64/include/asm/sysreg.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@
504504
#define SYS_VPIDR_EL2 sys_reg(3, 4, 0, 0, 0)
505505
#define SYS_VMPIDR_EL2 sys_reg(3, 4, 0, 0, 5)
506506

507-
#define SYS_SCTLR_EL2 sys_reg(3, 4, 1, 0, 0)
508507
#define SYS_ACTLR_EL2 sys_reg(3, 4, 1, 0, 1)
509508
#define SYS_SCTLR2_EL2 sys_reg(3, 4, 1, 0, 3)
510509
#define SYS_HCR_EL2 sys_reg(3, 4, 1, 1, 0)
@@ -836,12 +835,6 @@
836835
#define SCTLR_ELx_A (BIT(1))
837836
#define SCTLR_ELx_M (BIT(0))
838837

839-
/* SCTLR_EL2 specific flags. */
840-
#define SCTLR_EL2_RES1 ((BIT(4)) | (BIT(5)) | (BIT(11)) | (BIT(16)) | \
841-
(BIT(18)) | (BIT(22)) | (BIT(23)) | (BIT(28)) | \
842-
(BIT(29)))
843-
844-
#define SCTLR_EL2_BT (BIT(36))
845838
#ifdef CONFIG_CPU_BIG_ENDIAN
846839
#define ENDIAN_SET_EL2 SCTLR_ELx_EE
847840
#else

0 commit comments

Comments
 (0)