Skip to content

Commit 2084ae9

Browse files
committed
Merge: kvm/arm64 rebase to v6.17 plus v6.18-rc fixes without dependency on kvm/x86
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1754 kvm/arm64: Update RHEL-10.2 code base to upstream v6.17 plus v6.18 identified Fixes JIRA: https://issues.redhat.com/browse/RHEL-115972 v8: Fix made to one commit per Gavin's review; should fix selftest build warnings. Added two missing commits which should resolve another selftest build warning, and possibly the page_fault error Eric saw in his test runs. d8d7839 KVM: arm64: selftests: Introduce and use hardware-definition macros c8631ea KVM: arm64: selftests: Explicitly set the page attrs to Inner-Shareable The above found in v6.51-rc's, so went back and ensure no other commits missing in v6.15-rc<n>; found 12 others not in my original list, but all turned out to be backported in the 10.1 kvm-arm64 update. v7: Updated series per Gavin & Eric's input from v6. Found no obvious missing or incorrect patch to explain the selftest failure(s), though, so no additions/fixes for those test issues. If tests re-run, try against base-os version (-154), and report if different. v6: added latest Fixes from v6.18-rc5+: 75360a9 KVM: arm64: vgic-v3: Reinstate IRQ lock ordering for LPI xarray -- applied after commit that it is fixing in the backport series v5: Rebase to -154 kernel. Start this _v2 branch, since the original branch containing v1->v3 would not drop the commits from the kvm/x86+common MR. Closed original MR (1656) to avoid merge-conflicts as well. This version now shows 209 commits. v4: Rebase to -153 kernel. Drop patches that merge-conflict-ed with kvm/x86+common. Dropped arm-core patches that were included in -153. Note: Due to cert change, and failure to get to vpn, couldn't do build on remote arm server, or beaker build, so this hasn't even been compiled!\ -- going on Eric's feedback that dropping all of the above worked for him. -- Sebastian ran kvm selftests & unit tests on previous series; nothing added, and only removal was duplicate patches that arm-core provided, so assuming those tests still valid. When I get vpn (& kerberos) back, I'll do the compiles & tests. Pushing now since on PTO an hour ago(virtually) and all day Monday. Draft, v3: gitlab (cki) was not pleased with the v2 rebase & push; looks like the rebase to mr1640 was less than ideal, as it left my branch with 300 patches from the kvm-common series, when it had 307 patches. One of the kvm-common patches was null in my tree, which was a first for me, so that was another clue that the rebase to 1640 had an odd result. So, re-created this branch, starting with a -152 kernel base, which is what kvm-common rebase is based on, than a rebase to merge-1640, then re-quilting/merging the kvm-arm patches to it (very minor source-line diffs). Minor changes: dropped 10 patches related to irqchip, since realized they were backported for GICv5 support, which was removed in Draft-v2, which will be included in future arm-core update.\ Local builds done on arm64 (grace-hopper) and local x86 (laptop). All looks good. Brew build fails due to IT issues around certs (lost VPN, lost kerberos).\ -152 kernel has arm-core update in it, so that helped to drop more dependencies, so expecting this series to have a better outcome with CKI. Now reduced to 234 patches. Draft, v2: Added requested fix cd4178d (partial; part in kvm/x86+common).\ Commit already in 10.1: bae247c -- please check before reporting again. Major changes: Dropped GICv5 support and prereq patches to apply cleanly, mostly irqchip-related. : Dropped FEAT_MTE backports : Fixed missing and re-ordered KVM: arch64: SCTLR2, Double Fault and NV series; : Kept c20ad96 -- needed for 61b38f7 backport : Fixed KVM: arm64: Revamap Fine Grained Trap Handling; omitted 'Removed duplicated sysreg, expecting arm-core to clean that up due to other arm-core patches to backport around cpufeature and sysregs. : Dropped BRBE series patches that were previously included for other commits to cleanly backport. : Dropped perf-related patches. Overall, patch number reduced to 244. Rebased to recent MR 1640 base. Will run selftests next, and if passing, move out of Draft. Draft: The first 284 of these patches are the kvm/arm64 -related patches; the remaining 597 are the kvm/x86+common patch series. If there is a way to show include the kvm/arm64 patches, I will update this Draft before moving it to ready-for-review/non-draft state. Draft: Currently only compiled (successful brew build across all the arch's); need to start testing next. Creating MR now so others can start reviewing, request needed changes, and prep for shift to non-draft, targetting for CTC1. Omitted-fix: f1e30a4 tools kvm headers arm64: Update KVM header from the kernel sources above commit for PMU which not included in this series, expected in PMU update. Omitted-fix: a186fbc Subject: KVM: arm64: selftests: Filter ZCR_EL2 in get-reg-list above commit's content included in 3a90b6f Subject: KVM: arm64: selftests: get-reg-list: Add and there appears to be Merge commits in upstream to resolve the timing btwn the patches Omitted-fix: a186fbc KVM: arm64: selftests: Filter ZCR_EL2 in get-reg-list -- its one line fix included via Merge commit included in backport of 3a90b6f Subject: KVM: arm64: selftests: get-reg-list: Add base EL2 registers Signed-off-by: Donald Dutile <ddutile@redhat.com> Approved-by: Gavin Shan <gshan@redhat.com> Approved-by: Sebastian Ott <sebott@redhat.com> Approved-by: Eric Auger <eric.auger@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Jan Stancek <jstancek@redhat.com>
2 parents 2dd8657 + 8dc0cf8 commit 2084ae9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+7029
-2339
lines changed

