From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38BBAC04A95 for ; Wed, 28 Sep 2022 09:43:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBC8A8E0137; Wed, 28 Sep 2022 05:43:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B6C148E0120; Wed, 28 Sep 2022 05:43:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0C2C8E0137; Wed, 28 Sep 2022 05:43:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8E2918E0120 for ; Wed, 28 Sep 2022 05:43:04 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 50CE9AB866 for ; Wed, 28 Sep 2022 09:43:04 +0000 (UTC) X-FDA: 79961005488.19.A901EE5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id E3CA81C001C for ; Wed, 28 Sep 2022 09:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664358182; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e896d3p2GV00M1qPWHa/GVdZCvllUrpZmXvQcwWgt3E=; b=BWXb6jvC140MJUi7ScXhSsI6fmDmnxYPnTgrmAYOtddlClHkfo0Do11pLKEiWdUseOCc2f 0IUd86jK4fr6uTx4s6V78EMfWbUl5fZj9mg9QYrnYtKcrj9LSs5LVhPrZsXIjSULHYQayp ecksllKs3kTGqJqJmrcPRNSs81cM2rQ= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-131-jPUGdFcAPBKEuSM4WHH-Mg-1; Wed, 28 Sep 2022 05:43:01 -0400 X-MC-Unique: jPUGdFcAPBKEuSM4WHH-Mg-1 Received: by mail-ed1-f69.google.com with SMTP id i17-20020a05640242d100b0044f18a5379aso10031011edc.21 for ; Wed, 28 Sep 2022 02:43:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date; bh=e896d3p2GV00M1qPWHa/GVdZCvllUrpZmXvQcwWgt3E=; b=AW993oskZfmI/rxD1vpiCyDsV66gYsOb+6BavKkYZOuIGV9qMgJubBe4jN8ctVG4HM TBBTNqRdGafoKwM+jGoTkpFddAjUFNDEXeN1K7JJZqVh0ZkKb1JVF/caZKH+gJbH2Leb F24Z6JIWCjWU8GHifHojQKhd/53s970uTq/YKrZRkgNkAI08XO0BD1WcQq7DZ+by29tQ 6cgPgKgR3UitWtXHSI11I7VAhGh6hH8FZHoPabSAI/lVhuBGe37PZzfNS0kfjXYGC3E/ MLLebrr0jsT7PiY6z3UvcGAJJg7D6tqqhyFHUMw/ojORXM6QKDS5+6jaFIAWM5Y5YLiM F0tA== X-Gm-Message-State: ACrzQf3C9bhwmyBYbSD2T1c5krpgzc5+YqCQO6bSiy5uCPiJeeUvEqny FaqiErBzlFyI8C+rnLKJmaxn+lU6kswaPss4nctSanSMeOhtbKGMYVKD1YNU4asXigcxXXfgN+V CnwP1GC8PwZw= X-Received: by 2002:a17:906:478d:b0:783:2270:e85a with SMTP id cw13-20020a170906478d00b007832270e85amr16115182ejc.371.1664358179947; Wed, 28 Sep 2022 02:42:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7S8dt3b5d5cEWrRWEWAa1fgGCgEtYriooBRab/9F0zzWFUSuf4CLxvKzom7H85rA1s+owv5A== X-Received: by 2002:a17:906:478d:b0:783:2270:e85a with SMTP id cw13-20020a170906478d00b007832270e85amr16115152ejc.371.1664358179650; Wed, 28 Sep 2022 02:42:59 -0700 (PDT) Received: from [192.168.41.81] (83-90-141-187-cable.dk.customer.tdc.net. [83.90.141.187]) by smtp.gmail.com with ESMTPSA id 26-20020a170906309a00b00781b589a1afsm2095858ejv.159.2022.09.28.02.42.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Sep 2022 02:42:59 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <91bbd6dd-04d4-51a0-8a7d-cf124cefca29@redhat.com> Date: Wed, 28 Sep 2022 11:42:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Cc: brouer@redhat.com, ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, kpsingh@chromium.org, kernel-team@fb.com, haoluo@google.com, jlayton@kernel.org, bjorn@kernel.org, Toke Hoiland Jorgensen , Clark Williams , Steven Rostedt , Thomas Gleixner , Linux-MM Subject: Re: [PATCH v2 bpf-next 0/2] enforce W^X for trampoline and dispatcher To: Song Liu , bpf@vger.kernel.org References: <20220926184739.3512547-1-song@kernel.org> In-Reply-To: <20220926184739.3512547-1-song@kernel.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664358183; a=rsa-sha256; cv=none; b=DiD3Mg2QYX30OOjIvLcyMkCypBQ+KvxxvSj21kzH5Af1A/MJqe+gB4MilLMvDq37iD9vw/ XkkcIMPsec6w/7bD/cAgcMyhvVC97YPRaYa953ufclxobKzlCMGKyF6CgUj2B06Qu/sJBt xX8lV8hsjYGZlTPPNmRQC+SNcATBeTM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BWXb6jvC; spf=pass (imf20.hostedemail.com: domain of jbrouer@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=jbrouer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664358183; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=e896d3p2GV00M1qPWHa/GVdZCvllUrpZmXvQcwWgt3E=; b=ndSx8k8grV6iCJlgwAi0eR2ii+E2llJ1Ly5nOz8mEXBmUWjDdTBlmdOtv0IzeFsI42eFcK 5tuQ+9jMGR39mBItsRVp25OyvvFm3hEtfDlXOJzLcvxVoE3NOM3CaAtRmJjh/igLfh8i1S f+2ciAYyPdXrRP0khI+tie6VtJYBNdM= X-Stat-Signature: gou1p1tbj9unhqqxm5dfu6se6my7gpmo X-Rspamd-Queue-Id: E3CA81C001C X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BWXb6jvC; spf=pass (imf20.hostedemail.com: domain of jbrouer@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=jbrouer@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam08 X-HE-Tag: 1664358182-941553 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 26/09/2022 20.47, Song Liu wrote: > Changes v1 => v2: > 1. Update arch_prepare_bpf_dispatcher to use a RO image and a RW buffer. > (Alexei) Note: I haven't found an existing test to cover this part, so > this part was tested manually (comparing the generated dispatcher is > the same). > > Jeff Layton reported CPA W^X warning linux-next [1]. It turns out to be > W^X issue with bpf trampoline and bpf dispatcher. Fix these by: > > 1. Use bpf_prog_pack for bpf_dispatcher; > 2. Set memory permission properly with bpf trampoline. Indirectly related to your patchset[0]. - TL;DR calling set_memory_x() have side-effects We are getting reports that loading BPF-progs (jit stage) cause issues for RT in the form of triggering work on isolated CPUs. It looks like BTF JIT stage cause a TLB flush on all CPUs, including isolated CPUs. The triggering function is set_memory_x() (see call-stack[2]). We have noticed (and appreciate) you have previously improved the situation in this patchset[3]: [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80123f0ac4a6 Is this patchset also part of improving the situation, or does it introduce more calls to set_memory_x() ? > [1] https://lore.kernel.org/lkml/c84cc27c1a5031a003039748c3c099732a718aec.camel@kernel.org/ [2] Call stack triggering issue: smp_call_function_many_cond+0x1 smp_call_function+0x39 on_each_cpu+0x2a cpa_flush+0x11a change_page_attr_set_clr+0x129 set_memory_x+0x37 bpf_int_jit_compile+0x36f bpf_prog_select_runtime+0xc6 bpf_prepare_filter+0x523 sk_attach_filter+0x13 sock_setsockopt+0x920 __sys_setsockopt+0x16a __x64_sys_setsockopt+0x20 do_syscall_64+0x87 entry_SYSCALL_64_after_hwframe+0x65 [0] https://lore.kernel.org/all/20220926184739.3512547-1-song@kernel.org/#r --Jesper