Re: [PATCH bpf-next v2] bpf: Allow compiler to inline most of bpf_local_storage_lookup()

2024-02-07 Thread Marco Elver
On Thu, 8 Feb 2024 at 00:58, Yonghong Song wrote: > On 2/7/24 4:26 AM, Marco Elver wrote: > > In various performance profiles of kernels with BPF programs attached, > > bpf_local_storage_lookup() appears as a significant portion of CPU > > cycles spent. To enable the compiler generate more optimal

Re: [PATCH v9 25/25] integrity: Remove LSM

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Since now IMA and EVM use their own integrity metadata, it is safe to > remove the 'integrity' LSM, with its management of integrity metadata. > > Keep the iint.c file only for loading IMA and EVM keys at boot, and for > creating the integrity directory i

Re: [PATCH v9 23/25] evm: Make it independent from 'integrity' LSM

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Define a new structure for EVM-specific metadata, called evm_iint_cache, > and embed it in the inode security blob. Introduce evm_iint_inode() to > retrieve metadata, and register evm_inode_alloc_security() for the > inode_alloc_security LSM hook, to initi

Re: [PATCH v9 22/25] evm: Move to LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > As for IMA, move hardcoded EVM function calls from various places in the > kernel to the LSM infrastructure, by introducing a new LSM named 'evm' > (last and always enabled like 'ima'). The order in the Makefile ensures > that 'evm' hooks are executed afte

