lkml.org 
[lkml]   [2021]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 5.10 049/101] KVM: selftests: Fix kvm_check_cap() assertion
 Hi Pavel,

On Sat, Jul 3, 2021 at 4:21 PM Pavel Machek <pavel@denx.de> wrote:
>
> Hi!
>
> > From: Fuad Tabba <tabba@google.com>
> >
> > [ Upstream commit d8ac05ea13d789d5491a5920d70a05659015441d ]
> >
> > KVM_CHECK_EXTENSION ioctl can return any negative value on error,
> > and not necessarily -1. Change the assertion to reflect that.
> >
> > Signed-off-by: Fuad Tabba <tabba@google.com>
>
> This is userland code, right?
>
> > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> > @@ -55,7 +55,7 @@ int kvm_check_cap(long cap)
> > exit(KSFT_SKIP);
> >
> > ret = ioctl(kvm_fd, KVM_CHECK_EXTENSION, cap);
> > - TEST_ASSERT(ret != -1, "KVM_CHECK_EXTENSION IOCTL failed,\n"
> > + TEST_ASSERT(ret >= 0, "KVM_CHECK_EXTENSION IOCTL failed,\n"
> > " rc: %i errno: %i", ret, errno);

There's at least one case that I am aware of that potentially would
return a value other than -1 on error, which is a check for
KVM_CAP_MSI_DEVID (-EINVAL, -22):

https://elixir.bootlin.com/linux/latest/source/arch/arm64/kvm/arm.c#L229

Also, considering that this is test code, it might be good to have the
check be as strict as possible.

Cheers,
/fuad

> And syscalls return -1 on error in userland, not anything else. So
> this should not be needed.
>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

\
 
 \ /
  Last update: 2021-07-05 09:11    [W:0.107 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site