arch/arm64/include/asm/esr.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT)
101101

102102
/* Shared ISS field definitions for Data/Instruction aborts */
103+
#define ESR_ELx_VNCR_SHIFT (13)
104+
#define ESR_ELx_VNCR (UL(1) << ESR_ELx_VNCR_SHIFT)
103105
#define ESR_ELx_SET_SHIFT (11)
104106
#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT)
105107
#define ESR_ELx_FnV_SHIFT (10)
@@ -182,10 +184,12 @@
182184
#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0)
183185
#define ESR_ELx_xVC_IMM_MASK ((UL(1) << 16) - 1)
184186

185-
/* ISS definitions for LD64B/ST64B instructions */
187+
/* ISS definitions for LD64B/ST64B/{T,P}SBCSYNC instructions */
186188
#define ESR_ELx_ISS_OTHER_ST64BV (0)
187189
#define ESR_ELx_ISS_OTHER_ST64BV0 (1)
188190
#define ESR_ELx_ISS_OTHER_LDST64B (2)
191+
#define ESR_ELx_ISS_OTHER_TSBCSYNC (3)
192+
#define ESR_ELx_ISS_OTHER_PSBCSYNC (4)
189193

190194
#define DISR_EL1_IDS (UL(1) << 24)
191195
/*

arch/arm64/include/asm/fixmap.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ enum fixed_addresses {
4848
FIX_EARLYCON_MEM_BASE,
4949
FIX_TEXT_POKE0,
5050

51+
#ifdef CONFIG_KVM
52+
/* One slot per CPU, mapping the guest's VNCR page at EL2. */
53+
FIX_VNCR_END,
54+
FIX_VNCR = FIX_VNCR_END + NR_CPUS,
55+
#endif
56+
5157
#ifdef CONFIG_ACPI_APEI_GHES
5258
/* Used for GHES mapping from assorted contexts */
5359
FIX_APEI_GHES_IRQ,

arch/arm64/include/asm/kvm_arm.h

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -315,56 +315,19 @@
315315
GENMASK(15, 0))
316316

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

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

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 48 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,39 @@ bool kvm_condition_valid32(const struct kvm_vcpu *vcpu);
4545
void kvm_skip_instr32(struct kvm_vcpu *vcpu);
4646

