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] [thread-next>] [day] [month] [year] [list]
Message-Id: <4F509CE30200007800075F84@nat28.tlf.novell.com>
Date:	Fri, 02 Mar 2012 09:11:47 +0000
From:	"Jan Beulich" <JBeulich@...e.com>
To:	"Alex Shi" <alex.shi@...el.com>
Cc:	<jeremy@...p.org>,
	"asit.k.mallick@...el.com" <asit.k.mallick@...el.com>,
	"x86@...nel.org" <x86@...nel.org>, <tglx@...utronix.de>,
	"Andi Kleen" <ak@...ux.intel.com>,
	"mingo@...hat.com" <mingo@...hat.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"hpa@...or.com" <hpa@...or.com>
Subject: Re: [RFC patch] cmpxchg_double: remove local variables to get
 better performance

>>> On 02.03.12 at 10:00, Alex Shi <alex.shi@...el.com> wrote:
> Yes, we can use cast for intermediate data. And actually, current kernel
> has live mis-used case on cmpxchg(), that I plan to point out too. 
> 
> -- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -203,12 +203,12 @@ static bool make_all_cpus_request(struct kvm *kvm, 
> unsigned int req)
> 
>  void kvm_flush_remote_tlbs(struct kvm *kvm)
>  {
> -       int dirty_count = kvm->tlbs_dirty;
> +       long dirty_count = kvm->tlbs_dirty;
> 
>         smp_mb();
>         if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH))
>                 ++kvm->stat.remote_tlb_flush;
> -       cmpxchg(&kvm->tlbs_dirty, dirty_count, 0);
> +       cmpxchg(&kvm->tlbs_dirty, dirty_count, 0L);

Indeed - the cmpxchg would fail if the value doesn't fit. But this is not
to say that in certain cases it isn't valid to pass an int for the second
and/or third argument. (And quite likely the issue here is theoretical
only anyway.)

In particular, requiring an L suffix here on literals should be avoided.

Jan

>  }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