Browse Source

Merge branch 'freebsd/current/master' into hardened/current/master

* freebsd/current/master:
  netbsd-tests: libc: use correct modes in O_SEARCH tests
  amdtemp(4): Remove dead code that snuck in with r357190
  caroot: blacklisted: automatically pick up *.pem in the tree
  amdtemp(4): Add support for Family 17h CCD sensors
  amdtemp(4): Refactor shared temperature calculation logic
  x86: identcpu: Decode new Intel Structured Extended feature bits
  x86: identcpu: Decode new Zen2 AMD Feature2 bit
  Remove old device list
  bsdinstall: Provide help text for partitioning options
  multi-boot for openstack/qcow images
  Make mqueue objects work across a fork again.
  No need to have an extra layer of indirection here. Call the sdhci_cam_requiest routine directly when handling a MMIO request.
  Create a convenince wrapper to fill in a CAM_PATH_INQ request for MMC sims. Pass in the parameters needed for the different sims, but it's almost all identical.
  Correct the use of RB_AUGMENT in the RB_TREE macros so that is invoked at the root of every subtree that changes in an insert or delete, and only once, and ordered from the bottom of the tree to the top.  For intel_gas.c, the only user of RB_AUGMENT I can find, change the augmenting routine so that it does not climb from entry to tree root on every call, and remove a 'tree correcting' function that can be supplanted by proper tree augmentation.
  Fix aggregating geoms for BIO_SPEEDUP.
  Build hard-float lib32 for mips64hf/mips64elhf
  Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOS
hardened/current/master
HardenedBSD Sync Service 4 months ago
parent
commit
66fb17fbee
26 changed files with 417 additions and 486 deletions
  1. +10
    -10
      contrib/netbsd-tests/lib/libc/c063/t_o_search.c
  2. +3
    -0
      release/tools/openstack.conf
  3. +44
    -11
      sbin/newfs_msdos/mkfs_msdos.c
  4. +3
    -1
      secure/caroot/blacklisted/Makefile
  5. +2
    -147
      share/man/man4/umass.4
  6. +1
    -2
      share/mk/bsd.compat.mk
  7. +4
    -26
      sys/arm/allwinner/aw_mmc.c
  8. +4
    -0
      sys/cam/mmc/mmc_all.h
  9. +29
    -0
      sys/cam/mmc/mmc_xpt.c
  10. +1
    -1
      sys/dev/amdsmn/amdsmn.c
  11. +116
    -22
      sys/dev/amdtemp/amdtemp.c
  12. +0
    -2
      sys/dev/mmc/host/dwmmc.c
  13. +3
    -42
      sys/dev/sdhci/sdhci.c
  14. +4
    -0
      sys/fs/msdosfs/msdosfsmount.h
  15. +4
    -1
      sys/geom/geom_subr.c
  16. +2
    -0
      sys/geom/stripe/g_stripe.c
  17. +1
    -0
      sys/kern/uipc_mqueue.c
  18. +38
    -50
      sys/sys/tree.h
  19. +2
    -1
      sys/x86/iommu/intel_dmar.h
  20. +3
    -3
      sys/x86/iommu/intel_drv.c
  21. +89
    -150
      sys/x86/iommu/intel_gas.c
  22. +3
    -1
      sys/x86/x86/identcpu.c
  23. +19
    -1
      tools/build/Makefile
  24. +28
    -11
      usr.sbin/bsdinstall/scripts/auto
  25. +0
    -4
      usr.sbin/makefs/msdos/msdosfs_denode.c
  26. +4
    -0
      usr.sbin/makefs/msdos/msdosfs_vnops.c

+ 10
- 10
contrib/netbsd-tests/lib/libc/c063/t_o_search.c View File

@@ -79,7 +79,7 @@ ATF_TC_BODY(o_search_perm1, tc)
ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);
ATF_REQUIRE(close(fd) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) == -1);
ATF_REQUIRE(errno == EACCES);
@@ -109,12 +109,12 @@ ATF_TC_BODY(o_search_root_flag1, tc)
ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);
ATF_REQUIRE(close(fd) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);
ATF_REQUIRE(close(fd) == 0);

ATF_REQUIRE(fchmod(dfd, 444) == 0);
ATF_REQUIRE(fchmod(dfd, 0444) == 0);

ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);

@@ -141,12 +141,12 @@ ATF_TC_BODY(o_search_unpriv_flag1, tc)
ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);
ATF_REQUIRE(close(fd) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);
ATF_REQUIRE(close(fd) == 0);

ATF_REQUIRE(fchmod(dfd, 444) == 0);
ATF_REQUIRE(fchmod(dfd, 0444) == 0);

ATF_REQUIRE((fd = openat(dfd, BASEFILE, O_RDWR, 0)) != -1);

@@ -173,7 +173,7 @@ ATF_TC_BODY(o_search_perm2, tc)

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == -1);
ATF_REQUIRE(errno == EACCES);
@@ -202,11 +202,11 @@ ATF_TC_BODY(o_search_root_flag2, tc)

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

ATF_REQUIRE(fchmod(dfd, 444) == 0);
ATF_REQUIRE(fchmod(dfd, 0444) == 0);

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

@@ -232,11 +232,11 @@ ATF_TC_BODY(o_search_unpriv_flag2, tc)

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

ATF_REQUIRE(fchmod(dfd, 644) == 0);
ATF_REQUIRE(fchmod(dfd, 0644) == 0);

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);

ATF_REQUIRE(fchmod(dfd, 444) == 0);
ATF_REQUIRE(fchmod(dfd, 0444) == 0);

ATF_REQUIRE(faccessat(dfd, BASEFILE, W_OK, 0) == 0);


+ 3
- 0
release/tools/openstack.conf View File

@@ -41,6 +41,9 @@ vm_extra_pre_umount() {
# The console is not interactive, so we might as well boot quickly.
echo 'autoboot_delay="-1"' >> ${DESTDIR}/boot/loader.conf
echo 'beastie_disable="YES"' >> ${DESTDIR}/boot/loader.conf
echo 'boot_multicons="YES"' >> ${DESTDIR}/boot/loader.conf
echo 'console="comconsole vidconsole"' >> ${DESTDIR}/boot/loader.conf
echo 'comconsole_speed="115200"' >> ${DESTDIR}/boot/loader.conf

# Reboot quickly, Don't wait at the panic screen
echo 'debug.trace_on_panic=1' >> ${DESTDIR}/etc/sysctl.conf

+ 44
- 11
sbin/newfs_msdos/mkfs_msdos.c View File

@@ -31,10 +31,15 @@ static const char rcsid[] =
#endif /* not lint */

#include <sys/param.h>
#ifdef MAKEFS
/* In the makefs case we only want struct disklabel */
#include <sys/disk/bsd.h>
#else
#include <sys/fdcio.h>
#include <sys/disk.h>
#include <sys/disklabel.h>
#include <sys/mount.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>

@@ -285,14 +290,18 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
if (!S_ISREG(sb.st_mode))
warnx("warning, %s is not a regular file", fname);
} else {
#ifndef MAKEFS
#ifdef MAKEFS
errx(1, "o.create_size must be set!");
#else
if (!S_ISCHR(sb.st_mode))
warnx("warning, %s is not a character device", fname);
#endif
}
#ifndef MAKEFS
if (!o.no_create)
if (check_mounted(fname, sb.st_mode) == -1)
goto done;
#endif
if (o.offset && o.offset != lseek(fd, o.offset, SEEK_SET)) {
warnx("cannot seek to %jd", (intmax_t)o.offset);
goto done;
@@ -621,10 +630,12 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
bpb.bpbBigFATsecs) * bpb.bpbFATs;
memset(&si_sa, 0, sizeof(si_sa));
si_sa.sa_handler = infohandler;
#ifdef SIGINFO
if (sigaction(SIGINFO, &si_sa, NULL) == -1) {
warn("sigaction SIGINFO");
goto done;
}
#endif
for (lsn = 0; lsn < dir + (fat == 32 ? bpb.bpbSecPerClust : rds); lsn++) {
if (got_siginfo) {
fprintf(stderr,"%s: writing sector %u of %u (%u%%)\n",
@@ -766,6 +777,11 @@ done:
static int
check_mounted(const char *fname, mode_t mode)
{
/*
* If getmntinfo() is not available (e.g. Linux) don't check. This should
* not be a problem since we will only be using makefs to create images.
*/
#if !defined(MAKEFS)
struct statfs *mp;
const char *s1, *s2;
size_t len;
@@ -790,6 +806,7 @@ check_mounted(const char *fname, mode_t mode)
return -1;
}
}
#endif
return 0;
}

@@ -811,6 +828,23 @@ getstdfmt(const char *fmt, struct bpb *bpb)
return 0;
}