Re: [PATCH v9 19/25] integrity: Move integrity_kernel_module_request() to IMA

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for removing the 'integrity' LSM, move > integrity_kernel_module_request() to IMA, and rename it to > ima_kernel_module_request(). > > Compile it conditionally if CONFIG_INTEGRITY_ASYMMETRIC_KEYS is enabled, > and call it from security.c (r

Re: [PATCH v9 21/25] ima: Move IMA-Appraisal to LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > A few additional IMA hooks are needed to reset the cached appraisal > status, causing the file's integrity to be re-evaluated on next access. > Register these IMA-appraisal only functions separately from the rest of IMA > functions, as appraisal is a separ

Re: [PATCH v9 20/25] ima: Move to LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Move hardcoded IMA function calls (not appraisal-specific functions) from > various places in the kernel to the LSM infrastructure, by introducing a > new LSM named 'ima' (at the end of the LSM list and always enabled like > 'integrity'). > > Having IMA b

Re: [PATCH v9 18/25] security: Introduce key_post_create_or_update hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the key_post_create_or_update hook. > > Depending on policy, IMA measures the key content after creation or update, > so that remote verifiers are aware of the operation. > > Ot

Re: [PATCH v9 16/25] security: Introduce inode_post_set_acl hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the inode_post_set_acl hook. > > At inode_set_acl hook, EVM verifies the file's existing HMAC value. At > inode_post_set_acl, EVM re-calculates the file's HMAC based on the modif

Re: [PATCH v9 17/25] security: Introduce inode_post_remove_acl hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the inode_post_remove_acl hook. > > At inode_remove_acl hook, EVM verifies the file's existing HMAC value. At > inode_post_remove_acl, EVM re-calculates the file's HMAC with the

Re: [PATCH v9 15/25] security: Introduce inode_post_create_tmpfile hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the inode_post_create_tmpfile hook. > > As temp files can be made persistent, treat new temp files like other new > files, so that the file hash is calculated and stored in the s

Re: [PATCH v9 14/25] security: Introduce path_post_mknod hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the path_post_mknod hook. > > IMA-appraisal requires all existing files in policy to have a file > hash/signature stored in security.ima. An exception is made for empty files > c

Re: [PATCH v9 13/25] security: Introduce file_release hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the file_release hook. > > IMA calculates at file close the new digest of the file content and writes > it to security.ima, so that appraisal at next file access succeeds. > > A

Re: [PATCH v9 12/25] security: Introduce file_post_open hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation to move IMA and EVM to the LSM infrastructure, introduce the > file_post_open hook. Also, export security_file_post_open() for NFS. > > Based on policy, IMA calculates the digest of the file content and > extends the TPM with the digest, ve

Re: [PATCH v9 11/25] security: Introduce inode_post_removexattr hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the inode_post_removexattr hook. > > At inode_removexattr hook, EVM verifies the file's existing HMAC value. At > inode_post_removexattr, EVM re-calculates the file's HMAC with t

Re: [PATCH v9 10/25] security: Introduce inode_post_setattr hook

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > In preparation for moving IMA and EVM to the LSM infrastructure, introduce > the inode_post_setattr hook. > > At inode_setattr hook, EVM verifies the file's existing HMAC value. At > inode_post_setattr, EVM re-calculates the file's HMAC based on the modif

Re: [PATCH v9 9/25] security: Align inode_setattr hook definition with EVM

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Add the idmap parameter to the definition, so that evm_inode_setattr() can > be registered as this hook implementation. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Acked-by: Casey Schaufler > Reviewed-by: Mimi Zohar > --- > includ

Re: [PATCH v9 8/25] evm: Align evm_inode_post_setxattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change evm_inode_post_setxattr() definition, so that it can be registered > as implementation of the inode_post_setxattr hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Mimi Zohar > Reviewed-by: Casey Schaufler > ---

Re: [PATCH v9 7/25] evm: Align evm_inode_setxattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change evm_inode_setxattr() definition, so that it can be registered as > implementation of the inode_setxattr hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Mimi Zohar > Reviewed-by: Casey Schaufler > --- > includ

Re: [PATCH v9 6/25] evm: Align evm_inode_post_setattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change evm_inode_post_setattr() definition, so that it can be registered as > implementation of the inode_post_setattr hook (to be introduced). > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Casey Schaufler > Reviewed-by:

Re: [PATCH v9 5/25] ima: Align ima_post_read_file() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change ima_post_read_file() definition, by making "void *buf" a > "char *buf", so that it can be registered as implementation of the > post_read_file hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Mimi Zohar > Review

Re: [PATCH v9 4/25] ima: Align ima_inode_removexattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change ima_inode_removexattr() definition, so that it can be registered as > implementation of the inode_removexattr hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Casey Schaufler > Reviewed-by: Mimi Zohar > --- >

Re: [PATCH v9 3/25] ima: Align ima_inode_setxattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change ima_inode_setxattr() definition, so that it can be registered as > implementation of the inode_setxattr hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Mimi Zohar > Reviewed-by: Casey Schaufler > --- > includ

Re: [PATCH v9 2/25] ima: Align ima_file_mprotect() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change ima_file_mprotect() definition, so that it can be registered > as implementation of the file_mprotect hook. > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Casey Schaufler > Reviewed-by: Mimi Zohar > --- > include/

Re: [PATCH v9 1/25] ima: Align ima_inode_post_setattr() definition with LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > Change ima_inode_post_setattr() definition, so that it can be registered as > implementation of the inode_post_setattr hook (to be introduced). > > Signed-off-by: Roberto Sassu > Reviewed-by: Stefan Berger > Reviewed-by: Casey Schaufler > Reviewed-by:

Re: [PATCH v9 0/25] security: Move IMA and EVM to the LSM infrastructure

2024-02-07 Thread Paul Moore
On Jan 15, 2024 Roberto Sassu wrote: > > IMA and EVM are not effectively LSMs, especially due to the fact that in > the past they could not provide a security blob while there is another LSM > active. > > That changed in the recent years, the LSM stacking feature now makes it > possible to stack

Re: [PATCH net] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Jakub Kicinski
On Wed, 7 Feb 2024 18:42:52 -0800 Jakub Kicinski wrote: > On Tue, 6 Feb 2024 16:27:40 +0100 Paolo Abeni wrote: > > The gro self-tests sends the packets to be aggregated with > > multiple write operations. > > > > When running is slow environment, it's hard to guarantee that > > the GRO engine wil

Re: [PATCH net] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Jakub Kicinski
On Tue, 6 Feb 2024 16:27:40 +0100 Paolo Abeni wrote: > The gro self-tests sends the packets to be aggregated with > multiple write operations. > > When running is slow environment, it's hard to guarantee that > the GRO engine will wait for the last packet in an intended > train. > > The above ca

Re: [PATCH bpf-next v2] bpf: Allow compiler to inline most of bpf_local_storage_lookup()

2024-02-07 Thread Yonghong Song
On 2/7/24 4:26 AM, Marco Elver wrote: In various performance profiles of kernels with BPF programs attached, bpf_local_storage_lookup() appears as a significant portion of CPU cycles spent. To enable the compiler generate more optimal code, turn bpf_local_storage_lookup() into a static inline f

Re: [PATCH net v2] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Matthieu Baerts
Hi Paolo, On 07/02/2024 19:36, Paolo Abeni wrote: > The gro self-tests sends the packets to be aggregated with > multiple write operations. > > When running is slow environment, it's hard to guarantee that > the GRO engine will wait for the last packet in an intended > train. > > The above cause

Re: [PATCH] kunit: device: Unregister the kunit_bus on shutdown

2024-02-07 Thread Rae Moar
On Wed, Feb 7, 2024 at 8:36 AM Jani Nikula wrote: > > On Fri, 02 Feb 2024, Rae Moar wrote: > > On Thu, Feb 1, 2024 at 1:06 AM David Gow wrote: > >> > >> If KUnit is built as a module, and it's unloaded, the kunit_bus is not > >> unregistered. This causes an error if it's then re-loaded later, as

Re: [PATCH] mm, memcg: cg2 memory{.swap,}.peak write handlers

2024-02-07 Thread David Finkel
Did I miss a reviewer on this change? I've clearly missed the window for 6.8, but it would be nice to get this into a staging branch for 6.9. (I can definitely rebase and re-mail if necessary) Thanks, David Finkel On Mon, Dec 4, 2023 at 2:42 PM David Finkel wrote: > > Other mechanisms for que

[PATCH 8/8] selftests/damon/_chk_dependency: get debugfs mount point from /proc/mounts

2024-02-07 Thread SeongJae Park
DAMON debugfs selftests dependency checker assumes debugfs would be mounted at /sys/kernel/debug. That would be ok for many cases, but some systems might mounted the file system on some different places. Parse the real mount point using /proc/mounts file. Signed-off-by: SeongJae Park --- tools

[PATCH 7/8] selftests/damon: add a test for the pid leak of dbgfs_target_ids_write()

2024-02-07 Thread SeongJae Park
Commit ebb3f994dd92 ("mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()'") fixes a pid leak bug in DAMON debugfs interface, namely dbgfs_target_ids_write() function. Add a selftest for the issue to prevent the problem from mistakenly recurring. Signed-off-by: SeongJae Park ---

[PATCH 6/8] selftests/damon: add a test for a race between target_ids_read() and dbgfs_before_terminate()

2024-02-07 Thread SeongJae Park
commit 34796417964b ("mm/damon/dbgfs: protect targets destructions with kdamond_lock") fixed a race of DAMON debugfs interface. Specifically, the race was happening between target_ids_read() and dbgfs_before_terminate(). Add a test for the issue to prevent the problem from accidentally recurring.

[PATCH 5/8] selftests/damon: add a test for DAMOS apply intervals

2024-02-07 Thread SeongJae Park
Add a selftest for DAMOS apply intervals. It runs two schemes having different apply interval agains an artificial memory access workload, and check if the scheme with smaller apply interval was applied more frequently. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile

[PATCH 4/8] selftests/damon: add a test for DAMOS quota

2024-02-07 Thread SeongJae Park
Add a selftest for verifying the DAMOS quota feature. The test is very similar to sysfs_update_schemes_tried_regions_wss_estimation.py. It starts an artificial workload of 20 MiB working set, run DAMON to find the working set size, but with 1 MiB/100 ms size quota. Then, it collect the DAMON-fou

[PATCH 3/8] selftests/damon/_damon_sysfs: support DAMOS apply interval

2024-02-07 Thread SeongJae Park
Update the test-purpose DAMON sysfs control Python module to support DAMOS apply interval. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/t

[PATCH 2/8] selftests/damon/_damon_sysfs: support DAMOS stats

2024-02-07 Thread SeongJae Park
Update the test-purpose DAMON sysfs control Python module to support DAMOS stats. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 32 +++ 1 file changed, 32 insertions(+) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py b/tools/testing

[PATCH 1/8] selftests/damon/_damon_sysfs: support DAMOS quota

2024-02-07 Thread SeongJae Park
Update the test-purpose DAMON sysfs control Python module to support DAMOS quota. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/_damon_sysfs.py | 42 +++ 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/damon/_damon_sysfs.py

[PATCH 0/8] selftests/damon: add more tests for core functionalities and corner cases

2024-02-07 Thread SeongJae Park
Continue DAMON selftests' test coverage improvement works with a trivial improvement of the test code itself. The sequence of the patches in patchset is as follows. The first five patches add two DAMON core functionalities tests. Those begins with three patches (patches 1-3) that update the test

[PATCH net v2] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Paolo Abeni
The gro self-tests sends the packets to be aggregated with multiple write operations. When running is slow environment, it's hard to guarantee that the GRO engine will wait for the last packet in an intended train. The above causes almost deterministic failures in our CI for the 'large' test-case

Re: [PATCH net] selftests: net: add more missing kernel config

2024-02-07 Thread Eric Dumazet
On Wed, Feb 7, 2024 at 6:31 PM Paolo Abeni wrote: > > The reuseport_addr_any.sh is currently skipping DCCP tests and > pmtu.sh is skipping all the FOU/GUE related cases: add the missing > options. > > Signed-off-by: Paolo Abeni > --- SGTM thanks. Reviewed-by: Eric Dumazet

[PATCH v2 24/25] KVM: selftests: Add a new VM guest mode to run user level code

2024-02-07 Thread Xin Li
Add a new VM guest mode VM_MODE_PXXV48_4K_USER to set the user bit of guest page table entries, thus allow user level code to run in guests. Suggested-by: Sean Christopherson Signed-off-by: Xin Li --- .../testing/selftests/kvm/include/kvm_util_base.h | 1 + tools/testing/selftests/kvm/lib/kvm_

[PATCH v2 21/25] KVM: nVMX: Add VMCS FRED states checking

2024-02-07 Thread Xin Li
Add FRED related VMCS fields checkings. As real hardware, nested VMX performs checks on various VMCS fields, including both controls and guest/host states. With the introduction of VMX FRED, add FRED related VMCS fields checkings. Signed-off-by: Xin Li Tested-by: Shan Kang --- arch/x86/kvm/vm

[PATCH v2 25/25] KVM: selftests: Add fred exception tests

2024-02-07 Thread Xin Li
Add tests for FRED event data and VMX nested-exception. FRED is designed to save a complete event context in its stack frame, e.g., FRED saves the faulting linear address of a #PF into a 64-bit event data field defined in FRED stack frame. As such, FRED VMX adds event data handling during VMX tra

[PATCH v2 23/25] KVM: selftests: Run debug_regs test with FRED enabled

2024-02-07 Thread Xin Li
Run another round of debug_regs test with FRED enabled if FRED is available. Signed-off-by: Xin Li --- .../selftests/kvm/include/x86_64/processor.h | 4 ++ .../testing/selftests/kvm/x86_64/debug_regs.c | 50 ++- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/t

[PATCH v2 22/25] KVM: x86: Allow FRED/LKGS/WRMSRNS to be exposed to guests

2024-02-07 Thread Xin Li
Allow FRED/LKGS/WRMSRNS to be exposed to guests, thus a guest OS could see these features when the guest is configured with FRED/LKGS/WRMSRNS in Qemu. A qemu patch is required to expose FRED/LKGS/WRMSRNS to KVM guests. Signed-off-by: Xin Li Tested-by: Shan Kang --- arch/x86/kvm/cpuid.c | 4 ++-

[PATCH v2 19/25] KVM: nVMX: Add FRED VMCS fields

2024-02-07 Thread Xin Li
Add FRED VMCS fields to nested VMX context management. Todo: change VMCS12_REVISION, as struct vmcs12 is changed. Signed-off-by: Xin Li Tested-by: Shan Kang --- Change since v1: * Remove hyperv TLFS related changes (Jeremi Piotrowski). * Use kvm_cpu_cap_has() instead of cpu_feature_enabled() (

[PATCH v2 18/25] KVM: nVMX: Add a prerequisite to SHADOW_FIELD_R[OW] macros

2024-02-07 Thread Xin Li
Add a prerequisite for accessing VMCS fields referenced in macros SHADOW_FIELD_R[OW], because a VMCS field may not exist on some CPUs. Signed-off-by: Xin Li --- arch/x86/kvm/vmx/nested.c | 70 ++-- arch/x86/kvm/vmx/vmcs_shadow_fields.h | 76 +--

[PATCH v2 17/25] KVM: nVMX: Add support for the secondary VM exit controls

2024-02-07 Thread Xin Li
Enable the secondary VM exit controls to prepare for nested FRED. Signed-off-by: Xin Li Tested-by: Shan Kang --- Documentation/virt/kvm/x86/nested-vmx.rst | 1 + arch/x86/kvm/vmx/capabilities.h | 1 + arch/x86/kvm/vmx/nested.c | 15 ++- arch/x86/kvm/vmx/v

[PATCH v2 20/25] KVM: nVMX: Add support for VMX FRED controls

2024-02-07 Thread Xin Li
Add VMX FRED controls to nested VMX controls and set the VMX nested-exception support bit (bit 58) in the nested IA32_VMX_BASIC MSR when FRED is enabled. Signed-off-by: Xin Li Tested-by: Shan Kang --- arch/x86/kvm/vmx/nested.c | 14 ++ arch/x86/kvm/vmx/vmx.c| 1 + 2 files chang

[PATCH v2 13/25] KVM: VMX: Handle VMX nested exception for FRED

2024-02-07 Thread Xin Li
Set VMX nested exception bit in the VM-entry interruption information VMCS field when injecting a nested exception using FRED event delivery to ensure: 1) The nested exception is injected on a correct stack level. 2) The nested bit defined in FRED stack frame is set. The event stack level used

