Skip to content

Commit 4d526b0

Browse files
committed
Merge tag 'kvmarm-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into HEAD
KVM/arm64 updates for 6.16 * New features: - Add large stage-2 mapping support for non-protected pKVM guests, clawing back some performance. - Add UBSAN support to the standalone EL2 object used in nVHE/hVHE and protected modes. - Enable nested virtualisation support on systems that support it (yes, it has been a long time coming), though it is disabled by default. * Improvements, fixes and cleanups: - Large rework of the way KVM tracks architecture features and links them with the effects of control bits. This ensures correctness of emulation (the data is automatically extracted from the published JSON files), and helps dealing with the evolution of the architecture. - Significant changes to the way pKVM tracks ownership of pages, avoiding page table walks by storing the state in the hypervisor's vmemmap. This in turn enables the THP support described above. - New selftest checking the pKVM ownership transition rules - Fixes for FEAT_MTE_ASYNC being accidentally advertised to guests even if the host didn't have it. - Fixes for the address translation emulation, which happened to be rather buggy in some specific contexts. - Fixes for the PMU emulation in NV contexts, decoupling PMCR_EL0.N from the number of counters exposed to a guest and addressing a number of issues in the process. - Add a new selftest for the SVE host state being corrupted by a guest. - Keep HCR_EL2.xMO set at all times for systems running with the kernel at EL2, ensuring that the window for interrupts is slightly bigger, and avoiding a pretty bad erratum on the AmpereOne HW. - Add workaround for AmpereOne's erratum AC04_CPU_23, which suffers from a pretty bad case of TLB corruption unless accesses to HCR_EL2 are heavily synchronised. - Add a per-VM, per-ITS debugfs entry to dump the state of the ITS tables in a human-friendly fashion. - and the usual random cleanups.
2 parents 85502b2 + 1b85d92 commit 4d526b0

Some content is hidden

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

70 files changed

+5350
-1225
lines changed

Documentation/arch/arm64/silicon-errata.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ stable kernels.
5757
+----------------+-----------------+-----------------+-----------------------------+
5858
| Ampere | AmpereOne AC04 | AC04_CPU_10 | AMPERE_ERRATUM_AC03_CPU_38 |
5959
+----------------+-----------------+-----------------+-----------------------------+
60+
| Ampere | AmpereOne AC04 | AC04_CPU_23 | AMPERE_ERRATUM_AC04_CPU_23 |
61+
+----------------+-----------------+-----------------+-----------------------------+
6062
+----------------+-----------------+-----------------+-----------------------------+
6163
| ARM | Cortex-A510 | #2457168 | ARM64_ERRATUM_2457168 |
6264
+----------------+-----------------+-----------------+-----------------------------+

Documentation/virt/kvm/api.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3463,7 +3463,8 @@ The initial values are defined as:
34633463
- FPSIMD/NEON registers: set to 0
34643464
- SVE registers: set to 0
34653465
- System registers: Reset to their architecturally defined
3466-
values as for a warm reset to EL1 (resp. SVC)
3466+
values as for a warm reset to EL1 (resp. SVC) or EL2 (in the
3467+
case of EL2 being enabled).
34673468

34683469
Note that because some registers reflect machine topology, all vcpus
34693470
should be created before this ioctl is invoked.
@@ -3530,6 +3531,17 @@ Possible features:
35303531
- the KVM_REG_ARM64_SVE_VLS pseudo-register is immutable, and can
35313532
no longer be written using KVM_SET_ONE_REG.
35323533

3534+
- KVM_ARM_VCPU_HAS_EL2: Enable Nested Virtualisation support,
3535+
booting the guest from EL2 instead of EL1.
3536+
Depends on KVM_CAP_ARM_EL2.
3537+
The VM is running with HCR_EL2.E2H being RES1 (VHE) unless
3538+
KVM_ARM_VCPU_HAS_EL2_E2H0 is also set.
3539+
3540+
- KVM_ARM_VCPU_HAS_EL2_E2H0: Restrict Nested Virtualisation
3541+
support to HCR_EL2.E2H being RES0 (non-VHE).
3542+
Depends on KVM_CAP_ARM_EL2_E2H0.
3543+
KVM_ARM_VCPU_HAS_EL2 must also be set.
3544+
35333545
4.83 KVM_ARM_PREFERRED_TARGET
35343546
-----------------------------
35353547

