Commit 5bc49139 authored by HardenedBSD Sync Service's avatar HardenedBSD Sync Service
Browse files

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

parents 7a4ff5c0 de1292c6
......@@ -148,7 +148,7 @@ typedef struct {
int faults;
u_int caps;
struct cam_periph *periph;
} probe_softc;
} aprobe_softc;
static struct ata_quirk_entry ata_quirk_table[] =
{
......@@ -278,7 +278,7 @@ static cam_status
aproberegister(struct cam_periph *periph, void *arg)
{
union ccb *request_ccb; /* CCB representing the probe request */
probe_softc *softc;
aprobe_softc *softc;
request_ccb = (union ccb *)arg;
if (request_ccb == NULL) {
......@@ -287,7 +287,7 @@ aproberegister(struct cam_periph *periph, void *arg)
return(CAM_REQ_CMP_ERR);
}
softc = (probe_softc *)malloc(sizeof(*softc), M_CAMXPT, M_ZERO | M_NOWAIT);
softc = (aprobe_softc *)malloc(sizeof(*softc), M_CAMXPT, M_ZERO | M_NOWAIT);
if (softc == NULL) {
printf("proberegister: Unable to probe new device. "
......@@ -314,9 +314,9 @@ static void
aprobeschedule(struct cam_periph *periph)
{
union ccb *ccb;
probe_softc *softc;
aprobe_softc *softc;
softc = (probe_softc *)periph->softc;
softc = (aprobe_softc *)periph->softc;
ccb = (union ccb *)TAILQ_FIRST(&softc->request_ccbs);
if ((periph->path->device->flags & CAM_DEV_UNCONFIGURED) ||
......@@ -340,14 +340,14 @@ aprobestart(struct cam_periph *periph, union ccb *start_ccb)
struct ccb_trans_settings cts;
struct ccb_ataio *ataio;
struct ccb_scsiio *csio;
probe_softc *softc;
aprobe_softc *softc;
struct cam_path *path;
struct ata_params *ident_buf;
u_int oif;
CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("aprobestart\n"));
softc = (probe_softc *)periph->softc;
softc = (aprobe_softc *)periph->softc;
path = start_ccb->ccb_h.path;
ataio = &start_ccb->ataio;
csio = &start_ccb->csio;
......@@ -745,7 +745,7 @@ aprobedone(struct cam_periph *periph, union ccb *done_ccb)
struct ccb_trans_settings cts;
struct ata_params *ident_buf;
struct scsi_inquiry_data *inq_buf;
probe_softc *softc;
aprobe_softc *softc;
struct cam_path *path;
cam_status status;
u_int32_t priority;
......@@ -757,7 +757,7 @@ aprobedone(struct cam_periph *periph, union ccb *done_ccb)
CAM_DEBUG(done_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("aprobedone\n"));
softc = (probe_softc *)periph->softc;
softc = (aprobe_softc *)periph->softc;
path = done_ccb->ccb_h.path;
priority = done_ccb->ccb_h.pinfo.priority;
ident_buf = &path->device->ident_data;
......@@ -1605,9 +1605,9 @@ ata_scan_lun(struct cam_periph *periph, struct cam_path *path,
xpt_path_lock(path);
if ((old_periph = cam_periph_find(path, "aprobe")) != NULL) {
if ((old_periph->flags & CAM_PERIPH_INVALID) == 0) {
probe_softc *softc;
aprobe_softc *softc;
softc = (probe_softc *)old_periph->softc;
softc = (aprobe_softc *)old_periph->softc;
TAILQ_INSERT_TAIL(&softc->request_ccbs,
&request_ccb->ccb_h, periph_links.tqe);
softc->restart = 1;
......
......@@ -346,6 +346,7 @@ struct da_softc {
da_flags flags;
da_quirks quirks;
int minimum_cmd_size;
int mode_page;
int error_inject;
int trim_max_ranges;
int delete_available; /* Delete methods possibly available */
......@@ -2908,6 +2909,9 @@ daregister(struct cam_periph *periph, void *arg)
else
softc->minimum_cmd_size = 6;
/* On first PROBE_WP request all more pages, then adjust. */
softc->mode_page = SMS_ALL_PAGES_PAGE;
/* Predict whether device may support READ CAPACITY(16). */
if (SID_ANSI_REV(&cgd->inq_data) >= SCSI_REV_SPC3 &&
(softc->quirks & DA_Q_NO_RC16) == 0) {
......@@ -3501,7 +3505,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
void *mode_buf;
int mode_buf_len;
if (da_disable_wp_detection) {
if (da_disable_wp_detection || softc->mode_page < 0) {
if ((softc->flags & DA_FLAG_CAN_RC16) != 0)
softc->state = DA_STATE_PROBE_RC16;
else
......@@ -3525,7 +3529,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
/*tag_action*/ MSG_SIMPLE_Q_TAG,
/*dbd*/ FALSE,
/*pc*/ SMS_PAGE_CTRL_CURRENT,
/*page*/ SMS_ALL_PAGES_PAGE,
/*page*/ softc->mode_page,
/*param_buf*/ mode_buf,
/*param_len*/ mode_buf_len,
/*minimum_cmd_size*/ softc->minimum_cmd_size,
......@@ -4685,12 +4689,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
static void
dadone_probewp(struct cam_periph *periph, union ccb *done_ccb)
{
struct scsi_mode_header_6 *mode_hdr6;
struct scsi_mode_header_10 *mode_hdr10;
struct da_softc *softc;
struct ccb_scsiio *csio;
u_int32_t priority;
uint8_t dev_spec;
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probewp\n"));
......@@ -4708,18 +4709,31 @@ dadone_probewp(struct cam_periph *periph, union ccb *done_ccb)
(unsigned long)csio->ccb_h.ccb_state & DA_CCB_TYPE_MASK, periph,
done_ccb));
if (softc->minimum_cmd_size > 6) {
mode_hdr10 = (struct scsi_mode_header_10 *)csio->data_ptr;
dev_spec = mode_hdr10->dev_spec;
} else {
mode_hdr6 = (struct scsi_mode_header_6 *)csio->data_ptr;
dev_spec = mode_hdr6->dev_spec;
}
if (cam_ccb_status(done_ccb) == CAM_REQ_CMP) {
int len, off;
uint8_t dev_spec;
if (csio->cdb_len > 6) {
struct scsi_mode_header_10 *mh =
(struct scsi_mode_header_10 *)csio->data_ptr;
len = 2 + scsi_2btoul(mh->data_length);
off = sizeof(*mh) + scsi_2btoul(mh->blk_desc_len);
dev_spec = mh->dev_spec;
} else {
struct scsi_mode_header_6 *mh =
(struct scsi_mode_header_6 *)csio->data_ptr;
len = 1 + mh->data_length;
off = sizeof(*mh) + mh->blk_desc_len;
dev_spec = mh->dev_spec;
}
if ((dev_spec & 0x80) != 0)
softc->disk->d_flags |= DISKFLAG_WRITE_PROTECT;
else
softc->disk->d_flags &= ~DISKFLAG_WRITE_PROTECT;
/* Next time request only the first of returned mode pages. */
if (off < len && off < csio->dxfer_len - csio->resid)
softc->mode_page = csio->data_ptr[off] & SMPH_PC_MASK;
} else {
int error;
......@@ -4736,6 +4750,9 @@ dadone_probewp(struct cam_periph *periph, union ccb *done_ccb)
/*timeout*/0,
/*getcount_only*/0);
}
/* We don't depend on it, so don't try again. */
softc->mode_page = -1;
}
}
......
......@@ -159,7 +159,7 @@ enum {
FW_OK = (1 << 1),
CHK_MBOX_ACCESS = (1 << 2),
MASTER_PF = (1 << 3),
ADAP_SYSCTL_CTX = (1 << 4),
/* 1 << 4 is unused, was ADAP_SYSCTL_CTX */
ADAP_ERR = (1 << 5),
BUF_PACKING_OK = (1 << 6),
IS_VF = (1 << 7),
......@@ -174,7 +174,7 @@ enum {
/* VI flags */
DOOMED = (1 << 0),
VI_INIT_DONE = (1 << 1),
VI_SYSCTL_CTX = (1 << 2),
/* 1 << 2 is unused, was VI_SYSCTL_CTX */
TX_USES_VM_WR = (1 << 3),
VI_SKIP_STATS = (1 << 4),
......@@ -332,6 +332,8 @@ struct port_info {
u_int tx_parse_error;
int fcs_reg;
uint64_t fcs_base;
struct sysctl_ctx_list ctx;
};
#define IS_MAIN_VI(vi) ((vi) == &((vi)->pi->vi[0]))
......
......@@ -249,6 +249,8 @@ struct ccr_softc {
counter_u64_t stats_sglist_error;
counter_u64_t stats_process_error;
counter_u64_t stats_sw_fallback;
struct sysctl_ctx_list ctx;
};
/*
......@@ -1819,14 +1821,12 @@ ccr_probe(device_t dev)
static void
ccr_sysctls(struct ccr_softc *sc)
{
struct sysctl_ctx_list *ctx;
struct sysctl_ctx_list *ctx = &sc->ctx;
struct sysctl_oid *oid, *port_oid;
struct sysctl_oid_list *children;
char buf[16];
int i;
ctx = device_get_sysctl_ctx(sc->dev);
/*
* dev.ccr.X.
*/
......@@ -1952,6 +1952,7 @@ ccr_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
sysctl_ctx_init(&sc->ctx);
sc->adapter = device_get_softc(device_get_parent(dev));
for_each_port(sc->adapter, i) {
ccr_init_port(sc, i);
......@@ -2018,6 +2019,7 @@ ccr_detach(device_t dev)
crypto_unregister_all(sc->cid);
sysctl_ctx_free(&sc->ctx);
mtx_destroy(&sc->lock);
counter_u64_free(sc->stats_cipher_encrypt);
counter_u64_free(sc->stats_cipher_decrypt);
......
......@@ -1122,6 +1122,7 @@ t4_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
sysctl_ctx_init(&sc->ctx);
TUNABLE_INT_FETCH("hw.cxgbe.dflags", &sc->debug_flags);
if ((pci_get_device(dev) & 0xff00) == 0x5400)
......@@ -1175,10 +1176,10 @@ t4_attach(device_t dev)
TASK_INIT(&sc->reset_task, 0, reset_adapter, sc);
sc->ctrlq_oid = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->dev),
sc->ctrlq_oid = SYSCTL_ADD_NODE(&sc->ctx,
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "ctrlq",
CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "control queues");
sc->fwq_oid = SYSCTL_ADD_NODE(device_get_sysctl_ctx(sc->dev),
sc->fwq_oid = SYSCTL_ADD_NODE(&sc->ctx,
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO, "fwq",
CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "firmware event queue");
......@@ -1732,6 +1733,7 @@ t4_detach_common(device_t dev)
}
device_delete_children(dev);
sysctl_ctx_free(&sc->ctx);
adapter_full_uninit(sc);
if ((sc->flags & (IS_VF | FW_OK)) == FW_OK)
......@@ -2413,12 +2415,12 @@ cxgbe_vi_attach(device_t dev, struct vi_info *vi)
{
struct ifnet *ifp;
struct sbuf *sb;
struct sysctl_ctx_list *ctx;
struct sysctl_ctx_list *ctx = &vi->ctx;
struct sysctl_oid_list *children;
struct pfil_head_args pa;
struct adapter *sc = vi->adapter;
ctx = device_get_sysctl_ctx(vi->dev);
sysctl_ctx_init(ctx);
children = SYSCTL_CHILDREN(device_get_sysctl_tree(vi->dev));
vi->rxq_oid = SYSCTL_ADD_NODE(ctx, children, OID_AUTO, "rxq",
CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, "NIC rx queues");
......@@ -2565,6 +2567,8 @@ cxgbe_attach(device_t dev)
struct vi_info *vi;
int i, rc;
sysctl_ctx_init(&pi->ctx);
rc = cxgbe_vi_attach(dev, &pi->vi[0]);
if (rc)
return (rc);
......@@ -2606,6 +2610,7 @@ cxgbe_vi_detach(struct vi_info *vi)
#endif
cxgbe_uninit_synchronized(vi);
callout_drain(&vi->tick);
sysctl_ctx_free(&vi->ctx);
vi_full_uninit(vi);
if_free(vi->ifp);
......@@ -2625,6 +2630,7 @@ cxgbe_detach(device_t dev)
return (rc);
device_delete_children(dev);
sysctl_ctx_free(&pi->ctx);
doom_vi(sc, &pi->vi[0]);
if (pi->flags & HAS_TRACEQ) {
......@@ -6469,11 +6475,6 @@ adapter_full_init(struct adapter *sc)
ASSERT_SYNCHRONIZED_OP(sc);
if (!(sc->flags & ADAP_SYSCTL_CTX)) {
sysctl_ctx_init(&sc->ctx);
sc->flags |= ADAP_SYSCTL_CTX;
}
/*
* queues that belong to the adapter (not any particular port).
*/
......@@ -6528,12 +6529,6 @@ adapter_full_uninit(struct adapter *sc)
{
int i;
/* Do this before freeing the adapter queues. */
if (sc->flags & ADAP_SYSCTL_CTX) {
sysctl_ctx_free(&sc->ctx);
sc->flags &= ~ADAP_SYSCTL_CTX;
}
t4_teardown_adapter_queues(sc);
for (i = 0; i < nitems(sc->tq) && sc->tq[i]; i++) {
......@@ -6626,11 +6621,6 @@ vi_full_init(struct vi_info *vi)
ASSERT_SYNCHRONIZED_OP(sc);
if (!(vi->flags & VI_SYSCTL_CTX)) {
sysctl_ctx_init(&vi->ctx);
vi->flags |= VI_SYSCTL_CTX;
}
/*
* Allocate tx/rx/fl queues for this VI.
*/
......@@ -6764,12 +6754,6 @@ vi_full_uninit(struct vi_info *vi)
free(vi->nm_rss, M_CXGBE);
}
/* Do this before freeing the VI queues. */
if (vi->flags & VI_SYSCTL_CTX) {
sysctl_ctx_free(&vi->ctx);
vi->flags &= ~VI_SYSCTL_CTX;
}
t4_teardown_vi_queues(vi);
vi->flags &= ~VI_INIT_DONE;
}
......@@ -7132,13 +7116,11 @@ static char *caps_decoder[] = {
void
t4_sysctls(struct adapter *sc)
{
struct sysctl_ctx_list *ctx;
struct sysctl_ctx_list *ctx = &sc->ctx;
struct sysctl_oid *oid;
struct sysctl_oid_list *children, *c0;
static char *doorbells = {"\20\1UDB\2WCWR\3UDBWC\4KDB"};
ctx = device_get_sysctl_ctx(sc->dev);
/*
* dev.t4nex.X.
*/
......@@ -7649,12 +7631,10 @@ t4_sysctls(struct adapter *sc)
void
vi_sysctls(struct vi_info *vi)
{
struct sysctl_ctx_list *ctx;
struct sysctl_ctx_list *ctx = &vi->ctx;
struct sysctl_oid *oid;
struct sysctl_oid_list *children;
ctx = device_get_sysctl_ctx(vi->dev);
/*
* dev.v?(cxgbe|cxl).X.
*/
......@@ -7754,7 +7734,7 @@ vi_sysctls(struct vi_info *vi)
static void
cxgbe_sysctls(struct port_info *pi)
{
struct sysctl_ctx_list *ctx;
struct sysctl_ctx_list *ctx = &pi->ctx;
struct sysctl_oid *oid;
struct sysctl_oid_list *children, *children2;
struct adapter *sc = pi->adapter;
......@@ -7762,8 +7742,6 @@ cxgbe_sysctls(struct port_info *pi)
char name[16];
static char *tc_flags = {"\20\1USER"};
ctx = device_get_sysctl_ctx(pi->dev);
/*
* dev.cxgbe.X.
*/
......
......@@ -489,6 +489,7 @@ t4vf_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
sysctl_ctx_init(&sc->ctx);
pci_enable_busmaster(dev);
pci_set_max_read_req(dev, 4096);
sc->params.pci.mps = pci_get_max_payload(dev);
......
......@@ -554,6 +554,21 @@ static struct hdaa_model_pin_patch_t realtek_model_pin_patches[] = {
}
}, { }
}
}, { /**** CODEC: HDA_CODEC_ALC285 ****/
.id = HDA_CODEC_ALC285,
.patches = (struct model_pin_patch_t[]){
{
.models = (struct pin_machine_model_t[]){
PIN_SUBVENDOR(LENOVO_X120KH_SUBVENDOR),
PIN_SUBVENDOR(LENOVO_X120QD_SUBVENDOR),
{ }
},
.pin_patches = (struct pin_patch_t[]){
PIN_PATCH_STRING(33, "seq=15 as=1 color=Black ctype=1/8 device=Headphones loc=Left"),
{ }
}
}, { }
}
}, { /**** CODEC: HDA_CODEC_ALC286 ****/
.id = HDA_CODEC_ALC286,
.patches = (struct model_pin_patch_t[]){
......
......@@ -1025,7 +1025,7 @@ calcru1(struct proc *p, struct rusage_ext *ruxp, struct timeval *up,
uu = ruxp->rux_uu;
su = ruxp->rux_su;
tu = ruxp->rux_tu;
} else { /* tu < ruxp->rux_tu */
} else if (vm_guest == VM_GUEST_NO) { /* tu < ruxp->rux_tu */
/*
* What happened here was likely that a laptop, which ran at
* a reduced clock frequency at boot, kicked into high gear.
......
......@@ -1002,6 +1002,35 @@ native_lapic_disable_pmc(void)
#endif
}
static int
lapic_calibrate_initcount_cpuid_vm(void)
{
u_int regs[4];
uint64_t freq;
/* Get value from CPUID leaf if possible. */
if (vm_guest == VM_GUEST_NO)
return (false);
if (hv_high < 0x40000010)
return (false);
do_cpuid(0x40000010, regs);
freq = (uint64_t)(regs[1]) * 1000;
/* Pick timer divisor. */
lapic_timer_divisor = 2;
do {
if (freq / lapic_timer_divisor < APIC_TIMER_MAX_COUNT)
break;
lapic_timer_divisor <<= 1;
} while (lapic_timer_divisor <= 128);
if (lapic_timer_divisor > 128)
return (false);
/* Record divided frequency. */
count_freq = freq / lapic_timer_divisor;
return (true);
}
static uint64_t
cb_lapic_getcount(void)
{
......@@ -1014,6 +1043,9 @@ lapic_calibrate_initcount(struct lapic *la)
{
uint64_t freq;
if (lapic_calibrate_initcount_cpuid_vm())
goto done;
/* Calibrate the APIC timer frequency. */
lapic_timer_set_divisor(2);
lapic_timer_oneshot_nointr(la, APIC_TIMER_MAX_COUNT);
......@@ -1031,6 +1063,7 @@ lapic_calibrate_initcount(struct lapic *la)
if (lapic_timer_divisor > 128)
panic("lapic: Divisor too big");
count_freq = freq * 2 / lapic_timer_divisor;
done:
if (bootverbose) {
printf("lapic: Divisor %lu, Frequency %lu Hz\n",
lapic_timer_divisor, count_freq);
......
......@@ -121,20 +121,29 @@ static struct timecounter tsc_timecounter = {
#endif
};
static int
tsc_freq_cpuid_vm(void)
{
u_int regs[4];
if (vm_guest == VM_GUEST_NO)
return (false);
if (hv_high < 0x40000010)
return (false);
do_cpuid(0x40000010, regs);
tsc_freq = (uint64_t)(regs[0]) * 1000;
tsc_early_calib_exact = 1;
return (true);
}
static void
tsc_freq_vmware(void)
{
u_int regs[4];
if (hv_high >= 0x40000010) {
do_cpuid(0x40000010, regs);
tsc_freq = regs[0] * 1000;
} else {
vmware_hvcall(VMW_HVCMD_GETHZ, regs);
if (regs[1] != UINT_MAX)
tsc_freq = regs[0] | ((uint64_t)regs[1] << 32);
}
tsc_is_invariant = 1;
vmware_hvcall(VMW_HVCMD_GETHZ, regs);
if (regs[1] != UINT_MAX)
tsc_freq = regs[0] | ((uint64_t)regs[1] << 32);
tsc_early_calib_exact = 1;
}
......@@ -268,11 +277,6 @@ probe_tsc_freq(void)
tsc_perf_stat = 1;
}
if (vm_guest == VM_GUEST_VMWARE) {
tsc_freq_vmware();
return;
}
switch (cpu_vendor_id) {
case CPU_VENDOR_AMD:
case CPU_VENDOR_HYGON:
......@@ -311,6 +315,14 @@ probe_tsc_freq(void)
break;
}
if (tsc_freq_cpuid_vm())
return;
if (vm_guest == VM_GUEST_VMWARE) {
tsc_freq_vmware();
return;
}
if (tsc_freq_cpuid(&tsc_freq)) {
/*
* If possible, use the value obtained from CPUID as the initial
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment