public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Schlameuss <schlameuss@linux.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kselftest@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Nina Schoetterl-Glausch <nsg@linux.ibm.com>
Subject: Re: [PATCH v2 03/10] selftests: kvm: s390: Add s390x ucontrol test suite with hpage test
Date: Wed, 24 Jul 2024 18:18:54 +0200	[thread overview]
Message-ID: <20240724181854.3da1f7da.schlameuss@linux.ibm.com> (raw)
In-Reply-To: <5df2d680-6d6c-43c8-8b69-e6ad7e4ac35a@linux.ibm.com>

On Wed, 24 Jul 2024 16:52:00 +0200
Janosch Frank <frankja@linux.ibm.com> wrote:

> On 7/23/24 11:31, Christoph Schlameuss wrote:
> > Add test suite to validate the s390x architecture specific ucontrol KVM
> > interface.
> > 
> > Make use of the selftest test harness.
> > 
> > * uc_cap_hpage testcase verifies that a ucontrol VM cannot be run with
> >    hugepages.
> > 
> > To allow testing of the ucontrol interface the kernel needs a
> > non-default config containing CONFIG_KVM_S390_UCONTROL.
> > This config needs to be set to built-in (y) as this cannot be built as
> > module.
> > 
> > Signed-off-by: Christoph Schlameuss <schlameuss@linux.ibm.com>
> > Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> > ---  
> 
> [...]
> 
> > +#include "kselftest_harness.h"
> > +#include "kvm_util.h"
> > +
> > +#include <linux/capability.h>
> > +#include <linux/sizes.h>
> > +
> > +#define SYS_ADMIN_CAP 0x200000  
> 
> This looked suspicious to me.
> Surely this would be available in some form in capability.h since 
> CAP_SYS_ADMIN is something that's regularly checked.
> 
> [...]
> 
> > +
> > +/* so directly declare capget to check caps without libcap */
> > +int capget(cap_user_header_t header, cap_user_data_t data);
> > +
> > +/**
> > + * In order to create user controlled virtual machines on S390,
> > + * check KVM_CAP_S390_UCONTROL and use the flag KVM_VM_S390_UCONTROL
> > + * as privileged user (SYS_ADMIN).
> > + */
> > +void require_ucontrol_admin(void)
> > +{
> > +	struct __user_cap_data_struct data[_LINUX_CAPABILITY_U32S_3];
> > +	struct __user_cap_header_struct hdr = {
> > +		.version = _LINUX_CAPABILITY_VERSION_3,
> > +	};
> > +	int rc;
> > +
> > +	rc = capget(&hdr, data);
> > +	TEST_ASSERT_EQ(0, rc);
> > +	TEST_REQUIRE((data->effective & SYS_ADMIN_CAP) > 0);  
> 
> And in fact capability.h does have defines which hide the magic constant:
> data->effective & CAP_TO_MASK(CAP_SYS_ADMIN)
> 

Yes, thank you, that is much better. Will use that instead and remove
the custom SYS_ADMIN_CAP define above.

> > +
> > +	TEST_REQUIRE(kvm_has_cap(KVM_CAP_S390_UCONTROL));
> > +}
> > +  
> 


  reply	other threads:[~2024-07-24 16:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23  9:31 [PATCH v2 00/10] selftests: kvm: s390: Add s390x ucontrol selftests Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 01/10] selftests: kvm: s390: Define page sizes in shared header Christoph Schlameuss
2024-07-24 14:31   ` Janosch Frank
2024-07-23  9:31 ` [PATCH v2 02/10] selftests: kvm: s390: Add kvm_s390_sie_block definition for userspace tests Christoph Schlameuss
2024-07-24 14:39   ` Janosch Frank
2024-07-24 16:07     ` Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 03/10] selftests: kvm: s390: Add s390x ucontrol test suite with hpage test Christoph Schlameuss
2024-07-24 14:52   ` Janosch Frank
2024-07-24 16:18     ` Christoph Schlameuss [this message]
2024-07-23  9:31 ` [PATCH v2 04/10] selftests: kvm: s390: Add test fixture and simple VM setup tests Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 05/10] selftests: kvm: s390: Add debug print functions Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 06/10] selftests: kvm: s390: Add VM run test case Christoph Schlameuss
2024-07-25 12:03   ` Janosch Frank
2024-07-25 14:07     ` Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 07/10] selftests: kvm: s390: Add uc_map_unmap VM " Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 08/10] selftests: kvm: s390: Add uc_skey " Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 09/10] selftests: kvm: s390: Verify reject memory region operations for ucontrol VMs Christoph Schlameuss
2024-07-23  9:31 ` [PATCH v2 10/10] s390: Enable KVM_S390_UCONTROL config in debug_defconfig Christoph Schlameuss
2024-07-23  9:40   ` Christian Borntraeger
2024-07-23 12:48     ` Christoph Schlameuss

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=20240724181854.3da1f7da.schlameuss@linux.ibm.com \
    --to=schlameuss@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nsg@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=shuah@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox