GithubHelp home page GithubHelp logo

android-riscv64's Introduction

Android/riscv64

What is this?

This github project is solely for issue tracking/discussion/documentation purposes.

All Android/riscv64 work is being done directly in AOSP. Patches should be sent to AOSP using the usual AOSP contribution process and not as pull requests here.

You might also want to subscribe to the sig-android mailing list. (You need to send mail to [email protected] and then click "Join" on the mailing list web site.)

Status

We're currently (2023Q1) still working on cuttlefish virtual devices and ART, so for now all you'll have is a shell and command-line tools, and all the libraries they rely on. Until we have cuttlefish working you'll have to manually run them in qemu or on your own hardware.

You can see the current status of the riscv64 build in the aosp_riscv64 column of ci.android.com.

Can I try it?

Download the source using the usual AOSP download process and then:

$ cd aosp
$ source build/envsetup.sh
$ lunch aosp_cf_riscv64_phone-userdebug

============================================
PLATFORM_VERSION_CODENAME=UpsideDownCake
PLATFORM_VERSION=UpsideDownCake
TARGET_PRODUCT=aosp_cf_riscv64_phone
TARGET_BUILD_VARIANT=userdebug
TARGET_ARCH=riscv64
TARGET_ARCH_VARIANT=riscv64
TARGET_CPU_VARIANT=generic
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.19.11-1rodete1-amd64-x86_64-Debian-GNU/Linux-rodete
HOST_CROSS_OS=windows
BUILD_ID=AOSP.MASTER
OUT_DIR=out
============================================
$ make -j

If you want to check whether a particular directory builds, cd into that directory and use mm -j.

Cuttlefish (emulator) setup

To launch cuttlefish, follow the general AOSP cuttlefish setup instructions.

