static int mch_init(PCIDevice *d) { int i; MCHPCIState *mch = MCH_PCI_DEVICE(d); /* setup pci memory mapping */ pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory, mch->pci_address_space); /* smram */ cpu_smm_register(&mch_set_smm, mch); memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region", mch->pci_address_space, 0xa0000, 0x20000); memory_region_add_subregion_overlap(mch->system_memory, 0xa0000, &mch->smram_region, 1); memory_region_set_enabled(&mch->smram_region, false); init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < 12; ++i) { init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } /* Intel IOMMU (VT-d) */ if (qemu_opt_get_bool(qemu_get_machine_opts(), "iommu", false)) { mch_init_dmar(mch); } return 0; }
static void mch_realize(PCIDevice *d, Error **errp) { int i; MCHPCIState *mch = MCH_PCI_DEVICE(d); /* setup pci memory mapping */ pc_pci_as_mapping_init(OBJECT(mch), mch->system_memory, mch->pci_address_space); /* if *disabled* show SMRAM to all CPUs */ memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region", mch->pci_address_space, 0xa0000, 0x20000); memory_region_add_subregion_overlap(mch->system_memory, 0xa0000, &mch->smram_region, 1); memory_region_set_enabled(&mch->smram_region, true); memory_region_init_alias(&mch->open_high_smram, OBJECT(mch), "smram-open-high", mch->ram_memory, 0xa0000, 0x20000); memory_region_add_subregion_overlap(mch->system_memory, 0xfeda0000, &mch->open_high_smram, 1); memory_region_set_enabled(&mch->open_high_smram, false); /* smram, as seen by SMM CPUs */ memory_region_init(&mch->smram, OBJECT(mch), "smram", 1ull << 32); memory_region_set_enabled(&mch->smram, true); memory_region_init_alias(&mch->low_smram, OBJECT(mch), "smram-low", mch->ram_memory, 0xa0000, 0x20000); memory_region_set_enabled(&mch->low_smram, true); memory_region_add_subregion(&mch->smram, 0xa0000, &mch->low_smram); memory_region_init_alias(&mch->high_smram, OBJECT(mch), "smram-high", mch->ram_memory, 0xa0000, 0x20000); memory_region_set_enabled(&mch->high_smram, true); memory_region_add_subregion(&mch->smram, 0xfeda0000, &mch->high_smram); memory_region_init_io(&mch->tseg_blackhole, OBJECT(mch), &tseg_blackhole_ops, NULL, "tseg-blackhole", 0); memory_region_set_enabled(&mch->tseg_blackhole, false); memory_region_add_subregion_overlap(mch->system_memory, mch->below_4g_mem_size, &mch->tseg_blackhole, 1); memory_region_init_alias(&mch->tseg_window, OBJECT(mch), "tseg-window", mch->ram_memory, mch->below_4g_mem_size, 0); memory_region_set_enabled(&mch->tseg_window, false); memory_region_add_subregion(&mch->smram, mch->below_4g_mem_size, &mch->tseg_window); object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&mch->smram), &error_abort); init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < 12; ++i) { init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } }
static int mch_init(PCIDevice *d) { int i; hwaddr pci_hole64_size; MCHPCIState *mch = MCH_PCI_DEVICE(d); /* Leave enough space for the biggest MCFG BAR */ /* TODO: this matches current bios behaviour, but * it's not a power of two, which means an MTRR * can't cover it exactly. */ mch->guest_info->pci_info.w32.begin = MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT + MCH_HOST_BRIDGE_PCIEXBAR_MAX; /* setup pci memory regions */ memory_region_init_alias(&mch->pci_hole, OBJECT(mch), "pci-hole", mch->pci_address_space, mch->below_4g_mem_size, 0x100000000ULL - mch->below_4g_mem_size); memory_region_add_subregion(mch->system_memory, mch->below_4g_mem_size, &mch->pci_hole); pci_hole64_size = (sizeof(hwaddr) == 4 ? 0 : ((uint64_t)1 << 62)); memory_region_init_alias(&mch->pci_hole_64bit, OBJECT(mch), "pci-hole64", mch->pci_address_space, 0x100000000ULL + mch->above_4g_mem_size, pci_hole64_size); if (pci_hole64_size) { memory_region_add_subregion(mch->system_memory, 0x100000000ULL + mch->above_4g_mem_size, &mch->pci_hole_64bit); } /* smram */ cpu_smm_register(&mch_set_smm, mch); memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region", mch->pci_address_space, 0xa0000, 0x20000); memory_region_add_subregion_overlap(mch->system_memory, 0xa0000, &mch->smram_region, 1); memory_region_set_enabled(&mch->smram_region, false); init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < 12; ++i) { init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } return 0; }
static int mch_init(PCIDevice *d) { int i; MCHPCIState *mch = MCH_PCI_DEVICE(d); uint64_t pci_hole64_size; /* setup pci memory regions */ memory_region_init_alias(&mch->pci_hole, OBJECT(mch), "pci-hole", mch->pci_address_space, mch->below_4g_mem_size, 0x100000000ULL - mch->below_4g_mem_size); memory_region_add_subregion(mch->system_memory, mch->below_4g_mem_size, &mch->pci_hole); pci_hole64_size = pci_host_get_hole64_size(mch->pci_hole64_size); pc_init_pci64_hole(&mch->pci_info, 0x100000000ULL + mch->above_4g_mem_size, pci_hole64_size); memory_region_init_alias(&mch->pci_hole_64bit, OBJECT(mch), "pci-hole64", mch->pci_address_space, mch->pci_info.w64.begin, pci_hole64_size); if (pci_hole64_size) { memory_region_add_subregion(mch->system_memory, mch->pci_info.w64.begin, &mch->pci_hole_64bit); } /* smram */ cpu_smm_register(&mch_set_smm, mch); memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region", mch->pci_address_space, 0xa0000, 0x20000); memory_region_add_subregion_overlap(mch->system_memory, 0xa0000, &mch->smram_region, 1); memory_region_set_enabled(&mch->smram_region, false); init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[0], PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < 12; ++i) { init_pam(DEVICE(mch), mch->ram_memory, mch->system_memory, mch->pci_address_space, &mch->pam_regions[i+1], PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } return 0; }
/* Entry point of cc1/c++. Decode command args, then call compile_file. Exit code is 35 if can't open files, 34 if fatal error, 33 if had nonfatal errors, else success. */ int main(int argc, char **argv) { register int i; dd_list files, preludes; dd_list_pos cur; int version_flag = 0; char *p; char *config_file = NULL; #ifdef TIMER_USERTIME reset_timer(&total_time); #endif start_timer(&total_time); region_init(); parse_region = newregion(); in_prelude = FALSE; num_hotspots = 0; parsed_files = dd_new_list(parse_region); copy_argc = 0; copy_argv = xmalloc((argc + 1) * sizeof(*copy_argv)); files = dd_new_list(parse_region); preludes = dd_new_list(parse_region); p = argv[0] + strlen (argv[0]); while (p != argv[0] && p[-1] != '/' #ifdef DIR_SEPARATOR && p[-1] != DIR_SEPARATOR #endif ) --p; progname = p; #ifdef SIGPIPE signal (SIGPIPE, pipe_closed); #endif copy_argv[0] = argv[0]; copy_argc = 1; for (i = 1; i < argc; i++) { int j; bool copy_arg = TRUE; /* If this is a language-specific option, decode it in a language-specific way. */ for (j = 0; lang_options[j] != 0; j++) if (!strncmp (argv[i], lang_options[j], strlen (lang_options[j]))) break; if (lang_options[j] != 0) /* If the option is valid for *some* language, treat it as valid even if this language doesn't understand it. */ c_decode_option(argv[i]); else if (argv[i][0] == '-' && argv[i][1] != 0) { register char *str = argv[i] + 1; if (str[0] == 'Y') str++; if (!strcmp (str, "dumpbase")) copy_argv[copy_argc++] = argv[i++]; else if (str[0] == 'f') { register char *p = &str[1]; int found = 0; /* Some kind of -f option. P's value is the option sans `-f'. Search for it in the table of options. */ for (j = 0; !found && j < sizeof (f_options) / sizeof (f_options[0]); j++) { if (!strcmp (p, f_options[j].string)) { *f_options[j].variable = f_options[j].on_value; /* A goto here would be cleaner, but breaks the vax pcc. */ found = 1; } if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' && ! strcmp (p+3, f_options[j].string)) { *f_options[j].variable = ! f_options[j].on_value; found = 1; } } } else if (!strcmp (str, "pedantic")) pedantic = 1; else if (!strcmp (str, "pedantic-errors")) flag_pedantic_errors = pedantic = 1; else if (!strcmp (str, "quiet")) quiet_flag = 1; else if (!strcmp (str, "version")) version_flag = 1; else if (!strcmp (str, "w")) inhibit_warnings = 1; else if (!strcmp (str, "W")) { extra_warnings = 1; /* We save the value of warn_uninitialized, since if they put -Wuninitialized on the command line, we need to generate a warning about not using it without also specifying -O. */ if (warn_uninitialized != 1) warn_uninitialized = 2; } else if (str[0] == 'W') { register char *p = &str[1]; int found = 0; /* Some kind of -W option. P's value is the option sans `-W'. Search for it in the table of options. */ for (j = 0; !found && j < sizeof (W_options) / sizeof (W_options[0]); j++) { if (!strcmp (p, W_options[j].string)) { *W_options[j].variable = W_options[j].on_value; /* A goto here would be cleaner, but breaks the vax pcc. */ found = 1; } if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' && ! strcmp (p+3, W_options[j].string)) { *W_options[j].variable = ! W_options[j].on_value; found = 1; } } if (found) ; else if (!strncmp (p, "id-clash-", 9)) { char *endp = p + 9; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", argv[i]); goto id_clash_lose; } } warn_id_clash = 1; id_clash_len = atoi (str + 10); id_clash_lose: ; } else if (!strncmp (p, "larger-than-", 12)) { char *endp = p + 12; while (*endp) { if (*endp >= '0' && *endp <= '9') endp++; else { error ("Invalid option `%s'", argv[i]); goto larger_than_lose; } } warn_larger_than = 1; larger_than_size = atoi (str + 13); larger_than_lose: ; } } else if (!strcmp (str, "o")) copy_argv[copy_argc++] = argv[i++]; else if (str[0] == 'G') { if (str[1] == '\0') copy_argv[copy_argc++] = argv[i++]; } else if (!strncmp (str, "aux-info", 8)) { if (str[8] == '\0') copy_argv[copy_argc++] = argv[i++]; } else if (!strcmp(str, "config")) { if (i < argc - 1) { i++; config_file = strdup(argv[i]); } else error ("Missing -config file"); } else if (!strcmp(str, "prelude")) { if (i < argc - 1) { i++; dd_add_last(parse_region, preludes, rstrdup(parse_region, argv[i])); } else error("Missing -prelude file"); } else if (!strcmp(str, "hotspots")) { if (i < argc - 1) { i++; num_hotspots = atoi(argv[i]); if (num_hotspots < 0) error("Negative value for -hotspots count"); } else error("Missing -hotspots count"); } else if (!strcmp( str, "program-files")) { if (i < argc - 1) { i++; add_program_files(argv[i], files); } else error("Missing -program-files file"); } } else if (argv[i][0] == '+') ; else { /* Allow wildcards, because PAM won't expand files */ glob_t globbuf; char **cur; if (glob(argv[i], 0, NULL, &globbuf)) { /* glob returned non-zero error status; abort */ fprintf(stderr, "%s: file not found\n", argv[i]); exit(FATAL_EXIT_CODE); } else for (cur = globbuf.gl_pathv; *cur; cur++) { /* Assume anything called prelude.i is a prelude file */ if ( strlen(*cur) >= 9 && !strncmp("prelude.i", *cur + strlen(*cur) - 9, 9)) dd_add_last(parse_region, preludes, rstrdup(parse_region, *cur)); else dd_add_last(parse_region, files, rstrdup(parse_region, *cur)); } copy_arg = FALSE; } if (copy_arg) copy_argv[copy_argc++] = argv[i]; } copy_argv[copy_argc] = NULL; if (flag_casts_preserve && flag_flow_sensitive) { fprintf(stderr, "-fcasts-preserve currently not allowed with " "-fflow_sensitive"); exit(FATAL_EXIT_CODE); } /* Now analyze *all* of the files. First, initialize all appropriate data structures. */ init_types(); cval_init(); init_effects(); init_qtype(); init_quals(); init_qerror(); init_store(); if (config_file) load_config_file_quals(config_file); /* Add const so that we can do -fconst-subtyping no matter what */ if (!const_qual) { begin_po_qual(); const_qual = add_qual("const"); add_level_qual(const_qual, level_ref); set_po_nonprop(); end_po_qual(); } /* Add volatile so we can handle noreturn functions */ if (!volatile_qual) { begin_po_qual(); volatile_qual = add_qual("volatile"); add_level_qual(volatile_qual, level_ref); add_sign_qual(volatile_qual, sign_eq); set_po_nonprop(); end_po_qual(); } /* Add noreturn, for non-returning functions */ if (!noreturn_qual) { begin_po_qual(); noreturn_qual = add_qual("noreturn"); add_level_qual(noreturn_qual, level_value); add_sign_qual(noreturn_qual, sign_eq); set_po_nonprop(); end_po_qual(); } end_define_pos(); /* Allow cqual to run with no qualifiers */ init_pam(); init_analyze(); found_fs_qual = FALSE; /* Force reset, since init_analyze may look up some quals */ /* Now analyze the prelude files */ in_prelude = TRUE; dd_scan(cur, preludes) { char *file; file = DD_GET(char *, cur); fprintf(stderr, "Analyzing prelude %s\n", file); compile_file(file); }
int get_password(pam_handle_t *pamh, const char *username, const char *tty) { uid_t uid = getuid(); for (;;) { int rc; const char *msg; if (!pamh) { pamh = init_pam(username, tty, 1); if (!pamh) { /* Log the fact of failure. */ syslog(LOG_WARNING, "Authentication problems on %s for %s by (uid=%u)", tty, username, uid); puts(_("Please try again later.\n\n\n")); fflush(stdout); sleep(LONG_DELAY); continue; } } if (o_lock_all) { printf(_("The entire console display is now completely locked by %s.\n"), username); } else { printf(_("The %s is now locked by %s.\n"), tty, username); if (is_vt) puts(_("Use Alt-function keys to switch to other virtual consoles.")); } fflush(stdout); /* * No need to request a delay on failure via pam_fail_delay(3): * authentication module should do it for us. */ rc = pam_authenticate(pamh, 0); switch (rc) { case PAM_SUCCESS: rc = do_account_password_management(pamh); if (rc != PAM_SUCCESS) { /* * The user was authenticated but * either account or password management * returned an error. */ printf("%s.\n\n\n", pam_strerror(pamh, rc)); fflush(stdout); pam_end(pamh, rc); pamh = 0; sleep(SHORT_DELAY); break; } pam_end(pamh, rc); /* Log the fact of console unlocking. */ syslog(LOG_NOTICE, "Unlocked %s on %s for %s by (uid=%u)", locked_name(), tty, username, uid); return EXIT_SUCCESS; case PAM_MAXTRIES: case PAM_ABORT: msg = pam_strerror(pamh, rc); /* Log the fact of failure. */ syslog(LOG_WARNING, "%s", msg); printf("%s.\n\n\n", msg); fflush(stdout); msg = 0; pam_end(pamh, rc); pamh = 0; sleep(LONG_DELAY); break; default: printf("%s.\n\n\n", pam_strerror(pamh, rc)); fflush(stdout); /* * EOF encountered on read? * Check stdin. */ if (isatty(STDIN_FILENO)) { /* Ignore error. */ sleep(SHORT_DELAY); break; } /* Cancel locking. */ pam_end(pamh, rc); syslog(LOG_NOTICE, "Cancelled lock of %s on %s for %s by (uid=%u)", locked_name(), tty, username, uid); return EXIT_FAILURE; } } }