[PATCH v2 16/25] KVM: VMX: Invoke vmx_set_cpu_caps() before nested setup

2024-02-07 Thread Xin Li
Set VMX CPU capabilities before initializing nested instead of after, as it needs to check VMX CPU capabilities to setup the VMX basic MSR for nested. Signed-off-by: Xin Li --- arch/x86/kvm/vmx/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/vmx.c b

[PATCH v2 15/25] KVM: VMX: Dump FRED context in dump_vmcs()

2024-02-07 Thread Xin Li
Add FRED related VMCS fields to dump_vmcs() to have it dump FRED context. Signed-off-by: Xin Li Tested-by: Shan Kang --- Change since v1: * Use kvm_cpu_cap_has() instead of cpu_feature_enabled() (Chao Gao). * Dump guest FRED states only if guest has FRED enabled (Nikolay Borisov). --- arch/x86

[PATCH v2 12/25] KVM: VMX: Handle FRED event data

2024-02-07 Thread Xin Li
Set injected-event data when injecting a #PF, #DB, or #NM caused by extended feature disable using FRED event delivery, and save original-event data for being used as injected-event data. Unlike IDT using some extra CPU register as part of an event context, e.g., %cr2 for #PF, FRED saves a complet

[PATCH v2 14/25] KVM: VMX: Disable FRED if FRED consistency checks fail

