Skip to content

Commit bda3563

Browse files
borntraegerMartin Schwidefsky
authored andcommitted
[S390] cpcmd with vmalloc addresses.
Change the bounce buffer logic of cpcmd. diag8 needs _real_ memory below 2GB. Therefore vmalloced data does not work. As the data might cross a page boundary, we cannot use virt_to_page either. The solution is to use virt_to_page only in the check for a bounce buffer. There was a redundant check for response==NULL. response < 2GB contains this check as well. I also removed the rlen==0 check, since rlen=0 and response!=NULL would be a caller bug and response==NULL is already checked. Signed-off-by: Christian Borntraeger <cborntra@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 6038320 commit bda3563

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎arch/s390/kernel/cpcmd.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <asm/ebcdic.h>
1717
#include <asm/cpcmd.h>
1818
#include <asm/system.h>
19+
#include <asm/io.h>
1920

2021
static DEFINE_SPINLOCK(cpcmd_lock);
2122
static char cpcmd_buf[241];
@@ -88,13 +89,8 @@ int cpcmd(const char *cmd, char *response, int rlen, int *response_code)
8889
int len;
8990
unsigned long flags;
9091

91-
if ((rlen == 0) || (response == NULL)
92-
|| !((unsigned long)response >> 31)) {
93-
spin_lock_irqsave(&cpcmd_lock, flags);
94-
len = __cpcmd(cmd, response, rlen, response_code);
95-
spin_unlock_irqrestore(&cpcmd_lock, flags);
96-
}
97-
else {
92+
if ((virt_to_phys(response) != (unsigned long) response) ||
93+
(((unsigned long)response + rlen) >> 31)) {
9894
lowbuf = kmalloc(rlen, GFP_KERNEL | GFP_DMA);
9995
if (!lowbuf) {
10096
printk(KERN_WARNING
@@ -106,6 +102,10 @@ int cpcmd(const char *cmd, char *response, int rlen, int *response_code)
106102
spin_unlock_irqrestore(&cpcmd_lock, flags);
107103
memcpy(response, lowbuf, rlen);
108104
kfree(lowbuf);
105+
} else {
106+
spin_lock_irqsave(&cpcmd_lock, flags);
107+
len = __cpcmd(cmd, response, rlen, response_code);
108+
spin_unlock_irqrestore(&cpcmd_lock, flags);
109109
}
110110
return len;
111111
}

0 commit comments

Comments
 (0)