[PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread Ryan Roberts
Hi All, This series adds uffd write-protect and soft-dirty tracking support for arm64. I consider the soft-dirty support (patches 3 and 4) as RFC - see rationale below. Previous attempts to add these features have failed because of a perceived lack of available PTE SW bits. However it actually tu

[PATCH v1 1/5] arm64/mm: Move PTE_PROT_NONE and PMD_PRESENT_INVALID

2024-04-19 Thread Ryan Roberts
Previously PTE_PROT_NONE was occupying bit 58, one of the bits reserved for SW use when the PTE is valid. This is a waste of those precious SW bits since PTE_PROT_NONE can only ever be set when valid is clear. Instead let's overlay it on what would be a HW bit if valid was set. We need to be caref

[RFC PATCH v1 3/5] arm64/mm: Add soft-dirty page tracking support

2024-04-19 Thread Ryan Roberts
Use the final remaining PTE SW bit (63) for soft-dirty tracking. The standard handlers are implemented for set/test/clear for both pte and pmd. Additionally we must also track the soft-dirty state as a pte swp bit, so use a free swap entry pte bit (61). There are a few complexities worth calling o

[RFC PATCH v1 4/5] selftests/mm: Enable soft-dirty tests on arm64

2024-04-19 Thread Ryan Roberts
Now that arm64 supports soft-dirty tracking lets enable the tests, which were previously disabled for arm64 to reduce noise. This reverts commit f6dd4e223d87 ("selftests/mm: skip soft-dirty tests on arm64"). Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/Makefile| 5 +

[PATCH v1 2/5] arm64/mm: Add uffd write-protect support

2024-04-19 Thread Ryan Roberts
Let's use the newly-free PTE SW bit (58) to add support for uffd-wp. The standard handlers are implemented for set/test/clear for both pte and pmd. Additionally we must also track the uffd-wp state as a pte swp bit, so use a free swap entry pte bit (3). Signed-off-by: Ryan Roberts --- arch/arm6

[PATCH v1 5/5] selftests/mm: soft-dirty should fail if a testcase fails

2024-04-19 Thread Ryan Roberts
Previously soft-dirty was unconditionally exiting with success, even if one of it's testcases failed. Let's fix that so that failure can be reported to automated systems properly. Signed-off-by: Ryan Roberts --- tools/testing/selftests/mm/soft-dirty.c | 2 +- 1 file changed, 1 insertion(+), 1 de

Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread Ryan Roberts
On 19/04/2024 08:43, Ryan Roberts wrote: > Hi All, > > This series adds uffd write-protect and soft-dirty tracking support for > arm64. I > consider the soft-dirty support (patches 3 and 4) as RFC - see rationale > below. > > Previous attempts to add these features have failed because of a perc

Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread Shivansh Vij
(Sorry about the previous HTML email, accidentally used the wrong email client) Hey All, >On 19/04/2024 08:43, Ryan Roberts wrote: >> Hi All, >> >> This series adds uffd write-protect and soft-dirty tracking support for >> arm64. I >> consider the soft-dirty support (patches 3 and 4) as RFC - s

Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread David Hildenbrand
On 19.04.24 10:33, Shivansh Vij wrote: (Sorry about the previous HTML email, accidentally used the wrong email client) Hey All, On 19/04/2024 08:43, Ryan Roberts wrote: Hi All, This series adds uffd write-protect and soft-dirty tracking support for arm64. I consider the soft-dirty support (p

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:23AM -0800, Xin Li wrote: >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: Sh

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:24AM -0800, Xin Li wrote: >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 Reviewed-by: Chao Gao

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:25AM -0800, Xin Li wrote: >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

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:26AM -0800, Xin Li wrote: >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 imme

Re: [PATCH v4 00/14] security: digest_cache LSM

2024-04-19 Thread Bagas Sanjaya
On 4/18/24 02:02, Roberto Sassu wrote: > > 72374d71c315 > > Roberto > Still FTA (fail to apply), unfortunately. -- An old man doll... just what I always wanted! - Clara

[PATCH] selftests: mm: protection_keys: save/restore nr_hugepages value from launch script

2024-04-19 Thread Muhammad Usama Anjum
The save/restore of nr_hugepages was added to the test itself by using the atexit() functionality. But it is broken as parent exits after creating child. Hence calling the atexit() function early. That's not it. The child exits after creating its child and so on. The parent cannot wait to get the

Re: [PATCH v3 2/2] kunit: avoid memory leak on device register error

2024-04-19 Thread Wander Lairson Costa
On Fri, Apr 19, 2024 at 1:59 AM David Gow wrote: > > On Fri, 19 Apr 2024 at 05:02, Wander Lairson Costa wrote: > > > > If the device register fails, free the allocated memory before > > returning. > > > > Signed-off-by: Wander Lairson Costa > > Fixes: d03c720e03bd ("kunit: Add APIs for managing

[PATCH 11/10] KVM: x86: Fix software TSC upscaling in kvm_update_guest_time()

2024-04-19 Thread David Woodhouse
From: David Woodhouse There was some confusion in kvm_update_guest_time() when software needs to advance the guest TSC. In master clock mode, there are two points of time which need to be taken into account. First there is the master clock reference point, stored in kvm->arch.master_kernel_ns (a

Re: [RFC PATCH 0/10] Cleaning up the KVM clock mess

2024-04-19 Thread David Woodhouse
On Thu, 2024-04-18 at 20:34 +0100, David Woodhouse wrote: > >   KVM: x86: Remove periodic global clock updates >   KVM: x86: Kill KVM_REQ_GLOBAL_CLOCK_UPDATE Meh, I might have to put those back. They were originally introduced to cope with NTP frequency skew which is no longer a problem,

Re: [PATCH net-next v4 6/7] selftests: drv-net: add a TCP ping test case (and useful helpers)

2024-04-19 Thread Willem de Bruijn
Jakub Kicinski wrote: > More complex tests often have to spawn a background process, > like a server which will respond to requests or tcpdump. > > Add support for creating such processes using the with keyword: > > with bkg("my-daemon", ..): > # my-daemon is alive in this block > > My in

[PATCH v4 0/2] kunit: fix minor error path mistakes

2024-04-19 Thread Wander Lairson Costa
Hi, These two patches fix some minor error path mistakes in the device module. Changes --- v1->v2 * Add fixes tag * Add imperative statement in the commit description v2->v3 * Add a goto exit label kunit_device_register_internal v3->v4 * Remove some changes requested by Marcus Elfring, as I

[PATCH v4 2/2] kunit: avoid memory leak on device register error

2024-04-19 Thread Wander Lairson Costa
If the device register fails, free the allocated memory before returning. Signed-off-by: Wander Lairson Costa Fixes: d03c720e03bd ("kunit: Add APIs for managing devices") --- lib/kunit/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/kunit/device.c b/lib/kunit/device.c index 25c8

[PATCH v4 1/2] kunit: unregister the device on error

2024-04-19 Thread Wander Lairson Costa
kunit_init_device() should unregister the device on bus register error, but mistakenly it tries to unregister the bus. Unregister the device instead of the bus. Signed-off-by: Wander Lairson Costa Fixes: d03c720e03bd ("kunit: Add APIs for managing devices") --- lib/kunit/device.c | 2 +- 1 file

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:27AM -0800, Xin Li wrote: >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 Reviewed-by: Chao Gao two nits below. >--- > >Change since v1: >* Enable FRED MSRs in

Re: [PATCH v3 2/2] kunit: avoid memory leak on device register error

2024-04-19 Thread Greg Kroah-Hartman
On Fri, Apr 19, 2024 at 09:30:06AM -0300, Wander Lairson Costa wrote: > As a side note, the behavior of device_register() seems > counterintuitive and error-prone, IMO. If the function returns an > error, it should ensure it leaks no resource and shouldn't require the > caller to do any cleanup. I

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:28AM -0800, Xin Li wrote: >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 mana

Re: [PATCH v4 2/2] kunit: avoid memory leak on device register error

2024-04-19 Thread Greg Kroah-Hartman
On Fri, Apr 19, 2024 at 10:25:02AM -0300, Wander Lairson Costa wrote: > If the device register fails, free the allocated memory before > returning. > > Signed-off-by: Wander Lairson Costa > Fixes: d03c720e03bd ("kunit: Add APIs for managing devices") > --- > lib/kunit/device.c | 1 + > 1 file ch

Re: [PATCH v4 1/2] kunit: unregister the device on error

2024-04-19 Thread Greg Kroah-Hartman
On Fri, Apr 19, 2024 at 10:25:01AM -0300, Wander Lairson Costa wrote: > kunit_init_device() should unregister the device on bus register error, > but mistakenly it tries to unregister the bus. > > Unregister the device instead of the bus. > > Signed-off-by: Wander Lairson Costa > Fixes: d03c720e

Re: [PATCH v4 2/2] kunit: avoid memory leak on device register error

2024-04-19 Thread Wander Lairson Costa
On Fri, Apr 19, 2024 at 11:03 AM Greg Kroah-Hartman wrote: > > On Fri, Apr 19, 2024 at 10:25:02AM -0300, Wander Lairson Costa wrote: > > If the device register fails, free the allocated memory before > > returning. > > > > Signed-off-by: Wander Lairson Costa > > Fixes: d03c720e03bd ("kunit: Add A

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

2024-04-19 Thread Chao Gao
On Wed, Feb 07, 2024 at 09:26:29AM -0800, Xin Li wrote: >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 s

Re: [PATCH v10 0/5] Introduce mseal

2024-04-19 Thread Suren Baghdasaryan
On Thu, Apr 18, 2024 at 6:22 PM Jeff Xu wrote: > > On Thu, Apr 18, 2024 at 1:19 PM Suren Baghdasaryan wrote: > > > > On Tue, Apr 16, 2024 at 12:40 PM Jeff Xu wrote: > > > > > > On Tue, Apr 16, 2024 at 8:13 AM Liam R. Howlett > > > wrote: > > > > > > > > * jef...@chromium.org [240415 12:35]: >

Re: [PATCH bpf-next 11/18] bpf: wq: add bpf_wq_init

2024-04-19 Thread Benjamin Tissoires
On Apr 18 2024, Alexei Starovoitov wrote: > On Tue, Apr 16, 2024 at 04:08:24PM +0200, Benjamin Tissoires wrote: > > We need to teach the verifier about the second argument which is declared > > as void * but which is of type KF_ARG_PTR_TO_MAP. We could have dropped > > this extra case if we declare

Re: [PATCH bpf-next 17/18] bpf: add bpf_wq_start

2024-04-19 Thread Benjamin Tissoires
On Apr 18 2024, Alexei Starovoitov wrote: > On Tue, Apr 16, 2024 at 04:08:30PM +0200, Benjamin Tissoires wrote: > > again, copy/paste from bpf_timer_start(). > > > > Signed-off-by: Benjamin Tissoires > > --- > > kernel/bpf/helpers.c | 24 > > 1 file changed, 24 insertion

Re: [PATCH v10 0/5] Introduce mseal

2024-04-19 Thread Jeff Xu
On Fri, Apr 19, 2024 at 7:57 AM Suren Baghdasaryan wrote: > > On Thu, Apr 18, 2024 at 6:22 PM Jeff Xu wrote: > > > > On Thu, Apr 18, 2024 at 1:19 PM Suren Baghdasaryan > > wrote: > > > > > > On Tue, Apr 16, 2024 at 12:40 PM Jeff Xu wrote: > > > > > > > > On Tue, Apr 16, 2024 at 8:13 AM Liam R.

Re: [PATCH v2 01/12] dt-bindings: riscv: add Zca, Zcf, Zcd and Zcb ISA extension description

2024-04-19 Thread Conor Dooley
On Thu, Apr 18, 2024 at 02:42:24PM +0200, Clément Léger wrote: > Add description for Zca, Zcf, Zcd and Zcb extensions which are part the > Zc* standard extensions for code size reduction. Additional validation > rules are added since Zcb depends on Zca, Zcf, depends on Zca and F, Zcd > depends on Z

Re: [PATCH 02/10] KVM: x86: Improve accuracy of KVM clock when TSC scaling is in force

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse The kvm_guest_time_update() function scales the host TSC frequency to the guest's using kvm_scale_tsc() and the v->arch.l1_tsc_scaling_ratio scaling ratio previously calculated for that vCPU. Then calcuates the scaling factors fo

Re: [PATCH bpf-next 11/18] bpf: wq: add bpf_wq_init

2024-04-19 Thread Alexei Starovoitov
On Fri, Apr 19, 2024 at 8:12 AM Benjamin Tissoires wrote: > > > It's something I added while adding the tests. And some tests were passing > in case I was having a non sleepable callback. But if we have > bpf_rcu_read_lock(), we are all fine and can reduce the complexity. Not quite following what

Re: [PATCH 03/10] KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for accurate KVM clock migration

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: Jack Allister In the common case (where kvm->arch.use_master_clock is true), the KVM clock is defined as a simple arithmetic function of the guest TSC, based on a reference point stored in kvm->arch.master_kernel_ns and kvm->arch.master_cycle_no

Re: [PATCH 04/10] KVM: selftests: Add KVM/PV clock selftest to prove timer correction

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: Jack Allister A VM's KVM/PV clock has an inherent relationship to its TSC (guest). When either the host system live-updates or the VM is live-migrated this pairing of the two clock sources should stay the same. In reality this is not the case w

Re: [PATCH 05/10] KVM: x86: Explicitly disable TSC scaling without CONSTANT_TSC

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse KVM does make an attempt to cope with non-constant TSC, and has notifiers to handle host TSC frequency changes. However, it *only* adjusts the KVM clock, and doesn't adjust TSC frequency scaling when the host changes. This is pr

Re: [PATCH 03/10] KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for accurate KVM clock migration

2024-04-19 Thread David Woodhouse
On Fri, 2024-04-19 at 16:40 +0100, Paul Durrant wrote: > > > +    * If KVM_REQ_CLOCK_UPDATE is already pending, or if the > > hv_clock has > > +    * never been generated at all, call > > kvm_guest_time_update() to do so. > > +    * Might as well use the PVCLOCK_TSC_STABLE_BIT as the >

Re: [PATCH v2 03/12] dt-bindings: riscv: add Zc* extension rules implied by C extension

2024-04-19 Thread Conor Dooley
On Thu, Apr 18, 2024 at 02:42:26PM +0200, Clément Léger wrote: > As stated by Zc* spec: > > "As C defines the same instructions as Zca, Zcf and Zcd, the rule is that: > - C always implies Zca > - C+F implies Zcf (RV32 only) > - C+D implies Zcd" > > Add additionnal validation rules to enforce t

Re: [PATCH bpf-next 17/18] bpf: add bpf_wq_start

2024-04-19 Thread Alexei Starovoitov
On Fri, Apr 19, 2024 at 8:14 AM Benjamin Tissoires wrote: > > > Honestly I just felt the patch series was big enough for a PoC and > comparison with sleepable bpf_timer. But if we think this needs not to > be added, I guess that works too :) It certainly did its job to compare the two and imo bpf

Re: [PATCH 06/10] KVM: x86: Add KVM_VCPU_TSC_SCALE and fix the documentation on TSC migration

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse The documentation on TSC migration using KVM_VCPU_TSC_OFFSET is woefully inadequate. It ignores TSC scaling, and ignores the fact that the host TSC may differ from one host to the next (and in fact because of the way the kernel c

Re: [PATCH v2 08/12] dt-bindings: riscv: add Zcmop ISA extension description

2024-04-19 Thread Conor Dooley
On Thu, Apr 18, 2024 at 02:42:31PM +0200, Clément Léger wrote: > Add description for the Zcmop (Compressed May-Be-Operations) ISA > extension which was ratified in commit c732a4f39a4 ("Zcmop is > ratified/1.0") of the riscv-isa-manual. Acked-by: Conor Dooley signature.asc Description: PGP signa

Re: [PATCH v2 04/12] riscv: add ISA parsing for Zca, Zcf, Zcd and Zcb

2024-04-19 Thread Conor Dooley
On Thu, Apr 18, 2024 at 02:42:27PM +0200, Clément Léger wrote: > The Zc* standard extension for code reduction introduces new extensions. > This patch adds support for Zca, Zcf, Zcd and Zcb. Zce, Zcmt and Zcmp > are left out of this patch since they are targeting microcontrollers/ > embedded CPUs i

Re: [PATCH 06/10] KVM: x86: Add KVM_VCPU_TSC_SCALE and fix the documentation on TSC migration

2024-04-19 Thread David Woodhouse
On Fri, 2024-04-19 at 16:49 +0100, Paul Durrant wrote: > On 18/04/2024 20:34, David Woodhouse wrote: > > From: David Woodhouse > > > > The documentation on TSC migration using KVM_VCPU_TSC_OFFSET is woefully > > inadequate. It ignores TSC scaling, and ignores the fact that the host > > TSC may di

Re: [PATCH 07/10] KVM: x86: Avoid NTP frequency skew for KVM clock on 32-bit host

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse Commit 53fafdbb8b21 ("KVM: x86: switch KVMCLOCK base to monotonic raw clock") did so only for 64-bit hosts, by capturing the boot offset from within the existing clocksource notifier update_pvclock_gtod(). That notifier was adde

Re: [PATCH bpf-next 11/18] bpf: wq: add bpf_wq_init

2024-04-19 Thread Benjamin Tissoires
On Apr 19 2024, Alexei Starovoitov wrote: > On Fri, Apr 19, 2024 at 8:12 AM Benjamin Tissoires wrote: > > > > > > It's something I added while adding the tests. And some tests were passing > > in case I was having a non sleepable callback. But if we have > > bpf_rcu_read_lock(), we are all fine an

Re: [PATCH v2 02/12] riscv: dts: enable Zc* extensions when needed

2024-04-19 Thread Conor Dooley
On Thu, Apr 18, 2024 at 02:42:25PM +0200, Clément Léger wrote: > The Zc* spec states that: > > "The C extension is the superset of the following extensions: > - Zca > - Zcf if F is specified (RV32 only) > - Zcd if D is specified > As C defines the same instructions as Zca, Zcf and Zcd, the rul

Re: [PATCH 08/10] KVM: x86: Remove periodic global clock updates

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse This effectively reverts commit 332967a3eac0 ("x86: kvm: introduce periodic global clock updates"). The periodic update was introduced to propagate NTP corrections to the guest KVM clock, when the KVM clock was based on CLOCK_MON

Re: [PATCH 09/10] KVM: x86: Kill KVM_REQ_GLOBAL_CLOCK_UPDATE

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse This was introduced in commit 0061d53daf26 ("KVM: x86: limit difference between kvmclock updates") to reduce cross-vCPU differences which arose because the KVM clock was based on CLOCK_MONOTONIC and thus subject to NTP frequency

Re: [PATCH bpf-next 17/18] bpf: add bpf_wq_start

2024-04-19 Thread Benjamin Tissoires
On Apr 19 2024, Alexei Starovoitov wrote: > On Fri, Apr 19, 2024 at 8:14 AM Benjamin Tissoires wrote: > > > > > > Honestly I just felt the patch series was big enough for a PoC and > > comparison with sleepable bpf_timer. But if we think this needs not to > > be added, I guess that works too :) >

Re: [PATCH 10/10] KVM: x86: Fix KVM clock precision in __get_kvmclock()

2024-04-19 Thread Paul Durrant
On 18/04/2024 20:34, David Woodhouse wrote: From: David Woodhouse When in 'master clock mode' (i.e. when host and guest TSCs are behaving sanely and in sync), the KVM clock is defined in terms of the guest TSC. When TSC scaling is used, calculating the KVM clock directly from *host* TSC cycles

Re: [PATCH v4 00/30] NT synchronization primitive driver

2024-04-19 Thread Peter Zijlstra
On Tue, Apr 16, 2024 at 05:18:56PM -0500, Elizabeth Figura wrote: > On Tuesday, 16 April 2024 16:18:24 CDT Elizabeth Figura wrote: > > On Tuesday, 16 April 2024 03:14:21 CDT Peter Zijlstra wrote: > > > I don't support GE has it in his builds? Last time I tried, building > > > Wine was a bit of a pa

Re: [PATCH v4 0/2] kunit: fix minor error path mistakes

2024-04-19 Thread Markus Elfring
… > * Remove some changes requested by Marcus Elfring, I became curious how affected software components can evolve further. > as I was alerted he is a known troll. I would appreciate if this interpretation will be reconsidered somehow. Regards, Markus

Re: [PATCH 1/1] selftest mm/mseal: fix compile warning

2024-04-19 Thread Muhammad Usama Anjum
On 4/19/24 8:43 AM, jef...@chromium.org wrote: > From: Jeff Xu > > fix compile warning reported by test robot > > Signed-off-by: Jeff Xu > Reported-by: kernel test robot > Closes: https://lore.kernel.org/r/202404190226.ofjoewv8-...@intel.com/ Reviewed-by: Muhammad Usama Anjum > --- > tools/

Re: [PATCH v4 02/27] ntsync: Introduce NTSYNC_IOC_WAIT_ALL.

2024-04-19 Thread Peter Zijlstra
On Thu, Apr 18, 2024 at 11:35:11AM +0200, Peter Zijlstra wrote: > On Wed, Apr 17, 2024 at 03:03:05PM -0500, Elizabeth Figura wrote: > > > Ach. I wrote this with the idea that the race isn't meaningful, but > > looking at it again you're right—there is a harmful race here. > > > > I think it shoul

Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread Mike Rapoport
On Fri, Apr 19, 2024 at 11:45:14AM +0200, David Hildenbrand wrote: > On 19.04.24 10:33, Shivansh Vij wrote: > > > On 19/04/2024 08:43, Ryan Roberts wrote: > > > > Hi All, > > > > > > > > This series adds uffd write-protect and soft-dirty tracking support for > > > > arm64. I > > > > consider the

Re: [PATCH v4 1/2] kunit: unregister the device on error

2024-04-19 Thread Markus Elfring
> > kunit_init_device() should unregister the device on bus register error, > > but mistakenly it tries to unregister the bus. > > > > Unregister the device instead of the bus. … > Reviewed-by: Greg Kroah-Hartman Would you ever like to distinguish hardware register errors from item registration f

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

2024-04-19 Thread Li, Xin3
> >+if (unlikely(vmx->msr_host_fred_rsp0 == 0)) > >+vmx->msr_host_fred_rsp0 = > read_msr(MSR_IA32_FRED_RSP0); > > can we just drop this and use "(unsigned long)task_stack_page(current) + > THREAD_SIZE" > as host fred rsp0? I thought about it, however, don't see a s

Re: [PATCH] selftests: filesystems: fix warn_unused_result build warnings

2024-04-19 Thread Muhammad Usama Anjum
On 4/17/24 11:49 PM, Amer Al Shanawany wrote: > Fix the following warnings by adding return check and error messages. > > statmount_test.c: In function ‘cleanup_namespace’: > statmount_test.c:128:9: warning: ignoring return value of ‘fchdir’ > declared with attribute ‘warn_unused_result’ [-Wunused

Re: [PATCH 1/1] selftest mm/mseal: fix compile warning

2024-04-19 Thread Pedro Falcato
On Fri, Apr 19, 2024 at 4:44 AM wrote: > > From: Jeff Xu > > fix compile warning reported by test robot > > Signed-off-by: Jeff Xu > Reported-by: kernel test robot > Closes: https://lore.kernel.org/r/202404190226.ofjoewv8-...@intel.com/ > --- > tools/testing/selftests/mm/mseal_test.c | 3 +-- >

Re: [PATCH] selftests: filesystems: add missing stddef header

2024-04-19 Thread Muhammad Usama Anjum
On 4/17/24 9:16 PM, Amer Al Shanawany wrote: > fix compiler warning and errors when compiling statmount test. The error description or the compiler with version is required to reproduce the error easily. I'm unable to reproduce the error by gcc 12 and clang 17. > > Signed-off-by: Amer Al Shanawan

Re: [PATCH] selftests: Fix asan linkage to work with clang

2024-04-19 Thread Muhammad Usama Anjum
Thanks for the fix. On 4/17/24 9:07 PM, Ryan Roberts wrote: > Both fchmodat2 and openat2 statically link against libasan (for > explanation of why, look at the fixes commit). This is done using > `-static-libasan`. However, it turns out that clang uses a different > option, `-static-libsan`. This

Re: [PATCH] selftests: Make ksft_exit functions return void instead of int

2024-04-19 Thread Muhammad Usama Anjum
On 4/17/24 8:37 PM, Nathan Chancellor wrote: > Commit f7d5bcd35d42 ("selftests: kselftest: Mark functions that > unconditionally call exit() as __noreturn") marked functions that call > exit() as __noreturn but it did not change the return type of these > functions from 'void' to 'int' like it shou

Re: [PATCH v10 0/5] Introduce mseal

2024-04-19 Thread Suren Baghdasaryan
On Fri, Apr 19, 2024 at 3:15 PM Jeff Xu wrote: > > On Fri, Apr 19, 2024 at 7:57 AM Suren Baghdasaryan wrote: > > > > On Thu, Apr 18, 2024 at 6:22 PM Jeff Xu wrote: > > > > > > On Thu, Apr 18, 2024 at 1:19 PM Suren Baghdasaryan > > > wrote: > > > > > > > > On Tue, Apr 16, 2024 at 12:40 PM Jeff

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

2024-04-19 Thread Li, Xin3
> >+#ifdef CONFIG_X86_64 > > is this #ifdeffery neccesary? Yes, otherwise build fails on 32 bit. > > I assume kvm_cpu_cap_has(X86_FEATURE_FRED) is always false > for !CONFIG_X86_64. > Looks most of FRED changes in core kernel don't have such #ifdeffery. Because it's not a compile time false, i

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

2024-04-19 Thread Li, Xin3
> >+case MSR_IA32_FRED_RSP0 ... MSR_IA32_FRED_CONFIG: > >+/* FRED MSRs should be passthrough to FRED guests only */ > > This comment sounds weird. It sounds like the code will be something like: > if guest supports FRED > return true >

Re: [PATCH v1 0/5] arm64/mm: uffd write-protect and soft-dirty tracking

2024-04-19 Thread David Hildenbrand
On 19.04.24 18:30, Mike Rapoport wrote: On Fri, Apr 19, 2024 at 11:45:14AM +0200, David Hildenbrand wrote: On 19.04.24 10:33, Shivansh Vij wrote: On 19/04/2024 08:43, Ryan Roberts wrote: Hi All, This series adds uffd write-protect and soft-dirty tracking support for arm64. I consider the soft

Re: [PATCH 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer drift correction

2024-04-19 Thread Chen, Zide
On 4/8/2024 3:07 PM, Jack Allister wrote: > This test proves that there is an inherent KVM/PV clock drift away from the > guest TSC when KVM decides to update the PV time information structure due > to a KVM_REQ_MASTERCLOCK_UPDATE. This drift is exascerbated when a guest is > using TSC scaling a

Re: [PATCH v10 0/5] Introduce mseal

2024-04-19 Thread Pedro Falcato
On Fri, Apr 19, 2024 at 2:22 AM Jeff Xu wrote: > The overhead is likely to grow linearly with the number of VMA, since > it takes time to retrieve VMA's metadata. > > Let's use one data sample to look at impact: > > Test: munmap 1000 memory range, each memory range has 1 VMA > > syscall__ vm

Re: [PATCH 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer drift correction

2024-04-19 Thread David Woodhouse
On 19 April 2024 19:40:06 BST, David Woodhouse wrote: >On 19 April 2024 18:13:16 BST, "Chen, Zide" wrote: >>I'm wondering what's the underling theory that we definitely can achieve >>±1ns accuracy? I tested it on a Sapphire Rapids @2100MHz TSC frequency, >>and I can see delta_corrected=2 in ~2% c

Re: [PATCH 2/2] KVM: selftests: Add KVM/PV clock selftest to prove timer drift correction

2024-04-19 Thread David Woodhouse
On 19 April 2024 18:13:16 BST, "Chen, Zide" wrote: >I'm wondering what's the underling theory that we definitely can achieve >±1ns accuracy? I tested it on a Sapphire Rapids @2100MHz TSC frequency, >and I can see delta_corrected=2 in ~2% cases. Hm. Thanks for testing! So the KVM clock is based o

Re: [PATCH v4 00/14] security: digest_cache LSM

2024-04-19 Thread Jarkko Sakkinen
On Fri Apr 19, 2024 at 2:18 PM EEST, Bagas Sanjaya wrote: > On 4/18/24 02:02, Roberto Sassu wrote: > > > > 72374d71c315 > > > > Roberto > > > > Still FTA (fail to apply), unfortunately. Robert, quick suggestion. Maybe pick recent rc for the patch set, rebase on top of that and document that to

Re: [PATCH v4 00/30] NT synchronization primitive driver

2024-04-19 Thread Elizabeth Figura
On Friday, 19 April 2024 11:16:11 CDT Peter Zijlstra wrote: > On Tue, Apr 16, 2024 at 05:18:56PM -0500, Elizabeth Figura wrote: > > On Tuesday, 16 April 2024 16:18:24 CDT Elizabeth Figura wrote: > > > On Tuesday, 16 April 2024 03:14:21 CDT Peter Zijlstra wrote: > > > > I don't support GE has it in

Re: [PATCH bpf-next v3 07/11] bpf: Fix a false rejection caused by AND operation

2024-04-19 Thread Eduard Zingerman
On Thu, 2024-04-11 at 20:27 +0800, Xu Kuohai wrote: > From: Xu Kuohai > > With lsm return value check, the no-alu32 version > test_libbpf_get_fd_by_id_opts > is rejected by the verifier, and the log says: > > 0: R1=ctx() R10=fp0 > ; int BPF_PROG(check_access, struct bpf_map *map, fmode_t fm

Re: [PATCH v4 00/14] security: digest_cache LSM

2024-04-19 Thread Roberto Sassu
On 4/19/2024 4:18 AM, Bagas Sanjaya wrote: On 4/18/24 02:02, Roberto Sassu wrote: 72374d71c315 Roberto Still FTA (fail to apply), unfortunately. Sorry, looks like I didn't regenerate the patches after rebasing to the latest kernel. The current ones are still based on 6.8-rc3, but they s

Re: [PATCH v7 08/24] drivers/perf: riscv: Implement SBI PMU snapshot function

2024-04-19 Thread Atish Kumar Patra
On Thu, Apr 18, 2024 at 1:01 PM Samuel Holland wrote: > > Hi Atish, > > On 2024-04-18 2:47 AM, Atish Patra wrote: > > > > On 4/16/24 21:02, Samuel Holland wrote: > >> Hi Atish, > >> > >> On 2024-04-16 1:44 PM, Atish Patra wrote: > >>> SBI v2.0 SBI introduced PMU snapshot feature which adds the fol

[PATCH v8 00/24] RISC-V SBI v2.0 PMU improvements and Perf sampling in KVM guest

2024-04-19 Thread Atish Patra
This series implements SBI PMU improvements done in SBI v2.0[1] i.e. PMU snapshot and fw_read_hi() functions. SBI v2.0 introduced PMU snapshot feature which allows the SBI implementation to provide counter information (i.e. values/overflow status) via a shared memory between the SBI implementati

[PATCH v8 01/24] RISC-V: Fix the typo in Scountovf CSR name

2024-04-19 Thread Atish Patra
The counter overflow CSR name is "scountovf" not "sscountovf". Fix the csr name. Fixes: 4905ec2fb7e6 ("RISC-V: Add sscofpmf extension support") Reviewed-by: Clément Léger Reviewed-by: Conor Dooley Reviewed-by: Anup Patel Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/in

[PATCH v8 02/24] RISC-V: Add FIRMWARE_READ_HI definition

2024-04-19 Thread Atish Patra
SBI v2.0 added another function to SBI PMU extension to read the upper bits of a counter with width larger than XLEN. Add the definition for that function. Reviewed-by: Andrew Jones Reviewed-by: Clément Léger Acked-by: Conor Dooley Reviewed-by: Anup Patel Signed-off-by: Atish Patra --- arch

[PATCH v8 03/24] drivers/perf: riscv: Read upper bits of a firmware counter

2024-04-19 Thread Atish Patra
SBI v2.0 introduced a explicit function to read the upper 32 bits for any firmware counter width that is longer than 32bits. This is only applicable for RV32 where firmware counter can be 64 bit. Reviewed-by: Andrew Jones Acked-by: Palmer Dabbelt Reviewed-by: Conor Dooley Reviewed-by: Anup Pate

[PATCH v8 04/24] drivers/perf: riscv: Use BIT macro for shifting operations

2024-04-19 Thread Atish Patra
It is a good practice to use BIT() instead of (1 << x). Replace the current usages with BIT(). Take this opportunity to replace few (1UL << x) with BIT() as well for consistency. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/include/asm/sbi.h | 20 ++-- dr

[PATCH v8 05/24] RISC-V: Add SBI PMU snapshot definitions

2024-04-19 Thread Atish Patra
SBI PMU Snapshot function optimizes the number of traps to higher privilege mode by leveraging a shared memory between the S/VS-mode and the M/HS mode. Add the definitions for that extension and new error codes. Reviewed-by: Andrew Jones Reviewed-by: Anup Patel Acked-by: Palmer Dabbelt Signed-o

[PATCH v8 06/24] RISC-V: KVM: Rename the SBI_STA_SHMEM_DISABLE to a generic name

2024-04-19 Thread Atish Patra
SBI_STA_SHMEM_DISABLE is a macro to invoke disable shared memory commands. As this can be invoked from other SBI extension context as well, rename it to more generic name as SBI_SHMEM_DISABLE. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/include/asm/sbi.h | 2 +- arch/ri

[PATCH v8 07/24] RISC-V: Use the minor version mask while computing sbi version

2024-04-19 Thread Atish Patra
As per the SBI specification, minor version is encoded in the lower 24 bits only. Make sure that the SBI version is computed with the appropriate mask. Currently, there is no minor version in use. Thus, it doesn't change anything functionality but it is good to be compliant with the specification.

[PATCH v8 08/24] drivers/perf: riscv: Fix counter mask iteration for RV32

2024-04-19 Thread Atish Patra
For RV32, used_hw_ctrs can have more than 1 word if the firmware chooses to interleave firmware/hardware counters indicies. Even though it's a unlikely scenario, handle that case by iterating over all the words instead of just using the first word. Reviewed-by: Andrew Jones Signed-off-by: Atish P

[PATCH v8 09/24] drivers/perf: riscv: Implement SBI PMU snapshot function

2024-04-19 Thread Atish Patra
SBI v2.0 SBI introduced PMU snapshot feature which adds the following features. 1. Read counter values directly from the shared memory instead of csr read. 2. Start multiple counters with initial values with one SBI call. These functionalities optimizes the number of traps to the higher privilege

[PATCH v8 10/24] RISC-V: KVM: Fix the initial sample period value

2024-04-19 Thread Atish Patra
The initial sample period value when counter value is not assigned should be set to maximum value supported by the counter width. Otherwise, it may result in spurious interrupts. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/kvm/vcpu_pmu.c | 2 +- 1 file changed, 1 inserti

[PATCH v8 11/24] RISC-V: KVM: No need to update the counter value during reset

2024-04-19 Thread Atish Patra
The virtual counter value is updated during pmu_ctr_read. There is no need to update it in reset case. Otherwise, it will be counted twice which is incorrect. Fixes: 0cb74b65d2e5 ("RISC-V: KVM: Implement perf support without sampling") Reviewed-by: Anup Patel Reviewed-by: Andrew Jones Signed-off

[PATCH v8 12/24] RISC-V: KVM: No need to exit to the user space if perf event failed

2024-04-19 Thread Atish Patra
Currently, we return a linux error code if creating a perf event failed in kvm. That shouldn't be necessary as guest can continue to operate without perf profiling or profiling with firmware counters. Return appropriate SBI error code to indicate that PMU configuration failed. An error message in

[PATCH v8 13/24] RISC-V: KVM: Implement SBI PMU Snapshot feature

2024-04-19 Thread Atish Patra
PMU Snapshot function allows to minimize the number of traps when the guest access configures/access the hpmcounters. If the snapshot feature is enabled, the hypervisor updates the shared memory with counter data and state of overflown counters. The guest can just read the shared memory instead of

[PATCH v8 14/24] RISC-V: KVM: Add perf sampling support for guests

2024-04-19 Thread Atish Patra
KVM enables perf for guest via counter virtualization. However, the sampling can not be supported as there is no mechanism to enabled trap/emulate scountovf in ISA yet. Rely on the SBI PMU snapshot to provide the counter overflow data via the shared memory. In case of sampling event, the host firs

[PATCH v8 15/24] RISC-V: KVM: Support 64 bit firmware counters on RV32

2024-04-19 Thread Atish Patra
The SBI v2.0 introduced a fw_read_hi function to read 64 bit firmware counters for RV32 based systems. Add infrastructure to support that. Reviewed-by: Andrew Jones Reviewed-by: Anup Patel Signed-off-by: Atish Patra --- arch/riscv/include/asm/kvm_vcpu_pmu.h | 4 ++- arch/riscv/kvm/vcpu_pmu.c

[PATCH v8 16/24] RISC-V: KVM: Improve firmware counter read function

2024-04-19 Thread Atish Patra
Rename the function to indicate that it is meant for firmware counter read. While at it, add a range sanity check for it as well. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- arch/riscv/include/asm/kvm_vcpu_pmu.h | 2 +- arch/riscv/kvm/vcpu_pmu.c | 7 ++- arch/riscv/

[PATCH v8 17/24] KVM: riscv: selftests: Move sbi definitions to its own header file

2024-04-19 Thread Atish Patra
The SBI definitions will continue to grow. Move the sbi related definitions to its own header file from processor.h Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- .../selftests/kvm/include/riscv/processor.h | 39 --- .../testing/selftests/kvm/

[PATCH v8 18/24] KVM: riscv: selftests: Add helper functions for extension checks

2024-04-19 Thread Atish Patra
__vcpu_has_ext can check both SBI and ISA extensions when the first argument is properly converted to SBI/ISA extension IDs. Introduce two helper functions to make life easier for developers so they don't have to worry about the conversions. Replace the current usages as well with new helpers. Re

[PATCH v8 19/24] KVM: riscv: selftests: Add Sscofpmf to get-reg-list test

2024-04-19 Thread Atish Patra
The KVM RISC-V allows Sscofpmf extension for Guest/VM so let us add this extension to get-reg-list test. Reviewed-by: Anup Patel Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- tools/testing/selftests/kvm/riscv/get-reg-list.c | 4 1 file changed, 4 insertions(+) diff --git a/too

[PATCH v8 20/24] KVM: riscv: selftests: Add SBI PMU extension definitions

2024-04-19 Thread Atish Patra
The SBI PMU extension definition is required for upcoming SBI PMU selftests. Reviewed-by: Andrew Jones Reviewed-by: Anup Patel Signed-off-by: Atish Patra --- .../testing/selftests/kvm/include/riscv/sbi.h | 66 +++ 1 file changed, 66 insertions(+) diff --git a/tools/testing/sel

[PATCH v8 21/24] KVM: riscv: selftests: Add SBI PMU selftest

2024-04-19 Thread Atish Patra
This test implements basic sanity test and cycle/instret event counting tests. Reviewed-by: Anup Patel Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/riscv/sbi_pmu_test.c| 369 ++ 2 files

  1   2   >