2024-02-07 Thread Xin Li
Refuse to virtualize FRED if FRED consistency checks fail. Suggested-by: Chao Gao Signed-off-by: Xin Li --- arch/x86/kvm/vmx/capabilities.h | 10 ++ arch/x86/kvm/vmx/vmx.c | 2 ++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kvm/vmx/capabilities.h b/arch/x86/kvm/vm

[PATCH v2 11/25] KVM: x86: Add kvm_is_fred_enabled()

2024-02-07 Thread Xin Li
Add kvm_is_fred_enabled() to get if FRED is enabled on a vCPU. Signed-off-by: Xin Li Tested-by: Shan Kang --- Change since v1: * Explain why it is ok to only check CR4.FRED (Chao Gao). --- arch/x86/kvm/kvm_cache_regs.h | 17 + 1 file changed, 17 insertions(+) diff --git a/arch

[PATCH v2 10/25] KVM: VMX: Add support for FRED context save/restore

2024-02-07 Thread Xin Li
Handle host initiated FRED MSR access requests to allow FRED context to be set/get from user level. During VM save/restore and live migration, FRED context needs to be saved/restored, which requires FRED MSRs to be accessed from a user level application, e.g., Qemu. Note, handling of MSR_IA32_FRE

[PATCH v2 08/25] KVM: VMX: Initialize VMCS FRED fields

