[PATCH v5 18/18] selftests/sgx: Add scripts for EPC cgroup testing

2023-09-22 Thread Haitao Huang
The scripts rely on cgroup-tools package from libcgroup [1]. To run selftests for epc cgroup: sudo ./run_epc_cg_selftests.sh With different cgroups, the script starts one or multiple concurrent SGX selftests, each to run one unclobbered_vdso_oversubscribed test. Each of such test tries to load

[PATCH v5 16/18] x86/sgx: Limit process EPC usage with misc cgroup controller

2023-09-22 Thread Haitao Huang
From: Kristen Carlson Accardi Implement support for cgroup control of SGX Enclave Page Cache (EPC) memory using the misc cgroup controller. EPC memory is independent from normal system memory, e.g. must be reserved at boot from RAM and cannot be converted between EPC and normal memory while the

[PATCH v5 17/18] Docs/x86/sgx: Add description for cgroup support

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Add initial documentation of how to regulate the distribution of SGX Enclave Page Cache (EPC) memory via the Miscellaneous cgroup controller. Signed-off-by: Sean Christopherson Co-developed-by: Kristen Carlson Accardi Signed-off-by: Kristen Carlson Accardi

[PATCH v5 15/18] x86/sgx: Prepare for multiple LRUs

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Add wrappers where a direct references to the global LRU list in the reclaimer functions. To support multiple LRU lists (one per EPC cgroup) later, only make changes inside these wrappers. Signed-off-by: Sean Christopherson Co-developed-by: Kristen Carlson Accardi

[PATCH v5 14/18] x86/sgx: Add helper to grab pages from an arbitrary EPC LRU

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Move the isolation loop into a helper, sgx_isolate_pages(), in preparation for existence of multiple LRUs. Expose the helper to other SGX code so that it can be called from the EPC cgroup code, e.g., to isolate pages from a single cgroup LRU. Exposing the isolation loop

[PATCH v5 13/18] x86/sgx: Expose sgx_reclaim_pages() for use by EPC cgroup

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Adjust and expose the top-level reclaim function as sgx_reclaim_epc_pages() for use by the upcoming EPC cgroup, which will initiate reclaim to enforce the max limit. Make these adjustments to the function signature. 1) To take a parameter that specifies the number of

[PATCH v5 10/18] x86/sgx: Add EPC page flags to identify owner types

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Two types of owners of struct sgx_epc_page, 'sgx_encl' for VA pages and 'sgx_encl_page' can be stored in the previously introduced union field. OOM support for cgroups requires that the owner needs to be identified when selecting pages from the unreclaimable list.

[PATCH v5 11/18] x86/sgx: store unreclaimable pages in LRU lists

2023-09-22 Thread Haitao Huang
From: Sean Christopherson When an OOM event occurs, all pages associated with an enclave will need to be freed, including pages that are not currently tracked by the cgroup LRU lists. Add a new "unreclaimable" list to the sgx_epc_lru_lists struct and update the "sgx_record/drop_epc_pages()"

[PATCH v5 12/18] x86/sgx: Add EPC OOM path to forcefully reclaim EPC

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Introduce the OOM path for killing an enclave with a reclaimer that is no longer able to reclaim enough EPC pages. Find a victim enclave, which will be an enclave with only "unreclaimable" EPC pages left in the cgroup LRU lists. Once a victim is identified, mark the

[PATCH v5 09/18] x86/sgx: Store struct sgx_encl when allocating new VA pages

2023-09-22 Thread Haitao Huang
From: Sean Christopherson In a later patch, when a cgroup has exceeded the max capacity for EPC pages, it may need to identify and OOM kill a less active enclave to make room for other enclaves within the same group. Such a victim enclave would have no active pages other than the unreclaimable

[PATCH v5 08/18] x86/sgx: Use a list to track to-be-reclaimed pages

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Change sgx_reclaim_pages() to use a list rather than an array for storing the epc_pages which will be reclaimed. This change is needed to transition to the LRU implementation for EPC cgroup support. When the EPC cgroup is implemented, the reclaiming process will do a

[PATCH v5 07/18] x86/sgx: Introduce RECLAIM_IN_PROGRESS state

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Add RECLAIM_IN_PROGRESS state to not rely on list_empty(_page->list) to determine if an EPC page is selected as a reclaiming candidate. When a page is being reclaimed from the page pool (sgx_global_lru), there is an intermediate stage where a page may have been

[PATCH v5 06/18] x86/sgx: Introduce EPC page states

