KVM: arm64: Fix FEAT_MOPS in pKVM
PATCH 1/1 KVM: arm64: Fix FEAT_MOPS in pKVM
Flush HCRX_EL2 when switching between the host and the guests.
--- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kvm/hyp/nvhe/hyp-main.c +1 -0
@@ -109,6 +109,7 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vcpu) hyp_vcpu->vcpu.arch.hcr_el2 &= ~(HCR_TWI |HCR_TWE ); hyp_vcpu->vcpu.arch.hcr_el2 |=READ_ONCE (host_vcpu->arch.hcr_el2) & (HCR_TWI |HCR_TWE ); + hyp_vcpu->vcpu.arch.hcrx_el2 = host_vcpu->arch.hcrx_el2; hyp_vcpu->vcpu.arch.iflags = host_vcpu->arch.iflags;
Signature · 1 line
2.24.0
+cc Fuad
Quoted 4 lines · Vladimir Murzin
Flush
HCRX_EL2when switching between the host and the guests.Fixes 84de212d739e ("KVM: arm64: Make FEAT_MOPS UNDEF if not advertised to the guest")Signed-off-by Vladimir Murzin <[email protected]>
We shouldn't be trusting the host's hcrx_el2 in this case and should instead calculate it for the pVM similar to the other trap registers (see pkvm_vcpu_init_traps() and friends).
It is apparent, though, that we erroneously exposed MOPS before commit 3d7ff00700d1 ("KVM: arm64: Rework specifying restricted features for protected VMs").
Signature · 2 lines
Thanks, Oliver
Quoted 9 lines · Oliver Upton
+cc Fuad
Quoted 4 lines · Vladimir Murzin
Flush
HCRX_EL2when switching between the host and the guests.Fixes 84de212d739e ("KVM: arm64: Make FEAT_MOPS UNDEF if not advertised to the guest")Signed-off-by Vladimir Murzin <[email protected]>
Quoted 6 lines
We shouldn't be trusting the host's
hcrx_el2in this case and should instead calculate it for the pVM similar to the other trap registers (seepkvm_vcpu_init_traps()and friends).It is apparent, though, that we erroneously exposed MOPS before commit
3d7ff00700d1("KVM: arm64: Rework specifying restricted features for protected VMs").
Yeah, actually FEAT_MOPS needs a bit more work for it to work with pKVM. I have patches (downstream, Android) that add MOPS support for pKVM. If there's interest I can post them now, but since protected VMs aren't completely done upstream I thought I'd wait a bit.
Cheers,
/fuad
Quoted 4 lines
--
Thanks,
Oliver
Quoted 12 lines · Fuad Tabba
Quoted 11 lines · Oliver Upton
+cc Fuad
Quoted 4 lines · Vladimir Murzin
Flush
HCRX_EL2when switching between the host and the guests.Fixes 84de212d739e ("KVM: arm64: Make FEAT_MOPS UNDEF if not advertised to the guest")Signed-off-by Vladimir Murzin <[email protected]>We shouldn't be trusting the host's
hcrx_el2in this case and should instead calculate it for the pVM similar to the other trap registers (seepkvm_vcpu_init_traps()and friends).
Quoted 6 lines
Quoted 2 lines
It is apparent, though, that we erroneously exposed MOPS before commit
3d7ff00700d1("KVM: arm64: Rework specifying restricted features for protected VMs").Yeah, actually
FEAT_MOPSneeds a bit more work for it to work with pKVM. I have patches (downstream, Android) that add MOPS support for pKVM. If there's interest I can post them now, but since protected VMs aren't completely done upstream I thought I'd wait a bit.
Fair enough.
Vladimir
Quoted 7 lines
Cheers,
/fuadQuoted 3 lines
--
Thanks,
Oliver