bhyverun.c revision 264273
1/*- 2 * Copyright (c) 2011 NetApp, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $FreeBSD: stable/10/usr.sbin/bhyve/bhyverun.c 264273 2014-04-08 20:40:54Z jhb $ 27 */ 28 29#include <sys/cdefs.h> 30__FBSDID("$FreeBSD: stable/10/usr.sbin/bhyve/bhyverun.c 264273 2014-04-08 20:40:54Z jhb $"); 31 32#include <sys/types.h> 33#include <sys/mman.h> 34#include <sys/time.h> 35 36#include <machine/atomic.h> 37#include <machine/segments.h> 38 39#include <stdio.h> 40#include <stdlib.h> 41#include <string.h> 42#include <err.h> 43#include <libgen.h> 44#include <unistd.h> 45#include <assert.h> 46#include <errno.h> 47#include <pthread.h> 48#include <pthread_np.h> 49#include <sysexits.h> 50 51#include <machine/vmm.h> 52#include <vmmapi.h> 53 54#include "bhyverun.h" 55#include "acpi.h" 56#include "inout.h" 57#include "dbgport.h" 58#include "legacy_irq.h" 59#include "mem.h" 60#include "mevent.h" 61#include "mptbl.h" 62#include "pci_emul.h" 63#include "pci_lpc.h" 64#include "xmsr.h" 65#include "spinup_ap.h" 66#include "rtc.h" 67 68#define GUEST_NIO_PORT 0x488 /* guest upcalls via i/o port */ 69 70#define VMEXIT_SWITCH 0 /* force vcpu switch in mux mode */ 71#define VMEXIT_CONTINUE 1 /* continue from next instruction */ 72#define VMEXIT_RESTART 2 /* restart current instruction */ 73#define VMEXIT_ABORT 3 /* abort the vm run loop */ 74#define VMEXIT_RESET 4 /* guest machine has reset */ 75#define VMEXIT_POWEROFF 5 /* guest machine has powered off */ 76 77#define MB (1024UL * 1024) 78#define GB (1024UL * MB) 79 80typedef int (*vmexit_handler_t)(struct vmctx *, struct vm_exit *, int *vcpu); 81 82char *vmname; 83 84int guest_ncpus; 85 86static int pincpu = -1; 87static int guest_vmexit_on_hlt, guest_vmexit_on_pause, disable_x2apic; 88static int virtio_msix = 1; 89 90static int strictio; 91static int strictmsr = 1; 92 93static int acpi; 94 95static char *progname; 96static const int BSP = 0; 97 98static int cpumask; 99 100static void vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip); 101 102struct vm_exit vmexit[VM_MAXCPU]; 103 104struct bhyvestats { 105 uint64_t vmexit_bogus; 106 uint64_t vmexit_bogus_switch; 107 uint64_t vmexit_hlt; 108 uint64_t vmexit_pause; 109 uint64_t vmexit_mtrap; 110 uint64_t vmexit_inst_emul; 111 uint64_t cpu_switch_rotate; 112 uint64_t cpu_switch_direct; 113 int io_reset; 114} stats; 115 116struct mt_vmm_info { 117 pthread_t mt_thr; 118 struct vmctx *mt_ctx; 119 int mt_vcpu; 120} mt_vmm_info[VM_MAXCPU]; 121 122static void 123usage(int code) 124{ 125 126 fprintf(stderr, 127 "Usage: %s [-aehwAHIPW] [-g <gdb port>] [-s <pci>] [-S <pci>]\n" 128 " %*s [-c vcpus] [-p pincpu] [-m mem] [-l <lpc>] <vm>\n" 129 " -a: local apic is in XAPIC mode (default is X2APIC)\n" 130 " -A: create an ACPI table\n" 131 " -g: gdb port\n" 132 " -c: # cpus (default 1)\n" 133 " -p: pin vcpu 'n' to host cpu 'pincpu + n'\n" 134 " -H: vmexit from the guest on hlt\n" 135 " -P: vmexit from the guest on pause\n" 136 " -W: force virtio to use single-vector MSI\n" 137 " -e: exit on unhandled I/O access\n" 138 " -h: help\n" 139 " -s: <slot,driver,configinfo> PCI slot config\n" 140 " -S: <slot,driver,configinfo> legacy PCI slot config\n" 141 " -l: LPC device configuration\n" 142 " -m: memory size in MB\n" 143 " -w: ignore unimplemented MSRs\n", 144 progname, (int)strlen(progname), ""); 145 146 exit(code); 147} 148 149void * 150paddr_guest2host(struct vmctx *ctx, uintptr_t gaddr, size_t len) 151{ 152 153 return (vm_map_gpa(ctx, gaddr, len)); 154} 155 156int 157fbsdrun_disable_x2apic(void) 158{ 159 160 return (disable_x2apic); 161} 162 163int 164fbsdrun_vmexit_on_pause(void) 165{ 166 167 return (guest_vmexit_on_pause); 168} 169 170int 171fbsdrun_vmexit_on_hlt(void) 172{ 173 174 return (guest_vmexit_on_hlt); 175} 176 177int 178fbsdrun_virtio_msix(void) 179{ 180 181 return (virtio_msix); 182} 183 184static void * 185fbsdrun_start_thread(void *param) 186{ 187 char tname[MAXCOMLEN + 1]; 188 struct mt_vmm_info *mtp; 189 int vcpu; 190 191 mtp = param; 192 vcpu = mtp->mt_vcpu; 193 194 snprintf(tname, sizeof(tname), "vcpu %d", vcpu); 195 pthread_set_name_np(mtp->mt_thr, tname); 196 197 vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip); 198 199 /* not reached */ 200 exit(1); 201 return (NULL); 202} 203 204void 205fbsdrun_addcpu(struct vmctx *ctx, int vcpu, uint64_t rip) 206{ 207 int error; 208 209 if (cpumask & (1 << vcpu)) { 210 fprintf(stderr, "addcpu: attempting to add existing cpu %d\n", 211 vcpu); 212 exit(1); 213 } 214 215 atomic_set_int(&cpumask, 1 << vcpu); 216 217 /* 218 * Set up the vmexit struct to allow execution to start 219 * at the given RIP 220 */ 221 vmexit[vcpu].rip = rip; 222 vmexit[vcpu].inst_length = 0; 223 224 mt_vmm_info[vcpu].mt_ctx = ctx; 225 mt_vmm_info[vcpu].mt_vcpu = vcpu; 226 227 error = pthread_create(&mt_vmm_info[vcpu].mt_thr, NULL, 228 fbsdrun_start_thread, &mt_vmm_info[vcpu]); 229 assert(error == 0); 230} 231 232static int 233fbsdrun_deletecpu(struct vmctx *ctx, int vcpu) 234{ 235 236 if ((cpumask & (1 << vcpu)) == 0) { 237 fprintf(stderr, "addcpu: attempting to delete unknown cpu %d\n", 238 vcpu); 239 exit(1); 240 } 241 242 atomic_clear_int(&cpumask, 1 << vcpu); 243 return (cpumask == 0); 244} 245 246static int 247vmexit_catch_reset(void) 248{ 249 stats.io_reset++; 250 return (VMEXIT_RESET); 251} 252 253static int 254vmexit_catch_inout(void) 255{ 256 return (VMEXIT_ABORT); 257} 258 259static int 260vmexit_handle_notify(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu, 261 uint32_t eax) 262{ 263#if BHYVE_DEBUG 264 /* 265 * put guest-driven debug here 266 */ 267#endif 268 return (VMEXIT_CONTINUE); 269} 270 271static int 272vmexit_inout(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 273{ 274 int error; 275 int bytes, port, in, out; 276 uint32_t eax; 277 int vcpu; 278 279 vcpu = *pvcpu; 280 281 port = vme->u.inout.port; 282 bytes = vme->u.inout.bytes; 283 eax = vme->u.inout.eax; 284 in = vme->u.inout.in; 285 out = !in; 286 287 /* We don't deal with these */ 288 if (vme->u.inout.string || vme->u.inout.rep) 289 return (VMEXIT_ABORT); 290 291 /* Special case of guest reset */ 292 if (out && port == 0x64 && (uint8_t)eax == 0xFE) 293 return (vmexit_catch_reset()); 294 295 /* Extra-special case of host notifications */ 296 if (out && port == GUEST_NIO_PORT) 297 return (vmexit_handle_notify(ctx, vme, pvcpu, eax)); 298 299 error = emulate_inout(ctx, vcpu, in, port, bytes, &eax, strictio); 300 if (error == INOUT_OK && in) 301 error = vm_set_register(ctx, vcpu, VM_REG_GUEST_RAX, eax); 302 303 switch (error) { 304 case INOUT_OK: 305 return (VMEXIT_CONTINUE); 306 case INOUT_RESET: 307 return (VMEXIT_RESET); 308 case INOUT_POWEROFF: 309 return (VMEXIT_POWEROFF); 310 default: 311 fprintf(stderr, "Unhandled %s%c 0x%04x\n", 312 in ? "in" : "out", 313 bytes == 1 ? 'b' : (bytes == 2 ? 'w' : 'l'), port); 314 return (vmexit_catch_inout()); 315 } 316} 317 318static int 319vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 320{ 321 uint64_t val; 322 uint32_t eax, edx; 323 int error; 324 325 val = 0; 326 error = emulate_rdmsr(ctx, *pvcpu, vme->u.msr.code, &val); 327 if (error != 0) { 328 fprintf(stderr, "rdmsr to register %#x on vcpu %d\n", 329 vme->u.msr.code, *pvcpu); 330 if (strictmsr) 331 return (VMEXIT_ABORT); 332 } 333 334 eax = val; 335 error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RAX, eax); 336 assert(error == 0); 337 338 edx = val >> 32; 339 error = vm_set_register(ctx, *pvcpu, VM_REG_GUEST_RDX, edx); 340 assert(error == 0); 341 342 return (VMEXIT_CONTINUE); 343} 344 345static int 346vmexit_wrmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 347{ 348 int error; 349 350 error = emulate_wrmsr(ctx, *pvcpu, vme->u.msr.code, vme->u.msr.wval); 351 if (error != 0) { 352 fprintf(stderr, "wrmsr to register %#x(%#lx) on vcpu %d\n", 353 vme->u.msr.code, vme->u.msr.wval, *pvcpu); 354 if (strictmsr) 355 return (VMEXIT_ABORT); 356 } 357 return (VMEXIT_CONTINUE); 358} 359 360static int 361vmexit_spinup_ap(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 362{ 363 int newcpu; 364 int retval = VMEXIT_CONTINUE; 365 366 newcpu = spinup_ap(ctx, *pvcpu, 367 vme->u.spinup_ap.vcpu, vme->u.spinup_ap.rip); 368 369 return (retval); 370} 371 372static int 373vmexit_spindown_cpu(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu) 374{ 375 int lastcpu; 376 377 lastcpu = fbsdrun_deletecpu(ctx, *pvcpu); 378 if (!lastcpu) 379 pthread_exit(NULL); 380 return (vmexit_catch_reset()); 381} 382 383static int 384vmexit_vmx(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 385{ 386 387 fprintf(stderr, "vm exit[%d]\n", *pvcpu); 388 fprintf(stderr, "\treason\t\tVMX\n"); 389 fprintf(stderr, "\trip\t\t0x%016lx\n", vmexit->rip); 390 fprintf(stderr, "\tinst_length\t%d\n", vmexit->inst_length); 391 fprintf(stderr, "\terror\t\t%d\n", vmexit->u.vmx.error); 392 fprintf(stderr, "\texit_reason\t%u\n", vmexit->u.vmx.exit_reason); 393 fprintf(stderr, "\tqualification\t0x%016lx\n", 394 vmexit->u.vmx.exit_qualification); 395 396 return (VMEXIT_ABORT); 397} 398 399static int 400vmexit_bogus(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 401{ 402 403 stats.vmexit_bogus++; 404 405 return (VMEXIT_RESTART); 406} 407 408static int 409vmexit_hlt(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 410{ 411 412 stats.vmexit_hlt++; 413 414 /* 415 * Just continue execution with the next instruction. We use 416 * the HLT VM exit as a way to be friendly with the host 417 * scheduler. 418 */ 419 return (VMEXIT_CONTINUE); 420} 421 422static int 423vmexit_pause(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 424{ 425 426 stats.vmexit_pause++; 427 428 return (VMEXIT_CONTINUE); 429} 430 431static int 432vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 433{ 434 435 stats.vmexit_mtrap++; 436 437 return (VMEXIT_RESTART); 438} 439 440static int 441vmexit_inst_emul(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu) 442{ 443 int err; 444 stats.vmexit_inst_emul++; 445 446 err = emulate_mem(ctx, *pvcpu, vmexit->u.inst_emul.gpa, 447 &vmexit->u.inst_emul.vie); 448 449 if (err) { 450 if (err == EINVAL) { 451 fprintf(stderr, 452 "Failed to emulate instruction at 0x%lx\n", 453 vmexit->rip); 454 } else if (err == ESRCH) { 455 fprintf(stderr, "Unhandled memory access to 0x%lx\n", 456 vmexit->u.inst_emul.gpa); 457 } 458 459 return (VMEXIT_ABORT); 460 } 461 462 return (VMEXIT_CONTINUE); 463} 464 465static vmexit_handler_t handler[VM_EXITCODE_MAX] = { 466 [VM_EXITCODE_INOUT] = vmexit_inout, 467 [VM_EXITCODE_VMX] = vmexit_vmx, 468 [VM_EXITCODE_BOGUS] = vmexit_bogus, 469 [VM_EXITCODE_RDMSR] = vmexit_rdmsr, 470 [VM_EXITCODE_WRMSR] = vmexit_wrmsr, 471 [VM_EXITCODE_MTRAP] = vmexit_mtrap, 472 [VM_EXITCODE_INST_EMUL] = vmexit_inst_emul, 473 [VM_EXITCODE_SPINUP_AP] = vmexit_spinup_ap, 474 [VM_EXITCODE_SPINDOWN_CPU] = vmexit_spindown_cpu, 475}; 476 477static void 478vm_loop(struct vmctx *ctx, int vcpu, uint64_t rip) 479{ 480 cpuset_t mask; 481 int error, rc, prevcpu; 482 enum vm_exitcode exitcode; 483 484 if (pincpu >= 0) { 485 CPU_ZERO(&mask); 486 CPU_SET(pincpu + vcpu, &mask); 487 error = pthread_setaffinity_np(pthread_self(), 488 sizeof(mask), &mask); 489 assert(error == 0); 490 } 491 492 while (1) { 493 error = vm_run(ctx, vcpu, rip, &vmexit[vcpu]); 494 if (error != 0) { 495 /* 496 * It is possible that 'vmmctl' or some other process 497 * has transitioned the vcpu to CANNOT_RUN state right 498 * before we tried to transition it to RUNNING. 499 * 500 * This is expected to be temporary so just retry. 501 */ 502 if (errno == EBUSY) 503 continue; 504 else 505 break; 506 } 507 508 prevcpu = vcpu; 509 510 exitcode = vmexit[vcpu].exitcode; 511 if (exitcode >= VM_EXITCODE_MAX || handler[exitcode] == NULL) { 512 fprintf(stderr, "vm_loop: unexpected exitcode 0x%x\n", 513 exitcode); 514 exit(1); 515 } 516 517 rc = (*handler[exitcode])(ctx, &vmexit[vcpu], &vcpu); 518 519 switch (rc) { 520 case VMEXIT_CONTINUE: 521 rip = vmexit[vcpu].rip + vmexit[vcpu].inst_length; 522 break; 523 case VMEXIT_RESTART: 524 rip = vmexit[vcpu].rip; 525 break; 526 case VMEXIT_RESET: 527 exit(0); 528 default: 529 exit(1); 530 } 531 } 532 fprintf(stderr, "vm_run error %d, errno %d\n", error, errno); 533} 534 535static int 536num_vcpus_allowed(struct vmctx *ctx) 537{ 538 int tmp, error; 539 540 error = vm_get_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, &tmp); 541 542 /* 543 * The guest is allowed to spinup more than one processor only if the 544 * UNRESTRICTED_GUEST capability is available. 545 */ 546 if (error == 0) 547 return (VM_MAXCPU); 548 else 549 return (1); 550} 551 552void 553fbsdrun_set_capabilities(struct vmctx *ctx, int cpu) 554{ 555 int err, tmp; 556 557 if (fbsdrun_vmexit_on_hlt()) { 558 err = vm_get_capability(ctx, cpu, VM_CAP_HALT_EXIT, &tmp); 559 if (err < 0) { 560 fprintf(stderr, "VM exit on HLT not supported\n"); 561 exit(1); 562 } 563 vm_set_capability(ctx, cpu, VM_CAP_HALT_EXIT, 1); 564 if (cpu == BSP) 565 handler[VM_EXITCODE_HLT] = vmexit_hlt; 566 } 567 568 if (fbsdrun_vmexit_on_pause()) { 569 /* 570 * pause exit support required for this mode 571 */ 572 err = vm_get_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, &tmp); 573 if (err < 0) { 574 fprintf(stderr, 575 "SMP mux requested, no pause support\n"); 576 exit(1); 577 } 578 vm_set_capability(ctx, cpu, VM_CAP_PAUSE_EXIT, 1); 579 if (cpu == BSP) 580 handler[VM_EXITCODE_PAUSE] = vmexit_pause; 581 } 582 583 if (fbsdrun_disable_x2apic()) 584 err = vm_set_x2apic_state(ctx, cpu, X2APIC_DISABLED); 585 else 586 err = vm_set_x2apic_state(ctx, cpu, X2APIC_ENABLED); 587 588 if (err) { 589 fprintf(stderr, "Unable to set x2apic state (%d)\n", err); 590 exit(1); 591 } 592 593 vm_set_capability(ctx, cpu, VM_CAP_ENABLE_INVPCID, 1); 594} 595 596int 597main(int argc, char *argv[]) 598{ 599 int c, error, gdb_port, err, bvmcons; 600 int max_vcpus; 601 struct vmctx *ctx; 602 uint64_t rip; 603 size_t memsize; 604 605 bvmcons = 0; 606 progname = basename(argv[0]); 607 gdb_port = 0; 608 guest_ncpus = 1; 609 memsize = 256 * MB; 610 611 while ((c = getopt(argc, argv, "abehwAHIPWp:g:c:s:S:m:l:")) != -1) { 612 switch (c) { 613 case 'a': 614 disable_x2apic = 1; 615 break; 616 case 'A': 617 acpi = 1; 618 break; 619 case 'b': 620 bvmcons = 1; 621 break; 622 case 'p': 623 pincpu = atoi(optarg); 624 break; 625 case 'c': 626 guest_ncpus = atoi(optarg); 627 break; 628 case 'g': 629 gdb_port = atoi(optarg); 630 break; 631 case 'l': 632 if (lpc_device_parse(optarg) != 0) { 633 errx(EX_USAGE, "invalid lpc device " 634 "configuration '%s'", optarg); 635 } 636 break; 637 case 's': 638 if (pci_parse_slot(optarg, 0) != 0) 639 exit(1); 640 else 641 break; 642 case 'S': 643 if (pci_parse_slot(optarg, 1) != 0) 644 exit(1); 645 else 646 break; 647 case 'm': 648 error = vm_parse_memsize(optarg, &memsize); 649 if (error) 650 errx(EX_USAGE, "invalid memsize '%s'", optarg); 651 break; 652 case 'H': 653 guest_vmexit_on_hlt = 1; 654 break; 655 case 'I': 656 /* 657 * The "-I" option was used to add an ioapic to the 658 * virtual machine. 659 * 660 * An ioapic is now provided unconditionally for each 661 * virtual machine and this option is now deprecated. 662 */ 663 break; 664 case 'P': 665 guest_vmexit_on_pause = 1; 666 break; 667 case 'e': 668 strictio = 1; 669 break; 670 case 'w': 671 strictmsr = 0; 672 break; 673 case 'W': 674 virtio_msix = 0; 675 break; 676 case 'h': 677 usage(0); 678 default: 679 usage(1); 680 } 681 } 682 argc -= optind; 683 argv += optind; 684 685 if (argc != 1) 686 usage(1); 687 688 vmname = argv[0]; 689 690 ctx = vm_open(vmname); 691 if (ctx == NULL) { 692 perror("vm_open"); 693 exit(1); 694 } 695 696 max_vcpus = num_vcpus_allowed(ctx); 697 if (guest_ncpus > max_vcpus) { 698 fprintf(stderr, "%d vCPUs requested but only %d available\n", 699 guest_ncpus, max_vcpus); 700 exit(1); 701 } 702 703 fbsdrun_set_capabilities(ctx, BSP); 704 705 err = vm_setup_memory(ctx, memsize, VM_MMAP_ALL); 706 if (err) { 707 fprintf(stderr, "Unable to setup memory (%d)\n", err); 708 exit(1); 709 } 710 711 init_mem(); 712 init_inout(); 713 legacy_irq_init(); 714 715 rtc_init(ctx); 716 717 /* 718 * Exit if a device emulation finds an error in it's initilization 719 */ 720 if (init_pci(ctx) != 0) 721 exit(1); 722 723 if (gdb_port != 0) 724 init_dbgport(gdb_port); 725 726 if (bvmcons) 727 init_bvmcons(); 728 729 error = vm_get_register(ctx, BSP, VM_REG_GUEST_RIP, &rip); 730 assert(error == 0); 731 732 /* 733 * build the guest tables, MP etc. 734 */ 735 mptable_build(ctx, guest_ncpus); 736 737 if (acpi) { 738 error = acpi_build(ctx, guest_ncpus); 739 assert(error == 0); 740 } 741 742 /* 743 * Change the proc title to include the VM name. 744 */ 745 setproctitle("%s", vmname); 746 747 /* 748 * Add CPU 0 749 */ 750 fbsdrun_addcpu(ctx, BSP, rip); 751 752 /* 753 * Head off to the main event dispatch loop 754 */ 755 mevent_dispatch(); 756 757 exit(1); 758} 759