708342 Commits

Author SHA1 Message Date
Mohan Srinivasan
92fc7f9aa0 ANDROID: input: keychord: Fix a slab out-of-bounds read.
Fix a slab out of bounds read in keychord_write(), detected by KASAN.

Signed-off-by: Mohan Srinivasan <srmohan@google.com>
Bug: 63962952
Change-Id: Iafef48b5d7283750ac0f39f5aaa767b1c3bf2004

[AmitP: Folded following android-4.9 commit changes into this patch
        a1e4c795e1b6 ("Use %zu to print resid (size_t).")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
JP Abgrall
4017c45e8b ANDROID: input: keychord: log when keychord triggered
log keychord id at info level just before waking up processes.

Signed-off-by: JP Abgrall <jpa@google.com>

[AmitP: Rename task_list in wait_queue_head{} to align with upstream commit
        2055da97389a ("sched/wait: Disambiguate wq_entry->task_list and wq_head->task_list naming")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Eric Ernst
3ed870f4b0 ANDROID: input: keyreset: switch to orderly_reboot
Prior restart function would make a call to sys_sync and then
execute a kernel reset.  Rather than call the sync directly,
thus necessitating this driver to be builtin, call orderly_reboot,
which will take care of the file system sync.

Note: since CONFIG_INPUT Kconfig is tristate, this driver can be built
as module, despite being marked bool.

Signed-off-by: Eric Ernst <eric.ernst@linux.intel.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
514c1205c9 ANDROID: input: keyreset: Made keyreset more robust
Switched do_restart to run in a seperate workqueue to  handle
cases where kernel_restart hangs.

Change-Id: I1ecd61f8d0859f1a86d37c692351d644b5db9c69
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
e82706f010 ANDROID: input: keyreset: Changed keyreset to act as a wrapper for keycombo.
keyreset now registers a keycombo driver that acts as the old
keyreset driver acted.

Change-Id: I08f5279e3a33b267571b699697f9f54508868983
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Daniel Rosenberg
c0f873e9ac ANDROID: input: keycombo: add keycombo, a general key combo driver.
Keycombo lets you provide a key up and key down function, and an
optional time delay for key down. The driver will call the key
down function after the specified key combo has been held for the
speicified time delay. After you release the combo, if the key down
has happened, it calls key up.

Change-Id: I6a9a94e96a8f58fadd908fd1dc7944b9102a089f
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2017-12-18 21:11:22 +05:30
Mike Lockwood
08a0437bf8 ANDROID: input: keychord: Add keychord driver
This driver allows userspace to receive notification when client
specified key combinations are pressed.
The client opens /dev/keychord and writes a list of keychords
for the driver to monitor.
The client then reads or polls /dev/keychord for notifications.
A client specified ID for the keychord is returned from read()
when a keychord press is detected.

Signed-off-by: Mike Lockwood <lockwood@android.com>

keychord: fix to build without CONFIG_PREEMPT

Change-Id: I911f13aeda4224b6fa57863bc7e8972fec8837fb

[AmitP: Folded following android-4.9 commit changes into this patch
        f4d1cf1208fe ("ANDROID: input: misc: keychord: move header to uapi")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Arve Hjønnevåg
dd06fdde72 ANDROID: input: keyreset: Add keyreset driver.
Add a platform device in the board file to specify a reset key-combo.
The first time the key-combo is detected a work function that syncs
the filesystems is scheduled. If all the keys are released and then
pressed again, it calls panic. Reboot on panic should be set for
this to work.

Change-Id: I9d54283ca1fba45e4b1ae1a407524cdda8171143
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
bbaee1971e ANDROID: input: gpio_matrix: Remove wakelock.h dependencies
Change-Id: I228bcdebf28f5c67765002043d3f919718827316
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Todd Poynor
a177fb102f ANDROID: input: gpio_input: convert from wakelocks to wakeup sources
And add device names to wakeup source names

Change-Id: Ia5f2723319a2e749f00d6ec7d846edff6af6d5c2
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2017-12-18 21:11:22 +05:30
Colin Cross
1e8d9257c6 ANDROID: input: gpio_event: remove early suspend
Remove the early suspend handler.  Leave the suspend functions
for now, they should eventually get called through a userspace
interface.x

Change-Id: I67f9dafe32fe32577bab93c42b95824db96c215c
Signed-off-by: Colin Cross <ccross@android.com>
2017-12-18 21:11:22 +05:30
Arve Hjønnevåg
df4ef815c8 ANDROID: input: Generic GPIO Input devices
Supports keyboard matrixces, direct inputs, direct outputs and axes connected to gpios.

Change-Id: I5e921e6e3a1cc169316ee3b665f4cc21b5735114
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Nick Pelly <npelly@google.com>

[AmitP: Use ktime directly to align with upstream commit
        2456e8553544 ("ktime: Get rid of the union")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Rom Lemarchand
6a45470bc3 ANDROID: initramfs: Add skip_initramfs command line option
Add a skip_initramfs option to allow choosing whether to boot using
the initramfs or not at runtime.

Change-Id: If30428fa748c1d4d3d7b9d97c1f781de5e4558c3
Signed-off-by: Rom Lemarchand <romlem@google.com>
2017-12-18 21:11:22 +05:30
Jin Qian
d02a7ff02e ANDROID: build: add build server configs for goldfish
Change-Id: Icd7a8d44df2b09394be5c6230c64ecb374cae236

[AmitP: Folded following android-4.9 commit changes into this patch
        d7d2efab84d5 ("ANDROID: build: fix build config kernel_dir")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Jin Qian
b57a40f564 ANDROID: goldfish: add ranchu defconfigs
Change-Id: I73ef1b132b6203ae921a1e1d4850eaadf58f8926

[AmitP: Folded following android-4.9 commit changes into this patch
        b821439faf75 ("ANDROID: arm64: rename ranchu defconfig to ranchu64")
        1a03fc05a569 ("ANDROID: goldfish: enable CONFIG_INET_DIAG_DESTROY")
        2bed6160b367 ("ANDROID: goldfish: disable GOLDFISH_SYNC")
        ec6a764367a4 ("ANDROID: goldfish_sync: update defconfig for 4.9-compatible version")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Amit Pundir
0eb2b3b251 ANDROID: goldfish_sync_timeline: Rename fence to dma_fence
Rename fence interfaces to dma_fence to match with the upstream
commit, f54d1867005c ("dma-buf: Rename struct fence to dma_fence"),
changes.

FIXME: Might be a good idea to remove goldfish_sync_timeline and
       use upstream sync_timeline interfaces instead.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
ad2d529e6d ANDROID: goldfish_sync: 32 max cmds to save stack
We never use the 64 anyway.

Should fix compile warning.

Change-Id: I384155cc24e0a259d7d3898f310fc33154991311
Signed-off-by: Lingfeng Yang <lfy@google.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
deb85ad87d ANDROID: goldfish_sync: Fix sync_file_obj is NULL but dereferenced problem
Change-Id: I22c1e8c96a62ceaf3b0088b0b81dced6889334ab
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Dmitry Shmidt
3e59166fc3 ANDROID: goldfish_sync: Isolate single module to fix compilation
ERROR: "goldfish_sync_timeline_signal_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_timeline_create_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_pt_create_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!
ERROR: "goldfish_sync_timeline_put_internal"
   [drivers/staging/goldfish/goldfish_sync.ko] undefined!

Change-Id: I2a97c2a33b38ceeb696d28187539c158aa97a620
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
d1c4322ea1 ANDROID: goldfish_sync: upgrade to new fence sync api
goldfish_sync requires the following modifications
to bring it up:

- Copy and integrate goldfish_sync version of
sw_sync, from out of dma-buf driver.
- Don't delete timelines by itself; rely on put

Change-Id: Ie88d506955dbf5c8532281f122471dc7b1c0bccb
Signed-off-by: Lingfeng Yang <lfy@google.com>
2017-12-18 21:11:22 +05:30
Lingfeng Yang
818555892c ANDROID: goldfish_sync: Add goldfish sync driver
This is kernel driver for controlling the Goldfish sync
device on the host. It is used to maintain ordering
in critical OpenGL state changes while using
GPU emulation.

The guest open()'s the Goldfish sync device to create
a context for possibly maintaining sync timeline and fences.
There is a 1:1 correspondence between such sync contexts
and OpenGL contexts in the guest that need synchronization
(which in turn, is anything involving swapping buffers,
SurfaceFlinger, or Hardware Composer).

The ioctl QUEUE_WORK takes a handle to a sync object
and attempts to tell the host GPU to wait on the sync object
and deal with signaling it. It possibly outputs
a fence FD on which the Android systems that use them
(GLConsumer, SurfaceFlinger, anything employing
EGL_ANDROID_native_fence_sync) can use to wait.

Design decisions and work log:

- New approach is to have the guest issue ioctls that
  trigger host wait, and then host increments timeline.
- We need the host's sync object handle and sync thread handle
  as the necessary information for that.
- ioctl() from guest can work simultaneously with the
  interrupt handling for commands from host.
- optimization: don't write back on timeline inc
- Change spin lock design to be much more lightweight;
  do not call sw_sync functions or loop too long
  anywhere.
- Send read/write commands in batches to minimize guest/host
  transitions.
- robustness: BUG if we will overrun the cmd buffer.
- robustness: return fd -1 if we cannot get an unused fd.
- correctness: remove global mutex
- cleanup pass done, incl. but not limited to:
    - removal of clear_upto and
    - switching to devm_***

This is part of a sequential, multi-CL change:

external/qemu:

https://android-review.googlesource.com/239442 <- host-side device's
host interface

https://android-review.googlesource.com/221593
https://android-review.googlesource.com/248563
https://android-review.googlesource.com/248564
https://android-review.googlesource.com/223032

external/qemu-android:

https://android-review.googlesource.com/238790 <- host-side device
implementation

kernel/goldfish:

https://android-review.googlesource.com/232631 <- needed
https://android-review.googlesource.com/238399 <- this CL

Also squash following bug fixes from android-goldfish-3.18 branch.

b44d486 goldfish_sync: provide a signal to detect reboot
ad1f597 goldfish_sync: fix stalls by avoiding early kfree()
de208e8 [goldfish-sync] Fix possible race between kernel and user space

Change-Id: I22f8a0e824717a7e751b1b0e1b461455501502b6
2017-12-18 21:11:22 +05:30
Joshua Lang
bdcc178732 ANDROID: goldfish_audio: Clear audio read buffer status after each read
The buffer_status field is interrupt updated. After every read request,
the buffer_status read field should be reset so that on the next loop
iteration we don't read a stale value and read data before the
device is ready.

Signed-off-by: “Joshua Lang” <joshualang@google.com>
Change-Id: I4943d5aaada1cad9c7e59a94a87c387578dabe86
2017-12-18 21:11:22 +05:30
Yu Ning
038357818e ANDROID: goldfish_audio: Enable ACPI-based enumeration for goldfish audio
Follow the same way in which ACPI was enabled for goldfish battery. See
commit d3be10e for details.

Change-Id: I6ffe38ebc80fb8af8322152370b9d1fd227eaf50
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-12-18 21:11:22 +05:30
Christoffer Dall
670b5d24dd ANDROID: goldfishfb: Set pixclock = 0
User space Android code identifies pixclock == 0 as a sign for emulation
and will set the frame rate to 60 fps when reading this value, which is
the desired outcome.

Change-Id: I759bf518bf6683446bc786bf1be3cafa02dd8d42
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-12-18 21:11:22 +05:30
Yu Ning
32302fb983 ANDROID: goldfishfb: Enable ACPI-based enumeration for goldfish framebuffer
Follow the same way in which ACPI was enabled for goldfish battery. See
commit d3be10e for details.

Note that this patch also depends on commit af33cac.

Change-Id: Ic63b6e7e0a4b9896ef9a9d0ed135a7796a4c1fdb
Signed-off-by: Yu Ning <yu.ning@intel.com>
2017-12-18 21:11:22 +05:30
Greg Hackmann
89d5196454 ANDROID: goldfishfb: add devicetree bindings
Change-Id: I5f4ba861b981edf39af537001f8ac72202927031
Signed-off-by: Greg Hackmann <ghackmann@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        e4bc8c96ba03 ("ANDROID: video: goldfishfb: fix platform_no_drv_owner.cocci warnings")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Christian Poetzsch
078204d5b8 ANDROID: fs: Fix for in kernel emergency remount when loop mounts are used
adb reboot calls /proc/sysrq-trigger to force an emergency remount (ro) of all
mounted disks. This is executed in the order of the time the mount was originally
done. Because we have a test system which loop mount images from an extra
partition, we see errors cause the loop mounted partitions gets remounted after
this physical partition was set to read only already.

Fix this by reversing the order of the emergency remount. This will remount the
disk first which have been mounted last.

So instead of remounting in this order:
 /dev/sda1
 /dev/loop1
 /dev/loop2
we now remount in this order:
 /dev/loop2
 /dev/loop1
 /dev/sda1

Change-Id: I68fe7e16cc9400ab5278877af70c9ea1d9b57936
Signed-off-by: Christian Poetzsch <christian.potzsch@imgtec.com>
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
a59d873237 ANDROID: fs: Refactor FS readpage/write tracepoints.
Refactor the fs readpage/write tracepoints to move the
inode->path lookup outside the tracepoint code, and pass a pointer
to the path into the tracepoint code instead. This is necessary
because the tracepoint code runs non-preemptible. Thanks to
Trilok Soni for catching this in 4.4.

Signed-off-by: Mohan Srinivasan <srmohan@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        a5c4dbb05ab7 ("ANDROID: Replace spaces by '_' for some android filesystem tracepoints.")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Mohan Srinivasan
45560fee7f ANDROID: fs: FS tracepoints to track IO.
Adds tracepoints in ext4/f2fs/mpage to track readpages/buffered
write()s. This allows us to track files that are being read/written
to PIDs. (Merged from android4.4-common).

Signed-off-by: Mohan Srinivasan <srmohan@google.com>
2017-12-18 21:11:22 +05:30
Jin Qian
605a0bca49 ANDROID: fs: sched: add a counter to track fsync
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>

[AmitP: Refactored changes to align with changes from upstream commit
        9a07000400c8 ("sched/headers: Move CONFIG_TASK_XACCT bits from <linux/sched.h> to <linux/sched/xacct.h>")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Colin Cross
eada3e0077 ANDROID: fs: epoll: use freezable blocking call
Avoid waking up every thread sleeping in an epoll_wait call during
suspend and resume by calling a freezable blocking call.  Previous
patches modified the freezer to avoid sending wakeups to threads
that are blocked in freezable blocking calls.

This call was selected to be converted to a freezable call because
it doesn't hold any locks or release any resources when interrupted
that might be needed by another freezing task or a kernel driver
during suspend, and is a common site where idle userspace tasks are
blocked.

Change-Id: I848d08d28c89302fd42bbbdfa76489a474ab27bf
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-12-18 21:11:22 +05:30
JP Abgrall
19e049622b ANDROID: fs: ext4: Add support for FIDTRIM, a best-effort ioctl for deep discard trim
* What
This provides an interface for issuing an FITRIM which uses the
secure discard instead of just a discard.
Only the eMMC command is "secure", and not how the FS uses it:
due to the fact that the FS might reassign a region somewhere else,
the original deleted data will not be affected by the "trim" which only
handles un-used regions.
So we'll just call it "deep discard", and note that this is a
"best effort" cleanup.

* Why
Once in a while, We want to be able to cleanup most of the unused blocks
after erasing a bunch of files.
We don't want to constantly secure-discard via a mount option.

From an eMMC spec perspective, it tells the device to really get rid of
all the data for the specified blocks and not just put them back into the
pool of free ones (unlike the normal TRIM). The eMMC spec says the
secure trim handling must make sure the data (and metadata) is not available
anymore. A simple TRIM doesn't clear the data, it just puts blocks in the
free pool.
JEDEC Standard No. 84-A441
  7.6.9 Secure Erase
  7.6.10 Secure Trim

From an FS perspective, it is acceptable to leave some data behind.
 - directory entries related to deleted files
 - databases entries related to deleted files
 - small-file data stored in inode extents
 - blocks held by the FS waiting to be re-used (mitigated by sync).
 - blocks reassigned by the FS prior to FIDTRIM.

Change-Id: I676a1404a80130d93930c84898360f2e6fb2f81e
Signed-off-by: Geremy Condra <gcondra@google.com>
Signed-off-by: JP Abgrall <jpa@google.com>
2017-12-18 21:11:22 +05:30
Todd Poynor
090f104c11 ANDROID: fs: fuse: Freeze client on suspend when request sent to userspace
Suspend attempts can abort when the FUSE daemon is already frozen
and a client is waiting uninterruptibly for a response, causing
freezing of tasks to fail.

Use the freeze-friendly wait API, but disregard other signals.

Change-Id: Icefb7e4bbc718ccb76bf3c04daaa5eeea7e0e63c
Signed-off-by: Todd Poynor <toddpoynor@google.com>
2017-12-18 21:11:22 +05:30
Arve Hjønnevåg
ea5c90a736 ANDROID: fs: pstore: ram: Add ramoops_console_write_buf api
Allow writing into the ramoops console buffer.

Change-Id: Iff0d69b562e4dae33ea7f8d19412227bebb17e47
Signed-off-by: Arve Hjønnevåg <arve@android.com>
2017-12-18 21:11:22 +05:30
San Mehat
b2da450efe ANDROID: fs: block_dump: Don't display inode changes if block_dump < 2
Signed-off-by: San Mehat <san@android.com>
2017-12-18 21:11:22 +05:30
Keun-young Park
b7a823da74 ANDROID: dm: verity: add minimum prefetch size
- For device like eMMC, it gives better performance to read more hash
  blocks at a time.
- For android, set it to default 128.
  For other devices, set it to 1 which is the same as now.
- saved boot-up time by 300ms in tested device

bug: 32246564

Change-Id: Ibc0401a0cddba64b862a80445844b4e595213621
Cc: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Keun-young Park <keunyoung@google.com>
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
c35065fc74 ANDROID: dm: android-verity: mark dev as rw for linear target
Mark as rw when adding as linear target to allow changes
to the underlying filesystem through adb disable verity
and adb remount.

(Cherry-picked from
https://partner-android-review.googlesource.com/#/c/613573/
79a3032bb62da65a5d724eb70c8bdc662945d475)

BUG: 28845874
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: If41e9cad8e0f054f4778c09a6e2f0cb8af6fddaf
2017-12-18 21:11:22 +05:30
Bowgo Tsai
f782e47f2c ANDROID: dm: android-verity: allow disable dm-verity for Treble VTS
To start Treble VTS test, a single AOSP system.img will be flashed onto
the device. The size of AOSP system.img might be different than the
system partition size on device, making locating verity metadata fail
(at the last fixed size of the partition).

This change allows disabling dm-verity on system partition when the
device is unlocked (orange device state) with invalid metadata.

BUG: 35603549
Test: boot device with a different-sized system.img, checks verity is
      not enabled via:

          "adb shell getprop | grep partition.system.verified"

Change-Id: Ide78dca4eefde4ab019e4b202d3f590dcb1bb506
Signed-off-by: Bowgo Tsai <bowgotsai@google.com>
2017-12-18 21:11:22 +05:30
Greg Hackmann
9d8757c653 ANDROID: dm: android-verity: fix table_make_digest() error handling
If table_make_digest() fails, verify_verity_signature() would try to
pass the returned ERR_PTR() to kfree().

This fixes the smatch error:

drivers/md/dm-android-verity.c:601 verify_verity_signature() error: 'pks' dereferencing possible ERR_PTR()

Change-Id: I9b9b7764b538cb4a5f94337660e9b0f149b139be
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
539de6b39d ANDROID: dm: android-verity: rebase for 4.9
Export the direct_access method of dm_linear target for
dm-android-verity target.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I46556d882305e5194352946264cbc9c06e5038e4

[AmitP: Rebased the changes for v4.14]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
0b8bcd5c5d ANDROID: dm: android-verity: Remove fec_header location constraint
This CL removes the mandate of the fec_header being located right
after the ECC data.

(Cherry-picked from https://android-review.googlesource.com/#/c/280401)

Bug: 28865197
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: Ie04c8cf2dd755f54d02dbdc4e734a13d6f6507b5
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
28969a9aaf ANDROID: dm: android-verity: adopt changes made to dm callbacks
v4.4 introduced changes to the callbacks used for
dm-linear and dm-verity-target targets. Move to those headers
in dm-android-verity.

Verified on hikey while having
BOARD_USES_RECOVERY_AS_BOOT := true
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true

BUG: 27339727
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: Ic64950c3b55f0a6eaa570bcedc2ace83bbf3005e
2017-12-18 21:11:22 +05:30
Jeremy Compostella
834578d2b3 ANDROID: dm: android-verity: pack the fec_header structure
The fec_header structure is generated build time and stored on disk.
The fec_header might be build on a 64 bits machine while it is read
per a 32 bits device or the other way around.  In such situations, the
fec_header fields are not aligned as expected by the device and it
fails to read the fec_header structure.

This patch makes the fec_header packed.

Change-Id: Idb84453e70cc11abd5ef3a0adfbb16f8b5feaf06
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
1a83a5833d ANDROID: dm: android-verity: Verify header before fetching table
Move header validation logic before reading the verity_table as
an invalid header implies the table is invalid as well.

(Cherry-picked from:
https://partner-android-review.git.corp.google.com/#/c/625203)

BUG: 29940612
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: Ib34d25c0854202f3e70df0a6d0ef1d96f0250c8e
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
2cced7fcad ANDROID: dm: android-verity: allow adb disable-verity only in userdebug
adb disable-verity was allowed when the phone is in the
unlocked state. Since the driver is now aware of the build
variant, honor "adb disable-verity" only in userdebug
builds.

(Cherry-picked from
https://partner-android-review.git.corp.google.com/#/c/622117)

BUG: 29276559
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I7ce9f38d8c7a62361392c5a8ccebb288f8a3a2ea
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
c977df776c ANDROID: dm: android-verity: mount as linear target if eng build
eng builds dont have verity enabled i.e it does even
have verity metadata appended to the parition. Therefore
add rootdev as linear device and map the entire partition
if build variant is "eng".

(Cherry-picked based on
https://partner-android-review.git.corp.google.com/#/c/618690/)

BUG: 29276559
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I8f5c2289b842b820ca04f5773525e5449bb3f355
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
19263573b3 ANDROID: dm: android-verity: use default verity public key
If the dm-android-verity target does not provide a default
key try using the default public key from the system keyring.
The defualt verity keyid is passed as a kernel command line
argument veritykeyid=.

The order of the dm-android-verity params have been reversed
to facilitate the change.

Old format example:
dm="system none ro,0 1 android-verity Android:#7e4333f9bba00adfe0ede979e28ed1920492b40f /dev/mmcblk0p43"

New formats supported:
dm="system none ro,0 1 android-verity /dev/mmcblk0p43 Android:#7e4333f9bba00adfe0ede979e28ed1920492b40f"

(or)

dm="system none ro,0 1 android-verity /dev/mmcblk0p43"
when veritykeyid= is set in the kernel command line.

BUG: 28384658
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I506c89b053d835ab579e703eef2bc1f8487250de
(cherry picked from commit c5c74d0327729f35b576564976885596c6d0e7fb)
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
6d3f1f949f ANDROID: dm: android-verity: fix signature verification flag
The bug was that the signature verification was only
happening when verity was disabled. It should always
happen when verity is enabled.

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
Change-Id: I2d9354e240d36ea06fc68c2d18d8e87b823a4c2f
(cherry picked from commit 5364b5ca0b1a12a58283b51408e43fc36d4e4fe7)
2017-12-18 21:11:22 +05:30
Jeremy Compostella
7c27d16eee ANDROID: dm: android-verity: use name_to_dev_t
This patch makes android_verity_ctr() parse its block device string
parameter with name_to_dev_t().  It allows the use of less hardware
related block device reference like PARTUUID for instance.

Change-Id: Idb84453e70cc11abd5ef3a0adfbb16f8b5feaf07
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
2017-12-18 21:11:22 +05:30
Badhri Jagan Sridharan
47c3ee9725 ANDROID: dm: android-verity: Mounting root as linear device when verity disabled
This CL makes android-verity target to be added as linear
dm device if when bootloader is unlocked and verity is disabled.

Bug: 27175947
Change-Id: Ic41ca4b8908fb2777263799cf3a3e25934d70f18
Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>

[AmitP: Folded following android-4.9 commit changes into this patch
        7e70218c2699 ("ANDROID: dm: Minor cleanup")
        67584ff8412b ("ANDROID: dm: rename dm-linear methods for dm-android-verity")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2017-12-18 21:11:22 +05:30