Commit Graph

5 Commits

Author SHA1 Message Date
Andrew Scull 65ddfc4d84 Add a property to reflect the app debuggability
Set a build-time config to declare app debuggability that is used as
input to DICE and by apps, such as compos, that make decisions based on
this state. This will make it easier to tweak the definition of
debuggability and keep it consistent across dependents.

Bug: 219740340
Test: atest ComposHostTestCases
Test: atest MicrodroidTests
Change-Id: I770ae615a958dd6939925c400336a2550a3d950d
2022-02-16 09:53:14 +00:00
Jiyong Park 779daa9764 Run logd only when debug_level is set
When debug_level is set to none, logd is not started at all.

Bug: 200914564
Test: run a VM with and without --debug full
Change-Id: Idb1ea3753067242eb0dcd53d3ae783e9e947ca32
2021-10-27 01:34:39 +09:00
Jiyong Park 747d636b49 Use virtio-console for the serial devices
A VM is now provided with two
serial devices. One is the uart device which is used as the output
device for the cases where virtio-console device driver is not
available. In the case of Microdroid, it's used by bootloader (u-boot)
and by the kernel as earlycon. The other is the virtio-serial device. It
is used as the console for the kernel.

This CL has two X86 specific hacks though.

1. The PCI addresses of the boot devices were adjusted. This is because
we have added one more PCI device (the virtio-serial device) and crosvm
for x86_64 puts serial devices prior to the block devices and they all
share the same bus ID. As a result, the block device addresses are all
shifted by 1.

2. The kernel command line embedded in boot.img now has `console=none`.
This is to prevent u-boot from automatically adding `console=ttyS0`. If
we let u-boot do that, then we will have console=ttyS0 together with
console=hvc0. Then each kernel message is printed twice; once to ttyS0
and once again to hvc0.

Bug: 200914564
Test: run a VM
Change-Id: I4349c4d70ac76c1b4ddc77bbff6c9b697b2f1f4e
2021-10-20 16:04:34 +09:00
Jiyong Park e7407e22fc Don't start adb if debugging is off
* Debug level None: adb is not supported
* Debug level app_only: adb is supported, but rooting is prohibited
* Debug level full: adb is supported and can be rooted

Bug: 201362865
Test: start a VM with `--debug none` and try to connect to the VM via
adb. It doesn't work as expected.

Change-Id: I95fe01e722d974ff1eb29469ac96abe7d785288d
2021-10-18 20:38:23 +09:00
Jiyong Park c2a49cc0db Define debug levels
Previously, a VM can be configured as running in debug mode or not.
However, the debug mode was not defined clearly and debugging features
like logging and adb-shell were actually left enabled even when the
debug mode is off.

This CL re-defines the debuggability of a VM. A VM has a debug level
which can be either of these three:

1. None: In this level, VM is not debuggable at all. No log is exported
from the VM, and debugger can't be attached to any process in the VM.
adb-shell of course is not supported.

2. App-only: In this level, only the app payload is debuggable. Logs
from the app process is exported to the host and the process can be
attached to debugger. adb-shell is not supported.

3. Full: In this level, the VM is fully debuggable. All logs including
kernel logs are exported to the VM and developers can adb-shell into the
VM.

Note that this CL doesn't fully implement all the levels yet, but
implements the framework around supporting multiple debug levels.
Specifically, each debug level is associated with a bootconfig image.
Each image has config values each of which enables or disables a
debugging feature. For example, bootconfig images for the none and
app-only levels have "kernel.console = none" to not show kernel console
output.

The `vm` tool and the Java APIs are also amended accordingly. The debug
level can be set via `--debug <level>` flag and the `DebugLevel(...)`
method.

Future work:
* Implement each debug level
* Each level uses different vm-instance image. Debug level is stored in
the instance image and is compared against the given level when
microdroid boots.
* Sign bootconfig images with avb and let uboot verify them
(b/203031847)

Bug: 201362865
Test: atest MicrodroidHostTestCases
Test: adb shell /apex/com.android.virt/bin/vm run-app
/data/local/tmp/virt/MicrodroidDemoApp.apk
/data/local/tmp/virt/MicrodroidDemoApp.apk.idsig
/data/local/tmp/virt/instance.img assets/vm_config.json

shows ...

Created VM from
"/data/local/tmp/virt/MicrodroidDemoApp.apk"!"assets/vm_config.json"
with CID 13, state is NOT_STARTED.
Started VM, state now STARTING.
Hello Microdroid /mnt/apk/lib/arm64-v8a/MicrodroidTestNativeLib.so hello
microdroid

, which is without logs from the bootloader and the kernel

Change-Id: I897dcd88723f014524d2cd2b6ffaa6f9fb5696d6
2021-10-15 08:58:15 +09:00