[SRU,Bionic,1/1] test_bpf: flag tests that cannot be jited on s390

Message ID 20180710111345.28481-2-kleber.souza@canonical.com
State New
Headers show
Series
  • Fix for LP: #1753941
Related show

Commit Message

Kleber Sacilotto de Souza July 10, 2018, 11:13 a.m.
BugLink: https://bugs.launchpad.net/bugs/1753941

Flag with FLAG_EXPECTED_FAIL the BPF_MAXINSNS tests that cannot be jited
on s390 because they exceed BPF_SIZE_MAX and fail when
CONFIG_BPF_JIT_ALWAYS_ON is set. Also set .expected_errcode to -ENOTSUPP
so the tests pass in that case.

Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
(backported from commit 3203c9010060806ff88c9989aeab4dc8d9a474dc)
[ klebers: compile out for s390 also the testcases:
  - BPF_MAXINSNS: ld_abs+vlan_push/pop
  - BPF_MAXINSNS: jump around ld_abs ]
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
---
 lib/test_bpf.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

Stefan Bader July 26, 2018, 1:20 p.m. | #1
On 10.07.2018 13:13, Kleber Sacilotto de Souza wrote:
> BugLink: https://bugs.launchpad.net/bugs/1753941
> 
> Flag with FLAG_EXPECTED_FAIL the BPF_MAXINSNS tests that cannot be jited
> on s390 because they exceed BPF_SIZE_MAX and fail when
> CONFIG_BPF_JIT_ALWAYS_ON is set. Also set .expected_errcode to -ENOTSUPP
> so the tests pass in that case.
> 
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
> Acked-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> (backported from commit 3203c9010060806ff88c9989aeab4dc8d9a474dc)
> [ klebers: compile out for s390 also the testcases:
>   - BPF_MAXINSNS: ld_abs+vlan_push/pop
>   - BPF_MAXINSNS: jump around ld_abs ]
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  lib/test_bpf.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index 59359aad645d..1fe4d4b33217 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -5419,21 +5419,31 @@ static struct bpf_test tests[] = {
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Ctx heavy transformations",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC,
> +#endif
>  		{ },
>  		{
>  			{  1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) },
>  			{ 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }
>  		},
>  		.fill_helper = bpf_fill_maxinsns6,
> +		.expected_errcode = -ENOTSUPP,
>  	},
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Call heavy transformations",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC | FLAG_NO_DATA,
> +#endif
>  		{ },
>  		{ { 1, 0 }, { 10, 0 } },
>  		.fill_helper = bpf_fill_maxinsns7,
> +		.expected_errcode = -ENOTSUPP,
>  	},
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Jump heavy test",
> @@ -5475,11 +5485,17 @@ static struct bpf_test tests[] = {
>  	{
>  		"BPF_MAXINSNS: ld_abs+get_processor_id",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC,
> +#endif
>  		{ },
>  		{ { 1, 0xbee } },
>  		.fill_helper = bpf_fill_ld_abs_get_processor_id,
> +		.expected_errcode = -ENOTSUPP,
>  	},
> +#if !(defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390))
>  	{
>  		"BPF_MAXINSNS: ld_abs+vlan_push/pop",
>  		{ },
> @@ -5496,6 +5512,7 @@ static struct bpf_test tests[] = {
>  		{ { 2, 10 } },
>  		.fill_helper = bpf_fill_jump_around_ld_abs,
>  	},
> +#endif
>  	/*
>  	 * LD_IND / LD_ABS on fragmented SKBs
>  	 */
>
Thadeu Lima de Souza Cascardo July 31, 2018, 2:35 p.m. | #2
On Tue, Jul 10, 2018 at 01:13:45PM +0200, Kleber Sacilotto de Souza wrote:
> BugLink: https://bugs.launchpad.net/bugs/1753941
> 
> Flag with FLAG_EXPECTED_FAIL the BPF_MAXINSNS tests that cannot be jited
> on s390 because they exceed BPF_SIZE_MAX and fail when
> CONFIG_BPF_JIT_ALWAYS_ON is set. Also set .expected_errcode to -ENOTSUPP
> so the tests pass in that case.
> 
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
> Acked-by: Song Liu <songliubraving@fb.com>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> (backported from commit 3203c9010060806ff88c9989aeab4dc8d9a474dc)
> [ klebers: compile out for s390 also the testcases:
>   - BPF_MAXINSNS: ld_abs+vlan_push/pop
>   - BPF_MAXINSNS: jump around ld_abs ]
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>

Applies only to the tests, so shouldn't break the kernel. And should fix our
test results, and applied upstream. Looking at the upstream commits, it's
possible to understand the changes.

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

> ---
>  lib/test_bpf.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/lib/test_bpf.c b/lib/test_bpf.c
> index 59359aad645d..1fe4d4b33217 100644
> --- a/lib/test_bpf.c
> +++ b/lib/test_bpf.c
> @@ -5419,21 +5419,31 @@ static struct bpf_test tests[] = {
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Ctx heavy transformations",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC,
> +#endif
>  		{ },
>  		{
>  			{  1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) },
>  			{ 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }
>  		},
>  		.fill_helper = bpf_fill_maxinsns6,
> +		.expected_errcode = -ENOTSUPP,
>  	},
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Call heavy transformations",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC | FLAG_NO_DATA,
> +#endif
>  		{ },
>  		{ { 1, 0 }, { 10, 0 } },
>  		.fill_helper = bpf_fill_maxinsns7,
> +		.expected_errcode = -ENOTSUPP,
>  	},
>  	{	/* Mainly checking JIT here. */
>  		"BPF_MAXINSNS: Jump heavy test",
> @@ -5475,11 +5485,17 @@ static struct bpf_test tests[] = {
>  	{
>  		"BPF_MAXINSNS: ld_abs+get_processor_id",
>  		{ },
> +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
> +		CLASSIC | FLAG_EXPECTED_FAIL,
> +#else
>  		CLASSIC,
> +#endif
>  		{ },
>  		{ { 1, 0xbee } },
>  		.fill_helper = bpf_fill_ld_abs_get_processor_id,
> +		.expected_errcode = -ENOTSUPP,
>  	},
> +#if !(defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390))
>  	{
>  		"BPF_MAXINSNS: ld_abs+vlan_push/pop",
>  		{ },
> @@ -5496,6 +5512,7 @@ static struct bpf_test tests[] = {
>  		{ { 2, 10 } },
>  		.fill_helper = bpf_fill_jump_around_ld_abs,
>  	},
> +#endif
>  	/*
>  	 * LD_IND / LD_ABS on fragmented SKBs
>  	 */
> -- 
> 2.17.1

Patch

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 59359aad645d..1fe4d4b33217 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -5419,21 +5419,31 @@  static struct bpf_test tests[] = {
 	{	/* Mainly checking JIT here. */
 		"BPF_MAXINSNS: Ctx heavy transformations",
 		{ },
+#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
+		CLASSIC | FLAG_EXPECTED_FAIL,
+#else
 		CLASSIC,
+#endif
 		{ },
 		{
 			{  1, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) },
 			{ 10, !!(SKB_VLAN_TCI & VLAN_TAG_PRESENT) }
 		},
 		.fill_helper = bpf_fill_maxinsns6,
+		.expected_errcode = -ENOTSUPP,
 	},
 	{	/* Mainly checking JIT here. */
 		"BPF_MAXINSNS: Call heavy transformations",
 		{ },
+#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
+		CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
+#else
 		CLASSIC | FLAG_NO_DATA,
+#endif
 		{ },
 		{ { 1, 0 }, { 10, 0 } },
 		.fill_helper = bpf_fill_maxinsns7,
+		.expected_errcode = -ENOTSUPP,
 	},
 	{	/* Mainly checking JIT here. */
 		"BPF_MAXINSNS: Jump heavy test",
@@ -5475,11 +5485,17 @@  static struct bpf_test tests[] = {
 	{
 		"BPF_MAXINSNS: ld_abs+get_processor_id",
 		{ },
+#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390)
+		CLASSIC | FLAG_EXPECTED_FAIL,
+#else
 		CLASSIC,
+#endif
 		{ },
 		{ { 1, 0xbee } },
 		.fill_helper = bpf_fill_ld_abs_get_processor_id,
+		.expected_errcode = -ENOTSUPP,
 	},
+#if !(defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_S390))
 	{
 		"BPF_MAXINSNS: ld_abs+vlan_push/pop",
 		{ },
@@ -5496,6 +5512,7 @@  static struct bpf_test tests[] = {
 		{ { 2, 10 } },
 		.fill_helper = bpf_fill_jump_around_ld_abs,
 	},
+#endif
 	/*
 	 * LD_IND / LD_ABS on fragmented SKBs
 	 */