2023-09-22 Thread Haitao Huang
Use the lower 3 bits in the flags field of sgx_epc_page struct to track EPC states in its life cycle and define an enum for possible states. More state(s) will be added later. Signed-off-by: Haitao Huang --- V4: - No changes other than required for patch reordering. V3: - This is new in V3 to

[PATCH v5 05/18] x86/sgx: Store reclaimable EPC pages in sgx_epc_lru_lists

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Replace sgx_mark_page_reclaimable() and sgx_unmark_page_reclaimable() with sgx_record_epc_page() and sgx_drop_epc_page(). The sgx_record_epc_page() function adds the epc_page to the "reclaimable" list in the sgx_epc_lru_lists struct, while sgx_drop_epc_page() removes

[PATCH v5 03/18] x86/sgx: Add sgx_epc_lru_lists to encapsulate LRU lists

2023-09-22 Thread Haitao Huang
From: Sean Christopherson Introduce a data structure to wrap the existing reclaimable list and its spinlock. Each cgroup later will have one instance of this structure to track EPC pages allocated for processes associated with the same cgroup. Just like the global SGX reclaimer (ksgxd), an EPC

[PATCH v5 04/18] x86/sgx: Use sgx_epc_lru_lists for existing active page list

2023-09-22 Thread Haitao Huang
From: Sean Christopherson All EPC pages of enclaves including Version Array (VA) and SGX Enclave Control Structure (SECS) will be tracked in sgx_epc_lru_lists structs, one per cgroup. For now just replace the existing sgx_active_page_list in the reclaimer and its spinlock with a global

[PATCH v5 02/18] cgroup/misc: Add SGX EPC resource type and export APIs for SGX driver

2023-09-22 Thread Haitao Huang
From: Kristen Carlson Accardi Add SGX EPC memory, MISC_CG_RES_SGX_EPC, to be a valid resource type for the misc controller. Add per resource type private data so that SGX can store additional per cgroup data in misc_cg->misc_cg_res[MISC_CG_RES_SGX_EPC]. Export misc_cg_root() so the SGX driver

[PATCH v5 01/18] cgroup/misc: Add per resource callbacks for CSS events

2023-09-22 Thread Haitao Huang
From: Kristen Carlson Accardi The misc cgroup controller (subsystem) currently does not perform resource type specific action for Cgroups Subsystem State (CSS) events: the 'css_alloc' event when a cgroup is created and the 'css_free' event when a cgroup is destroyed, or in event of user writing

[PATCH v5 00/18] Add Cgroup support for SGX EPC memory

2023-09-22 Thread Haitao Huang
SGX EPC memory allocations are separate from normal RAM allocations, and are managed solely by the SGX subsystem. The existing cgroup memory controller cannot be used to limit or account for SGX EPC memory, which is a desirable feature in some environments, e.g., support for pod level control in a

[PATCH 1/2] pinctrl: qcom: msm8226: Add MPM pin mappings

2023-09-22 Thread Matti Lehtimäki
Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins. Signed-off-by: Matti Lehtimäki --- drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm8226.c

[PATCH 2/2] pinctrl: qcom: msm8974: Add MPM pin mappings

2023-09-22 Thread Matti Lehtimäki
Add pin <-> wakeirq mappings to allow for waking up the AP from sleep through MPM-connected pins. Signed-off-by: Matti Lehtimäki --- drivers/pinctrl/qcom/pinctrl-msm8x74.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/pinctrl/qcom/pinctrl-msm8x74.c

[PATCH 0/2] MPM pin mappings for MSM8226 and MSM8974

2023-09-22 Thread Matti Lehtimäki
This series adds the MPM wakeirq mappings for MSM8226 and MSM8974. Matti Lehtimäki (2): pinctrl: qcom: msm8226: Add MPM pin mappings pinctrl: qcom: msm8974: Add MPM pin mappings drivers/pinctrl/qcom/pinctrl-msm8226.c | 12 drivers/pinctrl/qcom/pinctrl-msm8x74.c | 12

Re: [PATCH v2] nd_btt: Make BTT lanes preemptible

2023-09-22 Thread Verma, Vishal L
On Wed, 2023-09-20 at 07:37 +0200, Tomas Glozar wrote: > nd_region_acquire_lane uses get_cpu, which disables preemption. This is > an issue on PREEMPT_RT kernels, since btt_write_pg and also > nd_region_acquire_lane itself take a spin lock, resulting in BUG: > sleeping function called from invalid

