16 Dec, 2017

1 commit

  • When ring enters polling mode we are expected to mask the ring interrupt
    before the callback is called. However, the current code actually
    unmasks it probably because of a copy-paste mistake.

    Mask the interrupt properly from now on.

    Fixes: 4ffe722eefcb ("thunderbolt: Add polling mode for rings")
    Signed-off-by: Mika Westerberg
    Acked-by: Yehezkel Bernat
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg
     

17 Nov, 2017

1 commit

  • …/git/gregkh/char-misc

    Pull char/misc updates from Greg KH:
    "Here is the big set of char/misc and other driver subsystem patches
    for 4.15-rc1.

    There are small changes all over here, hyperv driver updates, pcmcia
    driver updates, w1 driver updats, vme driver updates, nvmem driver
    updates, and lots of other little one-off driver updates as well. The
    shortlog has the full details.

    All of these have been in linux-next for quite a while with no
    reported issues"

    * tag 'char-misc-4.15-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (90 commits)
    VME: Return -EBUSY when DMA list in use
    w1: keep balance of mutex locks and refcnts
    MAINTAINERS: Update VME subsystem tree.
    nvmem: sunxi-sid: add support for A64/H5's SID controller
    nvmem: imx-ocotp: Update module description
    nvmem: imx-ocotp: Enable i.MX7D OTP write support
    nvmem: imx-ocotp: Add i.MX7D timing write clock setup support
    nvmem: imx-ocotp: Move i.MX6 write clock setup to dedicated function
    nvmem: imx-ocotp: Add support for banked OTP addressing
    nvmem: imx-ocotp: Pass parameters via a struct
    nvmem: imx-ocotp: Restrict OTP write to IMX6 processors
    nvmem: uniphier: add UniPhier eFuse driver
    dt-bindings: nvmem: add description for UniPhier eFuse
    nvmem: set nvmem->owner to nvmem->dev->driver->owner if unset
    nvmem: qfprom: fix different address space warnings of sparse
    nvmem: mtk-efuse: fix different address space warnings of sparse
    nvmem: mtk-efuse: use stack for nvmem_config instead of malloc'ing it
    nvmem: imx-iim: use stack for nvmem_config instead of malloc'ing it
    thunderbolt: tb: fix use after free in tb_activate_pcie_devices
    MAINTAINERS: Add git tree for Thunderbolt development
    ...

    Linus Torvalds
     

07 Nov, 2017

1 commit


04 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

27 Oct, 2017

