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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <47a766451de248718d2a9bec47dda86e@AcuMS.aculab.com>
Date:   Thu, 30 Apr 2020 13:18:10 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Paolo Bonzini' <pbonzini@...hat.com>,
        'Jim Mattson' <jmattson@...gle.com>
CC:     'LKML' <linux-kernel@...r.kernel.org>,
        'kvm list' <kvm@...r.kernel.org>,
        'Sean Christopherson' <sean.j.christopherson@...el.com>,
        'Joerg Roedel' <joro@...tes.org>,
        "'everdox@...il.com'" <everdox@...il.com>
Subject: RE: [PATCH] KVM: x86: handle wrap around 32-bit address space

From: Paolo Bonzini <pbonzini@...hat.com>
> Sent: 30 April 2020 13:45
> On 29/04/20 10:56, David Laight wrote:
> >>>> +               if (unlikely(((rip ^ orig_rip) >> 31) == 3) && !is_64_bit_mode(vcpu))
> >> Isn't the more obvious:
> >> 	if (((rip ^ orig_rip) & 1ull << 32) ...
> >> equivalent?
> 
> This one would not (it would also detect carry on high memory addresses,
> not just 0x7fffffff to 0x80000000)...

So will the proposed one half the time.
If (orig_rip & 1 << 32) is zero the high bits are all unchanged
and cancel out.

> > Actually not even being clever, how about:
> > 	if (orig_rip < (1ull << 32) && unlikely(rip >= (1ull << 32)) && ...
> 
> ... but yes this one would be equivalent.

If sub 4G addresses are likely on 64bit you may want to do:
	if (unlikely((rip ^ orig_rip) & (1ull << 32)) && orig_rip < (1ull << 32)) && ...
or unlikely((rip ^ orig_rip) >> 32)

I think you always want unlikely(a) && b rather than unlikely(a && b).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