aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/net/bpf_jit_comp.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index 2dde48bdcc42..7c06f18150ab 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -234,12 +234,18 @@ do { BUILD_BUG_ON(FIELD_SIZEOF(STRUCT, FIELD) != sizeof(u8)); \
234 __emit_load8(BASE, STRUCT, FIELD, DEST); \ 234 __emit_load8(BASE, STRUCT, FIELD, DEST); \
235} while (0) 235} while (0)
236 236
237#define emit_ldmem(OFF, DEST) \ 237#ifdef CONFIG_SPARC64
238do { *prog++ = LD32I | RS1(FP) | S13(-(OFF)) | RD(DEST); \ 238#define BIAS (STACK_BIAS - 4)
239#else
240#define BIAS (-4)
241#endif
242
243#define emit_ldmem(OFF, DEST) \
244do { *prog++ = LD32I | RS1(SP) | S13(BIAS - (OFF)) | RD(DEST); \
239} while (0) 245} while (0)
240 246
241#define emit_stmem(OFF, SRC) \ 247#define emit_stmem(OFF, SRC) \
242do { *prog++ = LD32I | RS1(FP) | S13(-(OFF)) | RD(SRC); \ 248do { *prog++ = ST32I | RS1(SP) | S13(BIAS - (OFF)) | RD(SRC); \
243} while (0) 249} while (0)
244 250
245#ifdef CONFIG_SMP 251#ifdef CONFIG_SMP
@@ -610,10 +616,11 @@ void bpf_jit_compile(struct bpf_prog *fp)
610 case BPF_ANC | SKF_AD_VLAN_TAG: 616 case BPF_ANC | SKF_AD_VLAN_TAG:
611 case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT: 617 case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
612 emit_skb_load16(vlan_tci, r_A); 618 emit_skb_load16(vlan_tci, r_A);
613 if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) { 619 if (code != (BPF_ANC | SKF_AD_VLAN_TAG)) {
614 emit_andi(r_A, VLAN_VID_MASK, r_A); 620 emit_alu_K(SRL, 12);
621 emit_andi(r_A, 1, r_A);
615 } else { 622 } else {
616 emit_loadimm(VLAN_TAG_PRESENT, r_TMP); 623 emit_loadimm(~VLAN_TAG_PRESENT, r_TMP);
617 emit_and(r_A, r_TMP, r_A); 624 emit_and(r_A, r_TMP, r_A);
618 } 625 }
619 break; 626 break;
@@ -625,15 +632,19 @@ void bpf_jit_compile(struct bpf_prog *fp)
625 emit_loadimm(K, r_X); 632 emit_loadimm(K, r_X);
626 break; 633 break;
627 case BPF_LD | BPF_MEM: 634 case BPF_LD | BPF_MEM:
635 seen |= SEEN_MEM;
628 emit_ldmem(K * 4, r_A); 636 emit_ldmem(K * 4, r_A);
629 break; 637 break;
630 case BPF_LDX | BPF_MEM: 638 case BPF_LDX | BPF_MEM:
639 seen |= SEEN_MEM | SEEN_XREG;
631 emit_ldmem(K * 4, r_X); 640 emit_ldmem(K * 4, r_X);
632 break; 641 break;
633 case BPF_ST: 642 case BPF_ST:
643 seen |= SEEN_MEM;
634 emit_stmem(K * 4, r_A); 644 emit_stmem(K * 4, r_A);
635 break; 645 break;
636 case BPF_STX: 646 case BPF_STX:
647 seen |= SEEN_MEM | SEEN_XREG;
637 emit_stmem(K * 4, r_X); 648 emit_stmem(K * 4, r_X);
638 break; 649 break;
639 650