1 commit

  • Commit 9a03c3d398c1 ("thunderbolt: Fix a couple right shifting to zero
    bugs") revealed an issue that was previously hidden because we never
    actually compared received XDomain message sequence numbers properly.
    The idea with these sequence numbers is that the responding host uses
    the same sequence number that was in the request packet which we can
    then check at the requesting host.

    However, testing against macOS it looks like it does not follow this but
    instead uses some other logic. Windows driver on the other hand handles
    it the same way than Linux.

    In order to be able to talk to macOS again, fix this so that we drop the
    whole sequence number check. This effectively works exactly the same
    than it worked before the aforementioned commit. This also follows the
    logic the original P2P networking code used.

    Signed-off-by: Mika Westerberg
    Signed-off-by: David S. Miller

    Mika Westerberg
     

19 Oct, 2017

1 commit

  • The problematic code looks like this:

    res_seq = res_hdr->xd_hdr.length_sn & TB_XDOMAIN_SN_MASK;
    res_seq >>= TB_XDOMAIN_SN_SHIFT;

    TB_XDOMAIN_SN_SHIFT is 27, and right shifting a u8 27 bits is always
    going to result in zero. The fix is to declare these variables as u32.

    Fixes: d1ff70241a27 ("thunderbolt: Add support for XDomain discovery protocol")
    Signed-off-by: Dan Carpenter
    Signed-off-by: David S. Miller

    Dan Carpenter
     

10 Oct, 2017

1 commit

  • The 0day kbuild robot reports following crash:

    BUG: unable to handle kernel NULL pointer dereference at 00000004
    IP: tb_property_find+0xe/0x41
    *pde = 00000000
    Oops: 0000 [#1]
    CPU: 0 PID: 1 Comm: swapper Not tainted 4.14.0-rc1-00741-ge69b6c0 #412
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
    task: 89c80000 task.stack: 89c7c000
    EIP: tb_property_find+0xe/0x41
    EFLAGS: 00210246 CPU: 0
    EAX: 00000000 EBX: 7a368f47 ECX: 00000044 EDX: 7a368f47
    ESI: 8851d340 EDI: 7a368f47 EBP: 89c7df0c ESP: 89c7defc
    DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
    CR0: 80050033 CR2: 00000004 CR3: 027a2000 CR4: 00000690
    Call Trace:
    tb_register_property_dir+0x49/0xb9
    ? cdc_mbim_driver_init+0x1b/0x1b
    tbnet_init+0x77/0x9f
    ? cdc_mbim_driver_init+0x1b/0x1b
    do_one_initcall+0x7e/0x145
    ? parse_args+0x10c/0x1b3
    ? kernel_init_freeable+0xbe/0x159
    kernel_init_freeable+0xd1/0x159
    ? rest_init+0x110/0x110
    kernel_init+0xd/0xd0
    ret_from_fork+0x19/0x30

    The reason is that both Thunderbolt bus and thunderbolt-net are build
    into the kernel image, and the latter is linked first because
    drivers/net comes before drivers/thunderbolt. Since both use
    module_init() thunderbolt-net ends up calling Thunderbolt bus functions
    too early triggering the above crash.

    Fix this by moving Thunderbolt bus initialization to happen earlier to
    make sure all the data structures are ready when Thunderbolt service
    drivers are initialized. To be on the safe side also add a check for
    properly initialized xdomain_property_dir to tb_register_property_dir().

    Reported-by: kernel test robot
    Signed-off-by: Mika Westerberg
    Signed-off-by: David S. Miller

    Mika Westerberg
     

03 Oct, 2017

15 commits

  • Thunderbolt services should not care which HopID (ring) they use for
    sending and receiving packets over the high-speed DMA path, so make
    tb_ring_alloc_rx() and tb_ring_alloc_tx() accept negative HopID. This
    means that the NHI will allocate next available HopID for the caller
    automatically.

    These HopIDs will be allocated from the range which is not reserved for
    the Thunderbolt protocol (8 .. hop_count - 1).

    The allocated HopID can be retrieved from ring->hop field after the ring
    has been allocated successfully if needed.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • In order to support things like networking over Thunderbolt cable, there
    needs to be a way to switch the ring to a mode where it can be polled
    with the interrupt masked. We implement such mode so that the caller can
    allocate a ring by passing pointer to a function that is then called
    when an interrupt is triggered. Completed frames can be fetched using
    tb_ring_poll() and the interrupt can be re-enabled when the caller is
    finished with polling by using tb_ring_poll_complete().

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • This is needed because ring polling functionality can be called from
    atomic contexts when networking and other high-speed traffic is
    transferred over a Thunderbolt cable.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • This makes it possible to enqueue frames also from atomic context which
    is needed for example, when networking packets are sent over a
    Thunderbolt cable.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • A Thunderbolt service driver might need to check if there was an error
    with the descriptor when in frame mode. We also add two Rx specific
    error flags RING_DESC_CRC_ERROR and RING_DESC_BUFFER_OVERRUN.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • These are used by Thunderbolt services to send and receive frames over
    the high-speed DMA rings.

    We also put the functions to tb_ namespace to make sure we do not
    collide with others and add missing kernel-doc comments for the exported
    functions.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • When high-speed DMA paths are used to transfer arbitrary data over a
    Thunderbolt link, DMA rings should be in frame mode instead of raw mode.
    The latter is used by the control channel (ring 0). In frame mode each
    data frame can hold up to 4kB payload.

    This patch modifies the DMA ring code to allow configuring a ring to be
    in frame mode by passing a new flag (RING_FLAG_FRAME) to the ring when
    it is allocated. In addition there might be need to enable end-to-end
    (E2E) workaround for the ring to prevent losing Rx frames in certain
    situations. We add another flag (RING_FLAG_E2E) that can be used for
    this purpose.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • This will keep the interrupt delivery rate reasonable. The value used
    here (128 us) is a recommendation from the hardware people.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • When two hosts are connected over a Thunderbolt cable, there is a
    protocol they can use to communicate capabilities supported by the host.
    The discovery protocol uses automatically configured control channel
    (ring 0) and is build on top of request/response transactions using
    special XDomain primitives provided by the Thunderbolt base protocol.

    The capabilities consists of a root directory block of basic properties
    used for identification of the host, and then there can be zero or more
    directories each describing a Thunderbolt service and its capabilities.

    Once both sides have discovered what is supported the two hosts can
    setup high-speed DMA paths and transfer data to the other side using
    whatever protocol was agreed based on the properties. The software
    protocol used to communicate which DMA paths to enable is service
    specific.

    This patch adds support for the XDomain discovery protocol to the
    Thunderbolt bus. We model each remote host connection as a Linux XDomain
    device. For each Thunderbolt service found supported on the XDomain
    device, we create Linux Thunderbolt service device which Thunderbolt
    service drivers can then bind to based on the protocol identification
    information retrieved from the property directory describing the
    service.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • A Thunderbolt service might need to find the physical port from a link
    the cable is connected to. For instance networking driver uses this
    information to generate MAC address according the Apple ThunderboltIP
    protocol.

    Move this function to thunderbolt.h and rename it to
    tb_phy_port_from_link() to reflect the fact that it does not take switch
    as parameter.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • These are needed by Thunderbolt services so move them to thunderbolt.h
    to make sure they are available outside of drivers/thunderbolt.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • These will be needed by Thunderbolt services when sending and receiving
    XDomain control messages. While there change TB_CFG_PKG_PREPARE_TO_SLEEP
    value to be decimal in order to be consistent with other members.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • Thunderbolt XDomain discovery protocol uses directories which contain
    properties and other directories to exchange information about what
    capabilities the remote host supports. This also includes identification
    information like device ID and name.

    This adds support for parsing and formatting these properties and
    establishes an API drivers can use in addition to the core Thunderbolt
    driver. This API is exposed in a new header: include/linux/thunderbolt.h.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • These messages are all 32-bit aligned and they should be packed without
    the __packed attribute just fine. It also allows compiler to generate
    better code on some architectures.

    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     
  • We will be using these when communicating XDomain discovery protocol
    over Thunderbolt link but they might be useful for other drivers as
    well.

    Make them available through byteorder/generic.h.

    Suggested-by: Andy Shevchenko
    Signed-off-by: Mika Westerberg
    Reviewed-by: Michael Jamet
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: David S. Miller

    Mika Westerberg
     

06 Sep, 2017

1 commit

  • Pull ACPI updates from Rafael Wysocki:
    "These include a usual ACPICA code update (this time to upstream
    revision 20170728), a fix for a boot crash on some systems with
    Thunderbolt devices connected at boot time, a rework of the handling
    of PCI bridges when setting up device wakeup, new support for Apple
    device properties, support for DMA configurations reported via ACPI on
    ARM64, APEI-related updates, ACPI EC driver updates and assorted minor
    modifications in several places.

    Specifics:

    - Update the ACPICA code in the kernel to upstream revision 20170728
    including:
    * Alias operator handling update (Bob Moore).
    * Deferred resolution of reference package elements (Bob Moore).
    * Support for the _DMA method in walk resources (Bob Moore).
    * Tables handling update and support for deferred table
    verification (Lv Zheng).
    * Update of SMMU models for IORT (Robin Murphy).
    * Compiler and disassembler updates (Alex James, Erik Schmauss,
    Ganapatrao Kulkarni, James Morse).
    * Tools updates (Erik Schmauss, Lv Zheng).
    * Assorted minor fixes and cleanups (Bob Moore, Kees Cook, Lv
    Zheng, Shao Ming).

    - Rework the initialization of non-wakeup GPEs with method handlers
    in order to address a boot crash on some systems with Thunderbolt
    devices connected at boot time where we miss an early hotplug event
    due to a delay in GPE enabling (Rafael Wysocki).

    - Rework the handling of PCI bridges when setting up ACPI-based
    device wakeup in order to avoid disabling wakeup for bridges
    prematurely (Rafael Wysocki).

    - Consolidate Apple DMI checks throughout the tree, add support for
    Apple device properties to the device properties framework and use
    these properties for the handling of I2C and SPI devices on Apple
    systems (Lukas Wunner).

    - Add support for _DMA to the ACPI-based device properties lookup
    code and make it possible to use the information from there to
    configure DMA regions on ARM64 systems (Lorenzo Pieralisi).

    - Fix several issues in the APEI code, add support for exporting the
    BERT error region over sysfs and update APEI MAINTAINERS entry with
    reviewers information (Borislav Petkov, Dongjiu Geng, Loc Ho, Punit
    Agrawal, Tony Luck, Yazen Ghannam).

    - Fix a potential initialization ordering issue in the ACPI EC driver
    and clean it up somewhat (Lv Zheng).

    - Update the ACPI SPCR driver to extend the existing XGENE 8250
    workaround in it to a new platform (m400) and to work around an
    Xgene UART clock issue (Graeme Gregory).

    - Add a new utility function to the ACPI core to support using ACPI
    OEM ID / OEM Table ID / Revision for system identification in
    blacklisting or similar and switch over the existing code already
    using this information to this new interface (Toshi Kani).

    - Fix an xpower PMIC issue related to GPADC reads that always return
    0 without extra pin manipulations (Hans de Goede).

    - Add statements to print debug messages in a couple of places in the
    ACPI core for easier diagnostics (Rafael Wysocki).

    - Clean up the ACPI processor driver slightly (Colin Ian King, Hanjun
    Guo).

    - Clean up the ACPI x86 boot code somewhat (Andy Shevchenko).

    - Add a quirk for Dell OptiPlex 9020M to the ACPI backlight driver
    (Alex Hung).

    - Assorted fixes, cleanups and updates related to ACPI (Amitoj Kaur
    Chawla, Bhumika Goyal, Frank Rowand, Jean Delvare, Punit Agrawal,
    Ronald Tschalär, Sumeet Pawnikar)"

    * tag 'acpi-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (75 commits)
    ACPI / APEI: Suppress message if HEST not present
    intel_pstate: convert to use acpi_match_platform_list()
    ACPI / blacklist: add acpi_match_platform_list()
    ACPI, APEI, EINJ: Subtract any matching Register Region from Trigger resources
    ACPI: make device_attribute const
    ACPI / sysfs: Extend ACPI sysfs to provide access to boot error region
    ACPI: APEI: fix the wrong iteration of generic error status block
    ACPI / processor: make function acpi_processor_check_duplicates() static
    ACPI / EC: Clean up EC GPE mask flag
    ACPI: EC: Fix possible issues related to EC initialization order
    ACPI / PM: Add debug statements to acpi_pm_notify_handler()
    ACPI: Add debug statements to acpi_global_event_handler()
    ACPI / scan: Enable GPEs before scanning the namespace
    ACPICA: Make it possible to enable runtime GPEs earlier
    ACPICA: Dispatch active GPEs at init time
    ACPI: SPCR: work around clock issue on xgene UART
    ACPI: SPCR: extend XGENE 8250 workaround to m400
    ACPI / LPSS: Don't abort ACPI scan on missing mem resource
    mailbox: pcc: Drop uninformative output during boot
    ACPI/IORT: Add IORT named component memory address limits
    ...

    Linus Torvalds
     

04 Sep, 2017

1 commit

  • * acpi-x86:
    ACPI / boot: Add number of legacy IRQs to debug output
    ACPI / boot: Correct address space of __acpi_map_table()
    ACPI / boot: Don't define unused variables

    * acpi-soc:
    ACPI / LPSS: Don't abort ACPI scan on missing mem resource

    * acpi-pmic:
    ACPI / PMIC: xpower: Do pinswitch magic when reading GPADC

    * acpi-apple:
    spi: Use Apple device properties in absence of ACPI resources
    ACPI / scan: Recognize Apple SPI and I2C slaves
    ACPI / property: Support Apple _DSM properties
    ACPI / property: Don't evaluate objects for devices w/o handle
    treewide: Consolidate Apple DMI checks

    Rafael J. Wysocki
     

28 Aug, 2017

4 commits

  • There is a mistake here where we accidentally use sizeof(TB_CFG_PKG_RESET)
    instead of just TB_CFG_PKG_RESET. The size of an int is 4 so it's the
    same as TB_CFG_PKG_NOTIFY_ACK.

    Fixes: d7f781bfdbf4 ("thunderbolt: Rework control channel to be more reliable")
    Reported-by: Colin King
    Signed-off-by: Dan Carpenter
    Acked-by: Mika Westerberg
    Cc: stable # 4.13
    Signed-off-by: Greg Kroah-Hartman

    Dan Carpenter
     
  • If secure authentication of a devices fails, either because the device
    already has another key uploaded, or there is some other error sending
    challenge to the device, and the user only wants to approve the device
    just once (without a new key being uploaded to the device) the current
    implementation does not allow this because the key cannot be cleared
    once set even if we allow it to be changed.

    Make this scenario possible and allow clearing the key by writing
    empty string to the key sysfs file.

    Signed-off-by: Yehezkel Bernat
    Acked-by: Mika Westerberg
    Signed-off-by: Greg Kroah-Hartman

    Bernat, Yehezkel
     
  • Non-root user may read the key back after root wrote it there.
    This removes read access to everyone but root.

    Signed-off-by: Yehezkel Bernat
    Acked-by: Mika Westerberg
    Signed-off-by: Greg Kroah-Hartman

    Bernat, Yehezkel
     
  • The key size is tested by hex2bin() already (as '\0' isn't an hex digit)

    Suggested-by: Andy Shevchenko
    Signed-off-by: Yehezkel Bernat
    Acked-by: Mika Westerberg
    Signed-off-by: Greg Kroah-Hartman

    Bernat, Yehezkel
     

14 Aug, 2017

1 commit


11 Aug, 2017

1 commit

  • Some Alpine Ridge LP DROMs (there might be others) erroneusly list more
    ports than the controller actually has. Most probably because DROM of
    the full Dual/Single port Thunderbolt controller was reused for LP
    version. The current DROM parser does not check the upper bound thus it
    leads to crash when sw->ports[] is accessed over bounds:

    BUG: unable to handle kernel NULL pointer dereference at 00000000000002ec
    IP: tb_drom_read+0x383/0x890 [thunderbolt]
    PGD 0
    P4D 0
    Oops: 0000 [#1] SMP
    CPU: 3 PID: 12248 Comm: systemd-udevd Not tainted 4.13.0-rc1-next-20170719 #1
    Hardware name: LENOVO 20HF000YGE/20HF000YGE, BIOS N1WET32W (1.11 ) 05/23/2017
    task: ffff8a293e4bcd80 task.stack: ffffa698027a8000
    RIP: 0010:tb_drom_read+0x383/0x890 [thunderbolt]
    RSP: 0018:ffffa698027ab990 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: ffff8a2940af7800 RCX: 0000000000000000
    RDX: ffff8a2940ebb400 RSI: 0000000000000000 RDI: ffffa698027ab9a0
    RBP: ffffa698027ab9d0 R08: 0000000000000001 R09: 0000000000000002
    R10: ffff8a2940ebb5b0 R11: 0000000000000000 R12: ffff8a293bfa968c
    R13: 000000000000002c R14: 0000000000000056 R15: 0000000000000056
    FS: 00007f0a945a38c0(0000) GS:ffff8a2961580000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 00000000000002ec CR3: 000000043e785000 CR4: 00000000003606e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
    tb_switch_add+0x9d/0x730 [thunderbolt]
    ? tb_switch_alloc+0x3cd/0x4d0 [thunderbolt]
    icm_start+0x5a/0xa0 [thunderbolt]
    tb_domain_add+0xc3/0xf0 [thunderbolt]
    nhi_probe+0x19e/0x310 [thunderbolt]
    local_pci_probe+0x42/0xa0
    pci_device_probe+0x18d/0x1a0
    driver_probe_device+0x2ff/0x450
    __driver_attach+0xa4/0xe0
    ? driver_probe_device+0x450/0x450
    bus_for_each_dev+0x6e/0xb0
    driver_attach+0x1e/0x20
    bus_add_driver+0x1d0/0x270
    ? 0xffffffffc0bbb000
    driver_register+0x60/0xe0
    ? 0xffffffffc0bbb000
    __pci_register_driver+0x4c/0x50
    nhi_init+0x28/0x1000 [thunderbolt]
    do_one_initcall+0x50/0x190
    ? __vunmap+0x81/0xb0
    ? _cond_resched+0x1a/0x50
    ? kmem_cache_alloc_trace+0x15f/0x1c0
    ? do_init_module+0x27/0x1e9
    do_init_module+0x5f/0x1e9
    load_module+0x24e7/0x2a60
    ? vfs_read+0x115/0x130
    SYSC_finit_module+0xfc/0x120
    ? SYSC_finit_module+0xfc/0x120
    SyS_finit_module+0xe/0x10
    do_syscall_64+0x67/0x170
    entry_SYSCALL64_slow_path+0x25/0x25

    Fix this by making sure we only enumerate DROM port entries the hardware
    actually has.

    Reported-by: Christian Kellner
    Signed-off-by: Mika Westerberg
    Reviewed-by: Lukas Wunner
    Tested-by: Christian Kellner
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg
     

04 Aug, 2017

2 commits

  • We're about to amend ACPI bus scan with DMI checks whether we're running
    on a Mac to support Apple device properties in AML. The DMI checks are
    performed for every single device, adding overhead for everything x86
    that isn't Apple, which is the majority. Rafael and Andy therefore
    request to perform the DMI match only once and cache the result.

    Outside of ACPI various other Apple DMI checks exist and it seems
    reasonable to use the cached value there as well. Rafael, Andy and
    Darren suggest performing the DMI check in arch code and making it
    available with a header in include/linux/platform_data/x86/.

    To this end, add early_platform_quirks() to arch/x86/kernel/quirks.c
    to perform the DMI check and invoke it from setup_arch(). Switch over
    all existing Apple DMI checks, thereby fixing two deficiencies:

    * They are now #defined to false on non-x86 arches and can thus be
    optimized away if they're located in cross-arch code.

    * Some of them only match "Apple Inc." but not "Apple Computer, Inc.",
    which is used by BIOSes released between January 2006 (when the first
    x86 Macs started shipping) and January 2007 (when the company name
    changed upon introduction of the iPhone).

    Suggested-by: Andy Shevchenko
    Suggested-by: Rafael J. Wysocki
    Suggested-by: Darren Hart
    Signed-off-by: Lukas Wunner
    Acked-by: Mika Westerberg
    Signed-off-by: Rafael J. Wysocki

    Lukas Wunner
     
  • * pm-core:
    PM / runtime: Document new pm_runtime_set_suspended() constraint

    * pm-misc:
    thunderbolt: icm: Ignore mailbox errors in icm_suspend()

    Rafael J. Wysocki
     

31 Jul, 2017

1 commit

  • On one of my test machines nhi_mailbox_cmd() called from icm_suspend()
    times out and returnes an error which then is propagated to the
    caller and causes the entire system suspend to be aborted which isn't
    very useful.

    Instead of aborting system suspend, print the error into the log
    and continue.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Mika Westerberg
    Acked-by: Michael Jamet

    Rafael J. Wysocki
     

26 Jul, 2017

1 commit


24 Jul, 2017

1 commit


17 Jul, 2017

1 commit

  • Firmware upgrade tools that decide which NVM image should be uploaded to
    the Thunderbolt controller need to access active parts of the NVM even
    if they are not run as root. The information in active NVM is not
    considered security critical so we can use the default permissions set
    by the NVMem framework.

    Writing the NVM image is still left as root only operation.

    While there mark the active NVM as read-only in the filesystem.

    Reported-by: Yehezkel Bernat
    Signed-off-by: Mika Westerberg
    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg
     

09 Jun, 2017

3 commits

  • Trivial fix to spelling mistake in tb_sw_warn warning message

    Signed-off-by: Colin Ian King
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     
  • Starting from Intel Falcon Ridge the NVM firmware can be upgraded by
    using DMA configuration based mailbox commands. If we detect that the
    host or device (device support starts from Intel Alpine Ridge) has the
    DMA configuration based mailbox we expose NVM information to the
    userspace as two separate Linux NVMem devices: nvm_active and
    nvm_non_active. The former is read-only portion of the active NVM which
    firmware upgrade tools can be use to find out suitable NVM image if the
    device identification strings are not enough.

    The latter is write-only portion where the new NVM image is to be
    written by the userspace. It is up to the userspace to find out right
    NVM image (the kernel does very minimal validation). The ICM firmware
    itself authenticates the new NVM firmware and fails the operation if it
    is not what is expected.

    We also expose two new sysfs files per each switch: nvm_version and
    nvm_authenticate which can be used to read the active NVM version and
    start the upgrade process.

    We also introduce safe mode which is the mode a switch goes when it does
    not have properly authenticated firmware. In this mode the switch only
    accepts a couple of commands including flashing a new NVM firmware image
    and triggering power cycle.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg
     
  • Starting from Intel Falcon Ridge the internal connection manager running
    on the Thunderbolt host controller has been supporting 4 security
    levels. One reason for this is to prevent DMA attacks and only allow
    connecting devices the user trusts.

    The internal connection manager (ICM) is the preferred way of connecting
    Thunderbolt devices over software only implementation typically used on
    Macs. The driver communicates with ICM using special Thunderbolt ring 0
    (control channel) messages. In order to handle these messages we add
    support for the ICM messages to the control channel.

    The security levels are as follows:

    none - No security, all tunnels are created automatically
    user - User needs to approve the device before tunnels are created
    secure - User need to approve the device before tunnels are created.
    The device is sent a challenge on future connects to be able
    to verify it is actually the approved device.
    dponly - Only Display Port and USB tunnels can be created and those
    are created automatically.

    The security levels are typically configurable from the system BIOS and
    by default it is set to "user" on many systems.

    In this patch each Thunderbolt device will have either one or two new
    sysfs attributes: authorized and key. The latter appears for devices
    that support secure connect.

    In order to identify the device the user can read identication
    information, including UUID and name of the device from sysfs and based
    on that make a decision to authorize the device. The device is
    authorized by simply writing 1 to the "authorized" sysfs attribute. This
    is following the USB bus device authorization mechanism. The secure
    connect requires an additional challenge step (writing 2 to the
    "authorized" attribute) in future connects when the key has already been
    stored to the NVM of the device.

    Non-ICM systems (before Alpine Ridge) continue to use the existing
    functionality and the security level is set to none. For systems with
    Alpine Ridge, even on Apple hardware, we will use ICM.

    This code is based on the work done by Amir Levy and Michael Jamet.

    Signed-off-by: Michael Jamet
    Signed-off-by: Mika Westerberg
    Reviewed-by: Yehezkel Bernat
    Reviewed-by: Andy Shevchenko
    Signed-off-by: Andreas Noever
    Signed-off-by: Greg Kroah-Hartman

    Mika Westerberg