(Note that in addition to the general setup mentioned above, if your host Linux distro doesn't already have it, you will have to apt install qemu-system-riscv64. If your host Linux distro's qemu version is too old -- we recommend 7.2.0 -- you may need to build your own. In that case, you'll need the -qemu_binary_dir= option when calling launch_cvd to point it at the correct copy of qemu.)

Getting to a shell (faster, but no graphics)

After building, run this following command from the same shell:

$ launch_cvd -cpus=4 --memory_mb=8192

After about 10s you should be able to use adb shell to connect to your riscv64 cuttlefish!

Getting to the home screen (slower, but with graphics)

After building, run this following command from the same shell:

$ launch_cvd -cpus=8 --memory_mb=8192 --gpu_mode=drm_virgl

You can then use vncviewer localhost:6444 to connect to your riscv64 cuttlefish!

(Note that even on a fast Xeon workstation it takes several minutes to get to the boot animation and tens of minutes to get to the home screen!)

How do I contribute?

Consult the regular AOSP Contributing documentation for more information on how to send us your patches.

Note that changes to projects under external/ (other than to Android.bp files) typically need to go to the upstream open source project in question first, and will then be merged into AOSP from there. In many cases, the METADATA file will point you to the upstream source, but feel free to ask here if not!

Review our Community Guidelines

This project follows Google's Open Source Community Guidelines.

android-riscv64's People

Contributors

enh-google avatar unicornx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

unicornx

android-riscv64's Issues

ship libFuzzer.a

both arm64 and x86_64 ship this in prebuilts/clang/host/linux-x86/clang-r475365/runtimes_ndk_cxx/

clang: check that the global clang driver's riscv64 default flags make sense for Android

we've typically had bits of Android-specific configuration for the llvm targets, and we'll obviously want that to specify our base ABI, but we should run clang -v or whatever and manually check that all the defaults make sense.

  • check defaults for C programs at -O0
  • check defaults for C++ programs at -O0
  • check defaults for C programs at -O2
  • check defaults for C++ programs at -O2
  • Create separate tasks for changes to defaults as needed.

bazel: microdroid will need bazel support for riscv64

really just filing this for completeness. having talked to the bazel folks, this is not expected to be much work, but it does need to be done at some point (probably for microdroid first?).

since riscv64 is already in CI, no actual action should be needed from us?

external/flac/: need V optimization

external/flac/ has optimized code (using intrinsics rather than in .S files) for all the other architectures. we'll likely want something for risc-v's V extension.

simpleperf

(googlers: see internal bug http://b/267670561)

Currently simpleperf uses external/llvm, which is too old to build on riscv.
So currently simpleperf is disabled on riscv, in system/extras/simpleperf/Android.bp L69.
To fix it, we need to export llvm libraries needed by simpleperf (listed in Android.bp L34) in clang prebuilts.
And switch simpleperf to the prebuilt libraries.

external/lzma: optimization (probably not?)

there's arch-specific "custom filter chain" stuff in lzma, but it doesn't look like it was extended to arm64 (and does support sparc!), so it's presumably of historical interest only?

system/core/init/: more ASLR bits when we have Kconfig support for more

init can ask for more aslr bits when we have newer kernels: https://android-review.git.corp.google.com/c/platform/system/core/+/2251618/1..2/init/security.cpp#b120

TODO: find out what kernel version improves this; ToT still only has 24 in arch/riscv/Kconfig --- https://github.com/torvalds/linux/blob/master/arch/riscv/Kconfig#L150 ... it looks like maybe VA_BITS has been increased already (https://github.com/torvalds/linux/blob/master/arch/riscv/include/asm/pgtable.h#L60) but no-one came back to fix the Kconfig, so there are still upstream fixes needed before we can use this in init?

llvm: fix emutls for risc-v (probably not?)

Android's build system's global default is emutls because all the other architectures shipped before we had elf tls. there's no reason for risc-v to use emutls (but see #3 for exactly what we'll use instead), but it's a bit odd that emutls is completely broken, and might cause porting issues for others (apps/middleware) who're also explicitly specifying emutls in their build systems?

external/libhevc/: optimization

(this is an ittiam library, so this work will presumably be done by them.)

there's some optimized assembler that needs writing using V.

llvm: should sqrt/sqrtf and the lrint/lrintf/llrint/llrintf family be builtins?

both riscv64 (https://cs.android.com/android/platform/superproject/+/master:bionic/libm/riscv64/) and arm64 (https://cs.android.com/android/platform/superproject/+/master:bionic/libm/arm64/) just have two .S files in libm, and they're all single-instruction functions for both architectures. this seems like something that llvm should just know about, so it can turn calls to sqrt etc into single instructions?

godbolt on a trivial function calling sqrt() shows that this isn't happening currently for arm64 or riscv64 (tested at -O2).

Investigate the current state of Auto-vectorization for RISC-V targets

  • Compiling TSVC benchmark would be a good way to find out if commonly found loop structures are getting vectorized.
  • Instruction scheduling of vectorized loops. If there is no instruction scheduling for RISC-V vectors, then we might have to create a separate task for this.
  • Eliminate redundant vsetvl instructions. If we are not doing it already, a simple reaching definition analysis should accomplish this.

bionic/: should we have vdso support for cache flushing and <sys/cacheflush.h>?

glibc has a <sys/cacheflush.h> for risc-v, and linux has a vdso entry that might motivate it ... but if you look at that (https://github.com/torvalds/linux/blob/master/arch/riscv/kernel/vdso/flush_icache.S) it's just calling the system call anyway (since Android is always SMP), so i think the traditional "just use __builtin___clear_cache()" advice (https://man7.org/linux/man-pages/man2/cacheflush.2.html) makes sense here too, and we should not do this?

security: enable software CFI

until we have #15 (which hopefully we'll get in the Android/riscv64 ABI), we should at least enable software-only CFI.

(we had to disable this in the build system's global settings, suggesting at least some llvm work is needed here.)

llvm: function alignment

do we care? is the llvm default good enough? best to leave it to llvm to decide on a per-SoC basis rather than having anything in the build system?

bionic/tests/sys_ptrace_test.cpp: add an instruction that writes more than 64 bits

we need to grab a V instruction to finish the missing piece of this test:

static void watchpoint_imprecise_child(Uint128_t& data) {
  raise(SIGSTOP);  // Synchronize with the tracer, let it set the watchpoint.

#if defined(__i386__) || defined(__x86_64__)
  asm volatile("movdqa %%xmm0, %0" : : "m"(data));
#elif defined(__arm__)
  asm volatile("stm %0, { r0, r1, r2, r3 }" : : "r"(&data));
#elif defined(__aarch64__)
  asm volatile("stp x0, x1, %0" : : "m"(data));
#elif defined(__riscv)
  UNUSED(data);
  GTEST_LOG_(INFO) << "missing riscv64 instruction to store > 64 bits in one instruction";
#endif
}

external/freetype: optimization (?)

src/smooth/ftgrays.c has one bit of arm64-specific configuration. check whether we need similar for rv64. (there's a lot more stuff for intel, but if arm64 hasn't needed it, does it matter?)

external/libmpeg2: optimization

(this is an ittiam library, so this work will presumably be done by them.)

there's some optimized assembler that needs writing using V.

external/libavc/: optimization

(this is an ittiam library, so this work will presumably be done by them.)

looks like this library needs saturating arithmetic, for which there's no extension yet.

but right now, we need some optimized assembler written using V.

renderscript: go from deprecation to removal

(http://b/206676167 is the internal bug for the overall "remove renderscript", http://b/255624710 the more specific "remove *.rscript files from the tree".)

renderscript's been deprecated for a while, but there was no real motivation (and some downside) to actually remove it until now. with risc-v, we either have to (a) backport risc-v support to a decade-old fork of llvm, (b) forward port renderscript to current llvm, or (c) finally remove renderscript. despite the unfortunate disruption to legacy code, option (c) is the least difficult of these choices.

i've removed all the renderscript from frameworks/av/ already (after proving it was unused), and obviously all the renderscript tools and the CTS tests of renderscript itself are easy to delete, but we'll need to manage the Studio side of things (they ship some of the tools).

the main issues are these camera tests, all of which will need to be rewritten:

https://cs.android.com/search?q=f:%5C.rscript$%20-f:cts%2Ftests%2Ftests%2Frenderscript%20-f:cts%2Ftests%2Ftests%2Frscpp%20-f:rsblas%20-f:frameworks%2Fcompile%20-f:frameworks%2Frs%20-f:development%2Fsamples&sq=package:%5Eandroid-internal$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.