[S390] vmur: diag14 only works with buffers below 2GB

If memory buffers above 2GB are used, diagnose 14 raises a specification
exception. This fix ensures that buffer allocation is done below the 2GB
boundary.

Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by Michael Holzheu and committed by Martin Schwidefsky 3eed13cc 4eac3452

+70 -36
+70 -36
drivers/s390/char/vmur.c
··· 472 472 return rc; 473 473 474 474 len = min((size_t) PAGE_SIZE, count); 475 - buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 475 + buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA); 476 476 if (!buf) 477 477 return -ENOMEM; 478 478 ··· 499 499 *offs += copied; 500 500 rc = copied; 501 501 fail: 502 - kfree(buf); 502 + free_page((unsigned long) buf); 503 503 return rc; 504 504 } 505 505 ··· 542 542 } 543 543 } 544 544 545 - static int verify_device(struct urdev *urd) 545 + static int verify_uri_device(struct urdev *urd) 546 546 { 547 - struct file_control_block fcb; 547 + struct file_control_block *fcb; 548 548 char *buf; 549 549 int rc; 550 550 551 + fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA); 552 + if (!fcb) 553 + return -ENOMEM; 554 + 555 + /* check for empty reader device (beginning of chain) */ 556 + rc = diag_read_next_file_info(fcb, 0); 557 + if (rc) 558 + goto fail_free_fcb; 559 + 560 + /* if file is in hold status, we do not read it */ 561 + if (fcb->file_stat & (FLG_SYSTEM_HOLD | FLG_USER_HOLD)) { 562 + rc = -EPERM; 563 + goto fail_free_fcb; 564 + } 565 + 566 + /* open file on virtual reader */ 567 + buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA); 568 + if (!buf) { 569 + rc = -ENOMEM; 570 + goto fail_free_fcb; 571 + } 572 + rc = diag_read_file(urd->dev_id.devno, buf); 573 + if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */ 574 + goto fail_free_buf; 575 + 576 + /* check if the file on top of the queue is open now */ 577 + rc = diag_read_next_file_info(fcb, 0); 578 + if (rc) 579 + goto fail_free_buf; 580 + if (!(fcb->file_stat & FLG_IN_USE)) { 581 + rc = -EMFILE; 582 + goto fail_free_buf; 583 + } 584 + rc = 0; 585 + 586 + fail_free_buf: 587 + free_page((unsigned long) buf); 588 + fail_free_fcb: 589 + kfree(fcb); 590 + return rc; 591 + } 592 + 593 + static int verify_device(struct urdev *urd) 594 + { 551 595 switch (urd->class) { 552 596 case DEV_CLASS_UR_O: 553 597 return 0; /* no check needed here */ 554 598 case DEV_CLASS_UR_I: 555 - /* check for empty reader device (beginning of chain) */ 556 - rc = diag_read_next_file_info(&fcb, 0); 557 - if (rc) 558 - return rc; 559 - /* if file is in hold status, we do not read it */ 560 - if (fcb.file_stat & (FLG_SYSTEM_HOLD | FLG_USER_HOLD)) 561 - return -EPERM; 562 - /* open file on virtual reader */ 563 - buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 564 - if (!buf) 565 - return -ENOMEM; 566 - rc = diag_read_file(urd->dev_id.devno, buf); 567 - kfree(buf); 568 - if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */ 569 - return rc; 570 - /* check if the file on top of the queue is open now */ 571 - rc = diag_read_next_file_info(&fcb, 0); 572 - if (rc) 573 - return rc; 574 - if (!(fcb.file_stat & FLG_IN_USE)) 575 - return -EMFILE; 576 - return 0; 599 + return verify_uri_device(urd); 577 600 default: 578 601 return -ENOTSUPP; 579 602 } 580 603 } 581 604 582 - static int get_file_reclen(struct urdev *urd) 605 + static int get_uri_file_reclen(struct urdev *urd) 583 606 { 584 - struct file_control_block fcb; 607 + struct file_control_block *fcb; 585 608 int rc; 586 609 610 + fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA); 611 + if (!fcb) 612 + return -ENOMEM; 613 + rc = diag_read_next_file_info(fcb, 0); 614 + if (rc) 615 + goto fail_free; 616 + if (fcb->file_stat & FLG_CP_DUMP) 617 + rc = 0; 618 + else 619 + rc = fcb->rec_len; 620 + 621 + fail_free: 622 + kfree(fcb); 623 + return rc; 624 + } 625 + 626 + static int get_file_reclen(struct urdev *urd) 627 + { 587 628 switch (urd->class) { 588 629 case DEV_CLASS_UR_O: 589 630 return 0; 590 631 case DEV_CLASS_UR_I: 591 - rc = diag_read_next_file_info(&fcb, 0); 592 - if (rc) 593 - return rc; 594 - break; 632 + return get_uri_file_reclen(urd); 595 633 default: 596 634 return -ENOTSUPP; 597 635 } 598 - if (fcb.file_stat & FLG_CP_DUMP) 599 - return 0; 600 - 601 - return fcb.rec_len; 602 636 } 603 637 604 638 static int ur_open(struct inode *inode, struct file *file)