All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: ahmeddan@amazon.com, kvm@vger.kernel.org,
	nikos.nikoleris@arm.com, drjones@redhat.com, graf@amazon.com
Subject: Re: [kvm-unit-tests PATCH v2 3/3] x86/msr.c generalize to any input msr
Date: Fri, 15 Oct 2021 17:57:37 +0200	[thread overview]
Message-ID: <8df06ec3-85a7-caae-04dc-6096de632e6f@redhat.com> (raw)
In-Reply-To: <20210927153028.27680-3-ahmeddan@amazon.com>

On 27/09/21 17:30, ahmeddan@amazon.com wrote:
> From: Daniele Ahmed <ahmeddan@amazon.com>
> 
> If an MSR description is provided as input by the user,
> run the test against that MSR. This allows the user to
> run tests on custom MSR's.
> 
> Otherwise run all default tests.
> 
> This is to validate custom MSR handling in user space
> with an easy-to-use tool. This kvm-unit-test submodule
> is a perfect fit. I'm extending it with a mode that
> takes an MSR index and a value to test arbitrary MSR accesses.
> 
> Signed-off-by: Daniele Ahmed <ahmeddan@amazon.com>

Queued, thanks.  I removed the "64-bit only" functionality because, for 
manual invocation, you can just not run the test when running on 32-bit 
targets.

Paolo

> ---
>   x86/msr.c | 29 +++++++++++++++++++++++++++--
>   1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/x86/msr.c b/x86/msr.c
> index 8931f59..1a2d791 100644
> --- a/x86/msr.c
> +++ b/x86/msr.c
> @@ -3,6 +3,17 @@
>   #include "libcflat.h"
>   #include "processor.h"
>   #include "msr.h"
> +#include <stdlib.h>
> +
> +/**
> + * This test allows two modes:
> + * 1. Default: the `msr_info' array contains the default test configurations
> + * 2. Custom: by providing command line arguments it is possible to test any MSR and value
> + *	Parameters order:
> + *		1. msr index as a base 16 number
> + *		2. value as a base 16 number
> + *		3. "0" if the msr is available only in 64b hosts, any other string otherwise
> + */
>   
>   struct msr_info {
>   	int index;
> @@ -100,8 +111,22 @@ int main(int ac, char **av)
>   	bool is_64bit_host = this_cpu_has(X86_FEATURE_LM);
>   	int i;
>   
> -	for (i = 0 ; i < ARRAY_SIZE(msr_info); i++) {
> -		test_msr(&msr_info[i], is_64bit_host);
> +	if (ac == 4) {
> +		char msr_name[16];
> +		int index = strtoul(av[1], NULL, 0x10);
> +		snprintf(msr_name, sizeof(msr_name), "MSR:0x%x", index);
> +
> +		struct msr_info msr = {
> +			.index = index,
> +			.name = msr_name,
> +			.is_64bit_only = !strcmp(av[3], "0"),
> +			.value = strtoull(av[2], NULL, 0x10)
> +		};
> +		test_msr(&msr, is_64bit_host);
> +	} else {
> +		for (i = 0 ; i < ARRAY_SIZE(msr_info); i++) {
> +			test_msr(&msr_info[i], is_64bit_host);
> +		}
>   	}
>   
>   	return report_summary();
> 


  parent reply	other threads:[~2021-10-15 15:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 14:31 [kvm-unit-tests PATCH] x86/msr.c generalize to any input msr yqwfh
2021-09-23  9:11 ` Alexander Graf
2021-09-23  9:32   ` Paolo Bonzini
2021-09-27 15:30   ` [kvm-unit-tests PATCH v2 1/3] lib/string: Add stroull and strtoll ahmeddan
2021-09-27 15:30     ` [kvm-unit-tests PATCH v2 2/3] [kvm-unit-tests PATCH] x86/msr.c refactor out generic test logic ahmeddan
2021-09-27 15:38       ` Alexander Graf
2021-09-27 15:30     ` [kvm-unit-tests PATCH v2 3/3] x86/msr.c generalize to any input msr ahmeddan
2021-09-28 15:36       ` Paolo Bonzini
2021-10-01 14:14         ` Ahmed, Daniele
2021-10-15 15:57       ` Paolo Bonzini [this message]
2021-10-13 16:44     ` [kvm-unit-tests PATCH v2 1/3] lib/string: Add stroull and strtoll Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8df06ec3-85a7-caae-04dc-6096de632e6f@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ahmeddan@amazon.com \
    --cc=drjones@redhat.com \
    --cc=graf@amazon.com \
    --cc=kvm@vger.kernel.org \
    --cc=nikos.nikoleris@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.