2024-02-07 Thread Xin Li
Initialize host VMCS FRED fields with host FRED MSRs' value and guest VMCS FRED fields to 0. FRED CPU states are managed in 9 new FRED MSRs, as well as a few existing CPU registers and MSRs, e.g., CR4.FRED. To support FRED context management, new VMCS fields corresponding to most of FRED CPU stat

[PATCH v2 09/25] KVM: VMX: Switch FRED RSP0 between host and guest

2024-02-07 Thread Xin Li
Switch MSR_IA32_FRED_RSP0 between host and guest in vmx_prepare_switch_to_{host,guest}(). MSR_IA32_FRED_RSP0 is used during ring 3 event delivery only, thus KVM, running on ring 0, can run safely with guest FRED RSP0, i.e., no need to switch between host/guest FRED RSP0 during VM entry and exit.

[PATCH v2 05/25] KVM: VMX: Initialize FRED VM entry/exit controls in vmcs_config

2024-02-07 Thread Xin Li
Setup the global vmcs_config for FRED: 1) Add VM_ENTRY_LOAD_IA32_FRED to KVM_OPTIONAL_VMX_VM_ENTRY_CONTROLS to have a FRED CPU load guest FRED MSRs from VMCS upon VM entry. 2) Add SECONDARY_VM_EXIT_SAVE_IA32_FRED to KVM_OPTIONAL_VMX_SECONDARY_VM_EXIT_CONTROLS to have a FRED CPU save guest

