All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Manali Shukla <manali.shukla@amd.com>
Cc: pbonzini@redhat.com, kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v2 1/4] x86: nSVM: Move common functionality of the main() to helper run_svm_tests
Date: Wed, 13 Apr 2022 20:28:50 +0000	[thread overview]
Message-ID: <Ylcyghve/NZ2jlwx@google.com> (raw)
In-Reply-To: <20220324053046.200556-2-manali.shukla@amd.com>

On Thu, Mar 24, 2022, Manali Shukla wrote:
> nSVM tests are "incompatible" with usermode due to __setup_vm()
> call in main function.
> 
> If __setup_vm() is replaced with setup_vm() in main function, KUT
> will build the test with PT_USER_MASK set on all PTEs.
> 
> nNPT tests will be moved to their own file so that the tests
> don't need to fiddle with page tables midway through.
> 
> The quick and dirty approach would be to turn the current main()
> into a small helper, minus its call to __setup_vm() and call the
> helper function run_svm_tests() from main() function.
> 
> No functional change intended.
> 
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Manali Shukla <manali.shukla@amd.com>
> ---
>  x86/svm.c | 14 +++++++++-----
>  x86/svm.h |  1 +
>  2 files changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/x86/svm.c b/x86/svm.c
> index 3f94b2a..e93e780 100644
> --- a/x86/svm.c
> +++ b/x86/svm.c
> @@ -406,17 +406,13 @@ test_wanted(const char *name, char *filters[], int filter_count)
>          }
>  }
>  
> -int main(int ac, char **av)
> +int run_svm_tests(int ac, char **av)
>  {
> -	/* Omit PT_USER_MASK to allow tested host.CR4.SMEP=1. */
> -	pteval_t opt_mask = 0;
>  	int i = 0;
>  
>  	ac--;
>  	av++;
>  
> -	__setup_vm(&opt_mask);
> -
>  	if (!this_cpu_has(X86_FEATURE_SVM)) {
>  		printf("SVM not availble\n");
>  		return report_summary();
> @@ -453,3 +449,11 @@ int main(int ac, char **av)
>  
>  	return report_summary();
>  }
> +
> +int main(int ac, char **av)
> +{
> +    pteval_t opt_mask = 0;

Please use tabs, not spaces.  Looks like this file is an unholy mess of tabs and
spaces.  And since we're riping this file apart, let's take the opportunity to
clean it up.  How about after moving code to svm_npt.c, go through and replace
all spaces with tabs and fixup indentation as appropriate in this file?

> +
> +    __setup_vm(&opt_mask);
> +    return run_svm_tests(ac, av);
> +}
> diff --git a/x86/svm.h b/x86/svm.h
> index f74b13a..9ab3aa5 100644
> --- a/x86/svm.h
> +++ b/x86/svm.h
> @@ -398,6 +398,7 @@ struct regs {
>  
>  typedef void (*test_guest_func)(struct svm_test *);
>  
> +int run_svm_tests(int ac, char **av);
>  u64 *npt_get_pte(u64 address);
>  u64 *npt_get_pde(u64 address);
>  u64 *npt_get_pdpe(void);
> -- 
> 2.30.2
> 

  reply	other threads:[~2022-04-13 20:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24  5:30 [kvm-unit-tests PATCH v2 0/4] Move npt test cases and NPT code improvements Manali Shukla
2022-03-24  5:30 ` [kvm-unit-tests PATCH v2 1/4] x86: nSVM: Move common functionality of the main() to helper run_svm_tests Manali Shukla
2022-04-13 20:28   ` Sean Christopherson [this message]
2022-04-14 16:42     ` Shukla, Manali
2022-03-24  5:30 ` [kvm-unit-tests PATCH v2 2/4] x86: nSVM: Move all nNPT test cases from svm_tests.c to a separate file Manali Shukla
2022-03-24  5:30 ` [kvm-unit-tests PATCH v2 3/4] x86: nSVM: Allow nSVM tests run with PT_USER_MASK enabled Manali Shukla
2022-03-24  5:30 ` [kvm-unit-tests PATCH v2 4/4] x86: nSVM: Build up the nested page table dynamically Manali Shukla
2022-04-13 21:33   ` Sean Christopherson
2022-04-14 16:39     ` Shukla, Manali
2022-03-24 15:58 ` [kvm-unit-tests PATCH v2 0/4] Move npt test cases and NPT code improvements Maxim Levitsky

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=Ylcyghve/NZ2jlwx@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=manali.shukla@amd.com \
    --cc=pbonzini@redhat.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.