lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 19 Apr 2024 16:49:14 +0100
From: David Woodhouse <dwmw2@...radead.org>
To: paul@....org, kvm@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>, Jonathan Corbet <corbet@....net>, 
 Sean Christopherson <seanjc@...gle.com>, Thomas Gleixner
 <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov
 <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
 "H. Peter Anvin" <hpa@...or.com>,  Shuah Khan <shuah@...nel.org>,
 linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-kselftest@...r.kernel.org, Oliver Upton <oliver.upton@...ux.dev>, 
 Marcelo Tosatti <mtosatti@...hat.com>, jalliste@...zon.co.uk,
 sveith@...zon.de
Subject: Re: [PATCH 03/10] KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for accurate
 KVM clock migration

On Fri, 2024-04-19 at 16:40 +0100, Paul Durrant wrote:
> 
> > +        * If KVM_REQ_CLOCK_UPDATE is already pending, or if the
> > hv_clock has
> > +        * never been generated at all, call
> > kvm_guest_time_update() to do so.
> > +        * Might as well use the PVCLOCK_TSC_STABLE_BIT as the
> > check for ever
> > +        * having been written.
> > +        */
> > +       if (kvm_check_request(KVM_REQ_CLOCK_UPDATE, v) ||
> > +           !(hv_clock->flags & PVCLOCK_TSC_STABLE_BIT)) {
> > +               if (kvm_guest_time_update(v))
> > +                       return -EINVAL;
> 
> nit: simple nested if, so you could use &&

Yeah, I frowned at that a bit, and decided I preferred it this way just
to highlight the fact that kvm_guest_time_update() is doing a *thing*.
And then we bail with -EINVAL if that thing fails.

If you stick it all in the if() statement, the code flow is logically
the same but it's just a bit less obvious that there are side-effects
here in the middle of the conditions, and that those side-effects are
actually the *main* point of the statement.


Download attachment "smime.p7s" of type "application/pkcs7-signature" (5965 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