[PATCH v2] eventfs: Remember what dentries were created on dir open

2023-09-22 Thread Steven Rostedt
From: "Steven Rostedt (Google)" Using the following code with libtracefs: int dfd; // create the directory events/kprobes/kp1 tracefs_kprobe_raw(NULL, "kp1", "schedule_timeout", "time=$arg1"); // Open the kprobes directory dfd =

Re: [PATCH] tracing/user_events: align uaddr on unsigned long alignment

2023-09-22 Thread Beau Belgrave
On Tue, Sep 19, 2023 at 02:59:12PM +0200, Clément Léger wrote: > > > On 14/09/2023 19:29, Steven Rostedt wrote: > > On Thu, 14 Sep 2023 13:17:00 -0400 > > Steven Rostedt wrote: > > > >> Now lets look at big endian layout: > >> > >> uaddr = 0xbeef0004 > >> enabler = 1; > >> > >> memory at

Re: [PATCH] tracing/user_events: align uaddr on unsigned long alignment

2023-09-22 Thread Beau Belgrave
On Tue, Sep 19, 2023 at 02:59:12PM +0200, Clément Léger wrote: > > > On 14/09/2023 19:29, Steven Rostedt wrote: > > On Thu, 14 Sep 2023 13:17:00 -0400 > > Steven Rostedt wrote: > > > >> Now lets look at big endian layout: > >> > >> uaddr = 0xbeef0004 > >> enabler = 1; > >> > >> memory at

Re: [PATCH v3 08/13] riscv: extend execmem_params for generated code allocations

2023-09-22 Thread Alexandre Ghiti
Hi Mike, On 18/09/2023 09:29, Mike Rapoport wrote: From: "Mike Rapoport (IBM)" The memory allocations for kprobes and BPF on RISC-V are not placed in the modules area and these custom allocations are implemented with overrides of alloc_insn_page() and bpf_jit_alloc_exec(). Slightly reorder

Re: [PATCH v3 09/13] powerpc: extend execmem_params for kprobes allocations

2023-09-22 Thread Christophe Leroy
Hi Mike, Le 18/09/2023 à 09:29, Mike Rapoport a écrit : > From: "Mike Rapoport (IBM)" > > powerpc overrides kprobes::alloc_insn_page() to remove writable > permissions when STRICT_MODULE_RWX is on. > > Add definition of EXECMEM_KRPOBES to execmem_params to allow using the > generic

Re: [PATCH v3 06/13] mm/execmem: introduce execmem_data_alloc()

2023-09-22 Thread Christophe Leroy
Le 22/09/2023 à 10:55, Song Liu a écrit : > On Fri, Sep 22, 2023 at 12:17 AM Christophe Leroy > wrote: >> >> >> >> Le 22/09/2023 à 00:52, Song Liu a écrit : >>> On Mon, Sep 18, 2023 at 12:31 AM Mike Rapoport wrote: >>> [...] diff --git a/include/linux/execmem.h

Re: [PATCH] Use CRC32 and a 1MiB dictionary for XZ compressed modules

2023-09-22 Thread Nicolas Schier
In linux-modules@v.k.o probably some more experts can comment on this: On Fri, Sep 15, 2023 at 12:15:39PM +0200, Martin Nybo Andersen wrote: > Kmod is now using the kernel decompressor which doesn't handle CRC64 > and dictionaries larger than 1MiB. > > Fixes:

Re: [PATCH v3 06/13] mm/execmem: introduce execmem_data_alloc()

2023-09-22 Thread Song Liu
On Fri, Sep 22, 2023 at 12:17 AM Christophe Leroy wrote: > > > > Le 22/09/2023 à 00:52, Song Liu a écrit : > > On Mon, Sep 18, 2023 at 12:31 AM Mike Rapoport wrote: > >> > > [...] > >> diff --git a/include/linux/execmem.h b/include/linux/execmem.h > >> index 519bdfdca595..09d45ac786e9 100644 >

Re: [PATCH v3 06/13] mm/execmem: introduce execmem_data_alloc()

2023-09-22 Thread Christophe Leroy
Le 22/09/2023 à 00:52, Song Liu a écrit : > On Mon, Sep 18, 2023 at 12:31 AM Mike Rapoport wrote: >> > [...] >> diff --git a/include/linux/execmem.h b/include/linux/execmem.h >> index 519bdfdca595..09d45ac786e9 100644 >> --- a/include/linux/execmem.h >> +++ b/include/linux/execmem.h >> @@ -29,6