svn commit: r354645 - head/sys/dev/nvdimm
Author: scottph Date: Tue Nov 12 15:50:30 2019 New Revision: 354645 URL: https://svnweb.freebsd.org/changeset/base/354645 Log: nvdimm(4): Only expose namespaces for accessible data SPAs Apply the same user accessible filter to namespaces as is applied to full-SPA devices. Also, explicitly filter out control region SPAs which don't expose the nvdimm data area. Reviewed by: cem Approved by: scottl (mentor) MFC after:1 week Sponsored by: Intel Corporation Differential Revision:https://reviews.freebsd.org/D21987 Modified: head/sys/dev/nvdimm/nvdimm_acpi.c head/sys/dev/nvdimm/nvdimm_spa.c head/sys/dev/nvdimm/nvdimm_var.h Modified: head/sys/dev/nvdimm/nvdimm_acpi.c == --- head/sys/dev/nvdimm/nvdimm_acpi.c Tue Nov 12 15:47:46 2019 (r354644) +++ head/sys/dev/nvdimm/nvdimm_acpi.c Tue Nov 12 15:50:30 2019 (r354645) @@ -144,7 +144,9 @@ nvdimm_root_create_spas(struct nvdimm_root_dev *dev, A free(spa_mapping, M_NVDIMM_ACPI); break; } - nvdimm_create_namespaces(spa_mapping, nfitbl); + if (nvdimm_spa_type_user_accessible(spa_type) && + spa_type != SPA_TYPE_CONTROL_REGION) + nvdimm_create_namespaces(spa_mapping, nfitbl); SLIST_INSERT_HEAD(&dev->spas, spa_mapping, link); } free(spas, M_NVDIMM_ACPI); Modified: head/sys/dev/nvdimm/nvdimm_spa.c == --- head/sys/dev/nvdimm/nvdimm_spa.cTue Nov 12 15:47:46 2019 (r354644) +++ head/sys/dev/nvdimm/nvdimm_spa.cTue Nov 12 15:50:30 2019 (r354645) @@ -155,6 +155,15 @@ nvdimm_spa_type_from_uuid(struct uuid *uuid) return (SPA_TYPE_UNKNOWN); } +bool +nvdimm_spa_type_user_accessible(enum SPA_mapping_type spa_type) +{ + + if ((int)spa_type < 0 || spa_type >= nitems(nvdimm_SPA_uuid_list)) + return (false); + return (nvdimm_SPA_uuid_list[spa_type].u_usr_acc); +} + static vm_memattr_t nvdimm_spa_memattr(uint64_t efi_mem_flags) { Modified: head/sys/dev/nvdimm/nvdimm_var.h == --- head/sys/dev/nvdimm/nvdimm_var.hTue Nov 12 15:47:46 2019 (r354644) +++ head/sys/dev/nvdimm/nvdimm_var.hTue Nov 12 15:50:30 2019 (r354645) @@ -166,6 +166,7 @@ void acpi_nfit_get_flush_addrs(ACPI_TABLE_NFIT *nfitbl uint64_t ***listp, int *countp); enum SPA_mapping_type nvdimm_spa_type_from_name(const char *); enum SPA_mapping_type nvdimm_spa_type_from_uuid(struct uuid *); +bool nvdimm_spa_type_user_accessible(enum SPA_mapping_type); struct nvdimm_dev *nvdimm_find_by_handle(nfit_handle_t nv_handle); int nvdimm_spa_init(struct SPA_mapping *spa, ACPI_NFIT_SYSTEM_ADDRESS *nfitaddr, enum SPA_mapping_type spa_type); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r354648 - head/sys/dev/nvdimm
Author: scottph Date: Tue Nov 12 16:24:37 2019 New Revision: 354648 URL: https://svnweb.freebsd.org/changeset/base/354648 Log: nvdimm(4): Fix various problems when the using the second label index block struct nvdimm_label_index is dynamically sized, with the `free` bitfield expanding to hold `slot_cnt` entries. Fix a few places where we were treating the struct as though it had a fixed sized. Reviewed by: cem Approved by: scottl (mentor) MFC after:1 week Sponsored by: Intel Corporation Differential Revision:https://reviews.freebsd.org/D22253 Modified: head/sys/dev/nvdimm/nvdimm.c Modified: head/sys/dev/nvdimm/nvdimm.c == --- head/sys/dev/nvdimm/nvdimm.cTue Nov 12 15:56:27 2019 (r354647) +++ head/sys/dev/nvdimm/nvdimm.cTue Nov 12 16:24:37 2019 (r354648) @@ -183,7 +183,7 @@ label_index_is_valid(struct nvdimm_label_index *index, { uint64_t checksum; - index = (struct nvdimm_label_index *)((uint8_t *)index + offset); + index = (struct nvdimm_label_index *)((uint8_t *)index + size * offset); if (strcmp(index->signature, NVDIMM_INDEX_BLOCK_SIGNATURE) != 0) return false; checksum = index->checksum; @@ -242,7 +242,7 @@ read_label(struct nvdimm_dev *nv, int num) static int read_labels(struct nvdimm_dev *nv) { - struct nvdimm_label_index *indices; + struct nvdimm_label_index *indices, *index1; size_t bitfield_size, index_size, num_labels; int error, n; bool index_0_valid, index_1_valid; @@ -258,6 +258,7 @@ read_labels(struct nvdimm_dev *nv) sizeof(struct nvdimm_label); bitfield_size = roundup2(num_labels, 8) / 8; indices = malloc(2 * index_size, M_NVDIMM, M_WAITOK); + index1 = (void *)((uint8_t *)indices + index_size); error = read_label_area(nv, (void *)indices, 0, 2 * index_size); if (error != 0) { free(indices, M_NVDIMM); @@ -271,18 +272,29 @@ read_labels(struct nvdimm_dev *nv) free(indices, M_NVDIMM); return (ENXIO); } - if (index_0_valid && index_1_valid && - (indices[1].seq > indices[0].seq || - (indices[1].seq == 1 && indices[0].seq == 3))) - index_0_valid = false; + if (index_0_valid && index_1_valid) { + if (((int)indices->seq - (int)index1->seq + 3) % 3 == 1) { + /* index 0 was more recently updated */ + index_1_valid = false; + } else { + /* +* either index 1 was more recently updated, +* or the sequence numbers are equal, in which +* case the specification says the block with +* the higher offset is to be treated as valid +*/ + index_0_valid = false; + } + } nv->label_index = malloc(index_size, M_NVDIMM, M_WAITOK); - bcopy(indices + (index_0_valid ? 0 : 1), nv->label_index, index_size); + bcopy(index_0_valid ? indices : index1, nv->label_index, index_size); free(indices, M_NVDIMM); - for (bit_ffc_at((bitstr_t *)nv->label_index->free, 0, num_labels, &n); -n >= 0; -bit_ffc_at((bitstr_t *)nv->label_index->free, n + 1, num_labels, -&n)) { + bit_ffc_at((bitstr_t *)nv->label_index->free, 0, + nv->label_index->slot_cnt, &n); + while (n >= 0) { read_label(nv, n); + bit_ffc_at((bitstr_t *)nv->label_index->free, n + 1, + nv->label_index->slot_cnt, &n); } return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r351225 - in head/sys/dev: acpica nvdimm
Author: scottph Date: Mon Aug 19 17:51:06 2019 New Revision: 351225 URL: https://svnweb.freebsd.org/changeset/base/351225 Log: Don't set the string "unknown" as a device's location_str Return an empty string when the location is unknown instead of the string "unknown". This ensures that all location entries are of the form key=val. Suggested by: imp Approved by: jhb (mentor) MFC after:1 week Sponsored by: Intel Corporation Differential Revision:https://reviews.freebsd.org/D21326 Modified: head/sys/dev/acpica/acpi.c head/sys/dev/nvdimm/nvdimm.c Modified: head/sys/dev/acpica/acpi.c == --- head/sys/dev/acpica/acpi.c Mon Aug 19 17:28:12 2019(r351224) +++ head/sys/dev/acpica/acpi.c Mon Aug 19 17:51:06 2019(r351225) @@ -866,7 +866,7 @@ acpi_child_location_str_method(device_t cbdev, device_ strlcat(buf, buf2, buflen); } } else { -snprintf(buf, buflen, "unknown"); +snprintf(buf, buflen, ""); } return (0); } Modified: head/sys/dev/nvdimm/nvdimm.c == --- head/sys/dev/nvdimm/nvdimm.cMon Aug 19 17:28:12 2019 (r351224) +++ head/sys/dev/nvdimm/nvdimm.cMon Aug 19 17:51:06 2019 (r351225) @@ -571,7 +571,7 @@ nvdimm_root_child_location_str(device_t dev, device_t if (handle != NULL) res = snprintf(buf, buflen, "handle=%s", acpi_name(handle)); else - res = snprintf(buf, buflen, "unknown"); + res = snprintf(buf, buflen, ""); if (res >= buflen) return (EOVERFLOW); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r351897 - head/share/man/man4
Author: scottph Date: Thu Sep 5 20:51:41 2019 New Revision: 351897 URL: https://svnweb.freebsd.org/changeset/base/351897 Log: nvdimm(4): Add description of NVDIMM Namespace support Reviewed by: kib, bcr Approved by: emaste (mentor) MFC after:3 days Sponsored by: Intel Corporation Differential Revision:https://reviews.freebsd.org/D21536 Modified: head/share/man/man4/nvdimm.4 Modified: head/share/man/man4/nvdimm.4 == --- head/share/man/man4/nvdimm.4Thu Sep 5 20:42:08 2019 (r351896) +++ head/share/man/man4/nvdimm.4Thu Sep 5 20:51:41 2019 (r351897) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 23, 2019 +.Dd September 5, 2019 .Dt NVDIMM 4 .Os .Sh NAME @@ -75,7 +75,7 @@ the device. .Pp Also, for each SPA, the geom provider .Pa spaNNN -is created, which can be used to create a conventional filesystem (e.g. +is created, which can be used to create a conventional filesystem (e.g., by .Xr newfs 8 ) and @@ -86,6 +86,18 @@ Content accessible by and .Pa /dev/spaNNN is coherent. +.Pp +The +.Nm +driver has support for reading NVDIMM namespaces (if supported by your +hardware and already configured by some other mechanism, e.g., a BIOS +configuration screen). +The driver will provide a +.Pa /dev/nvdimm_spaNNNnsMMM +device node and +.Pa spaNNNnsMMM +geom provider for each namespace in a SPA, which behave analogously to their +full-SPA cousins described above. .Sh SEE ALSO .Xr ACPI 4 , .Xr GEOM 4 , ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r348680 - in head: share/misc usr.bin/calendar/calendars
Author: scottph Date: Wed Jun 5 04:01:31 2019 New Revision: 348680 URL: https://svnweb.freebsd.org/changeset/base/348680 Log: Add myself to committers-src.dot and calendar.freebsd Approved by: jhb (mentor) Modified: head/share/misc/committers-src.dot head/usr.bin/calendar/calendars/calendar.freebsd Modified: head/share/misc/committers-src.dot == --- head/share/misc/committers-src.dot Wed Jun 5 03:40:34 2019 (r348679) +++ head/share/misc/committers-src.dot Wed Jun 5 04:01:31 2019 (r348680) @@ -318,6 +318,7 @@ sbruno [label="Sean Bruno\nsbr...@freebsd.org\n2008/08 scf [label="Sean C. Farley\n...@freebsd.org\n2007/06/24"] schweikh [label="Jens Schweikhardt\nschwe...@freebsd.org\n2001/04/06"] scottl [label="Scott Long\nsco...@freebsd.org\n2000/09/28"] +scottph [label="D Scott Phillips\nscot...@freebsd.org\n2019/05/28"] se [label="Stefan Esser\n...@freebsd.org\n1994/08/26"] sephe [label="Sepherosa Ziehau\nse...@freebsd.org\n2007/03/28"] sepotvin [label="Stephane E. Potvin\nsepot...@freebsd.org\n2007/02/15"] @@ -511,6 +512,7 @@ emaste -> lwhsu emaste -> markj emaste -> ngie emaste -> rstone +emaste -> scottph emax -> markus @@ -608,6 +610,7 @@ jhb -> pfg jhb -> rnoland jhb -> rpokala jhb -> arichardson +jhb -> scottph jhibbits -> bdragon jhibbits -> leitao Modified: head/usr.bin/calendar/calendars/calendar.freebsd == --- head/usr.bin/calendar/calendars/calendar.freebsdWed Jun 5 03:40:34 2019(r348679) +++ head/usr.bin/calendar/calendars/calendar.freebsdWed Jun 5 04:01:31 2019(r348680) @@ -15,6 +15,7 @@ 01/02 Patrick Li born in Beijing, People's Republic of China, 1985 01/03 Tetsurou Okazaki born in Mobara, Chiba, Japan, 1972 01/04 Hiroyuki Hanai born in Kagawa pre., Japan, 1969 +01/05 D Scott Phillips born in Anderson, Indiana, 1983 01/06 Adriaan de Groot born in Calgary, Canada, 1973 01/06 Philippe Audeoud born in Bretigny-Sur-Orge, France, 1980 01/08 Michael L. Hostbaek born in Copenhagen, Denmark, 1977 ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r348757 - head/sys/dev/nvdimm
Author: scottph Date: Thu Jun 6 20:12:04 2019 New Revision: 348757 URL: https://svnweb.freebsd.org/changeset/base/348757 Log: nvdimm: Provide nvdimm location information Provide the acpi handle path as the location string for the nvdimm children of the nvdimm_root device. Reviewed by: kib Approved by: jhb (mentor) MFC after:1 week Sponsored by: Intel Corporation Differential Revision:https://reviews.freebsd.org/D20528 Modified: head/sys/dev/nvdimm/nvdimm.c Modified: head/sys/dev/nvdimm/nvdimm.c == --- head/sys/dev/nvdimm/nvdimm.cThu Jun 6 20:03:55 2019 (r348756) +++ head/sys/dev/nvdimm/nvdimm.cThu Jun 6 20:12:04 2019 (r348757) @@ -560,6 +560,24 @@ nvdimm_root_write_ivar(device_t dev, device_t child, i return (0); } +static int +nvdimm_root_child_location_str(device_t dev, device_t child, char *buf, +size_t buflen) +{ + ACPI_HANDLE handle; + int res; + + handle = nvdimm_root_get_acpi_handle(child); + if (handle != NULL) + res = snprintf(buf, buflen, "handle=%s", acpi_name(handle)); + else + res = snprintf(buf, buflen, "unknown"); + + if (res >= buflen) + return (EOVERFLOW); + return (0); +} + static device_method_t nvdimm_methods[] = { DEVMETHOD(device_probe, nvdimm_probe), DEVMETHOD(device_attach, nvdimm_attach), @@ -582,6 +600,7 @@ static device_method_t nvdimm_root_methods[] = { DEVMETHOD(bus_add_child, bus_generic_add_child), DEVMETHOD(bus_read_ivar, nvdimm_root_read_ivar), DEVMETHOD(bus_write_ivar, nvdimm_root_write_ivar), + DEVMETHOD(bus_child_location_str, nvdimm_root_child_location_str), DEVMETHOD_END }; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r364794 - head/sys/arm64/arm64
Author: scottph Date: Wed Aug 26 02:04:04 2020 New Revision: 364794 URL: https://svnweb.freebsd.org/changeset/base/364794 Log: arm64: Make local stores observable before sending IPIs Add a synchronizing instruction to flush and wait until the local CPU's writes are observable to other CPUs before sending IPIs. This fixes an issue where recipient CPUs doing a rendezvous could enter the rendezvous handling code before the initiator's writes to the smp_rv_* variables were visible. This manifested as a system hang, where a single CPU's increment of smp_rv_waiters[0] actually happened "before" the initiator's zeroing of that field, so all CPUs were stuck with the field appearing to be at ncpus - 1. Reviewed by: andrew, markj Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D25798 Modified: head/sys/arm64/arm64/mp_machdep.c Modified: head/sys/arm64/arm64/mp_machdep.c == --- head/sys/arm64/arm64/mp_machdep.c Wed Aug 26 01:55:37 2020 (r364793) +++ head/sys/arm64/arm64/mp_machdep.c Wed Aug 26 02:04:04 2020 (r364794) @@ -304,6 +304,13 @@ pic_ipi_send(void *arg, cpuset_t cpus, u_int ipi) { KASSERT(intr_irq_root_dev != NULL, ("%s: no root attached", __func__)); + + /* +* Ensure that this CPU's stores will be visible to IPI +* recipients before starting to send the interrupts. +*/ + dsb(ishst); + PIC_IPI_SEND(intr_irq_root_dev, arg, cpus, ipi); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r364795 - head/usr.sbin/efibootmgr
Author: scottph Date: Wed Aug 26 02:05:58 2020 New Revision: 364795 URL: https://svnweb.freebsd.org/changeset/base/364795 Log: efibootmgr: Add option to request booting to the firmware user interface The OsIndications UEFI variable can request the firware to stop at its UI instead of continuing with boot. Add flags for setting and clearing this request. Reviewed by: manu, bcr (manpages) Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D25839 Modified: head/usr.sbin/efibootmgr/efibootmgr.8 head/usr.sbin/efibootmgr/efibootmgr.c Modified: head/usr.sbin/efibootmgr/efibootmgr.8 == --- head/usr.sbin/efibootmgr/efibootmgr.8 Wed Aug 26 02:04:04 2020 (r364794) +++ head/usr.sbin/efibootmgr/efibootmgr.8 Wed Aug 26 02:05:58 2020 (r364795) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 23, 2020 +.Dd August 25, 2020 .Dt EFIBOOTMGR 8 .Os .Sh NAME @@ -55,6 +55,10 @@ .Op Fl d .Op Fl p .Nm +.Fl F +.Nm +.Fl f +.Nm .Fl n .Fl b Ar bootnum .Nm @@ -137,6 +141,9 @@ is specified, the UEFI device path to the ESP is repor If .Fl p -unix-path is specified, the mount point of the ESP is reported instead. +.It Fl f -fw-ui , Fl F -no-fw-ui +Set or clear the request to the system firmware to stop in its user +interface on the next boot. .It Fl k -kernel Ar kernel The path to and name of the kernel. .It Fl l -loader Ar loader Modified: head/usr.sbin/efibootmgr/efibootmgr.c == --- head/usr.sbin/efibootmgr/efibootmgr.c Wed Aug 26 02:04:04 2020 (r364794) +++ head/usr.sbin/efibootmgr/efibootmgr.c Wed Aug 26 02:05:58 2020 (r364795) @@ -67,6 +67,8 @@ __FBSDID("$FreeBSD$"); #define BAD_LENGTH ((size_t)-1) +#define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0001 + typedef struct _bmgr_opts { char*env; char*loader; @@ -83,6 +85,8 @@ typedef struct _bmgr_opts { booldry_run; booldevice_path; boolesp_device; + boolfw_ui; + boolno_fw_ui; boolhas_bootnum; boolonce; int cp_src; @@ -110,6 +114,8 @@ static struct option lopts[] = { {"dry-run", no_argument, NULL, 'D'}, {"env", required_argument, NULL, 'e'}, {"esp", no_argument, NULL, 'E'}, + {"fw-ui", no_argument, NULL, 'f'}, + {"no-fw-ui", no_argument, NULL, 'F'}, {"help", no_argument, NULL, 'h'}, {"kernel", required_argument, NULL, 'k'}, {"label", required_argument, NULL, 'L'}, @@ -197,7 +203,7 @@ parse_args(int argc, char *argv[]) { int ch; - while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:Ehk:L:l:NnOo:pTt:v", + while ((ch = getopt_long(argc, argv, "AaBb:C:cdDe:EFfhk:L:l:NnOo:pTt:v", lopts, NULL)) != -1) { switch (ch) { case 'A': @@ -232,6 +238,12 @@ parse_args(int argc, char *argv[]) case 'E': opts.esp_device = true; break; + case 'F': + opts.no_fw_ui = true; + break; + case 'f': + opts.fw_ui = true; + break; case 'h': default: errx(1, "%s", USAGE); @@ -825,6 +837,45 @@ print_boot_var(const char *name, bool verbose, bool cu } +static bool +os_indication_supported(uint64_t indication) +{ + uint8_t *data; + size_t size; + uint32_t attrs; + int ret; + + ret = efi_get_variable(EFI_GLOBAL_GUID, "OsIndicationsSupported", &data, + &size, &attrs); + if (ret < 0) + return false; + return (le64dec(data) & indication) == indication; +} + +static uint64_t +os_indications(void) +{ + uint8_t *data; + size_t size; + uint32_t attrs; + int ret; + + ret = efi_get_variable(EFI_GLOBAL_GUID, "OsIndications", &data, &size, + &attrs); + if (ret < 0) + return 0; + return le64dec(data); +} + +static int +os_indications_set(uint64_t mask, uint64_t val) +{ + uint8_t new[sizeof(uint64_t)]; + + le64enc(&new, (os_indications() & ~mask) | (val & mask)); + return set_bootvar("OsIndications", new, sizeof(new)); +} + /* Cmd epilogue, or just the default with no args. * The order is [bootnext] bootcurrent, timeout, order, and the bootvars [-v] */ @@ -841,7 +892,15 @@ print_boot_vars(bool verbose) uint32_t attrs; int ret, bolen; uint16_t *boot_order = NULL, current; + bool boot_to_fw_ui; + if (os_indication_supported(EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) { + boot_to_fw_ui = +
svn commit: r364796 - in head: share/man/man9 sys/sys
Author: scottph Date: Wed Aug 26 02:07:46 2020 New Revision: 364796 URL: https://svnweb.freebsd.org/changeset/base/364796 Log: bitset: add BIT_FFS_AT() for finding the first bit set greater than a start bit Reviewed by: kib Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26128 Modified: head/share/man/man9/bitset.9 head/sys/sys/bitset.h Modified: head/share/man/man9/bitset.9 == --- head/share/man/man9/bitset.9Wed Aug 26 02:05:58 2020 (r364795) +++ head/share/man/man9/bitset.9Wed Aug 26 02:07:46 2020 (r364796) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 12, 2019 +.Dd August 25, 2020 .Dt BITSET 9 .Os .Sh NAME @@ -43,6 +43,7 @@ .Nm BIT_EMPTY , .Nm BIT_ISFULLSET , .Nm BIT_FFS , +.Nm BIT_FFS_AT , .Nm BIT_FLS , .Nm BIT_COUNT , .Nm BIT_SUBSET , @@ -86,6 +87,8 @@ .Ft int .Fn BIT_FFS "const SETSIZE" "struct STRUCTNAME *bitset" .Ft int +.Fn BIT_FFS_AT "const SETSIZE" "struct STRUCTNAME *bitset" "int start" +.Ft int .Fn BIT_FLS "const SETSIZE" "struct STRUCTNAME *bitset" .Ft int .Fn BIT_COUNT "const SETSIZE" "struct STRUCTNAME *bitset" @@ -285,6 +288,18 @@ index parameter to any other macro, you must subtract one from the result. .Pp The +.Fn BIT_FFS_AT +macro returns the 1-index of the first (lowest) set bit in +.Fa bitset , +which is greater than the given 1-indexed +.Fa start , +or zero if no bits in +.Fa bitset +greater than +.Fa start +are set. +.Pp +The .Fn BIT_FLS macro returns the 1-index of the last (highest) set bit in .Fa bitset , @@ -518,7 +533,8 @@ argument to all of these macros must match the value g .Fn BITSET_DEFINE . .Pp Unlike every other reference to individual set members, which are zero-indexed, -.Fn BIT_FFS +.Fn BIT_FFS , +.Fn BIT_FFS_AT and .Fn BIT_FLS return a one-indexed result (or zero if the set is empty). Modified: head/sys/sys/bitset.h == --- head/sys/sys/bitset.h Wed Aug 26 02:05:58 2020(r364795) +++ head/sys/sys/bitset.h Wed Aug 26 02:07:46 2020(r364796) @@ -207,20 +207,31 @@ (f)->__bits[__i]); \ } while (0) -#defineBIT_FFS(_s, p) __extension__ ({ \ +/* + * Note that `start` and the returned value from BIT_FFS_AT are + * 1-based bit indices. + */ +#defineBIT_FFS_AT(_s, p, start) __extension__ ({ \ __size_t __i; \ + long __mask;\ int __bit; \ \ + __mask = ~0UL << ((start) % _BITSET_BITS); \ __bit = 0; \ - for (__i = 0; __i < __bitset_words((_s)); __i++) { \ - if ((p)->__bits[__i] != 0) {\ - __bit = ffsl((p)->__bits[__i]); \ + for (__i = __bitset_word((_s), (start));\ + __i < __bitset_words((_s)); \ + __i++) {\ + if (((p)->__bits[__i] & __mask) != 0) { \ + __bit = ffsl((p)->__bits[__i] & __mask);\ __bit += __i * _BITSET_BITS;\ break; \ } \ + __mask = ~0UL; \ } \ __bit; \ }) + +#defineBIT_FFS(_s, p) BIT_FFS_AT((_s), (p), 0) #defineBIT_FLS(_s, p) __extension__ ({ \ __size_t __i; \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r364797 - in head/sys/arm64: acpica arm64
Author: scottph Date: Wed Aug 26 02:12:15 2020 New Revision: 364797 URL: https://svnweb.freebsd.org/changeset/base/364797 Log: arm64/acpi: Give the real PA limit to ACPI Read PA bits from ID_AA64MMFR0_EL1.PARange. Reviewed by: andrew, markj Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26133 Modified: head/sys/arm64/acpica/acpi_machdep.c head/sys/arm64/arm64/identcpu.c Modified: head/sys/arm64/acpica/acpi_machdep.c == --- head/sys/arm64/acpica/acpi_machdep.cWed Aug 26 02:07:46 2020 (r364796) +++ head/sys/arm64/acpica/acpi_machdep.cWed Aug 26 02:12:15 2020 (r364797) @@ -232,12 +232,47 @@ acpi_map_addr(struct acpi_generic_address *addr, bus_s static void parse_pxm_tables(void *dummy) { + uint64_t mmfr0, parange; /* Only parse ACPI tables when booting via ACPI */ if (arm64_bus_method != ARM64_BUS_ACPI) return; - acpi_pxm_init(MAXCPU, (vm_paddr_t)1 << 40); + if (!get_kernel_reg(ID_AA64MMFR0_EL1, &mmfr0)) { + /* chosen arbitrarily */ + mmfr0 = ID_AA64MMFR0_PARange_1T; + } + + switch (ID_AA64MMFR0_PARange_VAL(mmfr0)) { + case ID_AA64MMFR0_PARange_4G: + parange = (vm_paddr_t)4 << 30 /* GiB */; + break; + case ID_AA64MMFR0_PARange_64G: + parange = (vm_paddr_t)64 << 30 /* GiB */; + break; + case ID_AA64MMFR0_PARange_1T: + parange = (vm_paddr_t)1 << 40 /* TiB */; + break; + case ID_AA64MMFR0_PARange_4T: + parange = (vm_paddr_t)4 << 40 /* TiB */; + break; + case ID_AA64MMFR0_PARange_16T: + parange = (vm_paddr_t)16 << 40 /* TiB */; + break; + case ID_AA64MMFR0_PARange_256T: + parange = (vm_paddr_t)256 << 40 /* TiB */; + break; + case ID_AA64MMFR0_PARange_4P: + parange = (vm_paddr_t)4 << 50 /* PiB */; + break; + default: + /* chosen arbitrarily */ + parange = (vm_paddr_t)1 << 40 /* TiB */; + printf("Unknown value for PARange in mmfr0 (%#lx)\n", mmfr0); + break; + } + + acpi_pxm_init(MAXCPU, parange); acpi_pxm_parse_tables(); acpi_pxm_set_mem_locality(); } Modified: head/sys/arm64/arm64/identcpu.c == --- head/sys/arm64/arm64/identcpu.c Wed Aug 26 02:07:46 2020 (r364796) +++ head/sys/arm64/arm64/identcpu.c Wed Aug 26 02:12:15 2020 (r364797) @@ -916,6 +916,13 @@ static struct mrs_user_reg user_regs[] = { .offset = __offsetof(struct cpu_desc, id_aa64dfr0), .fields = id_aa64dfr0_fields, }, + { /* id_aa64mmfr0_el1 */ + .reg = ID_AA64MMFR0_EL1, + .CRm = 7, + .Op2 = 0, + .offset = __offsetof(struct cpu_desc, id_aa64mmfr0), + .fields = id_aa64mmfr0_fields, + }, }; #defineCPU_DESC_FIELD(desc, idx) \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r364798 - head/sys/arm64/include
Author: scottph Date: Wed Aug 26 02:13:27 2020 New Revision: 364798 URL: https://svnweb.freebsd.org/changeset/base/364798 Log: arm64: Increase dmap size to 95 TiB The Ampere Altra has physical memory populated sparsely within the physical address space. Increase the size of the dmap to cover all physical memory. Reviewed by: andrew Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26134 Modified: head/sys/arm64/include/vmparam.h Modified: head/sys/arm64/include/vmparam.h == --- head/sys/arm64/include/vmparam.hWed Aug 26 02:12:15 2020 (r364797) +++ head/sys/arm64/include/vmparam.hWed Aug 26 02:13:27 2020 (r364798) @@ -156,8 +156,8 @@ #defineVM_MIN_KERNEL_ADDRESS (0xUL) #defineVM_MAX_KERNEL_ADDRESS (0x0080UL) -/* 2 TiB maximum for the direct map region */ -#defineDMAP_MIN_ADDRESS(0xfd00UL) +/* 95 TiB maximum for the direct map region */ +#defineDMAP_MIN_ADDRESS(0xa000UL) #defineDMAP_MAX_ADDRESS(0xff00UL) #defineDMAP_MIN_PHYSADDR (dmap_phys_base) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r366715 - head/sys/arm64/include
Author: scottph Date: Thu Oct 15 03:12:00 2020 New Revision: 366715 URL: https://svnweb.freebsd.org/changeset/base/366715 Log: arm64: Increase NIRQ to 16k Ampere Altra in a dual socket configuration has 12 ITSes for the 12 PCIe root complexes. The NIRQ interrupts are statically split between each child of the gic bus, so here we increase that value. 16k is enough for (#cpus * #its * max_pcie_bifurcation) LPIs + (#SPIs and #PPIs) Reviewed by: jhb Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing Differential Revision:https://reviews.freebsd.org/D26766 Modified: head/sys/arm64/include/intr.h Modified: head/sys/arm64/include/intr.h == --- head/sys/arm64/include/intr.h Thu Oct 15 00:50:26 2020 (r366714) +++ head/sys/arm64/include/intr.h Thu Oct 15 03:12:00 2020 (r366715) @@ -36,7 +36,7 @@ #include #ifndef NIRQ -#defineNIRQ2048/* XXX - It should be an option. */ +#defineNIRQ16384 /* XXX - It should be an option. */ #endif static inline void ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r365505 - head/stand/efi/libefi
Author: scottph Date: Wed Sep 9 16:35:51 2020 New Revision: 365505 URL: https://svnweb.freebsd.org/changeset/base/365505 Log: stand/efihttp: Work around a bug in edk2 http instance reconfiguration A bug in the EFI HTTP driver of TianoCore EDK2 causes memory corruption when an http instance that uses tls is reconfigured, leading to a crash. Work around this by forcing a new http instance for each request instead of reconfiguring the existing one. The upstream bug report is https://bugzilla.tianocore.org/show_bug.cgi?id=1917 Submitted by: bcran Reviewed By: imp, kevans, tsoome MFC after:1 week Differential Revision:https://reviews.freebsd.org/D21281 Modified: head/stand/efi/libefi/efihttp.c Modified: head/stand/efi/libefi/efihttp.c == --- head/stand/efi/libefi/efihttp.c Wed Sep 9 16:13:33 2020 (r365504) +++ head/stand/efi/libefi/efihttp.c Wed Sep 9 16:35:51 2020 (r365505) @@ -576,6 +576,14 @@ efihttp_fs_open(const char *path, struct open_file *f) */ err = _efihttp_fs_open(path, f); if (err != 0) { + /* +* Work around a bug in the EFI HTTP implementation which +* causes a crash if the http instance isn't torn down +* between requests. +* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 +*/ + efihttp_dev_close(f); + efihttp_dev_open(f); path_slash = malloc(strlen(path) + 2); if (path_slash == NULL) return (ENOMEM); @@ -719,6 +727,14 @@ efihttp_fs_seek(struct open_file *f, off_t offset, int path = fh->path; fh->path = NULL; efihttp_fs_close(f); + /* +* Work around a bug in the EFI HTTP implementation which +* causes a crash if the http instance isn't torn down +* between requests. +* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 +*/ + efihttp_dev_close(f); + efihttp_dev_open(f); err = efihttp_fs_open(path, f); free(path); if (err != 0) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r365974 - head/sys/contrib/vchiq/interface/vchiq_arm
Author: scottph Date: Mon Sep 21 22:18:09 2020 New Revision: 365974 URL: https://svnweb.freebsd.org/changeset/base/365974 Log: vchi: rename bitset macros to avoid collision with bitset(9) An upcoming change to include bitset(9) macros from vm_page.h causes a macro name collision with vchi's custom bitset macros. This change was performed mechanically by: sed -i .orig s/BITSET/VCHI_BITSET/g $(grep -rl BITSET sys/contrib/vchiq) Reviewed by: andrew Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26177 Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.c head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.h Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.c == --- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.c Mon Sep 21 20:02:26 2020(r365973) +++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.c Mon Sep 21 22:18:09 2020(r365974) @@ -619,7 +619,7 @@ static void process_free_queue(VCHIQ_STATE_T *state) { VCHIQ_SHARED_STATE_T *local = state->local; - BITSET_T service_found[BITSET_SIZE(VCHIQ_MAX_SERVICES)]; + VCHI_BITSET_T service_found[VCHI_BITSET_SIZE(VCHIQ_MAX_SERVICES)]; int slot_queue_available; /* Find slots which have been freed by the other side, and return them @@ -646,7 +646,7 @@ process_free_queue(VCHIQ_STATE_T *state) /* Initialise the bitmask for services which have used this ** slot */ - BITSET_ZERO(service_found); + VCHI_BITSET_ZERO(service_found); pos = 0; @@ -686,9 +686,9 @@ process_free_queue(VCHIQ_STATE_T *state) header->size); WARN(1, "invalid message use count\n"); } - if (!BITSET_IS_SET(service_found, port)) { + if (!VCHI_BITSET_IS_SET(service_found, port)) { /* Set the found bit for this service */ - BITSET_SET(service_found, port); + VCHI_BITSET_SET(service_found, port); spin_lock("a_spinlock); count = service_quota->slot_use_count; @@ -1276,7 +1276,7 @@ poll_services(VCHIQ_STATE_T *state) { int group, i; - for (group = 0; group < BITSET_SIZE(state->unused_service); group++) { + for (group = 0; group < VCHI_BITSET_SIZE(state->unused_service); group++) { uint32_t flags; flags = atomic_xchg(&state->poll_services[group], 0); for (i = 0; flags; i++) { Modified: head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.h == --- head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.h Mon Sep 21 20:02:26 2020(r365973) +++ head/sys/contrib/vchiq/interface/vchiq_arm/vchiq_core.h Mon Sep 21 22:18:09 2020(r365974) @@ -141,17 +141,17 @@ vchiq_static_assert((unsigned int)VCHIQ_PORT_MAX < #define VCHIQ_BULK_ACTUAL_ABORTED -1 -typedef uint32_t BITSET_T; +typedef uint32_t VCHI_BITSET_T; -vchiq_static_assert((sizeof(BITSET_T) * 8) == 32); +vchiq_static_assert((sizeof(VCHI_BITSET_T) * 8) == 32); -#define BITSET_SIZE(b)((b + 31) >> 5) -#define BITSET_WORD(b)(b >> 5) -#define BITSET_BIT(b) (1 << (b & 31)) -#define BITSET_ZERO(bs) memset(bs, 0, sizeof(bs)) -#define BITSET_IS_SET(bs, b) (bs[BITSET_WORD(b)] & BITSET_BIT(b)) -#define BITSET_SET(bs, b) (bs[BITSET_WORD(b)] |= BITSET_BIT(b)) -#define BITSET_CLR(bs, b) (bs[BITSET_WORD(b)] &= ~BITSET_BIT(b)) +#define VCHI_BITSET_SIZE(b)((b + 31) >> 5) +#define VCHI_BITSET_WORD(b)(b >> 5) +#define VCHI_BITSET_BIT(b) (1 << (b & 31)) +#define VCHI_BITSET_ZERO(bs) memset(bs, 0, sizeof(bs)) +#define VCHI_BITSET_IS_SET(bs, b) (bs[VCHI_BITSET_WORD(b)] & VCHI_BITSET_BIT(b)) +#define VCHI_BITSET_SET(bs, b) (bs[VCHI_BITSET_WORD(b)] |= VCHI_BITSET_BIT(b)) +#define VCHI_BITSET_CLR(bs, b) (bs[VCHI_BITSET_WORD(b)] &= ~VCHI_BITSET_BIT(b)) #if VCHIQ_ENABLE_STATS #define VCHIQ_STATS_INC(state, stat) (state->stats. stat++) @@ -478,7 +478,7 @@ struct vchiq_state_struct { unsigned short data_quota; /* An array of bit sets indicating which services must be polled. */ - atomic_t poll_services[BITSET_SIZE(VCHIQ_MAX_SERVICES)]; + atomic_t poll_services[VCHI_BITSET_SIZE(VCHIQ_MAX_SERVICES)]; /* The number of the first unused service */ int unused_service; ___ svn-src-
svn commit: r365975 - in head: share/man/man9 sys/sys
Author: scottph Date: Mon Sep 21 22:19:12 2020 New Revision: 365975 URL: https://svnweb.freebsd.org/changeset/base/365975 Log: bitset: expand bit index type to `long` An upcoming patch to use the bitset macros for tracking vm page dump information could conceivably need more than INT_MAX bits. Expand the bit type to long so that the extra range is available on 64-bit platforms where it would most likely be needed. CPUSET_COUNT and DOMAINSET_COUNT are also modified to remain of type `int`. Reviewed by: kib, markj Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26190 Modified: head/share/man/man9/bitset.9 head/sys/sys/bitset.h head/sys/sys/cpuset.h head/sys/sys/domainset.h Modified: head/share/man/man9/bitset.9 == --- head/share/man/man9/bitset.9Mon Sep 21 22:18:09 2020 (r365974) +++ head/share/man/man9/bitset.9Mon Sep 21 22:19:12 2020 (r365975) @@ -84,13 +84,13 @@ .Fn BIT_EMPTY "const SETSIZE" "struct STRUCTNAME *bitset" .Ft bool .Fn BIT_ISFULLSET "const SETSIZE" "struct STRUCTNAME *bitset" -.Ft int +.Ft long .Fn BIT_FFS "const SETSIZE" "struct STRUCTNAME *bitset" -.Ft int -.Fn BIT_FFS_AT "const SETSIZE" "struct STRUCTNAME *bitset" "int start" -.Ft int +.Ft long +.Fn BIT_FFS_AT "const SETSIZE" "struct STRUCTNAME *bitset" "long start" +.Ft long .Fn BIT_FLS "const SETSIZE" "struct STRUCTNAME *bitset" -.Ft int +.Ft long .Fn BIT_COUNT "const SETSIZE" "struct STRUCTNAME *bitset" .\" .Ft bool Modified: head/sys/sys/bitset.h == --- head/sys/sys/bitset.h Mon Sep 21 22:18:09 2020(r365974) +++ head/sys/sys/bitset.h Mon Sep 21 22:19:12 2020(r365975) @@ -213,8 +213,7 @@ */ #defineBIT_FFS_AT(_s, p, start) __extension__ ({ \ __size_t __i; \ - long __mask;\ - int __bit; \ + long __bit, __mask; \ \ __mask = ~0UL << ((start) % _BITSET_BITS); \ __bit = 0; \ @@ -235,7 +234,7 @@ #defineBIT_FLS(_s, p) __extension__ ({ \ __size_t __i; \ - int __bit; \ + long __bit; \ \ __bit = 0; \ for (__i = __bitset_words((_s)); __i > 0; __i--) { \ @@ -250,7 +249,7 @@ #defineBIT_COUNT(_s, p) __extension__ ({ \ __size_t __i; \ - int __count;\ + long __count; \ \ __count = 0;\ for (__i = 0; __i < __bitset_words((_s)); __i++)\ Modified: head/sys/sys/cpuset.h == --- head/sys/sys/cpuset.h Mon Sep 21 22:18:09 2020(r365974) +++ head/sys/sys/cpuset.h Mon Sep 21 22:19:12 2020(r365975) @@ -65,7 +65,7 @@ #defineCPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) #defineCPU_COPY_STORE_REL(f, t)BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) #defineCPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) -#defineCPU_COUNT(p)BIT_COUNT(CPU_SETSIZE, p) +#defineCPU_COUNT(p)((int)BIT_COUNT(CPU_SETSIZE, p)) #defineCPUSET_FSET BITSET_FSET(_NCPUWORDS) #defineCPUSET_T_INITIALIZERBITSET_T_INITIALIZER Modified: head/sys/sys/domainset.h == --- head/sys/sys/domainset.hMon Sep 21 22:18:09 2020(r365974) +++ head/sys/sys/domainset.hMon Sep 21 22:19:12 2020(r365975) @@ -68,7 +68,7 @@ BIT_COPY_STORE_REL(DOMAINSET_SETSIZE, f, t) #defineDOMAINSET_FFS(p)BIT_FFS(DOMAINSET_SETSIZE, p) #defineDOMAINSET_FLS(p)BIT_FLS(DOMAINSET_SETSIZE, p) -#defineDOMAINSET_COUNT(p)
svn commit: r365977 - in head: . sys/amd64/amd64 sys/amd64/include sys/arm/arm sys/arm/include sys/arm64/arm64 sys/arm64/include sys/i386/i386 sys/i386/include sys/mips/include sys/mips/mips sys/po...
Author: scottph Date: Mon Sep 21 22:20:37 2020 New Revision: 365977 URL: https://svnweb.freebsd.org/changeset/base/365977 Log: Move vm_page_dump bitset array definition to MI code These definitions were repeated by all architectures, with small variations. Consolidate the common definitons in machine independent code and use bitset(9) macros for manipulation. Many opportunities for deduplication remain in the machine dependent minidump logic. The only intended functional change is increasing the bit index type to vm_pindex_t, allowing the indexing of pages with address of 8 TiB and greater. Reviewed by: kib, markj Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26129 Modified: head/.clang-format head/sys/amd64/amd64/minidump_machdep.c head/sys/amd64/include/md_var.h head/sys/amd64/include/vmparam.h head/sys/arm/arm/minidump_machdep.c head/sys/arm/include/md_var.h head/sys/arm/include/vmparam.h head/sys/arm64/arm64/minidump_machdep.c head/sys/arm64/include/md_var.h head/sys/arm64/include/vmparam.h head/sys/i386/i386/minidump_machdep.c head/sys/i386/i386/minidump_machdep_base.c head/sys/i386/include/md_var.h head/sys/i386/include/vmparam.h head/sys/mips/include/md_var.h head/sys/mips/include/vmparam.h head/sys/mips/mips/minidump_machdep.c head/sys/powerpc/include/md_var.h head/sys/powerpc/include/vmparam.h head/sys/powerpc/powerpc/minidump_machdep.c head/sys/riscv/include/md_var.h head/sys/riscv/include/vmparam.h head/sys/riscv/riscv/minidump_machdep.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h head/sys/x86/include/x86_var.h Modified: head/.clang-format == --- head/.clang-format Mon Sep 21 22:19:21 2020(r365976) +++ head/.clang-format Mon Sep 21 22:20:37 2020(r365977) @@ -76,6 +76,7 @@ ForEachMacros: - TAILQ_FOREACH_REVERSE_SAFE - TAILQ_FOREACH_SAFE - VM_MAP_ENTRY_FOREACH + - VM_PAGE_DUMP_FOREACH IndentCaseLabels: false IndentPPDirectives: None Language: Cpp Modified: head/sys/amd64/amd64/minidump_machdep.c == --- head/sys/amd64/amd64/minidump_machdep.c Mon Sep 21 22:19:21 2020 (r365976) +++ head/sys/amd64/amd64/minidump_machdep.c Mon Sep 21 22:20:37 2020 (r365977) @@ -54,9 +54,6 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); -uint64_t *vm_page_dump; -int vm_page_dump_size; - static struct kerneldumpheader kdh; /* Handle chunked writes. */ @@ -64,7 +61,6 @@ static size_t fragsz; static void *dump_va; static size_t counter, progress, dumpsize, wdog_next; -CTASSERT(sizeof(*vm_page_dump) == 8); static int dump_retry_count = 5; SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, &dump_retry_count, 0, "Number of times dump has to retry before bailing out"); @@ -223,9 +219,8 @@ minidumpsys(struct dumperinfo *di) uint32_t pmapsize; vm_offset_t va; int error; - uint64_t bits; uint64_t *pml4, *pdp, *pd, *pt, pa; - int i, ii, j, k, n, bit; + int i, ii, j, k, n; int retry_count; struct minidumphdr mdhdr; @@ -304,19 +299,13 @@ minidumpsys(struct dumperinfo *di) /* Calculate dump size. */ dumpsize = pmapsize; dumpsize += round_page(msgbufp->msg_size); - dumpsize += round_page(vm_page_dump_size); - for (i = 0; i < vm_page_dump_size / sizeof(*vm_page_dump); i++) { - bits = vm_page_dump[i]; - while (bits) { - bit = bsfq(bits); - pa = (((uint64_t)i * sizeof(*vm_page_dump) * NBBY) + bit) * PAGE_SIZE; - /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) { - dumpsize += PAGE_SIZE; - } else { - dump_drop_page(pa); - } - bits &= ~(1ul << bit); + dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); + VM_PAGE_DUMP_FOREACH(pa) { + /* Clear out undumpable pages now if needed */ + if (is_dumpable(pa)) { + dumpsize += PAGE_SIZE; + } else { + dump_drop_page(pa); } } dumpsize += PAGE_SIZE; @@ -328,7 +317,7 @@ minidumpsys(struct dumperinfo *di) strcpy(mdhdr.magic, MINIDUMP_MAGIC); mdhdr.version = MINIDUMP_VERSION; mdhdr.msgbufsize = msgbufp->msg_size; - mdhdr.bitmapsize = vm_page_dump_size; + mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages)); mdhdr.pmapsize = pmapsize; mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS; mdhdr.dmapbase =
svn commit: r365978 - in head: lib/libkvm sys/amd64/amd64 sys/amd64/include sys/arm/arm sys/arm/include sys/arm64/arm64 sys/arm64/include sys/i386/i386 sys/i386/include sys/mips/include sys/mips/mi...
Author: scottph Date: Mon Sep 21 22:21:59 2020 New Revision: 365978 URL: https://svnweb.freebsd.org/changeset/base/365978 Log: Sparsify the vm_page_dump bitmap On Ampere Altra systems, the sparse population of RAM within the physical address space causes the vm_page_dump bitmap to be much larger than necessary, increasing the size from ~8 Mib to > 2 Gib (and overflowing `int` for the size). Changing the page dump bitmap also changes the minidump file format, so changes are also necessary in libkvm. Reviewed by: jhb Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26131 Modified: head/lib/libkvm/kvm_minidump_aarch64.c head/lib/libkvm/kvm_minidump_amd64.c head/lib/libkvm/kvm_minidump_arm.c head/lib/libkvm/kvm_minidump_i386.c head/lib/libkvm/kvm_minidump_mips.c head/lib/libkvm/kvm_minidump_powerpc64.c head/lib/libkvm/kvm_minidump_riscv.c head/lib/libkvm/kvm_private.c head/lib/libkvm/kvm_private.h head/sys/amd64/amd64/minidump_machdep.c head/sys/amd64/include/minidump.h head/sys/arm/arm/minidump_machdep.c head/sys/arm/include/minidump.h head/sys/arm64/arm64/minidump_machdep.c head/sys/arm64/include/minidump.h head/sys/i386/i386/minidump_machdep_base.c head/sys/i386/include/minidump.h head/sys/mips/include/minidump.h head/sys/mips/mips/minidump_machdep.c head/sys/powerpc/include/minidump.h head/sys/powerpc/powerpc/minidump_machdep.c head/sys/riscv/include/minidump.h head/sys/riscv/riscv/minidump_machdep.c head/sys/vm/vm_page.c head/sys/vm/vm_page.h head/sys/vm/vm_phys.h Modified: head/lib/libkvm/kvm_minidump_aarch64.c == --- head/lib/libkvm/kvm_minidump_aarch64.c Mon Sep 21 22:20:37 2020 (r365977) +++ head/lib/libkvm/kvm_minidump_aarch64.c Mon Sep 21 22:21:59 2020 (r365978) @@ -82,7 +82,7 @@ static int _aarch64_minidump_initvtop(kvm_t *kd) { struct vmstate *vmst; - off_t off, sparse_off; + off_t off, dump_avail_off, sparse_off; vmst = _kvm_malloc(kd, sizeof(*vmst)); if (vmst == NULL) { @@ -102,7 +102,7 @@ _aarch64_minidump_initvtop(kvm_t *kd) } vmst->hdr.version = le32toh(vmst->hdr.version); - if (vmst->hdr.version != MINIDUMP_VERSION) { + if (vmst->hdr.version != MINIDUMP_VERSION && vmst->hdr.version != 1) { _kvm_err(kd, kd->program, "wrong minidump version. " "Expected %d got %d", MINIDUMP_VERSION, vmst->hdr.version); return (-1); @@ -114,15 +114,21 @@ _aarch64_minidump_initvtop(kvm_t *kd) vmst->hdr.dmapphys = le64toh(vmst->hdr.dmapphys); vmst->hdr.dmapbase = le64toh(vmst->hdr.dmapbase); vmst->hdr.dmapend = le64toh(vmst->hdr.dmapend); + vmst->hdr.dumpavailsize = vmst->hdr.version == MINIDUMP_VERSION ? + le32toh(vmst->hdr.dumpavailsize) : 0; /* Skip header and msgbuf */ - off = AARCH64_PAGE_SIZE + aarch64_round_page(vmst->hdr.msgbufsize); + dump_avail_off = AARCH64_PAGE_SIZE + aarch64_round_page(vmst->hdr.msgbufsize); + /* Skip dump_avail */ + off = dump_avail_off + aarch64_round_page(vmst->hdr.dumpavailsize); + /* build physical address lookup table for sparse pages */ sparse_off = off + aarch64_round_page(vmst->hdr.bitmapsize) + aarch64_round_page(vmst->hdr.pmapsize); - if (_kvm_pt_init(kd, vmst->hdr.bitmapsize, off, sparse_off, - AARCH64_PAGE_SIZE, sizeof(uint64_t)) == -1) { + if (_kvm_pt_init(kd, vmst->hdr.dumpavailsize, dump_avail_off, + vmst->hdr.bitmapsize, off, sparse_off, AARCH64_PAGE_SIZE, + sizeof(uint64_t)) == -1) { return (-1); } off += aarch64_round_page(vmst->hdr.bitmapsize); @@ -257,7 +263,9 @@ _aarch64_minidump_walk_pages(kvm_t *kd, kvm_walk_pages } while (_kvm_bitmap_next(&bm, &bmindex)) { - pa = bmindex * AARCH64_PAGE_SIZE; + pa = _kvm_bit_id_pa(kd, bmindex, AARCH64_PAGE_SIZE); + if (pa == _KVM_PA_INVALID) + break; dva = vm->hdr.dmapbase + pa; if (vm->hdr.dmapend < (dva + AARCH64_PAGE_SIZE)) break; Modified: head/lib/libkvm/kvm_minidump_amd64.c == --- head/lib/libkvm/kvm_minidump_amd64.cMon Sep 21 22:20:37 2020 (r365977) +++ head/lib/libkvm/kvm_minidump_amd64.cMon Sep 21 22:21:59 2020 (r365978) @@ -123,7 +123,7 @@ static int _amd64_minidump_initvtop(kvm_t *kd) { struct vmstate *vmst; - off_t off, sparse_off; + off_t off, dump_avail_off, sparse_off; vmst = _kvm_malloc(kd, sizeof(*vmst)); if (vmst == NULL) { @@ -143,10 +143,10 @@ _
svn commit: r365980 - head/sys/vm
Author: scottph Date: Mon Sep 21 22:22:53 2020 New Revision: 365980 URL: https://svnweb.freebsd.org/changeset/base/365980 Log: vm_reserv: Sparsify the vm_reserv_array when VM_PHYSSEG_SPARSE On an Ampere Altra system, the physical memory is populated sparsely within the physical address space, with only about 0.4% of physical addresses backed by RAM in the range [0, last_pa]. This is causing the vm_reserv_array to be over-sized by a few orders of magnitude, wasting roughly 5 GiB on a system with 256 GiB of RAM. The sparse allocation of vm_reserv_array is controlled by defining VM_PHYSSEG_SPARSE, with the dense allocation still remaining for platforms with VM_PHYSSEG_DENSE. Reviewed by: markj, alc, kib Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26130 Modified: head/sys/vm/vm_phys.h head/sys/vm/vm_reserv.c Modified: head/sys/vm/vm_phys.h == --- head/sys/vm/vm_phys.h Mon Sep 21 22:22:06 2020(r365979) +++ head/sys/vm/vm_phys.h Mon Sep 21 22:22:53 2020(r365980) @@ -69,6 +69,9 @@ struct vm_phys_seg { vm_paddr_t start; vm_paddr_t end; vm_page_t first_page; +#if VM_NRESERVLEVEL > 0 + vm_reserv_t first_reserv; +#endif int domain; struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX]; }; Modified: head/sys/vm/vm_reserv.c == --- head/sys/vm/vm_reserv.c Mon Sep 21 22:22:06 2020(r365979) +++ head/sys/vm/vm_reserv.c Mon Sep 21 22:22:53 2020(r365980) @@ -333,11 +333,17 @@ sysctl_vm_reserv_fullpop(SYSCTL_HANDLER_ARGS) for (segind = 0; segind < vm_phys_nsegs; segind++) { seg = &vm_phys_segs[segind]; paddr = roundup2(seg->start, VM_LEVEL_0_SIZE); +#ifdef VM_PHYSSEG_SPARSE + rv = seg->first_reserv + (paddr >> VM_LEVEL_0_SHIFT) - + (seg->start >> VM_LEVEL_0_SHIFT); +#else + rv = &vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT]; +#endif while (paddr + VM_LEVEL_0_SIZE > paddr && paddr + VM_LEVEL_0_SIZE <= seg->end) { - rv = &vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT]; fullpop += rv->popcnt == VM_LEVEL_0_NPAGES; paddr += VM_LEVEL_0_SIZE; + rv++; } } return (sysctl_handle_int(oidp, &fullpop, 0, req)); @@ -496,8 +502,15 @@ vm_reserv_depopulate(vm_reserv_t rv, int index) static __inline vm_reserv_t vm_reserv_from_page(vm_page_t m) { +#ifdef VM_PHYSSEG_SPARSE + struct vm_phys_seg *seg; + seg = &vm_phys_segs[m->segind]; + return (seg->first_reserv + (VM_PAGE_TO_PHYS(m) >> VM_LEVEL_0_SHIFT) - + (seg->start >> VM_LEVEL_0_SHIFT)); +#else return (&vm_reserv_array[VM_PAGE_TO_PHYS(m) >> VM_LEVEL_0_SHIFT]); +#endif } /* @@ -1054,22 +1067,38 @@ vm_reserv_init(void) struct vm_phys_seg *seg; struct vm_reserv *rv; struct vm_reserv_domain *rvd; +#ifdef VM_PHYSSEG_SPARSE + vm_pindex_t used; +#endif int i, j, segind; /* * Initialize the reservation array. Specifically, initialize the * "pages" field for every element that has an underlying superpage. */ +#ifdef VM_PHYSSEG_SPARSE + used = 0; +#endif for (segind = 0; segind < vm_phys_nsegs; segind++) { seg = &vm_phys_segs[segind]; +#ifdef VM_PHYSSEG_SPARSE + seg->first_reserv = &vm_reserv_array[used]; + used += howmany(seg->end, VM_LEVEL_0_SIZE) - + seg->start / VM_LEVEL_0_SIZE; +#else + seg->first_reserv = + &vm_reserv_array[seg->start >> VM_LEVEL_0_SHIFT]; +#endif paddr = roundup2(seg->start, VM_LEVEL_0_SIZE); + rv = seg->first_reserv + (paddr >> VM_LEVEL_0_SHIFT) - + (seg->start >> VM_LEVEL_0_SHIFT); while (paddr + VM_LEVEL_0_SIZE > paddr && paddr + VM_LEVEL_0_SIZE <= seg->end) { - rv = &vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT]; rv->pages = PHYS_TO_VM_PAGE(paddr); rv->domain = seg->domain; mtx_init(&rv->lock, "vm reserv", NULL, MTX_DEF); paddr += VM_LEVEL_0_SIZE; + rv++; } } for (i = 0; i < MAXMEMDOM; i++) { @@ -1400,30 +1429,40 @@ vm_reserv_size(int level) vm_paddr_t vm_reserv_startup(vm_offset_t *vaddr, vm_paddr_t end) { - vm_paddr_t new_end, high_water; + vm_paddr_t new_end; + vm_pindex_t count; size_t size;
svn commit: r365981 - in head/sys: arm64/arm64 vm
Author: scottph Date: Mon Sep 21 22:23:57 2020 New Revision: 365981 URL: https://svnweb.freebsd.org/changeset/base/365981 Log: arm64/pmap: Sparsify pv_table Reviewed by: markj, kib Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26132 Modified: head/sys/arm64/arm64/pmap.c head/sys/vm/vm_phys.h Modified: head/sys/arm64/arm64/pmap.c == --- head/sys/arm64/arm64/pmap.c Mon Sep 21 22:22:53 2020(r365980) +++ head/sys/arm64/arm64/pmap.c Mon Sep 21 22:23:57 2020(r365981) @@ -178,8 +178,32 @@ __FBSDID("$FreeBSD$"); #endif #definepmap_l2_pindex(v) ((v) >> L2_SHIFT) -#definepa_to_pvh(pa) (&pv_table[pmap_l2_pindex(pa)]) +static struct md_page * +pa_to_pvh(vm_paddr_t pa) +{ + struct vm_phys_seg *seg; + int segind; + + for (segind = 0; segind < vm_phys_nsegs; segind++) { + seg = &vm_phys_segs[segind]; + if (pa >= seg->start && pa < seg->end) + return ((struct md_page *)seg->md_first + + pmap_l2_pindex(pa) - pmap_l2_pindex(seg->start)); + } + panic("pa 0x%jx not within vm_phys_segs", (uintmax_t)pa); +} + +static struct md_page * +page_to_pvh(vm_page_t m) +{ + struct vm_phys_seg *seg; + + seg = &vm_phys_segs[m->segind]; + return ((struct md_page *)seg->md_first + + pmap_l2_pindex(VM_PAGE_TO_PHYS(m)) - pmap_l2_pindex(seg->start)); +} + #defineNPV_LIST_LOCKS MAXCPU #definePHYS_TO_PV_LIST_LOCK(pa)\ @@ -1049,6 +1073,8 @@ pmap_init_asids(struct asid_set *set, int bits) void pmap_init(void) { + struct vm_phys_seg *seg, *next_seg; + struct md_page *pvh; vm_size_t s; uint64_t mmfr1; int i, pv_npg, vmid_bits; @@ -1093,7 +1119,12 @@ pmap_init(void) /* * Calculate the size of the pv head table for superpages. */ - pv_npg = howmany(vm_phys_segs[vm_phys_nsegs - 1].end, L2_SIZE); + pv_npg = 0; + for (i = 0; i < vm_phys_nsegs; i++) { + seg = &vm_phys_segs[i]; + pv_npg += pmap_l2_pindex(roundup2(seg->end, L2_SIZE)) - + pmap_l2_pindex(seg->start); + } /* * Allocate memory for the pv head table for superpages. @@ -1105,6 +1136,31 @@ pmap_init(void) TAILQ_INIT(&pv_table[i].pv_list); TAILQ_INIT(&pv_dummy.pv_list); + /* +* Set pointers from vm_phys_segs to pv_table. +*/ + for (i = 0, pvh = pv_table; i < vm_phys_nsegs; i++) { + seg = &vm_phys_segs[i]; + seg->md_first = pvh; + pvh += pmap_l2_pindex(roundup2(seg->end, L2_SIZE)) - + pmap_l2_pindex(seg->start); + + /* +* If there is a following segment, and the final +* superpage of this segment and the initial superpage +* of the next segment are the same then adjust the +* pv_table entry for that next segment down by one so +* that the pv_table entries will be shared. +*/ + if (i + 1 < vm_phys_nsegs) { + next_seg = &vm_phys_segs[i + 1]; + if (pmap_l2_pindex(roundup2(seg->end, L2_SIZE)) - 1 == + pmap_l2_pindex(next_seg->start)) { + pvh--; + } + } + } + vm_initialized = 1; } @@ -2247,7 +2303,7 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l m->md.pv_gen++; if (TAILQ_EMPTY(&m->md.pv_list) && (m->flags & PG_FICTITIOUS) == 0) { - pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); + pvh = page_to_pvh(m); if (TAILQ_EMPTY(&pvh->pv_list)) { vm_page_aflag_clear(m, PGA_WRITEABLE); @@ -2788,7 +2844,7 @@ pmap_remove_l3(pmap_t pmap, pt_entry_t *l3, vm_offset_ pmap_pvh_free(&m->md, pmap, va); if (TAILQ_EMPTY(&m->md.pv_list) && (m->flags & PG_FICTITIOUS) == 0) { - pvh = pa_to_pvh(VM_PAGE_TO_PHYS(m)); + pvh = page_to_pvh(m); if (TAILQ_EMPTY(&pvh->pv_list)) vm_page_aflag_clear(m, PGA_WRITEABLE); } @@ -2858,7 +2914,7 @@ pmap_remove_l3_range(pmap_t pmap, pd_entry_t l2e, vm_o pmap_pvh_free(&m->md, pmap, sva); if (TAILQ_EMPTY(&m->md.pv_list) &&
svn commit: r365982 - head/stand/common
Author: scottph Date: Mon Sep 21 22:24:46 2020 New Revision: 365982 URL: https://svnweb.freebsd.org/changeset/base/365982 Log: stand/reloc_elf: Handle relative relocations for arm{,64} and riscv Extend the powerpc relative relocation handling from r240782 to a handful of other architectures. This is needed to properly read dependency information from kernel modules. Reviewed by: jhb Approved by: scottl (implicit) MFC after:1 week Sponsored by: Ampere Computing, Inc. Differential Revision:https://reviews.freebsd.org/D26365 Modified: head/stand/common/reloc_elf.c Modified: head/stand/common/reloc_elf.c == --- head/stand/common/reloc_elf.c Mon Sep 21 22:23:57 2020 (r365981) +++ head/stand/common/reloc_elf.c Mon Sep 21 22:24:46 2020 (r365982) @@ -175,7 +175,8 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr } return (0); -#elif defined(__powerpc__) +#elif defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) || \ +defined(__riscv) Elf_Size w; const Elf_Rela *rela; @@ -185,7 +186,15 @@ __elfN(reloc)(struct elf_file *ef, symaddr_fn *symaddr if (relbase + rela->r_offset >= dataaddr && relbase + rela->r_offset < dataaddr + len) { switch (ELF_R_TYPE(rela->r_info)) { +#if defined(__aarch64__) + case R_AARCH64_RELATIVE: +#elif defined(__arm__) + case R_ARM_RELATIVE: +#elif defined(__powerpc__) case R_PPC_RELATIVE: +#elif defined(__riscv) + case R_RISCV_RELATIVE: +#endif w = relbase + rela->r_addend; bcopy(&w, (u_char *)data + (relbase + rela->r_offset - dataaddr), sizeof(w)); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"