Skip to content

Commit f7dd9df

Browse files
author
Herton R. Krzesinski
committed
Merge: KVM: aarch64: Rebase to v6.0
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1663 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2128973 Depends: https://bugzilla.redhat.com/show_bug.cgi?id=2122232 Rebase the KVM/aarch64 code to v6.0 Signed-off-by: Cornelia Huck <cohuck@redhat.com> Approved-by: Eric Auger <eric.auger@redhat.com> Approved-by: Gavin Shan <gshan@redhat.com> Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Mark Salter <msalter@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 799a92a + ba032cd commit f7dd9df

Some content is hidden

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

71 files changed

+2744
-1350
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2439,7 +2439,6 @@
24392439

24402440
protected: nVHE-based mode with support for guests whose
24412441
state is kept private from the host.
2442-
Not valid if the kernel is running in EL2.
24432442

24442443
Defaults to VHE/nVHE based on hardware support.
24452444

Documentation/virt/kvm/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5922,6 +5922,8 @@ affect the device's behavior. Current defined flags::
59225922
#define KVM_RUN_X86_SMM (1 << 0)
59235923
/* x86, set if bus lock detected in VM */
59245924
#define KVM_RUN_BUS_LOCK (1 << 1)
5925+
/* arm64, set for KVM_EXIT_DEBUG */
5926+
#define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0)
59255927

59265928
::
59275929

Documentation/virt/kvm/arm/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ ARM
88
:maxdepth: 2
99

1010
hyp-abi
11-
psci
11+
hypercalls
1212
pvtime
1313
ptp_kvm

arch/arm64/include/asm/kvm_arm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@
8080
* FMO: Override CPSR.F and enable signaling with VF
8181
* SWIO: Turn set/way invalidates into set/way clean+invalidate
8282
* PTW: Take a stage2 fault if a stage1 walk steps in device memory
83+
* TID3: Trap EL1 reads of group 3 ID registers
8384
*/
8485
#define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \
8586
HCR_BSU_IS | HCR_FB | HCR_TACR | \
8687
HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \
87-
HCR_FMO | HCR_IMO | HCR_PTW )
88+
HCR_FMO | HCR_IMO | HCR_PTW | HCR_TID3 )
8889
#define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF)
8990
#define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK | HCR_ATA)
9091
#define HCR_HOST_NVHE_PROTECTED_FLAGS (HCR_HOST_NVHE_FLAGS | HCR_TSC)

arch/arm64/include/asm/kvm_asm.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,29 @@ struct kvm_nvhe_init_params {
169169
unsigned long tcr_el2;
170170
unsigned long tpidr_el2;
171171
unsigned long stack_hyp_va;
172+
unsigned long stack_pa;
172173
phys_addr_t pgd_pa;
173174
unsigned long hcr_el2;
174175
unsigned long vttbr;
175176
unsigned long vtcr;
176177
};
177178

179+
/*
180+
* Used by the host in EL1 to dump the nVHE hypervisor backtrace on
181+
* hyp_panic() in non-protected mode.
182+
*
183+
* @stack_base: hyp VA of the hyp_stack base.
184+
* @overflow_stack_base: hyp VA of the hyp_overflow_stack base.
185+
* @fp: hyp FP where the backtrace begins.
186+
* @pc: hyp PC where the backtrace begins.
187+
*/
188+
struct kvm_nvhe_stacktrace_info {
189+
unsigned long stack_base;
190+
unsigned long overflow_stack_base;
191+
unsigned long fp;
192+
unsigned long pc;
193+
};
194+
178195
/* Translate a kernel address @ptr into its equivalent linear mapping */
179196
#define kvm_ksym_ref(ptr) \
180197
({ \

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,6 @@ static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
8787

8888
if (vcpu_el1_is_32bit(vcpu))
8989
vcpu->arch.hcr_el2 &= ~HCR_RW;
90-
else
91-
/*
92-
* TID3: trap feature register accesses that we virtualise.
93-
* For now this is conditional, since no AArch32 feature regs
94-
* are currently virtualised.
95-
*/
96-
vcpu->arch.hcr_el2 |= HCR_TID3;
9790

9891
if (cpus_have_const_cap(ARM64_MISMATCHED_CACHE_TYPE) ||
9992
vcpu_el1_is_32bit(vcpu))
@@ -236,14 +229,14 @@ static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
236229
return mode != PSR_MODE_EL0t;
237230
}
238231

239-
static __always_inline u32 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu)
232+
static __always_inline u64 kvm_vcpu_get_esr(const struct kvm_vcpu *vcpu)
240233
{
241234
return vcpu->arch.fault.esr_el2;
242235
}
243236

244237
static __always_inline int kvm_vcpu_get_condition(const struct kvm_vcpu *vcpu)
245238
{
246-
u32 esr = kvm_vcpu_get_esr(vcpu);
239+
u64 esr = kvm_vcpu_get_esr(vcpu);
247240

248241
if (esr & ESR_ELx_CV)
249242
return (esr & ESR_ELx_COND_MASK) >> ESR_ELx_COND_SHIFT;
@@ -374,7 +367,7 @@ static __always_inline bool kvm_vcpu_abt_issea(const struct kvm_vcpu *vcpu)
374367

375368
static __always_inline int kvm_vcpu_sys_get_rt(struct kvm_vcpu *vcpu)
376369
{
377-
u32 esr = kvm_vcpu_get_esr(vcpu);
370+
u64 esr = kvm_vcpu_get_esr(vcpu);
378371
return ESR_ELx_SYS64_ISS_RT(esr);
379372
}
380373

@@ -480,9 +473,18 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu,
480473

481474
static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
482475
{
483-
vcpu->arch.flags |= KVM_ARM64_INCREMENT_PC;
476+
WARN_ON(vcpu_get_flag(vcpu, PENDING_EXCEPTION));
477+
vcpu_set_flag(vcpu, INCREMENT_PC);
484478
}
485479

480+
#define kvm_pend_exception(v, e) \
481+
do { \
482+
WARN_ON(vcpu_get_flag((v), INCREMENT_PC)); \
483+
vcpu_set_flag((v), PENDING_EXCEPTION); \
484+
vcpu_set_flag((v), e); \
485+
} while (0)
486+
487+
486488
static inline bool vcpu_has_feature(struct kvm_vcpu *vcpu, int feature)
487489
{
488490
return test_bit(feature, vcpu->arch.features);

0 commit comments

Comments
 (0)