[PATCH v2 06/25] KVM: VMX: Defer enabling FRED MSRs save/load until after set CPUID

2024-02-07 Thread Xin Li
Clear FRED VM entry/exit controls when initializing a vCPU, and set these controls only if FRED is enumerated after set CPUID. FRED VM entry/exit controls need to be set to establish context sufficient to support FRED event delivery immediately after VM entry and exit. However it is not required

[PATCH v2 07/25] KVM: VMX: Set intercept for FRED MSRs

2024-02-07 Thread Xin Li
Add FRED MSRs to the valid passthrough MSR list and set FRED MSRs intercept based on FRED enumeration. Signed-off-by: Xin Li Tested-by: Shan Kang --- Change since v1: * Enable FRED MSRs intercept if FRED is no longer enumerated in CPUID (Chao Gao). --- arch/x86/kvm/vmx/vmx.c | 17 +++

[PATCH v2 03/25] KVM: VMX: Add support for the secondary VM exit controls

2024-02-07 Thread Xin Li
Enable the secondary VM exit controls to prepare for FRED enabling. The activation of the secondary VM exit controls is off now, and it will be switched on when a VMX feature needing it is enabled. Signed-off-by: Xin Li Tested-by: Shan Kang --- Change since v1: * Always load the secondary VM e

[PATCH v2 04/25] KVM: x86: Mark CR4.FRED as not reserved

2024-02-07 Thread Xin Li
The CR4.FRED bit, i.e., CR4[32], is no longer a reserved bit when a guest enumerates FRED, otherwise it is still a reserved bit. Signed-off-by: Xin Li Tested-by: Shan Kang --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/x86.h | 2 ++ 2 files changed, 3 insertions(+), 1 del

[PATCH v2 02/25] KVM: VMX: Cleanup VMX misc information defines and usages

2024-02-07 Thread Xin Li
Define VMX misc information fields with BIT_ULL()/GENMASK_ULL(), and move VMX misc field macros to vmx.h if used in multiple files or where they are used only once. Signed-off-by: Xin Li --- arch/x86/include/asm/msr-index.h | 5 - arch/x86/include/asm/vmx.h | 12 +-- arch/x86/

[PATCH v2 01/25] KVM: VMX: Cleanup VMX basic information defines and usages

2024-02-07 Thread Xin Li
Define VMX basic information fields with BIT_ULL()/GENMASK_ULL(), and replace hardcoded VMX basic numbers with these field macros. Save the full/raw value of MSR_IA32_VMX_BASIC in the global vmcs_config as type u64 to get rid of the hi/lo crud, and then use VMX_BASIC helpers to extract info as nee

[PATCH v2 00/25] Enable FRED with KVM VMX

2024-02-07 Thread Xin Li
This patch set enables the Intel flexible return and event delivery (FRED) architecture with KVM VMX to allow guests to utilize FRED. The FRED architecture defines simple new transitions that change privilege level (ring transitions). The FRED architecture was designed with the following goals: 1

[PATCH net] selftests: net: add more missing kernel config

2024-02-07 Thread Paolo Abeni
The reuseport_addr_any.sh is currently skipping DCCP tests and pmtu.sh is skipping all the FOU/GUE related cases: add the missing options. Signed-off-by: Paolo Abeni --- Note that this does not include the - still missing - OVS-related option and pmtu.sh is will keep skipping such cases. Such tes

Re: [PATCH v12 03/20] KVM: xen: mark guest pages dirty with the pfncache lock held

2024-02-07 Thread Sean Christopherson
On Tue, Feb 06, 2024, David Woodhouse wrote: > On Tue, 2024-02-06 at 19:17 -0800, Sean Christopherson wrote: > > KVM: x86/xen: for the scope please.  A few commits have "KVM: xen:", but > > "x86/xen" > > is the overwhelming favorite. > > Paul's been using "KVM: xen:" in this patch series since fi