static void
compute_geometry_from_file(int fd, const char *fname, struct disklabel *lp)
{
struct stat st;
off_t ms;

if (fstat(fd, &st))
err(1, "cannot get disk size");
if (!S_ISREG(st.st_mode))
errx(1, "%s is not a regular file", fname);
ms = st.st_size;
lp->d_secsize = 512;
lp->d_nsectors = 63;
lp->d_ntracks = 255;
lp->d_secperunit = ms / lp->d_secsize;
}

/*
* Get disk slice, partition, and geometry information.
*/
@@ -819,8 +853,10 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag,
struct bpb *bpb)
{
struct disklabel *lp, dlp;
off_t hs = 0;
#ifndef MAKEFS
off_t ms;
struct fd_type type;
off_t ms, hs = 0;

lp = NULL;

@@ -832,16 +868,8 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag,
/* Maybe it's a floppy drive */
if (lp == NULL) {
if (ioctl(fd, DIOCGMEDIASIZE, &ms) == -1) {
struct stat st;

if (fstat(fd, &st))
err(1, "cannot get disk size");
/* create a fake geometry for a file image */
ms = st.st_size;
dlp.d_secsize = 512;
dlp.d_nsectors = 63;
dlp.d_ntracks = 255;
dlp.d_secperunit = ms / dlp.d_secsize;
compute_geometry_from_file(fd, fname, &dlp);
lp = &dlp;
} else if (ioctl(fd, FD_GTYPE, &type) != -1) {
dlp.d_secsize = 128 << type.secsize;
@@ -881,6 +909,11 @@ getdiskinfo(int fd, const char *fname, const char *dtype, __unused int oflag,
hs = (ms / dlp.d_secsize) - dlp.d_secperunit;
lp = &dlp;
}
#else
/* In the makefs case we only support image files: */
compute_geometry_from_file(fd, fname, &dlp);
lp = &dlp;
#endif

if (bpb->bpbBytesPerSec == 0) {
if (ckgeom(fname, lp->d_secsize, "bytes/sector") == -1)

+ 3
- 1
secure/caroot/blacklisted/Makefile View File

@@ -2,6 +2,8 @@

BINDIR= /usr/share/certs/blacklisted

FILES=
BLACKLISTED_CERTS!= ls ${.CURDIR}/*.pem 2> /dev/null || true

FILES+= ${BLACKLISTED_CERTS}

.include <bsd.prog.mk>

+ 2
- 147
share/man/man4/umass.4 View File

@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 19, 2014
.Dd January 27, 2020
.Dt UMASS 4
.Os
.Sh NAME
@@ -73,114 +73,6 @@ requires
and
.Xr scbus 4
to be included in the kernel.
.Sh HARDWARE
The
.Nm
driver supports USB Mass Storage devices, including:
.Pp
.Bl -bullet -compact
.It
ADTEC Stick Drive AD-UST32M, 64M, 128M, 256M
.It
Denno FireWire/USB2 Removable 2.5-inch HDD Case MIFU-25CB20
.It
FujiFilm Zip USB Drive ZDR100 USB A
.It
GREEN HOUSE USB Flash Memory "PicoDrive" GH-UFD32M, 64M, 128M
.It
Huawei Mobile (SD slot)
.It
IBM 32MB USB Memory Key (P/N 22P5296)
.It
IBM 256MB USB Drive (MSYSTEM DiskOnKey2)
.It
IBM ThinkPad USB Portable CD-ROM Drive (P/N 33L5151)
.It
I-O DATA USB CD/CD-R/CD-RW/DVD-R/DVD-RW/DVD-RAM/DVD-ROM Drive DVR-iUH2 (CDROM, DVD-RAM only)
.It
I-O DATA USB x6 CD-RW Drive CDRW-i64/USB (CDROM only)
.It
I-O DATA USB/IEEE1394 Portable HD Drive HDP-i30P/CI, HDP-i40P/CI
.It
Iomega USB Zip 100/250 drive
.It
Iomega Zip750 USB2.0 drive
.It
Keian USB1.1/2.0 3.5-inch HDD Case KU350A
.It
Kurouto Shikou USB 2.5-inch HDD Case GAWAP2.5PS-USB2.0
.It
LaCie P3 HardDrive USB 200GB
.It
Logitec LDR-H443U2 DVD-RAM/-R/+R/-RW/+RW drive
.It
Logitec Mobile USB Memory LMC-256UD
.It
Logitec USB1.1/2.0 HDD Unit SHD-E60U2
.It
Logitec USB Double-Speed Floppy Drive LFD-31U2
.It
Logitec USB/IEEE1394 DVD-RAM/R/RW Unit LDR-N21FU2 (CDROM only)
.It
MELCO USB Flash Disk "ClipDrive", RUF-C32M, -C64M, -C128M, -C256M, -C512M
.It
MELCO USB Flash Disk "PetitDrive", RUF-32M, -64M, -128M, -256Mm
.It
MELCO USB2.0 Flash Disk "PetitDrive2", RUF-256M/U2, -512M/U2
.It
MELCO USB2.0 MO Drive MO-CH640U2
.It
Matshita CF-VFDU03 floppy drive
.It
Merlin SM300 MP3/WMA Player (256Mb)
.It
Microtech International, Inc.\& USB-SCSI-HD 50 USB to SCSI cable
.It
Motorola E398 Mobile Phone (TransFlash memory card)
.It
NOVAC USB2.0 2.5/3.5-inch HDD Case NV-HD351U
.It
PNY Attache Flash Drive
.It
Panasonic ("Matshita FDD CF-VFDU03")
.It
Panasonic KXL-CB20AN Portable DVD-ROM/CD-R/RW
.It
Panasonic KXL-CB35AN (DVD-ROM & CD-R/RW)
.It
Panasonic USB2.0 Portable CD-RW Drive KXL-RW40AN (CDROM only)
.It
Panasonic floppy drive
.It
Qware BeatZkey!\& Pro
.It
RATOC Systems USB2.0 Removable HDD Case U2-MDK1, U2-MDK1B
.It
SanDisk SDDR-31 (Compact Flash)
.It
SanDisk SDDR-75 (only Compact Flash port works)
.It
Sitecom CN-300 MultiFlash (MMC/SD, SmartMedia, CF, MemoryStick)
.It
Sony Portable CD-R/RW Drive CRX10U (CDROM only)
.It
TEAC Portable USB CD-ROM Unit CD-110PU/210PU
.It
Time DPA20B MP3 Player (1Gb)
.It
Trek Thumbdrive 8MB
.It
VAIO floppy drive (includes Y-E Data Flashbuster-U)
.It
Y-E Data floppy drive (720/1.44/2.88Mb)
.El
.Pp
Among the supported digital cameras are:
.Pp
.Bl -bullet -compact
.It
Asahi Optical (PENTAX) Optio 230 & 330
.El
.Sh EXAMPLES
.Bd -literal -offset indent
device umass
@@ -193,11 +85,6 @@ Add the
.Nm
driver to the kernel.
.Pp
.Dl "camcontrol rescan 0"
.Pp
Rescan a Zip drive that was added after boot.
The command above
assumes that the Zip drive is on the first SCSI bus in the system.
.Bd -literal -offset indent
camcontrol rescan 0:0:0
camcontrol rescan 0:0:1
@@ -208,46 +95,14 @@ camcontrol rescan 0:0:3
Rescan all slots on a multi-slot flash reader, where the slots map to separate
LUNs on a single SCSI ID.
Typically only the first slot will be enabled at boot time.
Again, this assumes that the flash reader is the first SCSI bus in the system.
.Bd -literal -offset indent
bsdlabel -w da0 zip100
newfs da0c
mount -t ufs /dev/da0c /mnt
.Ed
.Pp
Write a disklabel to the Zip drive (see
.Xr vpo 4
for the
.Xr disktab 5
entry), creates the file system and mounts the new file system on /mnt.
.Pp
.Dl "newfs_msdos /dev/da0"
.Pp
Create a new FAT type file system.
Care should be taken not to run
.Xr newfs 8
on devices that already contain data, as this will result in the
information being lost.
.Pp
Many consumer devices such as digital cameras automatically create
.Tn MS-DOS
based file systems when storing information such as images and
videos.
These file systems can be accessed by specifying the file system
type as
.Cm msdosfs
when using
.Xr mount 8 .
This assumes that the flash reader is the first SCSI bus in the system and has 4 slots.
.Sh SEE ALSO
.Xr cfumass 4 ,
.Xr ehci 4 ,
.Xr ohci 4 ,
.Xr uhci 4 ,
.Xr usb 4 ,
.Xr vpo 4 ,
.Xr xhci 4 ,
.Xr disktab 5 ,
.Xr bsdlabel 8 ,
.Xr camcontrol 8
.\".Sh HISTORY
.Sh AUTHORS

+ 1
- 2
share/mk/bsd.compat.mk View File

@@ -79,11 +79,10 @@ LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
.endif
LIB32CPUFLAGS+= -mabi=32
LIB32_MACHINE= mips
LIB32_MACHINE_ARCH:= ${COMPAT_ARCH:S/64//}
.if ${COMPAT_ARCH:Mmips64el*} != ""
LIB32_MACHINE_ARCH= mipsel
_EMULATION= elf32ltsmip_fbsd
.else
LIB32_MACHINE_ARCH= mips
_EMULATION= elf32btsmip_fbsd
.endif
LIB32WMAKEFLAGS= LD="${XLD} -m ${_EMULATION}"

+ 4
- 26
sys/arm/allwinner/aw_mmc.c View File

@@ -213,33 +213,11 @@ aw_mmc_cam_action(struct cam_sim *sim, union ccb *ccb)

switch (ccb->ccb_h.func_code) {
case XPT_PATH_INQ:
{
struct ccb_pathinq *cpi;

cpi = &ccb->cpi;
cpi->version_num = 1;
cpi->hba_inquiry = 0;
cpi->target_sprt = 0;
cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
cpi->hba_eng_cnt = 0;
cpi->max_target = 0;
cpi->max_lun = 0;
cpi->initiator_id = 1;
cpi->maxio = (sc->aw_mmc_conf->dma_xferlen *
AW_MMC_DMA_SEGS) / MMC_SECTOR_SIZE;
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
strncpy(cpi->hba_vid, "Deglitch Networks", HBA_IDLEN);
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
cpi->unit_number = cam_sim_unit(sim);
cpi->bus_id = cam_sim_bus(sim);
cpi->protocol = PROTO_MMCSD;
cpi->protocol_version = SCSI_REV_0;
cpi->transport = XPORT_MMCSD;
cpi->transport_version = 1;

cpi->ccb_h.status = CAM_REQ_CMP;
mmc_path_inq(&ccb->cpi, "Deglitch Networks", sim,
(sc->aw_mmc_conf->dma_xferlen * AW_MMC_DMA_SEGS) /
MMC_SECTOR_SIZE);
break;
}

case XPT_GET_TRAN_SETTINGS:
{
struct ccb_trans_settings *cts = &ccb->cts;

+ 4
- 0
sys/cam/mmc/mmc_all.h View File

@@ -68,5 +68,9 @@
#include <dev/mmc/mmcreg.h>

void mmc_print_ident(struct mmc_params *ident_data);
struct ccb_pathinq;
struct cam_sim;
void mmc_path_inq(struct ccb_pathinq *cpi, const char *hba,
const struct cam_sim *sim, size_t maxio);

#endif

+ 29
- 0
sys/cam/mmc/mmc_xpt.c View File

@@ -1104,3 +1104,32 @@ mmcprobe_done(struct cam_periph *periph, union ccb *done_ccb)
cam_periph_release_locked(periph);
}
}

void
mmc_path_inq(struct ccb_pathinq *cpi, const char *hba,
const struct cam_sim *sim, size_t maxio)
{

cpi->version_num = 1;
cpi->hba_inquiry = 0;
cpi->target_sprt = 0;
cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
cpi->hba_eng_cnt = 0;
cpi->max_target = 0;
cpi->max_lun = 0;
cpi->initiator_id = 1;
cpi->maxio = maxio;
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
strncpy(cpi->hba_vid, hba, HBA_IDLEN);
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
cpi->unit_number = cam_sim_unit(sim);
cpi->bus_id = cam_sim_bus(sim);
cpi->protocol = PROTO_MMCSD;
cpi->protocol_version = SCSI_REV_0;
cpi->transport = XPORT_MMCSD;
cpi->transport_version = 1;

cpi->base_transfer_speed = 100; /* XXX WTF? */

cpi->ccb_h.status = CAM_REQ_CMP;
}

+ 1
- 1
sys/dev/amdsmn/amdsmn.c View File

@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
#define PCI_DEVICE_ID_AMD_15H_M60H_ROOT 0x1576
#define PCI_DEVICE_ID_AMD_17H_ROOT 0x1450
#define PCI_DEVICE_ID_AMD_17H_M10H_ROOT 0x15d0
#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480
#define PCI_DEVICE_ID_AMD_17H_M30H_ROOT 0x1480 /* Also M70H. */

struct pciid;
struct amdsmn_softc {

+ 116
- 22
sys/dev/amdtemp/amdtemp.c View File

@@ -5,8 +5,7 @@
* Copyright (c) 2009 Norikatsu Shigemura <nork@FreeBSD.org>
* Copyright (c) 2009-2012 Jung-uk Kim <jkim@FreeBSD.org>
* All rights reserved.
* Copyright (c) 2017-2019 Conrad Meyer <cem@FreeBSD.org>
* All rights reserved.
* Copyright (c) 2017-2020 Conrad Meyer <cem@FreeBSD.org>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -61,7 +60,18 @@ typedef enum {
CORE1_SENSOR0,
CORE1_SENSOR1,
CORE0,
CORE1
CORE1,
CCD1,
CCD_BASE = CCD1,
CCD2,
CCD3,
CCD4,
CCD5,
CCD6,
CCD7,
CCD8,
CCD_MAX = CCD8,
NUM_CCDS = CCD_MAX - CCD_BASE + 1,
} amdsensor_t;

struct amdtemp_softc {
@@ -96,7 +106,7 @@ struct amdtemp_softc {
#define DEVICEID_AMD_MISC16_M30H 0x1583
#define DEVICEID_AMD_HOSTB17H_ROOT 0x1450
#define DEVICEID_AMD_HOSTB17H_M10H_ROOT 0x15d0
#define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480
#define DEVICEID_AMD_HOSTB17H_M30H_ROOT 0x1480 /* Also M70h. */

static const struct amdtemp_product {
uint16_t amdtemp_vendorid;
@@ -149,7 +159,15 @@ static const struct amdtemp_product {
* to -49..206C.
*/
#define AMDTEMP_17H_CUR_TMP 0x59800
#define AMDTEMP_17H_CUR_TMP_RANGE_SEL (1 << 19)
#define AMDTEMP_17H_CUR_TMP_RANGE_SEL (1u << 19)
/*
* The following register set was discovered experimentally by Ondrej Čerman
* and collaborators, but is not (yet) documented in a PPR/OSRR (other than
* the M70H PPR SMN memory map showing [0x59800, +0x314] as allocated to
* SMU::THM). It seems plausible and the Linux sensor folks have adopted it.
*/
#define AMDTEMP_17H_CCD_TMP_BASE 0x59954
#define AMDTEMP_17H_CCD_TMP_VALID (1u << 11)

/*
* AMD temperature range adjustment, in deciKelvins (i.e., 49.0 Celsius).
@@ -186,6 +204,7 @@ static int32_t amdtemp_gettemp0f(device_t dev, amdsensor_t sensor);
static int32_t amdtemp_gettemp(device_t dev, amdsensor_t sensor);
static int32_t amdtemp_gettemp15hm60h(device_t dev, amdsensor_t sensor);
static int32_t amdtemp_gettemp17h(device_t dev, amdsensor_t sensor);
static void amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model);
static int amdtemp_sysctl(SYSCTL_HANDLER_ARGS);

static device_method_t amdtemp_methods[] = {
@@ -485,7 +504,9 @@ amdtemp_attach(device_t dev)
dev, CORE0_SENSOR0, amdtemp_sysctl, "IK",
"Core 0 / Sensor 0 temperature");

if (sc->sc_ntemps > 1) {
if (family == 0x17)
amdtemp_probe_ccd_sensors17h(dev, model);
else if (sc->sc_ntemps > 1) {
SYSCTL_ADD_PROC(sysctlctx,
SYSCTL_CHILDREN(sysctlnode),
OID_AUTO, "sensor1", CTLTYPE_INT | CTLFLAG_RD,
@@ -638,6 +659,8 @@ amdtemp_gettemp0f(device_t dev, amdsensor_t sensor)
if ((sc->sc_flags & AMDTEMP_FLAG_CS_SWAP) == 0)
temp |= AMDTEMP_TTSR_SELCORE;
break;
default:
__unreachable();
}
pci_write_config(dev, AMDTEMP_THERMTP_STAT, temp, 1);

@@ -651,26 +674,46 @@ amdtemp_gettemp0f(device_t dev, amdsensor_t sensor)
}

static uint32_t
amdtemp_decode_fam10h_to_16h(int32_t sc_offset, uint32_t val)
amdtemp_decode_fam10h_to_17h(int32_t sc_offset, uint32_t val, bool minus49)
{
uint32_t temp;

/* Convert raw register subfield units (0.125C) to units of 0.1C. */
temp = ((val >> AMDTEMP_REPTMP10H_CURTMP_SHIFT) &
AMDTEMP_REPTMP10H_CURTMP_MASK) * 5 / 4;
temp = (val & AMDTEMP_REPTMP10H_CURTMP_MASK) * 5 / 4;

if (minus49)
temp -= AMDTEMP_CURTMP_RANGE_ADJUST;

temp += AMDTEMP_ZERO_C_TO_K + sc_offset * 10;
return (temp);
}

static uint32_t
amdtemp_decode_fam10h_to_16h(int32_t sc_offset, uint32_t val)
{
bool minus49;

/*
* On Family 15h and higher, if CurTmpTjSel is 11b, the range is
* adjusted down by 49.0 degrees Celsius. (This adjustment is not
* documented in BKDGs prior to family 15h model 00h.)
*/
if (CPUID_TO_FAMILY(cpu_id) >= 0x15 &&
minus49 = (CPUID_TO_FAMILY(cpu_id) >= 0x15 &&
((val >> AMDTEMP_REPTMP10H_TJSEL_SHIFT) &
AMDTEMP_REPTMP10H_TJSEL_MASK) == 0x3)
temp -= AMDTEMP_CURTMP_RANGE_ADJUST;
AMDTEMP_REPTMP10H_TJSEL_MASK) == 0x3);

temp += AMDTEMP_ZERO_C_TO_K + sc_offset * 10;
return (temp);
return (amdtemp_decode_fam10h_to_17h(sc_offset,
val >> AMDTEMP_REPTMP10H_CURTMP_SHIFT, minus49));
}

static uint32_t
amdtemp_decode_fam17h_tctl(int32_t sc_offset, uint32_t val)
{
bool minus49;

minus49 = ((val & AMDTEMP_17H_CUR_TMP_RANGE_SEL) != 0);
return (amdtemp_decode_fam10h_to_17h(sc_offset,
val >> AMDTEMP_REPTMP10H_CURTMP_SHIFT, minus49));
}

static int32_t
@@ -699,16 +742,67 @@ static int32_t
amdtemp_gettemp17h(device_t dev, amdsensor_t sensor)
{
struct amdtemp_softc *sc = device_get_softc(dev);
uint32_t temp, val;
uint32_t val;
int error;

error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &val);
KASSERT(error == 0, ("amdsmn_read"));
switch (sensor) {
case CORE0_SENSOR0:
/* Tctl */
error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CUR_TMP, &val);
KASSERT(error == 0, ("amdsmn_read"));
return (amdtemp_decode_fam17h_tctl(sc->sc_offset, val));
case CCD_BASE ... CCD_MAX:
/* Tccd<N> */
error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CCD_TMP_BASE +
(((int)sensor - CCD_BASE) * sizeof(val)), &val);
KASSERT(error == 0, ("amdsmn_read2"));
KASSERT((val & AMDTEMP_17H_CCD_TMP_VALID) != 0,
("sensor %d: not valid", (int)sensor));
return (amdtemp_decode_fam10h_to_17h(sc->sc_offset, val, true));
default:
__unreachable();
}
}

temp = ((val >> 21) & 0x7ff) * 5 / 4;
if ((val & AMDTEMP_17H_CUR_TMP_RANGE_SEL) != 0)
temp -= AMDTEMP_CURTMP_RANGE_ADJUST;
temp += AMDTEMP_ZERO_C_TO_K + sc->sc_offset * 10;
static void
amdtemp_probe_ccd_sensors17h(device_t dev, uint32_t model)
{
char sensor_name[16], sensor_descr[32];
struct amdtemp_softc *sc;
uint32_t maxreg, i, val;
int error;

return (temp);
switch (model) {
case 0x00 ... 0x1f: /* Zen1, Zen+ */
maxreg = 4;
break;
case 0x30 ... 0x3f: /* Zen2 TR/Epyc */
case 0x70 ... 0x7f: /* Zen2 Ryzen */
maxreg = 8;
_Static_assert((int)NUM_CCDS >= 8, "");
break;
default:
device_printf(dev,
"Unrecognized Family 17h Model: %02xh\n", model);
return;
}

sc = device_get_softc(dev);
for (i = 0; i < maxreg; i++) {
error = amdsmn_read(sc->sc_smn, AMDTEMP_17H_CCD_TMP_BASE +
(i * sizeof(val)), &val);
if (error != 0)
continue;
if ((val & AMDTEMP_17H_CCD_TMP_VALID) == 0)
continue;

snprintf(sensor_name, sizeof(sensor_name), "ccd%u", i);
snprintf(sensor_descr, sizeof(sensor_descr),
"CCD %u temperature (Tccd%u)", i, i);

SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
sensor_name, CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
dev, CCD_BASE + i, amdtemp_sysctl, "IK", sensor_descr);
}
}

+ 0
- 2
sys/dev/mmc/host/dwmmc.c View File

@@ -67,8 +67,6 @@ __FBSDID("$FreeBSD$");
#include <dev/mmc/host/dwmmc_reg.h>
#include <dev/mmc/host/dwmmc_var.h>

#include "opt_mmccam.h"

#include "mmcbr_if.h"

#define dprintf(x, arg...)

+ 3
- 42
sys/dev/sdhci/sdhci.c View File

@@ -124,7 +124,6 @@ static void sdhci_transfer_pio(struct sdhci_slot *slot);
static void sdhci_cam_action(struct cam_sim *sim, union ccb *ccb);
static int sdhci_cam_get_possible_host_clock(const struct sdhci_slot *slot,
int proposed_clock);
static void sdhci_cam_handle_mmcio(struct cam_sim *sim, union ccb *ccb);
static void sdhci_cam_poll(struct cam_sim *sim);
static int sdhci_cam_request(struct sdhci_slot *slot, union ccb *ccb);
static int sdhci_cam_settran_settings(struct sdhci_slot *slot, union ccb *ccb);
@@ -2560,16 +2559,6 @@ fail:
cam_simq_free(slot->devq);
}

static void
sdhci_cam_handle_mmcio(struct cam_sim *sim, union ccb *ccb)
{
struct sdhci_slot *slot;

slot = cam_sim_softc(sim);

sdhci_cam_request(slot, ccb);
}

void
sdhci_cam_action(struct cam_sim *sim, union ccb *ccb)
{
@@ -2586,33 +2575,9 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb)

switch (ccb->ccb_h.func_code) {
case XPT_PATH_INQ:
{
struct ccb_pathinq *cpi;

cpi = &ccb->cpi;
cpi->version_num = 1;
cpi->hba_inquiry = 0;
cpi->target_sprt = 0;
cpi->hba_misc = PIM_NOBUSRESET | PIM_SEQSCAN;
cpi->hba_eng_cnt = 0;
cpi->max_target = 0;
cpi->max_lun = 0;
cpi->initiator_id = 1;
cpi->maxio = MAXPHYS;
strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
strncpy(cpi->hba_vid, "Deglitch Networks", HBA_IDLEN);
strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
cpi->unit_number = cam_sim_unit(sim);
cpi->bus_id = cam_sim_bus(sim);
cpi->base_transfer_speed = 100; /* XXX WTF? */
cpi->protocol = PROTO_MMCSD;
cpi->protocol_version = SCSI_REV_0;
cpi->transport = XPORT_MMCSD;
cpi->transport_version = 0;

cpi->ccb_h.status = CAM_REQ_CMP;
mmc_path_inq(&ccb->cpi, "Deglitch Networks", sim, MAXPHYS);
break;
}

case XPT_GET_TRAN_SETTINGS:
{
struct ccb_trans_settings *cts = &ccb->cts;
@@ -2648,13 +2613,11 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb)
break;
}
case XPT_SET_TRAN_SETTINGS:
{
if (sdhci_debug > 1)
slot_printf(slot, "Got XPT_SET_TRAN_SETTINGS\n");
sdhci_cam_settran_settings(slot, ccb);
ccb->ccb_h.status = CAM_REQ_CMP;
break;
}
case XPT_RESET_BUS:
if (sdhci_debug > 1)
slot_printf(slot, "Got XPT_RESET_BUS, ACK it...\n");
@@ -2671,10 +2634,8 @@ sdhci_cam_action(struct cam_sim *sim, union ccb *ccb)
slot_printf(slot, "Got XPT_MMC_IO\n");
ccb->ccb_h.status = CAM_REQ_INPROG;

sdhci_cam_handle_mmcio(sim, ccb);
sdhci_cam_request(cam_sim_softc(sim), ccb);
return;
/* NOTREACHED */
break;
default:
ccb->ccb_h.status = CAM_REQ_INVALID;
break;

+ 4
- 0
sys/fs/msdosfs/msdosfsmount.h View File

@@ -56,8 +56,10 @@
#if defined (_KERNEL) || defined(MAKEFS)

#include <sys/types.h>
#ifndef MAKEFS
#include <sys/lock.h>
#include <sys/lockmgr.h>
#endif
#include <sys/tree.h>

#ifdef MALLOC_DECLARE
@@ -110,7 +112,9 @@ struct msdosfsmount {
void *pm_w2u; /* Unicode->Local iconv handle */
void *pm_u2d; /* Unicode->DOS iconv handle */
void *pm_d2u; /* DOS->Local iconv handle */
#ifndef MAKEFS
struct lock pm_fatlock; /* lockmgr protecting allocations */
#endif
};

/*

+ 4
- 1
sys/geom/geom_subr.c View File

@@ -1134,8 +1134,11 @@ g_std_done(struct bio *bp)
bp2->bio_completed += bp->bio_completed;
g_destroy_bio(bp);
bp2->bio_inbed++;
if (bp2->bio_children == bp2->bio_inbed)
if (bp2->bio_children == bp2->bio_inbed) {
if (bp2->bio_cmd == BIO_SPEEDUP)
bp2->bio_completed = bp2->bio_length;
g_io_deliver(bp2, bp2->bio_error);
}
}

/* XXX: maybe this is only g_slice_spoiled */

+ 2
- 0
sys/geom/stripe/g_stripe.c View File

@@ -298,6 +298,8 @@ g_stripe_done(struct bio *bp)
mtx_unlock(&sc->sc_lock);
if (pbp->bio_driver1 != NULL)
uma_zfree(g_stripe_zone, pbp->bio_driver1);
if (bp->bio_cmd == BIO_SPEEDUP)
pbp->bio_completed = pbp->bio_length;
g_io_deliver(pbp, pbp->bio_error);
} else
mtx_unlock(&sc->sc_lock);

