NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/57447: HEAD fails to probe USB devices and fails to boot up
The following reply was made to PR kern/57447; it has been noted by GNATS.
From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
To: bsdprg%tuta.io@localhost
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: kern/57447: HEAD fails to probe USB devices and fails to boot up
Date: Fri, 2 Jun 2023 09:46:32 +0000
This is a multi-part message in MIME format.
--=_GedpluGHhMt+8t6kRp/y47P8O+rSmQXG
> Date: Fri, 2 Jun 2023 09:35:47 +0000
> From: Taylor R Campbell <riastradh%NetBSD.org@localhost>
>
> Can you please run with the attached patch and share dmesg once the
> machine boots?
Sorry, hit send before I verified it would compile -- try this one
instead.
--=_GedpluGHhMt+8t6kRp/y47P8O+rSmQXG
Content-Type: text/plain; charset="ISO-8859-1"; name="usbhack-v2"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="usbhack-v2.patch"
diff --git a/libexec/ld.elf_so/arch/aarch64/mdreloc.c b/libexec/ld.elf_so/a=
rch/aarch64/mdreloc.c
index 64335181bfe6..f656a08e2866 100644
--- a/libexec/ld.elf_so/arch/aarch64/mdreloc.c
+++ b/libexec/ld.elf_so/arch/aarch64/mdreloc.c
@@ -299,8 +299,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TLS_TYPE(TLS_TPREL):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value + defobj->tlsoffset +
diff --git a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c b/libexec/ld.elf_so=
/arch/alpha/alpha_reloc.c
index c7f2e85c2a28..0266dbfbdc9c 100644
--- a/libexec/ld.elf_so/arch/alpha/alpha_reloc.c
+++ b/libexec/ld.elf_so/arch/alpha/alpha_reloc.c
@@ -280,8 +280,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TPREL64):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
tmp =3D (Elf64_Addr)(def->st_value +
diff --git a/libexec/ld.elf_so/arch/arm/mdreloc.c b/libexec/ld.elf_so/arch/=
arm/mdreloc.c
index 79f7f2765a81..c234e4e80520 100644
--- a/libexec/ld.elf_so/arch/arm/mdreloc.c
+++ b/libexec/ld.elf_so/arch/arm/mdreloc.c
@@ -228,8 +228,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF32):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
if (__predict_true(RELOC_ALIGNED_P(where)))
diff --git a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c b/libexec/ld.elf_so/a=
rch/hppa/hppa_reloc.c
index dd11e536653f..a2b3853fe014 100644
--- a/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
+++ b/libexec/ld.elf_so/arch/hppa/hppa_reloc.c
@@ -553,7 +553,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPREL32):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(defobj->tlsoffset + def->st_value +
diff --git a/libexec/ld.elf_so/arch/i386/mdreloc.c b/libexec/ld.elf_so/arch=
/i386/mdreloc.c
index 5e3f7c959fca..8cae1c931fe3 100644
--- a/libexec/ld.elf_so/arch/i386/mdreloc.c
+++ b/libexec/ld.elf_so/arch/i386/mdreloc.c
@@ -147,8 +147,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where +=3D (Elf_Addr)(def->st_value - defobj->tlsoffset);
@@ -159,8 +159,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF32):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where +=3D (Elf_Addr)(defobj->tlsoffset - def->st_value);
diff --git a/libexec/ld.elf_so/arch/m68k/mdreloc.c b/libexec/ld.elf_so/arch=
/m68k/mdreloc.c
index d327e24f2edf..480159696075 100644
--- a/libexec/ld.elf_so/arch/m68k/mdreloc.c
+++ b/libexec/ld.elf_so/arch/m68k/mdreloc.c
@@ -142,9 +142,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_DTPREL32):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
- return -1;
-
*where =3D (Elf_Addr)(def->st_value + rela->r_addend
- TLS_DTV_OFFSET);
rdbg(("DTPREL32 %s in %s --> %p in %s",
@@ -153,7 +150,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPREL32):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value + rela->r_addend
diff --git a/libexec/ld.elf_so/arch/mips/mips_reloc.c b/libexec/ld.elf_so/a=
rch/mips/mips_reloc.c
index 9cd5de7cab51..9a15c25e9a2e 100644
--- a/libexec/ld.elf_so/arch/mips/mips_reloc.c
+++ b/libexec/ld.elf_so/arch/mips/mips_reloc.c
@@ -429,9 +429,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
Elf_Addr old =3D load_ptr(where, ELFSIZE / 8);
Elf_Addr val =3D old;
=20
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
- return -1;
-
val +=3D (Elf_Addr)def->st_value - TLS_DTV_OFFSET;
store_ptr(where, val, ELFSIZE / 8);
=20
@@ -450,7 +447,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
Elf_Addr old =3D load_ptr(where, ELFSIZE / 8);
Elf_Addr val =3D old;
=20
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
val +=3D (Elf_Addr)(def->st_value + defobj->tlsoffset
diff --git a/libexec/ld.elf_so/arch/or1k/mdreloc.c b/libexec/ld.elf_so/arch=
/or1k/mdreloc.c
index 78fd17293789..e17e58b1c18e 100644
--- a/libexec/ld.elf_so/arch/or1k/mdreloc.c
+++ b/libexec/ld.elf_so/arch/or1k/mdreloc.c
@@ -171,9 +171,6 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_DTPOFF):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
- return -1;
-
*where =3D (Elf_Addr)(def->st_value + rela->r_addend
- TLS_DTV_OFFSET);
rdbg(("DTPOFF %s in %s --> %p in %s",
@@ -182,7 +179,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value + rela->r_addend
diff --git a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c b/libexec/ld.elf_so=
/arch/powerpc/ppc_reloc.c
index 37ca160e6195..076572df2bb9 100644
--- a/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
+++ b/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c
@@ -321,7 +321,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TPREL):
- if (!defobj->tls_done && _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value + rela->r_addend
diff --git a/libexec/ld.elf_so/arch/riscv/mdreloc.c b/libexec/ld.elf_so/arc=
h/riscv/mdreloc.c
index 05cc4b81906a..62ede46f102b 100644
--- a/libexec/ld.elf_so/arch/riscv/mdreloc.c
+++ b/libexec/ld.elf_so/arch/riscv/mdreloc.c
@@ -203,8 +203,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
}
=20
case R_TYPESZ(TLS_TPREL):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value + defobj->tlsoffset +
diff --git a/libexec/ld.elf_so/arch/sh3/mdreloc.c b/libexec/ld.elf_so/arch/=
sh3/mdreloc.c
index 949bd02a88a9..99732d89fcaf 100644
--- a/libexec/ld.elf_so/arch/sh3/mdreloc.c
+++ b/libexec/ld.elf_so/arch/sh3/mdreloc.c
@@ -173,8 +173,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF32):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)def->st_value +
diff --git a/libexec/ld.elf_so/arch/sparc/mdreloc.c b/libexec/ld.elf_so/arc=
h/sparc/mdreloc.c
index 526c0dfa1d99..17358ef91e5f 100644
--- a/libexec/ld.elf_so/arch/sparc/mdreloc.c
+++ b/libexec/ld.elf_so/arch/sparc/mdreloc.c
@@ -282,8 +282,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF32):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where =3D (Elf_Addr)(def->st_value -
diff --git a/libexec/ld.elf_so/arch/sparc64/mdreloc.c b/libexec/ld.elf_so/a=
rch/sparc64/mdreloc.c
index e3ea5a8808e3..39591f2be248 100644
--- a/libexec/ld.elf_so/arch/sparc64/mdreloc.c
+++ b/libexec/ld.elf_so/arch/sparc64/mdreloc.c
@@ -383,9 +383,9 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TLS_TPOFF64):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
- return -1;
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
+ return -1;
=20
*where =3D (Elf64_Addr)(def->st_value -
defobj->tlsoffset + rela->r_addend);
diff --git a/libexec/ld.elf_so/arch/x86_64/mdreloc.c b/libexec/ld.elf_so/ar=
ch/x86_64/mdreloc.c
index a04c05ea0aa7..a1277f001a6f 100644
--- a/libexec/ld.elf_so/arch/x86_64/mdreloc.c
+++ b/libexec/ld.elf_so/arch/x86_64/mdreloc.c
@@ -226,8 +226,8 @@ _rtld_relocate_nonplt_objects(Obj_Entry *obj)
break;
=20
case R_TYPE(TPOFF64):
- if (!defobj->tls_done &&
- _rtld_tls_offset_allocate(obj))
+ if (defobj->tls_done !=3D 1 &&
+ _rtld_tls_offset_allocate(__UNCONST(defobj)))
return -1;
=20
*where64 =3D (Elf64_Addr)(def->st_value -
diff --git a/libexec/ld.elf_so/rtld.h b/libexec/ld.elf_so/rtld.h
index 0330ea964312..1f4310069657 100644
--- a/libexec/ld.elf_so/rtld.h
+++ b/libexec/ld.elf_so/rtld.h
@@ -483,7 +483,6 @@ _rtld_fetch_ventry(const Obj_Entry *obj, unsigned long =
symnum)
/* tls.c */
void *_rtld_tls_get_addr(void *, size_t, size_t);
void _rtld_tls_initial_allocation(void);
-void *_rtld_tls_module_allocate(size_t index);
int _rtld_tls_offset_allocate(Obj_Entry *);
void _rtld_tls_offset_free(Obj_Entry *);
=20
diff --git a/libexec/ld.elf_so/tls.c b/libexec/ld.elf_so/tls.c
index 01d5c9f9b6d6..8c75ca4c2648 100644
--- a/libexec/ld.elf_so/tls.c
+++ b/libexec/ld.elf_so/tls.c
@@ -43,6 +43,7 @@ __RCSID("$NetBSD: tls.c,v 1.17 2023/06/01 08:20:10 riastr=
adh Exp $");
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
=20
static struct tls_tcb *_rtld_tls_allocate_locked(void);
+static void *_rtld_tls_module_allocate(struct tls_tcb *, size_t);
=20
#ifndef TLS_DTV_OFFSET
#define TLS_DTV_OFFSET 0
@@ -84,7 +85,7 @@ _rtld_tls_get_addr(void *tls, size_t idx, size_t offset)
}
=20
if (__predict_false(dtv[idx] =3D=3D NULL))
- dtv[idx] =3D _rtld_tls_module_allocate(idx);
+ dtv[idx] =3D _rtld_tls_module_allocate(tcb, idx);
=20
_rtld_exclusive_exit(&mask);
=20
@@ -136,7 +137,7 @@ _rtld_tls_allocate_locked(void)
SET_DTV_GENERATION(tcb->tcb_dtv, _rtld_tls_dtv_generation);
=20
for (obj =3D _rtld_objlist; obj !=3D NULL; obj =3D obj->next) {
- if (obj->tls_done) {
+ if (obj->tls_done =3D=3D 1) {
#ifdef __HAVE_TLS_VARIANT_I
q =3D p + obj->tlsoffset;
#else
@@ -195,8 +196,8 @@ _rtld_tls_free(struct tls_tcb *tcb)
_rtld_exclusive_exit(&mask);
}
=20
-void *
-_rtld_tls_module_allocate(size_t idx)
+static void *
+_rtld_tls_module_allocate(struct tls_tcb *tcb, size_t idx)
{
Obj_Entry *obj;
uint8_t *p;
@@ -209,6 +210,14 @@ _rtld_tls_module_allocate(size_t idx)
_rtld_error("Module for TLS index %zu missing", idx);
_rtld_die();
}
+ if (obj->tls_done =3D=3D 1) {
+#ifdef __HAVE_TLS_VARIANT_I
+ p =3D (uint8_t *)tcb + obj->tlsoffset;
+#else
+ p =3D (uint8_t *)tcb - obj->tlsoffset;
+#endif
+ return p;
+ }
=20
p =3D xmalloc(obj->tlssize);
memcpy(p, obj->tlsinit, obj->tlsinitsize);
@@ -222,6 +231,9 @@ _rtld_tls_offset_allocate(Obj_Entry *obj)
{
size_t offset, next_offset;
=20
+ if (obj->tls_done =3D=3D 2)
+ return -1;
+
if (obj->tls_done)
return 0;
if (obj->tlssize =3D=3D 0) {
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index e14fec7e30be..33402e0a3ea8 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -680,6 +680,7 @@ usbd_set_config_no(struct usbd_device *dev, int no, int=
msg)
return USBD_INVAL;
}
=20
+#include <ddb/ddb.h>
usbd_status
usbd_set_config_index(struct usbd_device *dev, int index, int msg)
{
@@ -691,6 +692,9 @@ usbd_set_config_index(struct usbd_device *dev, int inde=
x, int msg)
usbd_status err;
int i, ifcidx, nifc, len, selfpowered, power;
=20
+ printf("%s: addr %u index %d msg %d\n", __func__,
+ dev->ud_addr, index, msg);
+ db_stacktrace();
=20
if (index >=3D dev->ud_ddesc.bNumConfigurations &&
index !=3D USB_UNCONFIG_INDEX) {
@@ -867,7 +871,7 @@ usbd_set_config_index(struct usbd_device *dev, int inde=
x, int msg)
goto bad;
}
=20
- KASSERTMSG(dev->ud_ifaces =3D=3D NULL, "ud_ifaces=3D%p", dev->ud_ifaces);
+// KASSERTMSG(dev->ud_ifaces =3D=3D NULL, "ud_ifaces=3D%p", dev->ud_ifaces=
);
=20
/* Allocate and fill interface data. */
nifc =3D cdp->bNumInterface;
--=_GedpluGHhMt+8t6kRp/y47P8O+rSmQXG--
Home |
Main Index |
Thread Index |
Old Index