Skip to contentSkip to conversation

linux-next: manual merge of the arm64 tree with the origin tree

DISCUSSION Mark Brown 3 participants 6 messages Jan 26

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

Hi all,

Today's linux-next merge of the arm64 tree got a conflict in:

arch/arm64/kvm/hyp/entry.S

between commit:

86364832ba6f2 ("KVM: arm64: Don't blindly set set PSTATE.PAN on guest exit")

from the origin tree and commit:

018a231b0260e ("arm64: Unconditionally enable PAN support")

from the arm64 tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

[Took the version from Linus' tree.]

maintainer
#1 lore raw
Quoted 16 lines · Mark Brown

Hi all,

Today's linux-next merge of the arm64 tree got a conflict in:

arch/arm64/kvm/hyp/entry.S

between commit:

86364832ba6f2 ("KVM: arm64: Don't blindly set set PSTATE.PAN on guest exit")

from the origin tree and commit:

018a231b0260e ("arm64: Unconditionally enable PAN support")

from the arm64 tree.

Quoted 8 lines

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

[Took the version from Linus' tree.]

Hmm, I suspect that's not quite right because CONFIG_ARM64_PAN doesn't exist anymore in the arm64 tree and so the hunk in arch/arm64/kvm/va_layout.c probably needs tweaking.

Marc -- how would you prefer to handle this? I could bring back CONFIG_ARM64_PAN as a hidden Kconfig option =y and then we could clean up the stragglers at -rc1?

Will

maintainer
#4 lore raw
In reply to Mark Brown
Quoted 18 lines · Mark Brown

[1 <text/plain; us-ascii (quoted-printable)>]
Hi all,

Today's linux-next merge of the arm64 tree got a conflict in:

arch/arm64/kvm/hyp/entry.S

between commit:

86364832ba6f2 ("KVM: arm64: Don't blindly set set PSTATE.PAN on guest exit")

from the origin tree and commit:

018a231b0260e ("arm64: Unconditionally enable PAN support")

from the arm64 tree.

Quoted 8 lines

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

[Took the version from Linus' tree.]

I can't see the latest next yet, but this doesn't sound right.

The correct resolution for this is in the kvmarm/next branch, effectively reverting most of 86364832ba6f2 ("KVM: arm64: Don't blindly set set PSTATE.PAN on guest exit").

Keeping the version from Linus' tree doesn't work, as kvm_pan_patch_el2_entry() references CONFIG_ARM64_PAN, which is removed by 018a231b0260e ("arm64: Unconditionally enable PAN support").

So the arm64 version should be the correct one.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
maintainer
#2 lore raw
In reply to Will Deacon
Quoted 25 lines · Will Deacon
Quoted 23 lines · Mark Brown

Hi all,

Today's linux-next merge of the arm64 tree got a conflict in:

arch/arm64/kvm/hyp/entry.S

between commit:

86364832ba6f2 ("KVM: arm64: Don't blindly set set PSTATE.PAN on guest exit")

from the origin tree and commit:

018a231b0260e ("arm64: Unconditionally enable PAN support")

from the arm64 tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Quoted 5 lines
Quoted 1 line

[Took the version from Linus' tree.]

Hmm, I suspect that's not quite right because CONFIG_ARM64_PAN doesn't exist anymore in the arm64 tree and so the hunk in arch/arm64/kvm/va_layout.c probably needs tweaking.

The whole function in va_layout.c should simply disappear and whatever is in arm64 be kept. That's what I did when I merged arm64/for-next/cpufeature and kvm-arm64/vtcr in kvmarm/next.

But I now realise that because all these changes happen only in the kvmarm/next branch (what was added is now removed), nobody sees that outside of that tree, and next ends up with something that isn't quite right.

Quoted 3 lines

Marc -- how would you prefer to handle this? I could bring back CONFIG_ARM64_PAN as a hidden Kconfig option =y and then we could clean up the stragglers at -rc1?

As long as entry.S reflects what is in arm64 tree, we don't need this. We just have a dangling patch function that is never called, and we can cull that later. But if entry.S stays with Linus' version, then we definitely need something of the sort.

FWIW, my own resolution is below.

Thanks,

	M.
arch/arm64/include/asm/kvm_asm.h +0 -2
index ce516d8187b1b..a1ad12c72ebf1 100644
@@ -300,8 +300,6 @@ void kvm_get_kimage_voffset(struct alt_instr *alt,
 	__le32 *origptr, __le32 *updptr, int nr_inst);
 void kvm_compute_final_ctr_el0(struct alt_instr *alt,
 	__le32 *origptr, __le32 *updptr, int nr_inst);
-void kvm_pan_patch_el2_entry(struct alt_instr *alt,
-			     __le32 *origptr, __le32 *updptr, int nr_inst);
 void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr, u64 elr_virt,
 	u64 elr_phys, u64 par, uintptr_t vcpu, u64 far, u64 hpfar);
 
arch/arm64/kvm/hyp/entry.S +1 -3
index d1ccddf9e87d9..11a10d8f5beb2 100644
@@ -126,9 +126,7 @@ SYM_INNER_LABEL(__guest_exit, SYM_L_GLOBAL)
 
 	add	x1, x1, #VCPU_CONTEXT
 
-	alternative_cb ARM64_ALWAYS_SYSTEM, kvm_pan_patch_el2_entry
-	nop
-	alternative_cb_end
+	ALTERNATIVE(nop, SET_PSTATE_PAN(1), ARM64_HAS_PAN)
 
 	// Store the guest regs x2 and x3
 	stp	x2, x3,   [x1, #CPU_XREG_OFFSET(2)]
arch/arm64/kvm/va_layout.c +0 -28
index bf888d150dc79..91b22a014610b 100644
@@ -296,31 +296,3 @@ void kvm_compute_final_ctr_el0(struct alt_instr *alt,
 	generate_mov_q(read_sanitised_ftr_reg(SYS_CTR_EL0),
 		       origptr, updptr, nr_inst);
 }
-
-void kvm_pan_patch_el2_entry(struct alt_instr *alt,
-			     __le32 *origptr, __le32 *updptr, int nr_inst)
-{
-	/*
-	 * If we're running at EL1 without hVHE, then SCTLR_EL2.SPAN means
-	 * nothing to us (it is RES1), and we don't need to set PSTATE.PAN
-	 * to anything useful.
-	 */
-	if (!is_kernel_in_hyp_mode() && !cpus_have_cap(ARM64_KVM_HVHE))
-		return;
-
-	/*
-	 * Leap of faith: at this point, we must be running VHE one way or
-	 * another, and FEAT_PAN is required to be implemented. If KVM
-	 * explodes at runtime because your system does not abide by this
-	 * requirement, call your favourite HW vendor, they have screwed up.
-	 *
-	 * We don't expect hVHE to access any userspace mapping, so always
-	 * set PSTATE.PAN on enty. Same thing if we have PAN enabled on an
-	 * EL2 kernel. Only force it to 0 if we have not configured PAN in
-	 * the kernel (and you know this is really silly).
-	 */
-	if (cpus_have_cap(ARM64_KVM_HVHE) || IS_ENABLED(CONFIG_ARM64_PAN))
-		*updptr = cpu_to_le32(ENCODE_PSTATE(1, PAN));
-	else
-		*updptr = cpu_to_le32(ENCODE_PSTATE(0, PAN));
-}
Signature · 1 line
Without deviation from the norm, progress is not possible.
author maintainer
#3 lore raw
In reply to Will Deacon
Quoted 7 lines · Will Deacon
Quoted 1 line · Mark Brown

[Took the version from Linus' tree.]

Hmm, I suspect that's not quite right because CONFIG_ARM64_PAN doesn't exist anymore in the arm64 tree and so the hunk in arch/arm64/kvm/va_layout.c probably needs tweaking.

Indeed - there's updates needed elsewhere.

Quoted 3 lines

Marc -- how would you prefer to handle this? I could bring back CONFIG_ARM64_PAN as a hidden Kconfig option =y and then we could clean up the stragglers at -rc1?

I guess you could also merge up -rc7 given that this is in Linus' tree?

author maintainer
#5 lore raw
In reply to Marc Zyngier
Quoted 4 lines · Marc Zyngier

Keeping the version from Linus' tree doesn't work, as kvm_pan_patch_el2_entry() references CONFIG_ARM64_PAN, which is removed by 018a231b0260e ("arm64: Unconditionally enable PAN support").

I was expecting some fixup to be required in there, yes - at a first glance the VHE based decisions looked like they'd still want to be made, though I didn't check in detail.

Quoted 1 line

So the arm64 version should be the correct one.

I've applied a fixup doing that.