mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
Merge branch kvm-arm64/nv-debug into kvmarm-master/next
* kvm-arm64/nv-debug: : . : Fix handling of MDSCR_EL1 in NV context, which is unfortunately : mishandled by the architecture. Patches courtesy of Oliver Upton : (20250917203125.283116-2-oliver.upton@linux.dev) : . KVM: arm64: nv: Apply guest's MDCR traps in nested context KVM: arm64: nv: Trap debug registers when in hyp context Signed-off-by: Marc Zyngier <maz@kernel.org>
This commit is contained in:
commit
f01c7baa16
|
|
@ -83,6 +83,8 @@ extern void check_nested_vcpu_requests(struct kvm_vcpu *vcpu);
|
|||
extern void kvm_nested_flush_hwstate(struct kvm_vcpu *vcpu);
|
||||
extern void kvm_nested_sync_hwstate(struct kvm_vcpu *vcpu);
|
||||
|
||||
extern void kvm_nested_setup_mdcr_el2(struct kvm_vcpu *vcpu);
|
||||
|
||||
struct kvm_s2_trans {
|
||||
phys_addr_t output;
|
||||
unsigned long block_size;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ static void kvm_arm_setup_mdcr_el2(struct kvm_vcpu *vcpu)
|
|||
if (!kvm_guest_owns_debug_regs(vcpu))
|
||||
vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA;
|
||||
|
||||
if (vcpu_has_nv(vcpu))
|
||||
kvm_nested_setup_mdcr_el2(vcpu);
|
||||
|
||||
/* Write MDCR_EL2 directly if we're already at EL2 */
|
||||
if (has_vhe())
|
||||
write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
|
||||
|
|
|
|||
|
|
@ -1796,3 +1796,33 @@ void kvm_nested_sync_hwstate(struct kvm_vcpu *vcpu)
|
|||
if (unlikely(vcpu_test_and_clear_flag(vcpu, NESTED_SERROR_PENDING)))
|
||||
kvm_inject_serror_esr(vcpu, vcpu_get_vsesr(vcpu));
|
||||
}
|
||||
|
||||
/*
|
||||
* KVM unconditionally sets most of these traps anyway but use an allowlist
|
||||
* to document the guest hypervisor traps that may take precedence and guard
|
||||
* against future changes to the non-nested trap configuration.
|
||||
*/
|
||||
#define NV_MDCR_GUEST_INCLUDE (MDCR_EL2_TDE | \
|
||||
MDCR_EL2_TDA | \
|
||||
MDCR_EL2_TDRA | \
|
||||
MDCR_EL2_TTRF | \
|
||||
MDCR_EL2_TPMS | \
|
||||
MDCR_EL2_TPM | \
|
||||
MDCR_EL2_TPMCR | \
|
||||
MDCR_EL2_TDCC | \
|
||||
MDCR_EL2_TDOSA)
|
||||
|
||||
void kvm_nested_setup_mdcr_el2(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
u64 guest_mdcr = __vcpu_sys_reg(vcpu, MDCR_EL2);
|
||||
|
||||
/*
|
||||
* In yet another example where FEAT_NV2 is fscking broken, accesses
|
||||
* to MDSCR_EL1 are redirected to the VNCR despite having an effect
|
||||
* at EL2. Use a big hammer to apply sanity.
|
||||
*/
|
||||
if (is_hyp_ctxt(vcpu))
|
||||
vcpu->arch.mdcr_el2 |= MDCR_EL2_TDA;
|
||||
else
|
||||
vcpu->arch.mdcr_el2 |= (guest_mdcr & NV_MDCR_GUEST_INCLUDE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user