Re: [PATCH v12 18/20] KVM: pfncache: check the need for invalidation under read lock first

2024-02-07 Thread Sean Christopherson
On Tue, Feb 06, 2024, David Woodhouse wrote: > On Tue, 2024-02-06 at 20:47 -0800, Sean Christopherson wrote: > > > > I'm saying this: > > > >   When processing mmu_notifier invalidations for gpc caches, pre-check for > >   overlap with the invalidation event while holding gpc->lock for read, and

Re: [PATCH v12 13/20] KVM: selftests / xen: map shared_info using HVA rather than GFN

2024-02-07 Thread Sean Christopherson
On Wed, Feb 07, 2024, Paul Durrant wrote: > On 07/02/2024 04:14, Sean Christopherson wrote: > > Please stop making up random scopes. Yes, I know "KVM: selftests:" is too > > coarse, > > bt everyone doing their own thing is worse. > > So what would you suggest? Until someone comes up with a bett

Re: [RFC PATCH 0/8] cgroup/cpuset: Support RCU_NOCB on isolated partitions

2024-02-07 Thread Frederic Weisbecker
Le Tue, Feb 06, 2024 at 04:15:18PM -0300, Marcelo Tosatti a écrit : > On Tue, Feb 06, 2024 at 01:56:23PM +0100, Frederic Weisbecker wrote: > > Le Wed, Jan 17, 2024 at 12:15:07PM -0500, Waiman Long a écrit : > > > > > > On 1/17/24 12:07, Tejun Heo wrote: > > > > Hello, > > > > > > > > On Wed, Jan

Re: [PATCH net] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Matthieu Baerts
Hi Paolo, On 07/02/2024 15:35, Paolo Abeni wrote: > On Wed, 2024-02-07 at 12:16 +0100, Matthieu Baerts wrote: >> Hi Paolo, >> >> On 06/02/2024 16:27, Paolo Abeni wrote: >>> The gro self-tests sends the packets to be aggregated with >>> multiple write operations. >>> >>> When running is slow enviro

Re: [PATCH net] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Paolo Abeni
On Wed, 2024-02-07 at 12:16 +0100, Matthieu Baerts wrote: > Hi Paolo, > > On 06/02/2024 16:27, Paolo Abeni wrote: > > The gro self-tests sends the packets to be aggregated with > > multiple write operations. > > > > When running is slow environment, it's hard to guarantee that > > the GRO engine

Re: [PATCH net] selftests: cmsg_ipv6: repeat the exact packet

2024-02-07 Thread patchwork-bot+netdevbpf
Hello: This patch was applied to netdev/net.git (main) by David S. Miller : On Sun, 4 Feb 2024 08:56:18 -0800 you wrote: > cmsg_ipv6 test requests tcpdump to capture 4 packets, > and sends until tcpdump quits. Only the first packet > is "real", however, and the rest are basic UDP packets. > So i

Re: [PATCH] kunit: device: Unregister the kunit_bus on shutdown

2024-02-07 Thread Jani Nikula
On Fri, 02 Feb 2024, Rae Moar wrote: > On Thu, Feb 1, 2024 at 1:06 AM David Gow wrote: >> >> If KUnit is built as a module, and it's unloaded, the kunit_bus is not >> unregistered. This causes an error if it's then re-loaded later, as we >> try to re-register the bus. >> >> Unregister the bus and

[PATCH net v2 2/2] selftests: openvswitch: Add validation for the recursion test

2024-02-07 Thread Aaron Conole
Add a test case into the netlink checks that will show the number of nested action recursions won't exceed 16. Going to 17 on a small clone call isn't enough to exhaust the stack on (most) systems, so it should be safe to run even on systems that don't have the fix applied. Signed-off-by: Aaron C

[PATCH net v2 1/2] net: openvswitch: limit the number of recursions from action sets

2024-02-07 Thread Aaron Conole
The ovs module allows for some actions to recursively contain an action list for complex scenarios, such as sampling, checking lengths, etc. When these actions are copied into the internal flow table, they are evaluated to validate that such actions make sense, and these calls happen recursively.

[PATCH net v2 0/2] net: openvswitch: limit the recursions from action sets

2024-02-07 Thread Aaron Conole
Open vSwitch module accepts actions as a list from the netlink socket and then creates a copy which it uses in the action set processing. During processing of the action list on a packet, the module keeps a count of the execution depth and exits processing if the action depth goes too high. Howeve