+ 1
- 0
sys/kern/uipc_mqueue.c View File

@@ -2669,6 +2669,7 @@ static struct fileops mqueueops = {
.fo_chown = mqf_chown,
.fo_sendfile = invfo_sendfile,
.fo_fill_kinfo = mqf_fill_kinfo,
.fo_flags = DFLAG_PASSABLE,
};

static struct vop_vector mqfs_vnodeops = {

+ 38
- 50
sys/sys/tree.h View File

@@ -335,8 +335,12 @@ struct { \
RB_COLOR(red, field) = RB_RED; \
} while (/*CONSTCOND*/ 0)

/*
* Something to be invoked in a loop at the root of every modified subtree,
* from the bottom up to the root, to update augmented node data.
*/
#ifndef RB_AUGMENT
#define RB_AUGMENT(x) do {} while (0)
#define RB_AUGMENT(x) break
#endif

#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
@@ -344,7 +348,6 @@ struct { \
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
@@ -354,9 +357,7 @@ struct { \
(head)->rbh_root = (tmp); \
RB_LEFT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
RB_AUGMENT(elm); \
} while (/*CONSTCOND*/ 0)

#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
@@ -364,7 +365,6 @@ struct { \
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
@@ -374,9 +374,7 @@ struct { \
(head)->rbh_root = (tmp); \
RB_RIGHT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
RB_AUGMENT(elm); \
} while (/*CONSTCOND*/ 0)

/* Generates prototypes and inline functions */
@@ -571,62 +569,49 @@ name##_RB_REMOVE(struct name *head, struct type *elm) \
else if (RB_RIGHT(elm, field) == NULL) \
child = RB_LEFT(elm, field); \
else { \
struct type *left; \
elm = RB_RIGHT(elm, field); \
while ((left = RB_LEFT(elm, field)) != NULL) \
elm = left; \
child = RB_RIGHT(elm, field); \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
if (RB_PARENT(elm, field) == old) \
parent = elm; \
(elm)->field = (old)->field; \
if (RB_PARENT(old, field)) { \
if (RB_LEFT(RB_PARENT(old, field), field) == old)\
RB_LEFT(RB_PARENT(old, field), field) = elm;\
elm = RB_RIGHT(old, field); \
if ((child = RB_LEFT(elm, field)) == NULL) { \
child = RB_RIGHT(elm, field); \
RB_RIGHT(old, field) = child; \
RB_PARENT(elm, field) = elm; \
} else { \
do \
elm = child; \
while ((child = RB_LEFT(elm, field)) != NULL); \
child = RB_RIGHT(elm, field); \
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
} \
RB_PARENT(RB_LEFT(old, field), field) = elm; \
parent = RB_PARENT(old, field); \
if (parent != NULL) { \
if (RB_LEFT(parent, field) == old) \
RB_LEFT(parent, field) = elm; \
else \
RB_RIGHT(RB_PARENT(old, field), field) = elm;\
RB_AUGMENT(RB_PARENT(old, field)); \
RB_RIGHT(parent, field) = elm; \
} else \
RB_ROOT(head) = elm; \
RB_PARENT(RB_LEFT(old, field), field) = elm; \
if (RB_RIGHT(old, field)) \
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
if (parent) { \
left = parent; \
do { \
RB_AUGMENT(left); \
} while ((left = RB_PARENT(left, field)) != NULL); \
} \
goto color; \
} \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
if (child != NULL) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (parent != NULL) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
color: \
if (elm != old) \
(elm)->field = (old)->field; \
if (color == RB_BLACK) \
name##_RB_REMOVE_COLOR(head, parent, child); \
while (parent != NULL) { \
RB_AUGMENT(parent); \
parent = RB_PARENT(parent, field); \
} \
return (old); \
} \
}

#define RB_GENERATE_INSERT(name, type, field, cmp, attr) \
/* Inserts a node into the RB tree */ \
@@ -653,10 +638,13 @@ name##_RB_INSERT(struct name *head, struct type *elm) \
RB_LEFT(parent, field) = elm; \
else \
RB_RIGHT(parent, field) = elm; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = elm; \
name##_RB_INSERT_COLOR(head, elm); \
while (elm != NULL) { \
RB_AUGMENT(elm); \
elm = RB_PARENT(elm, field); \
} \
return (NULL); \
}


+ 2
- 1
sys/x86/iommu/intel_dmar.h View File

@@ -47,7 +47,8 @@ struct dmar_qi_genseq {
struct dmar_map_entry {
dmar_gaddr_t start;
dmar_gaddr_t end;
dmar_gaddr_t free_after; /* Free space after the entry */
dmar_gaddr_t first; /* Least start in subtree */
dmar_gaddr_t last; /* Greatest end in subtree */
dmar_gaddr_t free_down; /* Max free space below the
current R/B tree node */
u_int flags;

+ 3
- 3
sys/x86/iommu/intel_drv.c View File

@@ -1112,9 +1112,9 @@ dmar_print_domain_entry(const struct dmar_map_entry *entry)
struct dmar_map_entry *l, *r;

db_printf(
" start %jx end %jx free_after %jx free_down %jx flags %x ",
entry->start, entry->end, entry->free_after, entry->free_down,
entry->flags);
" start %jx end %jx first %jx last %jx free_down %jx flags %x ",
entry->start, entry->end, entry->first, entry->last,
entry->free_down, entry->flags);
db_printf("left ");
l = RB_LEFT(entry, rb_entry);
if (l == NULL)

+ 89
- 150
sys/x86/iommu/intel_gas.c View File

@@ -139,71 +139,52 @@ dmar_gas_cmp_entries(struct dmar_map_entry *a, struct dmar_map_entry *b)
static void
dmar_gas_augment_entry(struct dmar_map_entry *entry)
{
struct dmar_map_entry *l, *r;

for (; entry != NULL; entry = RB_PARENT(entry, rb_entry)) {
l = RB_LEFT(entry, rb_entry);
r = RB_RIGHT(entry, rb_entry);
if (l == NULL && r == NULL) {
entry->free_down = entry->free_after;
} else if (l == NULL && r != NULL) {
entry->free_down = MAX(entry->free_after, r->free_down);
} else if (/*l != NULL && */ r == NULL) {
entry->free_down = MAX(entry->free_after, l->free_down);
} else /* if (l != NULL && r != NULL) */ {
entry->free_down = MAX(entry->free_after, l->free_down);
entry->free_down = MAX(entry->free_down, r->free_down);
}
}
struct dmar_map_entry *child;
dmar_gaddr_t free_down;

free_down = 0;
if ((child = RB_LEFT(entry, rb_entry)) != NULL) {
free_down = MAX(free_down, child->free_down);
free_down = MAX(free_down, entry->start - child->last);
entry->first = child->first;
} else
entry->first = entry->start;
if ((child = RB_RIGHT(entry, rb_entry)) != NULL) {
free_down = MAX(free_down, child->free_down);
free_down = MAX(free_down, child->first - entry->end);
entry->last = child->last;
} else
entry->last = entry->end;
entry->free_down = free_down;
}

RB_GENERATE(dmar_gas_entries_tree, dmar_map_entry, rb_entry,
dmar_gas_cmp_entries);

static void
dmar_gas_fix_free(struct dmar_domain *domain, struct dmar_map_entry *entry)
{
struct dmar_map_entry *next;

next = RB_NEXT(dmar_gas_entries_tree, &domain->rb_root, entry);
entry->free_after = (next != NULL ? next->start : domain->end) -
entry->end;
dmar_gas_augment_entry(entry);
}

#ifdef INVARIANTS
static void
dmar_gas_check_free(struct dmar_domain *domain)
{
struct dmar_map_entry *entry, *next, *l, *r;
struct dmar_map_entry *entry, *l, *r;
dmar_gaddr_t v;

RB_FOREACH(entry, dmar_gas_entries_tree, &domain->rb_root) {
KASSERT(domain == entry->domain,
("mismatched free domain %p entry %p entry->domain %p",
domain, entry, entry->domain));
next = RB_NEXT(dmar_gas_entries_tree, &domain->rb_root, entry);
if (next == NULL) {
MPASS(entry->free_after == domain->end - entry->end);
} else {
MPASS(entry->free_after = next->start - entry->end);
MPASS(entry->end <= next->start);
}
l = RB_LEFT(entry, rb_entry);
r = RB_RIGHT(entry, rb_entry);
if (l == NULL && r == NULL) {
MPASS(entry->free_down == entry->free_after);
} else if (l == NULL && r != NULL) {
MPASS(entry->free_down = MAX(entry->free_after,
r->free_down));
} else if (r == NULL) {
MPASS(entry->free_down = MAX(entry->free_after,
l->free_down));
} else {
v = MAX(entry->free_after, l->free_down);
v = 0;
if (l != NULL) {
v = MAX(v, l->free_down);
v = MAX(v, entry->start - l->last);
}
if (r != NULL) {
v = MAX(v, r->free_down);
MPASS(entry->free_down == v);
v = MAX(v, r->first - entry->end);
}
MPASS(entry->free_down == v);
}
}
#endif
@@ -211,25 +192,17 @@ dmar_gas_check_free(struct dmar_domain *domain)
static bool
dmar_gas_rb_insert(struct dmar_domain *domain, struct dmar_map_entry *entry)
{
struct dmar_map_entry *prev, *found;
struct dmar_map_entry *found;

found = RB_INSERT(dmar_gas_entries_tree, &domain->rb_root, entry);
dmar_gas_fix_free(domain, entry);
prev = RB_PREV(dmar_gas_entries_tree, &domain->rb_root, entry);
if (prev != NULL)
dmar_gas_fix_free(domain, prev);
return (found == NULL);
}

static void
dmar_gas_rb_remove(struct dmar_domain *domain, struct dmar_map_entry *entry)
{
struct dmar_map_entry *prev;

prev = RB_PREV(dmar_gas_entries_tree, &domain->rb_root, entry);
RB_REMOVE(dmar_gas_entries_tree, &domain->rb_root, entry);
if (prev != NULL)
dmar_gas_fix_free(domain, prev);
}

void
@@ -246,13 +219,11 @@ dmar_gas_init_domain(struct dmar_domain *domain)

begin->start = 0;
begin->end = DMAR_PAGE_SIZE;
begin->free_after = domain->end - begin->end;
begin->flags = DMAR_MAP_ENTRY_PLACE | DMAR_MAP_ENTRY_UNMAPPED;
dmar_gas_rb_insert(domain, begin);

end->start = domain->end;
end->end = domain->end;
end->free_after = 0;
end->flags = DMAR_MAP_ENTRY_PLACE | DMAR_MAP_ENTRY_UNMAPPED;
dmar_gas_rb_insert(domain, end);

@@ -281,7 +252,6 @@ dmar_gas_fini_domain(struct dmar_domain *domain)
entry = RB_MAX(dmar_gas_entries_tree, &domain->rb_root);
KASSERT(entry->start == domain->end, ("end entry start %p", domain));
KASSERT(entry->end == domain->end, ("end entry end %p", domain));
KASSERT(entry->free_after == 0, ("end entry free_after %p", domain));
KASSERT(entry->flags == DMAR_MAP_ENTRY_PLACE,
("end entry flags %p", domain));
RB_REMOVE(dmar_gas_entries_tree, &domain->rb_root, entry);
@@ -305,19 +275,26 @@ struct dmar_gas_match_args {
struct dmar_map_entry *entry;
};

/*
* The interval [beg, end) is a free interval between two dmar_map_entries.
* maxaddr is an upper bound on addresses that can be allocated. Try to
* allocate space in the free interval, subject to the conditions expressed
* by a, and return 'true' if and only if the allocation attempt succeeds.
*/
static bool
dmar_gas_match_one(struct dmar_gas_match_args *a, struct dmar_map_entry *prev,
dmar_gaddr_t end)
dmar_gas_match_one(struct dmar_gas_match_args *a, dmar_gaddr_t beg,
dmar_gaddr_t end, dmar_gaddr_t maxaddr)
{
dmar_gaddr_t bs, start;

if (a->entry->start + a->size > end)
a->entry->start = roundup2(beg + DMAR_PAGE_SIZE,
a->common->alignment);
if (a->entry->start + a->size > maxaddr)
return (false);

/* DMAR_PAGE_SIZE to create gap after new entry. */
if (a->entry->start < prev->end + DMAR_PAGE_SIZE ||
a->entry->start + a->size + a->offset + DMAR_PAGE_SIZE >
prev->end + prev->free_after)
if (a->entry->start < beg + DMAR_PAGE_SIZE ||
a->entry->start + a->size + a->offset + DMAR_PAGE_SIZE > end)
return (false);

/* No boundary crossing. */
@@ -328,15 +305,14 @@ dmar_gas_match_one(struct dmar_gas_match_args *a, struct dmar_map_entry *prev,
/*
* The start + offset to start + offset + size region crosses
* the boundary. Check if there is enough space after the
* next boundary after the prev->end.
* next boundary after the beg.
*/
bs = rounddown2(a->entry->start + a->offset + a->common->boundary,
a->common->boundary);
start = roundup2(bs, a->common->alignment);
/* DMAR_PAGE_SIZE to create gap after new entry. */
if (start + a->offset + a->size + DMAR_PAGE_SIZE <=
prev->end + prev->free_after &&
start + a->offset + a->size <= end &&
if (start + a->offset + a->size + DMAR_PAGE_SIZE <= end &&
start + a->offset + a->size <= maxaddr &&
dmar_test_boundary(start + a->offset, a->size,
a->common->boundary)) {
a->entry->start = start;
@@ -346,7 +322,7 @@ dmar_gas_match_one(struct dmar_gas_match_args *a, struct dmar_map_entry *prev,
/*
* Not enough space to align at the requested boundary, or
* boundary is smaller than the size, but allowed to split.
* We already checked that start + size does not overlap end.
* We already checked that start + size does not overlap maxaddr.
*
* XXXKIB. It is possible that bs is exactly at the start of
* the next entry, then we do not have gap. Ignore for now.
@@ -360,10 +336,8 @@ dmar_gas_match_one(struct dmar_gas_match_args *a, struct dmar_map_entry *prev,
}

static void
dmar_gas_match_insert(struct dmar_gas_match_args *a,
struct dmar_map_entry *prev)
dmar_gas_match_insert(struct dmar_gas_match_args *a)
{
struct dmar_map_entry *next;
bool found;

/*
@@ -376,102 +350,67 @@ dmar_gas_match_insert(struct dmar_gas_match_args *a,
*/
a->entry->end = a->entry->start + a->size;

next = RB_NEXT(dmar_gas_entries_tree, &a->domain->rb_root, prev);
KASSERT(next->start >= a->entry->end &&
next->start - a->entry->start >= a->size &&
prev->end <= a->entry->end,
("dmar_gas_match_insert hole failed %p prev (%jx, %jx) "
"free_after %jx next (%jx, %jx) entry (%jx, %jx)", a->domain,
(uintmax_t)prev->start, (uintmax_t)prev->end,
(uintmax_t)prev->free_after,
(uintmax_t)next->start, (uintmax_t)next->end,
(uintmax_t)a->entry->start, (uintmax_t)a->entry->end));

prev->free_after = a->entry->start - prev->end;
a->entry->free_after = next->start - a->entry->end;

found = dmar_gas_rb_insert(a->domain, a->entry);
KASSERT(found, ("found dup %p start %jx size %jx",
a->domain, (uintmax_t)a->entry->start, (uintmax_t)a->size));
a->entry->flags = DMAR_MAP_ENTRY_MAP;

KASSERT(RB_PREV(dmar_gas_entries_tree, &a->domain->rb_root,
a->entry) == prev,
("entry %p prev %p inserted prev %p", a->entry, prev,
RB_PREV(dmar_gas_entries_tree, &a->domain->rb_root, a->entry)));
KASSERT(RB_NEXT(dmar_gas_entries_tree, &a->domain->rb_root,
a->entry) == next,
("entry %p next %p inserted next %p", a->entry, next,
RB_NEXT(dmar_gas_entries_tree, &a->domain->rb_root, a->entry)));
}

static int
dmar_gas_lowermatch(struct dmar_gas_match_args *a, struct dmar_map_entry *prev)
dmar_gas_lowermatch(struct dmar_gas_match_args *a, struct dmar_map_entry *entry)
{
struct dmar_map_entry *l;
int ret;

if (prev->end < a->common->lowaddr) {
a->entry->start = roundup2(prev->end + DMAR_PAGE_SIZE,
a->common->alignment);
if (dmar_gas_match_one(a, prev, a->common->lowaddr)) {
dmar_gas_match_insert(a, prev);
return (0);
}
struct dmar_map_entry *child;

child = RB_RIGHT(entry, rb_entry);
if (child != NULL && entry->end < a->common->lowaddr &&
dmar_gas_match_one(a, entry->end, child->first,
a->common->lowaddr)) {
dmar_gas_match_insert(a);
return (0);
}
if (prev->free_down < a->size + a->offset + DMAR_PAGE_SIZE)
if (entry->free_down < a->size + a->offset + DMAR_PAGE_SIZE)
return (ENOMEM);
l = RB_LEFT(prev, rb_entry);
if (l != NULL) {
ret = dmar_gas_lowermatch(a, l);
if (ret == 0)
return (0);
child = RB_LEFT(entry, rb_entry);
if (child != NULL && 0 == dmar_gas_lowermatch(a, child))
return (0);
if (child != NULL && child->last < a->common->lowaddr &&
dmar_gas_match_one(a, child->last, entry->start,
a->common->lowaddr)) {
dmar_gas_match_insert(a);
return (0);
}
l = RB_RIGHT(prev, rb_entry);
if (l != NULL)
return (dmar_gas_lowermatch(a, l));
child = RB_RIGHT(entry, rb_entry);
if (child != NULL && 0 == dmar_gas_lowermatch(a, child))
return (0);
return (ENOMEM);
}

static int
dmar_gas_uppermatch(struct dmar_gas_match_args *a)
dmar_gas_uppermatch(struct dmar_gas_match_args *a, struct dmar_map_entry *entry)
{
struct dmar_map_entry *next, *prev, find_entry;
struct dmar_map_entry *child;

find_entry.start = a->common->highaddr;
next = RB_NFIND(dmar_gas_entries_tree, &a->domain->rb_root,
&find_entry);
if (next == NULL)
if (entry->last < a->common->highaddr)
return (ENOMEM);
prev = RB_PREV(dmar_gas_entries_tree, &a->domain->rb_root, next);
KASSERT(prev != NULL, ("no prev %p %jx", a->domain,
(uintmax_t)find_entry.start));
for (;;) {
a->entry->start = prev->start + DMAR_PAGE_SIZE;
if (a->entry->start < a->common->highaddr)
a->entry->start = a->common->highaddr;
a->entry->start = roundup2(a->entry->start,
a->common->alignment);
if (dmar_gas_match_one(a, prev, a->domain->end)) {
dmar_gas_match_insert(a, prev);
return (0);
}

/*
* XXXKIB. This falls back to linear iteration over
* the free space in the high region. But high
* regions are almost unused, the code should be
* enough to cover the case, although in the
* non-optimal way.
*/
prev = next;
next = RB_NEXT(dmar_gas_entries_tree, &a->domain->rb_root,
prev);
KASSERT(next != NULL, ("no next %p %jx", a->domain,
(uintmax_t)find_entry.start));
if (next->end >= a->domain->end)
return (ENOMEM);
child = RB_LEFT(entry, rb_entry);
if (child != NULL && 0 == dmar_gas_uppermatch(a, child))
return (0);
if (child != NULL && child->last >= a->common->highaddr &&
dmar_gas_match_one(a, child->last, entry->start,
a->domain->end)) {
dmar_gas_match_insert(a);
return (0);
}
child = RB_RIGHT(entry, rb_entry);
if (child != NULL && entry->end >= a->common->highaddr &&
dmar_gas_match_one(a, entry->end, child->first,
a->domain->end)) {
dmar_gas_match_insert(a);
return (0);
}
if (child != NULL && 0 == dmar_gas_uppermatch(a, child))
return (0);
return (ENOMEM);
}

static int
@@ -504,7 +443,7 @@ dmar_gas_find_space(struct dmar_domain *domain,
/* Handle upper region. */
if (common->highaddr >= domain->end)
return (ENOMEM);
error = dmar_gas_uppermatch(&a);
error = dmar_gas_uppermatch(&a, RB_ROOT(&domain->rb_root));
KASSERT(error == ENOMEM,
("error %d from dmar_gas_uppermatch", error));
return (error);

+ 3
- 1
sys/x86/x86/identcpu.c View File

@@ -934,7 +934,7 @@ printcpuinfo(void)
"\034PTSC" /* Performance TSC */
"\035PL2I" /* L2I perf count */
"\036MWAITX" /* MONITORX/MWAITX instructions */
"\037<b30>"
"\037ADMSKX" /* Address mask extension */
"\040<b31>"
);
}
@@ -1025,10 +1025,12 @@ printcpuinfo(void)
"\020"
"\003AVX512_4VNNIW"
"\004AVX512_4FMAPS"
"\005FSRM"
"\011AVX512VP2INTERSECT"
"\013MD_CLEAR"
"\016TSXFA"
"\023PCONFIG"
"\025IBT"
"\033IBPB"
"\034STIBP"
"\035L1DFL"

+ 19
- 1
tools/build/Makefile View File

@@ -4,11 +4,16 @@

LIB= egacy
SRC=
INCSGROUPS= INCS SYSINCS CASPERINC
INCSGROUPS= INCS SYSINCS CASPERINC UFSINCS FFSINCS MSDOSFSINCS DISKINCS
INCS=

SYSINCSDIR= ${INCLUDEDIR}/sys
CASPERINCDIR= ${INCLUDEDIR}/casper
# Also add ufs/ffs/msdosfs/disk headers to allow building makefs as a bootstrap tool
UFSINCSDIR= ${INCLUDEDIR}/ufs/ufs
FFSINCSDIR= ${INCLUDEDIR}/ufs/ffs
MSDOSFSINCSDIR= ${INCLUDEDIR}/fs/msdosfs
DISKINCSDIR= ${INCLUDEDIR}/sys/disk

BOOTSTRAPPING?= 0

@@ -70,6 +75,19 @@ SRCS= dummy.c
SUBDIR= cross-build
.endif

# To allow bootstrapping makefs on FreeBSD 11 or non-FreeBSD systems:
UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dinode.h
UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dir.h
FFSINCS+= ${SRCTOP}/sys/ufs/ffs/fs.h

MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bootsect.h
MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/bpb.h
MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/denode.h
MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/direntry.h
MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/fat.h
MSDOSFSINCS+= ${SRCTOP}/sys/fs/msdosfs/msdosfsmount.h
DISKINCS+= ${SRCTOP}/sys/sys/disk/bsd.h

# Needed to build config (since it uses libnv)
SYSINCS+= ${SRCTOP}/sys/sys/nv.h ${SRCTOP}/sys/sys/cnv.h \
${SRCTOP}/sys/sys/dnv.h

+ 28
- 11
usr.sbin/bsdinstall/scripts/auto View File

@@ -41,13 +41,25 @@ f_include $BSDCFG_SHARE/dialog.subr
hline_arrows_tab_enter="Press arrows, TAB or ENTER"
hline_arrows_tab_space_enter="Press arrows, TAB, SPACE or ENTER"
msg_abort="Abort"
msg_an_installation_step_has_been_aborted="An installation step has been aborted. Would you like\nto restart the installation or exit the installer?"
msg_auto_ufs="Auto (UFS)"
msg_auto_ufs_desc="Guided UFS Disk Setup"
msg_auto_ufs_help="Menu options help choose which disk to setup using UFS and standard partitions"
msg_auto_zfs="Auto (ZFS)"
msg_auto_zfs_desc="Guided Root-on-ZFS"
msg_auto_zfs_help="To use ZFS with less than 8GB RAM, see https://wiki.freebsd.org/ZFSTuningGuide"
msg_exit="Exit"
msg_freebsd_installer="HardenedBSD Installer"
msg_gpt_active_fix="Your hardware is known to have issues booting in CSM/Legacy/BIOS mode from GPT partitions that are not set active. Would you like the installer to apply this workaround for you?"
msg_lenovo_fix="Your model of Lenovo is known to have a BIOS bug that prevents it booting from GPT partitions without UEFI. Would you like the installer to apply a workaround for you?"
msg_an_installation_step_has_been_aborted="An installation step has been aborted. Would you like\nto restart the installation or exit the installer?"
msg_manual="Manual"
msg_manual_desc="Manual Disk Setup (experts)"
msg_manual_help="Create customized partitions from menu options"
msg_no="NO"
msg_restart="Restart"
msg_shell="Shell"
msg_shell_desc="Open a shell and partition by hand"
msg_shell_help="Create customized partitions using command-line utilities"
msg_yes="YES"

############################################################ FUNCTIONS
@@ -281,42 +293,47 @@ if f_interactive; then
esac
fi

PMODES="\
\"Auto (UFS)\" \"Guided Disk Setup\" \
Manual \"Manual Disk Setup (experts)\" \
Shell \"Open a shell and partition by hand\""
PMODES="
'$msg_auto_ufs' '$msg_auto_ufs_desc' '$msg_auto_ufs_help'
'$msg_manual' '$msg_manual_desc' '$msg_manual_help'
'$msg_shell' '$msg_shell_desc' '$msg_shell_help'
" # END-QUOTE

CURARCH=$( uname -m )
case $CURARCH in
amd64|arm64|i386) # Booting ZFS Supported
PMODES="\"Auto (ZFS)\" \"Guided Root-on-ZFS\" $PMODES"
PMODES="
'$msg_auto_zfs' '$msg_auto_zfs_desc' '$msg_auto_zfs_help'
$PMODES
" # END-QUOTE
;;
*) # Booting ZFS Unspported
*) # Booting ZFS Unsupported
;;
esac

exec 3>&1
PARTMODE=`echo $PMODES | xargs dialog --backtitle "HardenedBSD Installer" \
--title "Partitioning" \
--item-help \
--menu "How would you like to partition your disk?" \
0 0 0 2>&1 1>&3` || exit 1
exec 3>&-

case "$PARTMODE" in
"Auto (ZFS)") # ZFS
"$msg_auto_zfs") # ZFS
bsdinstall zfsboot || error "ZFS setup failed"
bsdinstall mount || error "Failed to mount filesystem"
;;
"Auto (UFS)") # Guided
"$msg_auto_ufs") # Guided UFS
bsdinstall autopart || error "Partitioning error"
bsdinstall mount || error "Failed to mount filesystem"
;;
"Shell") # Shell
"$msg_shell") # Shell
clear
echo "Use this shell to set up partitions for the new system. When finished, mount the system at $BSDINSTALL_CHROOT and place an fstab file for the new system at $PATH_FSTAB. Then type 'exit'. You can also enter the partition editor at any time by entering 'bsdinstall partedit'."
sh 2>&1
;;
"Manual") # Manual
"$msg_manual") # Manual
if f_isset debugFile; then
# Give partedit the path to our logfile so it can append
BSDINSTALL_LOG="${debugFile#+}" bsdinstall partedit || error "Partitioning error"

+ 0
- 4
usr.sbin/makefs/msdos/msdosfs_denode.c View File

@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");

#include <sys/param.h>
#include <sys/errno.h>
#include <sys/vnode.h>

#include <stdbool.h>
#include <stdio.h>
@@ -288,10 +287,7 @@ detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
return (error);
}
memset(bp->b_data + boff, 0, pmp->pm_bpcluster - boff);
if (flags & IO_SYNC)
bwrite(bp);
else
bdwrite(bp);
}
}


+ 4
- 0
usr.sbin/makefs/msdos/msdosfs_vnops.c View File

@@ -103,7 +103,11 @@ msdosfs_times(struct denode *dep, const struct stat *st)
if (stampst.st_ino)
st = &stampst;

#ifdef HAVE_STRUCT_STAT_BIRTHTIME
unix2fattime(&st->st_birthtim, &dep->de_CDate, &dep->de_CTime);
#else
unix2fattime(&st->st_ctim, &dep->de_CDate, &dep->de_CTime);
#endif
unix2fattime(&st->st_atim, &dep->de_ADate, NULL);
unix2fattime(&st->st_mtim, &dep->de_MDate, &dep->de_MTime);
}

Loading…
Cancel
Save