4747
void kvm_inject_undefined(struct kvm_vcpu *vcpu);
48-
void kvm_inject_vabt(struct kvm_vcpu *vcpu);
49-
void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
50-
void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
48+
int kvm_inject_serror_esr(struct kvm_vcpu *vcpu, u64 esr);
49+
int kvm_inject_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr);
5150
void kvm_inject_size_fault(struct kvm_vcpu *vcpu);
5251

52+
static inline int kvm_inject_sea_dabt(struct kvm_vcpu *vcpu, u64 addr)
53+
{
54+
return kvm_inject_sea(vcpu, false, addr);
55+
}
56+
57+
static inline int kvm_inject_sea_iabt(struct kvm_vcpu *vcpu, u64 addr)
58+
{
59+
return kvm_inject_sea(vcpu, true, addr);
60+
}
61+
62+
static inline int kvm_inject_serror(struct kvm_vcpu *vcpu)
63+
{
64+
/*
65+
* ESR_ELx.ISV (later renamed to IDS) indicates whether or not
66+
* ESR_ELx.ISS contains IMPLEMENTATION DEFINED syndrome information.
67+
*
68+
* Set the bit when injecting an SError w/o an ESR to indicate ISS
69+
* does not follow the architected format.
70+
*/
71+
return kvm_inject_serror_esr(vcpu, ESR_ELx_ISV);
72+
}
73+
5374
void kvm_vcpu_wfi(struct kvm_vcpu *vcpu);
5475

5576
void kvm_emulate_nested_eret(struct kvm_vcpu *vcpu);
5677
int kvm_inject_nested_sync(struct kvm_vcpu *vcpu, u64 esr_el2);
5778
int kvm_inject_nested_irq(struct kvm_vcpu *vcpu);
79+
int kvm_inject_nested_sea(struct kvm_vcpu *vcpu, bool iabt, u64 addr);
80+
int kvm_inject_nested_serror(struct kvm_vcpu *vcpu, u64 esr);
5881

5982
static inline void kvm_inject_nested_sve_trap(struct kvm_vcpu *vcpu)
6083
{
@@ -195,6 +218,11 @@ static inline bool vcpu_el2_tge_is_set(const struct kvm_vcpu *vcpu)
195218
return ctxt_sys_reg(&vcpu->arch.ctxt, HCR_EL2) & HCR_TGE;
196219
}
197220

221+
static inline bool vcpu_el2_amo_is_set(const struct kvm_vcpu *vcpu)
222+
{
223+
return ctxt_sys_reg(&vcpu->arch.ctxt, HCR_EL2) & HCR_AMO;
224+
}
225+
198226
static inline bool is_hyp_ctxt(const struct kvm_vcpu *vcpu)
199227
{
200228
bool e2h, tge;
@@ -224,6 +252,20 @@ static inline bool vcpu_is_host_el0(const struct kvm_vcpu *vcpu)
224252
return is_hyp_ctxt(vcpu) && !vcpu_is_el2(vcpu);
225253
}
226254

