Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1662589

Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon Djtag driver

From John Garry <john.garry@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon Djtag driver
Date 2017-06-09 18:10 +0200
Message-ID <tQuE2-3IK-39@gated-at.bofh.it> (permalink)
References <tJUtz-5zo-5@gated-at.bofh.it> <tQ8Dw-6E7-15@gated-at.bofh.it> <tQsVA-2Cx-15@gated-at.bofh.it> <tQukH-3nk-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Mark,

> What happens if the lock is already held by an agent in that case?
>
> Does the FW block until the lock is released?

The FW must also honour the contract - it must also block until the lock 
is available.

This may sound bad, but, in reality, probablity of simultaneous perf and 
hotplug access is very low.

>
> Can you elaborate on CPU hotplug? Which CPU is performing the
> maintenance in this scenario, and when? Can this block other CPUs until
> the lock is released?
>
> What happens if another agent pokes the djtag (without acquiring the
> lock) while FW is doing this? Can this result in issues on the secure
> side?
>

I need to check on this.

> [...]
>
>>> Can you explain how the locking scheme works? e.g. is this an
>>> advisory software-only policy, or does the hardware prohibit accesses
>> >from other agents somehow?
>>
>> The locking scheme is a software solution to spinlock. It's uses
>> djtag module select register as the spinlock flag, to avoid using
>> some shared memory.
>>
>> The tricky part is that there is no test-and-set hardware support,
>> so we use this algorithm:
>> - precondition: flag initially set unlocked
>>
>> a. agent reads flag
>>     - if not unlocked, continues to poll
>>     - otherwise, writes agent's unique lock value to flag
>> b. agent waits defined amount of time *uninterrupted* and then
>> checks the flag
>>     - if it is unchanged, it has the lock -> continue
>>     - if it is changed, it means other agent is trying to access the
>> lock and got it, so it goes back to a.
>> c. has lock, so safe to access djtag
>> d. to unlock, release by writing "unlock" value to flag
>
> This does not sound safe to me. There's always the potential for a race,
> no matter how long an agent waits.
>
>>> What happens if the kernel takes the lock, but doesn't release it?
>>
>> This should not happen. We use spinlock_irqsave() when locking.
>> However I have noted that we can BUG if djtag access timeout, so we
>> need to release the lock at this point. I don't think the code
>> handles this properly now.
>
> I was worried aobut BUG() and friends, and also preempt kernels.
>
> It doesn't sound like it's possible to make this robust.
>
>>> What happens if UEFI takes the lock, but doesn't release it?
>>
>> Again, we would not expect this to happen; but, if it does, Kernel
>> access should timeout.
>
> ... which they do not, in this patch series, as far as I can tell.
>

I noticed this also.

> This doesn't sound safe at all. :/

Right, we need to consider if this will fly at all.

At this point, we would rather concentrate on our new chipset, which is 
based on same perf HW architecture (so much code reuse), but uses 
directly mapped registers and *no djtag* - in this, most of the upstream 
effort from all parties is not wasted.

Please advise.

Much appreciated,
John

>
> Thanks,
> Mark.
>
> .
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Mark Rutland <mark.rutland@arm.com> - 2017-06-08 18:40 +0200
  Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver John Garry <john.garry@huawei.com> - 2017-06-09 16:20 +0200
    Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Will Deacon <will.deacon@arm.com> - 2017-06-09 16:40 +0200
      Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver John Garry <john.garry@huawei.com> - 2017-06-09 17:20 +0200
        Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Will Deacon <will.deacon@arm.com> - 2017-06-14 12:20 +0200
          Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-06-14 12:50 +0200
            Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Will Deacon <will.deacon@arm.com> - 2017-06-14 13:10 +0200
          Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Mark Rutland <mark.rutland@arm.com> - 2017-06-14 13:00 +0200
          Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Will Deacon <will.deacon@arm.com> - 2017-06-14 13:10 +0200
            Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver John Garry <john.garry@huawei.com> - 2017-06-14 13:40 +0200
              Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Will Deacon <will.deacon@arm.com> - 2017-06-14 13:50 +0200
                Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver John Garry <john.garry@huawei.com> - 2017-06-14 14:00 +0200
    Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Mark Rutland <mark.rutland@arm.com> - 2017-06-09 17:50 +0200
      Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver John Garry <john.garry@huawei.com> - 2017-06-09 18:10 +0200
        Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Mark Rutland <mark.rutland@arm.com> - 2017-06-09 18:50 +0200
  Re: [PATCH v8 6/9] drivers: perf: hisi: Add support for Hisilicon  Djtag driver Zhangshaokun <zhangshaokun@hisilicon.com> - 2017-06-14 10:20 +0200

csiph-web