[PATCH v2][BPF] cpu: fix offset16 type, update c-calls in bpf.cpu

David Faust david.faust@oracle.com
Thu Jun 25 17:06:47 GMT 2020


Correct the type of the offset16 field to HI, and simplify memory
accesses which use it. Also update c-calls in semantics for a
few instructions.

cpu/
2020-06-25 David Faust  <david.faust@oracle.com>

	* bpf.cpu (f-offset16): Change type from INT to HI.
	(dxli): Simplify memory access.
	(dxsi): Likewise.
	(define-endian-insn): Update c-call in semantics.
	(dlabs) Likewise.
	(dlind) Likewise.

--- a/cpu/bpf.cpu
+++ b/cpu/bpf.cpu
@@ -273,7 +273,7 @@
 ;; difficulty: we put them in their own instruction word so the
 ;; byte-endianness will be properly applied.
 
-(dwf f-offset16 "eBPF offset field" (all-isas) 16 16 15 16 INT)
+(dwf f-offset16 "eBPF offset field" (all-isas) 16 16 15 16 HI)
 (dwf f-imm32 "eBPF 32-bit immediate field" (all-isas) 32 32 31 32 INT)
 
 ;; For the disjoint 64-bit signed immediate, however, we need to use a
@@ -488,7 +488,7 @@
        (+  (f-offset16 0) ((.sym f-src x-endian) 0) (.sym dst x-endian) endsize
            OP_CLASS_ALU x-op-src OP_CODE_END)
        (set (.sym dst x-endian)
-            (c-call DI "bpfbf_end" (.sym dst x-endian) endsize))
+            (c-call DI (.str "bpfbf_end" x-suffix) (.sym dst x-endian) endsize))
        ()))
 
 (define-endian-insn "le" OP_SRC_K le)
@@ -538,4 +538,4 @@
                       (mem DI
                            (add DI
                                 (reg DI h-gpr 6) ;; Pointer to struct sk_buff
-                                (const DI 0)))   ;; XXX offsetof
+                                (c-call "bpfbf_skb_data_offset")))
@@ -572,4 +572,4 @@
                       (mem DI
                            (add DI
                                 (reg DI h-gpr 6) ;; Pointer to struct sk_buff
-                                (const DI 0)))   ;; XXX offsetof
+                                (c-call "bpfbf_skb_data_offset")))
@@ -612,7 +612,7 @@
           OP_CLASS_LDX (.sym OP_SIZE_ x-size) OP_MODE_MEM)
        (set x-mode
             (.sym dst x-endian)
-            (mem x-mode (add DI (.sym src x-endian) (ext DI (trunc HI offset16)))))
+            (mem x-mode (add DI (.sym src x-endian) offset16)))
        ()))
 
 (define-pmacro (dxsi x-basename x-suffix x-size x-endian x-mode)
@@ -623,7 +623,7 @@
        (+ (f-imm32 0) offset16 (.sym src x-endian) (.sym dst x-endian)
           OP_CLASS_STX (.sym OP_SIZE_ x-size) OP_MODE_MEM)
        (set x-mode
-            (mem x-mode (add DI (.sym dst x-endian) (ext DI (trunc HI offset16))))
+            (mem x-mode (add DI (.sym dst x-endian) offset16))
             (.sym src x-endian)) ;; XXX address is section-relative
        ()))
 
-- 
2.26.2



More information about the Binutils mailing list