255+
static inline bool is_nested_ctxt(struct kvm_vcpu *vcpu)
256+
{
257+
return vcpu_has_nv(vcpu) && !is_hyp_ctxt(vcpu);
258+
}
259+
260+
static inline bool vserror_state_is_nested(struct kvm_vcpu *vcpu)
261+
{
262+
if (!is_nested_ctxt(vcpu))
263+
return false;
264+
265+
return vcpu_el2_amo_is_set(vcpu) ||
266+
(__vcpu_sys_reg(vcpu, HCRX_EL2) & HCRX_EL2_TMEA);
267+
}
268+
227269
/*
228270
* The layout of SPSR for an AArch32 state is different when observed from an
229271
* AArch64 SPSR_ELx or an AArch32 SPSR_*. This function generates the AArch32
@@ -561,68 +603,6 @@ static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
561603
vcpu_set_flag((v), e); \
562604
} while (0)
563605

564-
#define __build_check_all_or_none(r, bits) \
565-
BUILD_BUG_ON(((r) & (bits)) && ((r) & (bits)) != (bits))
566-
567-
#define __cpacr_to_cptr_clr(clr, set) \
568-
({ \
569-
u64 cptr = 0; \
570-
\
571-
if ((set) & CPACR_EL1_FPEN) \
572-
cptr |= CPTR_EL2_TFP; \
573-
if ((set) & CPACR_EL1_ZEN) \
574-
cptr |= CPTR_EL2_TZ; \
575-
if ((set) & CPACR_EL1_SMEN) \
576-
cptr |= CPTR_EL2_TSM; \
577-
if ((clr) & CPACR_EL1_TTA) \
578-
cptr |= CPTR_EL2_TTA; \
579-
if ((clr) & CPTR_EL2_TAM) \
580-
cptr |= CPTR_EL2_TAM; \
581-
if ((clr) & CPTR_EL2_TCPAC) \
582-
cptr |= CPTR_EL2_TCPAC; \
583-
\
584-
cptr; \
585-
})
586-
587-
#define __cpacr_to_cptr_set(clr, set) \
588-
({ \
589-
u64 cptr = 0; \
590-
\
591-
if ((clr) & CPACR_EL1_FPEN) \
592-
cptr |= CPTR_EL2_TFP; \
593-
if ((clr) & CPACR_EL1_ZEN) \
594-
cptr |= CPTR_EL2_TZ; \
595-
if ((clr) & CPACR_EL1_SMEN) \
596-
cptr |= CPTR_EL2_TSM; \
597-
if ((set) & CPACR_EL1_TTA) \
598-
cptr |= CPTR_EL2_TTA; \
599-
if ((set) & CPTR_EL2_TAM) \
600-
cptr |= CPTR_EL2_TAM; \
601-
if ((set) & CPTR_EL2_TCPAC) \
602-
cptr |= CPTR_EL2_TCPAC; \
603-
\
604-
cptr; \
605-
})
606-
607-
#define cpacr_clear_set(clr, set) \
608-
do { \
609-
BUILD_BUG_ON((set) & CPTR_VHE_EL2_RES0); \
610-
BUILD_BUG_ON((clr) & CPACR_EL1_E0POE); \
611-
__build_check_all_or_none((clr), CPACR_EL1_FPEN); \
612-
__build_check_all_or_none((set), CPACR_EL1_FPEN); \
613-
__build_check_all_or_none((clr), CPACR_EL1_ZEN); \
614-
__build_check_all_or_none((set), CPACR_EL1_ZEN); \
615-
__build_check_all_or_none((clr), CPACR_EL1_SMEN); \
616-
__build_check_all_or_none((set), CPACR_EL1_SMEN); \
617-
\
618-
if (has_vhe() || has_hvhe()) \
619-
sysreg_clear_set(cpacr_el1, clr, set); \
620-
else \
621-
sysreg_clear_set(cptr_el2, \
622-
__cpacr_to_cptr_clr(clr, set), \
623-
__cpacr_to_cptr_set(clr, set));\
624-
} while (0)
625-
626606
/*
627607
* Returns a 'sanitised' view of CPTR_EL2, translating from nVHE to the VHE
628608
* format if E2H isn't set.
@@ -689,6 +669,9 @@ static inline void vcpu_set_hcrx(struct kvm_vcpu *vcpu)
689669

690670
if (kvm_has_fpmr(kvm))
691671
vcpu->arch.hcrx_el2 |= HCRX_EL2_EnFPM;
672+
673+
if (kvm_has_sctlr2(kvm))
674+
vcpu->arch.hcrx_el2 |= HCRX_EL2_SCTLR2En;
692675
}
693676
}
694677
#endif /* __ARM64_KVM_EMULATE_H__ */

0 commit comments

Comments
 (0)