Skip to contentSkip to conversation

s390: nmi: fix virtual-physical address confusion

PATCH Superseded Nico Boehr 4 participants 6 messages Feb 15, 2023 – Feb 16, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Nico Boehr

author
#0 lore raw

cover s390: nmi: fix virtual-physical address confusion

When a machine check is received while in SIE, it is reinjected into the guest in some cases. The respective code needs to access the sie_block, which is taken from the backed up R14.

Since reinjection only occurs while we are in SIE (i.e. between the labels sie_entry and sie_leave in entry.S and thus if CIF_MCCK_GUEST is set), the backed up R14 will always contain a physical address in s390_backup_mcck_info.

This currently works, because virtual and physical addresses are the same.

Add phys_to_virt() to resolve the virtual-physical confusion.

Nico Boehr (1):
s390: nmi: fix virtual-physical address confusion

 arch/s390/kernel/nmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.39.1
author
#1 lore raw

PATCH 1/1 s390: nmi: fix virtual-physical address confusion

When a machine check is received while in SIE, it is reinjected into the guest in some cases. The respective code needs to access the sie_block, which is taken from the backed up R14.

Since reinjection only occurs while we are in SIE (i.e. between the labels sie_entry and sie_leave in entry.S and thus if CIF_MCCK_GUEST is set), the backed up R14 will always contain a physical address in s390_backup_mcck_info.

This currently works, because virtual and physical addresses are the same.

Add phys_to_virt() to resolve the virtual-physical confusion.

---
 arch/s390/kernel/nmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/nmi.c +1 -1
index 5dbf274719a9..322160328866 100644
@@ -347,7 +347,7 @@ static void notrace s390_backup_mcck_info(struct pt_regs *regs)
 
 	/* r14 contains the sie block, which was set in sie64a */
 	struct kvm_s390_sie_block *sie_block =
-			(struct kvm_s390_sie_block *) regs->gprs[14];
+			(struct kvm_s390_sie_block *)phys_to_virt(regs->gprs[14]);
 
 	if (sie_block == NULL)
 		/* Something's seriously wrong, stop system. */
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#2 lore raw
Quoted 9 lines · On Wed, 15 Feb 2023 17:02:52 +0100 Nico Boehr <[email protected]> wrote:

When a machine check is received while in SIE, it is reinjected into the guest in some cases. The respective code needs to access the sie_block, which is taken from the backed up R14.

Since reinjection only occurs while we are in SIE (i.e. between the labels sie_entry and sie_leave in entry.S and thus if CIF_MCCK_GUEST is set), the backed up R14 will always contain a physical address in s390_backup_mcck_info.

Quoted 6 lines

This currently works, because virtual and physical addresses are the same.

Add phys_to_virt() to resolve the virtual-physical confusion.

Quoted 17 lines
---
 arch/s390/kernel/nmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/nmi.c +1 -1
index 5dbf274719a9..322160328866 100644
@@ -347,7 +347,7 @@ static void notrace s390_backup_mcck_info(struct pt_regs *regs)
 
 	/* r14 contains the sie block, which was set in sie64a */
 	struct kvm_s390_sie_block *sie_block =
-			(struct kvm_s390_sie_block *) regs->gprs[14];
+			(struct kvm_s390_sie_block *)phys_to_virt(regs->gprs[14]);
 
 	if (sie_block == NULL)
 		/* Something's seriously wrong, stop system. */
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to Nico Boehr
Quoted 24 lines · Nico Boehr

When a machine check is received while in SIE, it is reinjected into the guest in some cases. The respective code needs to access the sie_block, which is taken from the backed up R14.

Since reinjection only occurs while we are in SIE (i.e. between the labels sie_entry and sie_leave in entry.S and thus if CIF_MCCK_GUEST is set), the backed up R14 will always contain a physical address in s390_backup_mcck_info.

This currently works, because virtual and physical addresses are the same.

Add phys_to_virt() to resolve the virtual-physical confusion.

---
 arch/s390/kernel/nmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/nmi.c +0 -0
index 5dbf274719a9..322160328866 100644

arch/s390/kernel/nmi.c static void notrace s390_backup_mcck_info(struct pt_regs *regs) · line 350

Quoted 5 lines
arch/s390/kernel/nmi.c +1 -1
@@ -347,7 +347,7 @@ static void notrace s390_backup_mcck_info(struct pt_regs *regs)
 
 	/* r14 contains the sie block, which was set in sie64a */
 	struct kvm_s390_sie_block *sie_block =
-			(struct kvm_s390_sie_block *) regs->gprs[14];
+			(struct kvm_s390_sie_block *)phys_to_virt(regs->gprs[14]);

Casting to (struct kvm_s390_sie_block *) is not superfluous, since phys_to_virt() returns (void *).

arch/s390/kernel/nmi.c static void notrace s390_backup_mcck_info(struct pt_regs *regs) · line 353

Quoted 3 lines
arch/s390/kernel/nmi.c +0 -0
 	if (sie_block == NULL)
 		/* Something's seriously wrong, stop system. */
#4 lore raw
Quoted 1 line · Alexander Gordeev

Casting to (struct kvm_s390_sie_block *) is not superfluous,

s/not//

#5 lore raw
Quoted 4 lines · Alexander Gordeev
Quoted 1 line · Alexander Gordeev

Casting to (struct kvm_s390_sie_block *) is not superfluous,

s/not//

Do you want to pick this up or should it go through the kvm tree?