Age | Commit message (Collapse) | Author |
|
Change-Id: I41f644223454c399aa11065fb959f58440db94f2
|
|
After releasing APFv3, we realized that addressing memory from the top
could be simplified by adjusting a few details:
1) The APF interpreter now receives a single unified buffer containing
both the program bytecode and the data segment, unambiguously matching
the memory layout seen by installApfPacketFilter() and
readApfPacketFilter().
2) Data address zero coincides with the beginning of the APF program,
thus decoupling data addresses from the length of the program (which
could change between invokations of installApfPacketFilter()). This
simplifies the ApfGenerator by not requiring a data relocation step
similar to jump relocation.
3) For convenience, the interpreter pre-fills one volatile memory slot
with the total size of the APF buffer. The APF program can load this
value into a register to efficiently write near the end of the data
segment, thus allowing the program-data boundary to shift freely.
4) Negative addresses wrap around the end of the data buffer, such that
address -1 coincides with the last byte of the buffer.
5) The immediate offet of LDDW and SDDW are now sign-extended, such that
small negative offsets can be encoded as a 1-byte immediate. This,
combined with the modular addressing at (4), can be used to address
memory cells near the end of the data region with 2-byte opcodes.
Overall, the above changes allow building a simple 32bit counter with
a sequence more or less like this:
2 li R1, -4 ; R1 = -4 (last 32bit word of data)
1 lddw R0, [R1 + 0] ; R0 = old counter value
2 add R0, 42 ; Increment counter by some value
1 stdw R0, [R1 + 0] ; Write back the new value
Total: 6 bytes. Note how the above bytecode is independent of the actual
size of the program and data segments. To reduce bytecode size,
the counter increment sequence can be moved to an "IncrementAndDrop"
trampoline, taking only 2 bytes more than a direct jump to DROP:
2 li R1, -12 ; R0 = counter offset (third to last counter)
3 jmp CountAndDrop ; (could be 2 bytes if jumping nearby)
...
CountAndDrop:
1 lddw R0, [R1+0] ; R0 = old counter value
2 add R0, 1 ; Increment counter
1 stdw R0, [R1+0] ; Write back updated value
3 jmp DROP ; cya!
Adding a 1-byte INC instruction would make things a little nicer.
Change-Id: Ia9b25e49e127a48d7344ddc60b17c93d6421ab7d
Bug: 73804303
Test: runtest -x tests/net/java/android/net/apf/ApfTest.java
(cherry picked from commit 17c1fbc9e98e380e508fa83d0f927bc742a5161b)
|
|
Change-Id: If50a0682e77085adb03ddd990f75b682683927ad
|
|
Bug: 73804303
Test: runtest -x frameworks/base/tests/net/java/android/net/apf/ApfTest.java
Merged-In: I3543eedac5998d6a1b16010b5dc8865e9cc24b5b
Change-Id: I3543eedac5998d6a1b16010b5dc8865e9cc24b5b
(cherry picked from commit 7024456a1fb07f0a88ed8dbeeba41c21a4a40304)
|
|
Test: make apf_run works
Bug: 73804303
Merged-In: I6fd47d0a1fe4a73f2bad85a79566b40426f56eb2
Merged-In: I31a2a77c7025f6aa7abea40344622865567fa0a5
Change-Id: Icd4b5d051ba55439a5ce346c0bc61a95da6cc03f
(cherry picked from commit 7a1d9a6dbddaa46e8b74859952a58b55ddcd5801)
|
|
The new opcodes are LDDW (LoaD Data Word) and STDW (STore Data Word)
The only supported addressing mode is register-indirect with immediate
offset (register value + immediate value). Since there's a single
register bit encoded in the opcode, the other register is implicitly
used for the address operand. Hence, the following variations are
possible:
lddw R0, [1234]R1 ; R0 = *(R1 + 1234)
lddw R1, [1234]R0 ; R1 = *(R0 + 1234)
stdw R0, [1234]R1 ; *(R1 + 1234) = R0
stdw R1, [1234]R0 ; *(R0 + 1234) = R1
The immediate can also be specified to be length 0, making the memory
access equivalent to a plain register-indirect with no offset.
lddw R0, R1 ; R0 = *R1
lddw R1, R0 ; R1 = *R0
stdw R0, R1 ; *R1 = R0
stdw R1, R0 ; *R0 = R1
The encoding of the above instructions is a single byte, making a
typical counter increment more efficient, especially when the address
requires a multi-byte immediate:
ldh R1, 1234 ; address of our packet counter (3 bytes)
lddw R0, R1 ; load the counter from address 1234 (1 byte)
add R0, 1 ; increment the counter (2 bytes)
stdw R0, R1 ; write-back to data ram (1 byte)
Total: 7 bytes. Defining a separate INCW instruction would reduce the
above sequence down to 3 bytes (or 4 bytes if using an EXT opcode to
avoid wasting opcodes). This optimization can be added at a later point
if the data access patterns of production APF code justify it.
Bug: 73804303
Test: runtest -x tests/net/java/android/net/apf/ApfTest.java
Merged-In: I4bea29ea701cc11dc61cdcf60cc824bbe14b24f6
Merged-In: Ibbd427e12987a1eef63b41d816af05a1bd9f9170
Change-Id: Ibbd427e12987a1eef63b41d816af05a1bd9f9170
(cherry picked from commit 75410970184bf98626342588ba2eabf79cda6d38)
|
|
am: 904be69da9
am: 1bc3e766dd
Change-Id: I3a980446e96b2cc4cb2ac3b6a14de47c6184ea68
|
|
am: 904be69da9
Change-Id: Ib922e727598464781bb5854c0d9fd774532e3aa2
|
|
am: 063c56133a
Change-Id: Ie2e182db99e90e84aa36089871f97fcc7b5511ea
|
|
am: 89639347f9
Change-Id: I59617e8cf950aace37d97dad0ed94f4f67065b2d
|
|
Bug: 63408147
Test: builds
Change-Id: I96ac2a04e3a991af7429db1d32a00f69532e3765
|
|
am: 1f1b66837c
am: b75c9f3714
Change-Id: I64dbd692498a2e5e79ab5ebec46811a2b5fc8a0e
|
|
am: 1f1b66837c
Change-Id: Ic08fc90a57971d0278f79fc330647cce23bd09e2
|
|
am: dc89abf313
Change-Id: Id832ed1c7cc7a88fed0361359f9dda714bc95cdc
|
|
am: f7cea66b5e
Change-Id: Ic528a59aceb5c8a368c195d6de4fc9e3384292e4
|
|
Fixes warnings:
hardware/google/apf/apf_disassembler.c:136:48: warning: The right
operand of '|' is a garbage value
hardware/google/apf/apf_disassembler.c:96:32: warning: The right operand
of '|' is a garbage value
Test: Builds without above 2 warnings
Change-Id: I8a05e575c04dd74e29dfc845c6a7a58c10cbe380
|
|
f9491fa279 am: f80b9d17d3
am: 0b6f2a6cd6
Change-Id: I31fb92f18ed44e11019fc98d8af76fc46f9b55e1
|
|
f9491fa279
am: f80b9d17d3
Change-Id: I1493ee8fe134c25fb368757beed4b3752365835a
|
|
am: f9491fa279
Change-Id: I5aa3f0082621dc4da828d575c7df383e8dacc55b
|
|
f9491fa279
am: f5e8b86e2c
Change-Id: Iec1f4d59ba44e53ccba25995aa7404e12c5895e2
|
|
am: f9491fa279
Change-Id: Ia042800508bb055b14e2e385b406cfdc8138d251
|
|
This program is just for debugging purposes and isn't shipped.
Bug: 30138831
Change-Id: I8b943c1333db4addb729830f7e15e32653fe7ca4
|
|
1017073e88 am: ae7070075e
am: 696f753aec
* commit '696f753aec519420dd172e5cbe0aaa367efc7ca9':
Make the APF disassembler print pass and drop labels in jumps.
Change-Id: I898d8292780fe98a97114451e7053384a20be094
|
|
am: ae7070075e
* commit 'ae7070075ebcbc8e262bc8897616f4b671e38d46':
Make the APF disassembler print pass and drop labels in jumps.
Change-Id: Ia19583e3ff436b20f93b600f659448af9af81f1f
|
|
am: 1017073e88
* commit '1017073e88c658cb7b88c8272b396d7998d61b13':
Make the APF disassembler print pass and drop labels in jumps.
Change-Id: Ic60b78bea98891f4d36a95f43a467e5845125d6b
|
|
Also add a host executable target for it so it doesn't bitrot.
Bug: 26238573
Change-Id: I078d50a4c3896b381b2744ae5c75989b99b14d5d
|
|
am: 4adcbdf494
* commit '4adcbdf494d8d85a5a1a3cf4bafd26201503e692':
Add APF disassembler for testing purposes.
Change-Id: Ida886813a43eab4a84bb218557357205af504dd2
|
|
am: 63269f85d4
* commit '63269f85d445700a637be6297e7083259189a460':
Add APF disassembler for testing purposes.
Change-Id: I7bbed949782ebdc4e83c34b9b713bd9706a8620a
|
|
am: 497d4ee96c
* commit '497d4ee96c2459750e06c5c6a445dfaf0ced18fa':
Add APF disassembler for testing purposes.
Change-Id: I8d546b235b7d9b2140e8a01857099e9f021ac8e8
|
|
This change involves no functional change to the APF interpreter.
Bug: 26238573
Change-Id: I64bbccd4223c340e7dd6794ad48df12aae6ab78f
|
|
am: d0f1e60dcd
* commit 'd0f1e60dcd609299fc4defb847e0729a5554d488':
Make APF interpreter compile without C99 features.
|
|
This code is built by third-parties in build environments without
C99 features, so get it building cleanly in those environments.
Change-Id: Ic54807348282696d3dd588323fa06a7ead4aa74d
|
|
am: 51d3c5fa9c
* commit '51d3c5fa9c0ad7dd551c05b06a62ecec09c029d8':
Avoid compiler errors and enforce all warnings/errors.
|
|
Change-Id: I13305afc93942be7dbca0ae123aedf76c7a88135
|
|
am: e1caf6d87d
* commit 'e1caf6d87d16f7dfbc83a5501d4ecfb85faa83f3':
Android packet filter interpreter
Initial empty repository
|
|
Bug: 26238573
Change-Id: I67fca3eb41d4afcc3fe522c55239e1c02fde3e51
|
|
|
|
|