From: Geliang Tang <tanggeliang(a)kylinos.cn>
This patchset uses more network helpers in test_sock_addr.c, but
first of all, patch 2 is needed to make network_helpers.c independent
of test_progs.c. Then network_helpers.h can be included into
test_sock_addr.c without compile errors.
Patch 1 and patch 2 address Martin's comments for the previous series
too.
v2:
- Only a few minor cleanups to patch 5.
Geliang Tang (5):
selftests/bpf: Fix a fd leak in error paths in open_netns
selftests/bpf: Use log_err in open_netns/close_netns
selftests/bpf: Use start_server_addr in test_sock_addr
selftests/bpf: Use connect_to_addr in test_sock_addr
selftests/bpf: Use make_sockaddr in test_sock_addr
tools/testing/selftests/bpf/Makefile | 3 +-
tools/testing/selftests/bpf/network_helpers.c | 20 ++-
tools/testing/selftests/bpf/network_helpers.h | 1 +
.../selftests/bpf/prog_tests/empty_skb.c | 2 +
.../bpf/prog_tests/ip_check_defrag.c | 2 +
.../selftests/bpf/prog_tests/tc_redirect.c | 2 +-
.../selftests/bpf/prog_tests/test_tunnel.c | 4 +
.../selftests/bpf/prog_tests/xdp_metadata.c | 16 ++
tools/testing/selftests/bpf/test_sock_addr.c | 138 +++---------------
9 files changed, 63 insertions(+), 125 deletions(-)
--
2.40.1
Adding GHCB support for selftests. Very similar code to the ucall
functionality, I didn't refactor anything common out since I was unsure
with just two instances that is required. If pulling out common code
between those two is preferred please let me know. The series only adds a
single usage of the GHCB which is a special outsb GHCB exit to allow for
passing the 64-bit ucall pointer. In future series we can test more GHCB
functionality of KVM. I'd like to base some SNP smoke tests off of this
and the current SEV selftest work.
base-commit: 40e09b3ccfacc640d58e1e3d6b8f29b2db0a9848
Cc: Vishal Annapurve <vannapurve(a)google.com>
Cc: Ackerley Tng <ackerleytng(a)google.com>
Cc: Paolo Bonzini <pbonzini(a)redhat.com>
Cc: Claudio Imbrenda <imbrenda(a)linux.ibm.com>
Cc: Sean Christopherson <seanjc(a)google.com>
Cc: Carlos Bilbao <carlos.bilbao(a)amd.com>
Cc: Tom Lendacky <thomas.lendacky(a)amd.com>
Cc: Michael Roth <michael.roth(a)amd.com>
Cc: kvm(a)vger.kernel.org
Cc: linux-kselftest(a)vger.kernel.org
Signed-off-by: Peter Gonda <pgonda(a)google.com>
Peter Gonda (6):
Add GHCB with setters and getters
Add arch specific additional guest pages
Add vm_vaddr_alloc_pages_shared()
Add GHCB allocations and helpers
Add is_sev_enabled() helpers
Add ability for SEV-ES guests to use ucalls via GHCB
tools/testing/selftests/kvm/Makefile | 2 +-
.../selftests/kvm/include/kvm_util_base.h | 4 +
.../selftests/kvm/include/x86_64/sev.h | 7 +
.../selftests/kvm/include/x86_64/svm.h | 106 +++++++++++++
tools/testing/selftests/kvm/lib/kvm_util.c | 22 ++-
.../selftests/kvm/lib/x86_64/processor.c | 8 +
tools/testing/selftests/kvm/lib/x86_64/sev.c | 149 ++++++++++++++++++
.../testing/selftests/kvm/lib/x86_64/ucall.c | 17 ++
.../selftests/kvm/x86_64/sev_smoke_test.c | 22 +--
9 files changed, 313 insertions(+), 24 deletions(-)
--
2.44.0.478.gd926399ef9-goog
On Sat, Mar 30, 2024, Muhammad Usama Anjum wrote:
> On 2/7/24 10:26 PM, Xin Li wrote:
> > 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 transitions.
> >
> > Besides, FRED introduces event stack levels to dispatch an event handler
> > onto a stack baesd on current stack level and stack levels defined in
> > IA32_FRED_STKLVLS MSR for each exception vector. VMX nested-exception
> > support ensures a correct event stack level is chosen when a VM entry
> > injects a nested exception, which is regarded as occurred in ring 0.
> >
> > To fully test the underlying FRED VMX code, this test should be run one
> > more round with EPT disabled to inject page faults as nested exceptions.
> >
> > Originally-by: Shan Kang <shan.kang(a)intel.com>
> > Signed-off-by: Xin Li <xin3.li(a)intel.com>
> Thank you for the new test patch. We have been trying to ensure TAP
> conformance for tests which cannot be achieved if new tests aren't using
> TAP already.
Who is "we"?
> Please make your test TAP compliant.
This isn't entirely reasonable feedback. I'm all for getting KVM selftests
TAP-friendly, but the current reality is that the KVM selftests infrastructure
doesn't make it easy to be TAP compliant. We're working on improving things,
i.e. I do hope/want to get to a state where it's a hard requirement for KVM
selftests to be TAP compliant, but we aren't there yet.
If you have specific feedback on _how_ to make a test TAP compliant, then by all
means provide that feedback. But a drive-by "make your test TAP compliant" isn't
super helpful.
> > ---
> > tools/testing/selftests/kvm/Makefile | 1 +
> > .../selftests/kvm/include/x86_64/processor.h | 32 ++
> > .../testing/selftests/kvm/x86_64/fred_test.c | 297 ++++++++++++++++++
> Add generated binary object to .gitignore.
This should be unnecessary (though I haven't actually verified by building), as
KVM selftests ignore most everything by default since commit 43e96957e8b8
("KVM: selftests: Use pattern matching in .gitignore").
** Background **
Currently, OVS supports several packet sampling mechanisms (sFlow,
per-bridge IPFIX, per-flow IPFIX). These end up being translated into a
userspace action that needs to be handled by ovs-vswitchd's handler
threads only to be forwarded to some third party application that
will somehow process the sample and provide observability on the
datapath.
A particularly interesting use-case is controller-driven
per-flow IPFIX sampling where the OpenFlow controller can add metadata
to samples (via two 32bit integers) and this metadata is then available
to the sample-collecting system for correlation.
** Problem **
The fact that sampled traffic share netlink sockets and handler thread
time with upcalls, apart from being a performance bottleneck in the
sample extraction itself, can severely compromise the datapath,
yielding this solution unfit for highly loaded production systems.
Users are left with little options other than guessing what sampling
rate will be OK for their traffic pattern and system load and dealing
with the lost accuracy.
Looking at available infrastructure, an obvious candidated would be
to use psample. However, it's current state does not help with the
use-case at stake because sampled packets do not contain user-defined
metadata.
** Proposal **
This series is an attempt to fix this situation by extending the
existing psample infrastructure to carry a variable length
user-defined cookie.
The main existing user of psample is tc's act_sample. It is also
xtended to forward the action's cookie to psample.
Finally, OVS sample action is extended with a couple of attributes
(OVS_SAMPLE_ATTR_PSAMPLE_{GROUP,COOKIE}) that contain a 32 group_id
and a variable length cookie. When provided, OVS sends the packet
to psample for observability.
In order to make it easier for users to receive samples coming from
a specific source, group_id filtering is added to psample as well
as a tracepoint for troubleshooting.
--
rfc_v2 -> v1:
- Accomodate Ilya's comments.
- Split OVS's attribute in two attributes and simplify internal
handling of psample arguments.
- Extend psample and tc with a user-defined cookie.
- Add a tracepoint to psample to facilitate troubleshooting.
rfc_v1 -> rfc_v2:
- Use psample instead of a new OVS-only multicast group.
- Extend psample and tc with a user-defined cookie.
Adrian Moreno (8):
net: netlink: export genl private pointer getters
net: psample: add multicast filtering on group_id
net: psample: add user cookie
net: psample: add tracepoint
net: sched: act_sample: add action cookie to sample
net:openvswitch: add psample support
selftests: openvswitch: add sample action.
selftests: openvswitch: add psample test
Documentation/netlink/specs/ovs_flow.yaml | 6 +
include/net/psample.h | 2 +
include/uapi/linux/openvswitch.h | 49 ++++-
include/uapi/linux/psample.h | 2 +
net/netlink/genetlink.c | 2 +
net/openvswitch/actions.c | 51 ++++-
net/openvswitch/flow_netlink.c | 80 +++++--
net/psample/psample.c | 131 ++++++++++-
net/psample/trace.h | 62 ++++++
net/sched/act_sample.c | 12 +
.../selftests/net/openvswitch/openvswitch.sh | 97 +++++++-
.../selftests/net/openvswitch/ovs-dpctl.py | 207 +++++++++++++++++-
12 files changed, 655 insertions(+), 46 deletions(-)
create mode 100644 net/psample/trace.h
--
2.44.0
The patches in this series make the ktap sh helper and the power_supply
selftest POSIX-compliant. Tested with bash, dash and busybox ash.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado(a)collabora.com>
---
Nícolas F. R. A. Prado (2):
selftests: ktap_helpers: Make it POSIX-compliant
selftests: power_supply: Make it POSIX-compliant
tools/testing/selftests/kselftest/ktap_helpers.sh | 4 ++--
tools/testing/selftests/power_supply/test_power_supply_properties.sh | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
---
base-commit: 7e74ee01d1754156ed3706b61e793fbd46f5cd7b
change-id: 20240415-supply-selftest-posix-sh-aee99cf85e8f
Best regards,
--
Nícolas F. R. A. Prado <nfraprado(a)collabora.com>
On 19 April 2024 19:40:06 BST, David Woodhouse <dwmw2(a)infradead.org> wrote:
>On 19 April 2024 18:13:16 BST, "Chen, Zide" <zide.chen(a)intel.com> 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 on the guest TSC. Given a delta between the guest TSC T and some reference point in time R, the KVM clock is expressed as a(T-R)+r, where little r is the value of the KVM clock when the guest TSC was R, and (a) is the rate of the guest TSC.
>
>When set the clock with KVM_SET_CLOCK_GUEST, we are changing the values of R and r to a new point in time. Call the new ones Q and q respectively.
>
>But we calculate precisely (within 1ns at least) what the KVM clock would have been with the *old* formula, and adjust our new offset (q) so that at our new reference TSC value Q, the formulae give exactly the same result.
>
>And because the *rates* are the same, they should continue to give the same results, ±1ns.
>
>Or such *was* my theory, at least.
>
>Would be interesting to see it disproven with actual numbers for the old+new pvclock structs, so I can understand where the logic goes wrong.
>
>Were you using frequency scaling?
>
Oh, also please could you test the updated version I posted yesterday, from https://git.infradead.org/?p=users/dwmw2/linux.git;a=shortlog;h=refs/heads/…
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 turns out that there are 2
available but they are hidden. PTE_PROT_NONE was previously occupying a SW bit,
but it only applies when PTE_VALID is clear, so this is moved to overlay PTE_UXN
in patch 1, freeing up the SW bit. Bit 63 is marked as "IGNORED" in the Arm ARM,
but it does not currently indicate "reserved for SW use" like it does for the
other SW bits. I've confirmed with the spec owner that this is an oversight; the
bit is intended to be reserved for SW use and the spec will clarify this in a
future update.
So we have our two bits; patch 2 enables uffd-wp, patch 3 enables soft-dirty and
patches 4 and 5 sort out the selftests so that the soft-dirty tests are compiled
for, and run on arm64.
That said, these are the last 2 SW bits and we may want to keep 1 bit in reserve
for future use. soft-dirty is only used for CRIU to my knowledge, and it is
thought that their use case could be solved with the more generic uffd-wp. So
unless somebody makes a clear case for the inclusion of soft-dirty support, we
are probably better off dropping patches 3 and 4 and keeping bit 63 for future
use. Although note that the most recent attempt to add soft-dirty for arm64 was
last month [1] so I'd like to give Shivansh Vij the opportunity to make the
case.
---8<---
As an appendix, I've also experimented with adding an "extended SW bits" region
linked by the `struct ptdesc` (which you can always find from the `pte_t *`). If
demonstrated to work, this would act as an insurance policy in case we ever need
more SW bits in future, giving us confidence to merge soft-dirty now.
Unfortunately this approach suffers from 2 problems; 1) its slow; my fork()
microbenchmark takes 40% longer in the worst case. 2) it is not possible to read
the HW pte and the extended SW bits atomically so it is impossible to implement
ptep_get_lockess() in its current form. So I've abandoned this experiment. (I
can provide more details if there is interest).
---8<---
[1] https://lore.kernel.org/linux-arm-kernel/MW4PR12MB687563EFB56373E8D55DDEABB…
Thanks,
Ryan
Ryan Roberts (5):
arm64/mm: Move PTE_PROT_NONE and PMD_PRESENT_INVALID
arm64/mm: Add uffd write-protect support
arm64/mm: Add soft-dirty page tracking support
selftests/mm: Enable soft-dirty tests on arm64
selftests/mm: soft-dirty should fail if a testcase fails
arch/arm64/Kconfig | 2 +
arch/arm64/include/asm/pgtable-prot.h | 20 +++-
arch/arm64/include/asm/pgtable.h | 118 +++++++++++++++++++--
arch/arm64/mm/contpte.c | 6 +-
arch/arm64/mm/fault.c | 3 +-
arch/arm64/mm/hugetlbpage.c | 6 +-
tools/testing/selftests/mm/Makefile | 5 +-
tools/testing/selftests/mm/madv_populate.c | 26 +----
tools/testing/selftests/mm/run_vmtests.sh | 5 +-
tools/testing/selftests/mm/soft-dirty.c | 2 +-
10 files changed, 141 insertions(+), 52 deletions(-)
--
2.25.1
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.
Reviewed-by: Muhammad Usama Anjum <usama.anjum(a)collabora.com>
Reviewed-by: David Hildenbrand <david(a)redhat.com>
Signed-off-by: Ryan Roberts <ryan.roberts(a)arm.com>
---
Applies on top of v6.9-rc3.
I previously sent this out as part of a larger series [1]. Feedback was to
repost standalone.
[1] https://lore.kernel.org/all/20240419074344.2643212-1-ryan.roberts@arm.com/
Thanks,
Ryan
tools/testing/selftests/mm/soft-dirty.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c
index 7dbfa53d93a0..bdfa5d085f00 100644
--- a/tools/testing/selftests/mm/soft-dirty.c
+++ b/tools/testing/selftests/mm/soft-dirty.c
@@ -209,5 +209,5 @@ int main(int argc, char **argv)
close(pagemap_fd);
- return ksft_exit_pass();
+ ksft_finished();
}
--
2.25.1