Documentation/virt/kvm/devices/vcpu.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@ exit_reason = KVM_EXIT_FAIL_ENTRY and populate the fail_entry struct by setting
137137
hardare_entry_failure_reason field to KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED and
138138
the cpu field to the processor id.
139139

140+
1.5 ATTRIBUTE: KVM_ARM_VCPU_PMU_V3_SET_NR_COUNTERS
141+
--------------------------------------------------
142+
143+
:Parameters: in kvm_device_attr.addr the address to an unsigned int
144+
representing the maximum value taken by PMCR_EL0.N
145+
146+
:Returns:
147+
148+
======= ====================================================
149+
-EBUSY PMUv3 already initialized, a VCPU has already run or
150+
an event filter has already been set
151+
-EFAULT Error accessing the value pointed to by addr
152+
-ENODEV PMUv3 not supported or GIC not initialized
153+
-EINVAL No PMUv3 explicitly selected, or value of N out of
154+
range
155+
======= ====================================================
156+
157+
Set the number of implemented event counters in the virtual PMU. This
158+
mandates that a PMU has explicitly been selected via
159+
KVM_ARM_VCPU_PMU_V3_SET_PMU, and will fail when no PMU has been
160+
explicitly selected, or the number of counters is out of range for the
161+
selected PMU. Selecting a new PMU cancels the effect of setting this
162+
attribute.
163+
140164
2. GROUP: KVM_ARM_VCPU_TIMER_CTRL
141165
=================================
142166

arch/arm64/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,23 @@ config AMPERE_ERRATUM_AC03_CPU_38
464464

465465
If unsure, say Y.
466466

467+
config AMPERE_ERRATUM_AC04_CPU_23
468+
bool "AmpereOne: AC04_CPU_23: Failure to synchronize writes to HCR_EL2 may corrupt address translations."
469+
default y
470+
help
471+
This option adds an alternative code sequence to work around Ampere
472+
errata AC04_CPU_23 on AmpereOne.
473+
474+
Updates to HCR_EL2 can rarely corrupt simultaneous translations for
475+
data addresses initiated by load/store instructions. Only
476+
instruction initiated translations are vulnerable, not translations
477+
from prefetches for example. A DSB before the store to HCR_EL2 is
478+
sufficient to prevent older instructions from hitting the window
479+
for corruption, and an ISB after is sufficient to prevent younger
480+
instructions from hitting the window for corruption.
481+
482+
If unsure, say Y.
483+
467484
config ARM64_WORKAROUND_CLEAN_CACHE
468485
bool
469486

arch/arm64/include/asm/el2_setup.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
orr x0, x0, #HCR_E2H
4040
.LnVHE_\@:
41-
msr hcr_el2, x0
41+
msr_hcr_el2 x0
4242
isb
4343
.endm
4444

@@ -213,25 +213,25 @@
213213
cbz x1, .Lskip_debug_fgt_\@
214214

215215
/* Disable nVHE traps of TPIDR2 and SMPRI */
216-
orr x0, x0, #HFGxTR_EL2_nSMPRI_EL1_MASK
217-
orr x0, x0, #HFGxTR_EL2_nTPIDR2_EL0_MASK
216+
orr x0, x0, #HFGRTR_EL2_nSMPRI_EL1_MASK
217+
orr x0, x0, #HFGRTR_EL2_nTPIDR2_EL0_MASK
218218

219219
.Lskip_debug_fgt_\@:
220220
mrs_s x1, SYS_ID_AA64MMFR3_EL1
221221
ubfx x1, x1, #ID_AA64MMFR3_EL1_S1PIE_SHIFT, #4
222222
cbz x1, .Lskip_pie_fgt_\@
223223

224224
/* Disable trapping of PIR_EL1 / PIRE0_EL1 */
225-
orr x0, x0, #HFGxTR_EL2_nPIR_EL1
226-
orr x0, x0, #HFGxTR_EL2_nPIRE0_EL1
225+
orr x0, x0, #HFGRTR_EL2_nPIR_EL1
226+
orr x0, x0, #HFGRTR_EL2_nPIRE0_EL1
227227

228228
.Lskip_pie_fgt_\@:
229229
mrs_s x1, SYS_ID_AA64MMFR3_EL1
230230
ubfx x1, x1, #ID_AA64MMFR3_EL1_S1POE_SHIFT, #4
231231
cbz x1, .Lskip_poe_fgt_\@
232232

