Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756029AbXJBS15 (ORCPT ); Tue, 2 Oct 2007 14:27:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753331AbXJBS1u (ORCPT ); Tue, 2 Oct 2007 14:27:50 -0400 Received: from mx1.redhat.com ([66.187.233.31]:43750 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753059AbXJBS1t (ORCPT ); Tue, 2 Oct 2007 14:27:49 -0400 Message-ID: <47028D99.8020100@redhat.com> Date: Tue, 02 Oct 2007 14:27:37 -0400 From: Chuck Ebbert Organization: Red Hat User-Agent: Thunderbird 1.5.0.12 (X11/20070719) MIME-Version: 1.0 To: Arjan van de Ven CC: Kirill Korotaev , Andrew Morton , Andi Kleen , Linux Kernel Mailing List , devel@openvz.org Subject: Re: [PATCH] mark read_crX() asm code as volatile References: <470250E0.5090706@openvz.org> <20071002082856.3c478e66@laptopd505.fenrus.org> In-Reply-To: <20071002082856.3c478e66@laptopd505.fenrus.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1167 Lines: 37 On 10/02/2007 11:28 AM, Arjan van de Ven wrote: > On Tue, 02 Oct 2007 18:08:32 +0400 > Kirill Korotaev wrote: > >> Some gcc versions (I checked at least 4.1.1 from RHEL5 & 4.1.2 from >> gentoo) can generate incorrect code with read_crX()/write_crX() >> functions mix up, due to cached results of read_crX(). >> > > I'm not so sure volatile is the right answer, as compared to giving the > asm more strict contraints.... > > asm volatile tends to mean something else than "the result has > changed".... It means "don't eliminate this code if it's reachable" which should be just enough for this case. But it could still be reordered in some cases that could break, I think. This should work because the result gets used before reading again: read_cr3(a); write_cr3(a | 1); read_cr3(a); But this might be reordered so that b gets read before the write: read_cr3(a); write_cr3(a | 1); read_cr3(b); ? - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/