the guest VM
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/x86_64/get_cpuid_test.c | 90 ++-
1 file changed, 88 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
b/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
-by: Vitaly Kuznetsov
Reviewed-by: Sean Christopherson
Fixes: 433f4ba19041 ("KVM: x86: fix out-of-bounds write in
KVM_GET_EMULATED_CPUID (CVE-2019-19332)")
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/cpuid.c | 33 -
1 file changed, 16
As the similar kvm_get_supported_cpuid(),
kvm_get_emulated_cpuid allocates and gets
a struct kvm_cpuid2 filled with emulated features.
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/include/x86_64/processor.h | 1 +
.../selftests/kvm/lib/x86_64/processor.c | 33
.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 307f2fcf1b02..8ba23bc2a625 100644
--- a/Documentation/virt/kvm/api.rst
the ioctl documentation accordingly and
patches 3 and 4 extend the x86_64/get_cpuid_test.c selftest to check
the intended behavior of KVM_GET_EMULATED_CPUID.
Signed-off-by: Emanuele Giuseppe Esposito
---
v5:
- Better comment in cpuid.c (patch 1)
Emanuele Giuseppe Esposito (4):
KVM: x86: Fix
On 08/04/2021 22:29, Sean Christopherson wrote:
On Thu, Apr 08, 2021, Emanuele Giuseppe Esposito wrote:
When retrieving emulated CPUID entries, check for an insufficient array
size if and only if KVM is actually inserting an entry.
If userspace has a priori knowledge of the exact array size
the guest VM
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/x86_64/get_cpuid_test.c | 90 ++-
1 file changed, 88 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
b/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
As the similar kvm_get_supported_cpuid(),
kvm_get_emulated_cpuid allocates and gets
a struct kvm_cpuid2 filled with emulated features.
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/include/x86_64/processor.h | 1 +
.../selftests/kvm/lib/x86_64/processor.c | 33
.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 307f2fcf1b02..8ba23bc2a625 100644
--- a/Documentation/virt/kvm/api.rst
: 433f4ba19041 ("KVM: x86: fix out-of-bounds write in
KVM_GET_EMULATED_CPUID (CVE-2019-19332)")
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/cpuid.c | 33 -
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/arch/x86/kvm/cpuid.c b/ar
the ioctl documentation accordingly and
patches 3 and 4 extend the x86_64/get_cpuid_test.c selftest to check
the intended behavior of KVM_GET_EMULATED_CPUID.
Signed-off-by: Emanuele Giuseppe Esposito
---
v4:
- Address nitpicks given in the mailing list
Emanuele Giuseppe Esposito (4):
KVM: x86: Fix
the guest VM
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/x86_64/get_cpuid_test.c | 90 ++-
1 file changed, 88 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
b/tools/testing/selftests/kvm/x86_64/get_cpuid_test.c
As the similar kvm_get_supported_cpuid(),
kvm_get_emulated_cpuid allocates and gets
a struct kvm_cpuid2 filled with emulated features.
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/include/x86_64/processor.h | 1 +
.../selftests/kvm/lib/x86_64/processor.c | 33
.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 307f2fcf1b02..8ba23bc2a625 100644
--- a/Documentation/virt/kvm/api.rst
-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/cpuid.c | 33 -
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 6bd2f8b830e4..27059ddf9f0a 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
the ioctl documentation accordingly and
patches 3 and 4 extend the x86_64/get_cpuid_test.c selftest to check
the intended behavior of KVM_GET_EMULATED_CPUID.
Signed-off-by: Emanuele Giuseppe Esposito
---
v3:
- clearer commit message and problem explanation
- pre-initialize the stack variable 'entry
+static void check_cpuid(struct kvm_cpuid2 *cpuid, struct kvm_cpuid_entry2
*entrie)
+{
+ int i;
+
+ for (i = 0; i < cpuid->nent; i++) {
+ if (cpuid->entries[i].function == entrie->function &&
+ cpuid->entries[i].index == entrie->index) {
+
On 31/03/2021 20:31, Sean Christopherson wrote:
On Wed, Mar 31, 2021, Emanuele Giuseppe Esposito wrote:
Calling the kvm KVM_GET_[SUPPORTED/EMULATED]_CPUID ioctl requires
a nent field inside the kvm_cpuid2 struct to be big enough to contain
all entries that will be set by kvm.
Therefore
As the similar kvm_get_supported_cpuid, allocates and gets
the struct kvm_cpuid2 filled with emulated features.
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/include/x86_64/processor.h | 1 +
.../selftests/kvm/lib/x86_64/processor.c | 33 +++
2 files
.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 307f2fcf1b02..8ba23bc2a625 100644
--- a/Documentation/virt/kvm/api.rst
Introduce a new selftest for the KVM_GET_EMULATED_CPUID
ioctl. Since the behavior and functionality is similar to
get_cpuid_test, the test checks:
1) checks for corner case in the nent field of the struct kvm_cpuid2.
2) sets and gets it as cpuid from the guest VM
Signed-off-by: Emanuele Giuseppe
, when filling the entries do_cpuid_func() requires an
additional entry, so if the right nent is known in advance,
giving the exact number of entries won't work because it has to be
increased by one.
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/cpuid.c | 35
documentation accordingly and
patches 3 and 4 provide a selftest to check KVM_GET_EMULATED_CPUID
accordingly.
Signed-off-by: Emanuele Giuseppe Esposito
---
v2:
- better fix in cpuid.c, perform the nent check after the switch statement
- fix bug in get_emulated_cpuid.c selftest, each entry needs
On 31/03/2021 09:56, Vitaly Kuznetsov wrote:
Emanuele Giuseppe Esposito writes:
On 31/03/2021 05:01, Sean Christopherson wrote:
On Tue, Mar 30, 2021, Emanuele Giuseppe Esposito wrote:
Calling the kvm KVM_GET_[SUPPORTED/EMULATED]_CPUID ioctl requires
a nent field inside the kvm_cpuid2
On 31/03/2021 05:01, Sean Christopherson wrote:
On Tue, Mar 30, 2021, Emanuele Giuseppe Esposito wrote:
Calling the kvm KVM_GET_[SUPPORTED/EMULATED]_CPUID ioctl requires
a nent field inside the kvm_cpuid2 struct to be big enough to contain
all entries that will be set by kvm.
Therefore
Signed-off-by: Emanuele Giuseppe Esposito
---
tools/arch/x86/include/uapi/asm/kvm.h | 2 +-
tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/arch/x86/include/uapi/asm/kvm.h
b/tools/arch/x86/include/uapi
As the similar kvm_get_supported_cpuid, allocates and gets
the struct kvm_cpuid2 filled with emulated features.
Signed-off-by: Emanuele Giuseppe Esposito
---
.../selftests/kvm/include/x86_64/processor.h | 1 +
.../selftests/kvm/lib/x86_64/processor.c | 33 +++
2 files
Introduce a new selftest for the KVM_GET_EMULATED_CPUID
ioctl. Since the behavior and functionality is similar to
get_cpuid_test, the test checks:
1) checks for corner case in the nent field of the struct kvm_cpuid2.
2) sets and gets it as cpuid from the guest VM
Signed-off-by: Emanuele Giuseppe
.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 10 --
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 307f2fcf1b02..8ba23bc2a625 100644
--- a/Documentation/virt/kvm/api.rst
, when filling the entries do_cpuid_func() requires an
additional entry, so if the right nent is known in advance,
giving the exact number of entries won't work because it has to be increased
by one.
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/cpuid.c | 6 ++
1 file changed, 6
documentation accordingly and
patches 3 and 4 provide a selftest to check KVM_GET_EMULATED_CPUID
accordingly.
Emanuele Giuseppe Esposito (4):
kvm: cpuid: adjust the returned nent field of kvm_cpuid2 for
KVM_GET_SUPPORTED_CPUID and KVM_GET_EMULATED_CPUID
Documentation: kvm: update
The ioctl KVM_SET_BOOT_CPU_ID fails when called after vcpu creation.
Add this explanation in the documentation.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/virt/kvm/api.rst b
On 18/03/2021 17:20, Andrew Jones wrote:
On Thu, Mar 18, 2021 at 04:16:24PM +0100, Emanuele Giuseppe Esposito wrote:
Test for the KVM_SET_BOOT_CPU_ID ioctl.
Check that it correctly allows to change the BSP vcpu.
v1 -> v2:
- remove unnecessary printf
- move stage for loop inside run_v
Hi Andrew,
Thank you for the feedback (also in v1).
On 18/03/2021 18:03, Andrew Jones wrote:
On Thu, Mar 18, 2021 at 03:56:29PM +0100, Emanuele Giuseppe Esposito wrote:
Test the KVM_GET_MSR_FEATURE_INDEX_LIST
and KVM_GET_MSR_INDEX_LIST ioctls.
Signed-off-by: Emanuele Giuseppe Esposito
off-by: Emanuele Giuseppe Esposito
---
tools/testing/selftests/kvm/.gitignore| 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/x86_64/set_boot_cpu_id.c| 166 ++
3 files changed, 168 insertions(+)
create mode 100644 tools/testing/selftests/kvm/x86
As in kvm_ioctl and _kvm_ioctl, add
the respective _vm_ioctl for vm_ioctl.
_vm_ioctl invokes an ioctl using the vm fd,
leaving the caller to test the result.
Signed-off-by: Emanuele Giuseppe Esposito
---
tools/testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib
Test the KVM_GET_MSR_FEATURE_INDEX_LIST
and KVM_GET_MSR_INDEX_LIST ioctls.
Signed-off-by: Emanuele Giuseppe Esposito
---
tools/testing/selftests/kvm/.gitignore| 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../kvm/x86_64/get_msr_index_features.c | 124
On 17/03/2021 11:49, Paolo Bonzini wrote:
On 17/03/21 08:45, Emanuele Giuseppe Esposito wrote:
+ struct kvm_msr_list features_list;
buffer.header.nmsrs = 1;
buffer.entry.index = msr_index;
+ features_list.nmsrs = 1;
+
kvm_fd = open(KVM_DEV_PATH, O_RDONLY
Extend the kvm_get_feature_msr function to cover also
KVM_GET_MSR_FEATURE_INDEX_LIST.
Signed-off-by: Emanuele Giuseppe Esposito
---
tools/testing/selftests/kvm/lib/x86_64/processor.c | 7 +++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c
b
Test for the KVM_SET_BOOT_CPU_ID ioctl.
Check that it correctly allows to change the BSP vcpu.
Signed-off-by: Emanuele Giuseppe Esposito
---
tools/testing/selftests/kvm/.gitignore| 1 +
tools/testing/selftests/kvm/Makefile | 1 +
.../selftests/kvm/x86_64/set_boot_cpu_id.c
in KVM_GET_MSR_INDEX_LIST ioctl description
(section 4.3).
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/virt/kvm/api.rst | 250 -
1 file changed, 125 insertions(+), 125 deletions(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt
Hi,
+
+The STATS_FS_HIDDEN attribute won't affect the aggregation, it will only
+block the creation of the files.
Why does HIDDEN block the creation of files? instead of their visibility?
The file itself is used to allow the user to view the content of a
value. In order to make it hidden,
In order to run them, the kernel .config must set CONFIG_KUNIT=y
and a new .kunitconfig file must be created with CONFIG_STATS_FS=y
and CONFIG_STATS_FS_TEST=y
It looks like CONFIG_STATS_FS is built-in, but it exports
much of the functionality you are testing. However could the
tests also
The file system is mounted on /sys/kernel/stats and would be already used
by kvm. Statsfs was initially introduced by Paolo Bonzini [1].
What's the direct motivation for this work? Moving KVM stats out of
debugfs?
There's many reasons: one of these is not using debugfs for statistics,
Hi Andrew
How do you atomically get and display a group of statistics?
If you look at how the netlink socket works, you will see code like:
do {
start = u64_stats_fetch_begin_irq(_stats->syncp);
rx_packets =
Apply stats_fs on the networking statistics subsystem.
Currently it only works with disabled network namespace
(CONFIG_NET_NS=n), because multiple namespaces will have the same
device name under the same root source that will cause a conflict in
stats_fs.
Signed-off-by: Emanuele Giuseppe
in the kvm//vcpu/mp_state file
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/x86/kvm/stats_fs.c | 54 +
1 file changed, 54 insertions(+)
diff --git a/arch/x86/kvm/stats_fs.c b/arch/x86/kvm/stats_fs.c
index f6edebb9c559..902be18562da 100644
--- a/arch
-by: Emanuele Giuseppe Esposito
---
fs/stats_fs/Makefile | 2 +-
fs/stats_fs/inode.c| 461 +
fs/stats_fs/internal.h | 15 ++
fs/stats_fs/stats_fs.c | 92 +++-
include/linux/stats_fs.h | 18 ++
include/uapi/linux/magic.h | 1 +
tools
/debugfs/kvm is left for backward compatibility.
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/arm64/kvm/Kconfig | 1 +
arch/arm64/kvm/guest.c | 2 +-
arch/mips/kvm/Kconfig | 1 +
arch/mips/kvm/mips.c| 2 +-
arch/powerpc/kvm/Kconfig| 1
Html docs for a complete documentation of the stats_fs API,
filesystem and usage.
Signed-off-by: Emanuele Giuseppe Esposito
---
Documentation/filesystems/index.rst| 1 +
Documentation/filesystems/stats_fs.rst | 222 +
2 files changed, 223 insertions(+)
create mode
the root
directory of the linux kernel source tree:
./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all`
Signed-off-by: Emanuele Giuseppe Esposito
---
fs/Kconfig |6 +
fs/stats_fs/Makefile |2 +
fs/stats_fs/stats_fs-tests.c | 1097
, the former calling it when it needs to
display and clear statistics, the latter to add values and sources.
Signed-off-by: Emanuele Giuseppe Esposito
---
MAINTAINERS | 7 +
fs/Kconfig | 14 +
fs/Makefile | 1 +
fs/stats_fs/Makefile | 5 +
fs/stats_fs
ttps://lore.kernel.org/kvm/5d6cdcb1-d8ad-7ae6-7351-3544e2fa3...@redhat.com/?fbclid=IwAR18LHJ0PBcXcDaLzILFhHsl3qpT3z2vlG60RnqgbpGYhDv7L43n0ZXJY8M
Signed-off-by: Emanuele Giuseppe Esposito
v2 -> v3 move kconfig entry in the pseudo filesystem menu, add
documentation, get/clear function for valu
On 5/8/20 11:44 AM, Paolo Bonzini wrote:
> So in general I'd say the sources/values model holds up. We certainly
> want to:
>
> - switch immediately to callbacks instead of the type constants (so that
> core statsfs code only does signed/unsigned)
>
> - add a field to distinguish cumulative
On 5/4/20 11:37 PM, David Rientjes wrote:
On Mon, 4 May 2020, Emanuele Giuseppe Esposito wrote:
In this patch series I introduce statsfs, a synthetic ram-based virtual
filesystem that takes care of gathering and displaying statistics for the
Linux kernel subsystems.
This is exciting, we
for stats_fs_source data structures, which are
protected by an rw_semaphore to allow concurrent sysfs reads.
Signed-off-by: Emanuele Giuseppe Esposito
---
include/linux/kref.h | 11 +++
include/linux/refcount.h | 2 ++
lib/refcount.c | 32
3 files
/debugfs/kvm is left for backward compatibility.
Signed-off-by: Emanuele Giuseppe Esposito
---
arch/arm64/kvm/Kconfig | 1 +
arch/arm64/kvm/guest.c | 2 +-
arch/mips/kvm/Kconfig | 1 +
arch/mips/kvm/mips.c| 2 +-
arch/powerpc/kvm/Kconfig| 1
by a virtual file system in patch 4.
Its usage will be shared between the stats_fs file system
and the end-users like kvm, the former calling it when it needs to
display and clear statistics, the latter to add values and sources.
Signed-off-by: Emanuele Giuseppe Esposito
---
MAINTAINERS
the root
directory of the linux kernel source tree:
./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all`
Signed-off-by: Emanuele Giuseppe Esposito
---
fs/Kconfig |6 +
fs/stats_fs/Makefile |2 +
fs/stats_fs/stats_fs-tests.c | 1088
, with the exception that the API is only
composed by stats_fs_create_file, stats_fs_create_dir and stats_fs_remove.
Signed-off-by: Emanuele Giuseppe Esposito
---
fs/stats_fs/Makefile | 2 +-
fs/stats_fs/inode.c| 337 +
fs/stats_fs/internal.h
FhHsl3qpT3z2vlG60RnqgbpGYhDv7L43n0ZXJY8M
Signed-off-by: Emanuele Giuseppe Esposito
v1->v2 remove unnecessary list_foreach_safe loops, fix wrong indentation,
change statsfs in stats_fs
Emanuele Giuseppe Esposito (5):
refcount, kref: add dec-and-test wrappers for rw_semaphores
stats_fs A
61 matches
Mail list logo