233233
/* Disable trapping of POR_EL0 */
234-
orr x0, x0, #HFGxTR_EL2_nPOR_EL0
234+
orr x0, x0, #HFGRTR_EL2_nPOR_EL0
235235

236236
.Lskip_poe_fgt_\@:
237237
/* GCS depends on PIE so we don't check it if PIE is absent */
@@ -240,8 +240,8 @@
240240
cbz x1, .Lset_fgt_\@
241241

242242
/* Disable traps of access to GCS registers at EL0 and EL1 */
243-
orr x0, x0, #HFGxTR_EL2_nGCS_EL1_MASK
244-
orr x0, x0, #HFGxTR_EL2_nGCS_EL0_MASK
243+
orr x0, x0, #HFGRTR_EL2_nGCS_EL1_MASK
244+
orr x0, x0, #HFGRTR_EL2_nGCS_EL0_MASK
245245

246246
.Lset_fgt_\@:
247247
msr_s SYS_HFGRTR_EL2, x0

arch/arm64/include/asm/esr.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#define ESR_ELx_EC_FP_ASIMD UL(0x07)
2121
#define ESR_ELx_EC_CP10_ID UL(0x08) /* EL2 only */
2222
#define ESR_ELx_EC_PAC UL(0x09) /* EL2 and above */
23-
/* Unallocated EC: 0x0A - 0x0B */
23+
#define ESR_ELx_EC_OTHER UL(0x0A)
24+
/* Unallocated EC: 0x0B */
2425
#define ESR_ELx_EC_CP14_64 UL(0x0C)
2526
#define ESR_ELx_EC_BTI UL(0x0D)
2627
#define ESR_ELx_EC_ILL UL(0x0E)
@@ -99,6 +100,8 @@
99100
#define ESR_ELx_AET_CE (UL(6) << ESR_ELx_AET_SHIFT)
100101

101102
/* 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)
102105
#define ESR_ELx_SET_SHIFT (11)
103106
#define ESR_ELx_SET_MASK (UL(3) << ESR_ELx_SET_SHIFT)
104107
#define ESR_ELx_FnV_SHIFT (10)
@@ -181,6 +184,13 @@
181184
#define ESR_ELx_WFx_ISS_WFE (UL(1) << 0)
182185
#define ESR_ELx_xVC_IMM_MASK ((UL(1) << 16) - 1)
183186

187+
/* ISS definitions for LD64B/ST64B/{T,P}SBCSYNC instructions */
188+
#define ESR_ELx_ISS_OTHER_ST64BV (0)
189+
#define ESR_ELx_ISS_OTHER_ST64BV0 (1)
190+
#define ESR_ELx_ISS_OTHER_LDST64B (2)
191+
#define ESR_ELx_ISS_OTHER_TSBCSYNC (3)
192+
#define ESR_ELx_ISS_OTHER_PSBCSYNC (4)
193+
184194
#define DISR_EL1_IDS (UL(1) << 24)
185195
/*
186196
* DISR_EL1 and ESR_ELx share the bottom 13 bits, but the RES0 bits may mean
@@ -440,6 +450,11 @@ static inline bool esr_is_cfi_brk(unsigned long esr)
440450
(esr_brk_comment(esr) & ~CFI_BRK_IMM_MASK) == CFI_BRK_IMM_BASE;
441451
}
442452

453+
static inline bool esr_is_ubsan_brk(unsigned long esr)
454+
{
455+
return (esr_brk_comment(esr) & ~UBSAN_BRK_MASK) == UBSAN_BRK_IMM;
456+
}
457+
443458
static inline bool esr_fsc_is_translation_fault(unsigned long esr)
444459
{
445460
esr = esr & ESR_ELx_FSC;

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/hardirq.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ do { \
4141
\
4242
___hcr = read_sysreg(hcr_el2); \
4343
if (!(___hcr & HCR_TGE)) { \
44-
write_sysreg(___hcr | HCR_TGE, hcr_el2); \
44+
write_sysreg_hcr(___hcr | HCR_TGE); \
4545
isb(); \
4646
} \
4747
/* \
@@ -82,7 +82,7 @@ do { \
8282
*/ \
8383
barrier(); \
8484
if (!___ctx->cnt && !(___hcr & HCR_TGE)) \
85-
write_sysreg(___hcr, hcr_el2); \
85+
write_sysreg_hcr(___hcr); \
8686
} while (0)
8787

8888
static inline void ack_bad_irq(unsigned int irq)

0 commit comments

Comments
 (0)