Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
interfaces: add gpio-memory-control interface #4323
Conversation
kyrofa
requested a review
from
jdstrand
Nov 29, 2017
| +const gpioMemoryControlConnectedPlugAppArmor = ` | ||
| +# Description: Allow writing to /dev/gpiomem on kernels that provide it. | ||
| +# | ||
| +/dev/gpiomem rw, |
kyrofa
Nov 29, 2017
Member
Honestly I don't know. This worked for my purposes, which given my rudimentary understanding of the lib I'm using uses mmap, but it's possible they're falling back (note that I see no denials, however).
Note also that physical-memory-control does not use m for /dev/mem: https://github.com/snapcore/snapd/blob/master/interfaces/builtin/physical_memory_control.go#L41 .
|
@kyrofa once this gets a review from @jdstrand we should work with @sergiocazzolato on a spread test to make sure, you know, that it really works ;-) |
Do you have rpis in your test rig? |
|
Huh. Not sure what this Travis failure means:
|
jdstrand
requested changes
Nov 29, 2017
Looks good. Please address the review comments and get signoff on the name from @niemeyer.
| + | ||
| +package builtin | ||
| + | ||
| +const gpioMemoryControlSummary = `allows write access to all gpio memory` |
jdstrand
Nov 29, 2017
Contributor
Can you add a comment above this:
// https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/bcm2835-gpiomem.c
| +` | ||
| + | ||
| +const gpioMemoryControlConnectedPlugAppArmor = ` | ||
| +# Description: Allow writing to /dev/gpiomem on kernels that provide it. |
jdstrand
Nov 29, 2017
Contributor
Can you update this to be:
# Description: Allow writing to /dev/gpiomem on kernels that provide it (eg,
# via the bcm2835-gpiomem kernel module). This allows direct access to the
# physical memory for GPIO devices (ie, a subset of /dev/mem) and therefore
# grants access to all GPIO devices on the system.
| +const gpioMemoryControlConnectedPlugAppArmor = ` | ||
| +# Description: Allow writing to /dev/gpiomem on kernels that provide it. | ||
| +# | ||
| +/dev/gpiomem rw, |
kyrofa
Nov 29, 2017
Member
Honestly I don't know. This worked for my purposes, which given my rudimentary understanding of the lib I'm using uses mmap, but it's possible they're falling back (note that I see no denials, however).
Note also that physical-memory-control does not use m for /dev/mem: https://github.com/snapcore/snapd/blob/master/interfaces/builtin/physical_memory_control.go#L41 .
| + | ||
| +func init() { | ||
| + registerIface(&commonInterface{ | ||
| + name: "gpio-memory-control", |
jdstrand
Nov 29, 2017
Contributor
I'm conflicted on the name. On the one hand /dev/gpiomem gives precisely access to all GPIO memory so gpio-memory-control makes a lot of sense. However, there are several GPIO kernel systems and I wonder if it makes sense to have this interface reflect that this is for one, /dev/gpiomem, and therefore the interface could be named gpiomem-control. I think I prefer what you have, gpio-memory-control, but please get signoff from @niemeyer on the name.
| @@ -83,6 +83,9 @@ apps: | ||
| fwupd: | ||
| command: bin/run | ||
| plugs: [ fwupd ] | ||
| + gpio-memory-control: | ||
| + command: bin/run | ||
| + plugs: [ gpio-memory-control ] |
jdstrand
requested a review
from
niemeyer
Nov 29, 2017
codecov-io
commented
Nov 29, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #4323 +/- ##
========================================
Coverage ? 76.2%
========================================
Files ? 446
Lines ? 38784
Branches ? 0
========================================
Hits ? 29555
Misses ? 7215
Partials ? 2014
Continue to review full report at Codecov.
|
|
Looks good, thanks for adding this interface! This can go in once we have sign-off for the name from @niemeyer |
|
@kyrofa and you get to write a forum post about it and we get to link it via interface meta-data in snapd :) |
kyrofa commentedNov 29, 2017
Raspberry Pi systems expose GPIO-only memory at /dev/gpiomem, which provides much faster memory-mapped access than sysfs while being more constrained than /dev/mem.
Support write-access to /dev/gpiomem with a new interface named gpio-memory-control.