Skip to contentSkip to conversation

s390/cmf: Fix virtual vs physical address confusion

PATCH Superseded Peter Oberparleiter 3 participants 4 messages Sep 18 – Sep 21

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peter Oberparleiter

author maintainer
#0 lore raw

PATCH 1/1 s390/cmf: Fix virtual vs physical address confusion

The measurement block address is an absolute address; therefore add a missing virt_to_phys() translation.

Without this fix, a wrong address will be used by firmware when storing extended format channel measurement data on kernels built with CONFIG_RANDOMIZE_IDENTITY_BASE=y.

---
 drivers/s390/cio/cmf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/cmf.c +1 -1
index 92ab3d546fe4..5f57a12762d2 100644
@@ -183,7 +183,7 @@ static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc,
 	sch->config.mbfc = mbfc;
 	/* address can be either a block address or a block index */
 	if (mbfc)
-		sch->config.mba = address;
+		sch->config.mba = address ? virt_to_phys((void *)address) : 0;
 	else
 		sch->config.mbi = address;
 
Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

The measurement block address is an absolute address; therefore add a missing virt_to_phys() translation.

Without this fix, a wrong address will be used by firmware when storing extended format channel measurement data on kernels built with CONFIG_RANDOMIZE_IDENTITY_BASE=y.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Peter Oberparleiter
Quoted 17 lines · Peter Oberparleiter

The measurement block address is an absolute address; therefore add a missing virt_to_phys() translation.

Without this fix, a wrong address will be used by firmware when storing extended format channel measurement data on kernels built with CONFIG_RANDOMIZE_IDENTITY_BASE=y.

---
 drivers/s390/cio/cmf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/cmf.c +0 -0
index 92ab3d546fe4..5f57a12762d2 100644

drivers/s390/cio/cmf.c static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc, · line 186

Quoted 5 lines
drivers/s390/cio/cmf.c +1 -1
@@ -183,7 +183,7 @@ static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc,
 	sch->config.mbfc = mbfc;
 	/* address can be either a block address or a block index */
 	if (mbfc)
-		sch->config.mba = address;
+		sch->config.mba = address ? virt_to_phys((void *)address) : 0;

Would it make sense to change the type of the mba member in struct schib_config and struct schib to dma64_t, and use virt_to_dma64() instead of virt_to_phys() here?

That would add sparse type checking and would catch similar future bugs.

author maintainer
#3 lore raw
Quoted 28 lines · Heiko Carstens
Quoted 17 lines · Peter Oberparleiter

The measurement block address is an absolute address; therefore add a missing virt_to_phys() translation.

Without this fix, a wrong address will be used by firmware when storing extended format channel measurement data on kernels built with CONFIG_RANDOMIZE_IDENTITY_BASE=y.

---
 drivers/s390/cio/cmf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/cio/cmf.c +0 -0
index 92ab3d546fe4..5f57a12762d2 100644

drivers/s390/cio/cmf.c static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc, · line 186

Quoted 5 lines
drivers/s390/cio/cmf.c +1 -1
@@ -183,7 +183,7 @@ static int set_schib(struct ccw_device *cdev, u32 mme, int mbfc,
 	sch->config.mbfc = mbfc;
 	/* address can be either a block address or a block index */
 	if (mbfc)
-		sch->config.mba = address;
+		sch->config.mba = address ? virt_to_phys((void *)address) : 0;

Would it make sense to change the type of the mba member in struct schib_config and struct schib to dma64_t, and use virt_to_dma64() instead of virt_to_phys() here?

Quoted 1 line

That would add sparse type checking and would catch similar future bugs.

Sounds good - I'll prepare a v2.

Signature · 2 lines
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D