Re: [PATCH 3/3] tools/testing: adjust pstore backend related selftest

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 10:19:21AM +0800, Yuanhe Shu wrote: > Pstore now supports multiple backends, the module parameter > pstore.backend varies from 'registered backend' to 'backends that are > allowed to register'. Adjust selftests to match the change. > > Signed-off-by: Yuanhe Shu > --- > to

Re: [PATCH 2/3] Documentation: adjust pstore backend related document

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 10:19:20AM +0800, Yuanhe Shu wrote: > Pstore now supports multiple backends, adjust related document. > > Signed-off-by: Yuanhe Shu > --- > Documentation/ABI/testing/pstore| 8 > Documentation/admin-guide/kernel-parameters.txt | 4 +++- > 2 files

Re: [PATCH 1/3] pstore: add multi-backend support

2024-02-07 Thread Kees Cook
On Wed, Feb 07, 2024 at 10:19:19AM +0800, Yuanhe Shu wrote: > Currently, pstore supports only one backend open at a time. > Specifically, due to the global variable "psinfo", pstore only accepts > the first registered backend. If a new backend wants to register later, > pstore will simply reject it

[PATCH bpf-next v2] bpf: Allow compiler to inline most of bpf_local_storage_lookup()

2024-02-07 Thread Marco Elver
In various performance profiles of kernels with BPF programs attached, bpf_local_storage_lookup() appears as a significant portion of CPU cycles spent. To enable the compiler generate more optimal code, turn bpf_local_storage_lookup() into a static inline function, where only the cache insertion co

Re: [PATCH net] selftests: net: cope with slow env in gro.sh test

2024-02-07 Thread Matthieu Baerts
Hi Paolo, On 06/02/2024 16:27, Paolo Abeni wrote: > The gro self-tests sends the packets to be aggregated with > multiple write operations. > > When running is slow environment, it's hard to guarantee that > the GRO engine will wait for the last packet in an intended > train. > > The above cause

Re: [PATCH] bpf: Separate bpf_local_storage_lookup() fast and slow paths

2024-02-07 Thread Marco Elver
On Tue, Feb 06, 2024 at 05:22PM -0800, Martin KaFai Lau wrote: > On 2/6/24 9:04 AM, Marco Elver wrote: > > On Mon, Feb 05, 2024 at 03:24PM -0800, Martin KaFai Lau wrote: > > [...] > > > > Or can you suggest different functions to hook to for the recursion > > > > test? > > > > > > I don't prefer

[PATCH net-next] selftests: net: include forwarding lib

2024-02-07 Thread Paolo Abeni
The altnames test uses the forwarding/lib.sh and that dependency currently causes failures when running the test after install: make -C tools/testing/selftests/ TARGETS=net install ./tools/testing/selftests/kselftest_install/run_kselftest.sh \ -t net:altnames.sh # ... # ./altnames.sh

Re: [PATCH v12 13/20] KVM: selftests / xen: map shared_info using HVA rather than GFN

2024-02-07 Thread Paul Durrant
On 07/02/2024 04:14, Sean Christopherson wrote: Please stop making up random scopes. Yes, I know "KVM: selftests:" is too coarse, bt everyone doing their own thing is worse. So what would you suggest?

Re: [PATCH v12 11/20] KVM: xen: allow shared_info to be mapped by fixed HVA

2024-02-07 Thread Paul Durrant
On 07/02/2024 04:10, Sean Christopherson wrote: On Mon, Jan 15, 2024, Paul Durrant wrote: @@ -638,20 +637,32 @@ int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data) } break; - case KVM_XEN_ATTR_TYPE_SHARED_INFO: { + case KVM_XEN_ATTR

Re: [PATCH v12 03/20] KVM: xen: mark guest pages dirty with the pfncache lock held

2024-02-07 Thread Paul Durrant
On 07/02/2024 03:17, Sean Christopherson wrote: KVM: x86/xen: for the scope please. A few commits have "KVM: xen:", but "x86/xen" is the overwhelming favorite. If I have to re-post anyway then I can do that.

Re: [PATCH v12 04/20] KVM: pfncache: add a mark-dirty helper

2024-02-07 Thread Paul Durrant
On 07/02/2024 03:20, Sean Christopherson wrote: On Mon, Jan 15, 2024, Paul Durrant wrote: diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 7e7fd25b09b3..f3bb9e0a81fe 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1399,6 +1399,17 @@ int kvm_gpc_refr